MSDN EWFAPI Sample Logic Error.

  • Thread starter Thread starter Andre R.
  • Start date Start date
A

Andre R.

Hi all,

I appreciate the hard work you put into your products, and your blog. In
reviewing the usage of the EWFAPI in the sample code at
http://msdn2.microsoft.com/en-us/library/ms912855.aspx#xeconcodeexampleanchor21 I
noticed a discrepancy that does not make any sense.

For the sake of clarity I will quote the section I believe is in error here,
below is the sample directly from MSDN2.

Begin Quote
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE =
%u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
End Quote

If I am reading this code correctly it will always look up the drive letter
for the first volume returned in the volume list. Thus by extension this
function will display that all volumes recorded by the Overlay Configuration
will be using the same letter. This appears to be a logic error.

Am I correct in assuming that this routine should/could be using the values
reported in the pOvlConfig->VolumeDescArray?

Andre Reid.

Here is the complete sample for contextual understanding.
VOID DisplayEwfOverlayConfig ( PEWF_OVERLAY_STORE_CONFIG pOvlConfig )
{
PEWF_VOLUME_DESC pVolDesc = NULL;
WORD ii = 0, jj = 0;
WCHAR chDrive = NULL;
DWORD dwStatus = 0;
WCHAR szVolumeName[EWF_MAX_DEVICE_NAME_LENGTH + 15] = {0};

wprintf(L"\n\n");
wprintf(L"--------------------------------------------------------\n");
wprintf(L"-- Ewf overlay store configuration : \n");
wprintf(L"--------------------------------------------------------\n\n");

// Display the EWF overlay store configuration.
wprintf(L"Format Version : %u\n", pOvlConfig->FormatVersion);
wprintf(L"Volume Size : %I64d Mb\n", pOvlConfig->VolumeSize /
1000000L);
wprintf(L"Number of Segments : %u\n", pOvlConfig->NumSegments);
wprintf(L"Free Segments : %u\n", pOvlConfig->FreeSegments);
wprintf(L"Segment Size : %u Bytes\n", pOvlConfig->SegmentSize);
wprintf(L"Max Volumes : %u\n", pOvlConfig->MaxVolumes);
wprintf(L"Number of Volumes : %u\n", pOvlConfig->NumVolumes);
wprintf(L"Max Levels : %u\n\n", pOvlConfig->MaxLevels);

// Display information about each protected volume.
for (ii = 0; ii < pOvlConfig->NumVolumes; ii++)
{
pVolDesc = &pOvlConfig->VolumeDescArray[ii];

/*Error is in this Block*/
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE =
%u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
/*End error*/

wprintf(L"Protected Volume [%u] : ID = ",ii);

for (jj = 0; jj < EWF_VOLUME_ID_SIZE; jj++)
{
wprintf(L"%02X", pVolDesc->VolumeID[jj]);
}

wprintf(L"Name = %.*s Drive = %c\n",
EWF_MAX_DEVICE_NAME_LENGTH, pVolDesc->DeviceName, chDrive);

} // End for each protected volume.

wprintf(L"\n\n");
}
 
Andre,

I am not 100% sure what you are asking, but in this code version, there is a
"While" loop that should list all the drives configured to protected by EWF.

A slightly different version can be found here:
http://msdn2.microsoft.com/en-us/library/ms838476.aspx

Regards,

Sean Liming
www.sjjmicro.com / www.seanliming.com
XP Embedded Book Author - XP Embedded Advanced, XP Embedded Supplemental
Toolkit


Andre R. said:
Hi all,

I appreciate the hard work you put into your products, and your blog. In
reviewing the usage of the EWFAPI in the sample code at
http://msdn2.microsoft.com/en-us/library/ms912855.aspx#xeconcodeexampleanchor21 I
noticed a discrepancy that does not make any sense.

For the sake of clarity I will quote the section I believe is in error
here, below is the sample directly from MSDN2.

Begin Quote
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE =
%u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
End Quote

