Commit 53d95670 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

advapi32: Use wide character string literals.

parent 1690b6b4
......@@ -58,8 +58,7 @@ BOOL WINAPI GetUserNameA( LPSTR name, LPDWORD size )
*/
BOOL WINAPI GetUserNameW( LPWSTR name, LPDWORD size )
{
static const WCHAR wineusernameW[] = {'W','I','N','E','U','S','E','R','N','A','M','E',0};
DWORD len = GetEnvironmentVariableW( wineusernameW, name, *size );
DWORD len = GetEnvironmentVariableW( L"WINEUSERNAME", name, *size );
BOOL ret;
if (!len) return FALSE;
......@@ -273,14 +272,13 @@ typedef UINT (WINAPI *fnMsiProvideComponentFromDescriptor)(LPCWSTR,LPWSTR,DWORD*
DWORD WINAPI CommandLineFromMsiDescriptor( WCHAR *szDescriptor,
WCHAR *szCommandLine, DWORD *pcchCommandLine )
{
static const WCHAR szMsi[] = { 'm','s','i',0 };
fnMsiProvideComponentFromDescriptor mpcfd;
HMODULE hmsi;
UINT r = ERROR_CALL_NOT_IMPLEMENTED;
TRACE("%s %p %p\n", debugstr_w(szDescriptor), szCommandLine, pcchCommandLine);
hmsi = LoadLibraryW( szMsi );
hmsi = LoadLibraryW( L"msi" );
if (!hmsi)
return r;
mpcfd = (fnMsiProvideComponentFromDescriptor)GetProcAddress( hmsi,
......
......@@ -59,13 +59,7 @@ static HWND crypt_hWindow;
static inline PWSTR CRYPT_GetProvKeyName(PCWSTR pProvName)
{
static const WCHAR KEYSTR[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'C','r','y','p','t','o','g','r','a','p','h','y','\\',
'D','e','f','a','u','l','t','s','\\',
'P','r','o','v','i','d','e','r','\\',0
};
static const WCHAR KEYSTR[] = L"Software\\Microsoft\\Cryptography\\Defaults\\Provider\\";
PWSTR keyname;
keyname = CRYPT_Alloc((lstrlenW(KEYSTR) + lstrlenW(pProvName) +1)*sizeof(WCHAR));
......@@ -80,20 +74,8 @@ static inline PWSTR CRYPT_GetProvKeyName(PCWSTR pProvName)
static inline PWSTR CRYPT_GetTypeKeyName(DWORD dwType, BOOL user)
{
static const WCHAR MACHINESTR[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'C','r','y','p','t','o','g','r','a','p','h','y','\\',
'D','e','f','a','u','l','t','s','\\',
'P','r','o','v','i','d','e','r',' ','T','y','p','e','s','\\',
'T','y','p','e',' ','X','X','X',0
};
static const WCHAR USERSTR[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'C','r','y','p','t','o','g','r','a','p','h','y','\\',
'P','r','o','v','i','d','e','r',' ','T','y','p','e',' ','X','X','X',0
};
static const WCHAR MACHINESTR[] = L"Software\\Microsoft\\Cryptography\\Defaults\\Provider Types\\Type XXX";
static const WCHAR USERSTR[] = L"Software\\Microsoft\\Cryptography\\Provider Type XXX";
PWSTR keyname;
PWSTR ptr;
......@@ -272,22 +254,16 @@ error:
static void CRYPT_CreateMachineGuid(void)
{
static const WCHAR cryptographyW[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'C','r','y','p','t','o','g','r','a','p','h','y',0 };
static const WCHAR machineGuidW[] = {
'M','a','c','h','i','n','e','G','u','i','d',0 };
LONG r;
HKEY key;
r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, cryptographyW, 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY,
r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Cryptography", 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY,
&key);
if (!r)
{
DWORD size;
r = RegQueryValueExW(key, machineGuidW, NULL, NULL, NULL, &size);
r = RegQueryValueExW(key, L"MachineGuid", NULL, NULL, NULL, &size);
if (r == ERROR_FILE_NOT_FOUND)
{
UUID uuid;
......@@ -301,7 +277,7 @@ static void CRYPT_CreateMachineGuid(void)
uuid.Data4[2], uuid.Data4[3],
uuid.Data4[4], uuid.Data4[5],
uuid.Data4[6], uuid.Data4[7] );
RegSetValueExW(key, machineGuidW, 0, REG_SZ,
RegSetValueExW(key, L"MachineGuid", 0, REG_SZ,
(const BYTE *)buf,
(lstrlenW(buf)+1)*sizeof(WCHAR));
}
......@@ -351,9 +327,6 @@ BOOL WINAPI CryptAcquireContextW (HCRYPTPROV *phProv, LPCWSTR pszContainer,
PSTR provnameA = NULL, pszContainerA = NULL;
DWORD keytype, type, len;
ULONG r;
static const WCHAR nameW[] = {'N','a','m','e',0};
static const WCHAR typeW[] = {'T','y','p','e',0};
static const WCHAR imagepathW[] = {'I','m','a','g','e',' ','P','a','t','h',0};
TRACE("(%p, %s, %s, %d, %08x)\n", phProv, debugstr_w(pszContainer),
debugstr_w(pszProvider), dwProvType, dwFlags);
......@@ -401,7 +374,7 @@ BOOL WINAPI CryptAcquireContextW (HCRYPTPROV *phProv, LPCWSTR pszContainer,
}
}
CRYPT_Free(keyname);
r = RegQueryValueExW(key, nameW, NULL, &keytype, NULL, &len);
r = RegQueryValueExW(key, L"Name", NULL, &keytype, NULL, &len);
if( r != ERROR_SUCCESS || !len || keytype != REG_SZ)
{
TRACE("error %d reading size of 'Name' from registry\n", r );
......@@ -415,7 +388,7 @@ BOOL WINAPI CryptAcquireContextW (HCRYPTPROV *phProv, LPCWSTR pszContainer,
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto error;
}
r = RegQueryValueExW(key, nameW, NULL, NULL, (LPBYTE)provname, &len);
r = RegQueryValueExW(key, L"Name", NULL, NULL, (LPBYTE)provname, &len);
if( r != ERROR_SUCCESS )
{
TRACE("error %d reading 'Name' from registry\n", r );
......@@ -442,7 +415,7 @@ BOOL WINAPI CryptAcquireContextW (HCRYPTPROV *phProv, LPCWSTR pszContainer,
goto error;
}
len = sizeof(DWORD);
r = RegQueryValueExW(key, typeW, NULL, NULL, (BYTE*)&type, &len);
r = RegQueryValueExW(key, L"Type", NULL, NULL, (BYTE*)&type, &len);
if (r != ERROR_SUCCESS)
{
SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
......@@ -455,7 +428,7 @@ BOOL WINAPI CryptAcquireContextW (HCRYPTPROV *phProv, LPCWSTR pszContainer,
goto error;
}
r = RegQueryValueExW(key, imagepathW, NULL, &keytype, NULL, &len);
r = RegQueryValueExW(key, L"Image Path", NULL, &keytype, NULL, &len);
if ( r != ERROR_SUCCESS || keytype != REG_SZ)
{
TRACE("error %d reading size of 'Image Path' from registry\n", r );
......@@ -469,7 +442,7 @@ BOOL WINAPI CryptAcquireContextW (HCRYPTPROV *phProv, LPCWSTR pszContainer,
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto error;
}
r = RegQueryValueExW(key, imagepathW, NULL, NULL, (LPBYTE)temp, &len);
r = RegQueryValueExW(key, L"Image Path", NULL, NULL, (LPBYTE)temp, &len);
if( r != ERROR_SUCCESS )
{
TRACE("error %d reading 'Image Path' from registry\n", r );
......@@ -1125,14 +1098,6 @@ BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved,
DWORD dwFlags, DWORD *pdwProvType, LPWSTR pszProvName, DWORD *pcbProvName)
{
HKEY hKey;
static const WCHAR providerW[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'C','r','y','p','t','o','g','r','a','p','h','y','\\',
'D','e','f','a','u','l','t','s','\\',
'P','r','o','v','i','d','e','r',0
};
static const WCHAR typeW[] = {'T','y','p','e',0};
BOOL ret;
TRACE("(%d, %p, %d, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
......@@ -1149,7 +1114,7 @@ BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved,
return FALSE;
}
if (RegOpenKeyW(HKEY_LOCAL_MACHINE, providerW, &hKey))
if (RegOpenKeyW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Cryptography\\Defaults\\Provider", &hKey))
{
SetLastError(NTE_FAIL);
return FALSE;
......@@ -1199,7 +1164,7 @@ BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved,
return FALSE;
}
if (RegQueryValueExW(subkey, typeW, NULL, NULL, (BYTE*)pdwProvType, &size))
if (RegQueryValueExW(subkey, L"Type", NULL, NULL, (BYTE*)pdwProvType, &size))
ret = FALSE;
RegCloseKey(subkey);
......@@ -1275,14 +1240,6 @@ BOOL WINAPI CryptEnumProviderTypesW (DWORD dwIndex, DWORD *pdwReserved,
DWORD keylen, numkeys, dwType;
PWSTR keyname, ch;
DWORD result;
static const WCHAR KEYSTR[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'C','r','y','p','t','o','g','r','a','p','h','y','\\',
'D','e','f','a','u','l','t','s','\\',
'P','r','o','v','i','d','e','r',' ','T','y','p','e','s',0
};
static const WCHAR typenameW[] = {'T','y','p','e','N','a','m','e',0};
TRACE("(%d, %p, %08x, %p, %p, %p)\n", dwIndex, pdwReserved,
dwFlags, pdwProvType, pszTypeName, pcbTypeName);
......@@ -1298,7 +1255,7 @@ BOOL WINAPI CryptEnumProviderTypesW (DWORD dwIndex, DWORD *pdwReserved,
return FALSE;
}
if (RegOpenKeyW(HKEY_LOCAL_MACHINE, KEYSTR, &hKey))
if (RegOpenKeyW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Cryptography\\Defaults\\Provider Types", &hKey))
return FALSE;
RegQueryInfoKeyW(hKey, NULL, NULL, NULL, &numkeys, &keylen, NULL, NULL, NULL, NULL, NULL, NULL);
......@@ -1330,7 +1287,7 @@ BOOL WINAPI CryptEnumProviderTypesW (DWORD dwIndex, DWORD *pdwReserved,
*pdwProvType += (*(--ch) - '0') * 100;
CRYPT_Free(keyname);
result = RegQueryValueExW(hSubkey, typenameW, NULL, &dwType, (LPBYTE)pszTypeName, pcbTypeName);
result = RegQueryValueExW(hSubkey, L"TypeName", NULL, &dwType, (LPBYTE)pszTypeName, pcbTypeName);
if (result)
{
SetLastError(result);
......@@ -1494,7 +1451,6 @@ BOOL WINAPI CryptGetDefaultProviderW (DWORD dwProvType, DWORD *pdwReserved,
HKEY hKey;
PWSTR keyname;
DWORD result;
static const WCHAR nameW[] = {'N','a','m','e',0};
if (pdwReserved || !pcbProvName)
{
......@@ -1524,7 +1480,7 @@ BOOL WINAPI CryptGetDefaultProviderW (DWORD dwProvType, DWORD *pdwReserved,
}
CRYPT_Free(keyname);
result = RegQueryValueExW(hKey, nameW, NULL, NULL, (LPBYTE)pszProvName, pcbProvName);
result = RegQueryValueExW(hKey, L"Name", NULL, NULL, (LPBYTE)pszProvName, pcbProvName);
RegCloseKey(hKey);
if (result)
......@@ -2057,7 +2013,6 @@ BOOL WINAPI CryptSetProviderExW (LPCWSTR pszProvName, DWORD dwProvType, DWORD *p
{
HKEY hProvKey, hTypeKey;
PWSTR keyname;
static const WCHAR nameW[] = {'N','a','m','e',0};
TRACE("(%s, %d, %p, %08x)\n", debugstr_w(pszProvName), dwProvType, pdwReserved, dwFlags);
......@@ -2094,7 +2049,7 @@ BOOL WINAPI CryptSetProviderExW (LPCWSTR pszProvName, DWORD dwProvType, DWORD *p
if (dwFlags & CRYPT_DELETE_DEFAULT)
{
RegDeleteValueW(hTypeKey, nameW);
RegDeleteValueW(hTypeKey, L"Name");
}
else
{
......@@ -2114,7 +2069,7 @@ BOOL WINAPI CryptSetProviderExW (LPCWSTR pszProvName, DWORD dwProvType, DWORD *p
}
CRYPT_Free(keyname);
if (RegSetValueExW(hTypeKey, nameW, 0, REG_SZ, (const BYTE *)pszProvName,
if (RegSetValueExW(hTypeKey, L"Name", 0, REG_SZ, (const BYTE *)pszProvName,
(lstrlenW(pszProvName) + 1)*sizeof(WCHAR)))
{
RegCloseKey(hTypeKey);
......
......@@ -69,19 +69,11 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
BYTE* ptr = NULL;
UNICODE_STRING* ustr;
static const WCHAR wVNETSUP[] = {
'S','y','s','t','e','m','\\',
'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
'S','e','r','v','i','c','e','s','\\',
'V','x','D','\\','V','N','E','T','S','U','P','\0'};
ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wVNETSUP, 0, KEY_READ, &key);
ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Services\\VxD\\VNETSUP", 0, KEY_READ, &key);
if (ret == ERROR_SUCCESS)
{
DWORD size = 0;
static const WCHAR wg[] = { 'W','o','r','k','g','r','o','u','p',0 };
ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size);
ret = RegQueryValueExW(key, L"Workgroup", NULL, NULL, NULL, &size);
if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
{
ptr = heap_alloc_zero(sz + size);
......@@ -89,7 +81,7 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
ustr = (UNICODE_STRING*)(ptr + ofs);
ustr->MaximumLength = size;
ustr->Buffer = (WCHAR*)(ptr + sz);
ret = RegQueryValueExW(key, wg, NULL, NULL, (LPBYTE)ustr->Buffer, &size);
ret = RegQueryValueExW(key, L"Workgroup", NULL, NULL, (LPBYTE)ustr->Buffer, &size);
if (ret != ERROR_SUCCESS)
{
heap_free(ptr);
......@@ -101,14 +93,13 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
}
if (!ptr)
{
static const WCHAR wDomain[] = {'D','O','M','A','I','N','\0'};
ptr = heap_alloc_zero(sz + sizeof(wDomain));
ptr = heap_alloc_zero(sz + sizeof(L"DOMAIN"));
if (!ptr) return NULL;
ustr = (UNICODE_STRING*)(ptr + ofs);
ustr->MaximumLength = sizeof(wDomain);
ustr->MaximumLength = sizeof(L"DOMAIN");
ustr->Buffer = (WCHAR*)(ptr + sz);
ustr->Length = sizeof(wDomain) - sizeof(WCHAR);
memcpy(ustr->Buffer, wDomain, sizeof(wDomain));
ustr->Length = sizeof(L"DOMAIN") - sizeof(WCHAR);
memcpy(ustr->Buffer, L"DOMAIN", sizeof(L"DOMAIN"));
}
return ptr;
}
......
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