Skip to content

Commit

Permalink
Move to VS2019 and C++17 (#54)
Browse files Browse the repository at this point in the history
* big clean

* Move more code out of header

* consts and references

* fmt

* fmt

* More renaming
  • Loading branch information
Matt-Hurd committed Aug 5, 2019
1 parent 0a67e5f commit 9bda87d
Show file tree
Hide file tree
Showing 41 changed files with 1,598 additions and 1,465 deletions.
3 changes: 3 additions & 0 deletions PythonSDK.sln.DotSettings.user
@@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Undefine/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=WINAPI/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
21 changes: 12 additions & 9 deletions PythonSDK.vcxproj
Expand Up @@ -33,6 +33,7 @@
<ClCompile Include="src\BL2SDK\WinDrv_functions.cpp" />
<ClCompile Include="src\BL2SDK\XAudio2_functions.cpp" />
<ClCompile Include="src\CHookManager.cpp" />
<ClCompile Include="src\CoreExtensions.cpp" />
<ClCompile Include="src\CPythonInterface.cpp" />
<ClCompile Include="src\CSigScan.cpp" />
<ClCompile Include="src\CSimpleDetour.cpp" />
Expand Down Expand Up @@ -122,7 +123,6 @@
<ClInclude Include="src\include\pybind11\stl.h" />
<ClInclude Include="src\include\pybind11\stl_bind.h" />
<ClInclude Include="src\include\pydef.h" />
<ClInclude Include="src\include\resource.h" />
<ClInclude Include="src\include\Settings.h" />
<ClInclude Include="src\include\Signatures.h" />
<ClInclude Include="src\include\stb_image.h" />
Expand All @@ -135,7 +135,7 @@
<ProjectGuid>{32794345-2BB2-45E0-A461-914D13B0279F}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>bl2sdk</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>Borderlands 2 SDK</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Expand All @@ -149,7 +149,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down Expand Up @@ -267,29 +267,32 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Create</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MinSpace</Optimization>
<WarningLevel>Level4</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>
</IntrinsicFunctions>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;BL2SDK_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)src\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<MultiProcessorCompilation>false</MultiProcessorCompilation>
<MultiProcessorCompilation>
</MultiProcessorCompilation>
<DebugInformationFormat>
</DebugInformationFormat>
<MinimalRebuild>
</MinimalRebuild>
<WholeProgramOptimization>true</WholeProgramOptimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations />
<BufferSecurityCheck />
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
<TreatWarningAsError>false</TreatWarningAsError>
<DisableSpecificWarnings>4100;4121;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
6 changes: 3 additions & 3 deletions PythonSDK.vcxproj.filters
Expand Up @@ -101,9 +101,6 @@
<ClInclude Include="src\include\pydef.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\Settings.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -391,5 +388,8 @@
<ClCompile Include="src\CHookManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\CoreExtensions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
22 changes: 14 additions & 8 deletions src/AntiDebug.cpp
Expand Up @@ -10,7 +10,7 @@

namespace BL2SDK
{
typedef NTSTATUS(WINAPI* tNtSIT) (HANDLE, THREAD_INFORMATION_CLASS, PVOID, ULONG);
typedef NTSTATUS (WINAPI* tNtSIT)(HANDLE, THREAD_INFORMATION_CLASS, PVOID, ULONG);
tNtSIT pNtSetInformationThread = nullptr;

NTSTATUS NTAPI hkNtSetInformationThread(
Expand All @@ -25,10 +25,11 @@ namespace BL2SDK
return STATUS_SUCCESS;
}

return pNtSetInformationThread(ThreadHandle, ThreadInformationClass, ThreadInformation, ThreadInformationLength);
return pNtSetInformationThread(ThreadHandle, ThreadInformationClass, ThreadInformation,
ThreadInformationLength);
}

typedef NTSTATUS(WINAPI* tNtQIP) (HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
typedef NTSTATUS (WINAPI* tNtQIP)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
tNtQIP pNtQueryInformationProcess = nullptr;

NTSTATUS WINAPI hkNtQueryInformationProcess(
Expand All @@ -43,21 +44,24 @@ namespace BL2SDK
return STATUS_PORT_NOT_SET;
}

return pNtQueryInformationProcess(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength, ReturnLength);
return pNtQueryInformationProcess(ProcessHandle, ProcessInformationClass, ProcessInformation,
ProcessInformationLength, ReturnLength);
}

void HookAntiDebug()
{
HMODULE hNtdll = GetModuleHandle(L"ntdll.dll");
if (!hNtdll)
{
throw FatalSDKException(7000, Util::Format("GetModuleHandle failed for ntdll.dll (Error = 0x%X)", GetLastError()));
throw FatalSDKException(7000, Util::Format("GetModuleHandle failed for ntdll.dll (Error = 0x%X)",
GetLastError()));
}

pNtSetInformationThread = (tNtSIT)GetProcAddress(hNtdll, "NtSetInformationThread");
if (!pNtSetInformationThread)
{
throw FatalSDKException(7001, Util::Format("GetProcAddress failed for NtSetInformationThread (Error = 0x%X)", GetLastError()));
throw FatalSDKException(
7001, Util::Format("GetProcAddress failed for NtSetInformationThread (Error = 0x%X)", GetLastError()));
}

SETUP_SIMPLE_DETOUR(detNtSIT, pNtSetInformationThread, hkNtSetInformationThread);
Expand All @@ -67,11 +71,13 @@ namespace BL2SDK
pNtQueryInformationProcess = (tNtQIP)GetProcAddress(hNtdll, "NtQueryInformationProcess");
if (!pNtQueryInformationProcess)
{
throw FatalSDKException(7002, Util::Format("GetProcAddress failed for NtQueryInformationProcess (Error = 0x%X)", GetLastError()));
throw FatalSDKException(
7002, Util::Format("GetProcAddress failed for NtQueryInformationProcess (Error = 0x%X)",
GetLastError()));
}

SETUP_SIMPLE_DETOUR(detNtQIP, pNtQueryInformationProcess, hkNtQueryInformationProcess);
detNtQIP.Attach();
Logging::Log("[AntiDebug] Hook added for NtQueryInformationProcess\n");
}
}
}

0 comments on commit 9bda87d

Please sign in to comment.