diff --git a/BlitzPointer.cpp b/BlitzPointer.cpp
index 8612527..9b4e359 100644
--- a/BlitzPointer.cpp
+++ b/BlitzPointer.cpp
@@ -1,5 +1,5 @@
// 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
// it under the terms of the GNU Lesser General Public License as
@@ -15,7 +15,7 @@
// along with this program. If not, see .
// Idea take from Code by Noodoby
-// New Code by Xaymar
+// New Code by Xaymar
#pragma once
#include "BlitzPointer.h"
@@ -79,7 +79,23 @@ DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointer(int32_t pVariable)
// 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")
+#pragma comment(linker, "/EXPORT:BP_GetVariablePointer=_BP_GetVariablePointer@4")
+
+DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointerType( 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 - 11);
+}
+#pragma comment(linker, "/EXPORT:BP_GetVariablePointerType=_BP_GetVariablePointerType@4")
DLL_METHOD int32_t DLL_CALL BP_CallFunction0(BP_BlitzFunction0_t lpFunctionPointer) {
return lpFunctionPointer();
diff --git a/BlitzPointer.decls b/BlitzPointer.decls
index 0749a95..832e58f 100644
--- a/BlitzPointer.decls
+++ b/BlitzPointer.decls
@@ -1,5 +1,5 @@
; 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
; it under the terms of the GNU Lesser General Public License as
@@ -19,10 +19,10 @@
; BlitzPointer
BP_GetReturnAddress%()
BP_GetFunctionPointer%()
-;BP_GetVariablePointer%()
+;BP_GetVariablePointer%(pVariable%)
BP_GetVariablePointerInt%(pVariable%) : "BP_GetVariablePointer"
BP_GetVariablePointerFloat%(pVariable#) : "BP_GetVariablePointer"
-BP_GetVariablePointerType%(pVariable*) : "BP_GetVariablePointer"
+BP_GetVariablePointerType%(pVariable*) : "BP_GetVariablePointerType"
; Memory Modification
PeekMemoryByte%(lpMemoryPointer%)
diff --git a/BlitzPointer.h b/BlitzPointer.h
index 6eb6bb6..4296e99 100644
--- a/BlitzPointer.h
+++ b/BlitzPointer.h
@@ -1,5 +1,5 @@
// 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
// it under the terms of the GNU Lesser General Public License as
@@ -30,6 +30,7 @@ typedef int32_t(__stdcall *BP_BlitzFunction5_t)(int32_t, int32_t, int32_t, int32
DLL_METHOD intptr_t DLL_CALL BP_GetReturnAddress();
DLL_METHOD intptr_t DLL_CALL BP_GetFunctionPointer();
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
DLL_METHOD int32_t DLL_CALL BP_CallFunction0(BP_BlitzFunction0_t lpFunctionPointer);
diff --git a/BlitzPointer.vcxproj b/BlitzPointer.vcxproj
index cf9c51f..abeccb9 100644
--- a/BlitzPointer.vcxproj
+++ b/BlitzPointer.vcxproj
@@ -61,7 +61,7 @@
DefaultMultiThreadedfalse
- false
+ truefalsefalse4Bytes
@@ -83,6 +83,7 @@
falsetrue%(PreprocessorDefinitions)
+ EditAndContinuetrue
diff --git a/Examples/Example01.bb b/Examples/Example01.bb
index 630660f..83f745c 100644
--- a/Examples/Example01.bb
+++ b/Examples/Example01.bb
@@ -1,5 +1,5 @@
; 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
; it under the terms of the GNU Lesser General Public License as
diff --git a/Examples/Example02.bb b/Examples/Example02.bb
index 8478909..3693e46 100644
--- a/Examples/Example02.bb
+++ b/Examples/Example02.bb
@@ -1,5 +1,5 @@
; 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
; it under the terms of the GNU Lesser General Public License as
diff --git a/Examples/Example03.bb b/Examples/Example03.bb
index e2edacb..cce7b1c 100644
--- a/Examples/Example03.bb
+++ b/Examples/Example03.bb
@@ -1,5 +1,5 @@
; 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
; it under the terms of the GNU Lesser General Public License as
diff --git a/Examples/Example04.bb b/Examples/Example04.bb
index 5dbfef1..747bbd0 100644
--- a/Examples/Example04.bb
+++ b/Examples/Example04.bb
@@ -1,5 +1,5 @@
; 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
; it under the terms of the GNU Lesser General Public License as
diff --git a/Examples/Example05.bb b/Examples/Example05.bb
index b8cf68b..cfe84c3 100644
--- a/Examples/Example05.bb
+++ b/Examples/Example05.bb
@@ -1,5 +1,5 @@
; 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
; it under the terms of the GNU Lesser General Public License as
diff --git a/Examples/Example06.bb b/Examples/Example06.bb
index bdf8067..69ffb5d 100644
--- a/Examples/Example06.bb
+++ b/Examples/Example06.bb
@@ -1,5 +1,5 @@
; 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
; it under the terms of the GNU Lesser General Public License as
diff --git a/Examples/Example07.bb b/Examples/Example07.bb
index fda4700..521a500 100644
--- a/Examples/Example07.bb
+++ b/Examples/Example07.bb
@@ -1,5 +1,5 @@
; 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
; it under the terms of the GNU Lesser General Public License as
@@ -15,7 +15,7 @@
; along with this program. If not, see .
; ---------------------------------------------------------------------------- ;
-; Example 6 - Callbacks
+; Example 7 - Callbacks
; ---------------------------------------------------------------------------- ;
; License: Creative Commons Attribution 2.0
; Author: Michael Fabian Dirks
diff --git a/Examples/Example08.bb b/Examples/Example08.bb
index a8d3eac..a1ff2e4 100644
--- a/Examples/Example08.bb
+++ b/Examples/Example08.bb
@@ -1,5 +1,5 @@
; 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
; it under the terms of the GNU Lesser General Public License as
@@ -15,29 +15,70 @@
; along with this program. If not, see .
; ---------------------------------------------------------------------------- ;
-; Example 6 - Variable Pointers
+; Example 8 - Variable-pointers
; ---------------------------------------------------------------------------- ;
-; Variable Pointers, the one thing we have all waited for in addition to every-
-; thing else. Now we can pass things by reference instead of copying to & from
-; a bank. Unfortunately it only works for Integers, Floats and Types.
+; 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.
-; For Integers, all you have to do is declare a variable and then call the func-
-; tion that retrieves the pointer:
-Global MyVariable% = 1
-Global MyVariablePtr% = 0
-MyVariablePtr = BP_GetVariablePointerInt(MyVariable)
+; 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.)
-; Same for Floats, slightly different function though
-Global MyVariable2# = 1.2
-Global MyVariable2Ptr% = 0
-MyVariable2Ptr = BP_GetVariablePointerFloat(MyVariable2)
+; Integers and Floats are really simple, just declare them and grab the pointer.
+Global MyInteger% = 66
+Global MyFloat# = 66.6
+Global Pointer% = 0
-; Now we can directly modify them in memory, which means that we can modify them
-; from anywhere - inside and outside our program. What you do with this is up
-; to your imagination, just don't fuck up. Computers don't like that.
+; Grab the Integer Pointer and modify the value.
+Pointer = BP_GetVariablePointerInt(MyInteger)
+Print "MyInteger: " + PeekMemoryInt(Pointer)
+PokeMemoryInt(Pointer, 33)
+Print "MyInteger: " + PeekMemoryInt(Pointer)
-; Usage Example
-Print MyVariable
-PokeMemoryInt(MyVariable, 283)
-Print MyVariable
+; 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.
\ No newline at end of file
diff --git a/Examples/Example_Shared.bb b/Examples/Example_Shared.bb
index ad868c8..39e36a5 100644
--- a/Examples/Example_Shared.bb
+++ b/Examples/Example_Shared.bb
@@ -1,5 +1,5 @@
; 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
; it under the terms of the GNU Lesser General Public License as
diff --git a/MemoryHelpers.cpp b/MemoryHelpers.cpp
index d2ea2f5..b7d54eb 100644
--- a/MemoryHelpers.cpp
+++ b/MemoryHelpers.cpp
@@ -1,5 +1,5 @@
// 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
// it under the terms of the GNU Lesser General Public License as
diff --git a/dllmain.cpp b/dllmain.cpp
index 3653c44..d8ad91b 100644
--- a/dllmain.cpp
+++ b/dllmain.cpp
@@ -1,5 +1,5 @@
// 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
// it under the terms of the GNU Lesser General Public License as
diff --git a/dllmain.h b/dllmain.h
index f825c9c..7a098d7 100644
--- a/dllmain.h
+++ b/dllmain.h
@@ -1,5 +1,5 @@
// 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
// it under the terms of the GNU Lesser General Public License as