From 519cd5c5770fbb1f77ca40a48122922344df5f6f Mon Sep 17 00:00:00 2001 From: Michael Dirks Date: Wed, 30 Dec 2015 04:12:21 +0100 Subject: [PATCH] Upgrade to VS2015, implement variable pointers. Signed-off-by: Michael Dirks --- BlitzPointer.cpp | 18 ++++++++--- BlitzPointer.decls | 7 +++-- BlitzPointer.h | 2 +- BlitzPointer.vcxproj | 6 ++-- BlitzPointer.vcxproj.filters | 60 ++++++++++++++++++------------------ 5 files changed, 52 insertions(+), 41 deletions(-) diff --git a/BlitzPointer.cpp b/BlitzPointer.cpp index b4aa510..17b03a4 100644 --- a/BlitzPointer.cpp +++ b/BlitzPointer.cpp @@ -63,11 +63,19 @@ DLL_METHOD intptr_t DLL_CALL BP_GetFunctionPointer() } #pragma comment(linker, "/EXPORT:BP_GetFunctionPointer=_BP_GetFunctionPointer@0") -DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointer() { - // ToDo: Figure out how to get the pointer of a variable reliably. Must do so without Goto. - // - Idea: Have user assign variable to the ptr first? Easier to find. - // - Strings are difficult - exclude these? - return 0; +DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointer(int32_t pVariable) +{ + intptr_t StackPointer, ReturnAddress; + + __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. + } + // The Variable pointer that is used is at -9 bytes offset to the return address. + return *reinterpret_cast(ReturnAddress - 9); } #pragma comment(linker, "/EXPORT:BP_GetVariablePointer=_BP_GetVariablePointer@0") diff --git a/BlitzPointer.decls b/BlitzPointer.decls index 355b680..0749a95 100644 --- a/BlitzPointer.decls +++ b/BlitzPointer.decls @@ -19,7 +19,10 @@ ; BlitzPointer BP_GetReturnAddress%() BP_GetFunctionPointer%() -BP_GetVariablePointer%() +;BP_GetVariablePointer%() +BP_GetVariablePointerInt%(pVariable%) : "BP_GetVariablePointer" +BP_GetVariablePointerFloat%(pVariable#) : "BP_GetVariablePointer" +BP_GetVariablePointerType%(pVariable*) : "BP_GetVariablePointer" ; Memory Modification PeekMemoryByte%(lpMemoryPointer%) @@ -1125,4 +1128,4 @@ BP_CallFunctionIFPPPP%(Float#, Pointer*, Pointer*, Pointer*, Pointer*): "BP_Call BP_CallFunctionFFPPPP#(Float#, Pointer*, Pointer*, Pointer*, Pointer*): "BP_CallFunction5" BP_CallFunctionVPPPPP(Pointer*, Pointer*, Pointer*, Pointer*, Pointer*): "BP_CallFunction5" BP_CallFunctionIPPPPP%(Pointer*, Pointer*, Pointer*, Pointer*, Pointer*): "BP_CallFunction5" -BP_CallFunctionFPPPPP#(Pointer*, Pointer*, Pointer*, Pointer*, Pointer*): "BP_CallFunction5" +BP_CallFunctionFPPPPP#(Pointer*, Pointer*, Pointer*, Pointer*, Pointer*): "BP_CallFunction5" \ No newline at end of file diff --git a/BlitzPointer.h b/BlitzPointer.h index 0f37d0a..6eb6bb6 100644 --- a/BlitzPointer.h +++ b/BlitzPointer.h @@ -29,7 +29,7 @@ typedef int32_t(__stdcall *BP_BlitzFunction5_t)(int32_t, int32_t, int32_t, int32 // Basic Functionality (Pointer retrieval) DLL_METHOD intptr_t DLL_CALL BP_GetReturnAddress(); DLL_METHOD intptr_t DLL_CALL BP_GetFunctionPointer(); -DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointer(); +DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointer(int32_t pVariable); // Native Blitz Function Calls DLL_METHOD int32_t DLL_CALL BP_CallFunction0(BP_BlitzFunction0_t lpFunctionPointer); diff --git a/BlitzPointer.vcxproj b/BlitzPointer.vcxproj index ca0e1c4..07cac11 100644 --- a/BlitzPointer.vcxproj +++ b/BlitzPointer.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,13 +18,13 @@ DynamicLibrary true - v120 + v140 Unicode DynamicLibrary false - v120 + v140 false Unicode diff --git a/BlitzPointer.vcxproj.filters b/BlitzPointer.vcxproj.filters index f3b6ebc..6a6639d 100644 --- a/BlitzPointer.vcxproj.filters +++ b/BlitzPointer.vcxproj.filters @@ -39,41 +39,41 @@ - - Blitz Files - - - Blitz Files - - - Blitz Files - - - Blitz Files - - - Blitz Files - - - Blitz Files - - - Blitz Files - - - Blitz Files - - - Blitz Files - - - Blitz Files - Resource Files Resource Files + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + \ No newline at end of file