From: Micah N Gorrell mgorrell@codeweavers.com
Signed-off-by: Micah N Gorrell mgorrell@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/advapi32/advapi32_misc.h | 1 - dlls/advapi32/eventlog.c | 12 +++---- dlls/advapi32/security.c | 22 ++++++------- dlls/advapi32/service.c | 60 ++++++++++++----------------------- 4 files changed, 38 insertions(+), 57 deletions(-)
diff --git a/dlls/advapi32/advapi32_misc.h b/dlls/advapi32/advapi32_misc.h index 77b56420ba3..65bd8aa8529 100644 --- a/dlls/advapi32/advapi32_misc.h +++ b/dlls/advapi32/advapi32_misc.h @@ -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_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;
/* memory allocation functions */ diff --git a/dlls/advapi32/eventlog.c b/dlls/advapi32/eventlog.c index 11561b21271..c81df3ee29f 100644 --- a/dlls/advapi32/eventlog.c +++ b/dlls/advapi32/eventlog.c @@ -57,7 +57,7 @@ BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName ) LPWSTR backupW; BOOL ret;
- backupW = SERV_dup(lpBackupFileName); + backupW = strdupAW(lpBackupFileName); ret = BackupEventLogW(hEventLog, backupW); heap_free(backupW);
@@ -114,7 +114,7 @@ BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName ) LPWSTR backupW; BOOL ret;
- backupW = SERV_dup(lpBackupFileName); + backupW = strdupAW(lpBackupFileName); ret = ClearEventLogW(hEventLog, backupW); heap_free(backupW);
@@ -392,8 +392,8 @@ HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName ) LPWSTR uncnameW, filenameW; HANDLE handle;
- uncnameW = SERV_dup(lpUNCServerName); - filenameW = SERV_dup(lpFileName); + uncnameW = strdupAW(lpUNCServerName); + filenameW = strdupAW(lpFileName); handle = OpenBackupEventLogW(uncnameW, filenameW); heap_free(uncnameW); heap_free(filenameW); @@ -451,8 +451,8 @@ HANDLE WINAPI OpenEventLogA( LPCSTR uncname, LPCSTR source ) LPWSTR uncnameW, sourceW; HANDLE handle;
- uncnameW = SERV_dup(uncname); - sourceW = SERV_dup(source); + uncnameW = strdupAW(uncname); + sourceW = strdupAW(source); handle = OpenEventLogW(uncnameW, sourceW); heap_free(uncnameW); heap_free(sourceW); diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c index 7315f9b51a9..d3c9a6c1e29 100644 --- a/dlls/advapi32/security.c +++ b/dlls/advapi32/security.c @@ -1015,7 +1015,7 @@ GetFileSecurityA( LPCSTR lpFileName, BOOL r; LPWSTR name;
- name = SERV_dup(lpFileName); + name = strdupAW(lpFileName); r = GetFileSecurityW( name, RequestedInformation, pSecurityDescriptor, nLength, lpnLengthNeeded ); heap_free( name ); @@ -1044,7 +1044,7 @@ LookupAccountSidA( DWORD accountSizeW = *accountSize; DWORD domainSizeW = *domainSize;
- systemW = SERV_dup(system); + systemW = strdupAW(system); if (account) accountW = heap_alloc( accountSizeW * sizeof(WCHAR) ); if (domain) @@ -1299,7 +1299,7 @@ BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName, BOOL r; LPWSTR name;
- name = SERV_dup(lpFileName); + name = strdupAW(lpFileName); r = SetFileSecurityW( name, RequestedInformation, pSecurityDescriptor ); heap_free( name );
@@ -2228,7 +2228,7 @@ static DWORD trustee_name_A_to_W(TRUSTEE_FORM form, char *trustee_nameA, WCHAR * { case TRUSTEE_IS_NAME: { - *ptrustee_nameW = SERV_dup(trustee_nameA); + *ptrustee_nameW = strdupAW(trustee_nameA); return ERROR_SUCCESS; } case TRUSTEE_IS_OBJECTS_AND_NAME: @@ -2243,9 +2243,9 @@ static DWORD trustee_name_A_to_W(TRUSTEE_FORM form, char *trustee_nameA, WCHAR *
objW->ObjectsPresent = objA->ObjectsPresent; objW->ObjectType = objA->ObjectType; - objW->ObjectTypeName = SERV_dup(objA->ObjectTypeName); - objW->InheritedObjectTypeName = SERV_dup(objA->InheritedObjectTypeName); - objW->ptstrName = SERV_dup(objA->ptstrName); + objW->ObjectTypeName = strdupAW(objA->ObjectTypeName); + objW->InheritedObjectTypeName = strdupAW(objA->InheritedObjectTypeName); + objW->ptstrName = strdupAW(objA->ptstrName); }
*ptrustee_nameW = (WCHAR *)objW; @@ -2625,7 +2625,7 @@ DWORD WINAPI SetNamedSecurityInfoA(LPSTR pObjectName, TRACE("%s %d %d %p %p %p %p\n", debugstr_a(pObjectName), ObjectType, SecurityInfo, psidOwner, psidGroup, pDacl, pSacl);
- wstr = SERV_dup(pObjectName); + wstr = strdupAW(pObjectName); r = SetNamedSecurityInfoW( wstr, ObjectType, SecurityInfo, psidOwner, psidGroup, pDacl, pSacl );
@@ -3300,7 +3300,7 @@ BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorA( if(!StringSecurityDescriptor) return FALSE;
- StringSecurityDescriptorW = SERV_dup(StringSecurityDescriptor); + StringSecurityDescriptorW = strdupAW(StringSecurityDescriptor); ret = ConvertStringSecurityDescriptorToSecurityDescriptorW(StringSecurityDescriptorW, StringSDRevision, SecurityDescriptor, SecurityDescriptorSize); @@ -3841,7 +3841,7 @@ BOOL WINAPI ConvertStringSidToSidA(LPCSTR StringSid, PSID* Sid) SetLastError(ERROR_INVALID_PARAMETER); else { - WCHAR *wStringSid = SERV_dup(StringSid); + WCHAR *wStringSid = strdupAW(StringSid); bret = ConvertStringSidToSidW(wStringSid, Sid); heap_free(wStringSid); } @@ -4104,7 +4104,7 @@ DWORD WINAPI GetNamedSecurityInfoA(LPSTR pObjectName, TRACE("%s %d %d %p %p %p %p %p\n", pObjectName, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor);
- wstr = SERV_dup(pObjectName); + wstr = strdupAW(pObjectName); r = GetNamedSecurityInfoW( wstr, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor );
diff --git a/dlls/advapi32/service.c b/dlls/advapi32/service.c index 2781a128239..3bf6fdfd47f 100644 --- a/dlls/advapi32/service.c +++ b/dlls/advapi32/service.c @@ -113,24 +113,6 @@ static BOOL stop_service;
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) { UINT len = 0, n = 0; @@ -884,8 +866,8 @@ SC_HANDLE WINAPI OpenSCManagerA( LPCSTR lpMachineName, LPCSTR lpDatabaseName, LPWSTR machineW, databaseW; SC_HANDLE ret;
- machineW = SERV_dup(lpMachineName); - databaseW = SERV_dup(lpDatabaseName); + machineW = strdupAW(lpMachineName); + databaseW = strdupAW(lpDatabaseName); ret = OpenSCManagerW(machineW, databaseW, dwDesiredAccess); heap_free(databaseW); heap_free(machineW); @@ -1037,7 +1019,7 @@ SC_HANDLE WINAPI OpenServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
TRACE("%p %s 0x%08x\n", hSCManager, debugstr_a(lpServiceName), dwDesiredAccess);
- lpServiceNameW = SERV_dup(lpServiceName); + lpServiceNameW = strdupAW(lpServiceName); ret = OpenServiceW( hSCManager, lpServiceNameW, dwDesiredAccess); heap_free(lpServiceNameW); return ret; @@ -1171,13 +1153,13 @@ CreateServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName, TRACE("%p %s %s\n", hSCManager, debugstr_a(lpServiceName), debugstr_a(lpDisplayName));
- lpServiceNameW = SERV_dup( lpServiceName ); - lpDisplayNameW = SERV_dup( lpDisplayName ); - lpBinaryPathNameW = SERV_dup( lpBinaryPathName ); - lpLoadOrderGroupW = SERV_dup( lpLoadOrderGroup ); + lpServiceNameW = strdupAW( lpServiceName ); + lpDisplayNameW = strdupAW( lpDisplayName ); + lpBinaryPathNameW = strdupAW( lpBinaryPathName ); + lpLoadOrderGroupW = strdupAW( lpLoadOrderGroup ); lpDependenciesW = SERV_dupmulti( lpDependencies ); - lpServiceStartNameW = SERV_dup( lpServiceStartName ); - lpPasswordW = SERV_dup( lpPassword ); + lpServiceStartNameW = strdupAW( lpServiceStartName ); + lpPasswordW = strdupAW( lpPassword );
r = CreateServiceW( hSCManager, lpServiceNameW, lpDisplayNameW, dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl, @@ -1269,7 +1251,7 @@ BOOL WINAPI StartServiceA( SC_HANDLE hService, DWORD dwNumServiceArgs, lpwstr = heap_alloc( dwNumServiceArgs*sizeof(LPWSTR) );
for(i=0; i<dwNumServiceArgs; i++) - lpwstr[i]=SERV_dup(lpServiceArgVectors[i]); + lpwstr[i]=strdupAW(lpServiceArgVectors[i]);
r = StartServiceW(hService, dwNumServiceArgs, (LPCWSTR *)lpwstr);
@@ -2108,7 +2090,7 @@ BOOL WINAPI GetServiceKeyNameA( SC_HANDLE hSCManager, LPCSTR lpDisplayName, TRACE("%p %s %p %p\n", hSCManager, debugstr_a(lpDisplayName), lpServiceName, lpcchBuffer);
- lpDisplayNameW = SERV_dup(lpDisplayName); + lpDisplayNameW = strdupAW(lpDisplayName); if (lpServiceName) lpServiceNameW = heap_alloc(*lpcchBuffer * sizeof(WCHAR)); else @@ -2231,7 +2213,7 @@ BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName, TRACE("%p %s %p %p\n", hSCManager, debugstr_a(lpServiceName), lpDisplayName, lpcchBuffer);
- lpServiceNameW = SERV_dup(lpServiceName); + lpServiceNameW = strdupAW(lpServiceName); if (lpDisplayName) lpDisplayNameW = heap_alloc(*lpcchBuffer * sizeof(WCHAR)); else @@ -2374,12 +2356,12 @@ BOOL WINAPI ChangeServiceConfigA( SC_HANDLE hService, DWORD dwServiceType, lpdwTagId, lpDependencies, debugstr_a(lpServiceStartName), debugstr_a(lpPassword), debugstr_a(lpDisplayName) );
- wBinaryPathName = SERV_dup( lpBinaryPathName ); - wLoadOrderGroup = SERV_dup( lpLoadOrderGroup ); + wBinaryPathName = strdupAW( lpBinaryPathName ); + wLoadOrderGroup = strdupAW( lpLoadOrderGroup ); wDependencies = SERV_dupmulti( lpDependencies ); - wServiceStartName = SERV_dup( lpServiceStartName ); - wPassword = SERV_dup( lpPassword ); - wDisplayName = SERV_dup( lpDisplayName ); + wServiceStartName = strdupAW( lpServiceStartName ); + wPassword = strdupAW( lpPassword ); + wDisplayName = strdupAW( lpDisplayName );
r = ChangeServiceConfigW( hService, dwServiceType, dwStartType, dwErrorControl, wBinaryPathName, @@ -2411,7 +2393,7 @@ BOOL WINAPI ChangeServiceConfig2A( SC_HANDLE hService, DWORD dwInfoLevel, LPSERVICE_DESCRIPTIONA sd = lpInfo; SERVICE_DESCRIPTIONW sdw;
- sdw.lpDescription = SERV_dup( sd->lpDescription ); + sdw.lpDescription = strdupAW( sd->lpDescription );
r = ChangeServiceConfig2W( hService, dwInfoLevel, &sdw );
@@ -2423,8 +2405,8 @@ BOOL WINAPI ChangeServiceConfig2A( SC_HANDLE hService, DWORD dwInfoLevel, SERVICE_FAILURE_ACTIONSW faw;
faw.dwResetPeriod = fa->dwResetPeriod; - faw.lpRebootMsg = SERV_dup( fa->lpRebootMsg ); - faw.lpCommand = SERV_dup( fa->lpCommand ); + faw.lpRebootMsg = strdupAW( fa->lpRebootMsg ); + faw.lpCommand = strdupAW( fa->lpCommand ); faw.cActions = fa->cActions; faw.lpsaActions = fa->lpsaActions;
@@ -2589,7 +2571,7 @@ SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExA( LPCSTR name, LPHANDL LPWSTR nameW; SERVICE_STATUS_HANDLE ret;
- nameW = SERV_dup(name); + nameW = strdupAW(name); ret = RegisterServiceCtrlHandlerExW( nameW, handler, context ); heap_free( nameW ); return ret;