If I am reading this code correctly it will always look up the drive
letter for the first volume returned in the volume list. Thus by extension
this function will display that all volumes recorded by the Overlay
Configuration will be using the same letter. This appears to be a logic
error.

Am I correct in assuming that this routine should/could be using the
values reported in the pOvlConfig->VolumeDescArray?

Andre Reid.

Here is the complete sample for contextual understanding.
VOID DisplayEwfOverlayConfig ( PEWF_OVERLAY_STORE_CONFIG pOvlConfig )
{
PEWF_VOLUME_DESC pVolDesc = NULL;
WORD ii = 0, jj = 0;
WCHAR chDrive = NULL;
DWORD dwStatus = 0;
WCHAR szVolumeName[EWF_MAX_DEVICE_NAME_LENGTH + 15] = {0};

wprintf(L"\n\n");
wprintf(L"--------------------------------------------------------\n");
wprintf(L"-- Ewf overlay store configuration : \n");
wprintf(L"--------------------------------------------------------\n\n");

// Display the EWF overlay store configuration.
wprintf(L"Format Version : %u\n", pOvlConfig->FormatVersion);
wprintf(L"Volume Size : %I64d Mb\n", pOvlConfig->VolumeSize /
1000000L);
wprintf(L"Number of Segments : %u\n", pOvlConfig->NumSegments);
wprintf(L"Free Segments : %u\n", pOvlConfig->FreeSegments);
wprintf(L"Segment Size : %u Bytes\n", pOvlConfig->SegmentSize);
wprintf(L"Max Volumes : %u\n", pOvlConfig->MaxVolumes);
wprintf(L"Number of Volumes : %u\n", pOvlConfig->NumVolumes);
wprintf(L"Max Levels : %u\n\n", pOvlConfig->MaxLevels);

// Display information about each protected volume.
for (ii = 0; ii < pOvlConfig->NumVolumes; ii++)
{
pVolDesc = &pOvlConfig->VolumeDescArray[ii];

/*Error is in this Block*/
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE =
%u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
/*End error*/

wprintf(L"Protected Volume [%u] : ID = ",ii);

for (jj = 0; jj < EWF_VOLUME_ID_SIZE; jj++)
{
wprintf(L"%02X", pVolDesc->VolumeID[jj]);
}

wprintf(L"Name = %.*s Drive = %c\n",
EWF_MAX_DEVICE_NAME_LENGTH, pVolDesc->DeviceName, chDrive);

} // End for each protected volume.

wprintf(L"\n\n");
}
 
I think Andre is right.
The "while" loop is only there for *volume config* info printed out. For the *overlay config* they are looping through
VolumeDescArray but the drive letter conversion routine always takes the first protected volume name.
Looks to me like copy/paste bug. It is a sample code, after all - no guarantees :-)

--
=========
Regards,
KM
Andre,

I am not 100% sure what you are asking, but in this code version, there is a "While" loop that should list all the drives
configured to protected by EWF.

A slightly different version can be found here: http://msdn2.microsoft.com/en-us/library/ms838476.aspx

Regards,

Sean Liming
www.sjjmicro.com / www.seanliming.com
XP Embedded Book Author - XP Embedded Advanced, XP Embedded Supplemental Toolkit


Andre R. said:
Hi all,

I appreciate the hard work you put into your products, and your blog. In reviewing the usage of the EWFAPI in the sample code at
http://msdn2.microsoft.com/en-us/library/ms912855.aspx#xeconcodeexampleanchor21 I noticed a discrepancy that does not make any
sense.

For the sake of clarity I will quote the section I believe is in error here, below is the sample directly from MSDN2.

Begin Quote
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE = %u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
End Quote

If I am reading this code correctly it will always look up the drive letter for the first volume returned in the volume list.
Thus by extension this function will display that all volumes recorded by the Overlay Configuration will be using the same
letter. This appears to be a logic error.

Am I correct in assuming that this routine should/could be using the values reported in the pOvlConfig->VolumeDescArray?

Andre Reid.

