diff -urN -x .build -x .inst -x .sinst -x .buildlogs run-1.1.9-orig/src/run.c run-1.1.9/src/run.c --- run-1.1.9-orig/src/run.c 2006年04月06日 14:10:55.000000000 -0400 +++ run-1.1.9/src/run.c 2006年05月18日 01:50:43.859375000 -0400 @@ -32,6 +32,7 @@ #define WIN32 #include +#include #include #include #include @@ -193,6 +194,67 @@ free(var); } } +BOOL setup_invisible_console() +{ + HWINSTA h, horig; + USEROBJECTFLAGS oi; + DWORD len; + BOOL b = FALSE; + HMODULE lib = NULL; + HWINSTA WINAPI (*GetProcessWindowStationFP)(void) = NULL; + BOOL WINAPI (*GetUserObjectInformationFP)(HANDLE, int, PVOID, DWORD, PDWORD) = NULL; + HWINSTA WINAPI (*CreateWindowStationFP)(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES) = NULL; + BOOL WINAPI (*SetProcessWindowStationFP)(HWINSTA) = NULL; + BOOL WINAPI (*CloseWindowStationFP)(HWINSTA) = NULL; + + /* First, set up function pointers */ + if (lib = LoadLibrary ("user32.dll")) + { + GetProcessWindowStationFP = (HWINSTA WINAPI (*)(void)) + GetProcAddress (lib, "GetProcessWindowStation"); + GetUserObjectInformationFP = (BOOL WINAPI (*)(HANDLE, int, PVOID, DWORD, PDWORD)) + GetProcAddress (lib, "GetUserObjectInformationW"); /* ugly! */ + CreateWindowStationFP = (HWINSTA WINAPI (*)(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES)) + GetProcAddress (lib, "CreateWindowStationW"); /* ugly */ + SetProcessWindowStationFP = (BOOL WINAPI (*)(HWINSTA)) + GetProcAddress (lib, "SetProcessWindowStation"); + CloseWindowStationFP = (BOOL WINAPI (*)(HWINSTA)) + GetProcAddress (lib, "CloseWindowStation"); + + if (GetProcessWindowStationFP && + GetUserObjectInformationFP && + CreateWindowStationFP && + SetProcessWindowStationFP && + CloseWindowStationFP) + { + /* Then, do the work */ + FreeConsole(); + h = horig = (*GetProcessWindowStationFP)(); + if (!horig + || !(*GetUserObjectInformationFP) (horig, UOI_FLAGS, &oi, sizeof (oi), &len ) + || !(oi.dwFlags & WSF_VISIBLE)) + { + b = AllocConsole(); + } + else + { + h = (*CreateWindowStationFP) (NULL, 0, STANDARD_RIGHTS_READ, NULL); + if (h) + { + b = (*SetProcessWindowStationFP) (h); + } + b = AllocConsole(); + if (horig && h && h != horig && (*SetProcessWindowStationFP) (horig)) + { + (*CloseWindowStationFP) (h); + } + } + return b; + } + } + /* otherwise, fail */ + return FALSE; +} int start_child(char* cmdline, int wait_for_child) { @@ -204,6 +266,8 @@ setup_win_environ(); + setup_invisible_console(); + memset (&start, 0, sizeof (start)); start.cb = sizeof (start); start.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;

AltStyle によって変換されたページ (->オリジナル) /