diff --git a/dlls/advapi32/eventlog.c b/dlls/advapi32/eventlog.c index 3602eb2f66b..9f4ad5809ce 100644 --- a/dlls/advapi32/eventlog.c +++ b/dlls/advapi32/eventlog.c @@ -22,6 +22,7 @@ #include "windef.h" #include "winerror.h" #include "heap.h" +#include "winternl.h" #include "wine/debug.h" @@ -216,11 +217,15 @@ ReadEventLogW( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset, */ HANDLE WINAPI RegisterEventSourceA( LPCSTR lpUNCServerName, LPCSTR lpSourceName ) { - LPWSTR lpUNCServerNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpUNCServerName); - LPWSTR lpSourceNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpSourceName); - HANDLE ret = RegisterEventSourceW(lpUNCServerNameW,lpSourceNameW); - HeapFree(GetProcessHeap(),0,lpSourceNameW); - HeapFree(GetProcessHeap(),0,lpUNCServerNameW); + + UNICODE_STRING lpUNCServerNameW; + UNICODE_STRING lpSourceNameW; + HANDLE ret; + RtlCreateUnicodeStringFromAsciiz(&lpUNCServerNameW, lpUNCServerName); + RtlCreateUnicodeStringFromAsciiz(&lpSourceNameW, lpSourceName); + ret = RegisterEventSourceW(lpUNCServerNameW.Buffer,lpSourceNameW.Buffer); + RtlFreeUnicodeString (&lpUNCServerNameW); + RtlFreeUnicodeString (&lpSourceNameW); return ret; } diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c index fddba709d72..9d71c9c91e0 100644 --- a/dlls/advapi32/registry.c +++ b/dlls/advapi32/registry.c @@ -36,6 +36,7 @@ #include "heap.h" #include "wine/server.h" #include "wine/debug.h" +#include "winternl.h" WINE_DEFAULT_DEBUG_CHANNEL(reg); @@ -1636,9 +1637,12 @@ LONG WINAPI RegRestoreKeyW( HKEY hkey, LPCWSTR lpFile, DWORD dwFlags ) */ LONG WINAPI RegRestoreKeyA( HKEY hkey, LPCSTR lpFile, DWORD dwFlags ) { - LPWSTR lpFileW = HEAP_strdupAtoW( GetProcessHeap(), 0, lpFile ); - LONG ret = RegRestoreKeyW( hkey, lpFileW, dwFlags ); - HeapFree( GetProcessHeap(), 0, lpFileW ); + UNICODE_STRING lpFileW; + LONG ret; + + RtlCreateUnicodeStringFromAsciiz( &lpFileW, lpFile ); + ret = RegRestoreKeyW( hkey, lpFileW.Buffer, dwFlags ); + RtlFreeUnicodeString( &lpFileW ); return ret; } @@ -1662,9 +1666,12 @@ LONG WINAPI RegUnLoadKeyW( HKEY hkey, LPCWSTR lpSubKey ) */ LONG WINAPI RegUnLoadKeyA( HKEY hkey, LPCSTR lpSubKey ) { - LPWSTR lpSubKeyW = HEAP_strdupAtoW( GetProcessHeap(), 0, lpSubKey ); - LONG ret = RegUnLoadKeyW( hkey, lpSubKeyW ); - if(lpSubKeyW) HeapFree( GetProcessHeap(), 0, lpSubKeyW); + UNICODE_STRING lpSubKeyW; + LONG ret; + + RtlCreateUnicodeStringFromAsciiz( &lpSubKeyW, lpSubKey ); + ret = RegUnLoadKeyW( hkey, lpSubKeyW.Buffer ); + RtlFreeUnicodeString( &lpSubKeyW ); return ret; } @@ -1693,13 +1700,18 @@ LONG WINAPI RegReplaceKeyW( HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpNewFile, LONG WINAPI RegReplaceKeyA( HKEY hkey, LPCSTR lpSubKey, LPCSTR lpNewFile, LPCSTR lpOldFile ) { - LPWSTR lpSubKeyW = HEAP_strdupAtoW( GetProcessHeap(), 0, lpSubKey ); - LPWSTR lpNewFileW = HEAP_strdupAtoW( GetProcessHeap(), 0, lpNewFile ); - LPWSTR lpOldFileW = HEAP_strdupAtoW( GetProcessHeap(), 0, lpOldFile ); - LONG ret = RegReplaceKeyW( hkey, lpSubKeyW, lpNewFileW, lpOldFileW ); - HeapFree( GetProcessHeap(), 0, lpOldFileW ); - HeapFree( GetProcessHeap(), 0, lpNewFileW ); - HeapFree( GetProcessHeap(), 0, lpSubKeyW ); + UNICODE_STRING lpSubKeyW; + UNICODE_STRING lpNewFileW; + UNICODE_STRING lpOldFileW; + LONG ret; + + RtlCreateUnicodeStringFromAsciiz( &lpSubKeyW, lpSubKey ); + RtlCreateUnicodeStringFromAsciiz( &lpOldFileW, lpOldFile ); + RtlCreateUnicodeStringFromAsciiz( &lpNewFileW, lpNewFile ); + ret = RegReplaceKeyW( hkey, lpSubKeyW.Buffer, lpNewFileW.Buffer, lpOldFileW.Buffer ); + RtlFreeUnicodeString( &lpOldFileW ); + RtlFreeUnicodeString( &lpNewFileW ); + RtlFreeUnicodeString( &lpSubKeyW ); return ret; } @@ -1820,9 +1832,12 @@ LONG WINAPI RegConnectRegistryW( LPCWSTR lpMachineName, HKEY hKey, */ LONG WINAPI RegConnectRegistryA( LPCSTR machine, HKEY hkey, PHKEY reskey ) { - LPWSTR machineW = HEAP_strdupAtoW( GetProcessHeap(), 0, machine ); - DWORD ret = RegConnectRegistryW( machineW, hkey, reskey ); - HeapFree( GetProcessHeap(), 0, machineW ); + UNICODE_STRING machineW; + LONG ret; + + RtlCreateUnicodeStringFromAsciiz( &machineW, machine ); + ret = RegConnectRegistryW( machineW.Buffer, hkey, reskey ); + RtlFreeUnicodeString( &machineW ); return ret; } diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c index 3b6673ac6d1..e0470ce2546 100644 --- a/dlls/advapi32/security.c +++ b/dlls/advapi32/security.c @@ -634,13 +634,15 @@ LookupPrivilegeValueW( LPCWSTR lpSystemName, LPCWSTR lpName, PLUID lpLuid ) BOOL WINAPI LookupPrivilegeValueA( LPCSTR lpSystemName, LPCSTR lpName, PLUID lpLuid ) { - LPWSTR lpSystemNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpSystemName); - LPWSTR lpNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpName); + UNICODE_STRING lpSystemNameW; + UNICODE_STRING lpNameW; BOOL ret; - ret = LookupPrivilegeValueW( lpSystemNameW, lpNameW, lpLuid); - HeapFree(GetProcessHeap(), 0, lpNameW); - HeapFree(GetProcessHeap(), 0, lpSystemNameW); + RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW, lpSystemName); + RtlCreateUnicodeStringFromAsciiz(&lpNameW,lpName); + ret = LookupPrivilegeValueW(lpSystemNameW.Buffer, lpNameW.Buffer, lpLuid); + RtlFreeUnicodeString(&lpNameW); + RtlFreeUnicodeString(&lpSystemNameW); return ret; } diff --git a/dlls/advapi32/service.c b/dlls/advapi32/service.c index 610cae79f52..7d15da28dc4 100644 --- a/dlls/advapi32/service.c +++ b/dlls/advapi32/service.c @@ -28,6 +28,7 @@ #include "wine/unicode.h" #include "heap.h" #include "wine/debug.h" +#include "winternl.h" WINE_DEFAULT_DEBUG_CHANNEL(advapi); @@ -234,12 +235,15 @@ SC_HANDLE WINAPI OpenSCManagerA( LPCSTR lpMachineName, LPCSTR lpDatabaseName, DWORD dwDesiredAccess ) { - LPWSTR lpMachineNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpMachineName); - LPWSTR lpDatabaseNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpDatabaseName); - SC_HANDLE ret = OpenSCManagerW(lpMachineNameW,lpDatabaseNameW, - dwDesiredAccess); - HeapFree(GetProcessHeap(),0,lpDatabaseNameW); - HeapFree(GetProcessHeap(),0,lpMachineNameW); + UNICODE_STRING lpMachineNameW; + UNICODE_STRING lpDatabaseNameW; + SC_HANDLE ret; + + RtlCreateUnicodeStringFromAsciiz (&lpMachineNameW,lpMachineName); + RtlCreateUnicodeStringFromAsciiz (&lpDatabaseNameW,lpDatabaseName); + ret = OpenSCManagerW(lpMachineNameW.Buffer,lpDatabaseNameW.Buffer, dwDesiredAccess); + RtlFreeUnicodeString(&lpDatabaseNameW); + RtlFreeUnicodeString(&lpMachineNameW); return ret; } @@ -347,15 +351,15 @@ SC_HANDLE WINAPI OpenServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName, DWORD dwDesiredAccess ) { - LPWSTR lpServiceNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpServiceName); + UNICODE_STRING lpServiceNameW; SC_HANDLE ret; - + RtlCreateUnicodeStringFromAsciiz (&lpServiceNameW,lpServiceName); if(lpServiceName) TRACE("Request for service %s\n",lpServiceName); else return FALSE; - ret = OpenServiceW( hSCManager, lpServiceNameW, dwDesiredAccess); - HeapFree(GetProcessHeap(),0,lpServiceNameW); + ret = OpenServiceW( hSCManager, lpServiceNameW.Buffer, dwDesiredAccess); + RtlFreeUnicodeString(&lpServiceNameW); return ret; }