Here is the complete sample for contextual understanding.
VOID DisplayEwfOverlayConfig ( PEWF_OVERLAY_STORE_CONFIG pOvlConfig )
{
PEWF_VOLUME_DESC pVolDesc = NULL;
WORD ii = 0, jj = 0;
WCHAR chDrive = NULL;
DWORD dwStatus = 0;
WCHAR szVolumeName[EWF_MAX_DEVICE_NAME_LENGTH + 15] = {0};

wprintf(L"\n\n");
wprintf(L"--------------------------------------------------------\n");
wprintf(L"-- Ewf overlay store configuration : \n");
wprintf(L"--------------------------------------------------------\n\n");

// Display the EWF overlay store configuration.
wprintf(L"Format Version : %u\n", pOvlConfig->FormatVersion);
wprintf(L"Volume Size : %I64d Mb\n", pOvlConfig->VolumeSize / 1000000L);
wprintf(L"Number of Segments : %u\n", pOvlConfig->NumSegments);
wprintf(L"Free Segments : %u\n", pOvlConfig->FreeSegments);
wprintf(L"Segment Size : %u Bytes\n", pOvlConfig->SegmentSize);
wprintf(L"Max Volumes : %u\n", pOvlConfig->MaxVolumes);
wprintf(L"Number of Volumes : %u\n", pOvlConfig->NumVolumes);
wprintf(L"Max Levels : %u\n\n", pOvlConfig->MaxLevels);

// Display information about each protected volume.
for (ii = 0; ii < pOvlConfig->NumVolumes; ii++)
{
pVolDesc = &pOvlConfig->VolumeDescArray[ii];

/*Error is in this Block*/
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE = %u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
/*End error*/

wprintf(L"Protected Volume [%u] : ID = ",ii);

for (jj = 0; jj < EWF_VOLUME_ID_SIZE; jj++)
{
wprintf(L"%02X", pVolDesc->VolumeID[jj]);
}

wprintf(L"Name = %.*s Drive = %c\n",
EWF_MAX_DEVICE_NAME_LENGTH, pVolDesc->DeviceName, chDrive);

} // End for each protected volume.

wprintf(L"\n\n");
}
 
Yup. You are right. Well, it has been a long while since I looked at this
code. The MS code example looks a little new.

Regards,

Sean Liming
www.sjjmicro.com / www.seanliming.com
XP Embedded Book Author - XP Embedded Advanced, XP Embedded Supplemental
Toolkit


KM said:
I think Andre is right.
The "while" loop is only there for *volume config* info printed out. For
the *overlay config* they are looping through VolumeDescArray but the
drive letter conversion routine always takes the first protected volume
name.
Looks to me like copy/paste bug. It is a sample code, after all - no
guarantees :-)

--
=========
Regards,
KM
Andre,

I am not 100% sure what you are asking, but in this code version, there
is a "While" loop that should list all the drives configured to protected
by EWF.

A slightly different version can be found here:
http://msdn2.microsoft.com/en-us/library/ms838476.aspx

Regards,

Sean Liming
www.sjjmicro.com / www.seanliming.com
XP Embedded Book Author - XP Embedded Advanced, XP Embedded Supplemental
Toolkit


Andre R. said:
Hi all,

I appreciate the hard work you put into your products, and your blog.
In reviewing the usage of the EWFAPI in the sample code at
http://msdn2.microsoft.com/en-us/library/ms912855.aspx#xeconcodeexampleanchor21 I
noticed a discrepancy that does not make any sense.

For the sake of clarity I will quote the section I believe is in error
here, below is the sample directly from MSDN2.

Begin Quote
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE =
%u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
End Quote

If I am reading this code correctly it will always look up the drive
letter for the first volume returned in the volume list. Thus by
extension this function will display that all volumes recorded by the
Overlay Configuration will be using the same letter. This appears to be
a logic error.

Am I correct in assuming that this routine should/could be using the
values reported in the pOvlConfig->VolumeDescArray?

Andre Reid.

