|
GetDllBaseAddr proc DllName:DWORD
LOCAL @PEB_ADDR:DWORD ;peb address
LOCAL @LDR_ADDR:DWORD
LOCAL @LIST_ENTRY_FIREST:DWORD
LOCAL @LIST_ENTRY_NEXT:DWORD
assume fs:nothing
mov eax,fs:[30h]
mov @PEB_ADDR,eax
.if eax==0ffffffffh
jmp lable_end
.elseif eax==0
jmp lable_end
.endif
lea eax,[eax+0ch]
mov eax,[eax] ; eax=_PEB_LDR_DATA Ldr成员的的指针
mov @LDR_ADDR,eax ;保存ldr指针
mov eax,[eax+0ch] ;EAX = LISTENTRY HEADER
mov @LIST_ENTRY_FIREST,eax ;得到list entry heander
mov @LIST_ENTRY_NEXT,eax;这个留作指向一下一个指针用
lable_head:
mov eax,@LIST_ENTRY_NEXT
.if eax==0
jmp lable_end
.endif
lea eax,[eax+2ch]
mov eax,[eax+04h];此处eax是dllname wstr的指针
.if eax==0
jmp lable_getnextList
.endif
mov ebx,DllName;ebx保存参数名称
lable_while_start:
xor ecx,ecx
mov cl,[eax]
.if ecx<060h
.if ecx>040h
lea ecx,[ecx+020h]
.endif
.endif
xor edx,edx
mov dl,[ebx]
.if edx<060h
.if edx>040h
lea edx,[edx+020h]
.endif
.endif
cmp cl,dl ;判断字符是否相同
jne lable_getnextList
cmp cl,0
je lable_return
inc ebx
lea eax,[eax+2]
jmp lable_while_start
lable_getnextList:
mov eax,@LIST_ENTRY_NEXT ;next list netry point
mov eax,[eax]
.if eax!=@LIST_ENTRY_FIREST ;对比链表地址是否都已遍历完
mov @LIST_ENTRY_NEXT,eax
jmp lable_head
.endif
lable_end:
xor eax,eax
ret
lable_return:
mov eax,@LIST_ENTRY_NEXT ;取得dll基地址
mov eax,[eax+18h] ;取得dll基地址
Ret
GetDllBaseAddr endp |
|