句柄就是当前进程的私有的一张表里的索引
每个进程都有一张表,称为句柄表。这张表属于进程自己的,操作系统也有一张表,较全局句柄表,这张表中包含了当前操作系统中正在运行的所有的进程和线程,表里的结构和局部的句柄表没有太大的区别。
cBOOL CreateProcess( LPCTSTR lpApplicationName, // name of executable module LPTSTR lpCommandLine, // command line string LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD BOOL bInheritHandles, // handle inheritance option **DWORD dwCreationFlags, // creation flags** LPVOID lpEnvironment, // new environment block LPCTSTR lpCurrentDirectory, // current directory name LPSTARTUPINFO lpStartupInfo, // startup information LPPROCESS_INFORMATION lpProcessInformation // process information );
c<1> 任何进程都是别的进程创建的:CreateProcess() <2> 进程的创建过程 1、映射EXE文件 2、创建内核对象EPROCESS 3、映射系统DLL(ntdll.dll) 4、创建线程内核对象ETHREAD 5、如果是挂起的方式创建的: 。。。 6、恢复以后再继续执行 映射DLL(ntdll.LdrInitializeThunk) 线程开始执行
cchar strModule[256]; GetModuleFileName(NULL,strModule, 256); //得到当前模块目录,获取当前exe所在的路径 char strWork[1000]; int i=1000; GetCurrentDirectory(1000,buf); //获取当前工作目录 printf("模块目录:%s \n工作目录:%s \n",strModule,strWork);
c获取进程PID GetCurrentProcessId 获取进程句柄 GetCurrentProcess 获取命令行 GetCommandLine 获取启动信息 GetStartupInfo 遍历进程ID EnumProcesses 快照 CreateToolhelp32Snapshot
本文作者:Na1r
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!