Here is the complete sample for contextual understanding.
VOID DisplayEwfOverlayConfig ( PEWF_OVERLAY_STORE_CONFIG pOvlConfig )
{
PEWF_VOLUME_DESC pVolDesc = NULL;
WORD ii = 0, jj = 0;
WCHAR chDrive = NULL;
DWORD dwStatus = 0;
WCHAR szVolumeName[EWF_MAX_DEVICE_NAME_LENGTH + 15] = {0};

wprintf(L"\n\n");
wprintf(L"--------------------------------------------------------\n");
wprintf(L"-- Ewf overlay store configuration : \n");

wprintf(L"--------------------------------------------------------\n\n");

// Display the EWF overlay store configuration.
wprintf(L"Format Version : %u\n",
pOvlConfig->FormatVersion);
wprintf(L"Volume Size : %I64d Mb\n", pOvlConfig->VolumeSize /
1000000L);
wprintf(L"Number of Segments : %u\n", pOvlConfig->NumSegments);
wprintf(L"Free Segments : %u\n",
pOvlConfig->FreeSegments);
wprintf(L"Segment Size : %u Bytes\n", pOvlConfig->SegmentSize);
wprintf(L"Max Volumes : %u\n", pOvlConfig->MaxVolumes);
wprintf(L"Number of Volumes : %u\n", pOvlConfig->NumVolumes);
wprintf(L"Max Levels : %u\n\n", pOvlConfig->MaxLevels);

// Display information about each protected volume.
for (ii = 0; ii < pOvlConfig->NumVolumes; ii++)
{
pVolDesc = &pOvlConfig->VolumeDescArray[ii];

/*Error is in this Block*/
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE =
%u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
/*End error*/

wprintf(L"Protected Volume [%u] : ID = ",ii);

for (jj = 0; jj < EWF_VOLUME_ID_SIZE; jj++)
{
wprintf(L"%02X", pVolDesc->VolumeID[jj]);
}

wprintf(L"Name = %.*s Drive = %c\n",
EWF_MAX_DEVICE_NAME_LENGTH, pVolDesc->DeviceName, chDrive);

} // End for each protected volume.

wprintf(L"\n\n");
}
 
Sean,

Sorry I didn't reply sooner.

This code looks to me to have posted for SP2 - Feature Pack 2007.

I am writing a wrapper class to allow handling all the functions in a C++
class, however when I traced the Sample code for this function I noted the
logic error and thought I would post it here so that Andy and team would at
least see it and raise an issue with the documentation team.

I will admit that the logic bug is subtle esp. in the quoted section which
is why I posted the whole sample for context. I agree with KM it looks like
a copy paste bug. (imho- these can be the worst sort.:-)).

Andre.


Sean Liming (eMVP) said:
Yup. You are right. Well, it has been a long while since I looked at this
code. The MS code example looks a little new.

Regards,

Sean Liming
www.sjjmicro.com / www.seanliming.com
XP Embedded Book Author - XP Embedded Advanced, XP Embedded Supplemental
Toolkit


KM said:
I think Andre is right.
The "while" loop is only there for *volume config* info printed out. For
the *overlay config* they are looping through VolumeDescArray but the
drive letter conversion routine always takes the first protected volume
name.
Looks to me like copy/paste bug. It is a sample code, after all - no
guarantees :-)

--
=========
Regards,
KM
Andre,

I am not 100% sure what you are asking, but in this code version, there
is a "While" loop that should list all the drives configured to
protected by EWF.

A slightly different version can be found here:
http://msdn2.microsoft.com/en-us/library/ms838476.aspx

Regards,

Sean Liming
www.sjjmicro.com / www.seanliming.com
XP Embedded Book Author - XP Embedded Advanced, XP Embedded Supplemental
Toolkit


Hi all,

I appreciate the hard work you put into your products, and your blog.
In reviewing the usage of the EWFAPI in the sample code at
http://msdn2.microsoft.com/en-us/library/ms912855.aspx#xeconcodeexampleanchor21 I
noticed a discrepancy that does not make any sense.

