Don't use RtlCreateUnicodeStringFromAsciiz, it doesn't preserve NULL.
This commit is contained in:
parent
3c949ef412
commit
1645ab0492
|
@ -646,12 +646,12 @@ SERVICE_STATUS_HANDLE WINAPI
|
||||||
RegisterServiceCtrlHandlerA( LPCSTR lpServiceName,
|
RegisterServiceCtrlHandlerA( LPCSTR lpServiceName,
|
||||||
LPHANDLER_FUNCTION lpfHandler )
|
LPHANDLER_FUNCTION lpfHandler )
|
||||||
{
|
{
|
||||||
UNICODE_STRING lpServiceNameW;
|
LPWSTR lpServiceNameW;
|
||||||
SERVICE_STATUS_HANDLE ret;
|
SERVICE_STATUS_HANDLE ret;
|
||||||
|
|
||||||
RtlCreateUnicodeStringFromAsciiz (&lpServiceNameW,lpServiceName);
|
lpServiceNameW = SERV_dup(lpServiceName);
|
||||||
ret = RegisterServiceCtrlHandlerW( lpServiceNameW.Buffer, lpfHandler );
|
ret = RegisterServiceCtrlHandlerW( lpServiceNameW, lpfHandler );
|
||||||
RtlFreeUnicodeString(&lpServiceNameW);
|
SERV_free(lpServiceNameW);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -721,15 +721,14 @@ SetServiceStatus( SERVICE_STATUS_HANDLE hService, LPSERVICE_STATUS lpStatus )
|
||||||
SC_HANDLE WINAPI OpenSCManagerA( LPCSTR lpMachineName, LPCSTR lpDatabaseName,
|
SC_HANDLE WINAPI OpenSCManagerA( LPCSTR lpMachineName, LPCSTR lpDatabaseName,
|
||||||
DWORD dwDesiredAccess )
|
DWORD dwDesiredAccess )
|
||||||
{
|
{
|
||||||
UNICODE_STRING lpMachineNameW;
|
LPWSTR lpMachineNameW, lpDatabaseNameW;
|
||||||
UNICODE_STRING lpDatabaseNameW;
|
|
||||||
SC_HANDLE ret;
|
SC_HANDLE ret;
|
||||||
|
|
||||||
RtlCreateUnicodeStringFromAsciiz (&lpMachineNameW,lpMachineName);
|
lpMachineNameW = SERV_dup(lpMachineName);
|
||||||
RtlCreateUnicodeStringFromAsciiz (&lpDatabaseNameW,lpDatabaseName);
|
lpDatabaseNameW = SERV_dup(lpDatabaseName);
|
||||||
ret = OpenSCManagerW(lpMachineNameW.Buffer,lpDatabaseNameW.Buffer, dwDesiredAccess);
|
ret = OpenSCManagerW(lpMachineNameW, lpDatabaseNameW, dwDesiredAccess);
|
||||||
RtlFreeUnicodeString(&lpDatabaseNameW);
|
SERV_free(lpDatabaseNameW);
|
||||||
RtlFreeUnicodeString(&lpMachineNameW);
|
SERV_free(lpMachineNameW);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -932,15 +931,14 @@ CloseServiceHandle( SC_HANDLE hSCObject )
|
||||||
SC_HANDLE WINAPI OpenServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
|
SC_HANDLE WINAPI OpenServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
|
||||||
DWORD dwDesiredAccess )
|
DWORD dwDesiredAccess )
|
||||||
{
|
{
|
||||||
UNICODE_STRING lpServiceNameW;
|
LPWSTR lpServiceNameW;
|
||||||
SC_HANDLE ret;
|
SC_HANDLE ret;
|
||||||
RtlCreateUnicodeStringFromAsciiz (&lpServiceNameW,lpServiceName);
|
|
||||||
if(lpServiceName)
|
TRACE("%p %s %ld\n",hSCManager, debugstr_a(lpServiceName), dwDesiredAccess);
|
||||||
TRACE("Request for service %s\n",lpServiceName);
|
|
||||||
else
|
lpServiceNameW = SERV_dup(lpServiceName);
|
||||||
return FALSE;
|
ret = OpenServiceW( hSCManager, lpServiceNameW, dwDesiredAccess);
|
||||||
ret = OpenServiceW( hSCManager, lpServiceNameW.Buffer, dwDesiredAccess);
|
SERV_free(lpServiceNameW);
|
||||||
RtlFreeUnicodeString(&lpServiceNameW);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -958,8 +956,13 @@ SC_HANDLE WINAPI OpenServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName,
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
long r;
|
long r;
|
||||||
|
|
||||||
TRACE("(%p,%p,%ld)\n",hSCManager, lpServiceName,
|
TRACE("%p %s %ld\n",hSCManager, debugstr_w(lpServiceName), dwDesiredAccess);
|
||||||
dwDesiredAccess);
|
|
||||||
|
if (!lpServiceName)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_ADDRESS);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
retval = alloc_sc_handle( SC_HTYPE_SERVICE );
|
retval = alloc_sc_handle( SC_HTYPE_SERVICE );
|
||||||
if( NULL == retval )
|
if( NULL == retval )
|
||||||
|
@ -1208,29 +1211,23 @@ StartServiceA( SC_HANDLE hService, DWORD dwNumServiceArgs,
|
||||||
LPCSTR *lpServiceArgVectors )
|
LPCSTR *lpServiceArgVectors )
|
||||||
{
|
{
|
||||||
LPWSTR *lpwstr=NULL;
|
LPWSTR *lpwstr=NULL;
|
||||||
UNICODE_STRING usBuffer;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
TRACE("(%p,%ld,%p)\n",hService,dwNumServiceArgs,lpServiceArgVectors);
|
TRACE("(%p,%ld,%p)\n",hService,dwNumServiceArgs,lpServiceArgVectors);
|
||||||
|
|
||||||
if(dwNumServiceArgs)
|
if(dwNumServiceArgs)
|
||||||
lpwstr = (LPWSTR*) HeapAlloc( GetProcessHeap(), 0,
|
lpwstr = HeapAlloc( GetProcessHeap(), 0,
|
||||||
dwNumServiceArgs*sizeof(LPWSTR) );
|
dwNumServiceArgs*sizeof(LPWSTR) );
|
||||||
else
|
|
||||||
lpwstr = NULL;
|
|
||||||
|
|
||||||
for(i=0; i<dwNumServiceArgs; i++)
|
for(i=0; i<dwNumServiceArgs; i++)
|
||||||
{
|
lpwstr[i]=SERV_dup(lpServiceArgVectors[i]);
|
||||||
RtlCreateUnicodeStringFromAsciiz (&usBuffer,lpServiceArgVectors[i]);
|
|
||||||
lpwstr[i]=usBuffer.Buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
StartServiceW(hService, dwNumServiceArgs, (LPCWSTR *)lpwstr);
|
StartServiceW(hService, dwNumServiceArgs, (LPCWSTR *)lpwstr);
|
||||||
|
|
||||||
if(dwNumServiceArgs)
|
if(dwNumServiceArgs)
|
||||||
{
|
{
|
||||||
for(i=0; i<dwNumServiceArgs; i++)
|
for(i=0; i<dwNumServiceArgs; i++)
|
||||||
HeapFree(GetProcessHeap(), 0, lpwstr[i]);
|
SERV_free(lpwstr[i]);
|
||||||
HeapFree(GetProcessHeap(), 0, lpwstr);
|
HeapFree(GetProcessHeap(), 0, lpwstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue