|
楼主 |
发表于 2013-5-16 18:41:12
|
显示全部楼层
本帖最后由 bigfatcat 于 2013-5-16 18:42 编辑
Skyline 发表于 2013-5-16 13:48
兄台,问一下你这段代码想实现啥功能啊????
已经搞定了,读取系统进程的pid号
你懂的,然后你就可以
写了一个win32的版本,目前还在改,有很多地方有错:
- .386
- .model flat,stdcall
- option casemap:none
- include windows.inc
- include user32.inc
- includelib user32.lib
- include kernel32.inc
- includelib kernel32.lib
- .const
- szCaption db '失败了',0
- szText db '调用CreateToolhelp32Snapshot失败',0
- .code
- _Process proc uses eax ebx edi esi
- local @stPe32:PROCESSENTRY32
- local @stPinfo:PROCESS_INFORMATION
- mov @stPe32.dwSize,sizeof @stPe32
- invoke CreateToolhelp32Snapshot,TH32CS_SNAPPROCESS,NULL
- .if eax == INVALID_HANDLE_VALUE
- invoke MessageBox,NULL,offset szText,\
- offset szCaption,MB_OK
- .endif
- mov ebx,eax
- invoke Process32First,ebx,addr @stPe32
- .while eax
- invoke MessageBox,NULL,@stPe32.szExeFile,offset szCaption,MB_OK
- invoke MessageBox,NULL,@stPe32.th32ProcessID,offset szCaption,MB_OK
- .endw
- invoke CloseHandle,ebx
- ret
- _Process endp
- start:
- call _Process
- invoke ExitProcess,NULL
- end start
复制代码- #include<windows.h>
- #include<tlhelp32.h>
- #include "stdio.h"
- int main(int argc,char * argv[])
- {
- PROCESSENTRY32 pe32;
- pe32.dwSize = sizeof(pe32);
- HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
- if (hProcessSnap == INVALID_HANDLE_VALUE)
- {
- printf("CreateToolhelp32Snapshot 调用失败! \n");
- return -1;
- }
- BOOL bResult = Process32First(hProcessSnap, &pe32);
- while(bResult)
- {
- printf("进程名称:%s \n",pe32.szExeFile);
- printf("进程ID: %u \n",pe32.th32ProcessID);
- bResult = Process32Next(hProcessSnap, &pe32);
- }
- CloseHandle(hProcessSnap);
- return 0;
- }
复制代码
|
|