3

在内核调试 Windows(XP SP3)机器时,我想找到用户模式地址的页面保护(实际上只是检查它是否是 No-Execute 页面)。

扩展 !vprot (它就是这样做的)在内核调试时不起作用。

我试图改变到这个用户模式地址空间(使用'.process /i'),然后在地址上调用!pte。但有时,PTE 条目是无效的,因为它被分页了(我认为)。

有什么建议么?

4

1 回答 1

4

您可以尝试 !vad 和 !address 的组合:

0: kd> !process 0 0 calc.exe
PROCESS 89e035f8  SessionId: 0  Cid: 021c    Peb: 7ffdd000  ParentCid: 00d4
    DirBase: 0aac0200  ObjectTable: e1f587a8  HandleCount:  44.
    Image: calc.exe

0: kd> .process /i 89e035f8  

使用!vad:

3: kd> !vad 0x1000000
VAD     level      start      end    commit
89e02578 (-1)       1000     101e         3 Mapped  Exe  EXECUTE_WRITECOPY  \WINDOWS\system32\calc.exe
3: kd> !vad 0x1014000
VAD     level      start      end    commit
89e02578 (-1)       1000     101e         3 Mapped  Exe  EXECUTE_WRITECOPY  \WINDOWS\system32\calc.exe

问题是 !vad 只为您提供整个页面范围的 vad,更准确地说是 vad 段的大小。显然 0x1000000 [PE Header] 和 0x1014000 [.data section] 的页面没有相同的保护。

使用!地址:

请注意,!address 命令将映射很多东西(包括 PTE / PFN 和 VAD):

3: kd> !address 0x1000000
Mapping user range ...
Mapping system range ...
Mapping page tables...
Mapping hyperspace...
Mapping HAL reserved range...
Mapping User Probe Area...
Mapping system shared page...
Mapping system cache working set...
Mapping loader mappings...
Mapping system PTEs...
Mapping system paged pool...
Mapping session space...
Mapping dynamic system space...
Mapping PFN database...
Mapping non paged pool...
Mapping VAD regions...
Mapping module regions...
Mapping process, thread, and stack regions...
Mapping system cache regions...

使用“-v”和“-map”选项:

3: kd> !address -v -map 0x1000000
PDE:    c0600040 [contains 20b9a867]

        Page Frame Number:  20b9a, at address: 00000000
        Page Location:      6 (ActiveAndValid)
        PTE Frame:          00020a98
        Attributes:         M:Modified,Cached
        Usage:              PTEs Process 89e035f8 [calc.exe], Entries:22

PTE:    c0008000 [contains 20d86025]

        Page Frame Number:  20d86, at address: 00000000
        Page Location:      6 (ActiveAndValid)
        PTE Frame:          00020384
        Attributes:         P:Prototype,M:Modified,Cached
        Usage:              MappedFile CA:8a1282e0 [\WINDOWS\system32\calc.exe]

Type:   Valid
Attrs:  Private,NormalPage,NotDirty,NotDirty1,Accessed,User,NotWritable,NotWriteThrough
PFN:    20d86

Attrs 输出提供了有用的信息。此时您也许可以使用 !pte 命令:

3: kd> !pte c0008000
                    VA 01000000
PDE at C0600040            PTE at C0008000
contains 0000000020B9A867  contains 0000000020D86025
pfn 20b9a     ---DA--UWEV  pfn 20d86     ----A--UREV

希望能解决你的问题。

于 2013-05-27T09:52:47.720 回答