- Simplify assembler instructions so that we mess around less.
This commit is contained in:
+7
-15
@@ -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<int32_t*>(ReturnAddress - 9);
|
||||
return *reinterpret_cast<int32_t*>(*reinterpret_cast<intptr_t*>(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<int32_t*>(ReturnAddress - 11);
|
||||
// The Variable pointer that is used is at -11 bytes offset to the return address.
|
||||
return *reinterpret_cast<int32_t*>(*reinterpret_cast<intptr_t*>(BasePointer + 4) - 11);
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:BP_GetVariablePointerType=_BP_GetVariablePointerType@4")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user