/* Diagnose the copied original's black startup under the isolated Wine wrapper. Thread suspension perturbs timing: this is not a gameplay timing reference. No code/actor memory writes; every successfully suspended thread is resumed. */ #define main observer_unused_main #include "original_state_observer.c" #undef main #include static void threads(HANDLE process, DWORD pid, unsigned elapsed) { HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); THREADENTRY32 entry = {0}; entry.dwSize = sizeof(entry); if (snapshot == INVALID_HANDLE_VALUE) return; if (Thread32First(snapshot, &entry)) do { if (entry.th32OwnerProcessID != pid) continue; HANDLE thread = OpenThread(THREAD_SUSPEND_RESUME|THREAD_GET_CONTEXT|THREAD_QUERY_INFORMATION, FALSE, entry.th32ThreadID); CONTEXT context = {0}; uint32_t stack[64] = {0}; int context_ok = 0, stack_ok = 0; if (!thread) continue; DWORD prior = SuspendThread(thread); if (prior != (DWORD)-1) { context.ContextFlags = CONTEXT_CONTROL; context_ok = GetThreadContext(thread, &context); if (context_ok) stack_ok = read_memory(process, context.Esp, stack, sizeof(stack)); /* Resume even when context/stack reads fail. Keep prior suspension count. */ DWORD resumed = ResumeThread(thread); printf("{\"kind\":\"thread\",\"elapsed_ms\":%u,\"tid\":%lu,\"prior_suspend\":%lu," "\"resume_ok\":%s,\"context_ok\":%s,\"eip\":%lu,\"esp\":%lu,\"stack_ok\":%s,\"stack\":[", elapsed, entry.th32ThreadID, prior, resumed!=(DWORD)-1?"true":"false", context_ok?"true":"false", context.Eip, context.Esp, stack_ok?"true":"false"); for (unsigned i=0; stack_ok && isha)) { CloseHandle(file); return 4; } start.cb = sizeof(start); if (!CreateProcessA(command,command,NULL,NULL,FALSE,0,NULL,cwd,&start,&child)) { CloseHandle(file); return 5; } CloseHandle(file); CloseHandle(child.hThread); printf("{\"kind\":\"diagnostic_subject\",\"sha256\":\"%s\",\"pid\":%lu,\"timing_perturbed\":true}\n",digest,child.dwProcessId); DWORD began=GetTickCount(); int identified=0; for (unsigned sample=0; GetTickCount()-began