diff --git a/BlitzPointer.cpp b/BlitzPointer.cpp index 014e1f8..8be968c 100644 --- a/BlitzPointer.cpp +++ b/BlitzPointer.cpp @@ -55,34 +55,26 @@ DLL_METHOD intptr_t DLL_CALL BP_GetFunctionPointer() DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointer(int32_t pVariable) { - intptr_t StackPointer, ReturnAddress; + intptr_t BasePointer; __asm { //ASM. Do touch if suicidal. - mov StackPointer, esp; // Store current Stack Pointer - mov esp, ebp; // On X86, EBP[0] is our own function and EBP[1] is the return address. - add esp, 4; // Which means that we can just take it from there into our own variable. - pop ReturnAddress; // Just like this. - mov esp, [StackPointer]; // And then reset the Stack Pointer. + mov BasePointer, ebp; // Store current BasePointer } // The Variable pointer that is used is at -9 bytes offset to the return address. - return *reinterpret_cast(ReturnAddress - 9); + return *reinterpret_cast(*reinterpret_cast(BasePointer + 4) - 9); } #pragma comment(linker, "/EXPORT:BP_GetVariablePointer=_BP_GetVariablePointer@4") DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointerType( int32_t pVariable ) { - intptr_t StackPointer, ReturnAddress; + intptr_t BasePointer; __asm { //ASM. Do touch if suicidal. - mov StackPointer, esp; // Store current Stack Pointer - mov esp, ebp; // On X86, EBP[0] is our own function and EBP[1] is the return address. - add esp, 4; // Which means that we can just take it from there into our own variable. - pop ReturnAddress; // Just like this. - mov esp, [StackPointer]; // And then reset the Stack Pointer. + mov BasePointer, ebp; // Store current BasePointer } - // The Variable pointer that is used is at -9 bytes offset to the return address. - return *reinterpret_cast(ReturnAddress - 11); + // The Variable pointer that is used is at -11 bytes offset to the return address. + return *reinterpret_cast(*reinterpret_cast(BasePointer + 4) - 11); } #pragma comment(linker, "/EXPORT:BP_GetVariablePointerType=_BP_GetVariablePointerType@4")