HexEdit/Misc.cpp
BSTR GetPhysicalDeviceName(LPCTSTR name)
{
	CString dev_name;

	if (_tcsncmp(name, _T("\\\\.\\PhysicalDrive"), 17) == 0)
		dev_name.Format(_T("\\device\\Harddisk%d\\Partition0"), atoi(name + 17));
	else if (_tcsncmp(name, _T("\\\\.\\CdRom"), 9) == 0)
		dev_name.Format(_T("\\device\\Cdrom%d"), atoi(name + 9));
	else if (_tcsncmp(name, _T("\\\\.\\Floppy"), 10) == 0)
		dev_name.Format(_T("\\device\\Floppy%d"), atoi(name + 10));
	else
		ASSERT(0);

	// Return as a BSTR (so Unicode string is available)
	return dev_name.AllocSysString();
}
// Given a "fake" device file name return a NT native API device name. Eg \\.\Floppy1 => \device\Floppy1
// Note: For \device\HarddiskN entries the sub-entry "Partition0" is not really a partition but
//       allows access to the whole disk.  (This is only a real device under NT, but is a valid
//       alias under 2K/XP to something like \device\HarddiskN\DRM (where N != M, although N == M
//       for fixed devices and M > N for removeable (M increases every time media is swapped).

Given a "fake" device file name return a NT native API device name.
Given a " fake " device file name return a NT native API device name .
BSTR GetPhysicalDeviceName(LPCTSTR name)
{
	CString dev_name;
	if (_tcsncmp(name, _T("\\\\.\\PhysicalDrive"), 17) == 0)
		dev_name.Format(_T("\\device\\Harddisk%d\\Partition0"), atoi(name + 17));
	else if (_tcsncmp(name, _T("\\\\.\\CdRom"), 9) == 0)
		dev_name.Format(_T("\\device\\Cdrom%d"), atoi(name + 9));
	else if (_tcsncmp(name, _T("\\\\.\\Floppy"), 10) == 0)
		dev_name.Format(_T("\\device\\Floppy%d"), atoi(name + 10));
	else
		ASSERT(0);
	return dev_name.AllocSysString();
}
BSTR GetPhysicalDeviceName ( LPCTSTR name ) { CString dev_name ; if ( _tcsncmp ( name , _T ( " \\ \\ \\ " ) , 17 ) == 0 ) dev_name . Format ( _T ( " \\ \\ \\ " ) , atoi ( name + 17 ) ) ; else if ( _tcsncmp ( name , _T ( " \\ \\ \\ " ) , 9 ) == 0 ) dev_name . Format ( _T ( " \\ \\ " ) , atoi ( name + 9 ) ) ; else if ( _tcsncmp ( name , _T ( " \\ \\ \\ " ) , 10 ) == 0 ) dev_name . Format ( _T ( " \\ \\ " ) , atoi ( name + 10 ) ) ; else ASSERT ( 0 ) ; return dev_name . AllocSysString ( ) ; }
Given a "fake" device file name return a NT native API device name.
Given a " fake " device file name return a NT native API device name .
// Return as a BSTR (so Unicode string is available)
