Rev 3598 | Rev 5089 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3598 | Rev 3742 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line -... | Line 8... | ||
- | 8 | $Revision: 3742 $ |
|
- | 9 | ||
- | 10 | struct NTFS PARTITION |
|
- | 11 | Lock MUTEX ? ; currently operations with one partition |
|
- | 12 | ; can not be executed in parallel since the |
|
- | 13 | ; legacy code is not ready; this mutex guards |
|
- | 14 | ; all operations |
|
- | 15 | sectors_per_cluster dd ? |
|
- | 16 | mft_cluster dd ? |
|
- | 17 | mftmirr_cluster dd ? |
|
- | 18 | frs_size dd ? ; FRS size in bytes |
|
- | 19 | iab_size dd ? ; IndexAllocationBuffer size in bytes |
|
- | 20 | frs_buffer dd ? |
|
- | 21 | iab_buffer dd ? |
|
- | 22 | mft_retrieval dd ? |
|
- | 23 | mft_retrieval_size dd ? |
|
- | 24 | mft_retrieval_alloc dd ? |
|
- | 25 | mft_retrieval_end dd ? |
|
- | 26 | cur_index_size dd ? |
|
- | 27 | cur_index_buf dd ? |
|
- | 28 | ||
- | 29 | ntfs_cur_attr dd ? |
|
- | 30 | ntfs_cur_iRecord dd ? |
|
- | 31 | ntfs_cur_offs dd ? ; in sectors |
|
- | 32 | ntfs_cur_size dd ? ; in sectors |
|
- | 33 | ntfs_cur_buf dd ? |
|
- | 34 | ntfs_cur_read dd ? ; [output] |
|
- | 35 | ntfs_bCanContinue db ? |
|
- | 36 | rb 3 |
|
- | 37 | ||
- | 38 | cur_subnode_size dd ? |
|
- | 39 | ntfs_attr_iRecord dd ? |
|
- | 40 | ntfs_attr_iBaseRecord dd ? |
|
- | 41 | ntfs_attr_offs dd ? |
|
- | 42 | ntfs_attr_list dd ? |
|
- | 43 | ntfs_attr_size dq ? |
|
- | 44 | ntfs_cur_tail dd ? |
|
- | 45 | ||
- | 46 | ntfs_attrlist_buf rb 0x400 |
|
- | 47 | ntfs_attrlist_mft_buf rb 0x400 |
|
- | 48 | ntfs_bitmap_buf rb 0x400 |
|
- | 49 | ends |
|
- | 50 | ||
- | 51 | iglobal |
|
- | 52 | align 4 |
|
- | 53 | ntfs_user_functions: |
|
- | 54 | dd ntfs_free |
|
- | 55 | dd (ntfs_user_functions_end - ntfs_user_functions - 4) / 4 |
|
- | 56 | dd ntfs_Read |
|
- | 57 | dd ntfs_ReadFolder |
|
- | 58 | dd ntfs_Rewrite |
|
- | 59 | dd ntfs_Write |
|
- | 60 | dd ntfs_SetFileEnd |
|
- | 61 | dd ntfs_GetFileInfo |
|
- | 62 | dd ntfs_SetFileInfo |
|
- | 63 | dd 0 |
|
- | 64 | dd ntfs_Delete |
|
- | 65 | dd ntfs_CreateFolder |
|
Line 8... | Line 66... | ||
8 | $Revision: 3598 $ |
66 | ntfs_user_functions_end: |
9 | 67 | endg |
|
10 | 68 | ||
11 | ntfs_test_bootsec: |
69 | ntfs_test_bootsec: |
Line 91... | Line 149... | ||
91 | .no: |
149 | .no: |
92 | ; No, this bootsector isn't NTFS |
150 | ; No, this bootsector isn't NTFS |
93 | stc |
151 | stc |
94 | ret |
152 | ret |
Line -... | Line 153... | ||
- | 153 | ||
- | 154 | proc ntfs_create_partition |
|
- | 155 | mov edx, dword [ebp+PARTITION.Length] |
|
- | 156 | cmp dword [esp+4], 0 |
|
- | 157 | jz .boot_read_ok |
|
- | 158 | add ebx, 512 |
|
- | 159 | lea eax, [edx-1] |
|
- | 160 | call fs_read32_sys |
|
- | 161 | test eax, eax |
|
- | 162 | jnz @f |
|
- | 163 | call ntfs_test_bootsec |
|
- | 164 | jnc .ntfs_setup |
|
- | 165 | @@: |
|
- | 166 | mov eax, edx |
|
- | 167 | shr eax, 1 |
|
- | 168 | call fs_read32_sys |
|
95 | 169 | test eax, eax |
|
- | 170 | jnz .nope ; no chance... |
|
- | 171 | .boot_read_ok: |
|
- | 172 | call ntfs_test_bootsec |
|
- | 173 | jnc .ntfs_setup |
|
- | 174 | .nope: |
|
- | 175 | xor eax, eax |
|
- | 176 | jmp .exit |
|
- | 177 | ||
96 | ntfs_setup: ; CODE XREF: part_set.inc |
178 | .ntfs_setup: |
- | 179 | ; By given bootsector, initialize some NTFS variables |
|
- | 180 | movi eax, sizeof.NTFS |
|
- | 181 | call malloc |
|
- | 182 | test eax, eax |
|
- | 183 | jz .exit |
|
- | 184 | mov ecx, dword [ebp+PARTITION.FirstSector] |
|
97 | ; By given bootsector, initialize some NTFS variables |
185 | mov dword [eax+NTFS.FirstSector], ecx |
- | 186 | mov ecx, dword [ebp+PARTITION.FirstSector+4] |
|
- | 187 | mov dword [eax+NTFS.FirstSector+4], ecx |
|
- | 188 | mov ecx, dword [ebp+PARTITION.Length] |
|
- | 189 | mov dword [eax+NTFS.Length], ecx |
|
- | 190 | mov ecx, dword [ebp+PARTITION.Length+4] |
|
- | 191 | mov dword [eax+NTFS.Length+4], ecx |
|
- | 192 | mov ecx, [ebp+PARTITION.Disk] |
|
- | 193 | mov [eax+NTFS.Disk], ecx |
|
- | 194 | mov [eax+NTFS.FSUserFunctions], ntfs_user_functions |
|
- | 195 | push ebx ebp esi |
|
- | 196 | mov ebp, eax |
|
98 | ; call ntfs_test_bootsec ; checking boot sector was already |
197 | |
- | 198 | lea ecx, [ebp+NTFS.Lock] |
|
- | 199 | call mutex_init |
|
99 | ; jc problem_fat_dec_count |
200 | |
100 | movzx eax, byte [ebx+13] |
201 | movzx eax, byte [ebx+13] |
101 | mov [ntfs_data.sectors_per_cluster], eax |
202 | mov [ebp+NTFS.sectors_per_cluster], eax |
102 | mov eax, [ebx+0x28] |
- | |
103 | add eax, [PARTITION_START] |
- | |
104 | dec eax |
203 | mov eax, [ebx+0x28] |
105 | mov [PARTITION_END], eax |
204 | mov dword [ebp+NTFS.Length], eax |
106 | mov [fs_type], 1 |
205 | and dword [ebp+NTFS.Length+4], 0 |
107 | mov eax, [ebx+0x30] |
206 | mov eax, [ebx+0x30] |
108 | mov [ntfs_data.mft_cluster], eax |
207 | mov [ebp+NTFS.mft_cluster], eax |
109 | mov eax, [ebx+0x38] |
208 | mov eax, [ebx+0x38] |
110 | mov [ntfs_data.mftmirr_cluster], eax |
209 | mov [ebp+NTFS.mftmirr_cluster], eax |
111 | movsx eax, byte [ebx+0x40] |
210 | movsx eax, byte [ebx+0x40] |
112 | test eax, eax |
211 | test eax, eax |
113 | js .1 |
212 | js .1 |
114 | mul [ntfs_data.sectors_per_cluster] |
213 | mul [ebp+NTFS.sectors_per_cluster] |
115 | shl eax, 9 |
214 | shl eax, 9 |
116 | jmp .2 |
215 | jmp .2 |
117 | .1: |
216 | .1: |
118 | neg eax |
217 | neg eax |
119 | mov ecx, eax |
218 | mov ecx, eax |
120 | mov eax, 1 |
219 | mov eax, 1 |
121 | shl eax, cl |
220 | shl eax, cl |
122 | .2: |
221 | .2: |
123 | mov [ntfs_data.frs_size], eax |
222 | mov [ebp+NTFS.frs_size], eax |
124 | movsx eax, byte [ebx+0x44] |
223 | movsx eax, byte [ebx+0x44] |
125 | test eax, eax |
224 | test eax, eax |
126 | js .3 |
225 | js .3 |
127 | mul [ntfs_data.sectors_per_cluster] |
226 | mul [ebp+NTFS.sectors_per_cluster] |
128 | shl eax, 9 |
227 | shl eax, 9 |
129 | jmp .4 |
228 | jmp .4 |
130 | .3: |
229 | .3: |
131 | neg eax |
230 | neg eax |
132 | mov ecx, eax |
231 | mov ecx, eax |
133 | mov eax, 1 |
232 | mov eax, 1 |
134 | shl eax, cl |
233 | shl eax, cl |
135 | .4: |
234 | .4: |
136 | mov [ntfs_data.iab_size], eax |
235 | mov [ebp+NTFS.iab_size], eax |
137 | ; allocate space for buffers |
236 | ; allocate space for buffers |
138 | add eax, [ntfs_data.frs_size] |
237 | add eax, [ebp+NTFS.frs_size] |
139 | push eax |
238 | push eax |
140 | call kernel_alloc |
239 | call kernel_alloc |
141 | test eax, eax |
240 | test eax, eax |
142 | jz problem_fat_dec_count |
241 | jz .fail_free |
143 | mov [ntfs_data.frs_buffer], eax |
242 | mov [ebp+NTFS.frs_buffer], eax |
144 | add eax, [ntfs_data.frs_size] |
243 | add eax, [ebp+NTFS.frs_size] |
145 | mov [ntfs_data.iab_buffer], eax |
244 | mov [ebp+NTFS.iab_buffer], eax |
146 | ; read $MFT disposition |
245 | ; read $MFT disposition |
147 | mov eax, [ntfs_data.mft_cluster] |
246 | mov eax, [ebp+NTFS.mft_cluster] |
148 | mul [ntfs_data.sectors_per_cluster] |
247 | mul [ebp+NTFS.sectors_per_cluster] |
149 | call ntfs_read_frs_sector |
248 | call ntfs_read_frs_sector |
150 | cmp [hd_error], 0 |
249 | test eax, eax |
151 | jnz .usemirr |
250 | jnz .usemirr |
152 | cmp dword [ebx], 'FILE' |
251 | cmp dword [ebx], 'FILE' |
153 | jnz .usemirr |
252 | jnz .usemirr |
154 | call ntfs_restore_usa_frs |
253 | call ntfs_restore_usa_frs |
155 | jnc .mftok |
254 | jnc .mftok |
156 | .usemirr: |
- | |
157 | and [hd_error], 0 |
255 | .usemirr: |
158 | mov eax, [ntfs_data.mftmirr_cluster] |
256 | mov eax, [ebp+NTFS.mftmirr_cluster] |
159 | mul [ntfs_data.sectors_per_cluster] |
257 | mul [ebp+NTFS.sectors_per_cluster] |
160 | call ntfs_read_frs_sector |
258 | call ntfs_read_frs_sector |
161 | cmp [hd_error], 0 |
259 | test eax, eax |
162 | jnz @f |
260 | jnz @f |
163 | cmp dword [ebx], 'FILE' |
261 | cmp dword [ebx], 'FILE' |
164 | jnz @f |
262 | jnz @f |
165 | call ntfs_restore_usa_frs |
263 | call ntfs_restore_usa_frs |
166 | jnc .mftok |
264 | jnc .mftok |
167 | @@: |
265 | @@: |
168 | ; $MFT and $MFTMirr invalid! |
266 | ; $MFT and $MFTMirr invalid! |
169 | .fail_free_frs: |
267 | .fail_free_frs: |
170 | push [ntfs_data.frs_buffer] |
268 | push [ebp+NTFS.frs_buffer] |
- | 269 | call kernel_free |
|
- | 270 | .fail_free: |
|
- | 271 | mov eax, ebp |
|
- | 272 | call free |
|
- | 273 | xor eax, eax |
|
- | 274 | .pop_exit: |
|
- | 275 | pop esi ebp ebx |
|
171 | call kernel_free |
276 | .exit: |
- | 277 | cmp dword [esp+4], 0 |
|
- | 278 | jz @f |
|
- | 279 | sub ebx, 512 |
|
- | 280 | @@: |
|
172 | jmp problem_fat_dec_count |
281 | ret |
173 | .fail_free_mft: |
282 | .fail_free_mft: |
174 | push [ntfs_data.mft_retrieval] |
283 | push [ebp+NTFS.mft_retrieval] |
175 | call kernel_free |
284 | call kernel_free |
176 | jmp .fail_free_frs |
285 | jmp .fail_free_frs |
177 | .mftok: |
286 | .mftok: |
178 | ; read $MFT table retrieval information |
287 | ; read $MFT table retrieval information |
Line 181... | Line 290... | ||
181 | push 0x1000 |
290 | push 0x1000 |
182 | call kernel_alloc |
291 | call kernel_alloc |
183 | pop ebx |
292 | pop ebx |
184 | test eax, eax |
293 | test eax, eax |
185 | jz .fail_free_frs |
294 | jz .fail_free_frs |
186 | mov [ntfs_data.mft_retrieval], eax |
295 | mov [ebp+NTFS.mft_retrieval], eax |
187 | and [ntfs_data.mft_retrieval_size], 0 |
296 | and [ebp+NTFS.mft_retrieval_size], 0 |
188 | mov [ntfs_data.mft_retrieval_alloc], 0x1000/8 |
297 | mov [ebp+NTFS.mft_retrieval_alloc], 0x1000/8 |
189 | ; $MFT base record must contain unnamed non-resident $DATA attribute |
298 | ; $MFT base record must contain unnamed non-resident $DATA attribute |
190 | movzx eax, word [ebx+14h] |
299 | movzx eax, word [ebx+14h] |
191 | add eax, ebx |
300 | add eax, ebx |
192 | .scandata: |
301 | .scandata: |
193 | cmp dword [eax], -1 |
302 | cmp dword [eax], -1 |
Line 202... | Line 311... | ||
202 | .founddata: |
311 | .founddata: |
203 | cmp byte [eax+8], 0 |
312 | cmp byte [eax+8], 0 |
204 | jz .fail_free_mft |
313 | jz .fail_free_mft |
205 | ; load first portion of $DATA attribute retrieval information |
314 | ; load first portion of $DATA attribute retrieval information |
206 | mov edx, [eax+0x18] |
315 | mov edx, [eax+0x18] |
207 | mov [ntfs_data.mft_retrieval_end], edx |
316 | mov [ebp+NTFS.mft_retrieval_end], edx |
208 | mov esi, eax |
317 | mov esi, eax |
209 | movzx eax, word [eax+0x20] |
318 | movzx eax, word [eax+0x20] |
210 | add esi, eax |
319 | add esi, eax |
211 | sub esp, 10h |
320 | sub esp, 10h |
212 | .scanmcb: |
321 | .scanmcb: |
Line 215... | Line 324... | ||
215 | call .get_mft_retrieval_ptr |
324 | call .get_mft_retrieval_ptr |
216 | mov edx, [esp] ; block length |
325 | mov edx, [esp] ; block length |
217 | mov [eax], edx |
326 | mov [eax], edx |
218 | mov edx, [esp+8] ; block addr (relative) |
327 | mov edx, [esp+8] ; block addr (relative) |
219 | mov [eax+4], edx |
328 | mov [eax+4], edx |
220 | inc [ntfs_data.mft_retrieval_size] |
329 | inc [ebp+NTFS.mft_retrieval_size] |
221 | jmp .scanmcb |
330 | jmp .scanmcb |
222 | .scanmcbend: |
331 | .scanmcbend: |
223 | add esp, 10h |
332 | add esp, 10h |
224 | ; there may be other portions of $DATA attribute in auxiliary records; |
333 | ; there may be other portions of $DATA attribute in auxiliary records; |
225 | ; if they will be needed, they will be loaded later |
334 | ; if they will be needed, they will be loaded later |
Line 226... | Line 335... | ||
226 | 335 | ||
227 | mov [ntfs_data.cur_index_size], 0x1000/0x200 |
336 | mov [ebp+NTFS.cur_index_size], 0x1000/0x200 |
228 | push 0x1000 |
337 | push 0x1000 |
229 | call kernel_alloc |
338 | call kernel_alloc |
230 | test eax, eax |
339 | test eax, eax |
231 | jz .fail_free_mft |
340 | jz .fail_free_mft |
Line 232... | Line -... | ||
232 | mov [ntfs_data.cur_index_buf], eax |
- | |
233 | 341 | mov [ebp+NTFS.cur_index_buf], eax |
|
234 | popad |
342 | |
235 | call free_hd_channel |
343 | mov eax, ebp |
Line 236... | Line 344... | ||
236 | and [hd1_status], 0 |
344 | jmp .pop_exit |
237 | ret |
345 | endp |
238 | 346 | ||
239 | .get_mft_retrieval_ptr: |
347 | .get_mft_retrieval_ptr: |
240 | pushad |
348 | pushad |
241 | mov eax, [ntfs_data.mft_retrieval_size] |
349 | mov eax, [ebp+NTFS.mft_retrieval_size] |
242 | cmp eax, [ntfs_data.mft_retrieval_alloc] |
350 | cmp eax, [ebp+NTFS.mft_retrieval_alloc] |
243 | jnz .ok |
351 | jnz .ok |
244 | add eax, 0x1000/8 |
352 | add eax, 0x1000/8 |
245 | mov [ntfs_data.mft_retrieval_alloc], eax |
353 | mov [ebp+NTFS.mft_retrieval_alloc], eax |
246 | shl eax, 3 |
354 | shl eax, 3 |
247 | push eax |
355 | push eax |
248 | call kernel_alloc |
356 | call kernel_alloc |
249 | test eax, eax |
357 | test eax, eax |
250 | jnz @f |
358 | jnz @f |
251 | popad |
359 | popad |
252 | add esp, 14h |
360 | add esp, 14h |
253 | jmp .fail_free_mft |
361 | jmp .fail_free_mft |
254 | @@: |
362 | @@: |
255 | mov esi, [ntfs_data.mft_retrieval] |
363 | mov esi, [ebp+NTFS.mft_retrieval] |
256 | mov edi, eax |
364 | mov edi, eax |
257 | mov ecx, [ntfs_data.mft_retrieval_size] |
365 | mov ecx, [ebp+NTFS.mft_retrieval_size] |
258 | add ecx, ecx |
366 | add ecx, ecx |
259 | rep movsd |
367 | rep movsd |
260 | push [ntfs_data.mft_retrieval] |
368 | push [ebp+NTFS.mft_retrieval] |
261 | mov [ntfs_data.mft_retrieval], eax |
369 | mov [ebp+NTFS.mft_retrieval], eax |
262 | call kernel_free |
370 | call kernel_free |
263 | mov eax, [ntfs_data.mft_retrieval_size] |
371 | mov eax, [ebp+NTFS.mft_retrieval_size] |
264 | .ok: |
372 | .ok: |
265 | shl eax, 3 |
373 | shl eax, 3 |
266 | add eax, [ntfs_data.mft_retrieval] |
374 | add eax, [ebp+NTFS.mft_retrieval] |
Line -... | Line 375... | ||
- | 375 | mov [esp+28], eax |
|
- | 376 | popad |
|
- | 377 | ret |
|
- | 378 | ||
- | 379 | proc ntfs_free |
|
- | 380 | push ebx |
|
- | 381 | xchg ebx, eax |
|
- | 382 | stdcall kernel_free, [ebx+NTFS.frs_buffer] |
|
- | 383 | stdcall kernel_free, [ebx+NTFS.mft_retrieval] |
|
- | 384 | stdcall kernel_free, [ebx+NTFS.cur_index_buf] |
|
- | 385 | xchg ebx, eax |
|
- | 386 | call free |
|
- | 387 | pop ebx |
|
- | 388 | ret |
|
- | 389 | endp |
|
- | 390 | ||
- | 391 | proc ntfs_lock |
|
- | 392 | lea ecx, [ebp+NTFS.Lock] |
|
- | 393 | jmp mutex_lock |
|
- | 394 | endp |
|
- | 395 | ||
- | 396 | proc ntfs_unlock |
|
267 | mov [esp+28], eax |
397 | lea ecx, [ebp+NTFS.Lock] |
268 | popad |
398 | jmp mutex_unlock |
269 | ret |
- | |
270 | - | ||
271 | ntfs_read_frs_sector: |
- | |
272 | push eax ecx |
399 | endp |
273 | add eax, [PARTITION_START] |
400 | |
- | 401 | ntfs_read_frs_sector: |
|
- | 402 | push ecx |
|
- | 403 | mov ebx, [ebp+NTFS.frs_buffer] |
|
- | 404 | push ebx |
|
274 | mov ecx, [ntfs_data.frs_size] |
405 | mov ecx, [ebp+NTFS.frs_size] |
- | 406 | shr ecx, 9 |
|
275 | shr ecx, 9 |
407 | push ecx |
276 | mov ebx, [ntfs_data.frs_buffer] |
408 | mov ecx, eax |
277 | push ebx |
409 | @@: |
278 | @@: |
410 | mov eax, ecx |
279 | call hd_read |
411 | call fs_read32_sys |
- | 412 | test eax, eax |
|
280 | cmp [hd_error], 0 |
413 | jnz .fail |
- | 414 | add ebx, 0x200 |
|
281 | jnz .fail |
415 | inc ecx |
282 | add ebx, 0x200 |
416 | dec dword [esp] |
283 | inc eax |
417 | jnz @b |
284 | loop @b |
418 | pop eax |
Line 285... | Line -... | ||
285 | .fail: |
- | |
286 | pop ebx |
- | |
287 | pop ecx eax |
- | |
288 | ret |
- | |
289 | - | ||
290 | uglobal |
- | |
291 | align 4 |
- | |
292 | ntfs_cur_attr dd ? |
- | |
293 | ntfs_cur_iRecord dd ? |
- | |
294 | ntfs_cur_offs dd ? ; in sectors |
- | |
295 | ntfs_cur_size dd ? ; in sectors |
- | |
296 | ntfs_cur_buf dd ? |
- | |
297 | ntfs_cur_read dd ? ; [output] |
- | |
298 | ntfs_bCanContinue db ? |
- | |
299 | rb 3 |
- | |
300 | - | ||
301 | ntfs_attrlist_buf rb 0x400 |
- | |
302 | ntfs_attrlist_mft_buf rb 0x400 |
- | |
303 | ntfs_bitmap_buf rb 0x400 |
- | |
304 | - | ||
305 | ntfs_attr_iRecord dd ? |
- | |
306 | ntfs_attr_iBaseRecord dd ? |
- | |
307 | ntfs_attr_offs dd ? |
- | |
308 | ntfs_attr_list dd ? |
419 | .fail: |
309 | ntfs_attr_size dq ? |
420 | pop ebx |
310 | ntfs_cur_tail dd ? |
421 | pop ecx |
- | 422 | ret |
|
- | 423 | ||
311 | endg |
424 | ntfs_read_attr: |
312 | 425 | ; in: variables in ebp+NTFS.* |
|
313 | ntfs_read_attr: |
426 | ; out: [ebp+NTFS.ntfs_cur_read] |
314 | ; in: global variables |
427 | ; out: CF=1 => notfound, in this case eax=0 => disk ok, otherwise eax=disk error code |
315 | ; out: [ntfs_cur_read] |
428 | xor eax, eax |
316 | pushad |
429 | pushad |
317 | and [ntfs_cur_read], 0 |
430 | and [ebp+NTFS.ntfs_cur_read], 0 |
318 | cmp [ntfs_cur_iRecord], 0 |
431 | cmp [ebp+NTFS.ntfs_cur_iRecord], 0 |
319 | jnz .nomft |
432 | jnz .nomft |
320 | cmp [ntfs_cur_attr], 0x80 |
433 | cmp [ebp+NTFS.ntfs_cur_attr], 0x80 |
321 | jnz .nomft |
434 | jnz .nomft |
322 | mov eax, [ntfs_data.mft_retrieval_end] |
435 | mov eax, [ebp+NTFS.mft_retrieval_end] |
323 | inc eax |
436 | inc eax |
324 | mul [ntfs_data.sectors_per_cluster] |
437 | mul [ebp+NTFS.sectors_per_cluster] |
325 | cmp eax, [ntfs_cur_offs] |
438 | cmp eax, [ebp+NTFS.ntfs_cur_offs] |
326 | jbe .nomft |
439 | jbe .nomft |
327 | ; precalculated part of $Mft $DATA |
440 | ; precalculated part of $Mft $DATA |
328 | mov esi, [ntfs_data.mft_retrieval] |
441 | mov esi, [ebp+NTFS.mft_retrieval] |
329 | mov eax, [ntfs_cur_offs] |
442 | mov eax, [ebp+NTFS.ntfs_cur_offs] |
330 | xor edx, edx |
443 | xor edx, edx |
331 | div [ntfs_data.sectors_per_cluster] |
444 | div [ebp+NTFS.sectors_per_cluster] |
332 | ; eax = VCN, edx = offset in sectors from beginning of cluster |
445 | ; eax = VCN, edx = offset in sectors from beginning of cluster |
333 | xor ecx, ecx ; ecx will contain LCN |
446 | xor ecx, ecx ; ecx will contain LCN |
334 | .mftscan: |
447 | .mftscan: |
335 | add ecx, [esi+4] |
448 | add ecx, [esi+4] |
336 | sub eax, [esi] |
449 | sub eax, [esi] |
337 | jb @f |
450 | jb @f |
338 | add esi, 8 |
451 | add esi, 8 |
339 | push eax |
452 | push eax |
340 | mov eax, [ntfs_data.mft_retrieval_end] |
453 | mov eax, [ebp+NTFS.mft_retrieval_end] |
341 | shl eax, 3 |
454 | shl eax, 3 |
342 | add eax, [ntfs_data.mft_retrieval] |
455 | add eax, [ebp+NTFS.mft_retrieval] |
343 | cmp eax, esi |
456 | cmp eax, esi |
344 | pop eax |
457 | pop eax |
345 | jnz .mftscan |
458 | jnz .mftscan |
346 | jmp .nomft |
459 | jmp .nomft |
347 | @@: |
460 | @@: |
348 | push ecx |
461 | push ecx |
349 | add ecx, eax |
462 | add ecx, eax |
350 | add ecx, [esi] |
463 | add ecx, [esi] |
351 | push eax |
- | |
352 | push edx |
464 | push eax |
353 | mov eax, [ntfs_data.sectors_per_cluster] |
465 | push edx |
354 | mul ecx |
466 | mov eax, [ebp+NTFS.sectors_per_cluster] |
355 | ; eax = sector on partition |
467 | mul ecx |
356 | add eax, [PARTITION_START] |
468 | ; eax = sector on partition |
357 | pop edx |
469 | pop edx |
358 | add eax, edx |
470 | add eax, edx |
359 | mov ebx, [ntfs_cur_buf] |
471 | mov ebx, [ebp+NTFS.ntfs_cur_buf] |
360 | pop ecx |
472 | pop ecx |
361 | neg ecx |
473 | neg ecx |
362 | imul ecx, [ntfs_data.sectors_per_cluster] |
474 | imul ecx, [ebp+NTFS.sectors_per_cluster] |
363 | sub ecx, edx |
475 | sub ecx, edx |
- | 476 | cmp ecx, [ebp+NTFS.ntfs_cur_size] |
|
364 | cmp ecx, [ntfs_cur_size] |
477 | jb @f |
365 | jb @f |
478 | mov ecx, [ebp+NTFS.ntfs_cur_size] |
- | 479 | @@: |
|
366 | mov ecx, [ntfs_cur_size] |
480 | ; ecx = number of sequential sectors to read |
367 | @@: |
481 | push eax |
368 | ; ecx = number of sequential sectors to read |
482 | call fs_read32_sys |
369 | call hd_read |
483 | pop edx |
370 | cmp [hd_error], 0 |
484 | test eax, eax |
371 | jnz .errread |
485 | jnz .errread |
372 | add [ntfs_cur_read], 0x200 |
486 | add [ebp+NTFS.ntfs_cur_read], 0x200 |
373 | dec [ntfs_cur_size] |
487 | dec [ebp+NTFS.ntfs_cur_size] |
374 | inc [ntfs_cur_offs] |
488 | inc [ebp+NTFS.ntfs_cur_offs] |
375 | add ebx, 0x200 |
489 | add ebx, 0x200 |
376 | mov [ntfs_cur_buf], ebx |
490 | mov [ebp+NTFS.ntfs_cur_buf], ebx |
377 | inc eax |
491 | lea eax, [edx+1] |
378 | loop @b |
492 | loop @b |
379 | pop ecx |
493 | pop ecx |
380 | xor eax, eax |
494 | xor eax, eax |
381 | xor edx, edx |
495 | xor edx, edx |
382 | cmp [ntfs_cur_size], eax |
496 | cmp [ebp+NTFS.ntfs_cur_size], eax |
383 | jz @f |
497 | jz @f |
384 | add esi, 8 |
498 | add esi, 8 |
385 | push eax |
499 | push eax |
386 | mov eax, [ntfs_data.mft_retrieval_end] |
500 | mov eax, [ebp+NTFS.mft_retrieval_end] |
387 | shl eax, 3 |
501 | shl eax, 3 |
388 | add eax, [ntfs_data.mft_retrieval] |
502 | add eax, [ebp+NTFS.mft_retrieval] |
389 | cmp eax, esi |
503 | cmp eax, esi |
390 | pop eax |
504 | pop eax |
391 | jz .nomft |
505 | jz .nomft |
392 | jmp .mftscan |
506 | jmp .mftscan |
393 | @@: |
507 | @@: |
- | 508 | popad |
|
394 | popad |
509 | ret |
395 | ret |
510 | .errread: |
396 | .errread: |
511 | pop ecx |
397 | pop ecx |
512 | .errret: |
398 | .errret: |
513 | mov [esp+28], eax |
399 | stc |
514 | stc |
400 | popad |
515 | popad |
401 | ret |
516 | ret |
402 | .nomft: |
517 | .nomft: |
403 | ; 1. Read file record. |
518 | ; 1. Read file record. |
404 | ; N.B. This will do recursive call of read_attr for $MFT::$Data. |
519 | ; N.B. This will do recursive call of read_attr for $MFT::$Data. |
405 | mov eax, [ntfs_cur_iRecord] |
520 | mov eax, [ebp+NTFS.ntfs_cur_iRecord] |
406 | mov [ntfs_attr_iRecord], eax |
521 | mov [ebp+NTFS.ntfs_attr_iRecord], eax |
407 | and [ntfs_attr_list], 0 |
- | |
408 | or dword [ntfs_attr_size], -1 |
522 | and [ebp+NTFS.ntfs_attr_list], 0 |
409 | or dword [ntfs_attr_size+4], -1 |
523 | or dword [ebp+NTFS.ntfs_attr_size], -1 |
410 | or [ntfs_attr_iBaseRecord], -1 |
524 | or dword [ebp+NTFS.ntfs_attr_size+4], -1 |
411 | call ntfs_read_file_record |
525 | or [ebp+NTFS.ntfs_attr_iBaseRecord], -1 |
412 | test eax, eax |
526 | call ntfs_read_file_record |
413 | jz .errret |
527 | jc .errret |
414 | ; 2. Find required attribute. |
528 | ; 2. Find required attribute. |
415 | mov eax, [ntfs_data.frs_buffer] |
529 | mov eax, [ebp+NTFS.frs_buffer] |
416 | ; a) For auxiliary records, read base record |
530 | ; a) For auxiliary records, read base record |
417 | ; N.B. If base record is present, |
531 | ; N.B. If base record is present, |
418 | ; base iRecord may be 0 (for $Mft), but SequenceNumber is nonzero |
532 | ; base iRecord may be 0 (for $Mft), but SequenceNumber is nonzero |
419 | cmp dword [eax+24h], 0 |
533 | cmp dword [eax+24h], 0 |
420 | jz @f |
534 | jz @f |
421 | mov eax, [eax+20h] |
535 | mov eax, [eax+20h] |
422 | ; test eax, eax |
- | |
423 | ; jz @f |
536 | ; test eax, eax |
424 | .beginfindattr: |
537 | ; jz @f |
425 | mov [ntfs_attr_iRecord], eax |
538 | .beginfindattr: |
426 | call ntfs_read_file_record |
539 | mov [ebp+NTFS.ntfs_attr_iRecord], eax |
427 | test eax, eax |
540 | call ntfs_read_file_record |
428 | jz .errret |
541 | jc .errret |
429 | @@: |
542 | @@: |
430 | ; b) Scan for required attribute and for $ATTR_LIST |
543 | ; b) Scan for required attribute and for $ATTR_LIST |
431 | mov eax, [ntfs_data.frs_buffer] |
544 | mov eax, [ebp+NTFS.frs_buffer] |
432 | movzx ecx, word [eax+14h] |
545 | movzx ecx, word [eax+14h] |
433 | add eax, ecx |
546 | add eax, ecx |
434 | mov ecx, [ntfs_cur_attr] |
547 | mov ecx, [ebp+NTFS.ntfs_cur_attr] |
435 | and [ntfs_attr_offs], 0 |
548 | and [ebp+NTFS.ntfs_attr_offs], 0 |
436 | .scanattr: |
549 | .scanattr: |
437 | cmp dword [eax], -1 |
550 | cmp dword [eax], -1 |
438 | jz .scandone |
551 | jz .scandone |
439 | cmp dword [eax], ecx |
552 | cmp dword [eax], ecx |
440 | jz .okattr |
553 | jz .okattr |
441 | cmp [ntfs_attr_iBaseRecord], -1 |
554 | cmp [ebp+NTFS.ntfs_attr_iBaseRecord], -1 |
442 | jnz .scancont |
555 | jnz .scancont |
443 | cmp dword [eax], 0x20 ; $ATTR_LIST |
556 | cmp dword [eax], 0x20 ; $ATTR_LIST |
444 | jnz .scancont |
557 | jnz .scancont |
445 | mov [ntfs_attr_list], eax |
558 | mov [ebp+NTFS.ntfs_attr_list], eax |
446 | jmp .scancont |
559 | jmp .scancont |
447 | .okattr: |
560 | .okattr: |
448 | ; ignore named $DATA attributes (aka NTFS streams) |
561 | ; ignore named $DATA attributes (aka NTFS streams) |
449 | cmp ecx, 0x80 |
562 | cmp ecx, 0x80 |
450 | jnz @f |
563 | jnz @f |
451 | cmp byte [eax+9], 0 |
564 | cmp byte [eax+9], 0 |
452 | jnz .scancont |
565 | jnz .scancont |
453 | @@: |
566 | @@: |
454 | mov [ntfs_attr_offs], eax |
567 | mov [ebp+NTFS.ntfs_attr_offs], eax |
455 | .scancont: |
568 | .scancont: |
456 | add eax, [eax+4] |
569 | add eax, [eax+4] |
457 | jmp .scanattr |
570 | jmp .scanattr |
458 | .continue: |
571 | .continue: |
459 | pushad |
572 | pushad |
460 | and [ntfs_cur_read], 0 |
573 | and [ebp+NTFS.ntfs_cur_read], 0 |
461 | .scandone: |
574 | .scandone: |
462 | ; c) Check for required offset and length |
575 | ; c) Check for required offset and length |
463 | mov ecx, [ntfs_attr_offs] |
576 | mov ecx, [ebp+NTFS.ntfs_attr_offs] |
464 | jecxz .noattr |
577 | jecxz .noattr |
465 | push [ntfs_cur_size] |
578 | push [ebp+NTFS.ntfs_cur_size] |
466 | push [ntfs_cur_read] |
579 | push [ebp+NTFS.ntfs_cur_read] |
467 | call .doreadattr |
580 | call .doreadattr |
468 | pop edx |
581 | pop edx |
469 | pop eax |
582 | pop ecx |
470 | jc @f |
583 | jc @f |
471 | cmp [ntfs_bCanContinue], 0 |
584 | cmp [ebp+NTFS.ntfs_bCanContinue], 0 |
472 | jz @f |
585 | jz @f |
473 | sub edx, [ntfs_cur_read] |
586 | sub edx, [ebp+NTFS.ntfs_cur_read] |
474 | neg edx |
587 | neg edx |
475 | shr edx, 9 |
588 | shr edx, 9 |
476 | sub eax, edx |
589 | sub ecx, edx |
477 | mov [ntfs_cur_size], eax |
590 | mov [ebp+NTFS.ntfs_cur_size], ecx |
478 | jnz .not_in_cur |
591 | jnz .not_in_cur |
479 | @@: |
592 | @@: |
480 | popad |
593 | popad |
481 | ret |
594 | ret |
482 | .noattr: |
595 | .noattr: |
483 | .not_in_cur: |
596 | .not_in_cur: |
484 | cmp [ntfs_cur_attr], 0x20 |
597 | cmp [ebp+NTFS.ntfs_cur_attr], 0x20 |
- | 598 | jz @f |
|
485 | jz @f |
599 | mov ecx, [ebp+NTFS.ntfs_attr_list] |
486 | mov ecx, [ntfs_attr_list] |
600 | test ecx, ecx |
487 | test ecx, ecx |
601 | jnz .lookattr |
488 | jnz .lookattr |
602 | .ret_is_attr: |
489 | .ret_is_attr: |
603 | and dword [esp+28], 0 |
490 | cmp [ntfs_attr_offs], 1 ; CF set <=> ntfs_attr_offs == 0 |
604 | cmp [ebp+NTFS.ntfs_attr_offs], 1 ; CF set <=> ntfs_attr_offs == 0 |
491 | popad |
605 | popad |
492 | ret |
606 | ret |
493 | .lookattr: |
607 | .lookattr: |
494 | ; required attribute or required offset was not found in base record; |
608 | ; required attribute or required offset was not found in base record; |
495 | ; it may be present in auxiliary records; |
609 | ; it may be present in auxiliary records; |
496 | ; scan $ATTR_LIST |
- | |
497 | mov eax, [ntfs_attr_iBaseRecord] |
610 | ; scan $ATTR_LIST |
498 | cmp eax, -1 |
611 | mov eax, [ebp+NTFS.ntfs_attr_iBaseRecord] |
499 | jz @f |
612 | cmp eax, -1 |
500 | call ntfs_read_file_record |
613 | jz @f |
501 | test eax, eax |
614 | call ntfs_read_file_record |
502 | jz .errret |
615 | jc .errret |
503 | or [ntfs_attr_iBaseRecord], -1 |
616 | or [ebp+NTFS.ntfs_attr_iBaseRecord], -1 |
504 | @@: |
617 | @@: |
505 | push [ntfs_cur_offs] |
618 | push [ebp+NTFS.ntfs_cur_offs] |
506 | push [ntfs_cur_size] |
619 | push [ebp+NTFS.ntfs_cur_size] |
507 | push [ntfs_cur_read] |
620 | push [ebp+NTFS.ntfs_cur_read] |
508 | push [ntfs_cur_buf] |
621 | push [ebp+NTFS.ntfs_cur_buf] |
509 | push dword [ntfs_attr_size] |
622 | push dword [ebp+NTFS.ntfs_attr_size] |
510 | push dword [ntfs_attr_size+4] |
623 | push dword [ebp+NTFS.ntfs_attr_size+4] |
511 | or dword [ntfs_attr_size], -1 |
624 | or dword [ebp+NTFS.ntfs_attr_size], -1 |
512 | or dword [ntfs_attr_size+4], -1 |
625 | or dword [ebp+NTFS.ntfs_attr_size+4], -1 |
513 | and [ntfs_cur_offs], 0 |
626 | and [ebp+NTFS.ntfs_cur_offs], 0 |
514 | mov [ntfs_cur_size], 2 |
627 | mov [ebp+NTFS.ntfs_cur_size], 2 |
515 | and [ntfs_cur_read], 0 |
628 | and [ebp+NTFS.ntfs_cur_read], 0 |
516 | mov eax, ntfs_attrlist_buf |
629 | lea eax, [ebp+NTFS.ntfs_attrlist_buf] |
517 | cmp [ntfs_cur_iRecord], 0 |
630 | cmp [ebp+NTFS.ntfs_cur_iRecord], 0 |
518 | jnz @f |
631 | jnz @f |
519 | mov eax, ntfs_attrlist_mft_buf |
632 | lea eax, [ebp+NTFS.ntfs_attrlist_mft_buf] |
520 | @@: |
633 | @@: |
521 | mov [ntfs_cur_buf], eax |
634 | mov [ebp+NTFS.ntfs_cur_buf], eax |
522 | push eax |
635 | push eax |
523 | call .doreadattr |
636 | call .doreadattr |
524 | pop esi |
637 | pop esi |
525 | mov edx, 1 |
638 | mov edx, 1 |
526 | pop dword [ntfs_attr_size+4] |
639 | pop dword [ebp+NTFS.ntfs_attr_size+4] |
527 | pop dword [ntfs_attr_size] |
640 | pop dword [ebp+NTFS.ntfs_attr_size] |
528 | mov ebp, [ntfs_cur_read] |
641 | mov ecx, [ebp+NTFS.ntfs_cur_read] |
529 | pop [ntfs_cur_buf] |
642 | pop [ebp+NTFS.ntfs_cur_buf] |
530 | pop [ntfs_cur_read] |
643 | pop [ebp+NTFS.ntfs_cur_read] |
531 | pop [ntfs_cur_size] |
644 | pop [ebp+NTFS.ntfs_cur_size] |
- | 645 | pop [ebp+NTFS.ntfs_cur_offs] |
|
532 | pop [ntfs_cur_offs] |
646 | jc .errret |
533 | jc .errret |
647 | or edi, -1 |
534 | or edi, -1 |
648 | lea ecx, [ecx+esi-1Ah] |
535 | lea ebp, [ebp+esi-1Ah] |
649 | .scanliststart: |
536 | .scanliststart: |
650 | push ecx |
537 | mov eax, [ntfs_cur_attr] |
651 | mov eax, [ebp+NTFS.ntfs_cur_attr] |
538 | .scanlist: |
652 | .scanlist: |
539 | cmp esi, ebp |
653 | cmp esi, [esp] |
Line 553... | Line 667... | ||
553 | @@: |
667 | @@: |
554 | push eax |
668 | push eax |
555 | mov eax, [esi+8] |
669 | mov eax, [esi+8] |
556 | test eax, eax |
670 | test eax, eax |
557 | jnz .testf |
671 | jnz .testf |
558 | mov eax, dword [ntfs_attr_size] |
672 | mov eax, dword [ebp+NTFS.ntfs_attr_size] |
559 | and eax, dword [ntfs_attr_size+4] |
673 | and eax, dword [ebp+NTFS.ntfs_attr_size+4] |
560 | cmp eax, -1 |
674 | cmp eax, -1 |
561 | jnz .testfz |
675 | jnz .testfz |
562 | ; if attribute is in auxiliary records, its size is defined only in first |
676 | ; if attribute is in auxiliary records, its size is defined only in first |
563 | mov eax, [esi+10h] |
677 | mov eax, [esi+10h] |
564 | call ntfs_read_file_record |
678 | call ntfs_read_file_record |
565 | test eax, eax |
- | |
566 | jnz @f |
679 | jnc @f |
567 | .errret_pop: |
680 | .errret_pop: |
568 | pop eax |
681 | pop ecx ecx |
569 | jmp .errret |
682 | jmp .errret |
- | 683 | .errret2_pop: |
|
- | 684 | xor eax, eax |
|
- | 685 | jmp .errret_pop |
|
570 | @@: |
686 | @@: |
571 | mov eax, [ntfs_data.frs_buffer] |
687 | mov eax, [ebp+NTFS.frs_buffer] |
572 | movzx ecx, word [eax+14h] |
688 | movzx ecx, word [eax+14h] |
573 | add eax, ecx |
689 | add eax, ecx |
574 | mov ecx, [ntfs_cur_attr] |
690 | mov ecx, [ebp+NTFS.ntfs_cur_attr] |
575 | @@: |
691 | @@: |
576 | cmp dword [eax], -1 |
692 | cmp dword [eax], -1 |
577 | jz .errret_pop |
693 | jz .errret2_pop |
578 | cmp dword [eax], ecx |
694 | cmp dword [eax], ecx |
579 | jz @f |
695 | jz @f |
580 | .l1: |
696 | .l1: |
581 | add eax, [eax+4] |
697 | add eax, [eax+4] |
582 | jmp @b |
698 | jmp @b |
Line 587... | Line 703... | ||
587 | jnz .l1 |
703 | jnz .l1 |
588 | @@: |
704 | @@: |
589 | cmp byte [eax+8], 0 |
705 | cmp byte [eax+8], 0 |
590 | jnz .sdnores |
706 | jnz .sdnores |
591 | mov eax, [eax+10h] |
707 | mov eax, [eax+10h] |
592 | mov dword [ntfs_attr_size], eax |
708 | mov dword [ebp+NTFS.ntfs_attr_size], eax |
593 | and dword [ntfs_attr_size+4], 0 |
709 | and dword [ebp+NTFS.ntfs_attr_size+4], 0 |
594 | jmp .testfz |
710 | jmp .testfz |
595 | .sdnores: |
711 | .sdnores: |
596 | mov ecx, [eax+30h] |
712 | mov ecx, [eax+30h] |
597 | mov dword [ntfs_attr_size], ecx |
713 | mov dword [ebp+NTFS.ntfs_attr_size], ecx |
598 | mov ecx, [eax+34h] |
714 | mov ecx, [eax+34h] |
599 | mov dword [ntfs_attr_size+4], ecx |
715 | mov dword [ebp+NTFS.ntfs_attr_size+4], ecx |
600 | .testfz: |
716 | .testfz: |
601 | xor eax, eax |
717 | xor eax, eax |
602 | .testf: |
718 | .testf: |
603 | imul eax, [ntfs_data.sectors_per_cluster] |
719 | imul eax, [ebp+NTFS.sectors_per_cluster] |
604 | cmp eax, [ntfs_cur_offs] |
720 | cmp eax, [ebp+NTFS.ntfs_cur_offs] |
605 | pop eax |
721 | pop eax |
606 | ja @f |
722 | ja @f |
607 | mov edi, [esi+10h] ; keep previous iRecord |
723 | mov edi, [esi+10h] ; keep previous iRecord |
608 | jmp .scanlistcont |
724 | jmp .scanlistcont |
609 | @@: |
725 | @@: |
- | 726 | pop ecx |
|
610 | .scanlistfound: |
727 | .scanlistfound: |
611 | cmp edi, -1 |
728 | cmp edi, -1 |
612 | jnz @f |
729 | jnz @f |
613 | popad |
730 | popad |
614 | ret |
731 | ret |
615 | @@: |
732 | @@: |
616 | mov eax, [ntfs_cur_iRecord] |
733 | mov eax, [ebp+NTFS.ntfs_cur_iRecord] |
617 | mov [ntfs_attr_iBaseRecord], eax |
734 | mov [ebp+NTFS.ntfs_attr_iBaseRecord], eax |
618 | mov eax, edi |
735 | mov eax, edi |
619 | jmp .beginfindattr |
736 | jmp .beginfindattr |
620 | .sde: |
- | |
621 | popad |
- | |
622 | stc |
- | |
623 | ret |
- | |
624 | .scanlistdone: |
737 | .scanlistdone: |
- | 738 | pop ecx |
|
- | 739 | sub ecx, ebp |
|
625 | sub ebp, ntfs_attrlist_buf-1Ah |
740 | sub ecx, NTFS.ntfs_attrlist_buf-1Ah |
626 | cmp [ntfs_cur_iRecord], 0 |
741 | cmp [ebp+NTFS.ntfs_cur_iRecord], 0 |
627 | jnz @f |
742 | jnz @f |
628 | sub ebp, ntfs_attrlist_mft_buf-ntfs_attrlist_buf |
743 | sub ecx, NTFS.ntfs_attrlist_mft_buf-NTFS.ntfs_attrlist_buf |
629 | @@: |
744 | @@: |
630 | cmp ebp, 0x400 |
745 | cmp ecx, 0x400 |
631 | jnz .scanlistfound |
746 | jnz .scanlistfound |
632 | inc edx |
747 | inc edx |
633 | push esi edi |
748 | push esi edi |
634 | mov esi, ntfs_attrlist_buf+0x200 |
749 | lea esi, [ebp+NTFS.ntfs_attrlist_buf+0x200] |
635 | mov edi, ntfs_attrlist_buf |
750 | lea edi, [ebp+NTFS.ntfs_attrlist_buf] |
636 | cmp [ntfs_cur_iRecord], 0 |
751 | cmp [ebp+NTFS.ntfs_cur_iRecord], 0 |
637 | jnz @f |
752 | jnz @f |
638 | mov esi, ntfs_attrlist_mft_buf+0x200 |
753 | lea esi, [ebp+NTFS.ntfs_attrlist_mft_buf+0x200] |
639 | mov edi, ntfs_attrlist_mft_buf |
754 | lea edi, [ebp+NTFS.ntfs_attrlist_mft_buf] |
640 | @@: |
755 | @@: |
641 | mov ecx, 0x200/4 |
756 | mov ecx, 0x200/4 |
642 | rep movsd |
757 | rep movsd |
643 | mov eax, edi |
758 | mov eax, edi |
644 | pop edi esi |
759 | pop edi esi |
645 | sub esi, 0x200 |
760 | sub esi, 0x200 |
646 | push [ntfs_cur_offs] |
761 | push [ebp+NTFS.ntfs_cur_offs] |
647 | push [ntfs_cur_size] |
762 | push [ebp+NTFS.ntfs_cur_size] |
648 | push [ntfs_cur_read] |
763 | push [ebp+NTFS.ntfs_cur_read] |
649 | push [ntfs_cur_buf] |
764 | push [ebp+NTFS.ntfs_cur_buf] |
650 | push dword [ntfs_attr_size] |
765 | push dword [ebp+NTFS.ntfs_attr_size] |
651 | push dword [ntfs_attr_size+4] |
766 | push dword [ebp+NTFS.ntfs_attr_size+4] |
652 | or dword [ntfs_attr_size], -1 |
767 | or dword [ebp+NTFS.ntfs_attr_size], -1 |
653 | or dword [ntfs_attr_size+4], -1 |
768 | or dword [ebp+NTFS.ntfs_attr_size+4], -1 |
654 | mov [ntfs_cur_offs], edx |
769 | mov [ebp+NTFS.ntfs_cur_offs], edx |
655 | mov [ntfs_cur_size], 1 |
770 | mov [ebp+NTFS.ntfs_cur_size], 1 |
656 | and [ntfs_cur_read], 0 |
771 | and [ebp+NTFS.ntfs_cur_read], 0 |
657 | mov [ntfs_cur_buf], eax |
772 | mov [ebp+NTFS.ntfs_cur_buf], eax |
658 | mov ecx, [ntfs_attr_list] |
773 | mov ecx, [ebp+NTFS.ntfs_attr_list] |
659 | push esi edx |
774 | push esi edx edi |
660 | call .doreadattr |
775 | call .doreadattr |
661 | pop edx esi |
776 | pop edi edx esi |
662 | mov ebp, [ntfs_cur_read] |
777 | mov ecx, [ebp+NTFS.ntfs_cur_read] |
663 | pop dword [ntfs_attr_size+4] |
778 | pop dword [ebp+NTFS.ntfs_attr_size+4] |
664 | pop dword [ntfs_attr_size] |
779 | pop dword [ebp+NTFS.ntfs_attr_size] |
665 | pop [ntfs_cur_buf] |
780 | pop [ebp+NTFS.ntfs_cur_buf] |
666 | pop [ntfs_cur_read] |
781 | pop [ebp+NTFS.ntfs_cur_read] |
667 | pop [ntfs_cur_size] |
782 | pop [ebp+NTFS.ntfs_cur_size] |
668 | pop [ntfs_cur_offs] |
783 | pop [ebp+NTFS.ntfs_cur_offs] |
669 | jc .errret |
784 | jc .errret |
670 | add ebp, ntfs_attrlist_buf+0x200-0x1A |
785 | lea ecx, [ecx+ebp+NTFS.ntfs_attrlist_buf+0x200-0x1A] |
671 | cmp [ntfs_cur_iRecord], 0 |
786 | cmp [ebp+NTFS.ntfs_cur_iRecord], 0 |
672 | jnz .scanliststart |
787 | jnz .scanliststart |
673 | add ebp, ntfs_attrlist_mft_buf-ntfs_attrlist_buf |
788 | add ecx, NTFS.ntfs_attrlist_mft_buf-NTFS.ntfs_attrlist_buf |
674 | jmp .scanliststart |
789 | jmp .scanliststart |
Line 675... | Line 790... | ||
675 | 790 | ||
676 | .doreadattr: |
791 | .doreadattr: |
677 | mov [ntfs_bCanContinue], 0 |
792 | mov [ebp+NTFS.ntfs_bCanContinue], 0 |
678 | cmp byte [ecx+8], 0 |
793 | cmp byte [ecx+8], 0 |
679 | jnz .nonresident |
794 | jnz .nonresident |
680 | mov eax, [ecx+10h] ; length |
795 | mov eax, [ecx+10h] ; length |
681 | mov esi, eax |
796 | mov esi, eax |
682 | mov edx, [ntfs_cur_offs] |
797 | mov edx, [ebp+NTFS.ntfs_cur_offs] |
683 | shr eax, 9 |
798 | shr eax, 9 |
684 | cmp eax, edx |
799 | cmp eax, edx |
685 | jb .okret |
800 | jb .okret |
686 | shl edx, 9 |
801 | shl edx, 9 |
687 | sub esi, edx |
802 | sub esi, edx |
688 | movzx eax, word [ecx+14h] |
803 | movzx eax, word [ecx+14h] |
689 | add edx, eax |
804 | add edx, eax |
690 | add edx, ecx ; edx -> data |
805 | add edx, ecx ; edx -> data |
691 | mov eax, [ntfs_cur_size] |
806 | mov eax, [ebp+NTFS.ntfs_cur_size] |
692 | cmp eax, (0xFFFFFFFF shr 9)+1 |
807 | cmp eax, (0xFFFFFFFF shr 9)+1 |
693 | jbe @f |
808 | jbe @f |
694 | mov eax, (0xFFFFFFFF shr 9)+1 |
809 | mov eax, (0xFFFFFFFF shr 9)+1 |
695 | @@: |
810 | @@: |
696 | shl eax, 9 |
811 | shl eax, 9 |
697 | cmp eax, esi |
812 | cmp eax, esi |
698 | jbe @f |
813 | jbe @f |
699 | mov eax, esi |
814 | mov eax, esi |
700 | @@: |
815 | @@: |
701 | ; eax = length, edx -> data |
816 | ; eax = length, edx -> data |
702 | mov [ntfs_cur_read], eax |
817 | mov [ebp+NTFS.ntfs_cur_read], eax |
703 | mov ecx, eax |
818 | mov ecx, eax |
704 | mov eax, edx |
819 | mov eax, edx |
705 | mov ebx, [ntfs_cur_buf] |
820 | mov ebx, [ebp+NTFS.ntfs_cur_buf] |
706 | call memmove |
821 | call memmove |
707 | and [ntfs_cur_size], 0 ; CF=0 |
822 | and [ebp+NTFS.ntfs_cur_size], 0 ; CF=0 |
708 | ret |
823 | ret |
709 | .nonresident: |
824 | .nonresident: |
710 | ; Not all auxiliary records contain correct FileSize info |
825 | ; Not all auxiliary records contain correct FileSize info |
711 | mov eax, dword [ntfs_attr_size] |
826 | mov eax, dword [ebp+NTFS.ntfs_attr_size] |
712 | mov edx, dword [ntfs_attr_size+4] |
827 | mov edx, dword [ebp+NTFS.ntfs_attr_size+4] |
713 | push eax |
828 | push eax |
714 | and eax, edx |
829 | and eax, edx |
715 | cmp eax, -1 |
830 | cmp eax, -1 |
716 | pop eax |
831 | pop eax |
717 | jnz @f |
832 | jnz @f |
718 | mov eax, [ecx+30h] ; FileSize |
833 | mov eax, [ecx+30h] ; FileSize |
719 | mov edx, [ecx+34h] |
834 | mov edx, [ecx+34h] |
720 | mov dword [ntfs_attr_size], eax |
835 | mov dword [ebp+NTFS.ntfs_attr_size], eax |
721 | mov dword [ntfs_attr_size+4], edx |
836 | mov dword [ebp+NTFS.ntfs_attr_size+4], edx |
722 | @@: |
837 | @@: |
723 | add eax, 0x1FF |
838 | add eax, 0x1FF |
724 | adc edx, 0 |
839 | adc edx, 0 |
725 | shrd eax, edx, 9 |
840 | shrd eax, edx, 9 |
726 | sub eax, [ntfs_cur_offs] |
841 | sub eax, [ebp+NTFS.ntfs_cur_offs] |
727 | ja @f |
842 | ja @f |
728 | ; return with nothing read |
843 | ; return with nothing read |
729 | and [ntfs_cur_size], 0 |
844 | and [ebp+NTFS.ntfs_cur_size], 0 |
730 | .okret: |
845 | .okret: |
731 | clc |
846 | clc |
732 | ret |
847 | ret |
733 | @@: |
848 | @@: |
734 | ; reduce read length |
849 | ; reduce read length |
735 | and [ntfs_cur_tail], 0 |
850 | and [ebp+NTFS.ntfs_cur_tail], 0 |
736 | cmp [ntfs_cur_size], eax |
851 | cmp [ebp+NTFS.ntfs_cur_size], eax |
737 | jb @f |
852 | jb @f |
738 | mov [ntfs_cur_size], eax |
853 | mov [ebp+NTFS.ntfs_cur_size], eax |
739 | mov eax, dword [ntfs_attr_size] |
854 | mov eax, dword [ebp+NTFS.ntfs_attr_size] |
740 | and eax, 0x1FF |
855 | and eax, 0x1FF |
741 | mov [ntfs_cur_tail], eax |
856 | mov [ebp+NTFS.ntfs_cur_tail], eax |
742 | @@: |
857 | @@: |
743 | cmp [ntfs_cur_size], 0 |
858 | cmp [ebp+NTFS.ntfs_cur_size], 0 |
744 | jz .okret |
859 | jz .okret |
745 | mov eax, [ntfs_cur_offs] |
860 | mov eax, [ebp+NTFS.ntfs_cur_offs] |
746 | xor edx, edx |
861 | xor edx, edx |
747 | div [ntfs_data.sectors_per_cluster] |
862 | div [ebp+NTFS.sectors_per_cluster] |
748 | sub eax, [ecx+10h] ; first_vbo |
863 | sub eax, [ecx+10h] ; first_vbo |
749 | jb .okret |
864 | jb .okret |
750 | ; eax = cluster, edx = starting sector |
865 | ; eax = cluster, edx = starting sector |
751 | sub esp, 10h |
866 | sub esp, 10h |
752 | movzx esi, word [ecx+20h] ; mcb_info_ofs |
867 | movzx esi, word [ecx+20h] ; mcb_info_ofs |
753 | add esi, ecx |
868 | add esi, ecx |
754 | xor ebp, ebp |
869 | xor edi, edi |
755 | .readloop: |
870 | .readloop: |
756 | call ntfs_decode_mcb_entry |
871 | call ntfs_decode_mcb_entry |
757 | jnc .break |
872 | jnc .break |
758 | add ebp, [esp+8] |
873 | add edi, [esp+8] |
759 | sub eax, [esp] |
874 | sub eax, [esp] |
760 | jae .readloop |
875 | jae .readloop |
761 | push ecx |
876 | push ecx |
762 | push eax |
877 | push eax |
763 | add eax, [esp+8] |
878 | add eax, [esp+8] |
764 | add eax, ebp |
879 | add eax, edi |
765 | imul eax, [ntfs_data.sectors_per_cluster] |
880 | imul eax, [ebp+NTFS.sectors_per_cluster] |
766 | add eax, edx |
- | |
767 | add eax, [PARTITION_START] |
881 | add eax, edx |
768 | pop ecx |
882 | pop ecx |
769 | neg ecx |
883 | neg ecx |
770 | imul ecx, [ntfs_data.sectors_per_cluster] |
884 | imul ecx, [ebp+NTFS.sectors_per_cluster] |
771 | sub ecx, edx |
885 | sub ecx, edx |
772 | cmp ecx, [ntfs_cur_size] |
886 | cmp ecx, [ebp+NTFS.ntfs_cur_size] |
773 | jb @f |
887 | jb @f |
774 | mov ecx, [ntfs_cur_size] |
888 | mov ecx, [ebp+NTFS.ntfs_cur_size] |
775 | @@: |
889 | @@: |
776 | mov ebx, [ntfs_cur_buf] |
890 | mov ebx, [ebp+NTFS.ntfs_cur_buf] |
- | 891 | @@: |
|
- | 892 | push eax |
|
- | 893 | cmp [ebp+NTFS.ntfs_cur_attr], 0x80 |
|
- | 894 | jnz .sys |
|
- | 895 | cmp [ebp+NTFS.ntfs_cur_iRecord], 0 |
|
777 | @@: |
896 | jz .sys |
- | 897 | call fs_read32_app |
|
- | 898 | jmp .appsys |
|
778 | call hd_read |
899 | .sys: |
- | 900 | call fs_read32_sys |
|
- | 901 | .appsys: |
|
- | 902 | pop edx |
|
779 | cmp [hd_error], 0 |
903 | test eax, eax |
780 | jnz .errread2 |
904 | jnz .errread2 |
781 | add ebx, 0x200 |
905 | add ebx, 0x200 |
782 | mov [ntfs_cur_buf], ebx |
906 | mov [ebp+NTFS.ntfs_cur_buf], ebx |
783 | inc eax |
907 | lea eax, [edx+1] |
784 | add [ntfs_cur_read], 0x200 |
908 | add [ebp+NTFS.ntfs_cur_read], 0x200 |
785 | dec [ntfs_cur_size] |
909 | dec [ebp+NTFS.ntfs_cur_size] |
786 | inc [ntfs_cur_offs] |
910 | inc [ebp+NTFS.ntfs_cur_offs] |
787 | loop @b |
911 | loop @b |
788 | pop ecx |
912 | pop ecx |
789 | xor eax, eax |
913 | xor eax, eax |
790 | xor edx, edx |
914 | xor edx, edx |
791 | cmp [ntfs_cur_size], 0 |
915 | cmp [ebp+NTFS.ntfs_cur_size], 0 |
792 | jnz .readloop |
916 | jnz .readloop |
793 | add esp, 10h |
917 | add esp, 10h |
794 | mov eax, [ntfs_cur_tail] |
918 | mov eax, [ebp+NTFS.ntfs_cur_tail] |
795 | test eax, eax |
919 | test eax, eax |
796 | jz @f |
920 | jz @f |
797 | sub eax, 0x200 |
921 | sub eax, 0x200 |
798 | add [ntfs_cur_read], eax |
922 | add [ebp+NTFS.ntfs_cur_read], eax |
799 | @@: |
923 | @@: |
800 | clc |
924 | clc |
801 | ret |
925 | ret |
802 | .errread2: |
926 | .errread2: |
803 | pop ecx |
927 | pop ecx |
804 | add esp, 10h |
928 | add esp, 10h |
805 | stc |
929 | stc |
806 | ret |
930 | ret |
807 | .break: |
931 | .break: |
808 | add esp, 10h ; CF=0 |
932 | add esp, 10h ; CF=0 |
809 | mov [ntfs_bCanContinue], 1 |
933 | mov [ebp+NTFS.ntfs_bCanContinue], 1 |
Line 810... | Line 934... | ||
810 | ret |
934 | ret |
811 | 935 | ||
812 | ntfs_read_file_record: |
936 | ntfs_read_file_record: |
813 | ; in: eax=iRecord |
937 | ; in: eax=iRecord |
814 | ; out: [ntfs_data.frs_buffer] contains information |
938 | ; out: [ebp+NTFS.frs_buffer] contains information |
815 | ; eax=0 - failed, eax=1 - success |
939 | ; CF=1 - failed, in this case eax=0 => something with FS, eax nonzero => disk error |
816 | ; Read attr $DATA of $Mft, starting from eax*[ntfs_data.frs_size] |
940 | ; Read attr $DATA of $Mft, starting from eax*[ebp+NTFS.frs_size] |
817 | push ecx edx |
941 | push ecx edx |
818 | mov ecx, [ntfs_data.frs_size] |
942 | mov ecx, [ebp+NTFS.frs_size] |
819 | mul ecx |
943 | mul ecx |
820 | shrd eax, edx, 9 |
944 | shrd eax, edx, 9 |
821 | shr edx, 9 |
945 | shr edx, 9 |
822 | jnz .err |
946 | jnz .errret |
823 | push [ntfs_attr_iRecord] |
947 | push [ebp+NTFS.ntfs_attr_iRecord] |
824 | push [ntfs_attr_iBaseRecord] |
948 | push [ebp+NTFS.ntfs_attr_iBaseRecord] |
825 | push [ntfs_attr_offs] |
949 | push [ebp+NTFS.ntfs_attr_offs] |
826 | push [ntfs_attr_list] |
950 | push [ebp+NTFS.ntfs_attr_list] |
827 | push dword [ntfs_attr_size+4] |
951 | push dword [ebp+NTFS.ntfs_attr_size+4] |
828 | push dword [ntfs_attr_size] |
952 | push dword [ebp+NTFS.ntfs_attr_size] |
829 | push [ntfs_cur_iRecord] |
953 | push [ebp+NTFS.ntfs_cur_iRecord] |
830 | push [ntfs_cur_attr] |
954 | push [ebp+NTFS.ntfs_cur_attr] |
831 | push [ntfs_cur_offs] |
955 | push [ebp+NTFS.ntfs_cur_offs] |
832 | push [ntfs_cur_size] |
956 | push [ebp+NTFS.ntfs_cur_size] |
833 | push [ntfs_cur_buf] |
957 | push [ebp+NTFS.ntfs_cur_buf] |
834 | push [ntfs_cur_read] |
958 | push [ebp+NTFS.ntfs_cur_read] |
835 | mov [ntfs_cur_attr], 0x80 ; $DATA |
959 | mov [ebp+NTFS.ntfs_cur_attr], 0x80 ; $DATA |
836 | and [ntfs_cur_iRecord], 0 ; $Mft |
960 | and [ebp+NTFS.ntfs_cur_iRecord], 0 ; $Mft |
837 | mov [ntfs_cur_offs], eax |
961 | mov [ebp+NTFS.ntfs_cur_offs], eax |
838 | shr ecx, 9 |
962 | shr ecx, 9 |
839 | mov [ntfs_cur_size], ecx |
963 | mov [ebp+NTFS.ntfs_cur_size], ecx |
840 | mov eax, [ntfs_data.frs_buffer] |
964 | mov eax, [ebp+NTFS.frs_buffer] |
841 | mov [ntfs_cur_buf], eax |
965 | mov [ebp+NTFS.ntfs_cur_buf], eax |
842 | call ntfs_read_attr |
966 | call ntfs_read_attr |
843 | mov eax, [ntfs_cur_read] |
967 | mov edx, [ebp+NTFS.ntfs_cur_read] |
844 | pop [ntfs_cur_read] |
968 | pop [ebp+NTFS.ntfs_cur_read] |
845 | pop [ntfs_cur_buf] |
969 | pop [ebp+NTFS.ntfs_cur_buf] |
846 | pop [ntfs_cur_size] |
970 | pop [ebp+NTFS.ntfs_cur_size] |
847 | pop [ntfs_cur_offs] |
971 | pop [ebp+NTFS.ntfs_cur_offs] |
848 | pop [ntfs_cur_attr] |
972 | pop [ebp+NTFS.ntfs_cur_attr] |
849 | pop [ntfs_cur_iRecord] |
973 | pop [ebp+NTFS.ntfs_cur_iRecord] |
850 | pop dword [ntfs_attr_size] |
974 | pop dword [ebp+NTFS.ntfs_attr_size] |
851 | pop dword [ntfs_attr_size+4] |
975 | pop dword [ebp+NTFS.ntfs_attr_size+4] |
852 | pop [ntfs_attr_list] |
976 | pop [ebp+NTFS.ntfs_attr_list] |
853 | pop [ntfs_attr_offs] |
977 | pop [ebp+NTFS.ntfs_attr_offs] |
854 | pop [ntfs_attr_iBaseRecord] |
- | |
855 | pop [ntfs_attr_iRecord] |
978 | pop [ebp+NTFS.ntfs_attr_iBaseRecord] |
856 | pop edx ecx |
979 | pop [ebp+NTFS.ntfs_attr_iRecord] |
857 | jc .errret |
980 | jc .ret |
858 | cmp eax, [ntfs_data.frs_size] |
981 | cmp edx, [ebp+NTFS.frs_size] |
859 | jnz .errret |
982 | jnz .errret |
860 | mov eax, [ntfs_data.frs_buffer] |
983 | mov eax, [ebp+NTFS.frs_buffer] |
861 | cmp dword [eax], 'FILE' |
984 | cmp dword [eax], 'FILE' |
862 | jnz .errret |
985 | jnz .errret |
863 | push ebx |
986 | push ebx |
864 | mov ebx, eax |
987 | mov ebx, eax |
865 | call ntfs_restore_usa_frs |
- | |
866 | pop ebx |
988 | call ntfs_restore_usa_frs |
867 | setnc al |
989 | pop ebx |
868 | movzx eax, al |
- | |
869 | .ret: |
- | |
870 | ret |
990 | jc .errret |
- | 991 | .ret: |
|
871 | .err: |
992 | pop edx ecx |
- | 993 | ret |
|
872 | pop edx ecx |
994 | .errret: |
- | 995 | pop edx ecx |
|
873 | .errret: |
996 | xor eax, eax |
Line 874... | Line 997... | ||
874 | xor eax, eax |
997 | stc |
875 | ret |
998 | ret |
876 | 999 | ||
877 | ntfs_restore_usa_frs: |
1000 | ntfs_restore_usa_frs: |
878 | mov eax, [ntfs_data.frs_size] |
1001 | mov eax, [ebp+NTFS.frs_size] |
879 | ntfs_restore_usa: |
1002 | ntfs_restore_usa: |
880 | pushad |
1003 | pushad |
Line 953... | Line 1076... | ||
953 | .unk: |
1076 | .unk: |
954 | pop eax |
1077 | pop eax |
955 | ret |
1078 | ret |
Line 956... | Line 1079... | ||
956 | 1079 | ||
957 | ntfs_find_lfn: |
1080 | ntfs_find_lfn: |
958 | ; in: esi+ebp -> name |
1081 | ; in: esi+[esp+4] -> name |
959 | ; out: CF=1 - file not found |
1082 | ; out: CF=1 - file not found |
960 | ; else CF=0, [ntfs_cur_iRecord] valid, eax->record in parent directory |
1083 | ; else CF=0, [ebp+NTFS.ntfs_cur_iRecord] valid, eax->record in parent directory |
961 | mov [ntfs_cur_iRecord], 5 ; start parse from root cluster |
1084 | mov [ebp+NTFS.ntfs_cur_iRecord], 5 ; start parse from root cluster |
962 | .doit2: |
1085 | .doit2: |
963 | mov [ntfs_cur_attr], 0x90 ; $INDEX_ROOT |
1086 | mov [ebp+NTFS.ntfs_cur_attr], 0x90 ; $INDEX_ROOT |
964 | and [ntfs_cur_offs], 0 |
1087 | and [ebp+NTFS.ntfs_cur_offs], 0 |
965 | mov eax, [ntfs_data.cur_index_size] |
1088 | mov eax, [ebp+NTFS.cur_index_size] |
966 | mov [ntfs_cur_size], eax |
1089 | mov [ebp+NTFS.ntfs_cur_size], eax |
967 | mov eax, [ntfs_data.cur_index_buf] |
1090 | mov eax, [ebp+NTFS.cur_index_buf] |
968 | mov [ntfs_cur_buf], eax |
1091 | mov [ebp+NTFS.ntfs_cur_buf], eax |
969 | call ntfs_read_attr |
1092 | call ntfs_read_attr |
970 | jnc @f |
1093 | jnc @f |
971 | .ret: |
1094 | .ret: |
972 | ret |
1095 | ret 4 |
- | 1096 | @@: |
|
973 | @@: |
1097 | xor eax, eax |
974 | cmp [ntfs_cur_read], 0x20 |
1098 | cmp [ebp+NTFS.ntfs_cur_read], 0x20 |
975 | jc .ret |
1099 | jc .ret |
976 | pushad |
1100 | pushad |
977 | mov esi, [ntfs_data.cur_index_buf] |
1101 | mov esi, [ebp+NTFS.cur_index_buf] |
978 | mov eax, [esi+14h] |
1102 | mov eax, [esi+14h] |
979 | add eax, 10h |
1103 | add eax, 10h |
980 | cmp [ntfs_cur_read], eax |
1104 | cmp [ebp+NTFS.ntfs_cur_read], eax |
981 | jae .readok1 |
1105 | jae .readok1 |
982 | add eax, 1FFh |
1106 | add eax, 1FFh |
983 | shr eax, 9 |
1107 | shr eax, 9 |
984 | cmp eax, [ntfs_data.cur_index_size] |
1108 | cmp eax, [ebp+NTFS.cur_index_size] |
985 | ja @f |
1109 | ja @f |
986 | .stc_ret: |
1110 | .stc_ret: |
987 | popad |
1111 | popad |
988 | stc |
1112 | stc |
989 | ret |
1113 | ret 4 |
990 | @@: |
1114 | @@: |
991 | ; reallocate |
1115 | ; reallocate |
992 | push eax |
1116 | push eax |
993 | push [ntfs_data.cur_index_buf] |
1117 | push [ebp+NTFS.cur_index_buf] |
994 | call kernel_free |
1118 | call kernel_free |
995 | pop eax |
1119 | pop eax |
996 | mov [ntfs_data.cur_index_size], eax |
1120 | mov [ebp+NTFS.cur_index_size], eax |
997 | push eax |
1121 | push eax |
998 | call kernel_alloc |
1122 | call kernel_alloc |
999 | test eax, eax |
1123 | test eax, eax |
1000 | jnz @f |
1124 | jnz @f |
1001 | and [ntfs_data.cur_index_size], 0 |
1125 | and [ebp+NTFS.cur_index_size], 0 |
1002 | and [ntfs_data.cur_index_buf], 0 |
1126 | and [ebp+NTFS.cur_index_buf], 0 |
1003 | jmp .stc_ret |
1127 | jmp .stc_ret |
1004 | @@: |
1128 | @@: |
1005 | mov [ntfs_data.cur_index_buf], eax |
1129 | mov [ebp+NTFS.cur_index_buf], eax |
1006 | popad |
1130 | popad |
1007 | jmp .doit2 |
1131 | jmp .doit2 |
1008 | .readok1: |
1132 | .readok1: |
1009 | mov ebp, [esi+8] ; subnode_size |
1133 | mov edx, [esi+8] ; subnode_size |
1010 | shr ebp, 9 |
1134 | shr edx, 9 |
1011 | cmp ebp, [ntfs_data.cur_index_size] |
1135 | cmp edx, [ebp+NTFS.cur_index_size] |
1012 | jbe .ok2 |
1136 | jbe .ok2 |
1013 | push esi ebp |
1137 | push esi edx |
1014 | push ebp |
1138 | push edx |
1015 | call kernel_alloc |
1139 | call kernel_alloc |
1016 | pop ebp esi |
1140 | pop edx esi |
1017 | test eax, eax |
1141 | test eax, eax |
1018 | jz .stc_ret |
1142 | jz .stc_ret |
1019 | mov edi, eax |
1143 | mov edi, eax |
1020 | mov ecx, [ntfs_data.cur_index_size] |
1144 | mov ecx, [ebp+NTFS.cur_index_size] |
1021 | shl ecx, 9-2 |
1145 | shl ecx, 9-2 |
1022 | rep movsd |
1146 | rep movsd |
1023 | mov esi, eax |
1147 | mov esi, eax |
1024 | mov [ntfs_data.cur_index_size], ebp |
1148 | mov [ebp+NTFS.cur_index_size], edx |
1025 | push esi ebp |
1149 | push esi edx |
1026 | push [ntfs_data.cur_index_buf] |
1150 | push [ebp+NTFS.cur_index_buf] |
1027 | call kernel_free |
1151 | call kernel_free |
1028 | pop ebp esi |
1152 | pop edx esi |
1029 | mov [ntfs_data.cur_index_buf], esi |
1153 | mov [ebp+NTFS.cur_index_buf], esi |
1030 | .ok2: |
1154 | .ok2: |
1031 | add esi, 10h |
1155 | add esi, 10h |
1032 | mov edi, [esp+4] |
1156 | mov edi, [esp+4] |
1033 | ; edi -> name, esi -> current index data, ebp = subnode size |
1157 | ; edi -> name, esi -> current index data, edx = subnode size |
1034 | .scanloop: |
1158 | .scanloop: |
1035 | add esi, [esi] |
1159 | add esi, [esi] |
1036 | .scanloopint: |
1160 | .scanloopint: |
1037 | test byte [esi+0Ch], 2 |
1161 | test byte [esi+0Ch], 2 |
Line 1068... | Line 1192... | ||
1068 | .subnode: |
1192 | .subnode: |
1069 | test byte [esi+0Ch], 1 |
1193 | test byte [esi+0Ch], 1 |
1070 | jz .notfound |
1194 | jz .notfound |
1071 | movzx eax, word [esi+8] |
1195 | movzx eax, word [esi+8] |
1072 | mov eax, [esi+eax-8] |
1196 | mov eax, [esi+eax-8] |
1073 | mul [ntfs_data.sectors_per_cluster] |
1197 | imul eax, [ebp+NTFS.sectors_per_cluster] |
1074 | mov [ntfs_cur_offs], eax |
1198 | mov [ebp+NTFS.ntfs_cur_offs], eax |
1075 | mov [ntfs_cur_attr], 0xA0 ; $INDEX_ALLOCATION |
1199 | mov [ebp+NTFS.ntfs_cur_attr], 0xA0 ; $INDEX_ALLOCATION |
1076 | mov [ntfs_cur_size], ebp |
1200 | mov [ebp+NTFS.ntfs_cur_size], edx |
1077 | mov eax, [ntfs_data.cur_index_buf] |
1201 | mov eax, [ebp+NTFS.cur_index_buf] |
1078 | mov esi, eax |
1202 | mov esi, eax |
1079 | mov [ntfs_cur_buf], eax |
1203 | mov [ebp+NTFS.ntfs_cur_buf], eax |
- | 1204 | push edx |
|
1080 | call ntfs_read_attr |
1205 | call ntfs_read_attr |
- | 1206 | pop edx |
|
1081 | mov eax, ebp |
1207 | mov eax, edx |
1082 | shl eax, 9 |
1208 | shl eax, 9 |
1083 | cmp [ntfs_cur_read], eax |
1209 | cmp [ebp+NTFS.ntfs_cur_read], eax |
1084 | jnz .notfound |
1210 | jnz .notfound |
1085 | cmp dword [esi], 'INDX' |
1211 | cmp dword [esi], 'INDX' |
1086 | jnz .notfound |
1212 | jnz .notfound |
1087 | mov ebx, esi |
1213 | mov ebx, esi |
1088 | call ntfs_restore_usa |
1214 | call ntfs_restore_usa |
Line 1090... | Line 1216... | ||
1090 | add esi, 0x18 |
1216 | add esi, 0x18 |
1091 | jmp .scanloop |
1217 | jmp .scanloop |
1092 | .notfound: |
1218 | .notfound: |
1093 | popad |
1219 | popad |
1094 | stc |
1220 | stc |
1095 | ret |
1221 | ret 4 |
1096 | .found: |
1222 | .found: |
1097 | cmp byte [edi], 0 |
1223 | cmp byte [edi], 0 |
1098 | jz .done |
1224 | jz .done |
1099 | cmp byte [edi], '/' |
1225 | cmp byte [edi], '/' |
1100 | jz .next |
1226 | jz .next |
Line 1104... | Line 1230... | ||
1104 | .done: |
1230 | .done: |
1105 | .next: |
1231 | .next: |
1106 | pop esi |
1232 | pop esi |
1107 | pop esi |
1233 | pop esi |
1108 | mov eax, [esi] |
1234 | mov eax, [esi] |
1109 | mov [ntfs_cur_iRecord], eax |
1235 | mov [ebp+NTFS.ntfs_cur_iRecord], eax |
1110 | mov [esp+1Ch], esi |
1236 | mov [esp+1Ch], esi |
1111 | mov [esp+4], edi |
1237 | mov [esp+4], edi |
1112 | popad |
1238 | popad |
1113 | inc esi |
1239 | inc esi |
1114 | cmp byte [esi-1], 0 |
1240 | cmp byte [esi-1], 0 |
1115 | jnz .doit2 |
1241 | jnz .doit2 |
1116 | test ebp, ebp |
1242 | cmp dword [esp+4], 0 |
1117 | jz @f |
1243 | jz @f |
1118 | mov esi, ebp |
1244 | mov esi, [esp+4] |
1119 | xor ebp, ebp |
1245 | mov dword [esp+4], 0 |
1120 | jmp .doit2 |
1246 | jmp .doit2 |
1121 | @@: |
1247 | @@: |
1122 | ret |
1248 | ret 4 |
Line 1123... | Line 1249... | ||
1123 | 1249 | ||
1124 | ;---------------------------------------------------------------- |
- | |
1125 | ; |
1250 | ;---------------------------------------------------------------- |
1126 | ; ntfs_HdRead - read NTFS hard disk |
- | |
1127 | ; |
1251 | ; ntfs_Read - NTFS implementation of reading a file |
1128 | ; esi points to filename |
- | |
1129 | ; ebx pointer to 64-bit number = first wanted byte, 0+ |
- | |
1130 | ; may be ebx=0 - start from first byte |
- | |
1131 | ; ecx number of bytes to read, 0+ |
1252 | ; in: ebp = pointer to NTFS structure |
1132 | ; edx mem location to return data |
- | |
1133 | ; |
1253 | ; in: esi+[esp+4] = name |
1134 | ; ret ebx = bytes read or 0xffffffff file not found |
1254 | ; in: ebx = pointer to parameters from sysfunc 70 |
1135 | ; eax = 0 ok read or other = errormsg |
- | |
1136 | ; |
1255 | ; out: eax, ebx = return values for sysfunc 70 |
1137 | ;-------------------------------------------------------------- |
1256 | ;---------------------------------------------------------------- |
1138 | ntfs_HdRead: |
1257 | ntfs_Read: |
1139 | cmp byte [esi], 0 |
1258 | cmp byte [esi], 0 |
1140 | jnz @f |
1259 | jnz @f |
1141 | or ebx, -1 |
1260 | or ebx, -1 |
1142 | movi eax, ERROR_ACCESS_DENIED |
1261 | movi eax, ERROR_ACCESS_DENIED |
1143 | ret |
1262 | ret |
1144 | @@: |
1263 | @@: |
- | 1264 | call ntfs_lock |
|
1145 | call ntfs_find_lfn |
1265 | stdcall ntfs_find_lfn, [esp+4] |
- | 1266 | jnc .found |
|
1146 | jnc .found |
1267 | call ntfs_unlock |
1147 | or ebx, -1 |
1268 | or ebx, -1 |
1148 | movi eax, ERROR_FILE_NOT_FOUND |
1269 | movi eax, ERROR_FILE_NOT_FOUND |
1149 | ret |
1270 | ret |
1150 | .found: |
1271 | .found: |
1151 | mov [ntfs_cur_attr], 0x80 ; $DATA |
1272 | mov [ebp+NTFS.ntfs_cur_attr], 0x80 ; $DATA |
1152 | and [ntfs_cur_offs], 0 |
1273 | and [ebp+NTFS.ntfs_cur_offs], 0 |
1153 | and [ntfs_cur_size], 0 |
1274 | and [ebp+NTFS.ntfs_cur_size], 0 |
1154 | call ntfs_read_attr |
1275 | call ntfs_read_attr |
- | 1276 | jnc @f |
|
1155 | jnc @f |
1277 | call ntfs_unlock |
1156 | or ebx, -1 |
1278 | or ebx, -1 |
1157 | movi eax, ERROR_ACCESS_DENIED |
1279 | movi eax, ERROR_ACCESS_DENIED |
1158 | ret |
1280 | ret |
1159 | @@: |
1281 | @@: |
1160 | pushad |
1282 | pushad |
1161 | and dword [esp+10h], 0 |
1283 | and dword [esp+10h], 0 |
1162 | xor eax, eax |
- | |
1163 | test ebx, ebx |
- | |
1164 | jz .zero1 |
1284 | xor eax, eax |
1165 | cmp dword [ebx+4], 0x200 |
1285 | cmp dword [ebx+8], 0x200 |
1166 | jb @f |
1286 | jb @f |
1167 | .eof0: |
1287 | .eof0: |
1168 | popad |
1288 | popad |
1169 | xor ebx, ebx |
1289 | xor ebx, ebx |
1170 | .eof: |
1290 | .eof: |
- | 1291 | movi eax, ERROR_END_OF_FILE |
|
- | 1292 | push eax |
|
- | 1293 | call ntfs_unlock |
|
1171 | movi eax, ERROR_END_OF_FILE |
1294 | pop eax |
1172 | ret |
1295 | ret |
- | 1296 | @@: |
|
- | 1297 | mov ecx, [ebx+12] |
|
1173 | @@: |
1298 | mov edx, [ebx+16] |
1174 | mov eax, [ebx] |
1299 | mov eax, [ebx+4] |
1175 | test eax, 0x1FF |
1300 | test eax, 0x1FF |
1176 | jz .alignedstart |
1301 | jz .alignedstart |
1177 | push edx |
1302 | push edx |
1178 | mov edx, [ebx+4] |
1303 | mov edx, [ebx+8] |
1179 | shrd eax, edx, 9 |
1304 | shrd eax, edx, 9 |
1180 | pop edx |
1305 | pop edx |
1181 | mov [ntfs_cur_offs], eax |
1306 | mov [ebp+NTFS.ntfs_cur_offs], eax |
1182 | mov [ntfs_cur_size], 1 |
1307 | mov [ebp+NTFS.ntfs_cur_size], 1 |
- | 1308 | lea eax, [ebp+NTFS.ntfs_bitmap_buf] |
|
1183 | mov [ntfs_cur_buf], ntfs_bitmap_buf |
1309 | mov [ebp+NTFS.ntfs_cur_buf], eax |
1184 | call ntfs_read_attr.continue |
1310 | call ntfs_read_attr.continue |
1185 | mov eax, [ebx] |
1311 | mov eax, [ebx+4] |
1186 | and eax, 0x1FF |
1312 | and eax, 0x1FF |
1187 | lea esi, [ntfs_bitmap_buf+eax] |
1313 | lea esi, [ebp+NTFS.ntfs_bitmap_buf+eax] |
1188 | sub eax, [ntfs_cur_read] |
1314 | sub eax, [ebp+NTFS.ntfs_cur_read] |
1189 | jae .eof0 |
1315 | jae .eof0 |
1190 | neg eax |
1316 | neg eax |
1191 | push ecx |
1317 | push ecx |
1192 | cmp ecx, eax |
1318 | cmp ecx, eax |
Line 1200... | Line 1326... | ||
1200 | pop ecx |
1326 | pop ecx |
1201 | sub ecx, [esp+10h] |
1327 | sub ecx, [esp+10h] |
1202 | jnz @f |
1328 | jnz @f |
1203 | .retok: |
1329 | .retok: |
1204 | popad |
1330 | popad |
- | 1331 | call ntfs_unlock |
|
1205 | xor eax, eax |
1332 | xor eax, eax |
1206 | ret |
1333 | ret |
1207 | @@: |
1334 | @@: |
1208 | cmp [ntfs_cur_read], 0x200 |
1335 | cmp [ebp+NTFS.ntfs_cur_read], 0x200 |
1209 | jz .alignedstart |
1336 | jz .alignedstart |
1210 | .eof_ebx: |
1337 | .eof_ebx: |
1211 | popad |
1338 | popad |
1212 | jmp .eof |
1339 | jmp .eof |
1213 | .alignedstart: |
1340 | .alignedstart: |
1214 | mov eax, [ebx] |
1341 | mov eax, [ebx+4] |
1215 | push edx |
1342 | push edx |
1216 | mov edx, [ebx+4] |
1343 | mov edx, [ebx+8] |
1217 | add eax, 511 |
1344 | add eax, 511 |
1218 | adc edx, 0 |
1345 | adc edx, 0 |
1219 | shrd eax, edx, 9 |
1346 | shrd eax, edx, 9 |
1220 | pop edx |
1347 | pop edx |
1221 | .zero1: |
1348 | .zero1: |
1222 | mov [ntfs_cur_offs], eax |
1349 | mov [ebp+NTFS.ntfs_cur_offs], eax |
1223 | mov [ntfs_cur_buf], edx |
1350 | mov [ebp+NTFS.ntfs_cur_buf], edx |
1224 | mov eax, ecx |
1351 | mov eax, ecx |
1225 | shr eax, 9 |
1352 | shr eax, 9 |
1226 | mov [ntfs_cur_size], eax |
1353 | mov [ebp+NTFS.ntfs_cur_size], eax |
1227 | add eax, [ntfs_cur_offs] |
1354 | add eax, [ebp+NTFS.ntfs_cur_offs] |
1228 | push eax |
1355 | push eax |
1229 | call ntfs_read_attr.continue |
1356 | call ntfs_read_attr.continue |
1230 | pop [ntfs_cur_offs] |
1357 | pop [ebp+NTFS.ntfs_cur_offs] |
1231 | mov eax, [ntfs_cur_read] |
1358 | mov eax, [ebp+NTFS.ntfs_cur_read] |
1232 | add [esp+10h], eax |
1359 | add [esp+10h], eax |
1233 | mov eax, ecx |
1360 | mov eax, ecx |
1234 | and eax, not 0x1FF |
1361 | and eax, not 0x1FF |
1235 | cmp [ntfs_cur_read], eax |
1362 | cmp [ebp+NTFS.ntfs_cur_read], eax |
1236 | jnz .eof_ebx |
1363 | jnz .eof_ebx |
1237 | and ecx, 0x1FF |
1364 | and ecx, 0x1FF |
1238 | jz .retok |
1365 | jz .retok |
1239 | add edx, [ntfs_cur_read] |
1366 | add edx, [ebp+NTFS.ntfs_cur_read] |
1240 | mov [ntfs_cur_size], 1 |
1367 | mov [ebp+NTFS.ntfs_cur_size], 1 |
1241 | mov [ntfs_cur_buf], ntfs_bitmap_buf |
1368 | lea eax, [ebp+NTFS.ntfs_bitmap_buf] |
- | 1369 | mov [ebp+NTFS.ntfs_cur_buf], eax |
|
1242 | call ntfs_read_attr.continue |
1370 | call ntfs_read_attr.continue |
1243 | cmp [ntfs_cur_read], ecx |
1371 | cmp [ebp+NTFS.ntfs_cur_read], ecx |
1244 | jb @f |
1372 | jb @f |
1245 | mov [ntfs_cur_read], ecx |
1373 | mov [ebp+NTFS.ntfs_cur_read], ecx |
1246 | @@: |
1374 | @@: |
1247 | xchg ecx, [ntfs_cur_read] |
1375 | xchg ecx, [ebp+NTFS.ntfs_cur_read] |
1248 | push ecx |
1376 | push ecx |
1249 | mov edi, edx |
1377 | mov edi, edx |
1250 | mov esi, ntfs_bitmap_buf |
1378 | lea esi, [ebp+NTFS.ntfs_bitmap_buf] |
1251 | add [esp+10h+4], ecx |
1379 | add [esp+10h+4], ecx |
1252 | rep movsb |
1380 | rep movsb |
1253 | pop ecx |
1381 | pop ecx |
1254 | xor eax, eax |
1382 | xor eax, eax |
1255 | cmp ecx, [ntfs_cur_read] |
1383 | cmp ecx, [ebp+NTFS.ntfs_cur_read] |
1256 | jz @f |
1384 | jz @f |
1257 | mov al, ERROR_END_OF_FILE |
1385 | mov al, ERROR_END_OF_FILE |
1258 | @@: |
1386 | @@: |
1259 | mov [esp+1Ch], eax |
1387 | mov [esp+1Ch], eax |
- | 1388 | call ntfs_unlock |
|
1260 | popad |
1389 | popad |
1261 | ret |
1390 | ret |
Line 1262... | Line 1391... | ||
1262 | 1391 | ||
1263 | ;---------------------------------------------------------------- |
- | |
1264 | ; |
1392 | ;---------------------------------------------------------------- |
1265 | ; ntfs_HdReadFolder - read NTFS hard disk folder |
- | |
1266 | ; |
1393 | ; ntfs_ReadFolder - NTFS implementation of reading a folder |
1267 | ; esi points to filename |
- | |
1268 | ; ebx pointer to structure 32-bit number = first wanted block, 0+ |
- | |
1269 | ; & flags (bitfields) |
- | |
1270 | ; flags: bit 0: 0=ANSI names, 1=UNICODE names |
- | |
1271 | ; ecx number of blocks to read, 0+ |
1394 | ; in: ebp = pointer to NTFS structure |
1272 | ; edx mem location to return data |
- | |
1273 | ; |
1395 | ; in: esi+[esp+4] = name |
1274 | ; ret ebx = blocks read or 0xffffffff folder not found |
1396 | ; in: ebx = pointer to parameters from sysfunc 70 |
1275 | ; eax = 0 ok read or other = errormsg |
- | |
1276 | ; |
1397 | ; out: eax, ebx = return values for sysfunc 70 |
1277 | ;-------------------------------------------------------------- |
1398 | ;---------------------------------------------------------------- |
- | 1399 | ntfs_ReadFolder: |
|
1278 | ntfs_HdReadFolder: |
1400 | call ntfs_lock |
1279 | mov eax, 5 ; root cluster |
1401 | mov eax, 5 ; root cluster |
1280 | cmp byte [esi], 0 |
1402 | cmp byte [esi], 0 |
1281 | jz .doit |
1403 | jz .doit |
1282 | call ntfs_find_lfn |
1404 | stdcall ntfs_find_lfn, [esp+4] |
1283 | jnc .doit2 |
1405 | jnc .doit2 |
1284 | .notfound: |
1406 | .notfound: |
1285 | or ebx, -1 |
1407 | or ebx, -1 |
1286 | push ERROR_FILE_NOT_FOUND |
1408 | push ERROR_FILE_NOT_FOUND |
- | 1409 | .pop_ret: |
|
1287 | .pop_ret: |
1410 | call ntfs_unlock |
1288 | pop eax |
1411 | pop eax |
1289 | ret |
1412 | ret |
1290 | .doit: |
1413 | .doit: |
1291 | mov [ntfs_cur_iRecord], eax |
1414 | mov [ebp+NTFS.ntfs_cur_iRecord], eax |
1292 | .doit2: |
1415 | .doit2: |
1293 | mov [ntfs_cur_attr], 0x10 ; $STANDARD_INFORMATION |
1416 | mov [ebp+NTFS.ntfs_cur_attr], 0x10 ; $STANDARD_INFORMATION |
1294 | and [ntfs_cur_offs], 0 |
1417 | and [ebp+NTFS.ntfs_cur_offs], 0 |
1295 | mov [ntfs_cur_size], 1 |
1418 | mov [ebp+NTFS.ntfs_cur_size], 1 |
- | 1419 | lea eax, [ebp+NTFS.ntfs_bitmap_buf] |
|
1296 | mov [ntfs_cur_buf], ntfs_bitmap_buf |
1420 | mov [ebp+NTFS.ntfs_cur_buf], eax |
1297 | call ntfs_read_attr |
1421 | call ntfs_read_attr |
1298 | jc .notfound |
1422 | jc .notfound |
1299 | mov [ntfs_cur_attr], 0x90 ; $INDEX_ROOT |
1423 | mov [ebp+NTFS.ntfs_cur_attr], 0x90 ; $INDEX_ROOT |
1300 | and [ntfs_cur_offs], 0 |
1424 | and [ebp+NTFS.ntfs_cur_offs], 0 |
1301 | mov eax, [ntfs_data.cur_index_size] |
1425 | mov eax, [ebp+NTFS.cur_index_size] |
1302 | mov [ntfs_cur_size], eax |
1426 | mov [ebp+NTFS.ntfs_cur_size], eax |
1303 | mov eax, [ntfs_data.cur_index_buf] |
1427 | mov eax, [ebp+NTFS.cur_index_buf] |
1304 | mov [ntfs_cur_buf], eax |
1428 | mov [ebp+NTFS.ntfs_cur_buf], eax |
1305 | call ntfs_read_attr |
1429 | call ntfs_read_attr |
1306 | jnc .ok |
1430 | jnc .ok |
1307 | cmp [hd_error], 0 |
1431 | test eax, eax |
1308 | jz .notfound |
1432 | jz .notfound |
1309 | or ebx, -1 |
1433 | or ebx, -1 |
1310 | push 11 |
1434 | push 11 |
1311 | jmp .pop_ret |
1435 | jmp .pop_ret |
1312 | .ok: |
1436 | .ok: |
1313 | cmp [ntfs_cur_read], 0x20 |
1437 | cmp [ebp+NTFS.ntfs_cur_read], 0x20 |
1314 | jae @f |
1438 | jae @f |
1315 | or ebx, -1 |
1439 | or ebx, -1 |
1316 | .fserr: |
1440 | .fserr: |
1317 | push ERROR_FAT_TABLE |
1441 | push ERROR_FAT_TABLE |
1318 | jmp .pop_ret |
1442 | jmp .pop_ret |
1319 | @@: |
1443 | @@: |
1320 | pushad |
1444 | pushad |
1321 | mov esi, [ntfs_data.cur_index_buf] |
1445 | mov esi, [ebp+NTFS.cur_index_buf] |
1322 | mov eax, [esi+14h] |
1446 | mov eax, [esi+14h] |
1323 | add eax, 10h |
1447 | add eax, 10h |
1324 | cmp [ntfs_cur_read], eax |
1448 | cmp [ebp+NTFS.ntfs_cur_read], eax |
1325 | jae .readok1 |
1449 | jae .readok1 |
1326 | add eax, 1FFh |
1450 | add eax, 1FFh |
1327 | shr eax, 9 |
1451 | shr eax, 9 |
1328 | cmp eax, [ntfs_data.cur_index_size] |
1452 | cmp eax, [ebp+NTFS.cur_index_size] |
1329 | ja @f |
1453 | ja @f |
1330 | popad |
1454 | popad |
1331 | jmp .fserr |
1455 | jmp .fserr |
1332 | @@: |
1456 | @@: |
1333 | ; reallocate |
1457 | ; reallocate |
1334 | push eax |
1458 | push eax |
1335 | push [ntfs_data.cur_index_buf] |
1459 | push [ebp+NTFS.cur_index_buf] |
1336 | call kernel_free |
1460 | call kernel_free |
1337 | pop eax |
1461 | pop eax |
1338 | mov [ntfs_data.cur_index_size], eax |
1462 | mov [ebp+NTFS.cur_index_size], eax |
1339 | push eax |
1463 | push eax |
1340 | call kernel_alloc |
1464 | call kernel_alloc |
1341 | test eax, eax |
1465 | test eax, eax |
1342 | jnz @f |
1466 | jnz @f |
1343 | and [ntfs_data.cur_index_size], 0 |
1467 | and [ebp+NTFS.cur_index_size], 0 |
1344 | and [ntfs_data.cur_index_buf], 0 |
1468 | and [ebp+NTFS.cur_index_buf], 0 |
- | 1469 | .nomem: |
|
1345 | .nomem: |
1470 | call ntfs_unlock |
1346 | popad |
1471 | popad |
1347 | or ebx, -1 |
1472 | or ebx, -1 |
1348 | movi eax, 12 |
1473 | movi eax, 12 |
1349 | ret |
1474 | ret |
1350 | @@: |
1475 | @@: |
1351 | mov [ntfs_data.cur_index_buf], eax |
1476 | mov [ebp+NTFS.cur_index_buf], eax |
1352 | popad |
1477 | popad |
1353 | jmp .doit2 |
1478 | jmp .doit2 |
1354 | .readok1: |
1479 | .readok1: |
1355 | mov ebp, [esi+8] ; subnode_size |
1480 | mov edx, [esi+8] ; subnode_size |
- | 1481 | shr edx, 9 |
|
1356 | shr ebp, 9 |
1482 | mov [ebp+NTFS.cur_subnode_size], edx |
1357 | cmp ebp, [ntfs_data.cur_index_size] |
1483 | cmp edx, [ebp+NTFS.cur_index_size] |
1358 | jbe .ok2 |
1484 | jbe .ok2 |
1359 | push esi ebp |
1485 | push esi edx |
1360 | push ebp |
1486 | push edx |
1361 | call kernel_alloc |
1487 | call kernel_alloc |
1362 | pop ebp esi |
1488 | pop edx esi |
1363 | test eax, eax |
1489 | test eax, eax |
1364 | jz .nomem |
1490 | jz .nomem |
1365 | mov edi, eax |
1491 | mov edi, eax |
1366 | mov ecx, [ntfs_data.cur_index_size] |
1492 | mov ecx, [ebp+NTFS.cur_index_size] |
1367 | shl ecx, 9-2 |
1493 | shl ecx, 9-2 |
1368 | rep movsd |
1494 | rep movsd |
1369 | mov esi, eax |
1495 | mov esi, eax |
1370 | mov [ntfs_data.cur_index_size], ebp |
- | |
1371 | push esi ebp |
1496 | mov [ebp+NTFS.cur_index_size], edx |
1372 | push [ntfs_data.cur_index_buf] |
1497 | push [ebp+NTFS.cur_index_buf] |
1373 | call kernel_free |
- | |
1374 | pop ebp esi |
1498 | call kernel_free |
1375 | mov [ntfs_data.cur_index_buf], esi |
1499 | mov [ebp+NTFS.cur_index_buf], esi |
1376 | .ok2: |
1500 | .ok2: |
1377 | add esi, 10h |
- | |
1378 | mov ebx, [esp+10h] |
1501 | add esi, 10h |
1379 | mov edx, [esp+14h] |
1502 | mov edx, [ebx+16] |
1380 | push dword [ebx+4] ; read ANSI/UNICODE name |
- | |
1381 | mov ebx, [ebx] |
1503 | push dword [ebx+8] ; read ANSI/UNICODE name |
1382 | ; init header |
1504 | ; init header |
1383 | mov edi, edx |
1505 | mov edi, edx |
1384 | mov ecx, 32/4 |
1506 | mov ecx, 32/4 |
1385 | xor eax, eax |
1507 | xor eax, eax |
1386 | rep stosd |
1508 | rep stosd |
1387 | mov byte [edx], 1 ; version |
1509 | mov byte [edx], 1 ; version |
- | 1510 | mov ecx, [ebx+12] |
|
1388 | mov ecx, [esp+4+18h] |
1511 | mov ebx, [ebx+4] |
1389 | push edx |
1512 | push edx |
1390 | mov edx, esp |
1513 | mov edx, esp |
1391 | ; edi -> BDFE, esi -> current index data, ebp = subnode size, ebx = first wanted block, |
1514 | ; edi -> BDFE, esi -> current index data, ebx = first wanted block, |
1392 | ; ecx = number of blocks to read |
1515 | ; ecx = number of blocks to read |
1393 | ; edx -> parameters block: dd |
1516 | ; edx -> parameters block: dd |
1394 | cmp [ntfs_cur_iRecord], 5 |
1517 | cmp [ebp+NTFS.ntfs_cur_iRecord], 5 |
1395 | jz .skip_specials |
1518 | jz .skip_specials |
1396 | ; dot and dotdot entries |
1519 | ; dot and dotdot entries |
1397 | push esi |
1520 | push esi |
1398 | xor esi, esi |
1521 | xor esi, esi |
Line 1411... | Line 1534... | ||
1411 | add esi, eax |
1534 | add esi, eax |
1412 | jmp .dump_root |
1535 | jmp .dump_root |
1413 | .dump_root_done: |
1536 | .dump_root_done: |
1414 | ; now dump all subnodes |
1537 | ; now dump all subnodes |
1415 | push ecx edi |
1538 | push ecx edi |
1416 | mov edi, ntfs_bitmap_buf |
1539 | lea edi, [ebp+NTFS.ntfs_bitmap_buf] |
1417 | mov [ntfs_cur_buf], edi |
1540 | mov [ebp+NTFS.ntfs_cur_buf], edi |
1418 | mov ecx, 0x400/4 |
1541 | mov ecx, 0x400/4 |
1419 | xor eax, eax |
1542 | xor eax, eax |
1420 | rep stosd |
1543 | rep stosd |
1421 | mov [ntfs_cur_attr], 0xB0 ; $BITMAP |
1544 | mov [ebp+NTFS.ntfs_cur_attr], 0xB0 ; $BITMAP |
1422 | and [ntfs_cur_offs], 0 |
1545 | and [ebp+NTFS.ntfs_cur_offs], 0 |
1423 | mov [ntfs_cur_size], 2 |
1546 | mov [ebp+NTFS.ntfs_cur_size], 2 |
1424 | call ntfs_read_attr |
1547 | call ntfs_read_attr |
1425 | pop edi ecx |
1548 | pop edi ecx |
1426 | push 0 ; save offset in $BITMAP attribute |
1549 | push 0 ; save offset in $BITMAP attribute |
1427 | and [ntfs_cur_offs], 0 |
1550 | and [ebp+NTFS.ntfs_cur_offs], 0 |
1428 | .dumploop: |
1551 | .dumploop: |
1429 | mov [ntfs_cur_attr], 0xA0 |
1552 | mov [ebp+NTFS.ntfs_cur_attr], 0xA0 |
- | 1553 | mov eax, [ebp+NTFS.cur_subnode_size] |
|
1430 | mov [ntfs_cur_size], ebp |
1554 | mov [ebp+NTFS.ntfs_cur_size], eax |
1431 | mov eax, [ntfs_data.cur_index_buf] |
1555 | mov eax, [ebp+NTFS.cur_index_buf] |
1432 | mov esi, eax |
1556 | mov esi, eax |
1433 | mov [ntfs_cur_buf], eax |
1557 | mov [ebp+NTFS.ntfs_cur_buf], eax |
1434 | push [ntfs_cur_offs] |
1558 | push [ebp+NTFS.ntfs_cur_offs] |
1435 | mov eax, [ntfs_cur_offs] |
1559 | mov eax, [ebp+NTFS.ntfs_cur_offs] |
1436 | imul eax, ebp |
1560 | imul eax, [ebp+NTFS.cur_subnode_size] |
1437 | mov [ntfs_cur_offs], eax |
1561 | mov [ebp+NTFS.ntfs_cur_offs], eax |
1438 | call ntfs_read_attr |
1562 | call ntfs_read_attr |
1439 | pop [ntfs_cur_offs] |
1563 | pop [ebp+NTFS.ntfs_cur_offs] |
1440 | mov eax, ebp |
1564 | mov eax, [ebp+NTFS.cur_subnode_size] |
1441 | shl eax, 9 |
1565 | shl eax, 9 |
1442 | cmp [ntfs_cur_read], eax |
1566 | cmp [ebp+NTFS.ntfs_cur_read], eax |
1443 | jnz .done |
1567 | jnz .done |
1444 | push eax |
1568 | push eax |
1445 | mov eax, [ntfs_cur_offs] |
1569 | mov eax, [ebp+NTFS.ntfs_cur_offs] |
1446 | and eax, 0x400*8-1 |
1570 | and eax, 0x400*8-1 |
1447 | bt dword [ntfs_bitmap_buf], eax |
1571 | bt dword [ebp+NTFS.ntfs_bitmap_buf], eax |
1448 | pop eax |
1572 | pop eax |
1449 | jnc .dump_subnode_done |
1573 | jnc .dump_subnode_done |
1450 | cmp dword [esi], 'INDX' |
1574 | cmp dword [esi], 'INDX' |
1451 | jnz .dump_subnode_done |
1575 | jnz .dump_subnode_done |
1452 | push ebx |
1576 | push ebx |
Line 1462... | Line 1586... | ||
1462 | call .add_entry |
1586 | call .add_entry |
1463 | movzx eax, word [esi+8] |
1587 | movzx eax, word [esi+8] |
1464 | add esi, eax |
1588 | add esi, eax |
1465 | jmp .dump_subnode |
1589 | jmp .dump_subnode |
1466 | .dump_subnode_done: |
1590 | .dump_subnode_done: |
1467 | inc [ntfs_cur_offs] |
1591 | inc [ebp+NTFS.ntfs_cur_offs] |
1468 | test [ntfs_cur_offs], 0x400*8-1 |
1592 | test [ebp+NTFS.ntfs_cur_offs], 0x400*8-1 |
1469 | jnz .dumploop |
1593 | jnz .dumploop |
1470 | mov [ntfs_cur_attr], 0xB0 |
1594 | mov [ebp+NTFS.ntfs_cur_attr], 0xB0 |
1471 | push ecx edi |
1595 | push ecx edi |
1472 | mov edi, ntfs_bitmap_buf |
1596 | lea edi, [ebp+NTFS.ntfs_bitmap_buf] |
1473 | mov [ntfs_cur_buf], edi |
1597 | mov [ebp+NTFS.ntfs_cur_buf], edi |
1474 | mov ecx, 0x400/4 |
1598 | mov ecx, 0x400/4 |
1475 | xor eax, eax |
1599 | xor eax, eax |
1476 | rep stosd |
1600 | rep stosd |
1477 | pop edi ecx |
1601 | pop edi ecx |
1478 | pop eax |
1602 | pop eax |
1479 | push [ntfs_cur_offs] |
1603 | push [ebp+NTFS.ntfs_cur_offs] |
1480 | inc eax |
1604 | inc eax |
1481 | mov [ntfs_cur_offs], eax |
1605 | mov [ebp+NTFS.ntfs_cur_offs], eax |
1482 | mov [ntfs_cur_size], 2 |
1606 | mov [ebp+NTFS.ntfs_cur_size], 2 |
1483 | push eax |
1607 | push eax |
1484 | call ntfs_read_attr |
1608 | call ntfs_read_attr |
1485 | pop eax |
1609 | pop eax |
1486 | pop [ntfs_cur_offs] |
1610 | pop [ebp+NTFS.ntfs_cur_offs] |
1487 | push eax |
1611 | push eax |
1488 | jmp .dumploop |
1612 | jmp .dumploop |
1489 | .done: |
1613 | .done: |
1490 | pop eax |
1614 | pop eax |
1491 | pop edx |
1615 | pop edx |
Line 1496... | Line 1620... | ||
1496 | js @f |
1620 | js @f |
1497 | mov al, ERROR_END_OF_FILE |
1621 | mov al, ERROR_END_OF_FILE |
1498 | @@: |
1622 | @@: |
1499 | mov [esp+1Ch], eax |
1623 | mov [esp+1Ch], eax |
1500 | mov [esp+10h], ebx |
1624 | mov [esp+10h], ebx |
- | 1625 | call ntfs_unlock |
|
1501 | popad |
1626 | popad |
1502 | ret |
1627 | ret |
Line 1503... | Line 1628... | ||
1503 | 1628 | ||
1504 | .add_special_entry: |
1629 | .add_special_entry: |
Line 1515... | Line 1640... | ||
1515 | ; or al, 0x10 |
1640 | ; or al, 0x10 |
1516 | mov eax, 0x10 |
1641 | mov eax, 0x10 |
1517 | stosd |
1642 | stosd |
1518 | scasd |
1643 | scasd |
1519 | push edx |
1644 | push edx |
1520 | mov eax, dword [ntfs_bitmap_buf] |
1645 | mov eax, dword [ebp+NTFS.ntfs_bitmap_buf] |
1521 | mov edx, dword [ntfs_bitmap_buf+4] |
1646 | mov edx, dword [ebp+NTFS.ntfs_bitmap_buf+4] |
1522 | call ntfs_datetime_to_bdfe |
1647 | call ntfs_datetime_to_bdfe |
1523 | mov eax, dword [ntfs_bitmap_buf+0x18] |
1648 | mov eax, dword [ebp+NTFS.ntfs_bitmap_buf+0x18] |
1524 | mov edx, dword [ntfs_bitmap_buf+0x1C] |
1649 | mov edx, dword [ebp+NTFS.ntfs_bitmap_buf+0x1C] |
1525 | call ntfs_datetime_to_bdfe |
1650 | call ntfs_datetime_to_bdfe |
1526 | mov eax, dword [ntfs_bitmap_buf+8] |
1651 | mov eax, dword [ebp+NTFS.ntfs_bitmap_buf+8] |
1527 | mov edx, dword [ntfs_bitmap_buf+0xC] |
1652 | mov edx, dword [ebp+NTFS.ntfs_bitmap_buf+0xC] |
1528 | call ntfs_datetime_to_bdfe |
1653 | call ntfs_datetime_to_bdfe |
1529 | pop edx |
1654 | pop edx |
1530 | xor eax, eax |
1655 | xor eax, eax |
1531 | stosd |
1656 | stosd |
1532 | stosd |
1657 | stosd |
Line 1731... | Line 1856... | ||
1731 | mov [edi+5], al |
1856 | mov [edi+5], al |
1732 | add edi, 8 |
1857 | add edi, 8 |
1733 | ret |
1858 | ret |
Line 1734... | Line 1859... | ||
1734 | 1859 | ||
1735 | ;---------------------------------------------------------------- |
- | |
1736 | ; |
1860 | ;---------------------------------------------------------------- |
1737 | ; ntfs_HdRewrite - write to NTFS hard disk |
- | |
1738 | ; |
1861 | ; ntfs_Rewrite - NTFS implementation of creating a new file |
1739 | ; esi points to filename |
- | |
1740 | ; ebx ignored (reserved) |
- | |
1741 | ; ecx number of bytes to write, 0+ |
1862 | ; in: ebp = pointer to NTFS structure |
1742 | ; edx mem location to data |
- | |
1743 | ; |
1863 | ; in: esi+[esp+4] = name |
1744 | ; ret ebx = number of written bytes |
1864 | ; in: ebx = pointer to parameters from sysfunc 70 |
1745 | ; eax = 0 ok read or other = errormsg |
- | |
1746 | ; |
1865 | ; out: eax, ebx = return values for sysfunc 70 |
1747 | ;-------------------------------------------------------------- |
1866 | ;---------------------------------------------------------------- |
- | 1867 | ntfs_Rewrite: |
|
1748 | ntfs_HdRewrite: |
1868 | ntfs_CreateFolder: |
1749 | xor ebx, ebx |
1869 | xor ebx, ebx |
1750 | mov eax, ERROR_UNSUPPORTED_FS |
1870 | mov eax, ERROR_UNSUPPORTED_FS |
Line 1751... | Line 1871... | ||
1751 | ret |
1871 | ret |
1752 | - | ||
1753 | ;---------------------------------------------------------------- |
1872 | |
1754 | ; |
- | |
1755 | ; ntfs_HdWrite - write to NTFS hard disk |
1873 | ;---------------------------------------------------------------- |
1756 | ; |
- | |
1757 | ; esi points to filename |
- | |
1758 | ; ebx pointer to 64-bit number = first wanted byte, 0+ |
- | |
1759 | ; may be ebx=0 - start from first byte |
1874 | ; ntfs_Write - NTFS implementation of writing to file |
1760 | ; ecx number of bytes to write, 0+ |
- | |
1761 | ; edx mem location to data |
1875 | ; in: ebp = pointer to NTFS structure |
1762 | ; |
1876 | ; in: esi+[esp+4] = name |
1763 | ; ret ebx = bytes written (maybe 0) |
- | |
1764 | ; eax = 0 ok write or other = errormsg |
1877 | ; in: ebx = pointer to parameters from sysfunc 70 |
1765 | ; |
1878 | ; out: eax, ebx = return values for sysfunc 70 |
1766 | ;-------------------------------------------------------------- |
1879 | ;---------------------------------------------------------------- |
1767 | ntfs_HdWrite: |
1880 | ntfs_Write: |
1768 | xor ebx, ebx |
1881 | xor ebx, ebx |
Line 1769... | Line -... | ||
1769 | mov eax, ERROR_UNSUPPORTED_FS |
- | |
1770 | ret |
- | |
1771 | - | ||
1772 | ;---------------------------------------------------------------- |
- | |
1773 | ; |
- | |
1774 | ; ntfs_HdSetFileEnd - set end of file on NTFS hard disk |
- | |
1775 | ; |
- | |
1776 | ; esi points to filename |
- | |
1777 | ; ebx points to 64-bit number = new file size |
- | |
1778 | ; ecx ignored (reserved) |
- | |
1779 | ; edx ignored (reserved) |
- | |
1780 | ; |
- | |
1781 | ; ret eax = 0 ok or other = errormsg |
1882 | mov eax, ERROR_UNSUPPORTED_FS |
1782 | ; |
1883 | ret |
1783 | ;-------------------------------------------------------------- |
- | |
1784 | ntfs_HdSetFileEnd: |
- | |
1785 | ntfs_HdSetFileInfo: |
- | |
1786 | ;---------------------------------------------------------------- |
- | |
1787 | ; |
- | |
1788 | ; ntfs_HdDelete - delete file or empty folder from NTFS hard disk |
- | |
1789 | ; |
- | |
1790 | ; esi points to filename |
- | |
1791 | ; |
- | |
1792 | ; ret eax = 0 ok or other = errormsg |
1884 | |
1793 | ; |
1885 | ntfs_SetFileEnd: |
1794 | ;-------------------------------------------------------------- |
1886 | ntfs_SetFileInfo: |
Line -... | Line 1887... | ||
- | 1887 | ntfs_Delete: |
|
- | 1888 | mov eax, ERROR_UNSUPPORTED_FS |
|
- | 1889 | ret |
|
- | 1890 | ||
- | 1891 | ;---------------------------------------------------------------- |
|
- | 1892 | ; ntfs_GetFileInfo - NTFS implementation of getting file info |
|
- | 1893 | ; in: ebp = pointer to NTFS structure |
|
1795 | ntfs_HdDelete: |
1894 | ; in: esi+[esp+4] = name |
1796 | mov eax, ERROR_UNSUPPORTED_FS |
1895 | ; in: ebx = pointer to parameters from sysfunc 70 |
1797 | ret |
1896 | ; out: eax, ebx = return values for sysfunc 70 |
1798 | 1897 | ;---------------------------------------------------------------- |
|
1799 | ntfs_HdGetFileInfo: |
1898 | ntfs_GetFileInfo: |
1800 | cmp byte [esi], 0 |
1899 | cmp byte [esi], 0 |
1801 | jnz @f |
1900 | jnz @f |
- | 1901 | movi eax, 2 |
|
1802 | movi eax, 2 |
1902 | ret |
- | 1903 | @@: |
|
1803 | ret |
1904 | call ntfs_lock |
1804 | @@: |
- | |
1805 | call ntfs_find_lfn |
1905 | stdcall ntfs_find_lfn, [esp+4] |
1806 | jnc .doit |
1906 | jnc .doit |
1807 | movi eax, ERROR_FILE_NOT_FOUND |
1907 | test eax, eax |
- | 1908 | movi eax, ERROR_FILE_NOT_FOUND |
|
- | 1909 | jz @f |
|
- | 1910 | mov al, 11 |
|
1808 | cmp [hd_error], 0 |
1911 | @@: |
1809 | jz @f |
1912 | push eax |
1810 | mov al, 11 |
1913 | call ntfs_unlock |
1811 | @@: |
1914 | pop eax |
1812 | ret |
1915 | ret |
1813 | .doit: |
1916 | .doit: |
1814 | push esi edi |
1917 | push esi edi |
1815 | mov esi, eax |
1918 | mov esi, eax |
- | 1919 | mov edi, [ebx+16] |
|
1816 | mov edi, edx |
1920 | xor eax, eax |
1817 | xor eax, eax |
1921 | call ntfs_direntry_to_bdfe |