added a new debug option "ResumeByDebugger" for the Windows version of the client loader

This commit is contained in:
otavepto 2024-01-03 01:56:26 +02:00
parent bc62efa7f7
commit ace7aa4acb
4 changed files with 48 additions and 13 deletions

View File

@ -1,3 +1,6 @@
* added a new option to the Windows version of the client loader to aid in debugging.
the option is called `ResumeByDebugger`, and setting it to `1` will prevent the loader from
auto resuming the main app thread, giving you a chance to attach your debugger.
* make the script `generate_emu_config` generate an empty `DLC.txt` if the app has no DLCs * make the script `generate_emu_config` generate an empty `DLC.txt` if the app has no DLCs
* windows build: sign each file after build with a self-signed generated certificate + note in the release readme regarding false-positives * windows build: sign each file after build with a self-signed generated certificate + note in the release readme regarding false-positives
* windows build: note in readme about Windows SDK * windows build: note in readme about Windows SDK

View File

@ -25,6 +25,10 @@ You do not need to create a `steam_interfaces.txt` file for the `steamclient` ve
Optionally you can specify a different location for `steamclient(64).dll`: Optionally you can specify a different location for `steamclient(64).dll`:
* `SteamClientDll`: path to `steamclient.dll`, either full path or relative to this `.ini` file * `SteamClientDll`: path to `steamclient.dll`, either full path or relative to this `.ini` file
* `SteamClientDll`: path to `steamclient(64).dll`, either full path or relative to this `.ini` file * `SteamClientDll`: path to `steamclient(64).dll`, either full path or relative to this `.ini` file
* For debug **build** only:
* `ResumeByDebugger`: setting this to `1` or 'y' or `true` will prevent the loader from calling `ResumeThread` on the main thread after spawning the .exe, and it will display a mesage with the process ID (PID) so you attach your debugger on it.
Note that you have to resume the main thread from the debugger after attaching, also the entry breakpoint may not be set automatically, but you can do that manually.
**Note** that any arguments passed to `steamclient_loader.exe` via command line will be passed to the target `.exe`. **Note** that any arguments passed to `steamclient_loader.exe` via command line will be passed to the target `.exe`.
Example: `steamclient_loader.exe` `-dx11` Example: `steamclient_loader.exe` `-dx11`

View File

@ -10,6 +10,7 @@
#include <memory.h> #include <memory.h>
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include <string>
bool IsNotRelativePathOrRemoveFileName(WCHAR* output, bool Remove) bool IsNotRelativePathOrRemoveFileName(WCHAR* output, bool Remove)
{ {
@ -166,8 +167,32 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
return 1; return 1;
} }
// run and wait bool run_exe = true;
#ifndef EMU_RELEASE_BUILD
{
std::wstring dbg_file(50, L'\0');
auto res_dbg_len = GetPrivateProfileStringW(L"Debug", L"ResumeByDebugger", L"", &dbg_file[0], dbg_file.size(), CurrentDirectory);
if (dbg_file[0]) {
dbg_file = dbg_file.substr(0, res_dbg_len);
} else {
dbg_file.clear();
}
for (auto &c : dbg_file) {
c = (wchar_t)std::tolower((int)c);
}
if (dbg_file == L"1" || dbg_file == L"y" || dbg_file == L"yes" || dbg_file == L"true") {
run_exe = false;
std::string msg = "Attach a debugger now to PID " + std::to_string(processInfo.dwProcessId) + " and resume its main thread";
MessageBoxA(NULL, msg.c_str(), "ColdClientLoader", MB_OK);
}
}
#endif
// run
if (run_exe) {
ResumeThread(processInfo.hThread); ResumeThread(processInfo.hThread);
}
// wait
WaitForSingleObject(processInfo.hThread, INFINITE); WaitForSingleObject(processInfo.hThread, INFINITE);
CloseHandle(processInfo.hThread); CloseHandle(processInfo.hThread);

View File

@ -8,3 +8,6 @@ AppId=
SteamClientDll=steamclient.dll SteamClientDll=steamclient.dll
SteamClient64Dll=steamclient64.dll SteamClient64Dll=steamclient64.dll
[Debug]
ResumeByDebugger=0