"James Hawkins" truiken@gmail.com wrote:
What is left to change?
- DWORD keytype, type, len;
- DWORD keytype, type, len, size;
Why do you need new 'size' variable? 'len' works fine.
- CRYPT_Free(keyname);
- r = RegQueryValueExA(key, "Name", NULL, &keytype, NULL, &len);
- if( r != ERROR_SUCCESS || !len || keytype != REG_SZ)
CRYPT_Free(keyname);
r = RegQueryValueExW(key, nameW, NULL, &keytype, NULL, &size);
Please do not change formatting here and everywhere else, use tab equal to 8 spaces by default, not 4.
- r = RegQueryValueExA(key, "Image Path", NULL, &keytype, NULL, &len);
- size = sizeof(DWORD);
- r = RegQueryValueExW(key, imagePathW, NULL, &keytype, NULL, &size);
It was already explained. There are another similar cases.
Take into account that CryptEnumProvidersA/W, CryptEnumProviderTypesA/W, CryptGetDefaultProviderA/W take number of bytes for in/out buffer in all cases: when making cross calls to them and in internal implementation.
- if (RegSetValueExA(hKey, "Name", 0, REG_SZ, pszProvName, strlen(pszProvName) +1))
- if (RegSetValueExW(hKey, nameW, 0, REG_SZ, (LPBYTE)pszProvName, strlenW(pszProvName) +1))
Already was explained.