So this is what I've got so far... And I'm not even sure it will work. I haven't tried it yet. I'm afraid to, lol. Some of this is borrowed from starfish99's contribution: http://www.mmowned.com/forums/wow-me...et-result.html
Code:
string GetUnitGUID(string UnitID)
{
HANDLE Handle = OpenProcess(PROCESS_ALL_ACCESS,FALSE,HBAI.Instance[HBAI.CurrentWoWInstance].PID);
string localGUID;
//UnitGUID LUA Function address
DWORD UnitGUID = 0x00565370;
//lua state address
DWORD LUAStateAddress = 0x012E87EC;
//get arguments from lua stack
DWORD LUAGetString = 0x007AD920;
DWORD LUAGetNumber = 0x007AD870;
//push results to lua stack
DWORD LUAPushString = 0x007ADB90;
DWORD LUAPushNumber = 0x007ADAE0;
DWORD LUAPushNil = 0x007ADAC0;
//this address shows which addon is call lua function, the value is addon's name(string)
DWORD CallingAddon = 0x012EA330;
//Make WoW Think the blizz UI is calling this one
MemoryWriteInt(Handle,CallingAddon,0);
//Call the LUA Function UnitGUID
MemoryWriteDWORD(Handle,LUAStateAddress,UnitGUID);
//Add the UnitID to the parameters
MemoryWriteString(Handle,LUAPushString,UnitID);
//Get the results!
localGUID = MemoryReadString(Handle,LUAGetString);
CloseHandle(Handle);
return localGUID;
}
Code:
void MemoryWriteInt(HANDLE Handle, DWORD WriteAddress, int ValueToWrite)
{
SIZE_T BytesToWrite = sizeof ValueToWrite;
SIZE_T BytesWritten;
WriteProcessMemory(Handle,(LPVOID)WriteAddress,ValueToWrite,BytesToWrite,&BytesWritten);
}
void MemoryWriteDWORD(HANDLE Handle, DWORD WriteAddress, DWORD ValueToWrite)
{
SIZE_T BytesToWrite = sizeof ValueToWrite;
SIZE_T BytesWritten;
WriteProcessMemory(Handle,(LPVOID)WriteAddress,ValueToWrite,BytesToWrite,&BytesWritten);
}
string MemoryReadString(HANDLE Handle, DWORD ReadAddress)
{
SIZE_T BytesRead;
int BytesToRead = sizeof(ReadAddress);
string ContentsOfAddress;
ReadProcessMemory(Handle,(LPCVOID)ReadAddress,&ContentsOfAddress,BytesToRead,&BytesRead);
return ContentsOfAddress;
}
void MemoryWriteString(HANDLE Handle, DWORD WriteAddress, string ValueToWrite)
{
SIZE_T BytesToWrite = sizeof ValueToWrite;
SIZE_T BytesWritten;
WriteProcessMemory(Handle,(LPVOID)WriteAddress,ValueToWrite,BytesToWrite,&BytesWritten);
}
The concept: A unit ID (such as "player") goes in, and that unit's GUID comes out.
Can it be done this way? Or do I have to use ASM? I couldn't figure out how to translate starfish99's code to C++ or else I'd have done it exactly as shown.
Also, if ASM is the only way to do this... *sigh* ... How?