Hello, I'm trying to implement LoadLibrary and GetProcAddress in AngleScript.
uint64_t asLoadLibrary(string& library)
{
return (uint64_t)LoadLibraryA(library.c_str());
}
uint64_t asGetProcAddress(uint64_t* modulePTR, string& msg)
{
return (uint64_t)GetProcAddress((HMODULE)*modulePTR, msg.c_str());
}
This functions works great, Here's how I use it in AngleScript :
uint64 user32Module = asLoadLibrary("user32.dll");
asPrint(LogType::Default, " > User32.dll Module " + asPtrAsString(user32Module) + "\n");
uint64 messageBoxFuncAddress = asGetProcAddress(user32Module, "MessageBoxA");
asPrint(LogType::Default, " > MessageBoxA Addr " + asPtrAsString(messageBoxFuncAddress) + "\n");
Results are fine but now I don't know how to call this function dynamically, I added funcdef in global scope :
// Function Definitions
funcdef int MSGBOX(uint64, string, string, uint);
I tried to cast it but it doesn't work :
MSGBOX@ msgboxFunc = cast<MSGBOX@>(messageBoxFuncAddress);
How can I achieve this?
Also I have a side question, When passing user32Module
to asGetProcAddress
why modulePTR
it have to be uint64_t* and not uint64_t?
Thanks