ia-32e模式简介
0: kd> rdmsr c0000080
msr[c0000080] = 00000000`00000d01
0: kd> .formats d01
Evaluate expression:
Hex: 00000000`00000d01
Decimal: 3329
Decimal (unsigned) : 3329
Octal: 0000000000000000006401
Binary: 00000000 00000000 00000000 00000000 00000000 00000000 00001101 00000001
Chars: ........
Time: Thu Jan 1 08:55:29 1970
Float: low 4.66492e-042 high 0
Double: 1.64474e-320
0: kd> r gdtr
gdtr=fffff80580a99fb0
0: kd> dq fffff80580a99fb0
fffff805`80a99fb0 00000000`00000000 00000000`00000000
fffff805`80a99fc0 00209b00`00000000 00409300`00000000
fffff805`80a99fd0 00cffb00`0000ffff 00cff300`0000ffff
fffff805`80a99fe0 0020fb00`00000000 00000000`00000000
fffff805`80a99ff0 80008ba9`80000067 00000000`fffff805
fffff805`80a9a000 0040f300`00003c00 00000000`00000000
fffff805`80a9a010 00000000`00000000 00000000`00000000
fffff805`80a9a020 00000000`00000000 00000000`00000000
0: kd> dg 10
P Si Gr Pr Lo
Sel Base Limit Type l ze an es ng Flags
---- ----------------- ----------------- ---------- - -- -- -- -- --------
0010 00000000`00000000 00000000`00000000 Code RE Ac 0 Nb By P Lo 0000029b
0: kd> dg 3*8
P Si Gr Pr Lo
Sel Base Limit Type l ze an es ng Flags
---- ----------------- ----------------- ---------- - -- -- -- -- --------
0018 00000000`00000000 00000000`00000000 Data RW Ac 0 Bg By P Nl 00000493
#include <wdm.h>
//#include <ntifs.h>
#define NTSTRSAFE_LIB
#include <ntstrsafe.h>
#include <intrin.h>
#pragma pack(1)
struct Attribute
{
UINT64 offset1 : 16;
UINT64 p : 1;
UINT64 dpl : 2;
UINT64 s : 1;
UINT64 type : 4;
UINT64 unuse : 6;
UINT64 ist : 2;
UINT64 selector : 16;
UINT64 offset2 : 16;
};
typedef struct _IDT_ENTRY64 {union hightStruct
{
UINT64 lower;
struct Attribute attribute;
};
UINT64 hight;
}IDT_ENTRY64, * PIDT_ENTRY64;typedef struct _IDTR
{
UINT16 limit;
UINT64 base;
}IDTR, *PIDTR;
#pragma pack()VOID Unload(PDRIVER_OBJECT pDriver) {
KdPrint(("unload\r\n"));}
NTSTATUS DriverEntry(PDRIVER_OBJECT pDriver, PUNICODE_STRING pRegPath) {
NTSTATUS status = STATUS_SUCCESS;pDriver->DriverUnload = Unload;
KdPrint(("start\r\n"));
//关闭smap和smep
UINT64 cr4 = __readcr4();
cr4 &= 0xffffffffffcfffff;
__writecr4(cr4);
IDTR idtr = { 0 };
PIDT_ENTRY64 idtEntryArr = NULL;
__sidt(&idtr);
KdPrint(("idt base:0x%llx, limit:0x%x\r\n",idtr.base ,idtr.limit));
if (idtr.base == NULL && idtr.limit <= 0) {
return STATUS_UNSUCCESSFUL;
}
idtEntryArr = (PIDT_ENTRY64)idtr.base;
DbgBreakPoint();
SIZE_T i = 0;
while (i < (idtr.limit / 16))
{
UINT64 hight = idtEntryArr->hight << 32;
UINT64 lower_1 = (idtEntryArr->lower & 0xffff000000000000) >> 32;
UINT64 lower_2 = (idtEntryArr->lower & 0x000000000000ffff);
UINT64 offset = hight + lower_1 + lower_2;
UINT16 selector = (idtEntryArr->lower & 0x00000000ffff0000) >> 16;KdPrint(("中断门 index=%llu---offset=0x%llx---selector=0x%x---p=%d---dpl=%d---type=%d---ist=%d\r\n",
i, offset, (UINT32)selector, (UINT32)idtEntryArr->attribute.p,
(UINT32)idtEntryArr->attribute.dpl, (UINT32)idtEntryArr->attribute.type,
(UINT32)idtEntryArr->attribute.ist));
i++;
idtEntryArr++;
}
KdPrint(("end\r\n"));
return status;
}
看雪ID:幺幺满地乱爬
https://bbs.kanxue.com/user-home-987725.htm
# 往期推荐
球分享
球点赞
球在看