From: Bernhard Übelacker Subject: [PATCH] advapi32: succeed for null pointer in ChangeServiceConfig2 Message-Id: <550ABBAA.90507@vr-web.de> Date: Thu, 19 Mar 2015 13:06:02 +0100 Hello, attached patch avoids an issue when trying to run Flatout 2 with copy protection. When starting Flatout2.exe for the first time it wants to install some services, but shows in wine some error messages. The only visible sign in terminal output, that something went wrong, is this: err:rpc:I_RpcReceive we got fault packet with status 0x3e6 And of course later some dialog showing error 998 (=0x3e6) and a unhandled exception. This is because the SC_RPC_CONFIG_INFOW parameter has in its descr->lpDescription a null pointer instead of a valid LPWSTR. Right now this null pointer would be accessed in svcctl_ChangeServiceConfig2W and causes an exception there , but is hidden by the RPC layer. (And of course this makes the SF4 protection still not working.) Kind regards, Bernhard From d91851554ca350fae947ae7a41f001f72b2178b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= Date: Thu, 19 Mar 2015 02:08:38 +0100 Subject: advapi32: succeed for null pointer in ChangeServiceConfig2 --- dlls/advapi32/service.c | 8 +++++++- dlls/advapi32/tests/service.c | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dlls/advapi32/service.c b/dlls/advapi32/service.c index 0eb0a47..9feb1f7 100644 --- a/dlls/advapi32/service.c +++ b/dlls/advapi32/service.c @@ -2217,7 +2217,13 @@ BOOL WINAPI ChangeServiceConfig2W( SC_HANDLE hService, DWORD dwInfoLevel, info.dwInfoLevel = dwInfoLevel; info.u.descr = lpInfo; - err = svcctl_ChangeServiceConfig2W( hService, info ); + + if (info.u.descr->lpDescription) + { + err = svcctl_ChangeServiceConfig2W( hService, info ); + } else { + err = ERROR_SUCCESS; + } } __EXCEPT(rpc_filter) { diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c index 81d2f74..c219ff9 100644 --- a/dlls/advapi32/tests/service.c +++ b/dlls/advapi32/tests/service.c @@ -2079,6 +2079,13 @@ static void test_queryconfig2(void) goto cleanup; } + pConfig->lpDescription = NULL; + ret = pChangeServiceConfig2A(svc_handle, SERVICE_CONFIG_DESCRIPTION,buffer); + ok(ret, "ChangeServiceConfig2A failed with null pointer\n"); + if (!ret) { + goto cleanup; + } + SetLastError(0xdeadbeef); needed = 0; expected = sizeof(SERVICE_DESCRIPTIONA) + sizeof(description) * sizeof(WCHAR); /* !! */ -- 2.1.4