forked from TeamTofuShop/segatools
Modify host header in HTTP requests to bypass domain censorship in China. (#34)
Co-authored-by: Sanheiii <35133371+Sanheiii@users.noreply.github.com> Reviewed-on: Dniel97/segatools#34 Co-authored-by: Sanhei <sanhei@noreply.gitea.tendokyu.moe> Co-committed-by: Sanhei <sanhei@noreply.gitea.tendokyu.moe>
This commit is contained in:
34
util/get_function_ordinal.c
Normal file
34
util/get_function_ordinal.c
Normal file
@ -0,0 +1,34 @@
|
||||
#include "get_function_ordinal.h"
|
||||
|
||||
DWORD get_function_ordinal(const char* dllName, const char* functionName) {
|
||||
HMODULE hModule = LoadLibraryA(dllName);
|
||||
if (!hModule) {
|
||||
dprintf("Failed to load DLL: %s\n", dllName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ULONG size;
|
||||
PIMAGE_EXPORT_DIRECTORY exportDir = (PIMAGE_EXPORT_DIRECTORY)ImageDirectoryEntryToData(
|
||||
hModule, TRUE, IMAGE_DIRECTORY_ENTRY_EXPORT, &size);
|
||||
if (!exportDir) {
|
||||
dprintf("Failed to get export table\n");
|
||||
FreeLibrary(hModule);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD* functionNames = (DWORD*)((BYTE*)hModule + exportDir->AddressOfNames);
|
||||
WORD* ordinals = (WORD*)((BYTE*)hModule + exportDir->AddressOfNameOrdinals);
|
||||
|
||||
for (DWORD i = 0; i < exportDir->NumberOfNames; ++i) {
|
||||
char* name = (char*)((BYTE*)hModule + functionNames[i]);
|
||||
if (strcmp(name, functionName) == 0) {
|
||||
DWORD ordinal = ordinals[i] + exportDir->Base;
|
||||
FreeLibrary(hModule);
|
||||
return ordinal;
|
||||
}
|
||||
}
|
||||
|
||||
dprintf("Function not found: %s\n", functionName);
|
||||
FreeLibrary(hModule);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user