diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2013-11-19 15:14:36 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2013-11-19 15:14:36 +0400 |
commit | 700a3783ee4912e1000347bcde2116863507fbbd (patch) | |
tree | 11f2da2b17bc9a6044b79bb9c067ac3beff2355a /winsup/utils/module_info.cc | |
parent | e576e42013c4e62db3bb9fd5e9b539048bf537af (diff) |
* Makefile.in (cygcheck.exe): Link against wininet.dll.
(dumper.exe): Link against psapi.dll.
* cygcheck.cc (_WIN32_WINNT): Define as 0x0602.
(pInternetCloseHandle): Drop pointer.
(PRODUCT_UNLICENSED): Drop definition.
(PRODUCT_PROFESSIONAL_WMC): Ditto.
(package_grep): Delete code loading wininet functions dynamically, just
call functions directly.
Diffstat (limited to 'winsup/utils/module_info.cc')
-rw-r--r-- | winsup/utils/module_info.cc | 51 |
1 files changed, 4 insertions, 47 deletions
diff --git a/winsup/utils/module_info.cc b/winsup/utils/module_info.cc index 12e74de39..1437da421 100644 --- a/winsup/utils/module_info.cc +++ b/winsup/utils/module_info.cc @@ -15,20 +15,6 @@ details. */ #include <psapi.h> #include "loadlib.h" -static int psapi_loaded = 0; -static HMODULE psapi_module_handle = NULL; - -typedef BOOL WINAPI (tf_EnumProcessModules) (HANDLE, HMODULE *, DWORD, - LPDWORD); -typedef BOOL WINAPI (tf_GetModuleInformation) (HANDLE, HMODULE, LPMODULEINFO, - DWORD); -typedef DWORD WINAPI (tf_GetModuleFileNameExA) (HANDLE, HMODULE, LPSTR, - DWORD); - -static tf_EnumProcessModules *psapi_EnumProcessModules = NULL; -static tf_GetModuleInformation *psapi_GetModuleInformation = NULL; -static tf_GetModuleFileNameExA *psapi_GetModuleFileNameExA = NULL; - /* Returns full name of Dll, which is loaded by hProcess at BaseAddress. Uses psapi.dll. */ @@ -45,41 +31,14 @@ psapi_get_module_name (HANDLE hProcess, LPVOID BaseAddress) char name_buf[MAX_PATH + 1]; - if (!psapi_loaded || - psapi_EnumProcessModules == NULL || - psapi_GetModuleInformation == NULL || - psapi_GetModuleFileNameExA == NULL) - { - if (psapi_loaded) - goto failed; - psapi_loaded = 1; - psapi_module_handle = LoadLibrary ("psapi.dll"); - if (!psapi_module_handle) - goto failed; - psapi_EnumProcessModules = - (tf_EnumProcessModules *) GetProcAddress (psapi_module_handle, - "EnumProcessModules"); - psapi_GetModuleInformation = - (tf_GetModuleInformation *) GetProcAddress (psapi_module_handle, - "GetModuleInformation"); - psapi_GetModuleFileNameExA = - (tf_GetModuleFileNameExA *) GetProcAddress (psapi_module_handle, - "GetModuleFileNameExA"); - if (psapi_EnumProcessModules == NULL - || psapi_GetModuleInformation == NULL - || psapi_GetModuleFileNameExA == NULL) - goto failed; - } - - ok = (*psapi_EnumProcessModules) (hProcess, - DllHandle, sizeof (HMODULE), &cbNeeded); + ok = EnumProcessModules (hProcess, DllHandle, sizeof (HMODULE), &cbNeeded); if (!ok || !cbNeeded) goto failed; DllHandle = (HMODULE *) malloc (cbNeeded); if (!DllHandle) goto failed; - ok = (*psapi_EnumProcessModules) (hProcess, DllHandle, cbNeeded, &cbNeeded); + ok = EnumProcessModules (hProcess, DllHandle, cbNeeded, &cbNeeded); if (!ok) { free (DllHandle); @@ -88,15 +47,13 @@ psapi_get_module_name (HANDLE hProcess, LPVOID BaseAddress) for (i = 0; i < cbNeeded / sizeof (HMODULE); i++) { - if (!(*psapi_GetModuleInformation) (hProcess, - DllHandle[i], &mi, sizeof (mi))) + if (!GetModuleInformation (hProcess, DllHandle[i], &mi, sizeof (mi))) { free (DllHandle); goto failed; } - len = (*psapi_GetModuleFileNameExA) (hProcess, - DllHandle[i], name_buf, MAX_PATH); + len = GetModuleFileNameExA (hProcess, DllHandle[i], name_buf, MAX_PATH); if (len == 0) { free (DllHandle); |