8 Commits

Author SHA1 Message Date
Michael Dirks 57c310b0fc - Simplify assembler instructions so that we mess around less. 2015-12-30 06:24:35 +01:00
Michael Dirks 88122a928a - Fixed BP_GetReturnAddress not returning the correct address.
- Changed BP_GetFunctionPointer to use intelligent stackframe reading instead of memory scanning (faster & safer).
2015-12-30 06:19:44 +01:00
Michael Dirks 49c7264893 Fix broken decls. 2015-12-30 05:23:34 +01:00
Michael Dirks 7cc0788e8b - Update Headers in files to match new owner.
- Update Example08.bb to be more detailed
- Added function to grab Type pointers (would previously crash).
2015-12-30 05:11:33 +01:00
Michael Dirks 95dd86e6af Add Example08 to the project, rewrite GetFunctionPointer started. 2015-12-30 04:14:53 +01:00
Michael Dirks 519cd5c577 Upgrade to VS2015, implement variable pointers.
Signed-off-by: Michael Dirks <michael.fabian.dirks@gmail.com>
2015-12-30 04:12:21 +01:00
Michael Dirks 4b428b4535 Add Example08 - usage of Variable Pointers 2015-12-30 04:05:25 +01:00
Michael Dirks 1ec8bc54dd 1.3.1 Update - Move files to new locations, parameter count increased to 5. 2015-06-20 23:47:21 +02:00
19 changed files with 1333 additions and 1213 deletions
File diff suppressed because it is too large Load Diff
+39 -32
View File
@@ -1,5 +1,5 @@
// BlitzPointer - Adding Pointers to Blitz. // BlitzPointer - Adding Pointers to Blitz.
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks) // Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as // it under the terms of the GNU Lesser General Public License as
@@ -15,61 +15,68 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// Idea take from Code by Noodoby<http://www.blitzforum.de/forum/viewtopic.php?t=31651> // Idea take from Code by Noodoby<http://www.blitzforum.de/forum/viewtopic.php?t=31651>
// New Code by Xaymar<http://project-kube.de> // New Code by Xaymar<http://xaymar.com>
#pragma once #pragma once
#include "BlitzPointer.h" #include "BlitzPointer.h"
DLL_METHOD intptr_t DLL_CALL BP_GetReturnAddress() { DLL_METHOD intptr_t DLL_CALL BP_GetReturnAddress() {
intptr_t StackPointer, ReturnAddress; intptr_t BasePointer, ReturnAddress;
__asm { //ASM. Do touch if suicidal. __asm { //ASM. Do touch if suicidal.
mov StackPointer, esp; // Store current Stack Pointer mov BasePointer, ebp; // Store current BasePointer
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.
} }
// Blitz uses X86 Call-Near (E8) instructions to call its own functions.
// We can simply deduce the Return Address like this because of that.
ReturnAddress = *reinterpret_cast<intptr_t*>(*reinterpret_cast<intptr_t*>(*reinterpret_cast<intptr_t*>(BasePointer)) - 8);
return ReturnAddress; return ReturnAddress;
} }
#pragma comment(linker, "/EXPORT:BP_GetReturnAddress=_BP_GetReturnAddress@0") #pragma comment(linker, "/EXPORT:BP_GetReturnAddress=_BP_GetReturnAddress@0")
DLL_METHOD intptr_t DLL_CALL BP_GetFunctionPointer() DLL_METHOD intptr_t DLL_CALL BP_GetFunctionPointer()
{ {
intptr_t StackPointer, ReturnAddress; intptr_t BasePointer, ReturnAddress, FunctionPointer;
__asm { //ASM. Do touch if suicidal. __asm { //ASM. Do touch if suicidal.
mov StackPointer, esp; // Store current Stack Pointer mov BasePointer, ebp; // Store current BasePointer
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.
} }
// Let's look backwards in memory for the function signature (0x53 0x56 0x57 0x55 0x89 0xE5) for at most one megabyte. // Blitz uses X86 Call-Near (E8) instructions to call its own functions.
uint8_t* startPtr = (uint8_t*)ReturnAddress; // We can simply deduce the Return Address like this because of that.
uint8_t* endPtr = (uint8_t*)(ReturnAddress - 1048576); ReturnAddress = *reinterpret_cast<intptr_t*>(*reinterpret_cast<intptr_t*>(*reinterpret_cast<intptr_t*>(BasePointer)) - 8);
for (uint8_t* curPtr = startPtr; curPtr != endPtr; curPtr--) { // And since it's a Call-Near, the call is offset to the return address.
if (*(curPtr) == 0x53) // push ebx FunctionPointer = ReturnAddress + *reinterpret_cast<intptr_t*>(ReturnAddress - 4);
if (*(curPtr + 1) == 0x56) // push esi
if (*(curPtr + 2) == 0x57) // push edi
if (*(curPtr + 3) == 0x55) // push ebp
if (*(curPtr + 4) == 0x89 && *(curPtr + 5) == 0xE5) // mov ebp,esp
return (intptr_t)curPtr;
}
return 0; return FunctionPointer;
} }
#pragma comment(linker, "/EXPORT:BP_GetFunctionPointer=_BP_GetFunctionPointer@0") #pragma comment(linker, "/EXPORT:BP_GetFunctionPointer=_BP_GetFunctionPointer@0")
DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointer() { DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointer(int32_t pVariable)
// 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. intptr_t BasePointer;
// - Strings are difficult - exclude these?
return 0; __asm { //ASM. Do touch if suicidal.
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*>(*reinterpret_cast<intptr_t*>(BasePointer + 4) - 9);
} }
#pragma comment(linker, "/EXPORT:BP_GetVariablePointer=_BP_GetVariablePointer@0") #pragma comment(linker, "/EXPORT:BP_GetVariablePointer=_BP_GetVariablePointer@4")
DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointerType( int32_t pVariable ) {
intptr_t BasePointer;
__asm { //ASM. Do touch if suicidal.
mov BasePointer, ebp; // Store current BasePointer
}
// 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")
DLL_METHOD int32_t DLL_CALL BP_CallFunction0(BP_BlitzFunction0_t lpFunctionPointer) { DLL_METHOD int32_t DLL_CALL BP_CallFunction0(BP_BlitzFunction0_t lpFunctionPointer) {
return lpFunctionPointer(); return lpFunctionPointer();
+1131
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -1,5 +1,5 @@
// BlitzPointer - Adding Pointers to Blitz. // BlitzPointer - Adding Pointers to Blitz.
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks) // Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as // it under the terms of the GNU Lesser General Public License as
@@ -29,7 +29,8 @@ typedef int32_t(__stdcall *BP_BlitzFunction5_t)(int32_t, int32_t, int32_t, int32
// Basic Functionality (Pointer retrieval) // Basic Functionality (Pointer retrieval)
DLL_METHOD intptr_t DLL_CALL BP_GetReturnAddress(); DLL_METHOD intptr_t DLL_CALL BP_GetReturnAddress();
DLL_METHOD intptr_t DLL_CALL BP_GetFunctionPointer(); 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);
DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointerType(int32_t pVariable);
// Native Blitz Function Calls // Native Blitz Function Calls
DLL_METHOD int32_t DLL_CALL BP_CallFunction0(BP_BlitzFunction0_t lpFunctionPointer); DLL_METHOD int32_t DLL_CALL BP_CallFunction0(BP_BlitzFunction0_t lpFunctionPointer);
+20 -14
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?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"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
@@ -18,13 +18,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
@@ -61,7 +61,7 @@
<BasicRuntimeChecks>Default</BasicRuntimeChecks> <BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck> <BufferSecurityCheck>false</BufferSecurityCheck>
<FunctionLevelLinking>false</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<CompileAsManaged>false</CompileAsManaged> <CompileAsManaged>false</CompileAsManaged>
<CompileAsWinRT>false</CompileAsWinRT> <CompileAsWinRT>false</CompileAsWinRT>
<StructMemberAlignment>4Bytes</StructMemberAlignment> <StructMemberAlignment>4Bytes</StructMemberAlignment>
@@ -83,6 +83,7 @@
<FloatingPointExceptions>false</FloatingPointExceptions> <FloatingPointExceptions>false</FloatingPointExceptions>
<UseUnicodeForAssemblerListing>true</UseUnicodeForAssemblerListing> <UseUnicodeForAssemblerListing>true</UseUnicodeForAssemblerListing>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -163,56 +164,61 @@
<Link>BlitzPointer.LICENSE.lesser</Link> <Link>BlitzPointer.LICENSE.lesser</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="Blitz\BlitzPointer.decls"> <None Include="BlitzPointer.decls">
<Link>BlitzPointer.decls</Link> <Link>BlitzPointer.decls</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
</None> </None>
<None Include="Blitz\BlitzPointer.ipf"> <None Include="Examples\BlitzPointer.ipf">
<Link>Examples\BlitzPointer.ipf</Link> <Link>Examples\BlitzPointer.ipf</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
</None> </None>
<None Include="Blitz\Example_Shared.bb"> <None Include="Examples\Example_Shared.bb">
<Link>Examples\Example_Shared.bb</Link> <Link>Examples\Example_Shared.bb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
</None> </None>
<None Include="Blitz\Example01.bb"> <None Include="Examples\Example01.bb">
<Link>Examples\Example01.bb</Link> <Link>Examples\Example01.bb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
</None> </None>
<None Include="Blitz\Example02.bb"> <None Include="Examples\Example02.bb">
<Link>Examples\Example02.bb</Link> <Link>Examples\Example02.bb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
</None> </None>
<None Include="Blitz\Example03.bb"> <None Include="Examples\Example03.bb">
<Link>Examples\Example03.bb</Link> <Link>Examples\Example03.bb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
</None> </None>
<None Include="Blitz\Example04.bb"> <None Include="Examples\Example04.bb">
<Link>Examples\Example04.bb</Link> <Link>Examples\Example04.bb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
</None> </None>
<None Include="Blitz\Example05.bb"> <None Include="Examples\Example05.bb">
<Link>Examples\Example05.bb</Link> <Link>Examples\Example05.bb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
</None> </None>
<None Include="Blitz\Example06.bb"> <None Include="Examples\Example06.bb">
<Link>Examples\Example06.bb</Link> <Link>Examples\Example06.bb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
</None> </None>
<None Include="Blitz\Example07.bb"> <None Include="Examples\Example07.bb">
<Link>Examples\Example07.bb</Link> <Link>Examples\Example07.bb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
</None> </None>
<None Include="Examples\Example08.bb">
<Link>Examples\Example08.bb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
</None>
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
+44 -25
View File
@@ -8,6 +8,18 @@
<Filter Include="Blitz Files"> <Filter Include="Blitz Files">
<UniqueIdentifier>{53eae672-7e3f-4de4-af1f-79e46e407a39}</UniqueIdentifier> <UniqueIdentifier>{53eae672-7e3f-4de4-af1f-79e46e407a39}</UniqueIdentifier>
<ParseFiles>false</ParseFiles> <ParseFiles>false</ParseFiles>
<Extensions>bb;decls;ipf</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{527b3491-2ee2-474d-863f-2d21b7abb958}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{df5bf7dd-7995-49a8-b534-f2c83a65ad87}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Blitz Files\Examples">
<UniqueIdentifier>{2045f2b8-f3b8-4e65-80eb-459d4e00cd5a}</UniqueIdentifier>
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -22,45 +34,52 @@
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="dllmain.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="BlitzPointer.h"> <ClInclude Include="BlitzPointer.h">
<Filter>Source Files</Filter> <Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="dllmain.h">
<Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Blitz\Example05.bb"> <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> <Filter>Blitz Files</Filter>
</None> </None>
<None Include="Blitz\BlitzPointer.decls"> <None Include="Examples\Example_Shared.bb">
<Filter>Blitz Files</Filter> <Filter>Blitz Files\Examples</Filter>
</None> </None>
<None Include="Blitz\BlitzPointer.ipf"> <None Include="Examples\Example01.bb">
<Filter>Blitz Files</Filter> <Filter>Blitz Files\Examples</Filter>
</None> </None>
<None Include="Blitz\Example_Shared.bb"> <None Include="Examples\Example02.bb">
<Filter>Blitz Files</Filter> <Filter>Blitz Files\Examples</Filter>
</None> </None>
<None Include="Blitz\Example01.bb"> <None Include="Examples\Example03.bb">
<Filter>Blitz Files</Filter> <Filter>Blitz Files\Examples</Filter>
</None> </None>
<None Include="Blitz\Example02.bb"> <None Include="Examples\Example04.bb">
<Filter>Blitz Files</Filter> <Filter>Blitz Files\Examples</Filter>
</None> </None>
<None Include="Blitz\Example03.bb"> <None Include="Examples\Example05.bb">
<Filter>Blitz Files</Filter> <Filter>Blitz Files\Examples</Filter>
</None> </None>
<None Include="Blitz\Example04.bb"> <None Include="Examples\Example06.bb">
<Filter>Blitz Files</Filter> <Filter>Blitz Files\Examples</Filter>
</None> </None>
<None Include="Blitz\Example06.bb"> <None Include="Examples\Example07.bb">
<Filter>Blitz Files</Filter> <Filter>Blitz Files\Examples</Filter>
</None> </None>
<None Include="Blitz\Example07.bb"> <None Include="Examples\Example08.bb">
<Filter>Blitz Files</Filter> <Filter>Blitz Files\Examples</Filter>
</None>
<None Include="Examples\BlitzPointer.ipf">
<Filter>Blitz Files\Examples</Filter>
</None> </None>
<None Include="LICENSE" />
<None Include="LICENSE.lesser" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+1 -1
View File
@@ -1,5 +1,5 @@
; BlitzPointer - Adding Pointers to Blitz. ; BlitzPointer - Adding Pointers to Blitz.
; Copyright (C) 2015 Project Kube (Michael Fabian Dirks) ; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
; ;
; This program is free software: you can redistribute it and/or modify ; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as ; it under the terms of the GNU Lesser General Public License as
+1 -1
View File
@@ -1,5 +1,5 @@
; BlitzPointer - Adding Pointers to Blitz. ; BlitzPointer - Adding Pointers to Blitz.
; Copyright (C) 2015 Project Kube (Michael Fabian Dirks) ; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
; ;
; This program is free software: you can redistribute it and/or modify ; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as ; it under the terms of the GNU Lesser General Public License as
+1 -1
View File
@@ -1,5 +1,5 @@
; BlitzPointer - Adding Pointers to Blitz. ; BlitzPointer - Adding Pointers to Blitz.
; Copyright (C) 2015 Project Kube (Michael Fabian Dirks) ; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
; ;
; This program is free software: you can redistribute it and/or modify ; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as ; it under the terms of the GNU Lesser General Public License as
+1 -1
View File
@@ -1,5 +1,5 @@
; BlitzPointer - Adding Pointers to Blitz. ; BlitzPointer - Adding Pointers to Blitz.
; Copyright (C) 2015 Project Kube (Michael Fabian Dirks) ; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
; ;
; This program is free software: you can redistribute it and/or modify ; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as ; it under the terms of the GNU Lesser General Public License as
+1 -1
View File
@@ -1,5 +1,5 @@
; BlitzPointer - Adding Pointers to Blitz. ; BlitzPointer - Adding Pointers to Blitz.
; Copyright (C) 2015 Project Kube (Michael Fabian Dirks) ; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
; ;
; This program is free software: you can redistribute it and/or modify ; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as ; it under the terms of the GNU Lesser General Public License as
+1 -1
View File
@@ -1,5 +1,5 @@
; BlitzPointer - Adding Pointers to Blitz. ; BlitzPointer - Adding Pointers to Blitz.
; Copyright (C) 2015 Project Kube (Michael Fabian Dirks) ; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
; ;
; This program is free software: you can redistribute it and/or modify ; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as ; it under the terms of the GNU Lesser General Public License as
+2 -2
View File
@@ -1,5 +1,5 @@
; BlitzPointer - Adding Pointers to Blitz. ; BlitzPointer - Adding Pointers to Blitz.
; Copyright (C) 2015 Project Kube (Michael Fabian Dirks) ; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
; ;
; This program is free software: you can redistribute it and/or modify ; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as ; it under the terms of the GNU Lesser General Public License as
@@ -15,7 +15,7 @@
; along with this program. If not, see <http:;www.gnu.org/licenses/>. ; along with this program. If not, see <http:;www.gnu.org/licenses/>.
; ---------------------------------------------------------------------------- ; ; ---------------------------------------------------------------------------- ;
; Example 6 - Callbacks ; Example 7 - Callbacks
; ---------------------------------------------------------------------------- ; ; ---------------------------------------------------------------------------- ;
; License: Creative Commons Attribution 2.0 ; License: Creative Commons Attribution 2.0
; Author: Michael Fabian Dirks<michael.dirks@realitybends.de> ; Author: Michael Fabian Dirks<michael.dirks@realitybends.de>
+84
View File
@@ -0,0 +1,84 @@
; BlitzPointer - Adding Pointers to Blitz.
; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation, either version 3 of the
; License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public License
; along with this program. If not, see <http:;www.gnu.org/licenses/>.
; ---------------------------------------------------------------------------- ;
; Example 8 - Variable-pointers
; ---------------------------------------------------------------------------- ;
; Variable-pointers are really neat. Not only can you have a single variable for
; a lot of things in many locations (even across thread) but you can pass them
; to DLLs too! This opens up Blitz to a whole new way of working with DLLs.
; Three functions were added for this, each for the respective type
; - BP_GetVariablePointerInt(Int%)
; - BP_GetVariablePointerFloat(Float#)
; - BP_GetVariablePointerType(Type.)
; (Strings are not supported sorry.)
; Integers and Floats are really simple, just declare them and grab the pointer.
Global MyInteger% = 66
Global MyFloat# = 66.6
Global Pointer% = 0
; Grab the Integer Pointer and modify the value.
Pointer = BP_GetVariablePointerInt(MyInteger)
Print "MyInteger: " + PeekMemoryInt(Pointer)
PokeMemoryInt(Pointer, 33)
Print "MyInteger: " + PeekMemoryInt(Pointer)
; Grab the Float Pointer and modify the value.
Pointer = BP_GetVariablePointerFloat(MyFloat)
Print "MyFloat: " + PeekMemoryFloat(Pointer)
PokeMemoryFloat(Pointer, 33.3)
Print "MyFloat: " + PeekMemoryFloat(Pointer)
; Types are a tiny bit harder but open up so many possibilities once you get
; used to them. Start by defining a Type, we'll use a simple one for this.
Type MyType
Field Check%
End Type
; Now create some elements that we can use when modifying the pointer
Global MyElement.MyType = New MyType
Global MyElement1.MyType = New MyType
Global MyElement2.MyType = New MyType
Global MyElement3.MyType = New MyType
MyElement\Check = -1
MyElement1\Check = $F
MyElement2\Check = $FF
MyElement3\Check = $FFF
; Store the Pointer and original element.
Pointer = BP_GetVariablePointerType(MyElement)
Local TempPointer% = PeekMemoryInt(Pointer)
; Modifying is as simple as storing a new value to the address the pointer is
; pointing at. The Int() thing is explained in Example 5.
Print "MyElement\Check: " + MyElement\Check
PokeMemoryInt(Pointer, Int(MyElement1))
Print "MyElement\Check: " + MyElement\Check
PokeMemoryInt(Pointer, Int(MyElement2))
Print "MyElement\Check: " + MyElement\Check
PokeMemoryInt(Pointer, Int(MyElement3))
Print "MyElement\Check: " + MyElement\Check
; Always return things to their original condition. Just in case.
PokeMemoryInt(Pointer, TempPointer)
Print "MyElement\Check: " + MyElement\Check
WaitKey()
; You can do some magic with this, such as iterating through types yourself by
; changing the pointer to the next element or previous element. See Example 6.
@@ -1,5 +1,5 @@
; BlitzPointer - Adding Pointers to Blitz. ; BlitzPointer - Adding Pointers to Blitz.
; Copyright (C) 2015 Project Kube (Michael Fabian Dirks) ; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
; ;
; This program is free software: you can redistribute it and/or modify ; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as ; it under the terms of the GNU Lesser General Public License as
+1 -1
View File
@@ -1,5 +1,5 @@
// BlitzPointer - Adding Pointers to Blitz. // BlitzPointer - Adding Pointers to Blitz.
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks) // Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as // it under the terms of the GNU Lesser General Public License as
+1 -1
View File
@@ -1,5 +1,5 @@
// BlitzPointer - Adding Pointers to Blitz. // BlitzPointer - Adding Pointers to Blitz.
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks) // Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as // it under the terms of the GNU Lesser General Public License as
+1 -1
View File
@@ -1,5 +1,5 @@
// BlitzPointer - Adding Pointers to Blitz. // BlitzPointer - Adding Pointers to Blitz.
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks) // Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as // it under the terms of the GNU Lesser General Public License as