Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PE symbols enumeration procedure improper #269

Open
s0duku opened this issue Dec 27, 2024 · 0 comments
Open

PE symbols enumeration procedure improper #269

s0duku opened this issue Dec 27, 2024 · 0 comments

Comments

@s0duku
Copy link

s0duku commented Dec 27, 2024

https://github.com/rdbo/libmem/blob/fa4d3552c9d6d4d7044044e2d9ae996e0f165eb6/src/win/symbol.c

...
export_names = (DWORD *)(modbase + pexportdir->AddressOfNames);
export_funcs = (DWORD *)(modbase + pexportdir->AddressOfFunctions);

for (i = 0; i < pexportdir->NumberOfNames && i < pexportdir->NumberOfFunctions; ++i) {
		symbol.name = (lm_string_t)(modbase + export_names[i]);
		symbol.address = (lm_address_t)(module->base + export_funcs[i]);

...

When I try to hook ntdll.dll function, it failed to find the right address, It seems like LM_EnumSymbols did not handle exportdir->AddressOfOrdinals field.

I believe it should change to this

...
export_names = (DWORD *)(modbase + pexportdir->AddressOfNames);
export_funcs = (DWORD *)(modbase + pexportdir->AddressOfFunctions);
export_ordinals = (WORD *)(modbase + pexportdir->AddressOfOrdinals);

for (i = 0; i < pexportdir->NumberOfNames && i < pexportdir->NumberOfFunctions; ++i) {
		symbol.name = (lm_string_t)(modbase + export_names[i]);
		symbol.address = (lm_address_t)(module->base + export_funcs[export_ordinals [i]]);
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant