gpt4 book ai didi

c++ - 列出所有正在运行的应用程序 MASM32 程序集

转载 作者:太空宇宙 更新时间:2023-11-04 13:00:42 25 4
gpt4 key购买 nike

美好的一天!我一直在尝试列出所有当前正在运行的应用程序并使用 masm 将其写入文本文件。我是 assembly 新手,但使用 MSDN 作为我的引用。到目前为止,我知道如何使用 CreateFile、WriteFile、ReadFile 等,但我不明白 Process32First 是如何工作的。

我正在尝试将此链接中的代码转换为 MASM,( https://msdn.microsoft.com/en-us/library/windows/desktop/ms686701(v=vs.85).aspx ) 但运气不好,我无法获得任何输出。

我将非常感谢任何帮助!谢谢你!祝你有美好的一天。

include \masm32\include\masm32rt.inc

.data
pe32 PROCESSENTRY32 <>
errorCreateTool db "ERROR: CreateToolhelp32Snapshot", 0
errorPF db "ERROR: Process32First", 0
errorOP db "ERROR: OpenProcess", 0

yesMsg db "proceed", 0

.data?
dwPriorityClass dd ?
hProcessSnap HANDLE ?
hProcess HANDLE ?

.code

_start:

push 0
push TH32CS_SNAPPROCESS
call CreateToolhelp32Snapshot

mov hProcessSnap, eax

cmp hProcessSnap, INVALID_HANDLE_VALUE
je _errorCT

mov pe32.dwSize, sizeof PROCESSENTRY32

push offset pe32
push hProcessSnap
call Process32FirstW

cmp eax, ERROR_NO_MORE_FILES
je _errorPF

push offset pe32.szExeFile
call StdOut

mov dwPriorityClass, 0

push offset pe32.th32ProcessID
push FALSE
push PROCESS_ALL_ACCESS
call OpenProcess

cmp eax, 00H ;if I comment this out, the code will proceed
je _errorOpen

push offset pe32.th32ProcessID ;but this doesn't have any value and doesn't print out
call StdOut
push offset yesMsg ;while this prints out on the console
call StdOut

jmp _done

_errorOpen:
push offset errorOP
call StdOut
jmp _done

_errorPF:
push offset errorPF
call StdOut
jmp _done

_errorCT:
push offset errorCreateTool
call StdOut

_done:
push 0
call ExitProcess

end _start

最佳答案

我有使用该功能的经验。我所要做的就是按照您的建议更新我的 kernel32.inc 和 kernel32p.inc。完成这些操作后,我运行 masm32 文件夹中的 makelibs.bat,它从那里运行。

关于c++ - 列出所有正在运行的应用程序 MASM32 程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44304175/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com