Skip to content

Commit

Permalink
start to add debug dialog hook
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSapps committed Aug 10, 2017
1 parent 5dcd313 commit dbe167c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ if (MSVC AND NOT "${CMAKE_GENERATOR}" MATCHES "(Win64)")
tools/engine_hook/hook_utils.cpp
tools/engine_hook/anim_logger.hpp
tools/engine_hook/anim_logger.cpp
tools/engine_hook/resource.h
tools/engine_hook/resources.rc
)
set_target_properties(ddraw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
set_target_properties(ddraw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
Expand Down
7 changes: 7 additions & 0 deletions tools/engine_hook/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "window_hooks.hpp"
#include "game_functions.hpp"
#include "anim_logger.hpp"
#include "resource.h"

#define private public
#include "gridmap.hpp"
Expand Down Expand Up @@ -645,9 +646,13 @@ void HookMain()
Vars().alwaysDrawDebugText.Set(1);
}

static HMODULE gDllHandle = NULL;

// Proxy DLL entry point
HRESULT WINAPI NewDirectDrawCreate(GUID* lpGUID, IDirectDraw** lplpDD, IUnknown* pUnkOuter)
{
//CreateDialog(gDllHandle, MAKEINTRESOURCE(IDD_MAIN), NULL, NULL);

const HMODULE hDDrawDll = Utils::LoadRealDDrawDll();
const Utils::TDirectDrawCreate pRealDirectDrawCreate = Utils::GetFunctionPointersToRealDDrawFunctions(hDDrawDll);
const HRESULT ret = pRealDirectDrawCreate(lpGUID, lplpDD, pUnkOuter);
Expand All @@ -663,6 +668,8 @@ static bool gConsoleDone = false;

extern "C" BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{
gDllHandle = hModule;

if (!gConsoleDone)
{
gConsoleDone = true;
Expand Down
Binary file added tools/engine_hook/resource.h
Binary file not shown.
Binary file added tools/engine_hook/resources.rc
Binary file not shown.

0 comments on commit dbe167c

Please sign in to comment.