upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/process.cpp
diff options
context:
space:
mode:
authorMoonEyes <ducoinbenjamin@yahoo.fr>2026-11-29 02:03:37 +0100
committerGitHub <noreply@github.com>2026-11-29 02:03:37 +0100
commit5c8a9de7d36342a4630ccf62a283ab8a7eed1990 (patch)
tree930a69cf8ec2b6a30eef08f3cc3fc5b4405cd00a /runtime/shims/process.cpp
parent106e2611bf9c85c40b349f57fff24c120a9dcec9 (diff)
parentd411fe9b4a3aab2a75dfbed4d6e4f01d758ef668 (diff)
Merge pull request #2522 from Tyrannys/rt-com-null-barriers-entry
d3d12, process: null barrier arrays, CopyTiles in a bundle, calibration wait, entry thread argument, getmainargs expand (RT-COM-NULL-BARRIERS-ENTRY)
Diffstat (limited to 'runtime/shims/process.cpp')
-rw-r--r--runtime/shims/process.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/runtime/shims/process.cpp b/runtime/shims/process.cpp
index a692a6224..1705bf5e4 100644
--- a/runtime/shims/process.cpp
+++ b/runtime/shims/process.cpp
@@ -489,30 +489,30 @@ wchar_t** current_wide_environment() {
489 return _wenviron; 489 return _wenviron;
490} 490}
491 491
492// msvcrt.dll: int __getmainargs(int* argc, char*** argv, char*** env, int expand, void* startinfo) 492// msvcrt.dll: int __getmainargs(int* argc, char*** argv, char*** env, int expand, void* startinfo). A nonzero
493int __cdecl game_getmainargs(int* argc, char*** argv, char*** env, int, void*) { 493// `expand` (the CRT's _dowildcard) expands wildcards in the arguments, as _configure_narrow_argv's mode 2 does.
494 if (const int error = game_configure_narrow_argv(1)) return error; 494int __cdecl game_getmainargs(int* argc, char*** argv, char*** env, int expand, void*) {
495 if (!argc || !argv) return -1;
496 if (const int error = game_configure_narrow_argv(expand ? 2 : 1)) return error;
495 *argc = g_argc; 497 *argc = g_argc;
496 *argv = g_argv_ptr; 498 *argv = g_argv_ptr;
497 if (env) *env = current_environment(); 499 if (env) *env = current_environment();
498 return 0; 500 return 0;
499} 501}
500int __cdecl game_wgetmainargs(int* argc, wchar_t*** argv, wchar_t*** env, int, void*) { 502int __cdecl game_wgetmainargs(int* argc, wchar_t*** argv, wchar_t*** env, int expand, void*) {
501 if (const int error = game_configure_wide_argv(1)) return error; 503 if (!argc || !argv) return -1;
504 if (const int error = game_configure_wide_argv(expand ? 2 : 1)) return error;
502 *argc = g_argc; 505 *argc = g_argc;
503 *argv = g_wargv_ptr; 506 *argv = g_wargv_ptr;
504 if (env) *env = current_wide_environment(); 507 if (env) *env = current_wide_environment();
505 return 0; 508 return 0;
506} 509}
507 510
508struct EntryCall { 511// `p` is the entry point itself: run_entry can return (another thread ended the run) before this thread first runs,
509 void* entry; 512// so nothing of run_entry's frame may be read here.
510};
511
512DWORD WINAPI game_thread(void* p) { 513DWORD WINAPI game_thread(void* p) {
513 auto* call = static_cast<EntryCall*>(p);
514 // An EXE entry point (mainCRTStartup and friends) takes the PEB pointer and returns the process exit code. 514 // An EXE entry point (mainCRTStartup and friends) takes the PEB pointer and returns the process exit code.
515 auto entry = reinterpret_cast<DWORD(WINAPI*)(void*)>(call->entry); 515 auto entry = reinterpret_cast<DWORD(WINAPI*)(void*)>(p);
516 const DWORD code = entry(nullptr); 516 const DWORD code = entry(nullptr);
517 end_run(static_cast<int>(code)); // returning from the entry point is an exit too 517 end_run(static_cast<int>(code)); // returning from the entry point is an exit too
518} 518}
@@ -554,8 +554,7 @@ int run_entry(void* entry, size_t stack_bytes) {
554 g_done = CreateEventW(nullptr, TRUE, FALSE, nullptr); 554 g_done = CreateEventW(nullptr, TRUE, FALSE, nullptr);
555 if (!g_done) return -1; 555 if (!g_done) return -1;
556 g_running = true; 556 g_running = true;
557 EntryCall call{entry}; 557 HANDLE thread = CreateThread(nullptr, stack_bytes, game_thread, entry, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
558 HANDLE thread = CreateThread(nullptr, stack_bytes, game_thread, &call, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
559 if (!thread) { 558 if (!thread) {
560 g_running = false; 559 g_running = false;
561 CloseHandle(g_done); 560 CloseHandle(g_done);