#include <debug.h>
/* DEFINES *******************************************************************/
-//hack for amd64
-#define NPX_STATE_NOT_LOADED 0xA
-#define NPX_STATE_LOADED 0x0
#define KEY_BS 8
#define KEY_ESC 27
{ "SERIAL", DPFLTR_SERIAL_ID },
{ "SERENUM", DPFLTR_SERENUM_ID },
{ "UHCD", DPFLTR_UHCD_ID },
- { "BOOTOK", DPFLTR_BOOTOK_ID },
- { "BOOTVRFY", DPFLTR_BOOTVRFY_ID },
{ "RPCPROXY", DPFLTR_RPCPROXY_ID },
{ "AUTOCHK", DPFLTR_AUTOCHK_ID },
{ "DCOMSS", DPFLTR_DCOMSS_ID },
{ "STORPORT", DPFLTR_STORPORT_ID },
{ "STORMINIPORT", DPFLTR_STORMINIPORT_ID },
{ "PRINTSPOOLER", DPFLTR_PRINTSPOOLER_ID },
- };
+ { "VSSDYNDISK", DPFLTR_VSSDYNDISK_ID },
+ { "VERIFIER", DPFLTR_VERIFIER_ID },
+ { "VDS", DPFLTR_VDS_ID },
+ { "VDSBAS", DPFLTR_VDSBAS_ID },
+ { "VDSDYN", DPFLTR_VDSDYN_ID },
+ { "VDSDYNDR", DPFLTR_VDSDYNDR_ID },
+ { "VDSLDR", DPFLTR_VDSLDR_ID },
+ { "VDSUTIL", DPFLTR_VDSUTIL_ID },
+ { "DFRGIFC", DPFLTR_DFRGIFC_ID },
+ { "MM", DPFLTR_MM_ID },
+ { "DFSC", DPFLTR_DFSC_ID },
+ { "WOW64", DPFLTR_WOW64_ID },
+ { "ALPC", DPFLTR_ALPC_ID },
+ { "WDI", DPFLTR_WDI_ID },
+ { "PERFLIB", DPFLTR_PERFLIB_ID },
+ { "KTM", DPFLTR_KTM_ID },
+ { "IOSTRESS", DPFLTR_IOSTRESS_ID },
+ { "HEAP", DPFLTR_HEAP_ID },
+ { "WHEA", DPFLTR_WHEA_ID },
+ { "USERGDI", DPFLTR_USERGDI_ID },
+ { "MMCSS", DPFLTR_MMCSS_ID },
+ { "TPM", DPFLTR_TPM_ID },
+ { "THREADORDER", DPFLTR_THREADORDER_ID },
+ { "ENVIRON", DPFLTR_ENVIRON_ID },
+ { "EMS", DPFLTR_EMS_ID },
+ { "WDT", DPFLTR_WDT_ID },
+ { "FVEVOL", DPFLTR_FVEVOL_ID },
+ { "NDIS", DPFLTR_NDIS_ID },
+ { "NVCTRACE", DPFLTR_NVCTRACE_ID },
+ { "LUAFV", DPFLTR_LUAFV_ID },
+ { "APPCOMPAT", DPFLTR_APPCOMPAT_ID },
+ { "USBSTOR", DPFLTR_USBSTOR_ID },
+ { "SBP2PORT", DPFLTR_SBP2PORT_ID },
+ { "COVERAGE", DPFLTR_COVERAGE_ID },
+ { "CACHEMGR", DPFLTR_CACHEMGR_ID },
+ { "MOUNTMGR", DPFLTR_MOUNTMGR_ID },
+ { "CFR", DPFLTR_CFR_ID },
+ { "TXF", DPFLTR_TXF_ID },
+ { "KSECDD", DPFLTR_KSECDD_ID },
+ { "FLTREGRESS", DPFLTR_FLTREGRESS_ID },
+ { "MPIO", DPFLTR_MPIO_ID },
+ { "MSDSM", DPFLTR_MSDSM_ID },
+ { "UDFS", DPFLTR_UDFS_ID },
+ { "PSHED", DPFLTR_PSHED_ID },
+ { "STORVSP", DPFLTR_STORVSP_ID },
+ { "LSASS", DPFLTR_LSASS_ID },
+ { "SSPICLI", DPFLTR_SSPICLI_ID },
+ { "CNG", DPFLTR_CNG_ID },
+ { "EXFAT", DPFLTR_EXFAT_ID },
+ { "FILETRACE", DPFLTR_FILETRACE_ID },
+ { "XSAVE", DPFLTR_XSAVE_ID },
+ { "SE", DPFLTR_SE_ID },
+ { "DRIVEEXTENDER", DPFLTR_DRIVEEXTENDER_ID },
+ };
for (i = 0; i < sizeof(ComponentTable) / sizeof(ComponentTable[0]); i++)
{
return TRUE;
if (Result > (ULONGLONG)(~((ULONG_PTR)0)))
- KdbpPrint("Warning: Address %I64x is beeing truncated\n");
+ KdbpPrint("Warning: Address %I64x is beeing truncated\n",Result);
Address = (ULONG_PTR)Result;
}
if (!NT_SUCCESS(KdbpSafeReadMemory(&ul, (PVOID)Address, sizeof(ul))))
KdbpPrint(" ????????");
else
- KdbpPrint(" %x", ul);
+ KdbpPrint(" %08x", ul);
Address += sizeof(ul);
}
while (Count-- > 0)
{
if (!KdbSymPrintAddress((PVOID)Address))
- KdbpPrint("<%x>: ", Address);
+ KdbpPrint("<%08x>: ", Address);
else
KdbpPrint(": ");
{
PKTRAP_FRAME Tf = &KdbCurrentTrapFrame->Tf;
INT i;
- const PCHAR EflagsBits[32] = { " CF", NULL, " PF", " BIT3", " AF", " BIT5",
+ static const PCHAR EflagsBits[32] = { " CF", NULL, " PF", " BIT3", " AF", " BIT5",
" ZF", " SF", " TF", " IF", " DF", " OF",
NULL, NULL, " NT", " BIT15", " RF", " VF",
" AC", " VIF", " VIP", " ID", " BIT22",
" BIT23", " BIT24", " BIT25", " BIT26",
- " BIT27", " BIT28", " BIT29", " BIT30"
-
- };
+ " BIT27", " BIT28", " BIT29", " BIT30",
+ " BIT31" };
if (Argv[0][0] == 'r') /* regs */
{
- #ifdef _M_IX86
KdbpPrint("CS:EIP 0x%04x:0x%08x\n"
"SS:ESP 0x%04x:0x%08x\n"
" EAX 0x%08x EBX 0x%08x\n"
Tf->Ecx, Tf->Edx,
Tf->Esi, Tf->Edi,
Tf->Ebp);
-#elif defined(_M_AMD64)
- KdbpPrint("CS:RIP 0x%04x:0x%p\n"
- "SS:RSP 0x%04x:0x%p\n"
- " RAX 0x%p RBX 0x%p\n"
- " RCX 0x%p RDX 0x%p\n"
- " RSI 0x%p RDI 0x%p\n"
- " RBP 0x%p R8 0x%p\n"
- " R9 0x%p R10 0x%p\n"
- " R11 0x%p\n",
- Tf->SegCs & 0xFFFF, Tf->Rip,
- Tf->SegSs, Tf->Rsp,
- Tf->Rax, Tf->Rbx,
- Tf->Rcx, Tf->Rdx,
- Tf->Rsi, Tf->Rdi,
- Tf->Rbp, Tf->R8,
- Tf->R9, Tf->R10,
- Tf->R11);
-#endif
KdbpPrint("EFLAGS 0x%08x ", Tf->EFlags);
for (i = 0; i < 32; i++)
}
else if (Argv[0][0] == 'c') /* cregs */
{
- ULONG_PTR Cr0, Cr2, Cr3, Cr4;
+ ULONG Cr0, Cr2, Cr3, Cr4;
KDESCRIPTOR Gdtr, Idtr;
-#if defined(_M_IX86)
USHORT Ldtr;
- Ke386GetGlobalDescriptorTable(&Gdtr.Limit);
- Ldtr = Ke386GetLocalDescriptorTable();
-#elif defined(_M_AMD64)
- __sgdt(&Gdtr.Limit);
-#endif
static const PCHAR Cr0Bits[32] = { " PE", " MP", " EM", " TS", " ET", " NE", NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
" WP", NULL, " AM", NULL, NULL, NULL, NULL, NULL,
Cr3 = KdbCurrentTrapFrame->Cr3;
Cr4 = KdbCurrentTrapFrame->Cr4;
- /* Get interrupt descriptor table regs */
+ /* Get descriptor table regs */
+ Ke386GetGlobalDescriptorTable(&Gdtr.Limit);
+ Ldtr = Ke386GetLocalDescriptorTable();
__sidt(&Idtr.Limit);
/* Display the control registers */
- KdbpPrint("CR0 0x%p ", Cr0);
+ KdbpPrint("CR0 0x%08x ", Cr0);
for (i = 0; i < 32; i++)
{
KdbpPrint(Cr0Bits[i]);
}
- KdbpPrint("\nCR2 0x%p\n", Cr2);
- KdbpPrint("CR3 0x%p Pagedir-Base 0x%p %s%s\n", Cr3, (Cr3 & 0xfffff000),
+ KdbpPrint("\nCR2 0x%08x\n", Cr2);
+ KdbpPrint("CR3 0x%08x Pagedir-Base 0x%08x %s%s\n", Cr3, (Cr3 & 0xfffff000),
(Cr3 & (1 << 3)) ? " PWT" : "", (Cr3 & (1 << 4)) ? " PCD" : "" );
- KdbpPrint("CR4 0x%p ", Cr4);
+ KdbpPrint("CR4 0x%08x ", Cr4);
for (i = 0; i < 32; i++)
{
}
/* Display the descriptor table regs */
- KdbpPrint("\nGDTR Base 0x%p Size 0x%04x\n", Gdtr.Base, Gdtr.Limit);
-#ifdef _M_IX86
- KdbpPrint("LDTR 0x%p\n", Ldtr);
-#endif
- KdbpPrint("IDTR Base 0x%p Size 0x%04x\n", Idtr.Base, Idtr.Limit);
+ KdbpPrint("\nGDTR Base 0x%08x Size 0x%04x\n", Gdtr.Base, Gdtr.Limit);
+ KdbpPrint("LDTR 0x%04x\n", Ldtr);
+ KdbpPrint("IDTR Base 0x%08x Size 0x%04x\n", Idtr.Base, Idtr.Limit);
}
else if (Argv[0][0] == 's') /* sregs */
{
Tf->SegFs, Tf->SegFs >> 3, (Tf->SegFs & (1 << 2)) ? 'L' : 'G', Tf->SegFs & 3);
KdbpPrint("GS 0x%04x Index 0x%04x %cDT RPL%d\n",
Tf->SegGs, Tf->SegGs >> 3, (Tf->SegGs & (1 << 2)) ? 'L' : 'G', Tf->SegGs & 3);
-#ifdef _M_IX86
KdbpPrint("SS 0x%04x Index 0x%04x %cDT RPL%d\n",
Tf->HardwareSegSs, Tf->HardwareSegSs >> 3, (Tf->HardwareSegSs & (1 << 2)) ? 'L' : 'G', Tf->HardwareSegSs & 3);
-#else
- KdbpPrint("SS 0x%04x Index 0x%04x %cDT RPL%d\n",
- Tf->SegSs, Tf->SegSs >> 3, (Tf->SegSs & (1 << 2)) ? 'L' : 'G', Tf->SegSs & 3);
-#endif
-
}
else /* dregs */
{
ASSERT(Argv[0][0] == 'd');
- KdbpPrint("DR0 0x%p\n"
- "DR1 0x%p\n"
- "DR2 0x%p\n"
- "DR3 0x%p\n"
- "DR6 0x%p\n"
- "DR7 0x%p\n",
+ KdbpPrint("DR0 0x%08x\n"
+ "DR1 0x%08x\n"
+ "DR2 0x%08x\n"
+ "DR3 0x%08x\n"
+ "DR6 0x%08x\n"
+ "DR7 0x%08x\n",
Tf->Dr0, Tf->Dr1, Tf->Dr2, Tf->Dr3,
Tf->Dr6, Tf->Dr7);
}
ULONG Argc,
PCHAR Argv[])
{
- ULONG Count;
ULONG ul;
ULONGLONG Result = 0;
-#ifdef _M_IX86
ULONG_PTR Frame = KdbCurrentTrapFrame->Tf.Ebp;
-#elif defined(_M_AMD64)
- ULONG_PTR Frame = KdbCurrentTrapFrame->Tf.Rbp;
-#endif
ULONG_PTR Address;
if (Argc >= 2)
ul = strtoul(Argv[Argc-1], NULL, 0);
if (ul > 0)
{
- Count = ul;
Argc -= 2;
}
}
ul = strtoul(Argv[Argc-1] + 1, NULL, 0);
if (ul > 0)
{
- Count = ul;
Argc--;
}
}
return TRUE;
if (Result > (ULONGLONG)(~((ULONG_PTR)0)))
- KdbpPrint("Warning: Address %I64x is beeing truncated\n");
+ KdbpPrint("Warning: Address %I64x is beeing truncated\n",Result);
Frame = (ULONG_PTR)Result;
}
/* Try printing the function at EIP */
if (!KdbSymPrintAddress((PVOID)KdbCurrentTrapFrame->Tf.Eip))
- KdbpPrint("<%x>\n", KdbCurrentTrapFrame->Tf.Eip);
+ KdbpPrint("<%08x>\n", KdbCurrentTrapFrame->Tf.Eip);
else
KdbpPrint("\n");
}
break;
}
- if (!KdbSymPrintAddress((PVOID)Address))
- KdbpPrint("<%x>\n", Address);
+ /* Print the location of the call instruction */
+ if (!KdbSymPrintAddress((PVOID)(Address - 5)))
+ KdbpPrint("<%08x>\n", Address);
else
KdbpPrint("\n");
+ if (KdbOutputAborted) break;
+
if (Address == 0)
break;
{
GlobalOrLocal = Buffer;
sprintf(Buffer, " PID 0x%08lx",
- (ULONG_PTR)(Process ? Process->UniqueProcessId : INVALID_HANDLE_VALUE));
+ (ULONG)(Process ? Process->UniqueProcessId : INVALID_HANDLE_VALUE));
}
if (Type == KdbBreakPointSoftware || Type == KdbBreakPointTemporary)
Size = 2;
else if (_stricmp(Argv[2], "dword") == 0)
Size = 4;
- else if (_stricmp(Argv[2], "qword") == 0)
- Size = 8;
else if (AccessType == KdbAccessExec)
{
Size = 1;
}
if (Result > (ULONGLONG)(~((ULONG_PTR)0)))
- KdbpPrint("%s: Warning: Address %I64x is beeing truncated\n", Argv[0]);
+ KdbpPrint("%s: Warning: Address %I64x is beeing truncated\n", Argv[0],Result);
Address = (ULONG_PTR)Result;
PETHREAD Thread = NULL;
PEPROCESS Process = NULL;
BOOLEAN ReferencedThread = FALSE, ReferencedProcess = FALSE;
- PULONG_PTR Esp;
- PULONG_PTR Ebp;
- ULONG_PTR Eip;
- ULONG_PTR ul = 0;
+ PULONG Esp;
+ PULONG Ebp;
+ ULONG Eip;
+ ULONG ul = 0;
PCHAR State, pend, str1, str2;
static const PCHAR ThreadStateToString[DeferredReady+1] =
{
str2 = "";
}
- if (Thread->Tcb.TrapFrame)
+ if (!Thread->Tcb.InitialStack)
+ {
+ /* Thread has no kernel stack (probably terminated) */
+ Esp = Ebp = NULL;
+ Eip = 0;
+ }
+ else if (Thread->Tcb.TrapFrame)
{
-#ifdef _M_IX86
if (Thread->Tcb.TrapFrame->PreviousPreviousMode == KernelMode)
Esp = (PULONG)Thread->Tcb.TrapFrame->TempEsp;
else
Ebp = (PULONG)Thread->Tcb.TrapFrame->Ebp;
Eip = Thread->Tcb.TrapFrame->Eip;
-
-#elif defined(_M_AMD64)
- Esp = (PULONG_PTR)Thread->Tcb.TrapFrame->Rsp;
-
- Ebp = (PULONG_PTR)Thread->Tcb.TrapFrame->Rbp;
- Eip = Thread->Tcb.TrapFrame->Eip;
-#endif
}
else
{
- Esp = (PULONG_PTR)Thread->Tcb.KernelStack;
- Ebp = (PULONG_PTR)Esp[4];
+ Esp = (PULONG)Thread->Tcb.KernelStack;
+ Ebp = (PULONG)Esp[4];
Eip = 0;
if (Ebp) /* FIXME: Should we attach to the process to read Ebp[1]? */
else
State = "Unknown";
- KdbpPrint(" %s0x%p %-11s %3d 0x%p 0x%p 0x%p%s\n",
+ KdbpPrint(" %s0x%08x %-11s %3d 0x%08x 0x%08x 0x%08x%s\n",
str1,
Thread->Cid.UniqueThread,
State,
" State: %s (0x%x)\n"
" Priority: %d\n"
" Affinity: 0x%08x\n"
- " Initial Stack: 0x%p\n"
- " Stack Limit: 0x%p\n"
- " Stack Base: 0x%p\n"
- " Kernel Stack: 0x%p\n"
- " Trap Frame: 0x%p\n"
+ " Initial Stack: 0x%08x\n"
+ " Stack Limit: 0x%08x\n"
+ " Stack Base: 0x%08x\n"
+ " Kernel Stack: 0x%08x\n"
+ " Trap Frame: 0x%08x\n"
" NPX State: %s (0x%x)\n",
(Argc < 2) ? "Current Thread:\n" : "",
Thread->Cid.UniqueThread,
PEPROCESS Process;
BOOLEAN ReferencedProcess = FALSE;
PCHAR State, pend, str1, str2;
- ULONG_PTR ul;
+ ULONG ul;
extern LIST_ENTRY PsActiveProcessHead;
if (Argc >= 2 && _stricmp(Argv[1], "list") == 0)
return TRUE;
}
- KdbpPrint("Attached to process 0x%x, thread 0x%x.\n", ul,
- (ULONG_PTR)KdbCurrentThread->Cid.UniqueThread);
+ KdbpPrint("Attached to process 0x%08x, thread 0x%08x.\n", (ULONG)ul,
+ (ULONG)KdbCurrentThread->Cid.UniqueThread);
}
else
{
}
if (Result > (ULONGLONG)(~((ULONG_PTR)0)))
- KdbpPrint("%s: Warning: Address %I64x is beeing truncated\n", Argv[0]);
+ KdbpPrint("%s: Warning: Address %I64x is beeing truncated\n", Argv[0],Result);
Address = (ULONG_PTR)Result;
{
ULONG_PTR ntoskrnlBase = ((ULONG_PTR)KdbpCmdMod) & 0xfff00000;
KdbpPrint(" Base Size Name\n");
- KdbpPrint(" %p %x %s\n", ntoskrnlBase, 0, "ntoskrnl.exe");
+ KdbpPrint(" %08x %08x %s\n", ntoskrnlBase, 0, "ntoskrnl.exe");
return TRUE;
}
KdbpPrint(" Base Size Name\n");
for (;;)
{
- KdbpPrint(" %p %x %wZ\n", LdrEntry->DllBase, LdrEntry->SizeOfImage, &LdrEntry->BaseDllName);
+ KdbpPrint(" %08x %08x %wZ\n", LdrEntry->DllBase, LdrEntry->SizeOfImage, &LdrEntry->BaseDllName);
if(DisplayOnlyOneModule || !KdbpSymFindModule(NULL, NULL, i++, &LdrEntry))
break;
/*!\brief Displays GDT, LDT or IDTd.
*/
-#ifdef _M_AMD64
-static BOOLEAN
-KdbpCmdGdtLdtIdt(
- ULONG Argc,
- PCHAR Argv[])
-{
- KDESCRIPTOR Reg;
- KIDTENTRY IdtEntry;
- KGDTENTRY GdtEntry;
- ULONG_PTR SegBase;
- ULONG SegLimit;
- PCHAR SegType;
- USHORT SegSel;
- UCHAR Type, Dpl;
- INT i = 0;
- ULONG ul;
-
- if (Argv[0][0] == 'i')
- {
- /* Read IDTR */
- __sidt(&Reg.Limit);
-
- if (Reg.Limit < 7)
- {
- KdbpPrint("Interrupt descriptor table is empty.\n");
- return TRUE;
- }
-
- KdbpPrint("IDT Base: 0x%p Limit: 0x%04x\n", Reg.Base, Reg.Limit);
- KdbpPrint(" Idx Type Seg. Sel. Offset DPL\n");
-
- while (i < (Reg.Limit)/sizeof(IdtEntry))
- {
- if (!NT_SUCCESS(KdbpSafeReadMemory(&IdtEntry, (PVOID)((ULONG_PTR)Reg.Base +(i *sizeof(IdtEntry))), sizeof(IdtEntry))))
- {
- KdbpPrint("Couldn't access memory at 0x%x!\n", (ULONG_PTR)Reg.Base + sizeof(IdtEntry));
- return TRUE;
- }
-
- Dpl = IdtEntry.Dpl;
- if (IdtEntry.Type == 0x5) /* Task gate */
- SegType = "TASKGATE";
- else if (IdtEntry.Type == 0xE) /* 32 bit Interrupt gate */
- SegType = "INTGATE32";
- else if (IdtEntry.Type == 0x6) /* 16 bit Interrupt gate */
- SegType = "INTGATE16";
- else if (IdtEntry.Type == 0xF) /* 32 bit Trap gate */
- SegType = "TRAPGATE32";
- else if (IdtEntry.Type == 0x7) /* 16 bit Trap gate */
- SegType = "TRAPGATE16";
- else
- SegType = "UNKNOWN";
-
- if (IdtEntry.Present == 0) /* not present */
- {
- KdbpPrint(" %03d %-10s [NP] [NP] %02d\n",
- i, SegType, Dpl);
- }
- else if (IdtEntry.Type == 0x5) /* Task gate */
- {
- SegSel = IdtEntry.Selector;
- KdbpPrint(" %03d %-10s 0x%04x %02d\n",
- i, SegType, SegSel, Dpl);
- }
- else
- {
- SegSel = IdtEntry.Selector;
- SegBase = (ULONG64)IdtEntry.OffsetLow |
- (ULONG64)IdtEntry.OffsetMiddle << 16 |
- (ULONG64)IdtEntry.OffsetHigh << 32;
-
- KdbpPrint(" %03d %-10s 0x%04x 0x%p %02d\n",
- i , SegType, SegSel, SegBase, Dpl);
- }
- i++;
- }
- }
- else
- {
- ul = 0;
-
- if (Argv[0][0] == 'g')
- {
- /* Read GDTR */
- __sgdt(&Reg.Limit);
-
- }
- else
- {
- ASSERT(Argv[0][0] == 'l');
-
- /* Read LDTR */
- __sldt(&Reg.Limit);
-
- Reg.Base = 0;
- ul = 1 << 2;
- }
-
- if (Reg.Limit < 7)
- {
- KdbpPrint("%s descriptor table is empty.\n",
- Argv[0][0] == 'g' ? "Global" : "Local");
- return TRUE;
- }
-
- KdbpPrint("%cDT Base: 0x%p Limit: 0x%04x\n",
- Argv[0][0] == 'g' ? 'G' : 'L', Reg.Base, Reg.Limit);
- KdbpPrint(" Idx Sel. Type Base Limit DPL Attribs\n");
-
- while (i < (Reg.Limit)/sizeof(GdtEntry))
- {
- if (!NT_SUCCESS(KdbpSafeReadMemory(&GdtEntry, (PVOID)((ULONG_PTR)Reg.Base +(i * 8)), sizeof(GdtEntry))))
- {
- KdbpPrint("Couldn't access memory at 0x%p!\n", (ULONG_PTR)Reg.Base + i);
- return TRUE;
- }
-
- Dpl = GdtEntry.Bits.Dpl;
- Type = GdtEntry.Bits.Type;
-
- SegBase = (ULONG_PTR)KiGetGdtDescriptorBase(&GdtEntry);
-
- SegLimit = GdtEntry.LimitLow;
- SegLimit |= (ULONG64)GdtEntry.Bits.LimitHigh << 32;
-
- if (GdtEntry.Bits.DefaultBig != 0)
- {
- SegLimit *= 4096;
- SegLimit += 4095;
- }
- else
- {
- SegLimit++;
- }
-
- if (GdtEntry.Bits.System == 1) /* System segment */
- {
- switch (Type)
- {
- case 1: SegType = "TSS16(Avl)"; break;
- case 2: SegType = "LDT"; break;
- case 3: SegType = "TSS16(Busy)"; break;
- case 4: SegType = "CALLGATE16"; break;
- case 5: SegType = "TASKGATE"; break;
- case 6: SegType = "INTGATE16"; break;
- case 7: SegType = "TRAPGATE16"; break;
- case 9: SegType = "TSS32(Avl)"; break;
- case 11: SegType = "TSS32(Busy)"; break;
- case 12: SegType = "CALLGATE32"; break;
- case 14: SegType = "INTGATE32"; break;
- case 15: SegType = "INTGATE32"; break;
- default: SegType = "UNKNOWN"; break;
- }
-
- if (!(Type >= 1 && Type <= 3) &&
- Type != 9 && Type != 11)
- {
- SegBase = 0;
- SegLimit = 0;
- }
- }
- else if ((Type & (1 << 3)) == 0) /* Data segment */
- {
- if (GdtEntry.Bits.LongMode != 0)
- SegType = "DATA32";
- else
- SegType = "DATA16";
- }
- else /* Code segment */
- {
- if (GdtEntry.Bits.LongMode != 0)
- SegType = "CODE32";
- else
- SegType = "CODE16";
- }
-
- if (GdtEntry.Bits.Present == 0) /* not present */
- {
- KdbpPrint(" %03d 0x%04x %-11s [NP] [NP] %02d NP\n",
- i, i | Dpl | ul, SegType, Dpl);
- }
- else
- {
- KdbpPrint(" %03d 0x%04x %-11s 0x%p 0x%08x %02d ",
- i, i | Dpl | ul, SegType, SegBase, SegLimit, Dpl);
-
- if (GdtEntry.Bits.System == 1) /* System segment */
- {
- /* FIXME: Display system segment */
- /* they are twice as big as regular segments */
- i++;
- }
- else if ((Type & (1 << 3)) == 0) /* Data segment */
- {
- if ((Type & (1 << 2)) != 0) /* Expand-down */
- KdbpPrint(" E");
-
- KdbpPrint((Type & (1 << 1)) ? " R/W" : " R");
-
- if ((Type & (1 >> 1)) != 0)
- KdbpPrint(" A");
- }
- else /* Code segment */
- {
- if ((Type & (1 << 2)) != 0) /* Conforming */
- KdbpPrint(" C");
-
- KdbpPrint((Type & (1 << 1)) ? " R/X" : " X");
-
- if ((Type & (1 << 1)) != 0)
- KdbpPrint(" A");
- }
-
- if ((GdtEntry.Bits.LimitHigh & (1 << 3)) != 0)
- KdbpPrint(" AVL");
-
- KdbpPrint("\n");
- }
- i++;
- }
- }
-
- return TRUE;
-}
-#endif
-
-/*!\brief Displays GDT, LDT or IDTd.
- */
-#ifdef _M_IX86
static BOOLEAN
KdbpCmdGdtLdtIdt(
ULONG Argc,
for (i = 0; (i + sizeof(SegDesc) - 1) <= Reg.Limit; i += 8)
{
- if (!NT_SUCCESS(KdbpSafeReadMemory(SegDesc, (PVOID)((ULONG_PTR)Reg.Base + i), sizeof(SegDesc))))
+ if (!NT_SUCCESS(KdbpSafeReadMemory(SegDesc, (PVOID)(Reg.Base + i), sizeof(SegDesc))))
{
- KdbpPrint("Couldn't access memory at 0x%08x!\n", (ULONG_PTR)Reg.Base + i);
+ KdbpPrint("Couldn't access memory at 0x%08x!\n", Reg.Base + i);
return TRUE;
}
for (; (i + sizeof(SegDesc) - 1) <= Reg.Limit; i += 8)
{
- if (!NT_SUCCESS(KdbpSafeReadMemory(SegDesc, (PVOID)((ULONG_PTR)Reg.Base + i), sizeof(SegDesc))))
+ if (!NT_SUCCESS(KdbpSafeReadMemory(SegDesc, (PVOID)(Reg.Base + i), sizeof(SegDesc))))
{
- KdbpPrint("Couldn't access memory at 0x%08x!\n", (ULONG_PTR)Reg.Base + i);
+ KdbpPrint("Couldn't access memory at 0x%08x!\n", Reg.Base + i);
return TRUE;
}
return TRUE;
}
-#endif
/*!\brief Displays the KPCR
*/
{
PKIPCR Pcr = (PKIPCR)KeGetPcr();
-#ifdef _M_IX86
KdbpPrint("Current PCR is at 0x%08x.\n", (INT)Pcr);
KdbpPrint(" Tib.ExceptionList: 0x%08x\n"
" Tib.StackBase: 0x%08x\n"
Pcr->NtTib.Self, Pcr->Self, Pcr->Prcb, Pcr->Irql, Pcr->IRR, Pcr->IrrActive,
Pcr->IDR, Pcr->KdVersionBlock, Pcr->IDT, Pcr->GDT, Pcr->TSS,
Pcr->MajorVersion, Pcr->MinorVersion, Pcr->SetMember, Pcr->StallScaleFactor,
- Pcr->Number, Pcr->L2CacheAssociativity,
+ Pcr->Number, Pcr->SecondLevelCacheAssociativity,
Pcr->VdmAlert, Pcr->SecondLevelCacheSize, Pcr->InterruptMode);
-#elif defined(_M_AMD64)
- KdbpPrint("Current PCR is at 0x%x.\n", (INT_PTR)Pcr);
- KdbpPrint(" Tib.ExceptionList: 0x%p\n"
- " Tib.StackBase: 0x%p\n"
- " Tib.StackLimit: 0x%x\n"
- " Tib.SubSystemTib: 0x%p\n"
- " Tib.FiberData/Version: 0x%x\n"
- " Tib.ArbitraryUserPointer: 0x%p\n"
- " Tib.Self: 0x%p\n"
- " Self: 0x%p\n"
- " PCRCB: 0x%p\n"
- " Irql: 0x%x\n"
- " KdVersionBlock: 0x%08x\n"
- " IDT: 0x%p\n"
- " GDT: 0x%p\n"
- " TSS: 0x%p\n"
- " UserRsp: 0x%p\n"
- " MajorVersion: 0x%04x\n"
- " MinorVersion: 0x%04x\n"
- " StallScaleFactor: 0x%08x\n"
- " L2CacheAssociativity: 0x%02x\n"
- " L2CacheSize: 0x%08x\n",
- Pcr->NtTib.ExceptionList, Pcr->NtTib.StackBase, Pcr->NtTib.StackLimit,
- Pcr->NtTib.SubSystemTib, Pcr->NtTib.FiberData, Pcr->NtTib.ArbitraryUserPointer,
- Pcr->NtTib.Self, Pcr->Self, Pcr->Prcb, Pcr->Irql,
- Pcr->KdVersionBlock, Pcr->IdtBase, Pcr->GdtBase, Pcr->TssBase,Pcr->UserRsp,
- Pcr->MajorVersion, Pcr->MinorVersion, Pcr->StallScaleFactor,
- Pcr->SecondLevelCacheAssociativity, Pcr->SecondLevelCacheSize);
-#endif
+
return TRUE;
}
ULONG Argc,
PCHAR Argv[])
{
-#ifdef _M_IX86
KTSS *Tss = KeGetPcr()->TSS;
- KdbpPrint("Current TSS is at 0x%p.\n", (INT_PTR)Tss);
- KdbpPrint(" Eip: 0x%p\n"
+ KdbpPrint("Current TSS is at 0x%08x.\n", (INT)Tss);
+ KdbpPrint(" Eip: 0x%08x\n"
" Es: 0x%04x\n"
" Cs: 0x%04x\n"
" Ss: 0x%04x\n"
" Gs: 0x%04x\n"
" IoMapBase: 0x%04x\n",
Tss->Eip, Tss->Es, Tss->Cs, Tss->Ds, Tss->Fs, Tss->Gs, Tss->IoMapBase);
-#elif defined(_M_AMD64)
- KTSS *Tss = KeGetPcr()->TssBase;
-
- KdbpPrint("Current TSS is at 0x%p.\n", (INT_PTR)Tss);
- KdbpPrint(" Rsp0: 0x%p\n"
- " Rsp1: 0x%p\n"
- " Rsp2: 0x%p\n"
- " Ist: 0x%p\n"
- " IoMapBase: 0x%04x\n",
- Tss->Rsp0, Tss->Rsp1, Tss->Rsp2, Tss->Ist, Tss->IoMapBase);
-#endif
+
return TRUE;
}
*/
if (Buffer == Orig)
{
- strncpy(Buffer, LastCommand, Size);
- Buffer[Size - 1] = '\0';
+ RtlStringCbCopyA(Buffer, Size, LastCommand);
}
else
{
*Buffer = '\0';
- strncpy(LastCommand, Orig, sizeof (LastCommand));
- LastCommand[sizeof (LastCommand) - 1] = '\0';
+ RtlStringCbCopyA(LastCommand, sizeof(LastCommand), Orig);
}
return;
static PCH Argv[256];
static CHAR OrigCommand[1024];
- strncpy(OrigCommand, Command, sizeof(OrigCommand) - 1);
- OrigCommand[sizeof(OrigCommand) - 1] = '\0';
+ RtlStringCbCopyA(OrigCommand, sizeof(OrigCommand), Command);
Argc = 0;
p = Command;
/* Call the command */
Continue = KdbpDoCommand(Command);
+ KdbOutputAborted = FALSE;
}
while (Continue);
}
KdbpTryGetCharKeyboard(&DummyScanCode, 5);
}
- /*
+ /*
* Null terminate the output string -- documentation states that
* DbgPrompt does not null terminate, but it does
*/
/* Print a new line */
KdPortPutByteEx(&SerialPortInfo, '\r');
- KdPortPutByteEx(&SerialPortInfo, '\n');
+ KdPortPutByteEx(&SerialPortInfo, '\n');
/* Release spinlock */
KiReleaseSpinLock(&KdpSerialSpinLock);
/* Return the length */
return OutStringLength;
-}
\ No newline at end of file
+}