For the sake of clarity I will quote the section I believe is in error
here, below is the sample directly from MSDN2.

Begin Quote
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE =
%u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
End Quote

If I am reading this code correctly it will always look up the drive
letter for the first volume returned in the volume list. Thus by
extension this function will display that all volumes recorded by the
Overlay Configuration will be using the same letter. This appears to be
a logic error.

Am I correct in assuming that this routine should/could be using the
values reported in the pOvlConfig->VolumeDescArray?

Andre Reid.

Here is the complete sample for contextual understanding.
VOID DisplayEwfOverlayConfig ( PEWF_OVERLAY_STORE_CONFIG pOvlConfig )
{
PEWF_VOLUME_DESC pVolDesc = NULL;
WORD ii = 0, jj = 0;
WCHAR chDrive = NULL;
DWORD dwStatus = 0;
WCHAR szVolumeName[EWF_MAX_DEVICE_NAME_LENGTH + 15] = {0};

wprintf(L"\n\n");

wprintf(L"--------------------------------------------------------\n");
wprintf(L"-- Ewf overlay store configuration :
\n");

wprintf(L"--------------------------------------------------------\n\n");

// Display the EWF overlay store configuration.
wprintf(L"Format Version : %u\n", pOvlConfig->FormatVersion);
wprintf(L"Volume Size : %I64d Mb\n", pOvlConfig->VolumeSize /
1000000L);
wprintf(L"Number of Segments : %u\n",
pOvlConfig->NumSegments);
wprintf(L"Free Segments : %u\n", pOvlConfig->FreeSegments);
wprintf(L"Segment Size : %u Bytes\n",
pOvlConfig->SegmentSize);
wprintf(L"Max Volumes : %u\n", pOvlConfig->MaxVolumes);
wprintf(L"Number of Volumes : %u\n", pOvlConfig->NumVolumes);
wprintf(L"Max Levels : %u\n\n", pOvlConfig->MaxLevels);

// Display information about each protected volume.
for (ii = 0; ii < pOvlConfig->NumVolumes; ii++)
{
pVolDesc = &pOvlConfig->VolumeDescArray[ii];

/*Error is in this Block*/
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE =
%u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
/*End error*/

wprintf(L"Protected Volume [%u] : ID = ",ii);

for (jj = 0; jj < EWF_VOLUME_ID_SIZE; jj++)
{
wprintf(L"%02X", pVolDesc->VolumeID[jj]);
}

wprintf(L"Name = %.*s Drive = %c\n",
EWF_MAX_DEVICE_NAME_LENGTH, pVolDesc->DeviceName, chDrive);

} // End for each protected volume.

wprintf(L"\n\n");
}
 
KM
That is what I noticed. And I believe also that it is a copy paste bug.

Andre.


KM said:
I think Andre is right.
The "while" loop is only there for *volume config* info printed out. For
the *overlay config* they are looping through VolumeDescArray but the
drive letter conversion routine always takes the first protected volume
name.
Looks to me like copy/paste bug. It is a sample code, after all - no
guarantees :-)

--
=========
Regards,
KM
Andre,

I am not 100% sure what you are asking, but in this code version, there
is a "While" loop that should list all the drives configured to protected
by EWF.

A slightly different version can be found here:
http://msdn2.microsoft.com/en-us/library/ms838476.aspx

Regards,

Sean Liming
www.sjjmicro.com / www.seanliming.com
XP Embedded Book Author - XP Embedded Advanced, XP Embedded Supplemental
Toolkit


Andre R. said:
Hi all,

I appreciate the hard work you put into your products, and your blog.
In reviewing the usage of the EWFAPI in the sample code at
http://msdn2.microsoft.com/en-us/library/ms912855.aspx#xeconcodeexampleanchor21 I
noticed a discrepancy that does not make any sense.

For the sake of clarity I will quote the section I believe is in error
here, below is the sample directly from MSDN2.

Begin Quote
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE =
%u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
End Quote

