Commit 714b2219 authored by Micah N Gorrell's avatar Micah N Gorrell Committed by Alexandre Julliard

advapi32: Replace SERV_dup() with strdupAW().

parent 2f2074a5
...@@ -31,7 +31,6 @@ BOOL ADVAPI_GetComputerSid(PSID sid) DECLSPEC_HIDDEN; ...@@ -31,7 +31,6 @@ BOOL ADVAPI_GetComputerSid(PSID sid) DECLSPEC_HIDDEN;
BOOL lookup_local_wellknown_name(const LSA_UNICODE_STRING*, PSID, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE, BOOL*) DECLSPEC_HIDDEN; BOOL lookup_local_wellknown_name(const LSA_UNICODE_STRING*, PSID, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE, BOOL*) DECLSPEC_HIDDEN;
BOOL lookup_local_user_name(const LSA_UNICODE_STRING*, PSID, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE, BOOL*) DECLSPEC_HIDDEN; BOOL lookup_local_user_name(const LSA_UNICODE_STRING*, PSID, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE, BOOL*) DECLSPEC_HIDDEN;
WCHAR *SERV_dup(const char *str) DECLSPEC_HIDDEN;
const WCHAR *get_wellknown_privilege_name(const LUID *) DECLSPEC_HIDDEN; const WCHAR *get_wellknown_privilege_name(const LUID *) DECLSPEC_HIDDEN;
/* memory allocation functions */ /* memory allocation functions */
......
...@@ -57,7 +57,7 @@ BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName ) ...@@ -57,7 +57,7 @@ BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
LPWSTR backupW; LPWSTR backupW;
BOOL ret; BOOL ret;
backupW = SERV_dup(lpBackupFileName); backupW = strdupAW(lpBackupFileName);
ret = BackupEventLogW(hEventLog, backupW); ret = BackupEventLogW(hEventLog, backupW);
heap_free(backupW); heap_free(backupW);
...@@ -114,7 +114,7 @@ BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName ) ...@@ -114,7 +114,7 @@ BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
LPWSTR backupW; LPWSTR backupW;
BOOL ret; BOOL ret;
backupW = SERV_dup(lpBackupFileName); backupW = strdupAW(lpBackupFileName);
ret = ClearEventLogW(hEventLog, backupW); ret = ClearEventLogW(hEventLog, backupW);
heap_free(backupW); heap_free(backupW);
...@@ -392,8 +392,8 @@ HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName ) ...@@ -392,8 +392,8 @@ HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName )
LPWSTR uncnameW, filenameW; LPWSTR uncnameW, filenameW;
HANDLE handle; HANDLE handle;
uncnameW = SERV_dup(lpUNCServerName); uncnameW = strdupAW(lpUNCServerName);
filenameW = SERV_dup(lpFileName); filenameW = strdupAW(lpFileName);
handle = OpenBackupEventLogW(uncnameW, filenameW); handle = OpenBackupEventLogW(uncnameW, filenameW);
heap_free(uncnameW); heap_free(uncnameW);
heap_free(filenameW); heap_free(filenameW);
...@@ -451,8 +451,8 @@ HANDLE WINAPI OpenEventLogA( LPCSTR uncname, LPCSTR source ) ...@@ -451,8 +451,8 @@ HANDLE WINAPI OpenEventLogA( LPCSTR uncname, LPCSTR source )
LPWSTR uncnameW, sourceW; LPWSTR uncnameW, sourceW;
HANDLE handle; HANDLE handle;
uncnameW = SERV_dup(uncname); uncnameW = strdupAW(uncname);
sourceW = SERV_dup(source); sourceW = strdupAW(source);
handle = OpenEventLogW(uncnameW, sourceW); handle = OpenEventLogW(uncnameW, sourceW);
heap_free(uncnameW); heap_free(uncnameW);
heap_free(sourceW); heap_free(sourceW);
......
...@@ -1015,7 +1015,7 @@ GetFileSecurityA( LPCSTR lpFileName, ...@@ -1015,7 +1015,7 @@ GetFileSecurityA( LPCSTR lpFileName,
BOOL r; BOOL r;
LPWSTR name; LPWSTR name;
name = SERV_dup(lpFileName); name = strdupAW(lpFileName);
r = GetFileSecurityW( name, RequestedInformation, pSecurityDescriptor, r = GetFileSecurityW( name, RequestedInformation, pSecurityDescriptor,
nLength, lpnLengthNeeded ); nLength, lpnLengthNeeded );
heap_free( name ); heap_free( name );
...@@ -1044,7 +1044,7 @@ LookupAccountSidA( ...@@ -1044,7 +1044,7 @@ LookupAccountSidA(
DWORD accountSizeW = *accountSize; DWORD accountSizeW = *accountSize;
DWORD domainSizeW = *domainSize; DWORD domainSizeW = *domainSize;
systemW = SERV_dup(system); systemW = strdupAW(system);
if (account) if (account)
accountW = heap_alloc( accountSizeW * sizeof(WCHAR) ); accountW = heap_alloc( accountSizeW * sizeof(WCHAR) );
if (domain) if (domain)
...@@ -1299,7 +1299,7 @@ BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName, ...@@ -1299,7 +1299,7 @@ BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
BOOL r; BOOL r;
LPWSTR name; LPWSTR name;
name = SERV_dup(lpFileName); name = strdupAW(lpFileName);
r = SetFileSecurityW( name, RequestedInformation, pSecurityDescriptor ); r = SetFileSecurityW( name, RequestedInformation, pSecurityDescriptor );
heap_free( name ); heap_free( name );
...@@ -2228,7 +2228,7 @@ static DWORD trustee_name_A_to_W(TRUSTEE_FORM form, char *trustee_nameA, WCHAR * ...@@ -2228,7 +2228,7 @@ static DWORD trustee_name_A_to_W(TRUSTEE_FORM form, char *trustee_nameA, WCHAR *
{ {
case TRUSTEE_IS_NAME: case TRUSTEE_IS_NAME:
{ {
*ptrustee_nameW = SERV_dup(trustee_nameA); *ptrustee_nameW = strdupAW(trustee_nameA);
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
case TRUSTEE_IS_OBJECTS_AND_NAME: case TRUSTEE_IS_OBJECTS_AND_NAME:
...@@ -2243,9 +2243,9 @@ static DWORD trustee_name_A_to_W(TRUSTEE_FORM form, char *trustee_nameA, WCHAR * ...@@ -2243,9 +2243,9 @@ static DWORD trustee_name_A_to_W(TRUSTEE_FORM form, char *trustee_nameA, WCHAR *
objW->ObjectsPresent = objA->ObjectsPresent; objW->ObjectsPresent = objA->ObjectsPresent;
objW->ObjectType = objA->ObjectType; objW->ObjectType = objA->ObjectType;
objW->ObjectTypeName = SERV_dup(objA->ObjectTypeName); objW->ObjectTypeName = strdupAW(objA->ObjectTypeName);
objW->InheritedObjectTypeName = SERV_dup(objA->InheritedObjectTypeName); objW->InheritedObjectTypeName = strdupAW(objA->InheritedObjectTypeName);
objW->ptstrName = SERV_dup(objA->ptstrName); objW->ptstrName = strdupAW(objA->ptstrName);
} }
*ptrustee_nameW = (WCHAR *)objW; *ptrustee_nameW = (WCHAR *)objW;
...@@ -2625,7 +2625,7 @@ DWORD WINAPI SetNamedSecurityInfoA(LPSTR pObjectName, ...@@ -2625,7 +2625,7 @@ DWORD WINAPI SetNamedSecurityInfoA(LPSTR pObjectName,
TRACE("%s %d %d %p %p %p %p\n", debugstr_a(pObjectName), ObjectType, TRACE("%s %d %d %p %p %p %p\n", debugstr_a(pObjectName), ObjectType,
SecurityInfo, psidOwner, psidGroup, pDacl, pSacl); SecurityInfo, psidOwner, psidGroup, pDacl, pSacl);
wstr = SERV_dup(pObjectName); wstr = strdupAW(pObjectName);
r = SetNamedSecurityInfoW( wstr, ObjectType, SecurityInfo, psidOwner, r = SetNamedSecurityInfoW( wstr, ObjectType, SecurityInfo, psidOwner,
psidGroup, pDacl, pSacl ); psidGroup, pDacl, pSacl );
...@@ -3300,7 +3300,7 @@ BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorA( ...@@ -3300,7 +3300,7 @@ BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorA(
if(!StringSecurityDescriptor) if(!StringSecurityDescriptor)
return FALSE; return FALSE;
StringSecurityDescriptorW = SERV_dup(StringSecurityDescriptor); StringSecurityDescriptorW = strdupAW(StringSecurityDescriptor);
ret = ConvertStringSecurityDescriptorToSecurityDescriptorW(StringSecurityDescriptorW, ret = ConvertStringSecurityDescriptorToSecurityDescriptorW(StringSecurityDescriptorW,
StringSDRevision, SecurityDescriptor, StringSDRevision, SecurityDescriptor,
SecurityDescriptorSize); SecurityDescriptorSize);
...@@ -3841,7 +3841,7 @@ BOOL WINAPI ConvertStringSidToSidA(LPCSTR StringSid, PSID* Sid) ...@@ -3841,7 +3841,7 @@ BOOL WINAPI ConvertStringSidToSidA(LPCSTR StringSid, PSID* Sid)
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
else else
{ {
WCHAR *wStringSid = SERV_dup(StringSid); WCHAR *wStringSid = strdupAW(StringSid);
bret = ConvertStringSidToSidW(wStringSid, Sid); bret = ConvertStringSidToSidW(wStringSid, Sid);
heap_free(wStringSid); heap_free(wStringSid);
} }
...@@ -4104,7 +4104,7 @@ DWORD WINAPI GetNamedSecurityInfoA(LPSTR pObjectName, ...@@ -4104,7 +4104,7 @@ DWORD WINAPI GetNamedSecurityInfoA(LPSTR pObjectName,
TRACE("%s %d %d %p %p %p %p %p\n", pObjectName, ObjectType, SecurityInfo, TRACE("%s %d %d %p %p %p %p %p\n", pObjectName, ObjectType, SecurityInfo,
ppsidOwner, ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor); ppsidOwner, ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor);
wstr = SERV_dup(pObjectName); wstr = strdupAW(pObjectName);
r = GetNamedSecurityInfoW( wstr, ObjectType, SecurityInfo, ppsidOwner, r = GetNamedSecurityInfoW( wstr, ObjectType, SecurityInfo, ppsidOwner,
ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor ); ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor );
......
...@@ -113,24 +113,6 @@ static BOOL stop_service; ...@@ -113,24 +113,6 @@ static BOOL stop_service;
extern HANDLE CDECL __wine_make_process_system(void); extern HANDLE CDECL __wine_make_process_system(void);
/******************************************************************************
* String management functions (same behaviour as strdup)
* NOTE: the caller of those functions is responsible for calling HeapFree
* in order to release the memory allocated by those functions.
*/
LPWSTR SERV_dup( LPCSTR str )
{
UINT len;
LPWSTR wstr;
if( !str )
return NULL;
len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
wstr = heap_alloc( len*sizeof (WCHAR) );
MultiByteToWideChar( CP_ACP, 0, str, -1, wstr, len );
return wstr;
}
static inline LPWSTR SERV_dupmulti(LPCSTR str) static inline LPWSTR SERV_dupmulti(LPCSTR str)
{ {
UINT len = 0, n = 0; UINT len = 0, n = 0;
...@@ -884,8 +866,8 @@ SC_HANDLE WINAPI OpenSCManagerA( LPCSTR lpMachineName, LPCSTR lpDatabaseName, ...@@ -884,8 +866,8 @@ SC_HANDLE WINAPI OpenSCManagerA( LPCSTR lpMachineName, LPCSTR lpDatabaseName,
LPWSTR machineW, databaseW; LPWSTR machineW, databaseW;
SC_HANDLE ret; SC_HANDLE ret;
machineW = SERV_dup(lpMachineName); machineW = strdupAW(lpMachineName);
databaseW = SERV_dup(lpDatabaseName); databaseW = strdupAW(lpDatabaseName);
ret = OpenSCManagerW(machineW, databaseW, dwDesiredAccess); ret = OpenSCManagerW(machineW, databaseW, dwDesiredAccess);
heap_free(databaseW); heap_free(databaseW);
heap_free(machineW); heap_free(machineW);
...@@ -1037,7 +1019,7 @@ SC_HANDLE WINAPI OpenServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName, ...@@ -1037,7 +1019,7 @@ SC_HANDLE WINAPI OpenServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
TRACE("%p %s 0x%08x\n", hSCManager, debugstr_a(lpServiceName), dwDesiredAccess); TRACE("%p %s 0x%08x\n", hSCManager, debugstr_a(lpServiceName), dwDesiredAccess);
lpServiceNameW = SERV_dup(lpServiceName); lpServiceNameW = strdupAW(lpServiceName);
ret = OpenServiceW( hSCManager, lpServiceNameW, dwDesiredAccess); ret = OpenServiceW( hSCManager, lpServiceNameW, dwDesiredAccess);
heap_free(lpServiceNameW); heap_free(lpServiceNameW);
return ret; return ret;
...@@ -1171,13 +1153,13 @@ CreateServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName, ...@@ -1171,13 +1153,13 @@ CreateServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
TRACE("%p %s %s\n", hSCManager, TRACE("%p %s %s\n", hSCManager,
debugstr_a(lpServiceName), debugstr_a(lpDisplayName)); debugstr_a(lpServiceName), debugstr_a(lpDisplayName));
lpServiceNameW = SERV_dup( lpServiceName ); lpServiceNameW = strdupAW( lpServiceName );
lpDisplayNameW = SERV_dup( lpDisplayName ); lpDisplayNameW = strdupAW( lpDisplayName );
lpBinaryPathNameW = SERV_dup( lpBinaryPathName ); lpBinaryPathNameW = strdupAW( lpBinaryPathName );
lpLoadOrderGroupW = SERV_dup( lpLoadOrderGroup ); lpLoadOrderGroupW = strdupAW( lpLoadOrderGroup );
lpDependenciesW = SERV_dupmulti( lpDependencies ); lpDependenciesW = SERV_dupmulti( lpDependencies );
lpServiceStartNameW = SERV_dup( lpServiceStartName ); lpServiceStartNameW = strdupAW( lpServiceStartName );
lpPasswordW = SERV_dup( lpPassword ); lpPasswordW = strdupAW( lpPassword );
r = CreateServiceW( hSCManager, lpServiceNameW, lpDisplayNameW, r = CreateServiceW( hSCManager, lpServiceNameW, lpDisplayNameW,
dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl, dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl,
...@@ -1269,7 +1251,7 @@ BOOL WINAPI StartServiceA( SC_HANDLE hService, DWORD dwNumServiceArgs, ...@@ -1269,7 +1251,7 @@ BOOL WINAPI StartServiceA( SC_HANDLE hService, DWORD dwNumServiceArgs,
lpwstr = heap_alloc( dwNumServiceArgs*sizeof(LPWSTR) ); lpwstr = heap_alloc( dwNumServiceArgs*sizeof(LPWSTR) );
for(i=0; i<dwNumServiceArgs; i++) for(i=0; i<dwNumServiceArgs; i++)
lpwstr[i]=SERV_dup(lpServiceArgVectors[i]); lpwstr[i]=strdupAW(lpServiceArgVectors[i]);
r = StartServiceW(hService, dwNumServiceArgs, (LPCWSTR *)lpwstr); r = StartServiceW(hService, dwNumServiceArgs, (LPCWSTR *)lpwstr);
...@@ -2108,7 +2090,7 @@ BOOL WINAPI GetServiceKeyNameA( SC_HANDLE hSCManager, LPCSTR lpDisplayName, ...@@ -2108,7 +2090,7 @@ BOOL WINAPI GetServiceKeyNameA( SC_HANDLE hSCManager, LPCSTR lpDisplayName,
TRACE("%p %s %p %p\n", hSCManager, TRACE("%p %s %p %p\n", hSCManager,
debugstr_a(lpDisplayName), lpServiceName, lpcchBuffer); debugstr_a(lpDisplayName), lpServiceName, lpcchBuffer);
lpDisplayNameW = SERV_dup(lpDisplayName); lpDisplayNameW = strdupAW(lpDisplayName);
if (lpServiceName) if (lpServiceName)
lpServiceNameW = heap_alloc(*lpcchBuffer * sizeof(WCHAR)); lpServiceNameW = heap_alloc(*lpcchBuffer * sizeof(WCHAR));
else else
...@@ -2231,7 +2213,7 @@ BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName, ...@@ -2231,7 +2213,7 @@ BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
TRACE("%p %s %p %p\n", hSCManager, TRACE("%p %s %p %p\n", hSCManager,
debugstr_a(lpServiceName), lpDisplayName, lpcchBuffer); debugstr_a(lpServiceName), lpDisplayName, lpcchBuffer);
lpServiceNameW = SERV_dup(lpServiceName); lpServiceNameW = strdupAW(lpServiceName);
if (lpDisplayName) if (lpDisplayName)
lpDisplayNameW = heap_alloc(*lpcchBuffer * sizeof(WCHAR)); lpDisplayNameW = heap_alloc(*lpcchBuffer * sizeof(WCHAR));
else else
...@@ -2374,12 +2356,12 @@ BOOL WINAPI ChangeServiceConfigA( SC_HANDLE hService, DWORD dwServiceType, ...@@ -2374,12 +2356,12 @@ BOOL WINAPI ChangeServiceConfigA( SC_HANDLE hService, DWORD dwServiceType,
lpdwTagId, lpDependencies, debugstr_a(lpServiceStartName), lpdwTagId, lpDependencies, debugstr_a(lpServiceStartName),
debugstr_a(lpPassword), debugstr_a(lpDisplayName) ); debugstr_a(lpPassword), debugstr_a(lpDisplayName) );
wBinaryPathName = SERV_dup( lpBinaryPathName ); wBinaryPathName = strdupAW( lpBinaryPathName );
wLoadOrderGroup = SERV_dup( lpLoadOrderGroup ); wLoadOrderGroup = strdupAW( lpLoadOrderGroup );
wDependencies = SERV_dupmulti( lpDependencies ); wDependencies = SERV_dupmulti( lpDependencies );
wServiceStartName = SERV_dup( lpServiceStartName ); wServiceStartName = strdupAW( lpServiceStartName );
wPassword = SERV_dup( lpPassword ); wPassword = strdupAW( lpPassword );
wDisplayName = SERV_dup( lpDisplayName ); wDisplayName = strdupAW( lpDisplayName );
r = ChangeServiceConfigW( hService, dwServiceType, r = ChangeServiceConfigW( hService, dwServiceType,
dwStartType, dwErrorControl, wBinaryPathName, dwStartType, dwErrorControl, wBinaryPathName,
...@@ -2411,7 +2393,7 @@ BOOL WINAPI ChangeServiceConfig2A( SC_HANDLE hService, DWORD dwInfoLevel, ...@@ -2411,7 +2393,7 @@ BOOL WINAPI ChangeServiceConfig2A( SC_HANDLE hService, DWORD dwInfoLevel,
LPSERVICE_DESCRIPTIONA sd = lpInfo; LPSERVICE_DESCRIPTIONA sd = lpInfo;
SERVICE_DESCRIPTIONW sdw; SERVICE_DESCRIPTIONW sdw;
sdw.lpDescription = SERV_dup( sd->lpDescription ); sdw.lpDescription = strdupAW( sd->lpDescription );
r = ChangeServiceConfig2W( hService, dwInfoLevel, &sdw ); r = ChangeServiceConfig2W( hService, dwInfoLevel, &sdw );
...@@ -2423,8 +2405,8 @@ BOOL WINAPI ChangeServiceConfig2A( SC_HANDLE hService, DWORD dwInfoLevel, ...@@ -2423,8 +2405,8 @@ BOOL WINAPI ChangeServiceConfig2A( SC_HANDLE hService, DWORD dwInfoLevel,
SERVICE_FAILURE_ACTIONSW faw; SERVICE_FAILURE_ACTIONSW faw;
faw.dwResetPeriod = fa->dwResetPeriod; faw.dwResetPeriod = fa->dwResetPeriod;
faw.lpRebootMsg = SERV_dup( fa->lpRebootMsg ); faw.lpRebootMsg = strdupAW( fa->lpRebootMsg );
faw.lpCommand = SERV_dup( fa->lpCommand ); faw.lpCommand = strdupAW( fa->lpCommand );
faw.cActions = fa->cActions; faw.cActions = fa->cActions;
faw.lpsaActions = fa->lpsaActions; faw.lpsaActions = fa->lpsaActions;
...@@ -2589,7 +2571,7 @@ SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExA( LPCSTR name, LPHANDL ...@@ -2589,7 +2571,7 @@ SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExA( LPCSTR name, LPHANDL
LPWSTR nameW; LPWSTR nameW;
SERVICE_STATUS_HANDLE ret; SERVICE_STATUS_HANDLE ret;
nameW = SERV_dup(name); nameW = strdupAW(name);
ret = RegisterServiceCtrlHandlerExW( nameW, handler, context ); ret = RegisterServiceCtrlHandlerExW( nameW, handler, context );
heap_free( nameW ); heap_free( nameW );
return ret; return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment