Skip to content

Commit

Permalink
Adds a command line argument to prompt for debugger attachment.
Browse files Browse the repository at this point in the history
  • Loading branch information
CCHyper committed Oct 25, 2022
1 parent 19a371a commit 450ebf2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/hooker/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,20 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved
{
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:

#if !defined(NDEBUG) && defined(TS_CLIENT)
{
/**
* Give the user time to attach the debugger if one is not already present.
*/
#if !defined(NDEBUG) && defined(TS_CLIENT)
if (!IsDebuggerPresent()) {

#elif defined(TS_CLIENT)
const char *cmdline = GetCommandLineA();
bool wait_for_debugger = (std::strstr(cmdline, "-DEBUGGER_ATTACH") != nullptr);
if (wait_for_debugger) {
#endif
MessageBox(NULL, "Attach the debugger now or continue.", "Vinifera", MB_OK|MB_SERVICE_NOTIFICATION);
}
#endif

if (lpReserved) {
OutputDebugString(VINIFERA_DLL " is being loaded statically.\n");
Expand Down Expand Up @@ -105,9 +110,10 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved
DLLInstance = hModule;

return TRUE;
}

case DLL_PROCESS_DETACH:

{
OutputDebugString("\n\nAbout to call StopHooking()...\n\n");

if (!StopHooking()) {
Expand All @@ -124,6 +130,7 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved
OutputDebugString(VINIFERA_DLL " detached from " VINIFERA_TARGET_EXE ".\n");

return TRUE;
}

case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
Expand Down

0 comments on commit 450ebf2

Please sign in to comment.