Trace Carl lifecycle and add read-only original state observer
This commit is contained in:
1 parent
c642b69849
commit
4cd62d3627
28 files changed
+2387
-5
No files matched your search
@@ -0,0 +1,43 @@
|
||||
/* Wine-only integration driver, executed by reference_capture.py --asset-probe.
|
||||
The wrapper supplies /work/game as a generated copy and hides Original.
|
||||
Tests actual attach/read/leave-running behavior; no target memory writes.
|
||||
Place the separately built observer at /work/observer-under-test.exe. */
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static BOOL CALLBACK close_owned(HWND window, LPARAM pid) {
|
||||
DWORD owner = 0;
|
||||
GetWindowThreadProcessId(window, &owner);
|
||||
if (owner == (DWORD)pid && IsWindowVisible(window)) PostMessageA(window, WM_CLOSE, 0, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
STARTUPINFOA start = {0};
|
||||
PROCESS_INFORMATION game = {0}, observer = {0};
|
||||
char cwd[MAX_PATH], command[256];
|
||||
DWORD code = 1, game_code = 0;
|
||||
setbuf(stdout, NULL);
|
||||
/* This driver deliberately works only at the generated Wine wrapper path. */
|
||||
if (!GetCurrentDirectoryA(sizeof(cwd), cwd) || _stricmp(cwd, "Z:\\work\\game")) return 2;
|
||||
start.cb = sizeof(start);
|
||||
strcpy(command, "NeutronHDnoCD.exe");
|
||||
if (!CreateProcessA(command, command, NULL, NULL, FALSE, 0, NULL, cwd, &start, &game)) return 3;
|
||||
CloseHandle(game.hThread);
|
||||
Sleep(1000);
|
||||
snprintf(command, sizeof(command), "Z:\\work\\observer-under-test.exe --attach-copied-pid=%lu --seconds=10", game.dwProcessId);
|
||||
if (!CreateProcessA("Z:\\work\\observer-under-test.exe", command, NULL, NULL, FALSE, 0, NULL, cwd, &start, &observer)) return 4;
|
||||
CloseHandle(observer.hThread);
|
||||
if (WaitForSingleObject(observer.hProcess, 20000) != WAIT_OBJECT_0) return 5;
|
||||
GetExitCodeProcess(observer.hProcess, &code);
|
||||
GetExitCodeProcess(game.hProcess, &game_code);
|
||||
printf("OBSERVER_ATTACH_EXIT %lu ORIGINAL_STILL_RUNNING %d\n", code, game_code == STILL_ACTIVE);
|
||||
/* Only the launcher-owned game receives an ordinary close, after the test. */
|
||||
EnumWindows(close_owned, game.dwProcessId);
|
||||
CloseHandle(observer.hProcess); CloseHandle(game.hProcess);
|
||||
if (code || game_code != STILL_ACTIVE) return 6;
|
||||
puts("ORIGINAL_OBSERVER_ATTACH_COMPLETE");
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user