http://robotgymnast.pastebin.com/f2dfe9b18 http://robotgymnast.pastebin.com/f602de748 http://robotgymnast.pastebin.com/f42c1d70c
My program is basically a DLL, and it gets hooked into different programs (but I'm not sure at compile time exactly what the programs will be), so it's using functors to call functions that it knows are inside the program it gets hooked into.
Oh, and a UID is basically just user ID in a DWORD, nothing special. It's also part of the original program.
Anyway, I'm having a problem: the following code snippet:
// if alt+U is pressed
if(alt('U'))
{
// the UID string
char UID[11] = {0};
// the actual UID value
DWORD ID = 0;
// create a functor for the UID (basically it returns a UID and takes no parameters)
MUID(__cdecl* func)(void) = ZGetMyUID();
__asm
{
// call the UID function
call func;
// get the UID return value
mov eax,dword ptr ds:[eax+4];
// move it from the register to memory
mov ID,eax;
}
// convert the UID to a string
_itoa_s(ID,UID,sizeof(UID),10);
// output the UID
ZChatOutput()(UID,1,0,0xCC0033);
// pause
SleepEx(150,false);
}
works perfectly fine.. the functor might be a bit confusing; it's part of a large program.
however, changing to
void UIDTest()
{
// the UID string
char UID[11] = {0};
// the actual UID value
DWORD ID = 0;
// create a functor for the UID (basically it returns a UID and takes no parameters)
MUID(__cdecl* func)(void) = ZGetMyUID();
__asm
{
// call the UID function
call func;
// get the UID return value
mov eax,dword ptr ds:[eax+4];
// move it from the register to memory
mov ID,eax;
}
// convert the UID to a string
_itoa_s(ID,UID,sizeof(UID),10);
// output the UID
ZChatOutput()(UID,1,0,0xCC0033);
// pause
SleepEx(150,false);
}
...
...
...
// if alt+U is pressed
if(alt('U'))
{
// the UID test function, just checking if it works
UIDTest();
}
ends up crashing the program. After using a debugger (OllyDBG), I've found it crashes after returning from UIDTest(), right on the RETN statement (in ASM), because it tries to return to the value in ID (or more accurately, it's jumping to a location equivalent to the value in ID.. It's not coming directly from ID). Now, I've tried commenting out some of the lines to get this:
void UIDTest()
{
// the UID string
char UID[11] = {0};
// the actual UID value
DWORD ID = 0;
// create a functor for the UID (basically it returns a UID and takes no parameters)
MUID(__cdecl* func)(void) = ZGetMyUID();
__asm
{
// call the UID function
call func;
}
// convert the UID to a string
_itoa_s(ID,UID,sizeof(UID),10);
// output the UID
ZChatOutput()(UID,1,0,0xCC0033);
// pause
SleepEx(150,false);
}
and it crashes. I'm fairly sure it's being caused by the function call, because the function doesn't know it should be called (because the DLL isn't actually part of the program). That's my theory. It's storing something where it SHOULD be fine, but it's not because the DLL wasn't built like the main program was.
Oh, and weirdly, turning UIDTest() into an inline void doesn't help at ALL. Shouldn't that basically make it the same as the first code snippet? It still crashes when it's an inline void.


Sign In
Create Account


Back to top









