advapi32: Fix GetServiceKeyNameW behavior to pass the tests.
This commit is contained in:
parent
a882bb6a2c
commit
c795150932
|
@ -1565,6 +1565,7 @@ BOOL WINAPI GetServiceKeyNameW( SC_HANDLE hSCManager, LPCWSTR lpDisplayName,
|
||||||
LPWSTR lpServiceName, LPDWORD lpcchBuffer )
|
LPWSTR lpServiceName, LPDWORD lpcchBuffer )
|
||||||
{
|
{
|
||||||
DWORD err;
|
DWORD err;
|
||||||
|
WCHAR buffer[2];
|
||||||
|
|
||||||
TRACE("%p %s %p %p\n", hSCManager,
|
TRACE("%p %s %p %p\n", hSCManager,
|
||||||
debugstr_w(lpServiceName), lpDisplayName, lpcchBuffer);
|
debugstr_w(lpServiceName), lpDisplayName, lpcchBuffer);
|
||||||
|
@ -1575,10 +1576,20 @@ BOOL WINAPI GetServiceKeyNameW( SC_HANDLE hSCManager, LPCWSTR lpDisplayName,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* provide a buffer if the caller didn't */
|
||||||
|
if (!lpServiceName || *lpcchBuffer < 2)
|
||||||
|
{
|
||||||
|
lpServiceName = buffer;
|
||||||
|
/* A size of 1 would be enough, but tests show that Windows returns 2,
|
||||||
|
* probably because of a WCHAR/bytes mismatch in their code.
|
||||||
|
*/
|
||||||
|
*lpcchBuffer = 2;
|
||||||
|
}
|
||||||
|
|
||||||
__TRY
|
__TRY
|
||||||
{
|
{
|
||||||
err = svcctl_GetServiceKeyNameW(hSCManager, lpDisplayName, lpServiceName,
|
err = svcctl_GetServiceKeyNameW(hSCManager, lpDisplayName, lpServiceName,
|
||||||
lpServiceName ? *lpcchBuffer : 0, lpcchBuffer);
|
*lpcchBuffer, lpcchBuffer);
|
||||||
}
|
}
|
||||||
__EXCEPT(rpc_filter)
|
__EXCEPT(rpc_filter)
|
||||||
{
|
{
|
||||||
|
|
|
@ -760,7 +760,7 @@ static void test_get_servicekeyname(void)
|
||||||
ok(!ret, "Expected failure\n");
|
ok(!ret, "Expected failure\n");
|
||||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||||
todo_wine ok(servicesize == 15, "Service size expected 15, got %d\n", servicesize);
|
ok(servicesize == 15, "Service size expected 15, got %d\n", servicesize);
|
||||||
ok(servicenameW[0] == 0, "Service name not empty\n");
|
ok(servicenameW[0] == 0, "Service name not empty\n");
|
||||||
|
|
||||||
servicesize = 0;
|
servicesize = 0;
|
||||||
|
@ -776,7 +776,7 @@ static void test_get_servicekeyname(void)
|
||||||
lstrcpyW( servicenameW, abcW );
|
lstrcpyW( servicenameW, abcW );
|
||||||
ret = GetServiceKeyNameW(scm_handle, deadbeefW, servicenameW, &servicesize);
|
ret = GetServiceKeyNameW(scm_handle, deadbeefW, servicenameW, &servicesize);
|
||||||
ok(!ret, "Expected failure\n");
|
ok(!ret, "Expected failure\n");
|
||||||
todo_wine ok(servicesize == 2, "Service size expected 2, got %d\n", servicesize);
|
ok(servicesize == 2, "Service size expected 2, got %d\n", servicesize);
|
||||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||||
ok(servicenameW[0] == 'A', "Service name changed\n");
|
ok(servicenameW[0] == 'A', "Service name changed\n");
|
||||||
|
@ -794,10 +794,10 @@ static void test_get_servicekeyname(void)
|
||||||
lstrcpyW( servicenameW, abcW );
|
lstrcpyW( servicenameW, abcW );
|
||||||
ret = GetServiceKeyNameW(scm_handle, deadbeefW, servicenameW, &servicesize);
|
ret = GetServiceKeyNameW(scm_handle, deadbeefW, servicenameW, &servicesize);
|
||||||
ok(!ret, "Expected failure\n");
|
ok(!ret, "Expected failure\n");
|
||||||
todo_wine ok(servicesize == 2, "Service size expected 2, got %d\n", servicesize);
|
ok(servicesize == 2, "Service size expected 2, got %d\n", servicesize);
|
||||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||||
todo_wine ok(servicenameW[0] == 'A', "Service name changed\n");
|
ok(servicenameW[0] == 'A', "Service name changed\n");
|
||||||
|
|
||||||
servicesize = 2;
|
servicesize = 2;
|
||||||
strcpy(servicename, "ABC");
|
strcpy(servicename, "ABC");
|
||||||
|
@ -805,14 +805,14 @@ static void test_get_servicekeyname(void)
|
||||||
ok(!ret, "Expected failure\n");
|
ok(!ret, "Expected failure\n");
|
||||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||||
ok(servicesize == 2, "Service size expected 2, got %d\n", servicesize);
|
todo_wine ok(servicesize == 2, "Service size expected 2, got %d\n", servicesize);
|
||||||
ok(servicename[0] == 0, "Service name not empty\n");
|
ok(servicename[0] == 0, "Service name not empty\n");
|
||||||
|
|
||||||
servicesize = 2;
|
servicesize = 2;
|
||||||
lstrcpyW( servicenameW, abcW );
|
lstrcpyW( servicenameW, abcW );
|
||||||
ret = GetServiceKeyNameW(scm_handle, deadbeefW, servicenameW, &servicesize);
|
ret = GetServiceKeyNameW(scm_handle, deadbeefW, servicenameW, &servicesize);
|
||||||
ok(!ret, "Expected failure\n");
|
ok(!ret, "Expected failure\n");
|
||||||
todo_wine ok(servicesize == 2, "Service size expected 2, got %d\n", servicesize);
|
ok(servicesize == 2, "Service size expected 2, got %d\n", servicesize);
|
||||||
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
ok(GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST,
|
||||||
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
"Expected ERROR_SERVICE_DOES_NOT_EXIST, got %d\n", GetLastError());
|
||||||
ok(servicenameW[0] == 0, "Service name not empty\n");
|
ok(servicenameW[0] == 0, "Service name not empty\n");
|
||||||
|
|
|
@ -240,7 +240,7 @@ typedef [switch_type(DWORD)] union
|
||||||
[in] LPCWSTR lpServiceDisplayName,
|
[in] LPCWSTR lpServiceDisplayName,
|
||||||
[out,size_is(cchBufSize)] WCHAR lpBuffer[],
|
[out,size_is(cchBufSize)] WCHAR lpBuffer[],
|
||||||
[in] DWORD cchBufSize,
|
[in] DWORD cchBufSize,
|
||||||
[out] DWORD *cchLength);
|
[in,out] DWORD *cchLength);
|
||||||
|
|
||||||
/* Not compatible with Windows function 0x16 */
|
/* Not compatible with Windows function 0x16 */
|
||||||
DWORD svcctl_SCSetServiceBitsA(/* FIXME */);
|
DWORD svcctl_SCSetServiceBitsA(/* FIXME */);
|
||||||
|
|
|
@ -261,10 +261,7 @@ DWORD svcctl_GetServiceKeyNameW(
|
||||||
service_unlock(entry);
|
service_unlock(entry);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
*cchLength = 1;
|
|
||||||
err = ERROR_SERVICE_DOES_NOT_EXIST;
|
err = ERROR_SERVICE_DOES_NOT_EXIST;
|
||||||
}
|
|
||||||
|
|
||||||
scmdatabase_unlock(manager->db);
|
scmdatabase_unlock(manager->db);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue