Remove some Unicode->ANSI cross-calls in crypt functions.

This commit is contained in:
Vincent Béron 2005-09-28 11:59:04 +00:00 committed by Alexandre Julliard
parent fbecb0c319
commit bd6f176df9
2 changed files with 189 additions and 121 deletions

View File

@ -43,6 +43,7 @@
#include "winnls.h" #include "winnls.h"
#include "winreg.h" #include "winreg.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h"
#include "winternl.h" #include "winternl.h"
#include "ntstatus.h" #include "ntstatus.h"
@ -50,38 +51,56 @@ WINE_DEFAULT_DEBUG_CHANNEL(crypt);
HWND crypt_hWindow = 0; HWND crypt_hWindow = 0;
#define CRYPT_ReturnLastError(err) {SetLastError(err); return FALSE;} #define CRYPT_ReturnLastError(err) do {SetLastError(err); return FALSE;} while(0)
#define CRYPT_Alloc(size) ((LPVOID)LocalAlloc(LMEM_ZEROINIT, size)) #define CRYPT_Alloc(size) ((LPVOID)LocalAlloc(LMEM_ZEROINIT, size))
#define CRYPT_Free(buffer) (LocalFree((HLOCAL)buffer)) #define CRYPT_Free(buffer) (LocalFree((HLOCAL)buffer))
static inline PSTR CRYPT_GetProvKeyName(PCSTR pProvName) static inline PWSTR CRYPT_GetProvKeyName(PCWSTR pProvName)
{ {
PCSTR KEYSTR = "Software\\Microsoft\\Cryptography\\Defaults\\Provider\\"; static const WCHAR KEYSTR[] = {
PSTR keyname; '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
};
PWSTR keyname;
keyname = CRYPT_Alloc(strlen(KEYSTR) + strlen(pProvName) +1); keyname = CRYPT_Alloc((strlenW(KEYSTR) + strlenW(pProvName) +1)*sizeof(WCHAR));
if (keyname) if (keyname)
{ {
strcpy(keyname, KEYSTR); strcpyW(keyname, KEYSTR);
strcpy(keyname + strlen(KEYSTR), pProvName); strcpyW(keyname + strlenW(KEYSTR), pProvName);
} else } else
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return keyname; return keyname;
} }
static inline PSTR CRYPT_GetTypeKeyName(DWORD dwType, BOOL user) static inline PWSTR CRYPT_GetTypeKeyName(DWORD dwType, BOOL user)
{ {
PCSTR MACHINESTR = "Software\\Microsoft\\Cryptography\\Defaults\\Provider Types\\Type XXX"; static const WCHAR MACHINESTR[] = {
PCSTR USERSTR = "Software\\Microsoft\\Cryptography\\Provider Type XXX"; 'S','o','f','t','w','a','r','e','\\',
PSTR keyname; 'M','i','c','r','o','s','o','f','t','\\',
PSTR ptr; '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
};
PWSTR keyname;
PWSTR ptr;
keyname = CRYPT_Alloc( (user ? strlen(USERSTR) : strlen(MACHINESTR)) +1); keyname = CRYPT_Alloc( ((user ? strlenW(USERSTR) : strlenW(MACHINESTR)) +1)*sizeof(WCHAR));
if (keyname) if (keyname)
{ {
user ? strcpy(keyname, USERSTR) : strcpy(keyname, MACHINESTR); user ? strcpyW(keyname, USERSTR) : strcpyW(keyname, MACHINESTR);
ptr = keyname + strlen(keyname); ptr = keyname + strlenW(keyname);
*(--ptr) = (dwType % 10) + '0'; *(--ptr) = (dwType % 10) + '0';
*(--ptr) = ((dwType / 10) % 10) + '0'; *(--ptr) = ((dwType / 10) % 10) + '0';
*(--ptr) = (dwType / 100) + '0'; *(--ptr) = (dwType / 100) + '0';
@ -175,7 +194,7 @@ static BOOL CALLBACK CRYPT_ReturnhWnd(HWND *phWnd)
if ( !(provider->pFuncs->p##name = (void*)GetProcAddress(provider->hModule, #name)) ) goto error if ( !(provider->pFuncs->p##name = (void*)GetProcAddress(provider->hModule, #name)) ) goto error
#define CRYPT_GetProvFuncOpt(name) \ #define CRYPT_GetProvFuncOpt(name) \
provider->pFuncs->p##name = (void*)GetProcAddress(provider->hModule, #name) provider->pFuncs->p##name = (void*)GetProcAddress(provider->hModule, #name)
static PCRYPTPROV CRYPT_LoadProvider(PSTR pImage) static PCRYPTPROV CRYPT_LoadProvider(PWSTR pImage)
{ {
PCRYPTPROV provider; PCRYPTPROV provider;
DWORD errorcode = ERROR_NOT_ENOUGH_MEMORY; DWORD errorcode = ERROR_NOT_ENOUGH_MEMORY;
@ -183,10 +202,10 @@ static PCRYPTPROV CRYPT_LoadProvider(PSTR pImage)
if ( !(provider = CRYPT_Alloc(sizeof(CRYPTPROV))) ) goto error; if ( !(provider = CRYPT_Alloc(sizeof(CRYPTPROV))) ) goto error;
if ( !(provider->pFuncs = CRYPT_Alloc(sizeof(PROVFUNCS))) ) goto error; if ( !(provider->pFuncs = CRYPT_Alloc(sizeof(PROVFUNCS))) ) goto error;
if ( !(provider->pVTable = CRYPT_Alloc(sizeof(VTableProvStruc))) ) goto error; if ( !(provider->pVTable = CRYPT_Alloc(sizeof(VTableProvStruc))) ) goto error;
if ( !(provider->hModule = LoadLibraryA(pImage)) ) if ( !(provider->hModule = LoadLibraryW(pImage)) )
{ {
errorcode = (GetLastError() == ERROR_FILE_NOT_FOUND) ? NTE_PROV_DLL_NOT_FOUND : NTE_PROVIDER_DLL_FAIL; errorcode = (GetLastError() == ERROR_FILE_NOT_FOUND) ? NTE_PROV_DLL_NOT_FOUND : NTE_PROVIDER_DLL_FAIL;
FIXME("Failed to load dll %s\n", debugstr_a(pImage)); FIXME("Failed to load dll %s\n", debugstr_w(pImage));
goto error; goto error;
} }
provider->dwMagic = MAGIC_CRYPTPROV; provider->dwMagic = MAGIC_CRYPTPROV;
@ -249,7 +268,7 @@ error:
/****************************************************************************** /******************************************************************************
* CryptAcquireContextA (ADVAPI32.@) * CryptAcquireContextW (ADVAPI32.@)
* Acquire a crypto provider context handle. * Acquire a crypto provider context handle.
* *
* PARAMS * PARAMS
@ -261,17 +280,21 @@ error:
* *
* RETURNS TRUE on success, FALSE on failure. * RETURNS TRUE on success, FALSE on failure.
*/ */
BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer, BOOL WINAPI CryptAcquireContextW (HCRYPTPROV *phProv, LPCWSTR pszContainer,
LPCSTR pszProvider, DWORD dwProvType, DWORD dwFlags) LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
{ {
PCRYPTPROV pProv = NULL; PCRYPTPROV pProv = NULL;
HKEY key; HKEY key;
PSTR imagepath = NULL, keyname = NULL, provname = NULL, temp = NULL; PWSTR imagepath = NULL, keyname = NULL, provname = NULL, temp = NULL;
PSTR provnameA = NULL, pszContainerA = NULL;
DWORD keytype, type, len; DWORD keytype, type, len;
ULONG r; 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, %ld, %08lx)\n", phProv, pszContainer, TRACE("(%p, %s, %s, %ld, %08lx)\n", phProv, debugstr_w(pszContainer),
pszProvider, dwProvType, dwFlags); debugstr_w(pszProvider), dwProvType, dwFlags);
if (dwProvType < 1 || dwProvType > MAXPROVTYPES) if (dwProvType < 1 || dwProvType > MAXPROVTYPES)
{ {
@ -295,7 +318,7 @@ BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
SetLastError(NTE_PROV_TYPE_NOT_DEF); SetLastError(NTE_PROV_TYPE_NOT_DEF);
return FALSE; return FALSE;
} }
if (RegOpenKeyA(HKEY_CURRENT_USER, keyname, &key)) if (RegOpenKeyW(HKEY_CURRENT_USER, keyname, &key))
{ {
CRYPT_Free(keyname); CRYPT_Free(keyname);
if ( !(keyname = CRYPT_GetTypeKeyName(dwProvType, FALSE)) ) { if ( !(keyname = CRYPT_GetTypeKeyName(dwProvType, FALSE)) ) {
@ -304,8 +327,8 @@ BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
SetLastError(NTE_PROV_TYPE_NOT_DEF); SetLastError(NTE_PROV_TYPE_NOT_DEF);
goto error; goto error;
} }
if (RegOpenKeyA(HKEY_LOCAL_MACHINE, keyname, &key)) { if (RegOpenKeyW(HKEY_LOCAL_MACHINE, keyname, &key)) {
TRACE("Did not find registry entry of crypto provider for %s.\n", debugstr_a(keyname)); TRACE("Did not find registry entry of crypto provider for %s.\n", debugstr_w(keyname));
CRYPT_Free(keyname); CRYPT_Free(keyname);
RegCloseKey(key); RegCloseKey(key);
SetLastError(NTE_PROV_TYPE_NOT_DEF); SetLastError(NTE_PROV_TYPE_NOT_DEF);
@ -313,7 +336,7 @@ BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
} }
} }
CRYPT_Free(keyname); CRYPT_Free(keyname);
r = RegQueryValueExA(key, "Name", NULL, &keytype, NULL, &len); r = RegQueryValueExW(key, nameW, NULL, &keytype, NULL, &len);
if( r != ERROR_SUCCESS || !len || keytype != REG_SZ) if( r != ERROR_SUCCESS || !len || keytype != REG_SZ)
{ {
TRACE("error %ld reading size of 'Name' from registry\n", r ); TRACE("error %ld reading size of 'Name' from registry\n", r );
@ -327,7 +350,7 @@ BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto error; goto error;
} }
r = RegQueryValueExA(key, "Name", NULL, NULL, (LPBYTE)provname, &len); r = RegQueryValueExW(key, nameW, NULL, NULL, (LPBYTE)provname, &len);
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS )
{ {
TRACE("error %ld reading 'Name' from registry\n", r ); TRACE("error %ld reading 'Name' from registry\n", r );
@ -337,16 +360,16 @@ BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
} }
RegCloseKey(key); RegCloseKey(key);
} else { } else {
if ( !(provname = CRYPT_Alloc(strlen(pszProvider) +1)) ) if ( !(provname = CRYPT_Alloc((strlenW(pszProvider) +1)*sizeof(WCHAR))) )
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto error; goto error;
} }
strcpy(provname, pszProvider); strcpyW(provname, pszProvider);
} }
keyname = CRYPT_GetProvKeyName(provname); keyname = CRYPT_GetProvKeyName(provname);
r = RegOpenKeyA(HKEY_LOCAL_MACHINE, keyname, &key); r = RegOpenKeyW(HKEY_LOCAL_MACHINE, keyname, &key);
CRYPT_Free(keyname); CRYPT_Free(keyname);
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
{ {
@ -354,7 +377,7 @@ BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
goto error; goto error;
} }
len = sizeof(DWORD); len = sizeof(DWORD);
r = RegQueryValueExA(key, "Type", NULL, NULL, (BYTE*)&type, &len); r = RegQueryValueExW(key, typeW, NULL, NULL, (BYTE*)&type, &len);
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
{ {
SetLastError(NTE_PROV_TYPE_ENTRY_BAD); SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
@ -367,7 +390,7 @@ BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
goto error; goto error;
} }
r = RegQueryValueExA(key, "Image Path", NULL, &keytype, NULL, &len); r = RegQueryValueExW(key, imagepathW, NULL, &keytype, NULL, &len);
if ( r != ERROR_SUCCESS || keytype != REG_SZ) if ( r != ERROR_SUCCESS || keytype != REG_SZ)
{ {
TRACE("error %ld reading size of 'Image Path' from registry\n", r ); TRACE("error %ld reading size of 'Image Path' from registry\n", r );
@ -381,7 +404,7 @@ BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto error; goto error;
} }
r = RegQueryValueExA(key, "Image Path", NULL, NULL, (LPBYTE)temp, &len); r = RegQueryValueExW(key, imagepathW, NULL, NULL, (LPBYTE)temp, &len);
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS )
{ {
TRACE("error %ld reading 'Image Path' from registry\n", r ); TRACE("error %ld reading 'Image Path' from registry\n", r );
@ -390,13 +413,13 @@ BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
goto error; goto error;
} }
RegCloseKey(key); RegCloseKey(key);
len = ExpandEnvironmentStringsA(temp, NULL, 0); len = ExpandEnvironmentStringsW(temp, NULL, 0);
if ( !(imagepath = CRYPT_Alloc(len)) ) if ( !(imagepath = CRYPT_Alloc(len*sizeof(WCHAR))) )
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto error; goto error;
} }
if (!ExpandEnvironmentStringsA(temp, imagepath, len)) if (!ExpandEnvironmentStringsW(temp, imagepath, len))
{ {
/* ExpandEnvironmentStrings will call SetLastError */ /* ExpandEnvironmentStrings will call SetLastError */
goto error; goto error;
@ -407,8 +430,18 @@ BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
goto error; goto error;
} }
pProv->pVTable->dwProvType = dwProvType; pProv->pVTable->dwProvType = dwProvType;
pProv->pVTable->pszProvName = provname; if(!CRYPT_UnicodeToANSI(provname, &provnameA, -1))
if (pProv->pFuncs->pCPAcquireContext(&pProv->hPrivate, (CHAR*)pszContainer, dwFlags, pProv->pVTable)) {
/* CRYPT_UnicodeToANSI calls SetLastError */
goto error;
}
pProv->pVTable->pszProvName = provnameA;
if(!CRYPT_UnicodeToANSI(pszContainer, &pszContainerA, -1))
{
/* CRYPT_UnicodeToANSI calls SetLastError */
goto error;
}
if (pProv->pFuncs->pCPAcquireContext(&pProv->hPrivate, pszContainerA, dwFlags, pProv->pVTable))
{ {
/* MSDN: When this flag is set, the value returned in phProv is undefined, /* MSDN: When this flag is set, the value returned in phProv is undefined,
* and thus, the CryptReleaseContext function need not be called afterwards. * and thus, the CryptReleaseContext function need not be called afterwards.
@ -418,12 +451,15 @@ BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
{ {
pProv->dwMagic = 0; pProv->dwMagic = 0;
FreeLibrary(pProv->hModule); FreeLibrary(pProv->hModule);
CRYPT_Free(provname); CRYPT_Free(provnameA);
CRYPT_Free(pProv->pVTable);
CRYPT_Free(pProv->pFuncs); CRYPT_Free(pProv->pFuncs);
CRYPT_Free(pProv); CRYPT_Free(pProv);
} else { } else {
*phProv = (HCRYPTPROV)pProv; *phProv = (HCRYPTPROV)pProv;
} }
CRYPT_Free(pszContainerA);
CRYPT_Free(provname);
CRYPT_Free(temp); CRYPT_Free(temp);
CRYPT_Free(imagepath); CRYPT_Free(imagepath);
return TRUE; return TRUE;
@ -441,6 +477,10 @@ error:
CRYPT_Free(pProv->pFuncs); CRYPT_Free(pProv->pFuncs);
CRYPT_Free(pProv); CRYPT_Free(pProv);
} }
if (pszContainerA)
CRYPT_Free(pszContainerA);
if (provnameA)
CRYPT_Free(provnameA);
if (provname) if (provname)
CRYPT_Free(provname); CRYPT_Free(provname);
if (temp) if (temp)
@ -451,28 +491,28 @@ error:
} }
/****************************************************************************** /******************************************************************************
* CryptAcquireContextW (ADVAPI32.@) * CryptAcquireContextA (ADVAPI32.@)
* *
* see CryptAcquireContextA * see CryptAcquireContextW
*/ */
BOOL WINAPI CryptAcquireContextW (HCRYPTPROV *phProv, LPCWSTR pszContainer, BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags) LPCSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
{ {
PSTR pProvider = NULL, pContainer = NULL; PWSTR pProvider = NULL, pContainer = NULL;
BOOL ret = FALSE; BOOL ret = FALSE;
TRACE("(%p, %s, %s, %ld, %08lx)\n", phProv, debugstr_w(pszContainer), TRACE("(%p, %s, %s, %ld, %08lx)\n", phProv, pszContainer,
debugstr_w(pszProvider), dwProvType, dwFlags); pszProvider, dwProvType, dwFlags);
if ( !CRYPT_UnicodeToANSI(pszContainer, &pContainer, -1) ) if ( !CRYPT_ANSIToUnicode(pszContainer, &pContainer, -1) )
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY); CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
if ( !CRYPT_UnicodeToANSI(pszProvider, &pProvider, -1) ) if ( !CRYPT_ANSIToUnicode(pszProvider, &pProvider, -1) )
{ {
CRYPT_Free(pContainer); CRYPT_Free(pContainer);
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY); CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
} }
ret = CryptAcquireContextA(phProv, pContainer, pProvider, dwProvType, dwFlags); ret = CryptAcquireContextW(phProv, pContainer, pProvider, dwProvType, dwFlags);
if (pContainer) if (pContainer)
CRYPT_Free(pContainer); CRYPT_Free(pContainer);
@ -955,7 +995,6 @@ BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved,
DWORD dwFlags, DWORD *pdwProvType, LPWSTR pszProvName, DWORD *pcbProvName) DWORD dwFlags, DWORD *pdwProvType, LPWSTR pszProvName, DWORD *pcbProvName)
{ {
HKEY hKey; HKEY hKey;
static const WCHAR providerW[] = { static const WCHAR providerW[] = {
'S','o','f','t','w','a','r','e','\\', 'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\', 'M','i','c','r','o','s','o','f','t','\\',
@ -963,7 +1002,6 @@ BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved,
'D','e','f','a','u','l','t','s','\\', 'D','e','f','a','u','l','t','s','\\',
'P','r','o','v','i','d','e','r',0 'P','r','o','v','i','d','e','r',0
}; };
static const WCHAR typeW[] = {'T','y','p','e',0}; static const WCHAR typeW[] = {'T','y','p','e',0};
TRACE("(%ld, %p, %ld, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags, TRACE("(%ld, %p, %ld, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
@ -987,11 +1025,10 @@ BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved,
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY); CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
RegEnumKeyExW(hKey, dwIndex, provNameW, pcbProvName, NULL, NULL, NULL, NULL); RegEnumKeyExW(hKey, dwIndex, provNameW, pcbProvName, NULL, NULL, NULL, NULL);
CRYPT_Free(provNameW);
(*pcbProvName)++; (*pcbProvName)++;
*pcbProvName *= sizeof(WCHAR); *pcbProvName *= sizeof(WCHAR);
CRYPT_Free(provNameW);
if (dwIndex >= numkeys) if (dwIndex >= numkeys)
CRYPT_ReturnLastError(ERROR_NO_MORE_ITEMS); CRYPT_ReturnLastError(ERROR_NO_MORE_ITEMS);
} else { } else {
@ -1027,21 +1064,24 @@ BOOL WINAPI CryptEnumProvidersA (DWORD dwIndex, DWORD *pdwReserved,
TRACE("(%ld, %p, %08lx, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags, TRACE("(%ld, %p, %08lx, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
pdwProvType, pszProvName, pcbProvName); pdwProvType, pszProvName, pcbProvName);
strlen = *pcbProvName * sizeof(WCHAR); CryptEnumProvidersW(dwIndex, pdwReserved, dwFlags, pdwProvType, NULL, &strlen);
if ( pszProvName && !(str = CRYPT_Alloc(strlen)) ) if ( pszProvName && !(str = CRYPT_Alloc(strlen)) )
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY); CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
ret = CryptEnumProvidersW(dwIndex, pdwReserved, dwFlags, pdwProvType, str, &strlen); ret = CryptEnumProvidersW(dwIndex, pdwReserved, dwFlags, pdwProvType, str, &strlen);
if (str) if (str)
{
CRYPT_UnicodeToANSI(str, &pszProvName, *pcbProvName); CRYPT_UnicodeToANSI(str, &pszProvName, *pcbProvName);
CRYPT_Free(str);
}
*pcbProvName = strlen / sizeof(WCHAR); /* FIXME: not correct */ *pcbProvName = strlen / sizeof(WCHAR); /* FIXME: not correct */
if (str)
{
CRYPT_Free(str);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
CRYPT_ReturnLastError(ERROR_MORE_DATA);
}
return ret; return ret;
} }
/****************************************************************************** /******************************************************************************
* CryptEnumProviderTypesA (ADVAPI32i.@) * CryptEnumProviderTypesW (ADVAPI32i.@)
* *
* Retrieves the next type of CSP supported. * Retrieves the next type of CSP supported.
* *
@ -1059,16 +1099,24 @@ BOOL WINAPI CryptEnumProvidersA (DWORD dwIndex, DWORD *pdwReserved,
* Failure: FALSE * Failure: FALSE
* *
* NOTES * NOTES
* If pszTypeName is NULL, CryptEnumProviderTypesA sets the size of the name * If pszTypeName is NULL, CryptEnumProviderTypesW sets the size of the name
* for memory allocation purposes. * for memory allocation purposes.
*/ */
BOOL WINAPI CryptEnumProviderTypesA (DWORD dwIndex, DWORD *pdwReserved, BOOL WINAPI CryptEnumProviderTypesW (DWORD dwIndex, DWORD *pdwReserved,
DWORD dwFlags, DWORD *pdwProvType, LPSTR pszTypeName, DWORD *pcbTypeName) DWORD dwFlags, DWORD *pdwProvType, LPWSTR pszTypeName, DWORD *pcbTypeName)
{ {
HKEY hKey, hSubkey; HKEY hKey, hSubkey;
DWORD keylen, numkeys, dwType; DWORD keylen, numkeys, dwType;
PSTR keyname, ch; PWSTR keyname, ch;
DWORD result; 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("(%ld, %p, %08lx, %p, %p, %p)\n", dwIndex, pdwReserved, TRACE("(%ld, %p, %08lx, %p, %p, %p)\n", dwIndex, pdwReserved,
dwFlags, pdwProvType, pszTypeName, pcbTypeName); dwFlags, pdwProvType, pszTypeName, pcbTypeName);
@ -1077,28 +1125,28 @@ BOOL WINAPI CryptEnumProviderTypesA (DWORD dwIndex, DWORD *pdwReserved,
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER); CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
if (dwFlags) CRYPT_ReturnLastError(NTE_BAD_FLAGS); if (dwFlags) CRYPT_ReturnLastError(NTE_BAD_FLAGS);
if (RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\Defaults\\Provider Types", &hKey)) if (RegOpenKeyW(HKEY_LOCAL_MACHINE, KEYSTR, &hKey))
return FALSE; return FALSE;
RegQueryInfoKeyA(hKey, NULL, NULL, NULL, &numkeys, &keylen, NULL, NULL, NULL, NULL, NULL, NULL); RegQueryInfoKeyW(hKey, NULL, NULL, NULL, &numkeys, &keylen, NULL, NULL, NULL, NULL, NULL, NULL);
if (dwIndex >= numkeys) if (dwIndex >= numkeys)
CRYPT_ReturnLastError(ERROR_NO_MORE_ITEMS); CRYPT_ReturnLastError(ERROR_NO_MORE_ITEMS);
keylen++; keylen++;
if ( !(keyname = CRYPT_Alloc(keylen)) ) if ( !(keyname = CRYPT_Alloc(keylen*sizeof(WCHAR))) )
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY); CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
if ( RegEnumKeyA(hKey, dwIndex, keyname, keylen) ) { if ( RegEnumKeyW(hKey, dwIndex, keyname, keylen) ) {
CRYPT_Free(keyname); CRYPT_Free(keyname);
return FALSE; return FALSE;
} }
RegOpenKeyA(hKey, keyname, &hSubkey); RegOpenKeyW(hKey, keyname, &hSubkey);
ch = keyname + strlen(keyname); ch = keyname + strlenW(keyname);
/* Convert "Type 000" to 0, etc/ */ /* Convert "Type 000" to 0, etc/ */
*pdwProvType = *(--ch) - '0'; *pdwProvType = *(--ch) - '0';
*pdwProvType += (*(--ch) - '0') * 10; *pdwProvType += (*(--ch) - '0') * 10;
*pdwProvType += (*(--ch) - '0') * 100; *pdwProvType += (*(--ch) - '0') * 100;
CRYPT_Free(keyname); CRYPT_Free(keyname);
result = RegQueryValueExA(hSubkey, "TypeName", NULL, &dwType, (LPBYTE)pszTypeName, pcbTypeName); result = RegQueryValueExW(hSubkey, typenameW, NULL, &dwType, (LPBYTE)pszTypeName, pcbTypeName);
if (result) if (result)
CRYPT_ReturnLastError(result); CRYPT_ReturnLastError(result);
@ -1108,29 +1156,33 @@ BOOL WINAPI CryptEnumProviderTypesA (DWORD dwIndex, DWORD *pdwReserved,
} }
/****************************************************************************** /******************************************************************************
* CryptEnumProviderTypesW (ADVAPI32.@) * CryptEnumProviderTypesA (ADVAPI32.@)
* *
* see CryptEnumProviderTypesA * see CryptEnumProviderTypesW
*/ */
BOOL WINAPI CryptEnumProviderTypesW (DWORD dwIndex, DWORD *pdwReserved, BOOL WINAPI CryptEnumProviderTypesA (DWORD dwIndex, DWORD *pdwReserved,
DWORD dwFlags, DWORD *pdwProvType, LPWSTR pszTypeName, DWORD *pcbTypeName) DWORD dwFlags, DWORD *pdwProvType, LPSTR pszTypeName, DWORD *pcbTypeName)
{ {
PSTR str = NULL; PWSTR str = NULL;
DWORD strlen; DWORD strlen;
BOOL ret; BOOL ret;
TRACE("(%ld, %p, %08lx, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags, TRACE("(%ld, %p, %08lx, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
pdwProvType, pszTypeName, pcbTypeName); pdwProvType, pszTypeName, pcbTypeName);
strlen = *pcbTypeName / sizeof(WCHAR);
CryptEnumProviderTypesW(dwIndex, pdwReserved, dwFlags, pdwProvType, NULL, &strlen);
if ( pszTypeName && !(str = CRYPT_Alloc(strlen)) ) if ( pszTypeName && !(str = CRYPT_Alloc(strlen)) )
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY); CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
ret = CryptEnumProviderTypesA(dwIndex, pdwReserved, dwFlags, pdwProvType, str, &strlen); ret = CryptEnumProviderTypesW(dwIndex, pdwReserved, dwFlags, pdwProvType, str, &strlen);
if (str)
CRYPT_UnicodeToANSI(str, &pszTypeName, *pcbTypeName);
*pcbTypeName = strlen / sizeof(WCHAR);
if (str) if (str)
{ {
CRYPT_ANSIToUnicode(str, &pszTypeName, *pcbTypeName);
CRYPT_Free(str); CRYPT_Free(str);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
CRYPT_ReturnLastError(ERROR_MORE_DATA);
} }
*pcbTypeName = strlen * sizeof(WCHAR);
return ret; return ret;
} }
@ -1214,7 +1266,7 @@ BOOL WINAPI CryptGenKey (HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYPTKE
} }
/****************************************************************************** /******************************************************************************
* CryptGetDefaultProviderA (ADVAPI32.@) * CryptGetDefaultProviderW (ADVAPI32.@)
* *
* Finds the default CSP of a certain provider type. * Finds the default CSP of a certain provider type.
* *
@ -1233,12 +1285,13 @@ BOOL WINAPI CryptGenKey (HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYPTKE
* If pszProvName is NULL, pcbProvName will hold the size of the buffer for * If pszProvName is NULL, pcbProvName will hold the size of the buffer for
* memory allocation purposes on return. * memory allocation purposes on return.
*/ */
BOOL WINAPI CryptGetDefaultProviderA (DWORD dwProvType, DWORD *pdwReserved, BOOL WINAPI CryptGetDefaultProviderW (DWORD dwProvType, DWORD *pdwReserved,
DWORD dwFlags, LPSTR pszProvName, DWORD *pcbProvName) DWORD dwFlags, LPWSTR pszProvName, DWORD *pcbProvName)
{ {
HKEY hKey; HKEY hKey;
PSTR keyname; PWSTR keyname;
DWORD result; DWORD result;
static const WCHAR nameW[] = {'N','a','m','e',0};
if (pdwReserved || !pcbProvName) if (pdwReserved || !pcbProvName)
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER); CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
@ -1248,14 +1301,14 @@ BOOL WINAPI CryptGetDefaultProviderA (DWORD dwProvType, DWORD *pdwReserved,
CRYPT_ReturnLastError(NTE_BAD_PROV_TYPE); CRYPT_ReturnLastError(NTE_BAD_PROV_TYPE);
if ( !(keyname = CRYPT_GetTypeKeyName(dwProvType, dwFlags & CRYPT_USER_DEFAULT)) ) if ( !(keyname = CRYPT_GetTypeKeyName(dwProvType, dwFlags & CRYPT_USER_DEFAULT)) )
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY); CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
if (RegOpenKeyA((dwFlags & CRYPT_USER_DEFAULT) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE ,keyname, &hKey)) if (RegOpenKeyW((dwFlags & CRYPT_USER_DEFAULT) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE ,keyname, &hKey))
{ {
CRYPT_Free(keyname); CRYPT_Free(keyname);
CRYPT_ReturnLastError(NTE_PROV_TYPE_NOT_DEF); CRYPT_ReturnLastError(NTE_PROV_TYPE_NOT_DEF);
} }
CRYPT_Free(keyname); CRYPT_Free(keyname);
result = RegQueryValueExA(hKey, "Name", NULL, NULL, (LPBYTE)pszProvName, pcbProvName); result = RegQueryValueExW(hKey, nameW, NULL, NULL, (LPBYTE)pszProvName, pcbProvName);
if (result) if (result)
{ {
if (result != ERROR_MORE_DATA) if (result != ERROR_MORE_DATA)
@ -1271,29 +1324,32 @@ BOOL WINAPI CryptGetDefaultProviderA (DWORD dwProvType, DWORD *pdwReserved,
} }
/****************************************************************************** /******************************************************************************
* CryptGetDefaultProviderW (ADVAPI32.@) * CryptGetDefaultProviderA (ADVAPI32.@)
* *
* see CryptGetDefaultProviderA * see CryptGetDefaultProviderW
*/ */
BOOL WINAPI CryptGetDefaultProviderW (DWORD dwProvType, DWORD *pdwReserved, BOOL WINAPI CryptGetDefaultProviderA (DWORD dwProvType, DWORD *pdwReserved,
DWORD dwFlags, LPWSTR pszProvName, DWORD *pcbProvName) DWORD dwFlags, LPSTR pszProvName, DWORD *pcbProvName)
{ {
PSTR str = NULL; PWSTR str = NULL;
DWORD strlen; DWORD strlen;
BOOL ret = FALSE; BOOL ret = FALSE;
TRACE("(%ld, %p, %08lx, %p, %p)\n", dwProvType, pdwReserved, dwFlags, pszProvName, pcbProvName); TRACE("(%ld, %p, %08lx, %p, %p)\n", dwProvType, pdwReserved, dwFlags, pszProvName, pcbProvName);
strlen = *pcbProvName / sizeof(WCHAR); CryptGetDefaultProviderW(dwProvType, pdwReserved, dwFlags, NULL, &strlen);
if ( pszProvName && !(str = CRYPT_Alloc(strlen)) ) if ( pszProvName && !(str = CRYPT_Alloc(strlen)) )
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY); CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
ret = CryptGetDefaultProviderA(dwProvType, pdwReserved, dwFlags, str, &strlen); ret = CryptGetDefaultProviderW(dwProvType, pdwReserved, dwFlags, str, &strlen);
if (str)
CRYPT_UnicodeToANSI(str, &pszProvName, *pcbProvName);
*pcbProvName = strlen / sizeof(WCHAR);
if (str) if (str)
{ {
CRYPT_ANSIToUnicode(str, &pszProvName, *pcbProvName);
CRYPT_Free(str); CRYPT_Free(str);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
CRYPT_ReturnLastError(ERROR_MORE_DATA);
} }
*pcbProvName = strlen * sizeof(WCHAR);
return ret; return ret;
} }
@ -1696,7 +1752,7 @@ BOOL WINAPI CryptSetProviderW (LPCWSTR pszProvName, DWORD dwProvType)
} }
/****************************************************************************** /******************************************************************************
* CryptSetProviderExA (ADVAPI32.@) * CryptSetProviderExW (ADVAPI32.@)
* *
* Specifies the default CSP. * Specifies the default CSP.
* *
@ -1710,12 +1766,13 @@ BOOL WINAPI CryptSetProviderW (LPCWSTR pszProvName, DWORD dwProvType)
* Success: TRUE * Success: TRUE
* Failure: FALSE * Failure: FALSE
*/ */
BOOL WINAPI CryptSetProviderExA (LPCSTR pszProvName, DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags) BOOL WINAPI CryptSetProviderExW (LPCWSTR pszProvName, DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags)
{ {
HKEY hProvKey, hTypeKey; HKEY hProvKey, hTypeKey;
PSTR keyname; PWSTR keyname;
static const WCHAR nameW[] = {'N','a','m','e',0};
TRACE("(%s, %ld, %p, %08lx)\n", pszProvName, dwProvType, pdwReserved, dwFlags); TRACE("(%s, %ld, %p, %08lx)\n", debugstr_w(pszProvName), dwProvType, pdwReserved, dwFlags);
if (!pszProvName || pdwReserved) if (!pszProvName || pdwReserved)
CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER); CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER);
@ -1727,7 +1784,7 @@ BOOL WINAPI CryptSetProviderExA (LPCSTR pszProvName, DWORD dwProvType, DWORD *pd
if (!(keyname = CRYPT_GetTypeKeyName(dwProvType, dwFlags & CRYPT_USER_DEFAULT))) if (!(keyname = CRYPT_GetTypeKeyName(dwProvType, dwFlags & CRYPT_USER_DEFAULT)))
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY); CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
if (RegOpenKeyA((dwFlags & CRYPT_USER_DEFAULT) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, if (RegOpenKeyW((dwFlags & CRYPT_USER_DEFAULT) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
keyname, &hTypeKey)) keyname, &hTypeKey))
{ {
CRYPT_Free(keyname); CRYPT_Free(keyname);
@ -1737,7 +1794,7 @@ BOOL WINAPI CryptSetProviderExA (LPCSTR pszProvName, DWORD dwProvType, DWORD *pd
if (dwFlags & CRYPT_DELETE_DEFAULT) if (dwFlags & CRYPT_DELETE_DEFAULT)
{ {
RegDeleteValueA(hTypeKey, "Name"); RegDeleteValueW(hTypeKey, nameW);
} }
else else
{ {
@ -1746,7 +1803,7 @@ BOOL WINAPI CryptSetProviderExA (LPCSTR pszProvName, DWORD dwProvType, DWORD *pd
RegCloseKey(hTypeKey); RegCloseKey(hTypeKey);
CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY); CRYPT_ReturnLastError(ERROR_NOT_ENOUGH_MEMORY);
} }
if (RegOpenKeyA((dwFlags & CRYPT_USER_DEFAULT) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, if (RegOpenKeyW((dwFlags & CRYPT_USER_DEFAULT) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
keyname, &hProvKey)) keyname, &hProvKey))
{ {
CRYPT_Free(keyname); CRYPT_Free(keyname);
@ -1755,7 +1812,7 @@ BOOL WINAPI CryptSetProviderExA (LPCSTR pszProvName, DWORD dwProvType, DWORD *pd
} }
CRYPT_Free(keyname); CRYPT_Free(keyname);
if (RegSetValueExA(hTypeKey, "Name", 0, REG_SZ, (LPBYTE)pszProvName, strlen(pszProvName) + 1)) if (RegSetValueExW(hTypeKey, nameW, 0, REG_SZ, (LPBYTE)pszProvName, (strlenW(pszProvName) + 1)*sizeof(WCHAR)))
{ {
RegCloseKey(hTypeKey); RegCloseKey(hTypeKey);
RegCloseKey(hProvKey); RegCloseKey(hProvKey);
@ -1770,20 +1827,20 @@ BOOL WINAPI CryptSetProviderExA (LPCSTR pszProvName, DWORD dwProvType, DWORD *pd
} }
/****************************************************************************** /******************************************************************************
* CryptSetProviderExW (ADVAPI32.@) * CryptSetProviderExA (ADVAPI32.@)
* *
* See CryptSetProviderExA * See CryptSetProviderExW
*/ */
BOOL WINAPI CryptSetProviderExW (LPCWSTR pszProvName, DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags) BOOL WINAPI CryptSetProviderExA (LPCSTR pszProvName, DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags)
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
PSTR str = NULL; PWSTR str = NULL;
TRACE("(%s, %ld, %p, %08lx)\n", debugstr_w(pszProvName), dwProvType, pdwReserved, dwFlags); TRACE("(%s, %ld, %p, %08lx)\n", pszProvName, dwProvType, pdwReserved, dwFlags);
if (CRYPT_UnicodeToANSI(pszProvName, &str, -1)) if (CRYPT_ANSIToUnicode(pszProvName, &str, -1))
{ {
ret = CryptSetProviderExA(str, dwProvType, pdwReserved, dwFlags); ret = CryptSetProviderExW(str, dwProvType, pdwReserved, dwFlags);
CRYPT_Free(str); CRYPT_Free(str);
} }
return ret; return ret;

View File

@ -384,7 +384,7 @@ static void test_enum_providers(void)
DWORD providerLen; DWORD providerLen;
DWORD type; DWORD type;
DWORD count; DWORD count;
BOOL result; DWORD result;
DWORD notNull = 5; DWORD notNull = 5;
DWORD notZeroFlags = 5; DWORD notZeroFlags = 5;
@ -395,7 +395,10 @@ static void test_enum_providers(void)
} }
if (!FindProvRegVals(dwIndex, &dwType, &pszProvName, &cbName, &provCount)) if (!FindProvRegVals(dwIndex, &dwType, &pszProvName, &cbName, &provCount))
{
trace("could not find providers in registry, skipping the test\n");
return; return;
}
/* check pdwReserved flag for NULL */ /* check pdwReserved flag for NULL */
result = pCryptEnumProvidersA(dwIndex, &notNull, 0, &type, NULL, &providerLen); result = pCryptEnumProvidersA(dwIndex, &notNull, 0, &type, NULL, &providerLen);
@ -439,12 +442,13 @@ static void test_enum_providers(void)
if (!(provider = ((LPSTR)LocalAlloc(LMEM_ZEROINIT, providerLen)))) if (!(provider = ((LPSTR)LocalAlloc(LMEM_ZEROINIT, providerLen))))
return; return;
providerLen = 0xdeadbeef;
result = pCryptEnumProvidersA(dwIndex, NULL, 0, &type, provider, &providerLen); result = pCryptEnumProvidersA(dwIndex, NULL, 0, &type, provider, &providerLen);
ok(result && type==dwType, "expected %ld, got %ld\n", ok(result, "expected TRUE, got %ld\n", result);
dwType, type); ok(type==dwType, "expected %ld, got %ld\n", dwType, type);
ok(result && !strcmp(pszProvName, provider), "expected %s, got %s\n", pszProvName, provider); if (pszProvName)
ok(result && cbName==providerLen, "expected %ld, got %ld\n", ok(!strcmp(pszProvName, provider), "expected %s, got %s\n", pszProvName, provider);
cbName, providerLen); ok(cbName==providerLen, "expected %ld, got %ld\n", cbName, providerLen);
LocalFree(provider); LocalFree(provider);
} }
@ -656,7 +660,11 @@ static void test_get_default_provider(void)
return; return;
} }
FindDfltProvRegVals(dwProvType, dwFlags, &pszProvName, &cbProvName); if(!FindDfltProvRegVals(dwProvType, dwFlags, &pszProvName, &cbProvName))
{
trace("could not find default provider in registry, skipping the test\n");
return;
}
/* check pdwReserved for NULL */ /* check pdwReserved for NULL */
result = pCryptGetDefaultProviderA(provType, &notNull, flags, provName, &provNameSize); result = pCryptGetDefaultProviderA(provType, &notNull, flags, provName, &provNameSize);
@ -701,9 +709,12 @@ static void test_get_default_provider(void)
if (!(provName = LocalAlloc(LMEM_ZEROINIT, provNameSize))) if (!(provName = LocalAlloc(LMEM_ZEROINIT, provNameSize)))
return; return;
provNameSize = 0xdeadbeef;
result = pCryptGetDefaultProviderA(provType, NULL, flags, provName, &provNameSize); result = pCryptGetDefaultProviderA(provType, NULL, flags, provName, &provNameSize);
ok(result && !strcmp(pszProvName, provName), "expected %s, got %s\n", pszProvName, provName); ok(result, "expected TRUE, got %ld\n", result);
ok(result && provNameSize==cbProvName, "expected %ld, got %ld\n", cbProvName, provNameSize); if(pszProvName)
ok(!strcmp(pszProvName, provName), "expected %s, got %s\n", pszProvName, provName);
ok(provNameSize==cbProvName, "expected %ld, got %ld\n", cbProvName, provNameSize);
LocalFree(provName); LocalFree(provName);
} }