5 Commits

Author SHA1 Message Date
Michael Dirks ce731d795f Increased parameter count to 5 from 4. 2015-06-20 23:37:47 +02:00
Michael Dirks 78aac62649 Prepare changes to filter-only project. 2015-06-20 16:52:16 +02:00
Michael Dirks 5581958a44 30 minutes wasted playing find-the-old-DLL. At least BlitzPointer.cpp is only compiled once now. 2015-06-20 16:20:03 +02:00
Michael Dirks a1d252deba extern "c" -> extern "C" 2015-06-20 15:51:53 +02:00
Michael Dirks 880e754254 1.3 Update:
- Blitz functions are callable using __stdcall, use it instead of using tailored asm.
- DLLs that rely on this DLL no longer have to load the DLL to call Blitz functions, just include BlitzPointer.h and use the typedefs BP_BlitzFunction#_t.
- Removed Hybrid support until Hybrid is open-source.
2015-06-20 15:08:27 +02:00
16 changed files with 1237 additions and 695 deletions
+1097 -368
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -38,14 +38,14 @@ Global fpOurFunction = 0
; Our function can be anything we want, however we must be able to call it once ; Our function can be anything we want, however we must be able to call it once
; without effect before we can actually retrieve the function pointer. Why? ; without effect before we can actually retrieve the function pointer. Why?
; Simple! The BlitzPointer_GetFunctionPointer traces the return address for the ; Simple! The BP_GetFunctionPointer traces the return address for the
; Blitz function signature - and thus can't work outside a function. ; Blitz function signature - and thus can't work outside a function.
Function OurFunction() Function OurFunction()
; Let's begin by checking if we already have the pointer. Not required, but ; Let's begin by checking if we already have the pointer. Not required, but
; we do it anyway to save some scanning time on every call. ; we do it anyway to save some scanning time on every call.
If fpOurFunction = 0 Then If fpOurFunction = 0 Then
; Now let us call the above mentioned function to retrieve the pointer. ; Now let us call the above mentioned function to retrieve the pointer.
fpOurFunction = BlitzPointer_GetFunctionPointer() fpOurFunction = BP_GetFunctionPointer()
; Weether you use a Return or an Else is up to you. Return is technically ; Weether you use a Return or an Else is up to you. Return is technically
; faster in Blitz, as using Else causes a complex ASM construction. ; faster in Blitz, as using Else causes a complex ASM construction.
Return Return
+2 -2
View File
@@ -29,7 +29,7 @@ ExampleInit()
Global fpOurFunction = 0 Global fpOurFunction = 0
Function OurFunction() Function OurFunction()
If fpOurFunction = 0 Then If fpOurFunction = 0 Then
fpOurFunction = BlitzPointer_GetFunctionPointer() fpOurFunction = BP_GetFunctionPointer()
Return Return
EndIf EndIf
@@ -44,7 +44,7 @@ While Not KeyHit(1)
; BlitzPointer offers many ways of calling our function pointer. Each one ; BlitzPointer offers many ways of calling our function pointer. Each one
; describes different return types, parameter count and parameter types. ; describes different return types, parameter count and parameter types.
; Let's use the one that doesn't return a value for now. ; Let's use the one that doesn't return a value for now.
BlitzPointer_CallFunctionV fpOurFunction BP_CallFunctionV fpOurFunction
; Now if we run the program, instead of a fixed native call, we're calling a ; Now if we run the program, instead of a fixed native call, we're calling a
; function pointer instead. Pretty useful in my opinion, especially for UI, ; function pointer instead. Pretty useful in my opinion, especially for UI,
; networking, fake classes, etc. ; networking, fake classes, etc.
+9 -9
View File
@@ -29,9 +29,9 @@
; ---------------------------------------------------------------------------- ; ; ---------------------------------------------------------------------------- ;
; Type Id Description Calling Function ; Type Id Description Calling Function
; ---------------------------------------------------------------------------- ; ; ---------------------------------------------------------------------------- ;
; void V Nothing BlitzPointer_CallFunctionV ; void V Nothing BP_CallFunctionV
; int I 32-bit Integer BlitzPointer_CallFunctionI ; int I 32-bit Integer BP_CallFunctionI
; float F Floating Point BlitzPointer_CallFunctionF ; float F Floating Point BP_CallFunctionF
; Now that we know what we can and can't do (without memory leaks at least), ; Now that we know what we can and can't do (without memory leaks at least),
; let's try out the return types ourselves. ; let's try out the return types ourselves.
@@ -43,7 +43,7 @@ ExampleInit()
Global fpVoidFunction = 0 Global fpVoidFunction = 0
Function VoidFunction() Function VoidFunction()
If fpVoidFunction = 0 Then If fpVoidFunction = 0 Then
fpVoidFunction = BlitzPointer_GetFunctionPointer() fpVoidFunction = BP_GetFunctionPointer()
Return Return
EndIf EndIf
Text 0, 0, "Void Return Type" Text 0, 0, "Void Return Type"
@@ -54,7 +54,7 @@ VoidFunction()
Global fpIntFunction = 0 Global fpIntFunction = 0
Function IntFunction%() Function IntFunction%()
If fpIntFunction = 0 Then If fpIntFunction = 0 Then
fpIntFunction = BlitzPointer_GetFunctionPointer() fpIntFunction = BP_GetFunctionPointer()
Return Return
EndIf EndIf
Text 0, 15, "Int Return Type" Text 0, 15, "Int Return Type"
@@ -66,7 +66,7 @@ IntFunction()
Global fpFloatFunction = 0 Global fpFloatFunction = 0
Function FloatFunction#() Function FloatFunction#()
If fpFloatFunction = 0 Then If fpFloatFunction = 0 Then
fpFloatFunction = BlitzPointer_GetFunctionPointer() fpFloatFunction = BP_GetFunctionPointer()
Return Return
EndIf EndIf
Text 0, 30, "Float Return Type" Text 0, 30, "Float Return Type"
@@ -78,9 +78,9 @@ While Not KeyHit(1)
ExampleUpdate() ExampleUpdate()
; Calling the function and using the return value is really easy to do now: ; Calling the function and using the return value is really easy to do now:
BlitzPointer_CallFunctionV(fpVoidFunction) ; void returns nothing. BP_CallFunctionV(fpVoidFunction) ; void returns nothing.
Text 200, 15, BlitzPointer_CallFunctionI(fpIntFunction) Text 200, 15, BP_CallFunctionI(fpIntFunction)
Text 200, 30, BlitzPointer_CallFunctionF(fpFloatFunction) Text 200, 30, BP_CallFunctionF(fpFloatFunction)
ExampleLoop() ExampleLoop()
Wend Wend
+10 -10
View File
@@ -31,9 +31,9 @@
; ---------------------------------------------------------------------------- ; ; ---------------------------------------------------------------------------- ;
; Type Id Description Calling Function ; Type Id Description Calling Function
; ---------------------------------------------------------------------------- ; ; ---------------------------------------------------------------------------- ;
; int I 32-bit Integer BlitzPointer_CallFunction*I ; int I 32-bit Integer BP_CallFunction*I
; float F Floating Point BlitzPointer_CallFunction*F ; float F Floating Point BP_CallFunction*F
; pointer P Memory Pointer BlitzPointer_CallFunction*P ; pointer P Memory Pointer BP_CallFunction*P
; Watch out: ; Watch out:
; Calling a function that has parameters without giving enough parameters will ; Calling a function that has parameters without giving enough parameters will
@@ -47,7 +47,7 @@ ExampleInit()
Global fpCurInGameSecond = 0 Global fpCurInGameSecond = 0
Function CurInGameSecond%(p1%=0) Function CurInGameSecond%(p1%=0)
If fpCurInGameSecond = 0 Then If fpCurInGameSecond = 0 Then
fpCurInGameSecond = BlitzPointer_GetFunctionPointer() fpCurInGameSecond = BP_GetFunctionPointer()
Return Return
EndIf EndIf
Text 5, 15, "IIFunction" Text 5, 15, "IIFunction"
@@ -61,7 +61,7 @@ CurInGameSecond()
Global fpCurInGameSecondEx = 0 Global fpCurInGameSecondEx = 0
Function CurInGameSecondEx#(p1%=0, p2#=0) Function CurInGameSecondEx#(p1%=0, p2#=0)
If fpCurInGameSecondEx = 0 Then If fpCurInGameSecondEx = 0 Then
fpCurInGameSecondEx = BlitzPointer_GetFunctionPointer() fpCurInGameSecondEx = BP_GetFunctionPointer()
Return Return
EndIf EndIf
@@ -78,7 +78,7 @@ CurInGameSecondEx()
Global fpConvertIntFloat Global fpConvertIntFloat
Function ConvertIntFloat#(p1#=0) Function ConvertIntFloat#(p1#=0)
If fpConvertIntFloat = 0 Then If fpConvertIntFloat = 0 Then
fpConvertIntFloat = BlitzPointer_GetFunctionPointer() fpConvertIntFloat = BP_GetFunctionPointer()
Print Hex(fpConvertIntFloat) Print Hex(fpConvertIntFloat)
WaitKey() WaitKey()
Return Return
@@ -101,18 +101,18 @@ While Not KeyHit(1)
Text 480, 0, "Parameter 4" Text 480, 0, "Parameter 4"
Text 600, 0, "Result" Text 600, 0, "Result"
Text 605, 15, BlitzPointer_CallFunctionII(fpCurInGameSecond, Frame) Text 605, 15, BP_CallFunctionII(fpCurInGameSecond, Frame)
Text 605, 30, BlitzPointer_CallFunctionFIF(fpCurInGameSecondEx, Frame, 0.016666666) Text 605, 30, BP_CallFunctionFIF(fpCurInGameSecondEx, Frame, 0.016666666)
Local TempFlt# = Frame / 60.0 Local TempFlt# = Frame / 60.0
Local TempInt% = BlitzPointer_CallFunctionIF(fpConvertIntFloat, TempFlt) Local TempInt% = BP_CallFunctionIF(fpConvertIntFloat, TempFlt)
Text 5, 60, "Float -> Int" Text 5, 60, "Float -> Int"
Text 125, 60, TempFlt Text 125, 60, TempFlt
Text 605, 60, Hex(TempInt) Text 605, 60, Hex(TempInt)
Text 5, 75, "Int -> Float" Text 5, 75, "Int -> Float"
Text 125, 75, Hex(TempInt) Text 125, 75, Hex(TempInt)
Text 605, 75, BlitzPointer_CallFunctionFI(fpConvertIntFloat, TempInt) Text 605, 75, BP_CallFunctionFI(fpConvertIntFloat, TempInt)
ExampleLoop() ExampleLoop()
+3 -3
View File
@@ -41,7 +41,7 @@ End Type
Global fpMyTypeFunc = 0 Global fpMyTypeFunc = 0
Function MyTypeFunc(This.MyType) Function MyTypeFunc(This.MyType)
If fpMyTypeFunc = 0 Then If fpMyTypeFunc = 0 Then
fpMyTypeFunc = BlitzPointer_GetFunctionPointer() fpMyTypeFunc = BP_GetFunctionPointer()
Return Return
EndIf EndIf
If This = Null Then Return If This = Null Then Return
@@ -64,8 +64,8 @@ While Not KeyHit(1)
; Now in order to pass a Type Object to a function, we have to get a pointer ; Now in order to pass a Type Object to a function, we have to get a pointer
; from it. Thankfully, Blitz has this already built in: Int(). ; from it. Thankfully, Blitz has this already built in: Int().
If KeyDown(2) Then BlitzPointer_CallFunctionVI fpMyTypeFunc, Int(MT1) If KeyDown(2) Then BP_CallFunctionVI fpMyTypeFunc, Int(MT1)
If KeyDown(3) Then BlitzPointer_CallFunctionVI fpMyTypeFunc, Int(MT2) If KeyDown(3) Then BP_CallFunctionVI fpMyTypeFunc, Int(MT2)
ExampleLoop() ExampleLoop()
Wend Wend
+1 -1
View File
@@ -82,7 +82,7 @@ End Type
Global fpMyPointerFunction% = 0 Global fpMyPointerFunction% = 0
Function MyPointerFunction(Pointer%) Function MyPointerFunction(Pointer%)
If fpMyPointerFunction = 0 Then If fpMyPointerFunction = 0 Then
fpMyPointerFunction = BlitzPointer_GetFunctionPointer() fpMyPointerFunction = BP_GetFunctionPointer()
Return Return
EndIf EndIf
+3 -3
View File
@@ -54,7 +54,7 @@ Function TGenericUpdate()
Local This.TGeneric Local This.TGeneric
For This = Each TGeneric For This = Each TGeneric
If This\Pointer <> 0 Then If This\Pointer <> 0 Then
If BlitzPointer_CallFunctionII(CallbackIndex(This\Index), This\Pointer) Then If BP_CallFunctionII(CallbackIndex(This\Index), This\Pointer) Then
Delete This Delete This
EndIf EndIf
EndIf EndIf
@@ -98,7 +98,7 @@ End Function
Function TCubeCallback%(This.TCube) Function TCubeCallback%(This.TCube)
If CallbackIndex(CALLBACK_INDEX_TCUBE) = 0 Then If CallbackIndex(CALLBACK_INDEX_TCUBE) = 0 Then
CallbackIndex(CALLBACK_INDEX_TCUBE) = BlitzPointer_GetFunctionPointer() CallbackIndex(CALLBACK_INDEX_TCUBE) = BP_GetFunctionPointer()
Return Return
EndIf EndIf
; Safeguard against stupidity (it affect everyone). ; Safeguard against stupidity (it affect everyone).
@@ -156,7 +156,7 @@ End Function
Function TSphereUpdate%(This.TSphere) Function TSphereUpdate%(This.TSphere)
If CallbackIndex(CALLBACK_INDEX_TSPHERE) = 0 Then If CallbackIndex(CALLBACK_INDEX_TSPHERE) = 0 Then
CallbackIndex(CALLBACK_INDEX_TSPHERE) = BlitzPointer_GetFunctionPointer() CallbackIndex(CALLBACK_INDEX_TSPHERE) = BP_GetFunctionPointer()
Return Return
EndIf EndIf
; Safeguard against stupidity (it affect everyone). ; Safeguard against stupidity (it affect everyone).
-150
View File
@@ -1,150 +0,0 @@
// BlitzPointer - Adding Pointers to Blitz.
// Copyright (C) 2015 Project Kube (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/>.
#include "BlitzPointer.h"
// Hybrid specific defines.
#define CALLFUNCTION_DECL_BEGIN_64(NAME) DLL_EXPORT int64_t BlitzPointer_CallFunction##NAME(intptr_t lpFunctionPointer
#define CALLFUNCTION_IMPL_PARAMETER_64(INDEX, NAME) __asm MOV RAX, [NAME] __asm mov [esp + INDEX * 4], RAX
#define CALLFUNCTION_IMPL_CALL_64() __asm CALL QWORD ptr[lpFunctionPointer]
#define CALLFUNCTION_IMPL_RESULT_64() int64_t result; __asm MOV [result], RAX
/*
// No Parameters
CALLFUNCTION_DECL_BEGIN_64(Q0)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_CALL_64()
CALLFUNCTION_IMPL_RESULT_64()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
// One Parameter
CALLFUNCTION_DECL_BEGIN_64(Q1D)
CALLFUNCTION_DECL_PARAMETER(int32_t, p1)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_PREPARE(1)
CALLFUNCTION_IMPL_PARAMETER(0, p1)
CALLFUNCTION_IMPL_CALL_64()
CALLFUNCTION_IMPL_RESULT_64()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
CALLFUNCTION_DECL_BEGIN_64(Q1Q)
CALLFUNCTION_DECL_PARAMETER(int64_t, p1)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_PREPARE(1)
CALLFUNCTION_IMPL_PARAMETER_64(0, p1)
CALLFUNCTION_IMPL_CALL_64()
CALLFUNCTION_IMPL_RESULT_64()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
// Two Parameters
CALLFUNCTION_DECL_BEGIN(D2DQ)
CALLFUNCTION_DECL_PARAMETER(int32_t, p1)
CALLFUNCTION_DECL_PARAMETER(int64_t, p2)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_PREPARE(2)
CALLFUNCTION_IMPL_PARAMETER_64(1, p2)
CALLFUNCTION_IMPL_PARAMETER(0, p1)
CALLFUNCTION_IMPL_CALL()
CALLFUNCTION_IMPL_RESULT()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
CALLFUNCTION_DECL_BEGIN(D2QD)
CALLFUNCTION_DECL_PARAMETER(int64_t, p1)
CALLFUNCTION_DECL_PARAMETER(int32_t, p2)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_PREPARE(2)
CALLFUNCTION_IMPL_PARAMETER(1, p2)
CALLFUNCTION_IMPL_PARAMETER_64(0, p1)
CALLFUNCTION_IMPL_CALL()
CALLFUNCTION_IMPL_RESULT()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
CALLFUNCTION_DECL_BEGIN(D2QQ)
CALLFUNCTION_DECL_PARAMETER(int64_t, p1)
CALLFUNCTION_DECL_PARAMETER(int64_t, p2)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_PREPARE(2)
CALLFUNCTION_IMPL_PARAMETER_64(1, p2)
CALLFUNCTION_IMPL_PARAMETER_64(0, p1)
CALLFUNCTION_IMPL_CALL()
CALLFUNCTION_IMPL_RESULT()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
CALLFUNCTION_DECL_BEGIN_64(Q2DD)
CALLFUNCTION_DECL_PARAMETER(int32_t, p1)
CALLFUNCTION_DECL_PARAMETER(int64_t, p2)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_PREPARE(2)
CALLFUNCTION_IMPL_PARAMETER_64(1, p2)
CALLFUNCTION_IMPL_PARAMETER(0, p1)
CALLFUNCTION_IMPL_CALL()
CALLFUNCTION_IMPL_RESULT_64()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
CALLFUNCTION_DECL_BEGIN_64(Q2DQ)
CALLFUNCTION_DECL_PARAMETER(int32_t, p1)
CALLFUNCTION_DECL_PARAMETER(int64_t, p2)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_PREPARE(2)
CALLFUNCTION_IMPL_PARAMETER_64(1, p2)
CALLFUNCTION_IMPL_PARAMETER(0, p1)
CALLFUNCTION_IMPL_CALL()
CALLFUNCTION_IMPL_RESULT_64()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
CALLFUNCTION_DECL_BEGIN_64(Q2QD)
CALLFUNCTION_DECL_PARAMETER(int64_t, p1)
CALLFUNCTION_DECL_PARAMETER(int32_t, p2)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_PREPARE(2)
CALLFUNCTION_IMPL_PARAMETER(1, p2)
CALLFUNCTION_IMPL_PARAMETER_64(0, p1)
CALLFUNCTION_IMPL_CALL()
CALLFUNCTION_IMPL_RESULT_64()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
CALLFUNCTION_DECL_BEGIN_64(Q2QQ)
CALLFUNCTION_DECL_PARAMETER(int64_t, p1)
CALLFUNCTION_DECL_PARAMETER(int64_t, p2)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_PREPARE(2)
CALLFUNCTION_IMPL_PARAMETER_64(1, p2)
CALLFUNCTION_IMPL_PARAMETER_64(0, p1)
CALLFUNCTION_IMPL_CALL()
CALLFUNCTION_IMPL_RESULT_64()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
*/
-91
View File
@@ -1,91 +0,0 @@
// BlitzPointer - Adding Pointers to Blitz.
// Copyright (C) 2015 Project Kube (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/>.
#include "BlitzPointer.h"
// No Parameters
CALLFUNCTION_DECL_BEGIN(0)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_CALL()
CALLFUNCTION_IMPL_RESULT()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
#pragma comment(linker, "/EXPORT:BlitzPointer_CallFunction0=_BlitzPointer_CallFunction0@4")
// One Parameter
CALLFUNCTION_DECL_BEGIN(1)
CALLFUNCTION_DECL_PARAMETER(int32_t, p1)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_PREPARE(1)
CALLFUNCTION_IMPL_PARAMETER(0, p1)
CALLFUNCTION_IMPL_CALL()
CALLFUNCTION_IMPL_RESULT()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
#pragma comment(linker, "/EXPORT:BlitzPointer_CallFunction1=_BlitzPointer_CallFunction1@8")
// Two Parameters
CALLFUNCTION_DECL_BEGIN(2)
CALLFUNCTION_DECL_PARAMETER(int32_t, p1)
CALLFUNCTION_DECL_PARAMETER(int32_t, p2)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_PREPARE(2)
CALLFUNCTION_IMPL_PARAMETER(1, p2)
CALLFUNCTION_IMPL_PARAMETER(0, p1)
CALLFUNCTION_IMPL_CALL()
CALLFUNCTION_IMPL_RESULT()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
#pragma comment(linker, "/EXPORT:BlitzPointer_CallFunction2=_BlitzPointer_CallFunction2@12")
// Three Parameters
CALLFUNCTION_DECL_BEGIN(3)
CALLFUNCTION_DECL_PARAMETER(int32_t, p1)
CALLFUNCTION_DECL_PARAMETER(int32_t, p2)
CALLFUNCTION_DECL_PARAMETER(int32_t, p3)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_PREPARE(3)
CALLFUNCTION_IMPL_PARAMETER(2, p3)
CALLFUNCTION_IMPL_PARAMETER(1, p2)
CALLFUNCTION_IMPL_PARAMETER(0, p1)
CALLFUNCTION_IMPL_CALL()
CALLFUNCTION_IMPL_RESULT()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
#pragma comment(linker, "/EXPORT:BlitzPointer_CallFunction3=_BlitzPointer_CallFunction3@16")
// Four Parameters
CALLFUNCTION_DECL_BEGIN(4)
CALLFUNCTION_DECL_PARAMETER(int32_t, p1)
CALLFUNCTION_DECL_PARAMETER(int32_t, p2)
CALLFUNCTION_DECL_PARAMETER(int32_t, p3)
CALLFUNCTION_DECL_PARAMETER(int32_t, p4)
CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN()
CALLFUNCTION_IMPL_SAFEGUARD()
CALLFUNCTION_IMPL_PREPARE(4)
CALLFUNCTION_IMPL_PARAMETER(3, p4)
CALLFUNCTION_IMPL_PARAMETER(2, p3)
CALLFUNCTION_IMPL_PARAMETER(1, p2)
CALLFUNCTION_IMPL_PARAMETER(0, p1)
CALLFUNCTION_IMPL_CALL()
CALLFUNCTION_IMPL_RESULT()
CALLFUNCTION_IMPL_RETURN()
CALLFUNCTION_IMPL_END()
#pragma comment(linker, "/EXPORT:BlitzPointer_CallFunction4=_BlitzPointer_CallFunction4@20")
+43 -4
View File
@@ -17,9 +17,10 @@
// 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://project-kube.de>
#pragma once
#include "BlitzPointer.h" #include "BlitzPointer.h"
DLL_EXPORT intptr_t BlitzPointer_GetReturnAddress() { DLL_METHOD intptr_t DLL_CALL BP_GetReturnAddress() {
intptr_t StackPointer, ReturnAddress; intptr_t StackPointer, ReturnAddress;
__asm { //ASM. Do touch if suicidal. __asm { //ASM. Do touch if suicidal.
@@ -32,9 +33,9 @@ DLL_EXPORT intptr_t BlitzPointer_GetReturnAddress() {
return ReturnAddress; return ReturnAddress;
} }
#pragma comment(linker, "/EXPORT:BlitzPointer_GetReturnAddress=_BlitzPointer_GetReturnAddress@0") #pragma comment(linker, "/EXPORT:BP_GetReturnAddress=_BP_GetReturnAddress@0")
DLL_EXPORT intptr_t BlitzPointer_GetFunctionPointer() DLL_METHOD intptr_t DLL_CALL BP_GetFunctionPointer()
{ {
intptr_t StackPointer, ReturnAddress; intptr_t StackPointer, ReturnAddress;
@@ -60,4 +61,42 @@ DLL_EXPORT intptr_t BlitzPointer_GetFunctionPointer()
return 0; return 0;
} }
#pragma comment(linker, "/EXPORT:BlitzPointer_GetFunctionPointer=_BlitzPointer_GetFunctionPointer@0") #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;
}
#pragma comment(linker, "/EXPORT:BP_GetVariablePointer=_BP_GetVariablePointer@0")
DLL_METHOD int32_t DLL_CALL BP_CallFunction0(BP_BlitzFunction0_t lpFunctionPointer) {
return lpFunctionPointer();
}
#pragma comment(linker, "/EXPORT:BP_CallFunction0=_BP_CallFunction0@4")
DLL_METHOD int32_t DLL_CALL BP_CallFunction1(BP_BlitzFunction1_t lpFunctionPointer, int32_t p1) {
return lpFunctionPointer(p1);
}
#pragma comment(linker, "/EXPORT:BP_CallFunction1=_BP_CallFunction1@8")
DLL_METHOD int32_t DLL_CALL BP_CallFunction2(BP_BlitzFunction2_t lpFunctionPointer, int32_t p1, int32_t p2) {
return lpFunctionPointer(p1, p2);
}
#pragma comment(linker, "/EXPORT:BP_CallFunction2=_BP_CallFunction2@12")
DLL_METHOD int32_t DLL_CALL BP_CallFunction3(BP_BlitzFunction3_t lpFunctionPointer, int32_t p1, int32_t p2, int32_t p3) {
return lpFunctionPointer(p1, p2, p3);
}
#pragma comment(linker, "/EXPORT:BP_CallFunction3=_BP_CallFunction3@16")
DLL_METHOD int32_t DLL_CALL BP_CallFunction4(BP_BlitzFunction4_t lpFunctionPointer, int32_t p1, int32_t p2, int32_t p3, int32_t p4) {
return lpFunctionPointer(p1, p2, p3, p4);
}
#pragma comment(linker, "/EXPORT:BP_CallFunction4=_BP_CallFunction4@20")
DLL_METHOD int32_t DLL_CALL BP_CallFunction5(BP_BlitzFunction5_t lpFunctionPointer, int32_t p1, int32_t p2, int32_t p3, int32_t p4, int32_t p5) {
return lpFunctionPointer(p1, p2, p3, p4, p5);
}
#pragma comment(linker, "/EXPORT:BP_CallFunction5=_BP_CallFunction5@24")
+19 -14
View File
@@ -18,18 +18,23 @@
#include "dllmain.h" #include "dllmain.h"
#include <string> #include <string>
DLL_EXPORT intptr_t BlitzPointer_GetReturnAddress(); // Types of Blitz Functions.
DLL_EXPORT intptr_t BlitzPointer_GetFunctionPointer(); typedef int32_t(__stdcall *BP_BlitzFunction0_t)();
typedef int32_t(__stdcall *BP_BlitzFunction1_t)(int32_t);
typedef int32_t(__stdcall *BP_BlitzFunction2_t)(int32_t, int32_t);
typedef int32_t(__stdcall *BP_BlitzFunction3_t)(int32_t, int32_t, int32_t);
typedef int32_t(__stdcall *BP_BlitzFunction4_t)(int32_t, int32_t, int32_t, int32_t);
typedef int32_t(__stdcall *BP_BlitzFunction5_t)(int32_t, int32_t, int32_t, int32_t, int32_t);
// Defines for easier function generation. // Basic Functionality (Pointer retrieval)
#define CALLFUNCTION_DECL_BEGIN(NAME) DLL_EXPORT int32_t BlitzPointer_CallFunction##NAME(intptr_t lpFunctionPointer DLL_METHOD intptr_t DLL_CALL BP_GetReturnAddress();
#define CALLFUNCTION_DECL_PARAMETER(TYPE, NAME) , TYPE NAME DLL_METHOD intptr_t DLL_CALL BP_GetFunctionPointer();
#define CALLFUNCTION_DECL_END() ) DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointer();
#define CALLFUNCTION_IMPL_BEGIN() {
#define CALLFUNCTION_IMPL_SAFEGUARD() if (!lpFunctionPointer) return NULL; // Native Blitz Function Calls
#define CALLFUNCTION_IMPL_PREPARE(COUNT) __asm SUB ESP, COUNT * 4 DLL_METHOD int32_t DLL_CALL BP_CallFunction0(BP_BlitzFunction0_t lpFunctionPointer);
#define CALLFUNCTION_IMPL_PARAMETER(INDEX, NAME) __asm MOV EAX, [NAME] __asm MOV [ESP + INDEX * 4], EAX DLL_METHOD int32_t DLL_CALL BP_CallFunction1(BP_BlitzFunction1_t lpFunctionPointer, int32_t p1);
#define CALLFUNCTION_IMPL_CALL() __asm CALL DWORD ptr[lpFunctionPointer] DLL_METHOD int32_t DLL_CALL BP_CallFunction2(BP_BlitzFunction2_t lpFunctionPointer, int32_t p1, int32_t p2);
#define CALLFUNCTION_IMPL_RESULT() int32_t result; __asm MOV [result], EAX DLL_METHOD int32_t DLL_CALL BP_CallFunction3(BP_BlitzFunction3_t lpFunctionPointer, int32_t p1, int32_t p2, int32_t p3);
#define CALLFUNCTION_IMPL_RETURN() return result; DLL_METHOD int32_t DLL_CALL BP_CallFunction4(BP_BlitzFunction4_t lpFunctionPointer, int32_t p1, int32_t p2, int32_t p3, int32_t p4);
#define CALLFUNCTION_IMPL_END() } DLL_METHOD int32_t DLL_CALL BP_CallFunction5(BP_BlitzFunction5_t lpFunctionPointer, int32_t p1, int32_t p2, int32_t p3, int32_t p4, int32_t p5);
+33 -18
View File
@@ -43,14 +43,12 @@
<IntDir>$(SolutionDir)\#Intermediate\$(ProjectName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\#Intermediate\$(ProjectName)\$(Configuration)\</IntDir>
<TargetExt>.dll</TargetExt> <TargetExt>.dll</TargetExt>
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)\#Build\$(ProjectName)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\#Build\$(ProjectName)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)\#Intermediate\$(ProjectName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\#Intermediate\$(ProjectName)\$(Configuration)\</IntDir>
<TargetExt>.dll</TargetExt> <TargetExt>.dll</TargetExt>
<LinkIncremental>true</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
@@ -58,8 +56,8 @@
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<SDLCheck> <SDLCheck>
</SDLCheck> </SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir);$(ProjectDir)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>false</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<BasicRuntimeChecks>Default</BasicRuntimeChecks> <BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck> <BufferSecurityCheck>false</BufferSecurityCheck>
@@ -77,14 +75,27 @@
<PreprocessKeepComments>false</PreprocessKeepComments> <PreprocessKeepComments>false</PreprocessKeepComments>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion> <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
<OmitFramePointers>false</OmitFramePointers> <OmitFramePointers>false</OmitFramePointers>
<CallingConvention>StdCall</CallingConvention> <CallingConvention>Cdecl</CallingConvention>
<IntrinsicFunctions>false</IntrinsicFunctions>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<StringPooling>true</StringPooling>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<FloatingPointExceptions>false</FloatingPointExceptions>
<UseUnicodeForAssemblerListing>true</UseUnicodeForAssemblerListing>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<Version>1.0</Version> <Version>1.0</Version>
<LinkStatus> <LinkStatus>
</LinkStatus> </LinkStatus>
<CreateHotPatchableImage>Enabled</CreateHotPatchableImage>
<EnableCOMDATFolding>false</EnableCOMDATFolding>
<FixedBaseAddress>false</FixedBaseAddress>
</Link> </Link>
<ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
@@ -94,8 +105,8 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck> <SDLCheck>
</SDLCheck> </SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir);$(ProjectDir)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>false</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck> <BufferSecurityCheck>false</BufferSecurityCheck>
@@ -112,25 +123,29 @@
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<OmitFramePointers>false</OmitFramePointers> <OmitFramePointers>false</OmitFramePointers>
<CallingConvention>StdCall</CallingConvention> <CallingConvention>Cdecl</CallingConvention>
<StringPooling>true</StringPooling>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<FloatingPointExceptions>false</FloatingPointExceptions>
<UseUnicodeForAssemblerListing>true</UseUnicodeForAssemblerListing>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>false</GenerateDebugInformation> <GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding> <EnableCOMDATFolding>false</EnableCOMDATFolding>
</EnableCOMDATFolding>
<OptimizeReferences> <OptimizeReferences>
</OptimizeReferences> </OptimizeReferences>
<Version>1.0</Version> <Version>1.0</Version>
<LinkStatus> <LinkStatus>
</LinkStatus> </LinkStatus>
<CreateHotPatchableImage>Enabled</CreateHotPatchableImage>
<FixedBaseAddress>false</FixedBaseAddress>
</Link> </Link>
<ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="BlitzHybrid.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="BlitzNative.cpp" />
<ClCompile Include="BlitzPointer.cpp" /> <ClCompile Include="BlitzPointer.cpp" />
<ClCompile Include="dllmain.cpp" /> <ClCompile Include="dllmain.cpp" />
<ClCompile Include="MemoryHelpers.cpp" /> <ClCompile Include="MemoryHelpers.cpp" />
@@ -141,11 +156,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="LICENSE"> <None Include="LICENSE">
<Link>LICENSE</Link> <Link>BlitzPointer.LICENSE</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="LICENSE.lesser"> <None Include="LICENSE.lesser">
<Link>LICENSE.lesser</Link> <Link>BlitzPointer.LICENSE.lesser</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="Blitz\BlitzPointer.decls"> <None Include="Blitz\BlitzPointer.decls">
+2 -6
View File
@@ -17,12 +17,6 @@
<ClCompile Include="BlitzPointer.cpp"> <ClCompile Include="BlitzPointer.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="BlitzNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="BlitzHybrid.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MemoryHelpers.cpp"> <ClCompile Include="MemoryHelpers.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@@ -66,5 +60,7 @@
<None Include="Blitz\Example07.bb"> <None Include="Blitz\Example07.bb">
<Filter>Blitz Files</Filter> <Filter>Blitz Files</Filter>
</None> </None>
<None Include="LICENSE" />
<None Include="LICENSE.lesser" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+10 -10
View File
@@ -16,7 +16,7 @@
#include "dllmain.h" #include "dllmain.h"
DLL_EXPORT uint32_t PeekMemory(uint32_t* address, uint32_t length, intptr_t bank) { DLL_METHOD uint32_t DLL_CALL PeekMemory(uint32_t* address, uint32_t length, intptr_t bank) {
uint32_t bankAddress, bankSize; uint32_t bankAddress, bankSize;
bankAddress = *(uint32_t*)(bank + 4); bankAddress = *(uint32_t*)(bank + 4);
bankSize = *(uint32_t*)(bank + 8); bankSize = *(uint32_t*)(bank + 8);
@@ -32,7 +32,7 @@ DLL_EXPORT uint32_t PeekMemory(uint32_t* address, uint32_t length, intptr_t bank
} }
#pragma comment(linker, "/EXPORT:PeekMemory=_PeekMemory@12") #pragma comment(linker, "/EXPORT:PeekMemory=_PeekMemory@12")
DLL_EXPORT uint32_t PokeMemory(uint32_t address, uint32_t length, intptr_t bank) { DLL_METHOD uint32_t DLL_CALL PokeMemory(uint32_t address, uint32_t length, intptr_t bank) {
uint32_t bankAddress, bankSize; uint32_t bankAddress, bankSize;
bankAddress = *(uint32_t*)(bank + 4); bankAddress = *(uint32_t*)(bank + 4);
bankSize = *(uint32_t*)(bank + 8); bankSize = *(uint32_t*)(bank + 8);
@@ -48,42 +48,42 @@ DLL_EXPORT uint32_t PokeMemory(uint32_t address, uint32_t length, intptr_t bank)
} }
#pragma comment(linker, "/EXPORT:PokeMemory=_PokeMemory@12") #pragma comment(linker, "/EXPORT:PokeMemory=_PokeMemory@12")
DLL_EXPORT int8_t PeekMemoryByte(uint32_t* address) { DLL_METHOD int8_t DLL_CALL PeekMemoryByte(uint32_t* address) {
return *(int8_t*)address; return *(int8_t*)address;
} }
#pragma comment(linker, "/EXPORT:PeekMemoryByte=_PeekMemoryByte@4") #pragma comment(linker, "/EXPORT:PeekMemoryByte=_PeekMemoryByte@4")
DLL_EXPORT void PokeMemoryByte(uint32_t* address, int8_t value) { DLL_METHOD void DLL_CALL PokeMemoryByte(uint32_t* address, int8_t value) {
*(int8_t*)address = value; *(int8_t*)address = value;
} }
#pragma comment(linker, "/EXPORT:PokeMemoryByte=_PokeMemoryByte@8") #pragma comment(linker, "/EXPORT:PokeMemoryByte=_PokeMemoryByte@8")
DLL_EXPORT int16_t PeekMemoryShort(uint32_t* address) { DLL_METHOD int16_t DLL_CALL PeekMemoryShort(uint32_t* address) {
return *(int16_t*)address; return *(int16_t*)address;
} }
#pragma comment(linker, "/EXPORT:PeekMemoryShort=_PeekMemoryShort@4") #pragma comment(linker, "/EXPORT:PeekMemoryShort=_PeekMemoryShort@4")
DLL_EXPORT void PokeMemoryShort(uint32_t* address, int16_t value) { DLL_METHOD void DLL_CALL PokeMemoryShort(uint32_t* address, int16_t value) {
*(int16_t*)address = value; *(int16_t*)address = value;
} }
#pragma comment(linker, "/EXPORT:PokeMemoryShort=_PokeMemoryShort@8") #pragma comment(linker, "/EXPORT:PokeMemoryShort=_PokeMemoryShort@8")
DLL_EXPORT int32_t PeekMemoryInt(uint32_t* address) { DLL_METHOD int32_t DLL_CALL PeekMemoryInt(uint32_t* address) {
return *(int32_t*)address; return *(int32_t*)address;
} }
#pragma comment(linker, "/EXPORT:PeekMemoryInt=_PeekMemoryInt@4") #pragma comment(linker, "/EXPORT:PeekMemoryInt=_PeekMemoryInt@4")
DLL_EXPORT void PokeMemoryInt(uint32_t* address, int32_t value) { DLL_METHOD void DLL_CALL PokeMemoryInt(uint32_t* address, int32_t value) {
*(int32_t*)address = value; *(int32_t*)address = value;
} }
#pragma comment(linker, "/EXPORT:PokeMemoryInt=_PokeMemoryInt@8") #pragma comment(linker, "/EXPORT:PokeMemoryInt=_PokeMemoryInt@8")
DLL_EXPORT float_t PeekMemoryFloat(uint32_t* address) { DLL_METHOD float_t DLL_CALL PeekMemoryFloat(uint32_t* address) {
return *(float_t*)address; return *(float_t*)address;
} }
#pragma comment(linker, "/EXPORT:PeekMemoryFloat=_PeekMemoryFloat@4") #pragma comment(linker, "/EXPORT:PeekMemoryFloat=_PeekMemoryFloat@4")
DLL_EXPORT void PokeMemoryFloat(uint32_t* address, float_t value) { DLL_METHOD void DLL_CALL PokeMemoryFloat(uint32_t* address, float_t value) {
*(float_t*)address = value; *(float_t*)address = value;
} }
#pragma comment(linker, "/EXPORT:PokeMemoryFloat=_PokeMemoryFloat@8") #pragma comment(linker, "/EXPORT:PokeMemoryFloat=_PokeMemoryFloat@8")
+3 -4
View File
@@ -14,9 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License // 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/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// STL Exceptions #pragma once
#include <exception>
#include <stdexcept>
// Memory Management // Memory Management
#include <memory> #include <memory>
@@ -25,4 +23,5 @@
#include <windows.h> #include <windows.h>
// Macros // Macros
#define DLL_EXPORT extern "C" //__declspec(dllexport) #define DLL_METHOD extern "C"
#define DLL_CALL __stdcall