📄 e100kd.c
字号:
if((HwCbCommand & CB_CMD_MASK) == CB_TRANSMIT)
{
dprintf(" TxCbTbdPointer = 0x%08x\n", (ULONG)ReadField(TxCbTbdPointer));
dprintf(" TxCbCount = %d, ", (USHORT)ReadField(TxCbCount));
dprintf("TxCbThreshold = %d, ", (UCHAR)ReadField(TxCbThreshold));
dprintf("TxCbTbdNumber = %d\n", (UCHAR)ReadField(TxCbTbdNumber));
}
}
DECLARE_API(sendqueue)
{
ULONG64 pEntry;
ULONG64 pPacket;
ULONG ulSize;
int ArgCount = 0;
int index = 0;
if(*args)
{
ArgCount = sscanf(args,"%I64lx", &pEntry);
}
//check for arguments
if(ArgCount < 1)
{
dprintf("Usage: sendqueue <SendWaitQueue address>\n");
return ;
}
SIGN_EXTEND(pEntry);
if(!(ulSize = GetTypeSize("NDIS_PACKET_PRIVATE")))
{
dprintf("Failed to get the type size of NDIS_PACKET_PRIVATE\n");
return;
}
dprintf("NDIS_PACKET_PRIVATE size is 0x%x\n", ulSize);
while(pEntry)
{
pPacket = pEntry - ulSize;
if(pPacket > pEntry)
{
dprintf("Invalid pEntry %p\n", pEntry);
break;
}
dprintf(" (%d) pEntry = %p, Pkt = %p\n", index, pEntry, pPacket);
if(ReadPtr(pEntry, &pEntry))
{
break;
}
index++;
if(CheckControlC())
{
dprintf("***Control-C***\n");
break;
}
}
}
DECLARE_API(recvlist)
{
ULONG64 pListHead;
ULONG64 pMpRfd;
ULONG64 pHwRfd;
int ArgCount = 0;
int Verbosity = 0;
int index = 0;
if(*args)
{
ArgCount = sscanf(args,"%I64lx %lx", &pListHead, &Verbosity);
}
//check for arguments
if(ArgCount < 1 || Verbosity > 1)
{
dprintf("Usage: recvlist <RecvList address> <verbosity>\n");
dprintf("1-Show HW_RFD info\n");
return ;
}
SIGN_EXTEND(pListHead);
if(GetFieldValue(pListHead, "LIST_ENTRY", "Flink", pMpRfd))
{
dprintf("Failed to get LIST_ENTRY Flink at %p\n", pListHead);
return;
}
while((pMpRfd != pListHead))
{
dprintf(" (%d) pMpRfd %p :\n", index, pMpRfd);
PrintMpRfdDetails(pMpRfd, Verbosity);
if(GetFieldValue(pMpRfd, "LIST_ENTRY", "Flink", pMpRfd))
{
dprintf("Failed to get LIST_ENTRY Flink at %p\n", pMpRfd);
break;
}
index++;
if(CheckControlC())
{
dprintf("***Control-C***\n");
break;
}
}
dprintf("RecvList has %d RFDs\n", index);
}
DECLARE_API(mprfd)
{
ULONG64 pMpRfd;
int ArgCount = 0;
if(*args)
{
ArgCount = sscanf(args,"%I64lx", &pMpRfd);
}
//check for arguments
if(ArgCount < 1)
{
dprintf("Usage: mprfd <MP_RFD>\n");
return ;
}
dprintf(" pMpRfd %p : \n", pMpRfd);
PrintMpRfdDetails(pMpRfd, 1);
}
DECLARE_API(hwrfd)
{
ULONG64 pHwRfd;
int ArgCount = 0;
if(*args)
{
ArgCount = sscanf(args,"%I64lx", &pHwRfd);
}
//check for arguments
if(ArgCount < 1)
{
dprintf("Usage: hwrfd <HW_RFD>\n");
return ;
}
dprintf(" pHwRfd = %p : \n", pHwRfd);
PrintHwRfdDetails(pHwRfd);
}
void PrintMpRfdDetails(ULONG64 pMpRfd, int Verbosity)
{
ULONG64 pHwRfd;
ULONG Flags;
InitTypeRead(pMpRfd, MP_RFD);
dprintf(" Flink %p", ReadField(List.Flink));
dprintf(" , Blink %p\n", ReadField(List.Blink));
pHwRfd = ReadField(HwRfd);
dprintf(" NdisPacket = %p , NdisBuffer = %p , HwRfd = %p\n",
ReadField(NdisPacket), ReadField(NdisBuffer), pHwRfd);
dprintf(" PacketSize = %d, ", (ULONG) ReadField(PacketSize));
Flags = (ULONG) ReadField(Flags);
dprintf("Flags 0x%x", Flags);
if(Flags & fMP_RFD_RECV_PEND)
{
dprintf(" RECV_PEND ");
}
if(Flags & fMP_RFD_ALLOC_PEND)
{
dprintf(" ALLOC_PEND ");
}
if(Flags & fMP_RFD_RECV_READY)
{
dprintf(" RECV_READY ");
}
if(Flags & fMP_RFD_RESOURCES)
{
dprintf(" RESOURCES ");
}
dprintf("\n");
if(Verbosity == 1)
{
PrintHwRfdDetails(pHwRfd);
}
}
void PrintHwRfdDetails(ULONG64 pHwRfd)
{
USHORT RfdStatus;
USHORT RfdCommand;
ULONG i;
InitTypeRead(pHwRfd, HW_RFD);
RfdStatus = (USHORT) ReadField(RfdCbHeader.CbStatus);
RfdCommand = (USHORT) ReadField(RfdCbHeader.CbCommand);
dprintf(" RfdCbHeader.CbStatus = 0x%04x", RfdStatus);
for(i = 0; i < sizeof(DbgRfdStatus)/sizeof(DBG_RFD_STATUS); i++)
{
if(RfdStatus & DbgRfdStatus[i].Val)
{
dprintf(", %s", DbgRfdStatus[i].Name);
}
}
dprintf("\n");
dprintf(" RfdCbHeader.CbCommand = %04x", RfdCommand);
for(i = 0; i < sizeof(DbgRfdCommand)/sizeof(DBG_RFD_COMMAND); i++)
{
if(RfdCommand & DbgRfdCommand[i].Val)
{
dprintf(", %s", DbgRfdCommand[i].Name);
}
}
dprintf("\n");
dprintf(" RfdCbHeader.CbLinkPointer = 0x%x\n", (ULONG)ReadField(RfdCbHeader.CbLinkPointer));
//dprintf(" RfdRbdPointer = 0x%x\n", (ULONG)ReadField(RfdRbdPointer));
dprintf(" RfdActualCount = %x , %d", (USHORT)ReadField(RfdActualCount), (USHORT)ReadField(RfdActualCount) & 0x3fff);
dprintf(", RfdSize = %d\n", (USHORT)ReadField(RfdSize));
}
DECLARE_API(recvpendlist)
{
ULONG64 pListHead;
ULONG64 pMpRfd;
ULONG64 pPacket;
int ArgCount = 0;
int index = 0;
if(*args)
{
ArgCount = sscanf(args,"%I64lx", &pListHead);
}
//check for arguments
if(ArgCount < 1)
{
dprintf("Usage: recvpendlist <RecvPendList address>\n");
return ;
}
SIGN_EXTEND(pListHead);
if(GetFieldValue(pListHead, "LIST_ENTRY", "Flink", pMpRfd))
{
dprintf("Failed to get LIST_ENTRY Flink at %p\n", pListHead);
return;
}
while(pMpRfd != pListHead)
{
dprintf(" (%d) pMpRfd %x :\n", index, pMpRfd);
PrintMpRfdDetails(pMpRfd, 0);
if(GetFieldValue(pMpRfd, "LIST_ENTRY", "Flink", pMpRfd))
{
dprintf("Failed to get LIST_ENTRY Flink at %p\n", pMpRfd);
break;
}
index++;
if(CheckControlC())
{
dprintf("***Control-C***\n");
break;
}
}
dprintf("RecvPendList has %d RFDs\n", index);
}
/**
Get 'size' bytes from the debuggee program at 'dwAddress' and place it
in our address space at 'ptr'. Use 'type' in an error printout if necessary
**/
BOOL GetData( IN LPVOID ptr, IN ULONG64 AddressPtr, IN ULONG size, IN PCSTR type )
{
BOOL b;
ULONG BytesRead;
ULONG count = size;
while(size > 0)
{
if(count >= 3000)
count = 3000;
b = ReadMemory(AddressPtr, ptr, count, &BytesRead );
if(!b || BytesRead != count)
{
dprintf( "Unable to read %u bytes at %X, for %s\n", size, AddressPtr, type );
return FALSE;
}
AddressPtr += count;
size -= count;
ptr = (LPVOID)((ULONG_PTR)ptr + count);
}
return TRUE;
}
/**
Routine to get offset and size of a "Field" of "Type" on a debugee machine. This uses
Ioctl call for type info.
Returns 0 on success, Ioctl error value otherwise.
**/
ULONG GetFieldOffsetAndSize(
IN LPSTR Type,
IN LPSTR Field,
OUT PULONG pOffset,
OUT PULONG pSize)
{
FIELD_INFO flds = {
Field, "", 0,
DBG_DUMP_FIELD_FULL_NAME | DBG_DUMP_FIELD_RETURN_ADDRESS | DBG_DUMP_FIELD_SIZE_IN_BITS,
0, NULL};
SYM_DUMP_PARAM Sym = {
sizeof (SYM_DUMP_PARAM), Type, DBG_DUMP_NO_PRINT, 0,
NULL, NULL, NULL, 1, &flds
};
ULONG Err, i=0;
LPSTR dot, last=Field;
Sym.nFields = 1;
Err = Ioctl( IG_DUMP_SYMBOL_INFO, &Sym, Sym.size );
*pOffset = (ULONG) (flds.address - Sym.addr);
*pSize = flds.size;
return Err;
}
ULONG GetUlongFromAddress (
ULONG64 Location)
{
ULONG Value;
ULONG result;
if((!ReadMemory(Location,&Value,sizeof(ULONG),&result)) ||
(result < sizeof(ULONG)))
{
dprintf("unable to read from %08x\n",Location);
return 0;
}
return Value;
}
ULONG64 GetPointerFromAddress(
ULONG64 Location)
{
ULONG64 Value;
ULONG result;
if(ReadPtr(Location,&Value))
{
dprintf("unable to read from %p\n",Location);
return 0;
}
return Value;
}
ULONG GetUlongValue (
PCHAR String)
{
ULONG64 Location;
ULONG Value;
ULONG result;
Location = GetExpression(String);
if(!Location)
{
dprintf("unable to get %s\n",String);
return 0;
}
return GetUlongFromAddress(Location);
}
ULONG64 GetPointerValue (
PCHAR String)
{
ULONG64 Location, Val=0;
Location = GetExpression(String);
if(!Location)
{
dprintf("unable to get %s\n",String);
return 0;
}
ReadPtr(Location, &Val);
return Val;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -