网站首页  词典首页

请输入您要查询的函数:

 

术语 enumprocessmodules
释义 EnumProcessModules
语法:
C++
BOOL WINAPI EnumProcessModules(
__in HANDLE hProcess,
__out HMODULE *lphModule,
__in DWORD cb,
__out LPDWORD lpcbNeeded
);
EnumProcessModules函数
检索处理的每个指定的进程模块。
要控制是否64位应用程序列举的32位模块,64位模块,或两种类型的模块,使用EnumProcessModulesEx功能。
参数
hProcess [in]
句柄的进程。
lphModule [out]
数组接收模块列表的句柄。
文件 [in]
该lphModule数组的大小,以字节为单位。
lpcbNeeded [out]
所需的所有模块存储字节数在lphModule句柄数组。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
该EnumProcessModules功能主要是用来通过调试器和类似的应用程序必须提取从另一个进程模块信息的使用。如果在目标进程模块列表已损坏或尚未初始化,或者如果在作为结果的DLL函数调用模块列表的变化被加载或卸载,EnumProcessModules可能失败或返回不正确的信息。
这是一个好主意,指定一个HMODULE价值较大的数组,因为它是难以预料的模块,有多少会在这个过程将在调用EnumProcessModules时间。要确定是否lphModule数组太小,不能容纳所有模块的进程处理,比较在文件中指定的值lpcbNeeded返回的值。如果lpcbNeeded大于文件,增加数组的大小,并呼吁EnumProcessModules了。
为了确定有多少模块被调用到EnumProcessModules枚举,在分裂的sizeof(HMODULE)lpcbNeeded参数得到的值。
该EnumProcessModules函数不检索处理对那些与LOAD_LIBRARY_AS_DATAFILE标志加载的模块。有关更多信息,请参阅LoadLibraryEx。
不要要求任何CloseHandle的处理这个函数返回。这些信息来自一个快照,所以没有被释放的资源。
如果这个功能是从32位应用程序在WOW64下运行要求,只能列举的32位进程的模块。如果该进程是一个64位进程,这个函数失败,最后错误代码是ERROR_PARTIAL_COPY(299)。
采取的具体过程和堆,模块快照,这些进程使用的线程,使用CreateToolhelp32Snapshot函数。
与PSAPI版本的Windows 7和Windows Server 2008 R2的2起,这个函数被定义为K32EnumProcessModules在Psapi.h和Kernel32.lib和Kernel32.dll出口。但是,您应该始终作为EnumProcessModules调用此函数。为了确保对程序将运行在Windows的早期版本的符号的正确决议,添加Psapi.lib到TARGETLIBS宏和编译程序与- DPSAPI_VERSION = 1。
实例
有关示例,请参见枚举枚举所有进程,或者一个进程的所有模块。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderPsapi.h
LibraryKernel32.lib在Windows 7和Windows Server 2008 R2的Psapi.lib在Windows Server 2008,Windows Vista中的Windows Server 2003,和Windows XP/2000
DLLKernel32.dll在Windows 7和Windows Server 2008 R2的Psapi.dll在Windows Server 2008,Windows Vista中的Windows Server 2003,和Windows XP/2000
参见
CreateToolhelp32Snapshot
EnumProcesses
EnumProcessModulesEx
模块信息
PSAPI函数
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==EnumProcessModules Function
Retrieves a handle for each module in the specified process.
To control whether a 64-bit application enumerates 32-bit modules, 64-bit modules, or both types of modules, use the EnumProcessModulesEx function.
Syntax
C++
BOOL WINAPI EnumProcessModules(
__in HANDLE hProcess,
__out HMODULE *lphModule,
__in DWORD cb,
__out LPDWORD lpcbNeeded
);
Parameters
hProcess [in]
A handle to the process.
lphModule [out]
An array that receives the list of module handles.
cb [in]
The size of the lphModule array, in bytes.
lpcbNeeded [out]
The number of bytes required to store all module handles in the lphModule array.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
Remarks
The EnumProcessModules function is primarily designed for use by debuggers and similar applications that must extract module information from another process. If the module list in the target process is corrupted or not yet initialized, or if the module list changes during the function call as a result of DLLs being loaded or unloaded, EnumProcessModules may fail or return incorrect information.
It is a good idea to specify a large array of HMODULE values, because it is hard to predict how many modules there will be in the process at the time you call EnumProcessModules. To determine if the lphModule array is too small to hold all module handles for the process, compare the value returned in lpcbNeeded with the value specified in cb. If lpcbNeeded is greater than cb, increase the size of the array and call EnumProcessModules again.
To determine how many modules were enumerated by the call to EnumProcessModules, divide the resulting value in the lpcbNeeded parameter by sizeof(HMODULE).
The EnumProcessModules function does not retrieve handles for modules that were loaded with the LOAD_LIBRARY_AS_DATAFILE flag. For more information, see LoadLibraryEx .
Do not call CloseHandle on any of the handles returned by this function. The information comes from a snapshot, so there are no resources to be freed.
If this function is called from a 32-bit application running on WOW64, it can only enumerate the modules of a 32-bit process. If the process is a 64-bit process, this function fails and the last error code is ERROR_PARTIAL_COPY (299).
To take a snapshot of specified processes and the heaps, modules, and threads used by these processes, use the CreateToolhelp32Snapshot function.
Starting with PSAPI version 2 for Windows 7 and Windows Server 2008 R2, this function is defined as K32EnumProcessModules in Psapi.h and exported in Kernel32.lib and Kernel32.dll. However, you should always call this function as EnumProcessModules. To ensure correct resolution of symbols for programs that will run on earlier versions of Windows, add Psapi.lib to the TARGETLIBS macro and compile the program with –DPSAPI_VERSION=1.
Examples
For an example, see Enumerating All Processes or Enumerating All Modules for a Process .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderPsapi.h
LibraryKernel32.lib on Windows 7 and Windows Server 2008 R2, Psapi.lib on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP/2000
DLLKernel32.dll on Windows 7 and Windows Server 2008 R2, Psapi.dll on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP/2000
See Also
CreateToolhelp32Snapshot
EnumProcesses
EnumProcessModulesEx
Module Information
PSAPI Functions
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms682631(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:19:17