fixed map_pe()

git-svn-id: svn://kolibrios.org@668 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-10-28 05:36:29 +00:00
parent eec9fdbabb
commit 17c2ff7b3d

View File

@ -35,159 +35,175 @@ map_PE: ;stdcall base:dword, image:dword
push edi push edi
push esi push esi
push ebx push ebx
sub esp, 28 sub esp, 44
mov ebp, [esp+68]
mov ebx, [esp+64]
mov edx, ebp
mov esi, ebp
add edx, [ebp+60]
mov edi, ebx
mov [esp+32], edx
mov ecx, [edx+84]
shr ecx, 2
rep movsd
mov edx, [esp+52]
mov ebx, [esp+48]
mov dword [esp+20], 0
add edx, [edx+60]
movzx eax, word [edx+6] movzx eax, word [edx+6]
mov [esp+16], edx mov dword [esp+36], 0
mov [esp+12], eax mov [esp+28], eax
jmp .L6 jmp .L6
.L7: .L7:
mov eax, [edx+264] mov eax, [edx+264]
mov ebp, [edx+260] test eax, eax
mov esi, [esp+52] je .L8
mov esi, ebp
mov edi, ebx
add esi, [edx+268] add esi, [edx+268]
mov ecx, eax mov ecx, eax
lea edi, [ebx+ebp] add edi, [edx+260]
shr ecx, 2 shr ecx, 2
rep movsd rep movsd
mov ecx, [edx+256]
cmp ecx, eax
jbe .L8
sub ecx, eax
xor eax, eax
rep stosb
.L8: .L8:
inc dword [esp+20] mov ecx, [edx+256]
add ecx, 4095
and ecx, -4096
cmp ecx, eax
jbe .L10
sub ecx, eax
add eax, [edx+260]
lea edi, [eax+ebx]
xor eax, eax
rep stosb
.L10:
inc dword [esp+36]
add edx, 40 add edx, 40
.L6: .L6:
mov eax, [esp+12] mov esi, [esp+28]
cmp [esp+20], eax cmp [esp+36], esi
jne .L7 jne .L7
mov edx, [esp+16] mov edi, [esp+32]
cmp dword [edx+164], 0 cmp dword [edi+164], 0
je .L11 je .L13
mov eax, [esp+32]
mov edi, ebx mov edi, ebx
mov ecx, ebx mov ecx, ebx
sub edi, [edx+52] sub edi, [eax+52]
add ecx, [edx+160] add ecx, [eax+160]
mov eax, edi
shr eax, 16 mov edx, edi
mov [esp+4], eax shr edx, 16
jmp .L13 mov [esp+20], edx
.L14:
lea esi, [eax-8]
xor ebp, ebp
shr esi,1
jmp .L15 jmp .L15
.L16: .L16:
lea esi, [eax-8]
xor ebp, ebp
shr esi, 1
jmp .L17
.L18:
movzx eax, word [ecx+8+ebp*2] movzx eax, word [ecx+8+ebp*2]
mov edx, eax mov edx, eax
shr eax, 12 shr eax, 12
and edx, 4095 and edx, 4095
add edx, [ecx] add edx, [ecx]
cmp ax, 2 cmp ax, 2
je .L19 je .L21
cmp ax, 3 cmp ax, 3
je .L20 je .L22
dec ax dec ax
jne .L17 jne .L19
mov eax, [esp+4] mov eax, [esp+20]
add word [edx+ebx], ax add [edx+ebx], ax
.L19: .L21:
add word [edx+ebx], di add [edx+ebx], di
.L20: .L22:
add [edx+ebx], edi add [edx+ebx], edi
.L17: .L19:
inc ebp inc ebp
.L15: .L17:
cmp ebp, esi cmp ebp, esi
jne .L16 jne .L18
add ecx, [ecx+4] add ecx, [ecx+4]
.L13: .L15:
mov eax, [ecx+4] mov eax, [ecx+4]
test eax, eax test eax, eax
jne .L14 jne .L16
.L11: .L13:
mov edx, [esp+16] mov edx, [esp+32]
cmp dword [edx+132], 0 cmp dword [edx+132], 0
je .L22 je .L24
mov eax, ebx mov eax, ebx
add eax, [edx+128] add eax, [edx+128]
lea esi, [eax+20] lea esi, [eax+20]
.L24: .L26:
cmp dword [esi-16], 0 cmp dword [esi-16], 0
jne .L25 jne .L27
cmp dword [esi-8], 0 cmp dword [esi-8], 0
je .L22 je .L24
.L25: .L27:
mov ecx, [esi-20] mov ecx, [esi-20]
mov ebp, ebx mov ebp, ebx
add ebp, [esi-4] add ebp, [esi-4]
add ecx, ebx add ecx, ebx
mov [esp+24], ecx mov [esp+40], ecx
.L27: .L29:
mov edx, [esp+24] mov edi, [esp+40]
mov eax, [edx] mov eax, [edi]
test eax, eax test eax, eax
je .L28 je .L30
test eax, eax test eax, eax
js .L28 js .L30
lea eax, [eax+2+ebx] lea eax, [eax+2+ebx]
mov edi, kernel_export mov edi, kernel_export
mov dword [ebp], -1 mov [ebp], dword -1
mov [esp+8], eax mov [esp+24], eax
.L31: .L33:
push ecx push ecx
push 16 push 16
push dword [edi] push dword [edi]
push dword [esp+20] push dword [esp+36]
call strncmp call strncmp
pop edx pop edx
test eax, eax test eax, eax
jne .L32 jne .L34
mov eax, [edi+4] mov eax, [edi+4]
mov [ebp], eax mov [ebp], eax
jmp .L34 jmp .L36
.L32: .L34:
add edi, 8 add edi, 8
cmp dword [edi], 0 cmp dword [edi], 0
jne .L31 jne .L33
.L34: .L36:
add dword [esp+24], 4 add dword [esp+40], 4
add ebp, 4 add ebp, 4
jmp .L27 jmp .L29
.L28: .L30:
add esi, 20 add esi, 20
jmp .L24 jmp .L26
.L22: .L24:
mov eax, [esp+32]
mov ecx, [esp+16] add ebx, [eax+40]
add ebx, [ecx+40] add esp, 44
add esp, 28
mov eax, ebx mov eax, ebx
pop ebx pop ebx
pop esi pop esi
pop edi pop edi
pop ebp pop ebp
ret 8 ret 8