Upgrade to VS2015, implement variable pointers.

Signed-off-by: Michael Dirks <michael.fabian.dirks@gmail.com>
This commit is contained in:
Michael Dirks
2015-12-30 04:12:21 +01:00
parent 4b428b4535
commit 519cd5c577
5 changed files with 52 additions and 41 deletions
+13 -5
View File
@@ -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<int32_t*>(ReturnAddress - 9);
}
#pragma comment(linker, "/EXPORT:BP_GetVariablePointer=_BP_GetVariablePointer@0")
+5 -2
View File
@@ -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"
+1 -1
View File
@@ -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);
+3 -3
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -18,13 +18,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
+30 -30
View File
@@ -39,41 +39,41 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Blitz\Example05.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Blitz\BlitzPointer.decls">
<Filter>Blitz Files</Filter>
</None>
<None Include="Blitz\BlitzPointer.ipf">
<Filter>Blitz Files</Filter>
</None>
<None Include="Blitz\Example_Shared.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Blitz\Example01.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Blitz\Example02.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Blitz\Example03.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Blitz\Example04.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Blitz\Example06.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Blitz\Example07.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="LICENSE">
<Filter>Resource Files</Filter>
</None>
<None Include="LICENSE.lesser">
<Filter>Resource Files</Filter>
</None>
<None Include="BlitzPointer.decls">
<Filter>Blitz Files</Filter>
</None>
<None Include="Examples\BlitzPointer.ipf">
<Filter>Blitz Files</Filter>
</None>
<None Include="Examples\Example_Shared.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Examples\Example01.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Examples\Example02.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Examples\Example03.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Examples\Example04.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Examples\Example05.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Examples\Example06.bb">
<Filter>Blitz Files</Filter>
</None>
<None Include="Examples\Example07.bb">
<Filter>Blitz Files</Filter>
</None>
</ItemGroup>
</Project>