Rev 517 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 517 | Rev 589 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | CHECK_FOR_LEAKS = 0 |
|
- | 2 | if CHECK_FOR_LEAKS |
|
- | 3 | uglobal |
|
- | 4 | allocatedregions rd 1024 |
|
- | 5 | endg |
|
- | 6 | iglobal |
|
- | 7 | numallocatedregions dd 0 |
|
- | 8 | endg |
|
- | 9 | end if |
|
1 | pgalloc: |
10 | pgalloc: |
2 | ; in: ecx=size |
11 | ; in: ecx=size |
3 | ; out: eax=pointer or NULL |
12 | ; out: eax=pointer or NULL |
4 | push ebx |
13 | push ebx |
5 | push 68 |
14 | push 68 |
6 | pop eax |
15 | pop eax |
7 | push 12 |
16 | push 12 |
8 | pop ebx |
17 | pop ebx |
9 | int 0x40 |
18 | int 0x40 |
- | 19 | if CHECK_FOR_LEAKS |
|
- | 20 | test eax, eax |
|
- | 21 | jz .no |
|
- | 22 | .b: |
|
- | 23 | mov ebx, [numallocatedregions] |
|
- | 24 | cmp ebx, 1024 |
|
- | 25 | jb @f |
|
- | 26 | int3 |
|
- | 27 | jmp $ |
|
- | 28 | @@: |
|
- | 29 | mov [allocatedregions+ebx*4], eax |
|
- | 30 | inc [numallocatedregions] |
|
- | 31 | .no: |
|
- | 32 | end if |
|
10 | pop ebx |
33 | pop ebx |
11 | ret |
34 | ret |
Line 12... | Line 35... | ||
12 | 35 | ||
13 | pgfree: |
36 | pgfree: |
14 | ; in: ecx=pointer |
37 | ; in: ecx=pointer |
- | 38 | ; destroys eax |
|
- | 39 | if CHECK_FOR_LEAKS |
|
- | 40 | jecxz .no |
|
- | 41 | mov eax, [numallocatedregions] |
|
- | 42 | @@: |
|
- | 43 | dec eax |
|
- | 44 | js .a |
|
- | 45 | cmp [allocatedregions+eax*4], ecx |
|
- | 46 | jnz @b |
|
- | 47 | jmp @f |
|
- | 48 | .a: |
|
- | 49 | int3 |
|
- | 50 | jmp $ |
|
- | 51 | @@: |
|
- | 52 | dec [numallocatedregions] |
|
- | 53 | @@: |
|
- | 54 | cmp eax, [numallocatedregions] |
|
- | 55 | jae @f |
|
- | 56 | push [allocatedregions+eax*4+4] |
|
- | 57 | pop [allocatedregions+eax*4] |
|
- | 58 | inc eax |
|
- | 59 | jmp @b |
|
- | 60 | @@: |
|
- | 61 | .no: |
|
15 | ; destroys eax |
62 | end if |
16 | push ebx |
63 | push ebx |
17 | push 68 |
64 | push 68 |
18 | pop eax |
65 | pop eax |
19 | push 13 |
66 | push 13 |
Line 29... | Line 76... | ||
29 | push 68 |
76 | push 68 |
30 | pop eax |
77 | pop eax |
31 | push 20 |
78 | push 20 |
32 | pop ebx |
79 | pop ebx |
33 | int 0x40 |
80 | int 0x40 |
- | 81 | if CHECK_FOR_LEAKS |
|
- | 82 | test edx, edx |
|
- | 83 | jz pgalloc.b |
|
- | 84 | test eax, eax |
|
- | 85 | jz .no |
|
- | 86 | cmp eax, edx |
|
- | 87 | jz .no |
|
- | 88 | xor ebx, ebx |
|
- | 89 | @@: |
|
- | 90 | cmp ebx, [numallocatedregions] |
|
- | 91 | jae .a |
|
- | 92 | cmp [allocatedregions+ebx*4], edx |
|
- | 93 | jz @f |
|
- | 94 | inc ebx |
|
- | 95 | jmp @b |
|
- | 96 | @@: |
|
- | 97 | mov [allocatedregions+ebx*4], eax |
|
- | 98 | jmp .no |
|
- | 99 | .a: |
|
- | 100 | int3 |
|
- | 101 | jmp $ |
|
- | 102 | .no: |
|
- | 103 | end if |
|
34 | pop ebx |
104 | pop ebx |
35 | ret |
105 | ret |
Line 36... | Line 106... | ||
36 | 106 | ||
37 | xpgalloc: |
107 | xpgalloc: |
Line 50... | Line 120... | ||
50 | ; in: edx=pointer, ecx=new size |
120 | ; in: edx=pointer, ecx=new size |
51 | ; out: eax=pointer or NULL |
121 | ; out: eax=pointer or NULL |
52 | call pgrealloc |
122 | call pgrealloc |
53 | jmp xpgalloc.common |
123 | jmp xpgalloc.common |
Line -... | Line 124... | ||
- | 124 | ||
- | 125 | getfreemem: |
|
- | 126 | ; out: eax=size of free RAM in Kb |
|
- | 127 | push ebx |
|
- | 128 | push 18 |
|
- | 129 | pop eax |
|
- | 130 | push 16 |
|
- | 131 | pop ebx |
|
- | 132 | int 0x40 |
|
- | 133 | pop ebx |
|
- | 134 | ret |
|
54 | 135 | ||
55 | get_error_msg: |
136 | get_error_msg: |
56 | ; in: eax=error code |
137 | ; in: eax=error code |
57 | ; out: eax=pointer to message (in static buffer) |
138 | ; out: eax=pointer to message (in static buffer) |
58 | push esi edi |
139 | push esi edi |
Line 83... | Line 164... | ||
83 | lodsb |
164 | lodsb |
84 | stosb |
165 | stosb |
85 | test al, al |
166 | test al, al |
86 | jnz @b |
167 | jnz @b |
87 | pop eax |
168 | pop eax |
- | 169 | dec edi |
|
88 | push edx ecx |
170 | push edx ecx |
89 | test eax, eax |
171 | test eax, eax |
90 | jns @f |
172 | jns @f |
91 | mov byte [edi], '-' |
173 | mov byte [edi], '-' |
92 | inc edi |
174 | inc edi |
Line 160... | Line 242... | ||
160 | test al, al |
242 | test al, al |
161 | loopnz @b |
243 | loopnz @b |
162 | pop eax |
244 | pop eax |
163 | pop esi |
245 | pop esi |
164 | jz .do |
246 | jz .do |
- | 247 | .big: |
|
165 | push eax |
248 | push esi |
166 | mov edi, aFileNameTooBig |
249 | mov edi, aFileNameTooBig |
167 | .sayerr: |
250 | .sayerr: |
168 | push dword aCannotLoadDLL |
251 | push dword aCannotLoadDLL |
169 | push edi |
252 | push edi |
170 | mov eax, esp |
253 | mov eax, esp |
171 | push dword aOk |
254 | push dword aOk |
172 | push esp |
255 | push esp |
173 | push 1 |
256 | push 1 |
174 | push eax |
257 | push eax |
175 | push 3 |
258 | push 3 |
176 | push -1 |
- | |
177 | push -1 |
- | |
178 | push dword aError |
- | |
179 | call SayErr |
259 | call SayErr |
180 | add esp, 16 |
260 | add esp, 16 |
181 | xor eax, eax |
261 | xor eax, eax |
182 | inc eax |
262 | inc eax |
183 | ret |
263 | ret |
Line 190... | Line 270... | ||
190 | pop ebx |
270 | pop ebx |
191 | int 0x40 |
271 | int 0x40 |
192 | mov edi, aInvalidDLL |
272 | mov edi, aInvalidDLL |
193 | test eax, eax |
273 | test eax, eax |
194 | jz .sayerr |
274 | jz .sayerr |
- | 275 | mov edx, eax |
|
- | 276 | cmp ebp, -1 |
|
- | 277 | jnz @f |
|
- | 278 | pop eax |
|
- | 279 | xor eax, eax |
|
- | 280 | ret |
|
- | 281 | @@: |
|
195 | ; initialize import |
282 | ; initialize import |
196 | mov edi, aMissingExport |
283 | mov edi, aMissingExport |
197 | mov edx, eax |
- | |
198 | .import_loop: |
284 | .import_loop: |
199 | lodsd |
285 | lodsd |
200 | test eax, eax |
286 | test eax, eax |
201 | jz .import_done |
287 | jz .import_done |
202 | call .find_exported_function |
288 | call .find_exported_function |