Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions src/Phobos.Ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,35 @@ DEFINE_HOOK(0x67FDB1, LoadOptionsClass_GetFileInfo, 0x7)
#include <Dbghelp.h>
#include <tlhelp32.h>

/**
* Sets up to close Syringe when the game exits.
* We don't do it immediately so that the client doesn't think
* the game has exited once Syringe closes.
*
* Ported from Vinifera
* @author: ZivDero, secsome
*/
static DWORD DebuggerPID = 0;

void _cdecl Kill_Debugger()
{
if (DebuggerPID != 0)
{
HANDLE handle = OpenProcess(PROCESS_TERMINATE, FALSE, DebuggerPID);
if (handle)
{
TerminateProcess(handle, EXIT_SUCCESS);
CloseHandle(handle);
}
}
}

void Setup_Kill_Debugger(DWORD pid)
{
DebuggerPID = pid;
atexit(Kill_Debugger);
}

bool Phobos::DetachFromDebugger()
{
auto GetDebuggerProcessId = [](DWORD dwSelfProcessId) -> DWORD
Expand Down Expand Up @@ -362,13 +391,8 @@ bool Phobos::DetachFromDebugger()
status = NtRemoveProcessDebug(hCurrentProcess, hDebug);
if (0 <= status)
{
HANDLE hDbgProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
if (INVALID_HANDLE_VALUE != hDbgProcess)
{
BOOL ret = TerminateProcess(hDbgProcess, EXIT_SUCCESS);
CloseHandle(hDbgProcess);
return ret;
}
Setup_Kill_Debugger(pid);
return true;
}
}
NtClose(hDebug);
Expand Down
3 changes: 1 addition & 2 deletions src/Phobos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ void Phobos::ExeRun()

L"To attach a debugger find the YR process in Process Hacker "
L"/ Visual Studio processes window and detach debuggers from it, "
L"then you can attach your own debugger. After this you should "
L"terminate Syringe.exe because it won't automatically exit when YR is closed.\n\n"
L"then you can attach your own debugger.\n\n"

L"Press OK to continue YR execution.",
L"Debugger Notice", MB_OK);
Expand Down
Loading