I'm trying to export a completely clean function name, this is because I need to use it within GetProcAddress (2nd parameter). I know this is possible as if you test dumpbin against Kernel32 it will display clean function names.
I have looked around found numerous "solutions", and I have gotten my mangled name from jibberish to:
1 0 00001810 SomeFunction = _SomeFunction
However I need it to look like:
1 0 00001810 SomeFunction
This would allow me to call it from the GetProcAddress function, as I can't get it to work with a "Mangled" name.
Here is how I'm defining it:
extern "C" __declspec(dllexport) void SomeFunction(void * SomeArguments)
{
//Function Content
}
With a module definition file, it's useless... I get a totally mangled name. Using this way, I can get it nearly there however the '_' is preventing GetProcAddress resolving my function name to a address.
Module Definition output:
1 0 00001810 SomeFunction = ?SomeFunction@@YAXPAX@Z (void __cdecl SomeFunction(void *))
EDIT: (If you mean the function aboves content... it's simply a message box MessageBoxA()... there can't be anything wrong there.)
GetProcAddressLine:
LPVOID SomeFunctionAddr = (LPVOID)GetProcAddress(GetModuleHandleA("Pies.dll"), "SomeFunction");
Full "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);