Files
WoW-Hybrid-gateway/native/windows_launcher_entry.c
praxisandClaude Fable 5.2 8e02dccb86 In-client stack: transport, session lifecycle and engine bridge
175 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

47 lines
2.0 KiB
C

/* Native Windows entry for the bundled Python launcher and session supervisor. */
#ifndef UNICODE
#define UNICODE
#endif
#ifndef _UNICODE
#define _UNICODE
#endif
#include <windows.h>
#include <wchar.h>
#include <stdio.h>
#include <shellapi.h>
int wmain(int argc,wchar_t **argv) {
wchar_t root[32768],python[32768],script[32768],command[32768];
DWORD n=GetModuleFileNameW(NULL,root,32768);
if(!n||n>=32768)return 2;
wchar_t *slash=wcsrchr(root,L'\\');if(!slash)return 2;*slash=0;
#ifdef GW_BACKEND_ENTRY
slash=wcsrchr(root,L'\\');if(!slash)return 2;*slash=0;
if(argc!=3||wcscmp(argv[1],L"--endpoint-profile")||wcscmp(argv[2],L"octo"))return 2;
const wchar_t *relative=L"ops\\windows_launcher_backend.py";
const wchar_t *arguments=L" --endpoint-profile octo";
#else
if(argc>2||(argc==2&&wcscmp(argv[1],L"--check")))return 2;
const wchar_t *relative=L"launcher.py";
const wchar_t *arguments=argc==2?L" --check":L"";
#endif
if(swprintf(python,32768,L"%ls\\python\\python.exe",root)<0||swprintf(script,32768,L"%ls\\%ls",root,relative)<0)return 2;
if(swprintf(command,32768,L"\"%ls\" -I \"%ls\"%ls",python,script,arguments)<0)return 2;
STARTUPINFOW startup={0};PROCESS_INFORMATION child={0};startup.cb=sizeof(startup);
startup.dwFlags=STARTF_USESTDHANDLES;startup.hStdInput=GetStdHandle(STD_INPUT_HANDLE);startup.hStdOutput=GetStdHandle(STD_OUTPUT_HANDLE);startup.hStdError=GetStdHandle(STD_ERROR_HANDLE);
if(!CreateProcessW(python,command,NULL,NULL,TRUE,CREATE_NO_WINDOW,NULL,root,&startup,&child))return 2;
CloseHandle(child.hThread);DWORD code=2;
if(WaitForSingleObject(child.hProcess,INFINITE)==WAIT_OBJECT_0)GetExitCodeProcess(child.hProcess,&code);
CloseHandle(child.hProcess);return (int)code;
}
#ifndef GW_BACKEND_ENTRY
int WINAPI wWinMain(HINSTANCE instance,HINSTANCE previous,LPWSTR line,int show) {
(void)instance;(void)previous;(void)line;(void)show;
int argc=0;LPWSTR *argv=CommandLineToArgvW(GetCommandLineW(),&argc);
if(!argv)return 2;
int result=wmain(argc,argv);
LocalFree(argv);
return result;
}
#endif