If I am reading this code correctly it will always look up the drive
letter for the first volume returned in the volume list. Thus by
extension this function will display that all volumes recorded by the
Overlay Configuration will be using the same letter. This appears to be
a logic error.

Am I correct in assuming that this routine should/could be using the
values reported in the pOvlConfig->VolumeDescArray?

Andre Reid.

Here is the complete sample for contextual understanding.
VOID DisplayEwfOverlayConfig ( PEWF_OVERLAY_STORE_CONFIG pOvlConfig )
{
PEWF_VOLUME_DESC pVolDesc = NULL;
WORD ii = 0, jj = 0;
WCHAR chDrive = NULL;
DWORD dwStatus = 0;
WCHAR szVolumeName[EWF_MAX_DEVICE_NAME_LENGTH + 15] = {0};

wprintf(L"\n\n");
wprintf(L"--------------------------------------------------------\n");
wprintf(L"-- Ewf overlay store configuration : \n");

wprintf(L"--------------------------------------------------------\n\n");

// Display the EWF overlay store configuration.
wprintf(L"Format Version : %u\n",
pOvlConfig->FormatVersion);
wprintf(L"Volume Size : %I64d Mb\n", pOvlConfig->VolumeSize /
1000000L);
wprintf(L"Number of Segments : %u\n", pOvlConfig->NumSegments);
wprintf(L"Free Segments : %u\n",
pOvlConfig->FreeSegments);
wprintf(L"Segment Size : %u Bytes\n", pOvlConfig->SegmentSize);
wprintf(L"Max Volumes : %u\n", pOvlConfig->MaxVolumes);
wprintf(L"Number of Volumes : %u\n", pOvlConfig->NumVolumes);
wprintf(L"Max Levels : %u\n\n", pOvlConfig->MaxLevels);

// Display information about each protected volume.
for (ii = 0; ii < pOvlConfig->NumVolumes; ii++)
{
pVolDesc = &pOvlConfig->VolumeDescArray[ii];

/*Error is in this Block*/
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE =
%u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
/*End error*/

wprintf(L"Protected Volume [%u] : ID = ",ii);

for (jj = 0; jj < EWF_VOLUME_ID_SIZE; jj++)
{
wprintf(L"%02X", pVolDesc->VolumeID[jj]);
}

wprintf(L"Name = %.*s Drive = %c\n",
EWF_MAX_DEVICE_NAME_LENGTH, pVolDesc->DeviceName, chDrive);

} // End for each protected volume.

wprintf(L"\n\n");
}
 
You would want to post this to the XPe forum for the XPe team to spot it
quickly: http://forums.microsoft.com/embeddedwindows/default.aspx?siteid=47

Regards,

Sean Liming
www.sjjmicro.com / www.seanliming.com
XP Embedded Book Author - XP Embedded Advanced, XP Embedded Supplemental
Toolkit


Andre R. said:
Sean,

Sorry I didn't reply sooner.

This code looks to me to have posted for SP2 - Feature Pack 2007.

I am writing a wrapper class to allow handling all the functions in a C++
class, however when I traced the Sample code for this function I noted the
logic error and thought I would post it here so that Andy and team would
at least see it and raise an issue with the documentation team.

I will admit that the logic bug is subtle esp. in the quoted section which
is why I posted the whole sample for context. I agree with KM it looks
like a copy paste bug. (imho- these can be the worst sort.:-)).

Andre.


Sean Liming (eMVP) said:
Yup. You are right. Well, it has been a long while since I looked at this
code. The MS code example looks a little new.

Regards,

Sean Liming
www.sjjmicro.com / www.seanliming.com
XP Embedded Book Author - XP Embedded Advanced, XP Embedded Supplemental
Toolkit


KM said:
I think Andre is right.
The "while" loop is only there for *volume config* info printed out. For
the *overlay config* they are looping through VolumeDescArray but the
drive letter conversion routine always takes the first protected volume
name.
Looks to me like copy/paste bug. It is a sample code, after all - no
guarantees :-)

--
=========
Regards,
KM

Andre,

