关于进程创建时在驱动下获取命令行参数的问题

晚上在试图解决某个问题的时候,尝试在PROCESS CALLBACK下获取命令行参数,但是在WINDBG下调试的时候

1、先切换到目标进程
kd> .process /p 0x825da8d8
Implicit process is now 825da8d8

2、再输出PEB结构体信息
kd> dt _peb 0x7ffd3000
ntdll!_PEB
   +0x000 InheritedAddressSpace : 0 ''
   +0x001 ReadImageFileExecOptions : 0 ''
   +0x002 BeingDebugged    : 0 ''
   +0x003 SpareBool        : 0 ''
   +0x004 Mutant           : 0xffffffff Void
   +0x008 ImageBaseAddress : 0x00400000 Void
   +0x00c Ldr              : (null)
   +0x010 ProcessParameters : 0x00020000 _RTL_USER_PROCESS_PARAMETERS

3、最后输出命令行参数信息
kd> dt  _RTL_USER_PROCESS_PARAMETERS 0x00020000
ntdll!_RTL_USER_PROCESS_PARAMETERS
   +0x000 MaximumLength    : 0x1000
   +0x004 Length           : 0x748
   +0x008 Flags            : 0
   +0x00c DebugFlags       : 0
   +0x010 ConsoleHandle    : 0xfffffffe Void
   +0x014 ConsoleFlags     : 0
   +0x018 StandardInput    : (null)
   +0x01c StandardOutput   : 0x00010001 Void
   +0x020 StandardError    : (null)
   +0x024 CurrentDirectory : _CURDIR
   +0x030 DllPath          : _UNICODE_STRING "--- memory read error at address 0x00000498 ---"
   +0x038 ImagePathName    : _UNICODE_STRING "--- memory read error at address 0x000005fc ---"
   +0x040 CommandLine      : _UNICODE_STRING "--- memory read error at address 0x0000065c ---"
   +0x048 Environment      : 0x00010000 Void
   +0x04c StartingX        : 0
   +0x050 StartingY        : 0
   +0x054 CountX           : 0
   +0x058 CountY           : 0
   +0x05c CountCharsX      : 0
   +0x060 CountCharsY      : 0
   +0x064 FillAttribute    : 0
   +0x068 WindowFlags      : 0x401
   +0x06c ShowWindowFlags  : 1
   +0x070 WindowTitle      : _UNICODE_STRING "--- memory read error at address 0x000006c4 ---"
   +0x078 DesktopInfo      : _UNICODE_STRING "--- memory read error at address 0x00000724 ---"
   +0x080 ShellInfo        : _UNICODE_STRING "--- memory read error at address 0x00000744 ---"
   +0x088 RuntimeData      : _UNICODE_STRING ""
   +0x090 CurrentDirectores : [32] _RTL_DRIVE_LETTER_CURDIR

无法输出命令行参数字符串,开始误以为是还未填充命令行参数,后来继续用!PEB
kd> !peb 0x7ffd3000
PEB at 7ffd3000
    InheritedAddressSpace:    No
    ReadImageFileExecOptions: No
    BeingDebugged:            No
    ImageBaseAddress:         00400000
    Ldr                       00000000
    *** unable to read Ldr table at 00000000
    SubSystemData:     00000000
    ProcessHeap:       00000000
    ProcessParameters: 00020000
    CurrentDirectory:  '< Name not readable >'
    WindowTitle:  'C:\Program Files\Internet Explorer\iexplore.exe'
    ImageFile:    'C:\Program Files\Internet Explorer\iexplore.exe'
    CommandLine:  '"C:\Program Files\Internet Explorer\iexplore.exe" '
    DllPath:      'C:\Program Files\Internet Explorer;C:\WINDOWS\system32;C:\WINDOWS\system;C:\WINDOWS;.;C:\Program Files\Internet Explorer;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem'
    Environment:  00010000

缺可以显示,最后发现是_RTL_USER_PROCESS_PARAMETERS 结构体里的UNICODE_STRING的Buffer参数这时候保存的是相对于结构体_RTL_USER_PROCESS_PARAMETERS 的偏移。至此,问题解决。

posted @ 2012-01-26 21:59  robinh00d  阅读(1195)  评论(0编辑  收藏  举报