WinDbg 디버깅2007. 9. 23. 02:17
반응형

시스템 오브젝트의 정보를 보여주는 명령어입니다.

형식은 다음과 같이 사용할 수 있습니다.

!object Address
!object Path
!object 0 Name

아래 예제에서 각각의 경우에 대하여 설명합니다.

1) !object Address

오브젝트의 주소를 알고 있을 때 주소를 주면 오브젝트의 정보가 자세히 나옵니다.

아래 예제는 WinDbg Help 의 예제입니다.
!handle 의 결과를 보면 핸들이 어떤 오브젝트를 가리키는지 나옵니다.

kd> !handle
processor number 0
PROCESS 80a02920  Cid: 0002    Peb: 00000000  ParentCid: 0000
    DirBase: 0006c805  ObjectTable: 80a03788  TableSize:  54.
    Image: System
006c: Object: 80967768  GrantedAccess: 00100003
Object: 80967768  Type: (809d5c20) File
    ObjectHeader: 80967750
        HandleCount: 1  PointerCount: 1
        Directory Object: 00000000  Name: \WINNT\system32\config\software {Partition1}

이 정보는 !object 에서 나오는 결과와 동일합니다.

kd> !object 80967768
Object: 80967768  Type: (809d5c20) File
    ObjectHeader: 80967750
    HandleCount: 1  PointerCount: 1
    Directory Object: 00000000  Name: \WINNT\system32\config\software {Partition1}

오브젝트 주소를 알고 있다면 위와 같이 바로 !object 명령으로 자세한 정보를 볼 수 있습니다.


2) !object Path

!object 명령을 이용해서 오브젝트들의 구성을 볼 수 있습니다.
마치 winobj 유틸리티를 사용하는 것과 같은 느낌입니다.
먼저 Root 를 봅니다.

kd> !object \
Object: e1001690  Type: (81586490) Directory
    ObjectHeader: e1001678
    HandleCount: 0  PointerCount: 40
    Directory Object: 00000000  Name: \
    109 symbolic links snapped through this directory

    Hash Address  Type          Name
    ---- -------  ----          ----
     00  e1006850 Directory     ArcName
         81570218 Device        Ntfs
     01  e16839b8 Port          SeLsaCommandPort
     02  812d2818 Device        FatCdrom
     03  e1007160 Key           \REGISTRY
     05  e1711db8 Port          ThemeApiPort
     06  e1782888 Port          XactSrvLpcPort
     09  e14c4c38 Directory     NLS
     10  e1000150 SymbolicLink  DosDevices
     13  e135aa38 Port          SeRmCommandPort
     14  e16cdf18 Port          LsaAuthenticationPort
         814e8030 Device        Dfs
         813fdf18 Event         LanmanServerAnnounceEvent
     16  e1289f58 Directory     Driver
     19  e1006778 Directory     Device
     20  e13d8bb8 Directory     Windows
     21  813b1fc0 Event         SAM_SERVICE_STARTED
         e13d8a08 Directory     Sessions
     22  e13d8ae0 Directory     RPC Control
         e12e3400 Port          SmApiPort
         8131b400 Device        Fat
     23  e14c3030 Directory     BaseNamedObjects
         e1001510 Directory     KernelObjects
     24  e1289e80 Directory     FileSystem
         e1000308 Directory     GLOBAL??
     25  8129faa0 WaitablePort  NLAPublicPort
     26  e18cc1d0 Port          SmSsWinStationApiPort
         e1001428 Directory     ObjectTypes
     ...

Type 이 Directory 라고 되어 있는 것들은 하위에 다른 오브젝트들을 포함하고 있는 것입니다.
ObjectTypes 라는 Directory를 들여다 봅니다.

