crypt32: Implement CRYPT_WriteSerializedStoreToFile using CRYPT_WriteSerializedStoreToStream.

This commit is contained in:
Juan Lang 2007-09-27 12:36:06 -07:00 committed by Alexandre Julliard
parent 779dd45e6b
commit bba9587f40
1 changed files with 4 additions and 56 deletions

View File

@ -599,68 +599,16 @@ BOOL CRYPT_WriteSerializedStoreToStream(HCERTSTORE store,
return ret; return ret;
} }
static BOOL CRYPT_SerializeContextsToFile(HANDLE file, static BOOL CRYPT_FileOutputFunc(void *handle, const void *buffer, DWORD size)
const WINE_CONTEXT_INTERFACE *contextInterface, HCERTSTORE store)
{ {
const void *context = NULL; return WriteFile(handle, buffer, size, &size, NULL);
BOOL ret;
do {
context = contextInterface->enumContextsInStore(store, context);
if (context)
{
DWORD size = 0;
LPBYTE buf = NULL;
ret = contextInterface->serialize(context, 0, NULL, &size);
if (size)
buf = CryptMemAlloc(size);
if (buf)
{
ret = contextInterface->serialize(context, 0, buf, &size);
if (ret)
ret = WriteFile(file, buf, size, &size, NULL);
}
CryptMemFree(buf);
}
else
ret = TRUE;
} while (ret && context != NULL);
if (context)
contextInterface->free(context);
return ret;
} }
BOOL CRYPT_WriteSerializedStoreToFile(HANDLE file, HCERTSTORE store) BOOL CRYPT_WriteSerializedStoreToFile(HANDLE file, HCERTSTORE store)
{ {
static const BYTE fileTrailer[12] = { 0 };
WINE_CONTEXT_INTERFACE interface;
BOOL ret;
DWORD size;
SetFilePointer(file, 0, NULL, FILE_BEGIN); SetFilePointer(file, 0, NULL, FILE_BEGIN);
ret = WriteFile(file, fileHeader, sizeof(fileHeader), &size, NULL); return CRYPT_WriteSerializedStoreToStream(store, CRYPT_FileOutputFunc,
if (ret) file);
{
memcpy(&interface, pCertInterface, sizeof(interface));
interface.serialize = (SerializeElementFunc)CRYPT_SerializeCertNoHash;
ret = CRYPT_SerializeContextsToFile(file, &interface, store);
}
if (ret)
{
memcpy(&interface, pCRLInterface, sizeof(interface));
interface.serialize = (SerializeElementFunc)CRYPT_SerializeCRLNoHash;
ret = CRYPT_SerializeContextsToFile(file, &interface, store);
}
if (ret)
{
memcpy(&interface, pCTLInterface, sizeof(interface));
interface.serialize = (SerializeElementFunc)CRYPT_SerializeCTLNoHash;
ret = CRYPT_SerializeContextsToFile(file, &interface, store);
}
if (ret)
ret = WriteFile(file, fileTrailer, sizeof(fileTrailer), &size, NULL);
return ret;
} }
BOOL WINAPI CertAddSerializedElementToStore(HCERTSTORE hCertStore, BOOL WINAPI CertAddSerializedElementToStore(HCERTSTORE hCertStore,