Skip to content

Commit

Permalink
fixed issues on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbo committed Mar 5, 2024
1 parent 72de297 commit 21ed44e
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/win/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ LM_EnumSymbols(const lm_module_t *module,
lm_void_t *arg)
{
lm_bool_t result = LM_FALSE;
WCHAR *wpath;
BOOL is_loaded = FALSE;
HMODULE hmod;
lm_address_t modbase;
Expand All @@ -43,23 +44,29 @@ LM_EnumSymbols(const lm_module_t *module,
DWORD i;
lm_symbol_t symbol;

wpath = wcstoutf8(module->path, NULL, 0);
if (!wpath)
return result;

/* Attempt to get the module handle without loading the library */
hmod = GetModuleHandle(module->path);
printf("GETTING MODULE HANLDE\n");
hmod = GetModuleHandleW(module->path);
/* WARN: 'wpath' MUST BE FREE'd unconditionally inside the following conditional blocks */
if (!hmod) {
WCHAR *wpath;

wpath = wcstoutf8(module->path, NULL, 0);
if (!wpath)
return result;

/* Load library purely for getting resources, and not executing */
hmod = LoadLibraryExW(module->path, NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE);
printf("LOADING LIB\n");
hmod = LoadLibraryExW(wpath, NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE);
free(wpath);

if (!hmod)
return result;

printf("MODULE LOADED\n");

is_loaded = TRUE;
} else {
printf("GOT HANDLE\n");
free(wpath);
}

/*
Expand Down

0 comments on commit 21ed44e

Please sign in to comment.