Routine description:
This routine demonstrates the use of EwfMgrSetPersistentData
and EwfMgrGetPersistentData. First, a handle is opened to a
protected volume, and then commands are issued to the protected volume.
EwfMgrSetPersistentData, EwfMgrGetPersistentData :
Commands: Set and get persistent data to and
from the desired EWF-protected volume.
Reboot: Not required.
Supported on EWF configurations of type EWF_DISK and
EWF_RAM.
Arguments:
szProVolName
Volume name obtained from EwfMgrGetProtectedVolumeList or
device name obtained from EwfMgrGetOverlayStoreConfig prepended with
\\.\C: where C represents the drive letter of the protected volume.
Return value:
ERROR_SUCCESS if success; otherwise, a Win32 error code.
--*/
DWORD DoEwfPersistCommands ( LPWSTR szProVolName )
{
DWORD dwStatus = ERROR_SUCCESS;
HANDLE hProVol = INVALID_HANDLE_VALUE;
BOOL bResult = FALSE;
WORD wIdx = 0;
// Used to demonstrate EWF set and get persistent data commands.
BYTE buffer[EWF_MAX_PERSISTENT_DATA] = {
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,
0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,
0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20};
DWORD cbCount = EWF_MAX_PERSISTENT_DATA; // 32 bytes
// Use the volume name to open a handle to this protected volume.
hProVol = EwfMgrOpenProtected(szProVolName);
if (hProVol == INVALID_HANDLE_VALUE)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrOpenProtected failed LE = %u\n",dwStatus);
goto exit;
}
bResult = EwfMgrSetPersistentData(
hProVol,
(LPBYTE)buffer,
cbCount);
if (!bResult)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrSetPersistentData failed LE = %u\n",dwStatus);
goto exit;
}
wprintf(L"EwfMgrSetPersistentData succeeded\n");
ZeroMemory(buffer,cbCount);
bResult = EwfMgrGetPersistentData(
hProVol,
buffer,
cbCount);
if (!bResult)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetPersistentData failed LE = %u\n",dwStatus);
goto exit;
}
wprintf(L"EwfMgrGetPersistentData succeeded\n");
// Display the persistent data of the protected volume.
for (wIdx = 0; wIdx < EWF_MAX_PERSISTENT_DATA; wIdx++)
{
wprintf(L"%02X",buffer[wIdx]);
}
wprintf(L"\n");
exit:
if (hProVol != INVALID_HANDLE_VALUE)
{
EwfMgrClose(hProVol);
}
return dwStatus;
}
/*++