Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ce731d795f | |||
| 78aac62649 | |||
| 5581958a44 | |||
| a1d252deba | |||
| 880e754254 |
+1097
-368
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -38,14 +38,14 @@ Global fpOurFunction = 0
|
||||
|
||||
; 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?
|
||||
; 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.
|
||||
Function OurFunction()
|
||||
; 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.
|
||||
If fpOurFunction = 0 Then
|
||||
; 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
|
||||
; faster in Blitz, as using Else causes a complex ASM construction.
|
||||
Return
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ ExampleInit()
|
||||
Global fpOurFunction = 0
|
||||
Function OurFunction()
|
||||
If fpOurFunction = 0 Then
|
||||
fpOurFunction = BlitzPointer_GetFunctionPointer()
|
||||
fpOurFunction = BP_GetFunctionPointer()
|
||||
Return
|
||||
EndIf
|
||||
|
||||
@@ -44,7 +44,7 @@ While Not KeyHit(1)
|
||||
; BlitzPointer offers many ways of calling our function pointer. Each one
|
||||
; describes different return types, parameter count and parameter types.
|
||||
; 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
|
||||
; function pointer instead. Pretty useful in my opinion, especially for UI,
|
||||
; networking, fake classes, etc.
|
||||
|
||||
+9
-9
@@ -29,9 +29,9 @@
|
||||
; ---------------------------------------------------------------------------- ;
|
||||
; Type Id Description Calling Function
|
||||
; ---------------------------------------------------------------------------- ;
|
||||
; void V Nothing BlitzPointer_CallFunctionV
|
||||
; int I 32-bit Integer BlitzPointer_CallFunctionI
|
||||
; float F Floating Point BlitzPointer_CallFunctionF
|
||||
; void V Nothing BP_CallFunctionV
|
||||
; int I 32-bit Integer BP_CallFunctionI
|
||||
; float F Floating Point BP_CallFunctionF
|
||||
|
||||
; Now that we know what we can and can't do (without memory leaks at least),
|
||||
; let's try out the return types ourselves.
|
||||
@@ -43,7 +43,7 @@ ExampleInit()
|
||||
Global fpVoidFunction = 0
|
||||
Function VoidFunction()
|
||||
If fpVoidFunction = 0 Then
|
||||
fpVoidFunction = BlitzPointer_GetFunctionPointer()
|
||||
fpVoidFunction = BP_GetFunctionPointer()
|
||||
Return
|
||||
EndIf
|
||||
Text 0, 0, "Void Return Type"
|
||||
@@ -54,7 +54,7 @@ VoidFunction()
|
||||
Global fpIntFunction = 0
|
||||
Function IntFunction%()
|
||||
If fpIntFunction = 0 Then
|
||||
fpIntFunction = BlitzPointer_GetFunctionPointer()
|
||||
fpIntFunction = BP_GetFunctionPointer()
|
||||
Return
|
||||
EndIf
|
||||
Text 0, 15, "Int Return Type"
|
||||
@@ -66,7 +66,7 @@ IntFunction()
|
||||
Global fpFloatFunction = 0
|
||||
Function FloatFunction#()
|
||||
If fpFloatFunction = 0 Then
|
||||
fpFloatFunction = BlitzPointer_GetFunctionPointer()
|
||||
fpFloatFunction = BP_GetFunctionPointer()
|
||||
Return
|
||||
EndIf
|
||||
Text 0, 30, "Float Return Type"
|
||||
@@ -78,9 +78,9 @@ While Not KeyHit(1)
|
||||
ExampleUpdate()
|
||||
|
||||
; Calling the function and using the return value is really easy to do now:
|
||||
BlitzPointer_CallFunctionV(fpVoidFunction) ; void returns nothing.
|
||||
Text 200, 15, BlitzPointer_CallFunctionI(fpIntFunction)
|
||||
Text 200, 30, BlitzPointer_CallFunctionF(fpFloatFunction)
|
||||
BP_CallFunctionV(fpVoidFunction) ; void returns nothing.
|
||||
Text 200, 15, BP_CallFunctionI(fpIntFunction)
|
||||
Text 200, 30, BP_CallFunctionF(fpFloatFunction)
|
||||
|
||||
ExampleLoop()
|
||||
Wend
|
||||
|
||||
+10
-10
@@ -31,9 +31,9 @@
|
||||
; ---------------------------------------------------------------------------- ;
|
||||
; Type Id Description Calling Function
|
||||
; ---------------------------------------------------------------------------- ;
|
||||
; int I 32-bit Integer BlitzPointer_CallFunction*I
|
||||
; float F Floating Point BlitzPointer_CallFunction*F
|
||||
; pointer P Memory Pointer BlitzPointer_CallFunction*P
|
||||
; int I 32-bit Integer BP_CallFunction*I
|
||||
; float F Floating Point BP_CallFunction*F
|
||||
; pointer P Memory Pointer BP_CallFunction*P
|
||||
|
||||
; Watch out:
|
||||
; Calling a function that has parameters without giving enough parameters will
|
||||
@@ -47,7 +47,7 @@ ExampleInit()
|
||||
Global fpCurInGameSecond = 0
|
||||
Function CurInGameSecond%(p1%=0)
|
||||
If fpCurInGameSecond = 0 Then
|
||||
fpCurInGameSecond = BlitzPointer_GetFunctionPointer()
|
||||
fpCurInGameSecond = BP_GetFunctionPointer()
|
||||
Return
|
||||
EndIf
|
||||
Text 5, 15, "IIFunction"
|
||||
@@ -61,7 +61,7 @@ CurInGameSecond()
|
||||
Global fpCurInGameSecondEx = 0
|
||||
Function CurInGameSecondEx#(p1%=0, p2#=0)
|
||||
If fpCurInGameSecondEx = 0 Then
|
||||
fpCurInGameSecondEx = BlitzPointer_GetFunctionPointer()
|
||||
fpCurInGameSecondEx = BP_GetFunctionPointer()
|
||||
Return
|
||||
EndIf
|
||||
|
||||
@@ -78,7 +78,7 @@ CurInGameSecondEx()
|
||||
Global fpConvertIntFloat
|
||||
Function ConvertIntFloat#(p1#=0)
|
||||
If fpConvertIntFloat = 0 Then
|
||||
fpConvertIntFloat = BlitzPointer_GetFunctionPointer()
|
||||
fpConvertIntFloat = BP_GetFunctionPointer()
|
||||
Print Hex(fpConvertIntFloat)
|
||||
WaitKey()
|
||||
Return
|
||||
@@ -101,18 +101,18 @@ While Not KeyHit(1)
|
||||
Text 480, 0, "Parameter 4"
|
||||
Text 600, 0, "Result"
|
||||
|
||||
Text 605, 15, BlitzPointer_CallFunctionII(fpCurInGameSecond, Frame)
|
||||
Text 605, 30, BlitzPointer_CallFunctionFIF(fpCurInGameSecondEx, Frame, 0.016666666)
|
||||
Text 605, 15, BP_CallFunctionII(fpCurInGameSecond, Frame)
|
||||
Text 605, 30, BP_CallFunctionFIF(fpCurInGameSecondEx, Frame, 0.016666666)
|
||||
|
||||
Local TempFlt# = Frame / 60.0
|
||||
Local TempInt% = BlitzPointer_CallFunctionIF(fpConvertIntFloat, TempFlt)
|
||||
Local TempInt% = BP_CallFunctionIF(fpConvertIntFloat, TempFlt)
|
||||
Text 5, 60, "Float -> Int"
|
||||
Text 125, 60, TempFlt
|
||||
Text 605, 60, Hex(TempInt)
|
||||
|
||||
Text 5, 75, "Int -> Float"
|
||||
Text 125, 75, Hex(TempInt)
|
||||
Text 605, 75, BlitzPointer_CallFunctionFI(fpConvertIntFloat, TempInt)
|
||||
Text 605, 75, BP_CallFunctionFI(fpConvertIntFloat, TempInt)
|
||||
|
||||
ExampleLoop()
|
||||
|
||||
|
||||
+3
-3
@@ -41,7 +41,7 @@ End Type
|
||||
Global fpMyTypeFunc = 0
|
||||
Function MyTypeFunc(This.MyType)
|
||||
If fpMyTypeFunc = 0 Then
|
||||
fpMyTypeFunc = BlitzPointer_GetFunctionPointer()
|
||||
fpMyTypeFunc = BP_GetFunctionPointer()
|
||||
Return
|
||||
EndIf
|
||||
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
|
||||
; from it. Thankfully, Blitz has this already built in: Int().
|
||||
If KeyDown(2) Then BlitzPointer_CallFunctionVI fpMyTypeFunc, Int(MT1)
|
||||
If KeyDown(3) Then BlitzPointer_CallFunctionVI fpMyTypeFunc, Int(MT2)
|
||||
If KeyDown(2) Then BP_CallFunctionVI fpMyTypeFunc, Int(MT1)
|
||||
If KeyDown(3) Then BP_CallFunctionVI fpMyTypeFunc, Int(MT2)
|
||||
|
||||
ExampleLoop()
|
||||
Wend
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ End Type
|
||||
Global fpMyPointerFunction% = 0
|
||||
Function MyPointerFunction(Pointer%)
|
||||
If fpMyPointerFunction = 0 Then
|
||||
fpMyPointerFunction = BlitzPointer_GetFunctionPointer()
|
||||
fpMyPointerFunction = BP_GetFunctionPointer()
|
||||
Return
|
||||
EndIf
|
||||
|
||||
|
||||
+3
-3
@@ -54,7 +54,7 @@ Function TGenericUpdate()
|
||||
Local This.TGeneric
|
||||
For This = Each TGeneric
|
||||
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
|
||||
EndIf
|
||||
EndIf
|
||||
@@ -98,7 +98,7 @@ End Function
|
||||
|
||||
Function TCubeCallback%(This.TCube)
|
||||
If CallbackIndex(CALLBACK_INDEX_TCUBE) = 0 Then
|
||||
CallbackIndex(CALLBACK_INDEX_TCUBE) = BlitzPointer_GetFunctionPointer()
|
||||
CallbackIndex(CALLBACK_INDEX_TCUBE) = BP_GetFunctionPointer()
|
||||
Return
|
||||
EndIf
|
||||
; Safeguard against stupidity (it affect everyone).
|
||||
@@ -156,7 +156,7 @@ End Function
|
||||
|
||||
Function TSphereUpdate%(This.TSphere)
|
||||
If CallbackIndex(CALLBACK_INDEX_TSPHERE) = 0 Then
|
||||
CallbackIndex(CALLBACK_INDEX_TSPHERE) = BlitzPointer_GetFunctionPointer()
|
||||
CallbackIndex(CALLBACK_INDEX_TSPHERE) = BP_GetFunctionPointer()
|
||||
Return
|
||||
EndIf
|
||||
; Safeguard against stupidity (it affect everyone).
|
||||
|
||||
-150
@@ -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()
|
||||
|
||||
*/
|
||||
@@ -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
@@ -17,9 +17,10 @@
|
||||
// Idea take from Code by Noodoby<http://www.blitzforum.de/forum/viewtopic.php?t=31651>
|
||||
// New Code by Xaymar<http://project-kube.de>
|
||||
|
||||
#pragma once
|
||||
#include "BlitzPointer.h"
|
||||
|
||||
DLL_EXPORT intptr_t BlitzPointer_GetReturnAddress() {
|
||||
DLL_METHOD intptr_t DLL_CALL BP_GetReturnAddress() {
|
||||
intptr_t StackPointer, ReturnAddress;
|
||||
|
||||
__asm { //ASM. Do touch if suicidal.
|
||||
@@ -32,9 +33,9 @@ DLL_EXPORT intptr_t BlitzPointer_GetReturnAddress() {
|
||||
|
||||
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;
|
||||
|
||||
@@ -60,4 +61,42 @@ DLL_EXPORT intptr_t BlitzPointer_GetFunctionPointer()
|
||||
|
||||
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
@@ -18,18 +18,23 @@
|
||||
#include "dllmain.h"
|
||||
#include <string>
|
||||
|
||||
DLL_EXPORT intptr_t BlitzPointer_GetReturnAddress();
|
||||
DLL_EXPORT intptr_t BlitzPointer_GetFunctionPointer();
|
||||
// Types of Blitz Functions.
|
||||
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.
|
||||
#define CALLFUNCTION_DECL_BEGIN(NAME) DLL_EXPORT int32_t BlitzPointer_CallFunction##NAME(intptr_t lpFunctionPointer
|
||||
#define CALLFUNCTION_DECL_PARAMETER(TYPE, NAME) , TYPE NAME
|
||||
#define CALLFUNCTION_DECL_END() )
|
||||
#define CALLFUNCTION_IMPL_BEGIN() {
|
||||
#define CALLFUNCTION_IMPL_SAFEGUARD() if (!lpFunctionPointer) return NULL;
|
||||
#define CALLFUNCTION_IMPL_PREPARE(COUNT) __asm SUB ESP, COUNT * 4
|
||||
#define CALLFUNCTION_IMPL_PARAMETER(INDEX, NAME) __asm MOV EAX, [NAME] __asm MOV [ESP + INDEX * 4], EAX
|
||||
#define CALLFUNCTION_IMPL_CALL() __asm CALL DWORD ptr[lpFunctionPointer]
|
||||
#define CALLFUNCTION_IMPL_RESULT() int32_t result; __asm MOV [result], EAX
|
||||
#define CALLFUNCTION_IMPL_RETURN() return result;
|
||||
#define CALLFUNCTION_IMPL_END() }
|
||||
// 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();
|
||||
|
||||
// Native Blitz Function Calls
|
||||
DLL_METHOD int32_t DLL_CALL BP_CallFunction0(BP_BlitzFunction0_t lpFunctionPointer);
|
||||
DLL_METHOD int32_t DLL_CALL BP_CallFunction1(BP_BlitzFunction1_t lpFunctionPointer, int32_t p1);
|
||||
DLL_METHOD int32_t DLL_CALL BP_CallFunction2(BP_BlitzFunction2_t lpFunctionPointer, int32_t p1, int32_t p2);
|
||||
DLL_METHOD int32_t DLL_CALL BP_CallFunction3(BP_BlitzFunction3_t lpFunctionPointer, int32_t p1, int32_t p2, int32_t p3);
|
||||
DLL_METHOD int32_t DLL_CALL BP_CallFunction4(BP_BlitzFunction4_t lpFunctionPointer, int32_t p1, int32_t p2, int32_t p3, int32_t p4);
|
||||
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
@@ -43,14 +43,12 @@
|
||||
<IntDir>$(SolutionDir)\#Intermediate\$(ProjectName)\$(Configuration)\</IntDir>
|
||||
<TargetExt>.dll</TargetExt>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)\#Build\$(ProjectName)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\#Intermediate\$(ProjectName)\$(Configuration)\</IntDir>
|
||||
<TargetExt>.dll</TargetExt>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -58,8 +56,8 @@
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir);$(ProjectDir)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>false</MultiProcessorCompilation>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
@@ -77,14 +75,27 @@
|
||||
<PreprocessKeepComments>false</PreprocessKeepComments>
|
||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
||||
<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>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<Version>1.0</Version>
|
||||
<LinkStatus>
|
||||
</LinkStatus>
|
||||
<CreateHotPatchableImage>Enabled</CreateHotPatchableImage>
|
||||
<EnableCOMDATFolding>false</EnableCOMDATFolding>
|
||||
<FixedBaseAddress>false</FixedBaseAddress>
|
||||
</Link>
|
||||
<ProjectReference>
|
||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
||||
</ProjectReference>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
@@ -94,8 +105,8 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir);$(ProjectDir)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>false</MultiProcessorCompilation>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
@@ -112,25 +123,29 @@
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<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>
|
||||
<Link>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>
|
||||
</EnableCOMDATFolding>
|
||||
<EnableCOMDATFolding>false</EnableCOMDATFolding>
|
||||
<OptimizeReferences>
|
||||
</OptimizeReferences>
|
||||
<Version>1.0</Version>
|
||||
<LinkStatus>
|
||||
</LinkStatus>
|
||||
<CreateHotPatchableImage>Enabled</CreateHotPatchableImage>
|
||||
<FixedBaseAddress>false</FixedBaseAddress>
|
||||
</Link>
|
||||
<ProjectReference>
|
||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
||||
</ProjectReference>
|
||||
</ItemDefinitionGroup>
|
||||
<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="dllmain.cpp" />
|
||||
<ClCompile Include="MemoryHelpers.cpp" />
|
||||
@@ -141,11 +156,11 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="LICENSE">
|
||||
<Link>LICENSE</Link>
|
||||
<Link>BlitzPointer.LICENSE</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="LICENSE.lesser">
|
||||
<Link>LICENSE.lesser</Link>
|
||||
<Link>BlitzPointer.LICENSE.lesser</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Blitz\BlitzPointer.decls">
|
||||
|
||||
@@ -17,12 +17,6 @@
|
||||
<ClCompile Include="BlitzPointer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BlitzNative.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BlitzHybrid.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MemoryHelpers.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -66,5 +60,7 @@
|
||||
<None Include="Blitz\Example07.bb">
|
||||
<Filter>Blitz Files</Filter>
|
||||
</None>
|
||||
<None Include="LICENSE" />
|
||||
<None Include="LICENSE.lesser" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+10
-10
@@ -16,7 +16,7 @@
|
||||
|
||||
#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;
|
||||
bankAddress = *(uint32_t*)(bank + 4);
|
||||
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")
|
||||
|
||||
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;
|
||||
bankAddress = *(uint32_t*)(bank + 4);
|
||||
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")
|
||||
|
||||
DLL_EXPORT int8_t PeekMemoryByte(uint32_t* address) {
|
||||
DLL_METHOD int8_t DLL_CALL PeekMemoryByte(uint32_t* address) {
|
||||
return *(int8_t*)address;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
#pragma comment(linker, "/EXPORT:PokeMemoryFloat=_PokeMemoryFloat@8")
|
||||
|
||||
@@ -14,9 +14,7 @@
|
||||
// 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/>.
|
||||
|
||||
// STL Exceptions
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#pragma once
|
||||
|
||||
// Memory Management
|
||||
#include <memory>
|
||||
@@ -25,4 +23,5 @@
|
||||
#include <windows.h>
|
||||
|
||||
// Macros
|
||||
#define DLL_EXPORT extern "C" //__declspec(dllexport)
|
||||
#define DLL_METHOD extern "C"
|
||||
#define DLL_CALL __stdcall
|
||||
Reference in New Issue
Block a user