익히 알려진 것들이겠지만... 정리차원에서 살포시 올려봅니다.
일단 "프로세스" 에 대한 전체 경로이기 때문에 EPROCESS 에서부터 시작합니다. ^^;;;;
편의상 WinXP SP3 OS 환경 하의 notepad.exe 를 타겟으로 잡고 진행합니다. ^^;;
( XP 이상이면 가능할 것으로 생각됩니다...ㅎ )
타겟으로 잡은 notepad.exe 의 EPROCESS 는 다음과 같습니다.
kd> dt nt!_EPROCESS 85f92020
+0x000 Pcb : _KPROCESS
+0x06c ProcessLock : _EX_PUSH_LOCK
+0x070 CreateTime : _LARGE_INTEGER 0x1cd567a`80b6038c
+0x078 ExitTime : _LARGE_INTEGER 0x0
+0x080 RundownProtect : _EX_RUNDOWN_REF
+0x084 UniqueProcessId : 0x0000047c Void
+0x088 ActiveProcessLinks : _LIST_ENTRY [ 0x8055c258 - 0x8616e510 ]
+0x090 QuotaUsage : [3] 0xaa0
+0x09c QuotaPeak : [3] 0xca8
+0x0a8 CommitCharge : 0x1e8
+0x0ac PeakVirtualSize : 0x2483000
+0x0b0 VirtualSize : 0x1fcf000
+0x0b4 SessionProcessLinks : _LIST_ENTRY [ 0xf7b04014 - 0x8616e53c ]
+0x0bc DebugPort : (null)
+0x0c0 ExceptionPort : 0xe13c3f68 Void
+0x0c4 ObjectTable : 0xe104e4c0 _HANDLE_TABLE
+0x0c8 Token : _EX_FAST_REF
+0x0cc WorkingSetLock : _FAST_MUTEX
+0x0ec WorkingSetPage : 0x17237
+0x0f0 AddressCreationLock : _FAST_MUTEX
+0x110 HyperSpaceLock : 0
+0x114 ForkInProgress : (null)
+0x118 HardwareTrigger : 0
+0x11c VadRoot : 0x861ace78 Void
+0x120 VadHint : 0x861483d0 Void
+0x124 CloneRoot : (null)
+0x128 NumberOfPrivatePages : 0xdf
+0x12c NumberOfLockedPages : 0
+0x130 Win32Process : 0xe1070558 Void
+0x134 Job : (null)
+0x138 SectionObject : 0xe19085f8 Void
+0x13c SectionBaseAddress : 0x01000000 Void
+0x140 QuotaBlock : 0x862dcb88 _EPROCESS_QUOTA_BLOCK
+0x144 WorkingSetWatch : (null)
+0x148 Win32WindowStation : 0x0000003c Void
+0x14c InheritedFromUniqueProcessId : 0x00000630 Void
+0x150 LdtInformation : (null)
+0x154 VadFreeHint : (null)
+0x158 VdmObjects : (null)
+0x15c DeviceMap : 0xe18307b0 Void
+0x160 PhysicalVadList : _LIST_ENTRY [ 0x85f92180 - 0x85f92180 ]
+0x168 PageDirectoryPte : _HARDWARE_PTE
+0x168 Filler : 0
+0x170 Session : 0xf7b04000 Void
+0x174 ImageFileName : [16] "notepad.exe"
+0x184 JobLinks : _LIST_ENTRY [ 0x0 - 0x0 ]
+0x18c LockedPagesList : (null)
+0x190 ThreadListHead : _LIST_ENTRY [ 0x860305d4 - 0x860305d4 ]
+0x198 SecurityPort : (null)
+0x19c PaeTop : 0xf7ca21a0 Void
+0x1a0 ActiveThreads : 1
+0x1a4 GrantedAccess : 0x1f0fff
+0x1a8 DefaultHardErrorProcessing : 1
+0x1ac LastThreadExitStatus : 0n0
+0x1b0 Peb : 0x7ffd3000 _PEB
+0x1b4 PrefetchTrace : _EX_FAST_REF
+0x1b8 ReadOperationCount : _LARGE_INTEGER 0x1
+0x1c0 WriteOperationCount : _LARGE_INTEGER 0x0
+0x1c8 OtherOperationCount : _LARGE_INTEGER 0x7f
+0x1d0 ReadTransferCount : _LARGE_INTEGER 0xc
+0x1d8 WriteTransferCount : _LARGE_INTEGER 0x0
+0x1e0 OtherTransferCount : _LARGE_INTEGER 0x198
+0x1e8 CommitChargeLimit : 0
+0x1ec CommitChargePeak : 0x1e9
+0x1f0 AweInfo : (null)
+0x1f4 SeAuditProcessCreationInfo : _SE_AUDIT_PROCESS_CREATION_INFO
+0x1f8 Vm : _MMSUPPORT
+0x238 LastFaultCount : 0
+0x23c ModifiedPageCount : 0x21
+0x240 NumberOfVads : 0x44
+0x244 JobStatus : 0
+0x248 Flags : 0xd0800
+0x248 CreateReported : 0y0
+0x248 NoDebugInherit : 0y0
+0x248 ProcessExiting : 0y0
+0x248 ProcessDelete : 0y0
+0x248 Wow64SplitPages : 0y0
+0x248 VmDeleted : 0y0
+0x248 OutswapEnabled : 0y0
+0x248 Outswapped : 0y0
+0x248 ForkFailed : 0y0
+0x248 HasPhysicalVad : 0y0
+0x248 AddressSpaceInitialized : 0y10
+0x248 SetTimerResolution : 0y0
+0x248 BreakOnTermination : 0y0
+0x248 SessionCreationUnderway : 0y0
+0x248 WriteWatch : 0y0
+0x248 ProcessInSession : 0y1
+0x248 OverrideAddressSpace : 0y0
+0x248 HasAddressSpace : 0y1
+0x248 LaunchPrefetched : 0y1
+0x248 InjectInpageErrors : 0y0
+0x248 VmTopDown : 0y0
+0x248 Unused3 : 0y0
+0x248 Unused4 : 0y0
+0x248 VdmAllowed : 0y0
+0x248 Unused : 0y00000 (0)
+0x248 Unused1 : 0y0
+0x248 Unused2 : 0y0
+0x24c ExitStatus : 0n259
+0x250 NextPageColor : 0xdf34
+0x252 SubSystemMinorVersion : 0 ''
+0x253 SubSystemMajorVersion : 0x4 ''
+0x252 SubSystemVersion : 0x400
+0x254 PriorityClass : 0x2 ''
+0x255 WorkingSetAcquiredUnsafe : 0 ''
+0x258 Cookie : 0x817205b5
EPROCESS 의 여러 정보들 중에서 SectionObject, Peb, SeAuditProcessCreationInfo ...
이상의 세가지를 통해 전체경로를 구해보도록 하겠습니다. ( 물론 다른 방법도 있을 수 있겠죠..^^;; )
1. Peb
유저레벨에서도 접근이 가능한 Peb 를 이용하는 것이 가장 일반적인 방법이 아닐까 싶네요.
Peb 에는 다음과 같은 정보들이 있습니다.
kd> dt nt!_PEB 0x7ffd3000
+0x000 InheritedAddressSpace : 0 ''
+0x001 ReadImageFileExecOptions : 0 ''
+0x002 BeingDebugged : 0 ''
+0x003 SpareBool : 0 ''
+0x004 Mutant : 0xffffffff Void
+0x008 ImageBaseAddress : 0x01000000 Void
+0x00c Ldr : 0x001a1e90 _PEB_LDR_DATA
+0x010 ProcessParameters : 0x00020000 _RTL_USER_PROCESS_PARAMETERS
+0x014 SubSystemData : (null)
+0x018 ProcessHeap : 0x000a0000 Void
+0x01c FastPebLock : 0x7c9b0620 _RTL_CRITICAL_SECTION
+0x020 FastPebLockRoutine : 0x7c931000 Void
+0x024 FastPebUnlockRoutine : 0x7c9310e0 Void
+0x028 EnvironmentUpdateCount : 1
+0x02c KernelCallbackTable : 0x77cf2970 Void
+0x030 SystemReserved : [1] 0
+0x034 AtlThunkSListPtr32 : 0
+0x038 FreeList : (null)
+0x03c TlsExpansionCounter : 0
+0x040 TlsBitmap : 0x7c9b05e0 Void
+0x044 TlsBitmapBits : [2] 0x3fffff
+0x04c ReadOnlySharedMemoryBase : 0x7f6f0000 Void
+0x050 ReadOnlySharedMemoryHeap : 0x7f6f0000 Void
+0x054 ReadOnlyStaticServerData : 0x7f6f0688 -> (null)
+0x058 AnsiCodePageData : 0x7ffa0000 Void
+0x05c OemCodePageData : 0x7ffa0000 Void
+0x060 UnicodeCaseTableData : 0x7ffd1000 Void
+0x064 NumberOfProcessors : 1
+0x068 NtGlobalFlag : 0
+0x070 CriticalSectionTimeout : _LARGE_INTEGER 0xffffe86d`079b8000
+0x078 HeapSegmentReserve : 0x100000
+0x07c HeapSegmentCommit : 0x2000
+0x080 HeapDeCommitTotalFreeThreshold : 0x10000
+0x084 HeapDeCommitFreeBlockThreshold : 0x1000
+0x088 NumberOfHeaps : 9
+0x08c MaximumNumberOfHeaps : 0x10
+0x090 ProcessHeaps : 0x7c9affe0 -> 0x000a0000 Void
+0x094 GdiSharedHandleTable : 0x00480000 Void
+0x098 ProcessStarterHelper : (null)
+0x09c GdiDCAttributeList : 0x14
+0x0a0 LoaderLock : 0x7c9ae174 Void
+0x0a4 OSMajorVersion : 5
+0x0a8 OSMinorVersion : 1
+0x0ac OSBuildNumber : 0xa28
+0x0ae OSCSDVersion : 0x300
+0x0b0 OSPlatformId : 2
+0x0b4 ImageSubsystem : 2
+0x0b8 ImageSubsystemMajorVersion : 4
+0x0bc ImageSubsystemMinorVersion : 0
+0x0c0 ImageProcessAffinityMask : 0
+0x0c4 GdiHandleBuffer : [34] 0
+0x14c PostProcessInitRoutine : (null)
+0x150 TlsExpansionBitmap : 0x7c9b05d8 Void
+0x154 TlsExpansionBitmapBits : [32] 0
+0x1d4 SessionId : 0
+0x1d8 AppCompatFlags : _ULARGE_INTEGER 0x0
+0x1e0 AppCompatFlagsUser : _ULARGE_INTEGER 0x0
+0x1e8 pShimData : (null)
+0x1ec AppCompatInfo : (null)
+0x1f0 CSDVersion : _UNICODE_STRING "Service Pack 3"
+0x1f8 ActivationContextData : 0x00090000 Void
+0x1fc ProcessAssemblyStorageMap : 0x000a2f50 Void
+0x200 SystemDefaultActivationContextData : 0x00080000 Void
+0x204 SystemAssemblyStorageMap : (null)
+0x208 MinimumStackCommit : 0
ProcessParameters 는 프로세스의 파라메터에 대한 정보를 담고있는데...
ImagePathName 이라는 필드에 해당 프로세스의 전체 경로가 저장이 됩니다.
kd> dt nt!_RTL_USER_PROCESS_PARAMETERS 0x00020000
+0x000 MaximumLength : 0x1000
+0x004 Length : 0x700
+0x008 Flags : 0x22001
+0x00c DebugFlags : 0
+0x010 ConsoleHandle : (null)
+0x014 ConsoleFlags : 0
+0x018 StandardInput : (null)
+0x01c StandardOutput : 0x00010001 Void
+0x020 StandardError : (null)
+0x024 CurrentDirectory : _CURDIR
+0x030 DllPath : _UNICODE_STRING "C:\WINDOWS\system32;C:\WINDOWS\system32;C:\WINDOWS\system;C:\WINDOWS;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\UTIL;C:\MyTools\OllyDBG;C:\MyTools\LordPE;C:\MyTools\ImpREC"
+0x038 ImagePathName : _UNICODE_STRING "C:\WINDOWS\system32\notepad.exe"
+0x040 CommandLine : _UNICODE_STRING ""C:\WINDOWS\system32\notepad.exe" "
+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 "C:\WINDOWS\system32\notepad.exe"
+0x078 DesktopInfo : _UNICODE_STRING "WinSta0\Default"
+0x080 ShellInfo : _UNICODE_STRING ""
+0x088 RuntimeData : _UNICODE_STRING ""
+0x090 CurrentDirectores : [32] _RTL_DRIVE_LETTER_CURDIR
2. SeAuditProcessCreationInfo
+0x1f4 SeAuditProcessCreationInfo : _SE_AUDIT_PROCESS_CREATION_INFO
+0x000 ImageFileName : 0x86027008 _OBJECT_NAME_INFORMATION
+0x000 Name : _UNICODE_STRING "\Device\HarddiskVolume1\WINDOWS\system32\notepad.exe"
3. SectionObject
kd> dt nt!_SECTION_OBJECT 0xe19085f8
+0x000 StartingVa : (null)
+0x004 EndingVa : (null)
+0x008 Parent : (null)
+0x00c LeftChild : (null)
+0x010 RightChild : (null)
+0x014 Segment : 0xe182dd08 _SEGMENT_OBJECT
kd> dt nt!_SEGMENT 0xe182dd08
+0x000 ControlArea : 0x86005008 _CONTROL_AREA
+0x004 TotalNumberOfPtes : 0x14
+0x008 NonExtendedPtes : 0x14
+0x00c WritableUserReferences : 0
+0x010 SizeOfSegment : 0x14000
+0x018 SegmentPteTemplate : _MMPTE
+0x020 NumberOfCommittedPages : 0
+0x024 ExtendInfo : (null)
+0x028 SystemImageBase : (null)
+0x02c BasedAddress : 0x01000000 Void
+0x030 u1 : __unnamed
+0x034 u2 : __unnamed
+0x038 PrototypePte : 0xe182dd48 _MMPTE
+0x040 ThePtes : [1] _MMPTE
kd> dt nt!_CONTROL_AREA 0x86005008
+0x000 Segment : 0xe182dd08 _SEGMENT
+0x004 DereferenceList : _LIST_ENTRY [ 0x0 - 0x0 ]
+0x00c NumberOfSectionReferences : 1
+0x010 NumberOfPfnReferences : 0x13
+0x014 NumberOfMappedViews : 1
+0x018 NumberOfSubsections : 4
+0x01a FlushInProgressCount : 0
+0x01c NumberOfUserReferences : 2
+0x020 u : __unnamed
+0x024 FilePointer : 0x86132220 _FILE_OBJECT
+0x028 WaitingForDeletion : (null)
+0x02c ModifiedWriteCount : 0
+0x02e NumberOfSystemCacheViews : 0
kd> dt nt!_FILE_OBJECT 0x86132220
+0x000 Type : 0n5
+0x002 Size : 0n112
+0x004 DeviceObject : 0x863bd900 _DEVICE_OBJECT
+0x008 Vpb : 0x863e28e0 _VPB
+0x00c FsContext : 0xe1043d90 Void
+0x010 FsContext2 : 0xe1043ee8 Void
+0x014 SectionObjectPointer : 0x86133424 _SECTION_OBJECT_POINTERS
+0x018 PrivateCacheMap : (null)
+0x01c FinalStatus : 0n0
+0x020 RelatedFileObject : (null)
+0x024 LockOperation : 0 ''
+0x025 DeletePending : 0 ''
+0x026 ReadAccess : 0x1 ''
+0x027 WriteAccess : 0 ''
+0x028 DeleteAccess : 0 ''
+0x029 SharedRead : 0x1 ''
+0x02a SharedWrite : 0 ''
+0x02b SharedDelete : 0x1 ''
+0x02c Flags : 0x44042
+0x030 FileName : _UNICODE_STRING "\WINDOWS\system32\notepad.exe"
+0x038 CurrentByteOffset : _LARGE_INTEGER 0x0
+0x040 Waiters : 0
+0x044 Busy : 0
+0x048 LastLock : (null)
+0x04c Lock : _KEVENT
+0x05c Event : _KEVENT
+0x06c CompletionContext : (null)
"프로세스" 에 포커스를 맞춰서 전체경로를 얻어오는 방법을 정리한건데...
"전체경로" 에 포커스를 맞춘다면 Peb 의 Ldr 정보를 이용하거나...
VadRoot 를 이용해서 로딩된 모듈들의 전체 경로를 구할 수도 있습니다.
그 중에서 프로세스의 경로만 가져오면 되겠죠... ^^;;;;;