I am not 100% sure what you are asking, but in this code version, there
is a "While" loop that should list all the drives configured to
protected by EWF.

A slightly different version can be found here:
http://msdn2.microsoft.com/en-us/library/ms838476.aspx

Regards,

Sean Liming
www.sjjmicro.com / www.seanliming.com
XP Embedded Book Author - XP Embedded Advanced, XP Embedded
Supplemental Toolkit


Hi all,

I appreciate the hard work you put into your products, and your blog.
In reviewing the usage of the EWFAPI in the sample code at
http://msdn2.microsoft.com/en-us/library/ms912855.aspx#xeconcodeexampleanchor21 I
noticed a discrepancy that does not make any sense.

For the sake of clarity I will quote the section I believe is in error
here, below is the sample directly from MSDN2.

Begin Quote
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE =
%u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
End Quote

If I am reading this code correctly it will always look up the drive
letter for the first volume returned in the volume list. Thus by
extension this function will display that all volumes recorded by the
Overlay Configuration will be using the same letter. This appears to
be a logic error.

Am I correct in assuming that this routine should/could be using the
values reported in the pOvlConfig->VolumeDescArray?

Andre Reid.

Here is the complete sample for contextual understanding.
VOID DisplayEwfOverlayConfig ( PEWF_OVERLAY_STORE_CONFIG pOvlConfig )
{
PEWF_VOLUME_DESC pVolDesc = NULL;
WORD ii = 0, jj = 0;
WCHAR chDrive = NULL;
DWORD dwStatus = 0;
WCHAR szVolumeName[EWF_MAX_DEVICE_NAME_LENGTH + 15] = {0};

wprintf(L"\n\n");

wprintf(L"--------------------------------------------------------\n");
wprintf(L"-- Ewf overlay store configuration : \n");

wprintf(L"--------------------------------------------------------\n\n");

// Display the EWF overlay store configuration.
wprintf(L"Format Version : %u\n", pOvlConfig->FormatVersion);
wprintf(L"Volume Size : %I64d Mb\n", pOvlConfig->VolumeSize
/ 1000000L);
wprintf(L"Number of Segments : %u\n", pOvlConfig->NumSegments);
wprintf(L"Free Segments : %u\n", pOvlConfig->FreeSegments);
wprintf(L"Segment Size : %u Bytes\n",
pOvlConfig->SegmentSize);
wprintf(L"Max Volumes : %u\n",
pOvlConfig->MaxVolumes);
wprintf(L"Number of Volumes : %u\n",
pOvlConfig->NumVolumes);
wprintf(L"Max Levels : %u\n\n", pOvlConfig->MaxLevels);

// Display information about each protected volume.
for (ii = 0; ii < pOvlConfig->NumVolumes; ii++)
{
pVolDesc = &pOvlConfig->VolumeDescArray[ii];

/*Error is in this Block*/
// Convert the protected volume's device name into a volume name.
PEWF_VOLUME_NAME_ENTRY pEwfVolName = NULL;
pEwfVolName = EwfMgrGetProtectedVolumeList();

// Get the drive letter that represents this protected volume.
chDrive = EwfMgrGetDriveLetterFromVolumeName(pEwfVolName->Name);

if (chDrive == -1)
{
dwStatus = GetLastError();
wprintf(L"EwfMgrGetDriveLetterFromVolumeName failed LE =
%u\n",dwStatus);
}

if ( pEwfVolName )
{
EwfMgrVolumeNameListDelete( pEwfVolName );
pEwfVolName = NULL;
}
/*End error*/

wprintf(L"Protected Volume [%u] : ID = ",ii);

for (jj = 0; jj < EWF_VOLUME_ID_SIZE; jj++)
{
wprintf(L"%02X", pVolDesc->VolumeID[jj]);
}

wprintf(L"Name = %.*s Drive = %c\n",
EWF_MAX_DEVICE_NAME_LENGTH, pVolDesc->DeviceName, chDrive);

} // End for each protected volume.

wprintf(L"\n\n");
}
 
Back
Top