-find_in_any_module_using_psapi (const gchar *symbol_name)
-{
- static HMODULE psapi = NULL;
-
- typedef BOOL (WINAPI *PFNENUMPROCESSMODULES) (HANDLE, HMODULE *, DWORD, LPDWORD) ;
- static PFNENUMPROCESSMODULES pfnEnumProcessModules = NULL;
-
- HMODULE *modules;
- HMODULE dummy;
- gint i, size;
- DWORD needed;
-
- gpointer p;
-
- if (!pfnEnumProcessModules)
- {
- if (!psapi)
- if ((psapi = LoadLibrary ("psapi.dll")) == NULL)
- return NULL;
-
- if (!(pfnEnumProcessModules = (PFNENUMPROCESSMODULES) GetProcAddress (psapi, "EnumProcessModules")))
- return NULL;
- }
-
- if (!(*pfnEnumProcessModules) (GetCurrentProcess (), &dummy,
- sizeof (HMODULE), &needed))
- return NULL;
-
- size = needed + 10 * sizeof (HMODULE);
- modules = g_malloc (size);
-
- if (!(*pfnEnumProcessModules) (GetCurrentProcess (), modules,
- size, &needed)
- || needed > size)
- {
- g_free (modules);
- return NULL;
- }
-
- p = NULL;
- for (i = 0; i < needed / sizeof (HMODULE); i++)
- if ((p = GetProcAddress (modules[i], symbol_name)) != NULL)
- break;
-
- g_free (modules);
-
- return p;
-}
-
-static gpointer