5 Commits

4 changed files with 1140 additions and 1135 deletions
+32 -29
View File
@@ -21,6 +21,7 @@
#include "BlitzPointer.h"
DLL_METHOD intptr_t DLL_CALL BP_GetReturnAddress() {
#pragma comment(linker, "/EXPORT:BP_GetReturnAddress=_BP_GetReturnAddress@0")
intptr_t BasePointer, ReturnAddress;
__asm { //ASM. Do touch if suicidal.
@@ -29,14 +30,15 @@ DLL_METHOD intptr_t DLL_CALL BP_GetReturnAddress() {
// 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);
//-- Parent_EBP = *EBP
//-- Parent_RP = Parent_EBP + 16
ReturnAddress = *(intptr_t*)((*(intptr_t*)BasePointer) + 16);
return ReturnAddress;
}
#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() {
#pragma comment(linker, "/EXPORT:BP_GetFunctionPointer=_BP_GetFunctionPointer@0")
intptr_t BasePointer, ReturnAddress, FunctionPointer;
__asm { //ASM. Do touch if suicidal.
@@ -45,65 +47,66 @@ DLL_METHOD intptr_t DLL_CALL BP_GetFunctionPointer()
// 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);
//-- Parent_EBP = *EBP
//-- Parent_RP = Parent_EBP + 16
ReturnAddress = *(intptr_t*)((*(intptr_t*)BasePointer) + 16);
// And since it's a Call-Near, the call is offset to the return address.
FunctionPointer = ReturnAddress + *reinterpret_cast<intptr_t*>(ReturnAddress - 4);
FunctionPointer = ReturnAddress + *(intptr_t*)(ReturnAddress - 4);
return FunctionPointer;
}
#pragma comment(linker, "/EXPORT:BP_GetFunctionPointer=_BP_GetFunctionPointer@0")
DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointer(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 -9 bytes offset to the return address.
return *reinterpret_cast<int32_t*>(*reinterpret_cast<intptr_t*>(BasePointer + 4) - 9);
}
DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointer(int32_t pVariable) {
#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);
// The Variable pointer that is used is at -9 bytes offset to the return address of this function.
return *(intptr_t*)(*(intptr_t*)(BasePointer + 4) - 9);
}
DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointerType(int32_t pVariable) {
#pragma comment(linker, "/EXPORT:BP_GetVariablePointerType=_BP_GetVariablePointerType@4")
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 of this function.
return *(intptr_t*)(*(intptr_t*)(BasePointer + 4) - 11);
}
DLL_METHOD int32_t DLL_CALL BP_CallFunction0(BP_BlitzFunction0_t lpFunctionPointer) {
#pragma comment(linker, "/EXPORT:BP_CallFunction0=_BP_CallFunction0@4")
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) {
#pragma comment(linker, "/EXPORT:BP_CallFunction1=_BP_CallFunction1@8")
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) {
#pragma comment(linker, "/EXPORT:BP_CallFunction2=_BP_CallFunction2@12")
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) {
#pragma comment(linker, "/EXPORT:BP_CallFunction3=_BP_CallFunction3@16")
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) {
#pragma comment(linker, "/EXPORT:BP_CallFunction4=_BP_CallFunction4@20")
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) {
#pragma comment(linker, "/EXPORT:BP_CallFunction5=_BP_CallFunction5@24")
return lpFunctionPointer(p1, p2, p3, p4, p5);
}
#pragma comment(linker, "/EXPORT:BP_CallFunction5=_BP_CallFunction5@24")
}
+1091 -1089
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -29,6 +29,8 @@ typedef int32_t(__stdcall *BP_BlitzFunction5_t)(int32_t, int32_t, int32_t, int32
// Basic Functionality (Pointer retrieval)
DLL_METHOD intptr_t DLL_CALL BP_GetReturnAddress();
DLL_METHOD intptr_t DLL_CALL BP_GetFunctionPointer();
/*DLL_METHOD intptr_t DLL_CALL BP_GetLastCalledFunctionPointer( );
DLL_METHOD intptr_t DLL_CALL BP_GetNextCalledFunctionPointer();*/
DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointer(int32_t pVariable);
DLL_METHOD intptr_t DLL_CALL BP_GetVariablePointerType(int32_t pVariable);
+15 -17
View File
@@ -13,6 +13,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{AC8F52F4-9FE6-4CEF-B549-8180757020C8}</ProjectGuid>
<RootNamespace>BlitzPointer</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -39,14 +40,14 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)\#Build\$(ProjectName)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)\#Intermediate\$(ProjectName)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)#Build\$(ProjectName)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)#Intermediate\$(ProjectName)\$(Configuration)\</IntDir>
<TargetExt>.dll</TargetExt>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)\#Build\$(ProjectName)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)\#Intermediate\$(ProjectName)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)#Build\$(ProjectName)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)#Intermediate\$(ProjectName)\$(Configuration)\</IntDir>
<TargetExt>.dll</TargetExt>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
@@ -54,11 +55,9 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>
</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
@@ -66,8 +65,8 @@
<CompileAsWinRT>false</CompileAsWinRT>
<StructMemberAlignment>4Bytes</StructMemberAlignment>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<CreateHotpatchableImage>true</CreateHotpatchableImage>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<OpenMPSupport>false</OpenMPSupport>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
@@ -79,8 +78,8 @@
<IntrinsicFunctions>false</IntrinsicFunctions>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<StringPooling>true</StringPooling>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<FloatingPointExceptions>false</FloatingPointExceptions>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointExceptions>true</FloatingPointExceptions>
<UseUnicodeForAssemblerListing>true</UseUnicodeForAssemblerListing>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
@@ -102,10 +101,8 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Full</Optimization>
<FunctionLevelLinking>false</FunctionLevelLinking>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>
</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
@@ -122,14 +119,15 @@
</ForcedIncludeFiles>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<MinimalRebuild>false</MinimalRebuild>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<OmitFramePointers>false</OmitFramePointers>
<CallingConvention>Cdecl</CallingConvention>
<StringPooling>true</StringPooling>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<FloatingPointExceptions>false</FloatingPointExceptions>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointExceptions>true</FloatingPointExceptions>
<UseUnicodeForAssemblerListing>true</UseUnicodeForAssemblerListing>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>None</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>false</GenerateDebugInformation>