Rev 660 | Rev 668 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 660 | Rev 662 | ||
---|---|---|---|
1 | align 4 |
1 | align 4 |
2 | 2 | ||
3 | proc load_PE stdcall, file_name:dword |
3 | proc load_PE stdcall, file_name:dword |
4 | locals |
4 | locals |
5 | image dd ? |
5 | image dd ? |
6 | endl |
6 | endl |
7 | 7 | ||
8 | stdcall load_file, [file_name] |
8 | stdcall load_file, [file_name] |
9 | test eax, eax |
9 | test eax, eax |
10 | jz .fail |
10 | jz .fail |
11 | 11 | ||
12 | mov [image], eax |
12 | mov [image], eax |
13 | 13 | ||
14 | mov edx, [eax+60] |
14 | mov edx, [eax+60] |
15 | 15 | ||
16 | stdcall kernel_alloc, [eax+80+edx] |
16 | stdcall kernel_alloc, [eax+80+edx] |
17 | test eax, eax |
17 | test eax, eax |
18 | jz .cleanup |
18 | jz .cleanup |
19 | 19 | ||
20 | stdcall map_PE, eax, [image] |
20 | stdcall map_PE, eax, [image] |
21 | ret |
21 | ret |
22 | .cleanup: |
22 | .cleanup: |
23 | stdcall kernel_free,[image] |
23 | stdcall kernel_free,[image] |
24 | .fail: |
24 | .fail: |
25 | xor eax, eax |
25 | xor eax, eax |
26 | ret |
26 | ret |
27 | endp |
27 | endp |
28 | 28 | ||
29 | 29 | ||
30 | align 4 |
30 | align 4 |
31 | map_PE: |
31 | map_PE: ;stdcall base:dword, image:dword |
32 | cld |
32 | cld |
33 | push ebp |
33 | push ebp |
34 | push edi |
34 | push edi |
35 | push esi |
35 | push esi |
36 | push ebx |
36 | push ebx |
37 | sub esp, 28 |
37 | sub esp, 28 |
38 | 38 | ||
39 | mov edx, [esp+52] |
39 | mov edx, [esp+52] |
40 | mov ebx, [esp+48] |
40 | mov ebx, [esp+48] |
41 | mov dword [esp+20], 0 |
41 | mov dword [esp+20], 0 |
42 | add edx, [edx+60] |
42 | add edx, [edx+60] |
43 | movzx eax, word [edx+6] |
43 | movzx eax, word [edx+6] |
44 | mov [esp+16], edx |
44 | mov [esp+16], edx |
45 | mov [esp+12], eax |
45 | mov [esp+12], eax |
46 | jmp .L6 |
46 | jmp .L6 |
47 | .L7: |
47 | .L7: |
48 | mov eax, [edx+264] |
48 | mov eax, [edx+264] |
49 | mov ebp, [edx+260] |
49 | mov ebp, [edx+260] |
50 | mov esi, [esp+52] |
50 | mov esi, [esp+52] |
51 | add esi, [edx+268] |
51 | add esi, [edx+268] |
52 | mov ecx, eax |
52 | mov ecx, eax |
53 | lea edi, [ebx+ebp] |
53 | lea edi, [ebx+ebp] |
54 | 54 | ||
55 | shr ecx, 2 |
55 | shr ecx, 2 |
56 | rep movsd |
56 | rep movsd |
57 | 57 | ||
58 | mov ecx, [edx+256] |
58 | mov ecx, [edx+256] |
59 | cmp ecx, eax |
59 | cmp ecx, eax |
60 | jbe .L8 |
60 | jbe .L8 |
61 | sub ecx, eax |
61 | sub ecx, eax |
62 | 62 | ||
63 | xor eax, eax |
63 | xor eax, eax |
64 | rep stosb |
64 | rep stosb |
65 | 65 | ||
66 | .L8: |
66 | .L8: |
67 | inc dword [esp+20] |
67 | inc dword [esp+20] |
68 | add edx, 40 |
68 | add edx, 40 |
69 | .L6: |
69 | .L6: |
70 | mov eax, [esp+12] |
70 | mov eax, [esp+12] |
71 | cmp [esp+20], eax |
71 | cmp [esp+20], eax |
72 | jne .L7 |
72 | jne .L7 |
73 | 73 | ||
74 | mov edx, [esp+16] |
74 | mov edx, [esp+16] |
75 | cmp dword [edx+164], 0 |
75 | cmp dword [edx+164], 0 |
76 | je .L11 |
76 | je .L11 |
77 | 77 | ||
78 | mov edi, ebx |
78 | mov edi, ebx |
79 | mov ecx, ebx |
79 | mov ecx, ebx |
80 | sub edi, [edx+52] |
80 | sub edi, [edx+52] |
81 | add ecx, [edx+160] |
81 | add ecx, [edx+160] |
82 | mov eax, edi |
82 | mov eax, edi |
83 | shr eax, 16 |
83 | shr eax, 16 |
84 | mov [esp+4], eax |
84 | mov [esp+4], eax |
85 | jmp .L13 |
85 | jmp .L13 |
86 | .L14: |
86 | .L14: |
87 | lea esi, [eax-8] |
87 | lea esi, [eax-8] |
88 | xor ebp, ebp |
88 | xor ebp, ebp |
89 | shr esi,1 |
89 | shr esi,1 |
90 | jmp .L15 |
90 | jmp .L15 |
91 | .L16: |
91 | .L16: |
92 | movzx eax, word [ecx+8+ebp*2] |
92 | movzx eax, word [ecx+8+ebp*2] |
93 | mov edx, eax |
93 | mov edx, eax |
94 | shr eax, 12 |
94 | shr eax, 12 |
95 | and edx, 4095 |
95 | and edx, 4095 |
96 | add edx, [ecx] |
96 | add edx, [ecx] |
97 | cmp ax, 2 |
97 | cmp ax, 2 |
98 | je .L19 |
98 | je .L19 |
99 | 99 | ||
100 | cmp ax, 3 |
100 | cmp ax, 3 |
101 | je .L20 |
101 | je .L20 |
102 | 102 | ||
103 | dec ax |
103 | dec ax |
104 | jne .L17 |
104 | jne .L17 |
105 | 105 | ||
106 | mov eax, [esp+4] |
106 | mov eax, [esp+4] |
107 | add word [edx+ebx], ax |
107 | add word [edx+ebx], ax |
108 | .L19: |
108 | .L19: |
109 | add word [edx+ebx], di |
109 | add word [edx+ebx], di |
110 | .L20: |
110 | .L20: |
111 | add [edx+ebx], edi |
111 | add [edx+ebx], edi |
112 | .L17: |
112 | .L17: |
113 | inc ebp |
113 | inc ebp |
114 | .L15: |
114 | .L15: |
115 | cmp ebp, esi |
115 | cmp ebp, esi |
116 | jne .L16 |
116 | jne .L16 |
117 | add ecx, [ecx+4] |
117 | add ecx, [ecx+4] |
118 | .L13: |
118 | .L13: |
119 | mov eax, [ecx+4] |
119 | mov eax, [ecx+4] |
120 | test eax, eax |
120 | test eax, eax |
121 | jne .L14 |
121 | jne .L14 |
122 | .L11: |
122 | .L11: |
123 | mov edx, [esp+16] |
123 | mov edx, [esp+16] |
124 | cmp dword [edx+132], 0 |
124 | cmp dword [edx+132], 0 |
125 | je .L22 |
125 | je .L22 |
126 | 126 | ||
127 | mov eax, ebx |
127 | mov eax, ebx |
128 | add eax, [edx+128] |
128 | add eax, [edx+128] |
129 | lea esi, [eax+20] |
129 | lea esi, [eax+20] |
130 | .L24: |
130 | .L24: |
131 | cmp dword [esi-16], 0 |
131 | cmp dword [esi-16], 0 |
132 | jne .L25 |
132 | jne .L25 |
133 | 133 | ||
134 | cmp dword [esi-8], 0 |
134 | cmp dword [esi-8], 0 |
135 | je .L22 |
135 | je .L22 |
136 | .L25: |
136 | .L25: |
137 | mov ecx, [esi-20] |
137 | mov ecx, [esi-20] |
138 | mov ebp, ebx |
138 | mov ebp, ebx |
139 | add ebp, [esi-4] |
139 | add ebp, [esi-4] |
140 | add ecx, ebx |
140 | add ecx, ebx |
141 | mov [esp+24], ecx |
141 | mov [esp+24], ecx |
142 | .L27: |
142 | .L27: |
143 | mov edx, [esp+24] |
143 | mov edx, [esp+24] |
144 | mov eax, [edx] |
144 | mov eax, [edx] |
145 | test eax, eax |
145 | test eax, eax |
146 | je .L28 |
146 | je .L28 |
147 | 147 | ||
148 | test eax, eax |
148 | test eax, eax |
149 | js .L28 |
149 | js .L28 |
150 | 150 | ||
151 | lea eax, [eax+2+ebx] |
151 | lea eax, [eax+2+ebx] |
152 | mov edi, kernel_export |
152 | mov edi, kernel_export |
153 | mov dword [ebp], -1 |
153 | mov dword [ebp], -1 |
154 | mov [esp+8], eax |
154 | mov [esp+8], eax |
155 | .L31: |
155 | .L31: |
156 | push ecx |
156 | push ecx |
157 | push 16 |
157 | push 16 |
158 | push dword [edi] |
158 | push dword [edi] |
159 | push dword [esp+20] |
159 | push dword [esp+20] |
160 | call strncmp |
160 | call strncmp |
161 | pop edx |
161 | pop edx |
162 | test eax, eax |
162 | test eax, eax |
163 | jne .L32 |
163 | jne .L32 |
164 | 164 | ||
165 | mov eax, [edi+4] |
165 | mov eax, [edi+4] |
166 | mov [ebp], eax |
166 | mov [ebp], eax |
167 | jmp .L34 |
167 | jmp .L34 |
168 | .L32: |
168 | .L32: |
169 | add edi, 8 |
169 | add edi, 8 |
170 | cmp dword [edi], 0 |
170 | cmp dword [edi], 0 |
171 | jne .L31 |
171 | jne .L31 |
172 | .L34: |
172 | .L34: |
173 | add dword [esp+24], 4 |
173 | add dword [esp+24], 4 |
174 | add ebp, 4 |
174 | add ebp, 4 |
175 | jmp .L27 |
175 | jmp .L27 |
176 | .L28: |
176 | .L28: |
177 | add esi, 20 |
177 | add esi, 20 |
178 | jmp .L24 |
178 | jmp .L24 |
179 | .L22: |
179 | .L22: |
180 | 180 | ||
181 | mov ecx, [esp+16] |
181 | mov ecx, [esp+16] |
182 | add ebx, [ecx+40] |
182 | add ebx, [ecx+40] |
183 | 183 | ||
184 | add esp, 28 |
184 | add esp, 28 |
185 | mov eax, ebx |
185 | mov eax, ebx |
186 | 186 | ||
187 | pop ebx |
187 | pop ebx |
188 | pop esi |
188 | pop esi |
189 | pop edi |
189 | pop edi |
190 | pop ebp |
190 | pop ebp |
191 | 191 | ||
192 | ret 8 |
192 | ret 8 |