Skip to content

Commit

Permalink
A bit of "pre-release" cleanup
Browse files Browse the repository at this point in the history
Added something to the build events to delete the original DX11 dll from the game dir for proper testing.
  • Loading branch information
FromDarkHell committed Dec 20, 2020
1 parent 47255ac commit 87a71de
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
4 changes: 4 additions & 0 deletions BL3DX11Injection/BL3DX11Injection.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
</ModuleDefinitionFile>
<ImportLibrary>$(ProjectDir)$(TargetName).lib</ImportLibrary>
</Link>
<PostBuildEvent>
<Command>del "$(TargetDir)d3d11_org.dll"
del "$(TargetDir)PluginLoader.log"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="dllmain.h" />
Expand Down
3 changes: 0 additions & 3 deletions BL3DX11Injection/PluginLoadHook.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@


VOID WINAPI ExitProcessHook(ULONG ExitCode);

void PluginLoadFunction(std::wstring dll, long delay);

void InitializePluginHooks(HMODULE gameModule);

void LoadPlugins();
18 changes: 8 additions & 10 deletions BL3DX11Injection/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
#include "ThreadManager.hpp"
#pragma pack(1)




static HINSTANCE hL;
static HMODULE gameModule;

BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID) {
if (reason == DLL_PROCESS_ATTACH) {
// Suspend all other threads to prevent a giant race condition
ThreadManager::Suspend();

std::string cmdArgs = GetCommandLineA(); // Get the command line args for our running process

// If we're running in debug mode, we wanna allocate the console
Expand All @@ -27,6 +21,11 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID) {
LogString(L"Console allocated...\n");
LogString(L"==== Debug ====\n");

LogString(L"Suspending all other threads...");

// Suspend all other threads to prevent a giant race condition
ThreadManager::Suspend();

// Check if the file exists to just avoid constantly copying the file on launch
std::string DX11OrgPath = FlattenString(GetModulePath()) + "\\d3d11_org.dll";
std::filesystem::remove(FlattenString(GetModulePath()) + "\\PluginLoader.log");
Expand All @@ -44,6 +43,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID) {
// Copy the file from Sys32 over to the root directory
std::filesystem::copy(DX11Path, DX11OrgPath);
}

LogString(L"Proxy DX11 Exists: " + std::wstring(std::filesystem::exists(DX11OrgPath) ? L"Yes" : L"No") + L"\n");

gameModule = hModule;
Expand All @@ -59,17 +59,15 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID) {
}

int executionThread() {
InitializePluginHooks(gameModule);

InitializePluginHooks(gameModule);
return TRUE;

}


#pragma region Linker Exports
#pragma comment(linker, "/export:D3D11CoreCreateDevice=d3d11_org.D3D11CoreCreateDevice")

#pragma comment(linker, "/export:D3D11CreateDevice=d3d11_org.D3D11CreateDevice")

#pragma comment(linker, "/export:D3D11CreateDeviceAndSwapChain=d3d11_org.D3D11CreateDeviceAndSwapChain")

#pragma endregion
2 changes: 0 additions & 2 deletions BL3DX11Injection/dllmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID);

int executionThread();

std::wstring GetLastErrorAsString();
4 changes: 1 addition & 3 deletions BL3DX11Injection/pch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ std::wstring GetModulePath() {
std::wstring out = std::wstring(buffer).substr(0, pos);
return out;
}
else {
return L"C:";
}
return L"C:";
}

void InitializeConsole() {
Expand Down

0 comments on commit 87a71de

Please sign in to comment.