[PATCH v3 0/3] MR10634: kernel32: Fix application restart and recovery API stubs.
-- v3: kernel32: Fix application restart and recovery API stubs. kernel32/tests: Add tests for application restart and recovery APIs. https://gitlab.winehq.org/wine/wine/-/merge_requests/10634
From: Sam Hsu <san65384@gmail.com> Signed-off-by: Sam Hsu <san65384@gmail.com> --- dlls/kernel32/version.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dlls/kernel32/version.c b/dlls/kernel32/version.c index 923a5ae83a2..2cce5148b9f 100644 --- a/dlls/kernel32/version.c +++ b/dlls/kernel32/version.c @@ -212,10 +212,12 @@ mismatch: * * Find out whether the terminal server is in INSTALL or EXECUTE mode. */ +static BOOL app_install_mode = FALSE; + BOOL WINAPI TermsrvAppInstallMode(void) { - FIXME("stub\n"); - return FALSE; + TRACE("returning %d\n", app_install_mode); + return app_install_mode; } /*********************************************************************** @@ -230,6 +232,7 @@ BOOL WINAPI TermsrvAppInstallMode(void) */ DWORD WINAPI SetTermsrvAppInstallMode(BOOL bInstallMode) { - FIXME("(%d): stub\n", bInstallMode); + TRACE("(%d)\n", bInstallMode); + app_install_mode = bInstallMode; return 0; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10634
From: Sam Hsu <san65384@gmail.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --- dlls/kernel32/tests/process.c | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index a9ff167972a..dea491f71db 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -98,6 +98,11 @@ static DWORD (WINAPI *pGetMaximumProcessorCount)(WORD); static BOOL (WINAPI *pGetProcessInformation)(HANDLE,PROCESS_INFORMATION_CLASS,void*,DWORD); static void (WINAPI *pClosePseudoConsole)(HPCON); static HRESULT (WINAPI *pCreatePseudoConsole)(COORD,HANDLE,HANDLE,DWORD,HPCON*); +static HRESULT (WINAPI *pRegisterApplicationRestart)(PCWSTR, DWORD); +static HRESULT (WINAPI *pUnregisterApplicationRestart)(void); +static HRESULT (WINAPI *pRegisterApplicationRecoveryCallback)(APPLICATION_RECOVERY_CALLBACK, PVOID, DWORD, DWORD); +static VOID (WINAPI *pApplicationRecoveryFinished)(BOOL); +static HRESULT (WINAPI *pApplicationRecoveryInProgress)(PBOOL); /* ############################### */ static char base[MAX_PATH]; @@ -263,6 +268,11 @@ static BOOL init(void) pSetInformationJobObject = (void *)GetProcAddress(hkernel32, "SetInformationJobObject"); pCreateIoCompletionPort = (void *)GetProcAddress(hkernel32, "CreateIoCompletionPort"); pGetNumaProcessorNode = (void *)GetProcAddress(hkernel32, "GetNumaProcessorNode"); + pRegisterApplicationRestart = (void *)GetProcAddress(hkernel32, "RegisterApplicationRestart"); + pUnregisterApplicationRestart = (void *)GetProcAddress(hkernel32, "UnregisterApplicationRestart"); + pRegisterApplicationRecoveryCallback = (void *)GetProcAddress(hkernel32, "RegisterApplicationRecoveryCallback"); + pApplicationRecoveryFinished = (void *)GetProcAddress(hkernel32, "ApplicationRecoveryFinished"); + pApplicationRecoveryInProgress = (void *)GetProcAddress(hkernel32, "ApplicationRecoveryInProgress"); pWTSGetActiveConsoleSessionId = (void *)GetProcAddress(hkernel32, "WTSGetActiveConsoleSessionId"); pCreateToolhelp32Snapshot = (void *)GetProcAddress(hkernel32, "CreateToolhelp32Snapshot"); pProcess32First = (void *)GetProcAddress(hkernel32, "Process32First"); @@ -5720,6 +5730,46 @@ static void test_GetProcessInformation(void) } } +static void test_application_restart(void) +{ + WCHAR cmdline[RESTART_MAX_CMD_LINE + 1]; + HRESULT hr; + BOOL canceled; + + if (!pRegisterApplicationRestart) + { + win_skip("RegisterApplicationRestart is not available\n"); + return; + } + + hr = pRegisterApplicationRestart(NULL, 0); + ok(hr == S_OK, "RegisterApplicationRestart(NULL) returned %#lx\n", hr); + + hr = pRegisterApplicationRestart(L"test args", 0); + ok(hr == S_OK, "RegisterApplicationRestart returned %#lx\n", hr); + + /* command line >= RESTART_MAX_CMD_LINE chars should return E_INVALIDARG */ + memset(cmdline, 'a', RESTART_MAX_CMD_LINE * sizeof(WCHAR)); + cmdline[RESTART_MAX_CMD_LINE] = 0; + hr = pRegisterApplicationRestart(cmdline, 0); + ok(hr == E_INVALIDARG, "RegisterApplicationRestart(too long) returned %#lx\n", hr); + + hr = pUnregisterApplicationRestart(); + ok(hr == S_OK, "UnregisterApplicationRestart returned %#lx\n", hr); + + /* NULL callback should return E_INVALIDARG */ + hr = pRegisterApplicationRecoveryCallback(NULL, NULL, 0, 0); + ok(hr == E_INVALIDARG, "RegisterApplicationRecoveryCallback(NULL) returned %#lx\n", hr); + + /* outside a recovery callback, Windows returns E_FAIL */ + canceled = 0xdeadbeef; + hr = pApplicationRecoveryInProgress(&canceled); + ok(hr == E_FAIL, "ApplicationRecoveryInProgress returned %#lx\n", hr); + + pApplicationRecoveryFinished(TRUE); + pApplicationRecoveryFinished(FALSE); +} + START_TEST(process) { HANDLE job, hproc, h, h2; @@ -5850,6 +5900,7 @@ START_TEST(process) test_services_exe(); test_startupinfo(); test_GetProcessInformation(); + test_application_restart(); /* things that can be tested: * lookup: check the way program to be executed is searched -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10634
From: Sam Hsu <san65384@gmail.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --- dlls/kernel32/process.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 98313f4634c..a2ab776b221 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -528,7 +528,7 @@ BOOL WINAPI CmdBatNotification( BOOL bBatchRunning ) */ HRESULT WINAPI RegisterApplicationRestart(PCWSTR pwzCommandLine, DWORD dwFlags) { - FIXME("(%s,%ld)\n", debugstr_w(pwzCommandLine), dwFlags); + TRACE("(%s,%ld)\n", debugstr_w(pwzCommandLine), dwFlags); return S_OK; } @@ -575,8 +575,7 @@ BOOL WINAPI SetProcessDEPPolicy( DWORD flags ) */ VOID WINAPI ApplicationRecoveryFinished(BOOL success) { - FIXME(": stub\n"); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + TRACE("(%d)\n", success); } /********************************************************************** @@ -584,8 +583,7 @@ VOID WINAPI ApplicationRecoveryFinished(BOOL success) */ HRESULT WINAPI ApplicationRecoveryInProgress(PBOOL canceled) { - FIXME(":%p stub\n", canceled); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + TRACE("(%p)\n", canceled); return E_FAIL; } @@ -594,7 +592,7 @@ HRESULT WINAPI ApplicationRecoveryInProgress(PBOOL canceled) */ HRESULT WINAPI RegisterApplicationRecoveryCallback(APPLICATION_RECOVERY_CALLBACK callback, PVOID param, DWORD pingint, DWORD flags) { - FIXME("%p, %p, %ld, %ld: stub, faking success\n", callback, param, pingint, flags); + TRACE("%p, %p, %ld, %ld\n", callback, param, pingint, flags); return S_OK; } @@ -854,8 +852,7 @@ BOOL WINAPI GetProcessDEPPolicy(HANDLE process, LPDWORD flags, PBOOL permanent) */ HRESULT WINAPI UnregisterApplicationRestart(void) { - FIXME(": stub\n"); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + TRACE("\n"); return S_OK; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10634
participants (2)
-
Sam Hsu -
徐世恩 (@san65384)