Skip to content

Commit

Permalink
removed debug logs from windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbo committed Apr 11, 2024
1 parent 2260007 commit e81521b
Showing 1 changed file with 1 addition and 35 deletions.
36 changes: 1 addition & 35 deletions src/win/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,76 +45,42 @@ LM_EnumSymbols(const lm_module_t *module,
DWORD i;
lm_symbol_t symbol;

printf("ENUM SYMBOLS CALLED\n");
fflush(stdout);

if (!module || !callback)
return result;

printf("ARGUMENTS CHECKED\n");
fflush(stdout);

if (!utf8towcs(module->path, wpath, LM_PATH_MAX))
return result;

printf("UTF8 CONVERTED TO WCS\n");
fflush(stdout);

/* Attempt to get the module handle without loading the library */
hmod = GetModuleHandleW(wpath);
printf("ATTEMPTED TO GET HMODULE: %p\n", (void *)hmod);
fflush(stdout);
if (!hmod) {
printf("HMODULE NOT FOUND, ATTEMPING TO LOAD LIBRARY\n");
fflush(stdout);
/* Load library purely for getting resources, and not executing */
hmod = LoadLibraryExW(wpath, NULL, DONT_RESOLVE_DLL_REFERENCES);
printf("LIBRARY LOADED: %p\n", (void *)hmod);
fflush(stdout);
if (!hmod)
return result;

is_loaded = TRUE;
}
printf("STARTED SYMBOL ENUMERATION\n");
fflush(stdout);

/*
* From: https://learn.microsoft.com/en-us/windows/win32/api/psapi/ns-psapi-moduleinfo
*
* "The load address of a module is the same as the HMODULE value."
*/
modbase = (lm_address_t)hmod;
printf("MODBASE: %p\n", (void *)modbase);
fflush(stdout);

modbase = (lm_address_t)hmod;
pdoshdr = (PIMAGE_DOS_HEADER)modbase;
pnthdr = (PIMAGE_NT_HEADERS)(modbase + (lm_address_t)pdoshdr->e_lfanew);
printf("NTHDR: %p\n", (void *)pnthdr);
fflush(stdout);

pexportdir = (PIMAGE_EXPORT_DIRECTORY)(
modbase + pnthdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress
);
printf("EXPORT DIR: %p\n", (void *)pexportdir);
fflush(stdout);

export_names = (DWORD *)(modbase + pexportdir->AddressOfNames);
printf("EXPORT_NAMES: %p\n", (void *)export_names);
fflush(stdout);

export_funcs = (DWORD *)(modbase + pexportdir->AddressOfFunctions);
printf("EXPORT_FUNCS: %p\n", export_funcs);
fflush(stdout);

for (i = 0; i < pexportdir->NumberOfNames && i < pexportdir->NumberOfFunctions; ++i) {
symbol.name = (lm_string_t)(modbase + export_names[i]);
printf("SYMBOL NAME: %s\n", symbol.name);
fflush(stdout);

symbol.address = (lm_address_t)(module->base + export_funcs[i]);
printf("SYMBOL ADDRESS: %p\n", symbol.address);
fflush(stdout);

if (callback(&symbol, arg) == LM_FALSE)
break;
Expand Down

0 comments on commit e81521b

Please sign in to comment.