advapi32/service: Forward GetServiceDisplayNameA to GetServiceDisplayNameW.
This commit is contained in:
parent
23d61ac866
commit
95d2f04611
|
@ -2266,45 +2266,50 @@ BOOL WINAPI QueryServiceLockStatusW( SC_HANDLE hSCManager,
|
||||||
BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
|
BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
|
||||||
LPSTR lpDisplayName, LPDWORD lpcchBuffer)
|
LPSTR lpDisplayName, LPDWORD lpcchBuffer)
|
||||||
{
|
{
|
||||||
struct sc_manager *hscm;
|
LPWSTR lpServiceNameW, lpDisplayNameW = NULL;
|
||||||
DWORD type, size;
|
DWORD size, sizeW, GLE;
|
||||||
LONG ret;
|
BOOL ret;
|
||||||
|
|
||||||
TRACE("%p %s %p %p\n", hSCManager,
|
TRACE("%p %s %p %p\n", hSCManager,
|
||||||
debugstr_a(lpServiceName), lpDisplayName, lpcchBuffer);
|
debugstr_a(lpServiceName), lpDisplayName, lpcchBuffer);
|
||||||
|
|
||||||
hscm = sc_handle_get_handle_data(hSCManager, SC_HTYPE_MANAGER);
|
lpServiceNameW = SERV_dup(lpServiceName);
|
||||||
if (!hscm)
|
lpDisplayNameW = HeapAlloc(GetProcessHeap(), 0, *lpcchBuffer * sizeof(WCHAR));
|
||||||
|
|
||||||
|
size = sizeW = *lpcchBuffer;
|
||||||
|
ret = GetServiceDisplayNameW(hSCManager, lpServiceNameW,
|
||||||
|
lpDisplayName ? lpDisplayNameW : NULL,
|
||||||
|
&sizeW);
|
||||||
|
/* Last error will be set by GetServiceDisplayNameW and must be preserved */
|
||||||
|
GLE = GetLastError();
|
||||||
|
|
||||||
|
if (!lpDisplayName && lpcchBuffer && !ret && (GLE == ERROR_INSUFFICIENT_BUFFER))
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_HANDLE);
|
/* Request for buffersize.
|
||||||
return FALSE;
|
*
|
||||||
|
* Only set the size for ERROR_INSUFFICIENT_BUFFER
|
||||||
|
*/
|
||||||
|
size = sizeW * 2;
|
||||||
|
}
|
||||||
|
else if (lpDisplayName && lpcchBuffer && !ret)
|
||||||
|
{
|
||||||
|
/* Request for displayname.
|
||||||
|
*
|
||||||
|
* size only has to be set if this fails
|
||||||
|
*/
|
||||||
|
size = sizeW * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lpServiceName)
|
WideCharToMultiByte(CP_ACP, 0, lpDisplayNameW, (sizeW + 1), lpDisplayName,
|
||||||
{
|
*lpcchBuffer, NULL, NULL );
|
||||||
SetLastError(ERROR_INVALID_ADDRESS);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
size = *lpcchBuffer;
|
*lpcchBuffer = size;
|
||||||
ret = RegGetValueA(hscm->hkey, lpServiceName, "DisplayName", RRF_RT_REG_SZ, &type, lpDisplayName, &size);
|
|
||||||
if (!ret && !lpDisplayName && size)
|
|
||||||
ret = ERROR_MORE_DATA;
|
|
||||||
|
|
||||||
if (ret)
|
HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
|
||||||
{
|
SERV_free(lpServiceNameW);
|
||||||
if (lpDisplayName && *lpcchBuffer) *lpDisplayName = 0;
|
|
||||||
|
|
||||||
if (ret == ERROR_MORE_DATA)
|
SetLastError(GLE);
|
||||||
{
|
return ret;
|
||||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
||||||
*lpcchBuffer = size - 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SetLastError(ret);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
|
|
@ -459,24 +459,19 @@ static void test_get_displayname(void)
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
displaysize = (tempsize / 2) + 1;
|
displaysize = (tempsize / 2) + 1;
|
||||||
ret = GetServiceDisplayNameA(scm_handle, spooler, displayname, &displaysize);
|
ret = GetServiceDisplayNameA(scm_handle, spooler, displayname, &displaysize);
|
||||||
todo_wine
|
|
||||||
{
|
|
||||||
ok(ret, "Expected success\n");
|
ok(ret, "Expected success\n");
|
||||||
ok(displaysize == ((tempsize / 2) + 1), "Expected no change for the needed buffer size\n");
|
ok(displaysize == ((tempsize / 2) + 1), "Expected no change for the needed buffer size\n");
|
||||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||||
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
||||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
||||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||||
}
|
|
||||||
|
|
||||||
/* Now with the original returned size */
|
/* Now with the original returned size */
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
displaysize = tempsize;
|
displaysize = tempsize;
|
||||||
ret = GetServiceDisplayNameA(scm_handle, spooler, displayname, &displaysize);
|
ret = GetServiceDisplayNameA(scm_handle, spooler, displayname, &displaysize);
|
||||||
todo_wine
|
|
||||||
ok(ret, "Expected success\n");
|
ok(ret, "Expected success\n");
|
||||||
ok(displaysize == tempsize, "Expected no change for the needed buffer size\n");
|
ok(displaysize == tempsize, "Expected no change for the needed buffer size\n");
|
||||||
todo_wine
|
|
||||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||||
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
||||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
||||||
|
@ -493,7 +488,6 @@ static void test_get_displayname(void)
|
||||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||||
/* Test that shows that if the buffersize is enough, it's not changed */
|
/* Test that shows that if the buffersize is enough, it's not changed */
|
||||||
ok(displaysize == tempsize * 2, "Expected no change for the needed buffer size\n");
|
ok(displaysize == tempsize * 2, "Expected no change for the needed buffer size\n");
|
||||||
todo_wine
|
|
||||||
ok(lstrlen(displayname) == tempsize/2,
|
ok(lstrlen(displayname) == tempsize/2,
|
||||||
"Expected the buffer to be twice the length of the string\n") ;
|
"Expected the buffer to be twice the length of the string\n") ;
|
||||||
|
|
||||||
|
@ -538,9 +532,9 @@ static void test_get_displayname(void)
|
||||||
ok(displaysize == tempsizeW, "Expected the needed buffersize\n");
|
ok(displaysize == tempsizeW, "Expected the needed buffersize\n");
|
||||||
ok(lstrlenW(displaynameW) == displaysize,
|
ok(lstrlenW(displaynameW) == displaysize,
|
||||||
"Expected the buffer to be the length of the string\n") ;
|
"Expected the buffer to be the length of the string\n") ;
|
||||||
|
}
|
||||||
ok(tempsize / 2 == tempsizeW,
|
ok(tempsize / 2 == tempsizeW,
|
||||||
"Expected the needed buffersize (in bytes) to be the same for the A and W call\n");
|
"Expected the needed buffersize (in bytes) to be the same for the A and W call\n");
|
||||||
}
|
|
||||||
|
|
||||||
CloseServiceHandle(scm_handle);
|
CloseServiceHandle(scm_handle);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue