📄 debug.cpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#include <windows.h>
#include <debug.h>
#ifdef DEBUG
void DumpRegKey(DWORD dwZone, PTSTR szKey, HKEY hKey)
{
DWORD dwIndex = 0;
WCHAR szValueName[MAX_PATH];
DWORD dwValueNameSize = MAX_PATH;
BYTE pValueData[256];
DWORD dwType;
DWORD dwValueDataSize = sizeof(pValueData);
DEBUGMSG(dwZone, (TEXT("Atapi!DumpRegKey> %s \r\n"), szKey));
while (ERROR_SUCCESS == RegEnumValue(hKey, dwIndex, szValueName, &dwValueNameSize, NULL, &dwType, pValueData, &dwValueDataSize)) {
if (REG_SZ == dwType) {
DEBUGMSG(dwZone, (TEXT("\t\t%s = %s\r\n"), szValueName, (LPWSTR)pValueData));
}
else if (REG_DWORD == dwType) {
DEBUGMSG(dwZone, (TEXT("\t\t%s = %08X\r\n"), szValueName, *(PDWORD)pValueData));
}
else if (REG_MULTI_SZ == dwType) {
PWSTR pValueTemp = (PWSTR)pValueData;
DEBUGMSG(dwZone, (TEXT("\t\t%s :\r\n"), szValueName));
while (*pValueTemp) {
DEBUGMSG(dwZone, (TEXT("\t\t\t%s\r\n"), (LPWSTR)pValueTemp));
pValueTemp += (wcslen(pValueTemp) + 1);
}
}
dwIndex++;
dwValueDataSize = sizeof(pValueData);
dwValueNameSize = MAX_PATH;
}
}
VOID DumpIdentify(PIDENTIFY_DATA pId)
{
#if 0
DWORD i;
PUCHAR pCh;
TCHAR OutBuf[128];
LPTSTR pOut;
PUSHORT tempS;
UCHAR tempByte;
ULONG j,k;
#endif
#if 0
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!DumpIdentify> ...\r\n")));
i = sizeof(IDENTIFY_DATA);
pCh = (PUCHAR)pId;
while (i) {
pOut = OutBuf;
k = (i < 16) ? i : 16;
for (j = 0; j < k; j++) {
pOut += wsprintf(pOut, TEXT("%2x "), pCh[j]);
}
if (k < 16) {
for (j = 0; j < 16 - k; j++) {
pOut += wsprintf(pOut, TEXT(" "));
}
}
for (j = 0; j < k; j++) {
if ((pCh[j] < ' ') || (pCh[j] > '~')) {
pOut += wsprintf(pOut, TEXT("."));
} else {
pOut += wsprintf(pOut, TEXT("%c"), pCh[j]);
}
}
DEBUGMSG(ZONE_INIT,(TEXT("%s\r\n"), OutBuf));
i -= k;
pCh += k;
}
if (pId->GeneralConfiguration & 0x8000) {
DEBUGMSG(ZONE_INIT, (TEXT(" non-magnetic media\r\n")));
}
if (pId->GeneralConfiguration & 0x4000) {
DEBUGMSG(ZONE_INIT, (TEXT(" format speed tolerance gap required\r\n")));
}
if (pId->GeneralConfiguration & 0x2000) {
DEBUGMSG(ZONE_INIT, (TEXT(" track offset option available\r\n")));
}
if (pId->GeneralConfiguration & 0x1000) {
DEBUGMSG(ZONE_INIT, (TEXT(" data strobe offset option available\r\n")));
}
if (pId->GeneralConfiguration & 0x0800) {
DEBUGMSG(ZONE_INIT, (TEXT(" rotational speed tolerance is > 0,5%\r\n")));
}
#endif
if (pId->GeneralConfiguration & 0x0400) {
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!CDisk::Identify> Disk transfer rate > 10Mbs\r\n")));
}
if (pId->GeneralConfiguration & 0x0200) {
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!CDisk::Identify> Disk transfer rate > 5Mbs and <= 10Mbs\r\n")));
}
if (pId->GeneralConfiguration & 0x0100) {
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!CDisk::Identify> Disk transfer rate <= 5Mbs\r\n")));
}
if (pId->Capabilities & 0x0100) {
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!CDisk::Identify> DMA supported\r\n")));
}
else {
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!CDisk::Identify> DMA not supported\r\n")));
}
#if 0
if (pId->GeneralConfiguration & 0x0080) {
DEBUGMSG(ZONE_INIT, (TEXT(" removeable cartridge drive\r\n")));
}
if (pId->GeneralConfiguration & 0x0040) {
DEBUGMSG(ZONE_INIT, (TEXT(" fixed drive\r\n")));
}
if (pId->GeneralConfiguration & 0x0020) {
DEBUGMSG(ZONE_INIT, (TEXT(" spindle motor control option implemented\r\n")));
}
if (pId->GeneralConfiguration & 0x0010) {
DEBUGMSG(ZONE_INIT, (TEXT(" head switch time > 15us\r\n")));
}
if (pId->GeneralConfiguration & 0x0008) {
DEBUGMSG(ZONE_INIT, (TEXT(" not MFM encoded\r\n")));
}
if (pId->GeneralConfiguration & 0x0004) {
DEBUGMSG(ZONE_INIT, (TEXT(" soft sectored\r\n")));
}
if (pId->GeneralConfiguration & 0x0002) {
DEBUGMSG(ZONE_INIT, (TEXT(" hard sectored\r\n")));
}
#endif
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!CDisk::Identify> (The following data may be read from an obsolete INDENTIFY DEVICE address)\r\n")));
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!CDisk::Identify> %d cylinders\r\n"), pId->NumberOfCylinders));
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!CDisk::Identify> %d heads\r\n"), pId->NumberOfHeads));
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!CDisk::Identify> %d unformatted bytes per track\r\n"), pId->UnformattedBytesPerTrack));
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!CDisk::Identify> %d unformatted bytes per sector\r\n"), pId->UnformattedBytesPerSector));
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!CDisk::Identify> %d sectors per track\r\n"), pId->SectorsPerTrack));
#if 0
tempS = pId->ModelNumber;
for (k=0; k<20; k++) {
tempByte = (UCHAR)(tempS[k] & 0x00FF);
tempS[k] = tempS[k] >> 8;
tempS[k] |= tempByte << 8;
}
tempS = pId->FirmwareRevision;
for (k=0; k<4; k++) {
tempByte = (UCHAR)(tempS[k] & 0x00FF);
tempS[k] = tempS[k] >> 8;
tempS[k] |= tempByte << 8;
}
tempS = pId->SerialNumber;
for (k=0; k<10; k++) {
tempByte = (UCHAR)(tempS[k] & 0x00FF);
tempS[k] = tempS[k] >> 8;
tempS[k] |= tempByte << 8;
}
if (pId->BufferType == 0) {
DEBUGMSG(ZONE_INIT, (TEXT(
" buffer type : unspecified\r\n")));
}
if (pId->BufferType == 1) {
DEBUGMSG(ZONE_INIT, (TEXT(
" buffer type : single port; no simultaneous transfers\r\n")));
}
if (pId->BufferType == 2) {
DEBUGMSG(ZONE_INIT, (TEXT(
" buffer type : dual port; simultaneous transfers supported\r\n")));
}
if (pId->BufferType == 3) {
DEBUGMSG(ZONE_INIT, (TEXT(
" buffer type : dual port; simultaneous transfer supported, read cache supported\r\n")));
}
if (pId->BufferType >= 4) {
DEBUGMSG(ZONE_INIT, (TEXT(
" buffer type : reserved\r\n")));
}
#endif
#if 0
if (pId->DoubleWordIo == 0) {
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!CDisk::Identify> double word IO : not supported\r\n")));
}
else if (pId->DoubleWordIo == 1) {
DEBUGMSG(ZONE_INIT, (TEXT("Atapi!CDisk::Identify> double word IO : supported\r\n")));
}
else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -