Skip to content

Commit

Permalink
Don't fully load DDrawCompat when using Dd7to9
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Aug 21, 2024
1 parent c7f1cf3 commit bffd149
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
3 changes: 2 additions & 1 deletion DDrawCompat/DDrawCompatExternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ namespace DDrawCompat

void Start(HINSTANCE hinstDLL, DWORD fdwReason)
{
IsDDrawEnabled = RunStart(hinstDLL, fdwReason);
bool ret = RunStart(hinstDLL, fdwReason);
IsDDrawEnabled = Config.Dd7to9 ? false : ret;
}

bool IsEnabled()
Expand Down
23 changes: 18 additions & 5 deletions DDrawCompat/v0.3.1/Dll/DllMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,29 @@ namespace Compat32
static bool RunOnce = true;
if (RunOnce && !DDrawCompat::IsEnabled())
{
RunOnce = false;
Time::init();
Compat32::Log() << "Installing memory management hooks";
Win32::MemoryManagement::installHooks();
Compat32::Log() << "Installing messaging hooks";
Win32::MsgHooks::installHooks();
Compat32::Log() << "Installing display mode hooks";
Win32::DisplayMode::installHooks();
if (Config.DDrawCompat)
{
Compat32::Log() << "Installing Direct3D driver hooks";
D3dDdi::installHooks();
}
Compat32::Log() << "Installing registry hooks";
Win32::Registry::installHooks();
Compat32::Log() << "Installing Win32 hooks";
Win32::WaitFunctions::installHooks();
if (Config.DDrawCompat && !Config.DDrawCompatDisableGDIHook)
{
Compat32::Log() << "Installing GDI hooks";
Gdi::installHooks();
}
Compat32::closeDbgEng();
RunOnce = false;
}
}
//********** End Edit ***************
Expand Down Expand Up @@ -307,10 +317,13 @@ namespace Compat32
timeBeginPeriod(1);
setDpiAwareness();
SetThemeAppProperties(0);
Win32::MemoryManagement::installHooks();
Win32::MsgHooks::installHooks();
Time::init();
Compat32::closeDbgEng();
if (!Config.Dd7to9)
{
Win32::MemoryManagement::installHooks();
Win32::MsgHooks::installHooks();
Time::init();
Compat32::closeDbgEng();
}

//********** Begin Edit *************
if (Config.DisableMaxWindowedModeNotSet)
Expand Down
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 7100
#define BUILD_NUMBER 7101
22 changes: 16 additions & 6 deletions Dllmain/Dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,9 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved)
}
}

// Start Dd7to9
// Add Dd7to9 to the chain
if (Config.Dd7to9)
{
InitDDraw();
using namespace ddraw;
using namespace DdrawWrapper;
VISIT_PROCS_DDRAW(SET_WRAPPED_PROC);
Expand All @@ -424,7 +423,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved)

#ifdef DDRAWCOMPAT
// Add DDrawCompat to the chain
if (Config.DDrawCompat)
else if (Config.DDrawCompat)
{
Logging::Log() << "Enabling DDrawCompat";
using namespace ddraw;
Expand Down Expand Up @@ -532,20 +531,31 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved)
Utils::LoadPlugins();
}

bool DDrawCompatEnabed = false;
#ifdef DDRAWCOMPAT
DDrawCompatEnabed = DDrawCompat::IsEnabled();
#endif // DDRAWCOMPAT

// Set timer
if (!Config.DDrawCompat)
if (!DDrawCompatEnabed)
{
timeBeginPeriod(1);
}

#ifdef DDRAWCOMPAT
// Extra compatibility hooks from DDrawCompat
if (!DDrawCompat::IsEnabled() && (Config.Dd7to9 || Config.D3d8to9))
if (!DDrawCompatEnabed && (Config.Dd7to9 || Config.D3d8to9))
{
DDrawCompat::InstallDd7to9Hooks();
}
#endif // DDRAWCOMPAT

// Start Dd7to9
if (Config.Dd7to9)
{
InitDDraw();
}

// Start fullscreen thread
if (Config.FullScreen || Config.ForceTermination)
{
Expand Down Expand Up @@ -600,7 +610,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved)

#ifdef DDRAWCOMPAT
// Unload and Unhook DDrawCompat
if (DDrawCompat::IsEnabled())
if (DDrawCompat::IsEnabled() || Config.Dd7to9)
{
DDrawCompat::Start(nullptr, DLL_PROCESS_DETACH);
}
Expand Down

0 comments on commit bffd149

Please sign in to comment.