汇编取自进程入口点
用到了InlineAssembler支持库
图1
图2
PEB结构体 -- fs:[0x30]
ntdll!_PEB
+0x000 InheritedAddressSpace : UChar
+0x001 ReadImageFileExecOptions : UChar
+0x002 BeingDebugged : UChar
+0x003 BitField : UChar
+0x003 ImageUsesLargePages : Pos 0, 1 Bit
+0x003 IsProtectedProcess : Pos 1, 1 Bit
+0x003 IsLegacyProcess : Pos 2, 1 Bit
+0x003 IsImageDynamicallyRelocated : Pos 3, 1 Bit
+0x003 SkipPatchingUser32Forwarders : Pos 4, 1 Bit
+0x003 SpareBits : Pos 5, 3 Bits
+0x004 Mutant : Ptr32 Void
+0x008 ImageBaseAddress : Ptr32 Void
+0x00c Ldr : Ptr32 _PEB_LDR_DATA // PEB_LOADER_DATA 进程加载信息表
ntdll!_PEB_LDR_DATA
+ 0x000 Length : Uint4B
+ 0x004 Initialized : UChar
+ 0x008 SsHandle : Ptr32 Void
+ 0x00c InLoadOrderModuleList : _LIST_ENTRY // 模块加载顺序
+ 0x014 InMemoryOrderModuleList : _LIST_ENTRY // 加载后在内存中的顺序
+ 0x01c InInitializationOrderModuleList : _LIST_ENTRY // 模块初始化的顺序
+ 0x024 EntryInProgress : Ptr32 Void
+ 0x028 ShutdownInProgress : UChar
+ 0x02c ShutdownThreadId : Ptr32 Void
ntdll!_LDR_DATA_TABLE_ENTRY
+ 0x000 InLoadOrderLinks : _LIST_ENTRY
+ 0x008 InMemoryOrderLinks : _LIST_ENTRY
+ 0x010 InInitializationOrderLinks : _LIST_ENTRY
+ 0x018 DllBase : Ptr32 Void // 模块基地址
+ 0x01c EntryPoint : Ptr32 Void // 入口函数(对于 exe 模块有效)
+ 0x020 SizeOfImage : Uint4B // 模块大小
+ 0x024 FullDllName : _UNICODE_STRING // 完成模块名称(带路径)
+ 0x02c BaseDllName : _UNICODE_STRING // 模块名称
+ 0x034 Flags : Uint4B
原理就是遍历 _PEB_LDR_DATA.InLoadOrderModuleList,
比较 _PEB.ImageBaseAddress 和_LDR_DATA_TABLE_ENTRY.DllBase(0x18) 的值,
相等就返回 _LDR_DATA_TABLE_ENTRY.EntryPoint(0x1c)
应该可以简单校验一下自身文件有没有被加料修改入口点
没了
最后说一句,InlineAssembler支持库,耗用

|