kd> !object \ObjectTypes
Object: e1001428  Type: (81586490) Directory
    ObjectHeader: e1001410
    HandleCount: 0  PointerCount: 25
    Directory Object: e1001690  Name: ObjectTypes

    Hash Address  Type          Name
    ---- -------  ----          ----
     00  81586490 Type          Directory
     01  8154d858 Type          Mutant
         81552ca0 Type          Thread
     03  81570a80 Type          FilterCommunicationPort
     05  8153c040 Type          Controller
     07  8154c040 Type          Profile
         8154dbf8 Type          Event
         81586660 Type          Type
     09  8154c880 Type          Section
         8154da28 Type          EventPair
         815862c0 Type          SymbolicLink
     10  8154cad0 Type          Desktop
     11  8154d2e8 Type          Timer
     12  8153c900 Type          File
         8154cca0 Type          WindowStation
     16  8153cca0 Type          Driver
     ...
     34  8154d4b8 Type          Semaphore

시스템에 존재하는 오브젝트 Type 들이 모두 보여집니다.

이번에는 FileSystem 이라는 Directory를 들여다 봅니다.

kd> !object \FileSystem
Object: e1289e80  Type: (81586490) Directory
    ObjectHeader: e1289e68
    HandleCount: 0  PointerCount: 23
    Directory Object: e1001690  Name: FileSystem

    Hash Address  Type          Name
    ---- -------  ----          ----
     00  81570340 Driver        Ntfs
     01  812d2040 Driver        Fastfat
         813c9040 Driver        NetBIOS
     02  815707c0 Driver        sr
     05  814284b0 Driver        Rdbss
     15  81425cc0 Driver        Msfs
     17  813c3cc0 Driver        MRxSmb
     18  8142a340 Device        UdfsCdRomRecognizer
     19  812d72e0 Driver        Srv
     24  81519628 Driver        Mup
         81537f38 Driver        RAW
     25  813bbf38 Driver        Npfs
         8149a368 Driver        Fs_Rec
     26  e1289da8 Directory     Filters
     30  813a0970 Driver        MRxVPC
     31  813d8bf8 Driver        Cdfs
     32  8137c138 Device        FatCdRomRecognizer
         813730e0 Device        CdfsRecognizer
         81570f38 Driver        FltMgr
     34  81382138 Device        FatDiskRecognizer
     35  812b9330 Driver        MRxDAV
     36  81456030 Device        UdfsDiskRecognizer

파일시스템으로 등록된 것들이 보이네요.
Filters Directory 로 한번 더 들어가 볼까요?

kd> !object \FileSystem\Filters
Object: e1289da8  Type: (81586490) Directory
    ObjectHeader: e1289d90
    HandleCount: 0  PointerCount: 4
    Directory Object: e1289e80  Name: Filters

    Hash Address  Type          Name
    ---- -------  ----          ----
     11  81570958 Device        FltMgrMsg
     31  81570698 Device        SystemRestore
     32  81570e10 Device        FltMgr

Filter Manager Device 인 FlgMgr 도 보이네요.

이처럼 시스템에 존재하는 Object 들의 구성을 마음대로 볼 수 있으므로 필요한 정보를 확인할 때 유용하게 사용할 수 있습니다.


3) !object 0 Name

Name 은 오브젝트의 Type 이름입니다.
특정 오브젝트를 찾을 때 사용할 수 있습니다.

File Type 인 것들을 찾아봅니다.

kd> !object 0 File
Scanning 1571 objects of type 'File'
Object: 8153be70  Type: (8153c900) File
    ObjectHeader: 8153be58
    HandleCount: 0  PointerCount: 1
Object: 815659a0  Type: (8153c900) File
    ObjectHeader: 81565988
    HandleCount: 0  PointerCount: 1
    Directory Object: 00000000  Name: \WINDOWS\system32\ntdll.dll {HarddiskVolume1}
Object: 814a2758  Type: (8153c900) File
    ObjectHeader: 814a2740
    HandleCount: 0  PointerCount: 1
    Directory Object: 00000000  Name: \WINDOWS\system32\drivers\vpc-8042.sys {HarddiskVolume1}
Object: 814a0090  Type: (8153c900) File
    ObjectHeader: 814a0078
    HandleCount: 0  PointerCount: 1
    Directory Object: 00000000  Name: \WINDOWS\system32\drivers\vpc-s3.sys {HarddiskVolume1}
Object: 81499918  Type: (8153c900) File
    ObjectHeader: 81499900
    HandleCount: 0  PointerCount: 1
    Directory Object: 00000000  Name: \WINDOWS\system32\drivers\vmsrvc.sys {HarddiskVolume1}
