我正在尝试导出一个完全干净的函数名称,这是因为我需要在 GetProcAddress (第二个参数)中使用它。我知道这是可能的,就像您针对 Kernel32 测试 dumpbin 一样,它将显示干净的函数名称。
我环顾四周发现了许多“解决方案”,并且我已经将我的名字从乱码变成了:
1 0 00001810 SomeFunction = _SomeFunction
但是我需要它看起来像:
1 0 00001810 某功能
这将允许我从 GetProcAddress 函数调用它,因为我无法让它与“Mangled”名称一起使用。
这是我定义它的方式:
extern "C" __declspec(dllexport) void SomeFunction(void * SomeArguments)
{
//Function Content
}
使用模块定义文件,它没用......我得到了一个完全错误的名字。使用这种方式,我几乎可以得到它,但是“_”阻止 GetProcAddress 将我的函数名称解析为地址。
模块定义输出:
1 0 00001810 SomeFunction = ?SomeFunction@@YAXPAX@Z (void __cdecl SomeFunction(void *))
编辑:(如果你的意思是上面的功能......它只是一个消息框MessageBoxA()......那里不可能有任何问题。)
GetProcAddressLine:
LPVOID SomeFunctionAddr = (LPVOID)GetProcAddress(GetModuleHandleA("Pies.dll"), "SomeFunction");
完整的“GetProcAddress”:
LPVOID SomeFunctionAddr = (LPVOID)GetProcAddress(GetModuleHandleA("Pies.dll"), "SomeFunction");
if (!SomeFunctionAddr)
{
std::cout << "Failed to obtain SomeFunction Address!\n";
return 0;
}
Allocate = VirtualAllocEx(Handle, NULL, strlen(Path), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
WriteProcessMemory(Handle, Allocate, Path, strlen(Path), NULL);
Thread = CreateRemoteThread(Handle, NULL, NULL, (LPTHREAD_START_ROUTINE)SomeFunctionAddr, Allocate, 0, NULL);
WaitForSingleObject(Thread, INFINITE);
VirtualFreeEx(Handle, Thread, strlen(Path), MEM_RELEASE);