Object: 814991c0  Type: (8153c900) File
    ObjectHeader: 814991a8
    HandleCount: 0  PointerCount: 1
    Directory Object: 00000000  Name: \WINDOWS\system32\ntdll.dll {HarddiskVolume1}
Object: 8148a8e8  Type: (8153c900) File
    ObjectHeader: 8148a8d0
    HandleCount: 0  PointerCount: 1
    Directory Object: 00000000  Name: \WINDOWS\system32\drivers\vpc-8042.sys {HarddiskVolume1}
...

File Type 을 가진 모든 것들이 뿌려지므로 이 중에서 찾으려고 했던 특정 파일이 있는지 확인할 수 있습니다.

Driver Type 을 가지는 것들도 찾아봅니다.

kd> !object 0 Driver
Scanning 84 objects of type 'Driver'
Object: 8153c780  Type: (8153cca0) Driver
    ObjectHeader: 8153c768
    HandleCount: 0  PointerCount: 57
    Directory Object: e1289f58  Name: PnpManager
Object: 81581cf8  Type: (8153cca0) Driver
    ObjectHeader: 81581ce0
    HandleCount: 0  PointerCount: 4
    Directory Object: e1289f58  Name: ACPI_HAL
Object: 815819a0  Type: (8153cca0) Driver
    ObjectHeader: 81581988
    HandleCount: 0  PointerCount: 4
    Directory Object: e1289f58  Name: WMIxWDM
Object: 81537f38  Type: (8153cca0) Driver
    ObjectHeader: 81537f20
    HandleCount: 0  PointerCount: 5
    Directory Object: e1289e80  Name: RAW
Object: 81537a88  Type: (8153cca0) Driver
    ObjectHeader: 81537a70
    HandleCount: 0  PointerCount: 26
    Directory Object: e1289f58  Name: ACPI
Object: 81522948  Type: (8153cca0) Driver
    ObjectHeader: 81522930
    HandleCount: 0  PointerCount: 8
    Directory Object: e1289f58  Name: PCI
Object: 81575bd8  Type: (8153cca0) Driver
    ObjectHeader: 81575bc0
    HandleCount: 0  PointerCount: 6
    Directory Object: e1289f58  Name: isapnp
Object: 8151b518  Type: (8153cca0) Driver
    ObjectHeader: 8151b500
    HandleCount: 0  PointerCount: 5
    Directory Object: e1289f58  Name: IntelIde
...

시스템에 로드된 드라이버들의 리스트를 볼 수 있습니다.

몇가지 다른 타입의 오브젝트들에 대해서 해봤는데 다음과 같은 오류가 발생했습니다.

kd> !object 0 Process
Scanning 21 objects of type 'Process'
*** objects of the same type are only linked together if the 4000 flag is set in NtGlobalFlags
Total of 0 objects of type 'Process'

kd> !object 0 Thread
Scanning 312 objects of type 'Thread'
*** objects of the same type are only linked together if the 4000 flag is set in NtGlobalFlags
Total of 0 objects of type 'Thread'

kd> !object 0 Timer
Scanning 29 objects of type 'Timer'
*** objects of the same type are only linked together if the 4000 flag is set in NtGlobalFlags
Total of 0 objects of type 'Timer'

gflags.exe 를 사용해서 0x4000 플래그를 켜주면 정상적으로 보일 것 같기는 하지만 실제로 해 보지는 않았습니다.

사실 위에서 정상적으로 볼 수 있었던 File 과 Driver 같은 경우도 verifier 를 켰기 때문에 나오는 것이지 verifier 가 설정되지 않았다면 위와 같은 오류가 발생합니다.
이 점 때문에 일반적인 경우는 잘 써먹지 못하겠지만 특별히 이와 같은 디버깅이 필요할 경우를 만나시면 gflags.exe 로 플래그를 켜서 응용해 보시기 바랍니다. ^^

http://www.driveronline.org/bbs/view.asp?tb=tipbbs&GotoPage=3&s_bulu=&s_key=&no=69

반응형
Posted by GreeMate