Rev 129 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 129 | Rev 384 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;* expiration hd_wait_timeout - Mario79 * |
3 | ;* expiration hd_wait_timeout - Mario79 * |
4 | ;* 28.01.2006 find all Fat16/32 partition in all input point * |
4 | ;* 28.01.2006 find all Fat16/32 partition in all input point * |
5 | ;* to MBR - Mario79 * |
5 | ;* to MBR - Mario79 * |
6 | ;************************************************************* |
6 | ;************************************************************* |
Line -... | Line 7... | ||
- | 7 | ||
7 | 8 | uglobal |
|
- | 9 | align 4 |
|
8 | align 4 |
10 | |
9 | ;****************************************************** |
11 | ;****************************************************** |
10 | ; Please do not change this place - variables in text |
12 | ; Please do not change this place - variables in text |
11 | ; Mario79 |
13 | ; Mario79 |
12 | ; START place |
14 | ; START place |
13 | ;****************************************************** |
15 | ;****************************************************** |
14 | PARTITION_START dd 0x3f |
16 | PARTITION_START dd 0x3f |
- | 17 | PARTITION_END dd 0 |
|
- | 18 | fs_type db 0 ; 0=none, 1=NTFS, 16=FAT16, 32=FAT32 |
|
- | 19 | align 4 |
|
- | 20 | ||
- | 21 | fs_dependent_data_start: |
|
- | 22 | ; FATxx data |
|
15 | PARTITION_END dd 0 |
23 | |
16 | SECTORS_PER_FAT dd 0x1f3a |
24 | SECTORS_PER_FAT dd 0x1f3a |
17 | NUMBER_OF_FATS dd 0x2 |
25 | NUMBER_OF_FATS dd 0x2 |
18 | SECTORS_PER_CLUSTER dd 0x8 |
26 | SECTORS_PER_CLUSTER dd 0x8 |
19 | BYTES_PER_SECTOR dd 0x200 ; Note: if BPS <> 512 need lots of changes |
27 | BYTES_PER_SECTOR dd 0x200 ; Note: if BPS <> 512 need lots of changes |
Line 28... | Line 36... | ||
28 | fatRESERVED dd 0x0FFFFFF6 |
36 | fatRESERVED dd 0x0FFFFFF6 |
29 | fatBAD dd 0x0FFFFFF7 |
37 | fatBAD dd 0x0FFFFFF7 |
30 | fatEND dd 0x0FFFFFF8 |
38 | fatEND dd 0x0FFFFFF8 |
31 | fatMASK dd 0x0FFFFFFF |
39 | fatMASK dd 0x0FFFFFFF |
Line -... | Line 40... | ||
- | 40 | ||
- | 41 | fs_dependent_data_end: |
|
- | 42 | file_system_data_size = $ - PARTITION_START |
|
- | 43 | if file_system_data_size > 96 |
|
- | 44 | ERROR: sizeof(file system data) too big! |
|
- | 45 | end if |
|
- | 46 | ||
- | 47 | virtual at fs_dependent_data_start |
|
- | 48 | ; NTFS data |
|
- | 49 | ntfs_data: |
|
- | 50 | .sectors_per_cluster dd ? |
|
- | 51 | .mft_cluster dd ? |
|
32 | 52 | .mftmirr_cluster dd ? |
|
- | 53 | .frs_size dd ? ; FRS size in bytes |
|
- | 54 | .iab_size dd ? ; IndexAllocationBuffer size in bytes |
|
- | 55 | .frs_buffer dd ? |
|
- | 56 | .iab_buffer dd ? |
|
- | 57 | .mft_retrieval dd ? |
|
- | 58 | .mft_retrieval_size dd ? |
|
- | 59 | .mft_retrieval_alloc dd ? |
|
- | 60 | .mft_retrieval_end dd ? |
|
- | 61 | .cur_index_size dd ? |
|
- | 62 | .cur_index_buf dd ? |
|
- | 63 | if $ > fs_dependent_data_end |
|
- | 64 | ERROR: increase sizeof(fs_dependent_data)! |
|
- | 65 | end if |
|
- | 66 | end virtual |
|
33 | fat_type db 0 ; 0=none, 16=fat16, 32=fat32 |
67 | |
34 | ;*************************************************************************** |
68 | ;*************************************************************************** |
35 | ; End place |
69 | ; End place |
36 | ; Mario79 |
70 | ; Mario79 |
37 | ;*************************************************************************** |
71 | ;*************************************************************************** |
38 | 72 | endg |
|
- | 73 | iglobal |
|
39 | iglobal |
74 | |
40 | partition_types: ; list of fat16/32 partitions |
75 | partition_types: ; list of fat16/32 partitions |
41 | db 0x04 ; DOS: fat16 <32M |
76 | db 0x04 ; DOS: fat16 <32M |
42 | db 0x06 ; DOS: fat16 >32M |
77 | db 0x06 ; DOS: fat16 >32M |
43 | db 0x0b ; WIN95: fat32 |
78 | db 0x0b ; WIN95: fat32 |
Line 53... | Line 88... | ||
53 | db 0xcb ; DRDOS/secured: fat32 |
88 | db 0xcb ; DRDOS/secured: fat32 |
54 | db 0xcc ; DRDOS/secured: fat32, LBA-mapped |
89 | db 0xcc ; DRDOS/secured: fat32, LBA-mapped |
55 | db 0xce ; DRDOS/secured: fat16, LBA-mapped |
90 | db 0xce ; DRDOS/secured: fat16, LBA-mapped |
56 | db 0xd4 ; Old Multiuser DOS secured: fat16 <32M |
91 | db 0xd4 ; Old Multiuser DOS secured: fat16 <32M |
57 | db 0xd6 ; Old Multiuser DOS secured: fat16 >32M |
92 | db 0xd6 ; Old Multiuser DOS secured: fat16 >32M |
- | 93 | db 0x07 ; NTFS |
|
58 | partition_types_end: |
94 | partition_types_end: |
Line 59... | Line 95... | ||
59 | 95 | ||
60 | 96 | ||
Line 77... | Line 113... | ||
77 | ; Notes: |
113 | ; Notes: |
78 | ; - extended partition need to be in second entry on table |
114 | ; - extended partition need to be in second entry on table |
79 | ; - it will skip over removed partitions |
115 | ; - it will skip over removed partitions |
Line 80... | Line 116... | ||
80 | 116 | ||
81 | set_FAT32_variables: |
- | |
82 | mov [0xfe10],dword 0 ; entries in hd cache |
117 | set_FAT32_variables: |
83 | mov [problem_partition],0 |
118 | mov [problem_partition],0 |
84 | call reserve_hd1 |
119 | call reserve_hd1 |
Line 85... | Line 120... | ||
85 | call clear_hd_cache |
120 | call reserve_hd_channel |
86 | 121 | ||
Line 87... | Line 122... | ||
87 | cmp dword [hdpos],0 |
122 | cmp dword [hdpos],0 |
Line 120... | Line 155... | ||
120 | cmp ecx,[fat32part] ; is it wanted partition? |
155 | cmp ecx,[fat32part] ; is it wanted partition? |
121 | jnz next_primary_partition ; no |
156 | jnz next_primary_partition ; no |
Line 122... | Line 157... | ||
122 | 157 | ||
123 | mov edx,eax ; start sector |
158 | mov edx, eax ; start sector |
- | 159 | add edx, [ebx+0x1be+8] ; add relative start |
|
- | 160 | push edx |
|
- | 161 | add edx, [ebx+0x1be+12] ; add length |
|
- | 162 | dec edx ; PARTITION_END is inclusive |
|
- | 163 | mov [PARTITION_END], edx ; note that this can be changed |
|
- | 164 | ; when file system data will be available |
|
- | 165 | mov dl, [ebx+0x1be+4] |
|
- | 166 | mov [fs_type], dl ; save for FS recognizer (separate FAT vs NTFS) |
|
Line 124... | Line 167... | ||
124 | add edx,[ebx+0x1be+8] ; add relative start |
167 | pop edx |
125 | 168 | ||
126 | next_primary_partition: |
169 | next_primary_partition: |
127 | push eax |
170 | push eax |
Line 132... | Line 175... | ||
132 | 175 | ||
133 | inc ecx |
176 | inc ecx |
134 | cmp ecx,[fat32part] ; is it wanted partition? |
177 | cmp ecx,[fat32part] ; is it wanted partition? |
Line -... | Line 178... | ||
- | 178 | jnz next_primary_partition_1 ; no |
|
135 | jnz next_primary_partition_1 ; no |
179 | |
- | 180 | mov edx, eax |
|
136 | 181 | add edx, [ebx+0x1be+8+16] |
|
- | 182 | push edx |
|
- | 183 | add edx, [ebx+0x1be+12+16] |
|
- | 184 | dec edx |
|
- | 185 | mov [PARTITION_END], edx |
|
- | 186 | mov dl, [ebx+0x1be+4+16] |
|
Line 137... | Line 187... | ||
137 | mov edx,eax ; start sector |
187 | mov [fs_type], dl |
138 | add edx,[ebx+0x1be+8+16] ; add relative start |
188 | pop edx |
139 | 189 | ||
140 | next_primary_partition_1: |
190 | next_primary_partition_1: |
Line 146... | Line 196... | ||
146 | 196 | ||
147 | inc ecx |
197 | inc ecx |
148 | cmp ecx,[fat32part] ; is it wanted partition? |
198 | cmp ecx,[fat32part] ; is it wanted partition? |
Line -... | Line 199... | ||
- | 199 | jnz next_primary_partition_2 ; no |
|
149 | jnz next_primary_partition_2 ; no |
200 | |
- | 201 | mov edx, eax |
|
150 | 202 | add edx, [ebx+0x1be+8+16+16] |
|
- | 203 | push edx |
|
- | 204 | add edx, [ebx+0x1be+12+16+16] |
|
- | 205 | dec edx |
|
- | 206 | mov [PARTITION_END], edx |
|
- | 207 | mov dl, [ebx+0x1be+4+16+16] |
|
Line 151... | Line 208... | ||
151 | mov edx,eax ; start sector |
208 | mov [fs_type], dl |
152 | add edx,[ebx+0x1be+8+16+16] ; add relative start |
209 | pop edx |
153 | 210 | ||
154 | next_primary_partition_2: |
211 | next_primary_partition_2: |
Line 160... | Line 217... | ||
160 | 217 | ||
161 | inc ecx |
218 | inc ecx |
162 | cmp ecx,[fat32part] ; is it wanted partition? |
219 | cmp ecx,[fat32part] ; is it wanted partition? |
Line -... | Line 220... | ||
- | 220 | jnz next_partition ; no |
|
163 | jnz next_partition ; no |
221 | |
- | 222 | mov edx, eax |
|
164 | 223 | add edx, [ebx+0x1be+8+16+16+16] |
|
- | 224 | push edx |
|
- | 225 | add edx, [ebx+0x1be+12+16+16+16] |
|
- | 226 | dec edx |
|
- | 227 | mov [PARTITION_END], edx |
|
- | 228 | mov dl, [ebx+0x1be+4+16+16+16] |
|
Line 165... | Line 229... | ||
165 | mov edx,eax ; start sector |
229 | mov [fs_type], dl |
166 | add edx,[ebx+0x1be+8+16+16+16] ; add relative start |
230 | pop edx |
167 | 231 | ||
168 | next_partition: |
232 | next_partition: |
Line 239... | Line 303... | ||
239 | 303 | ||
240 | problem_partition_or_fat: |
304 | problem_partition_or_fat: |
Line 241... | Line 305... | ||
241 | popad |
305 | popad |
242 | 306 | ||
- | 307 | problem_hd: |
|
243 | problem_hd: |
308 | mov [fs_type],0 |
244 | mov [fat_type],0 |
309 | call free_hd_channel |
245 | mov [hd1_status],0 ; free |
310 | mov [hd1_status],0 ; free |
Line 246... | Line 311... | ||
246 | mov [problem_partition],1 |
311 | mov [problem_partition],1 |
247 | ret |
312 | ret |
248 | 313 | ||
- | 314 | hd_and_partition_ok: |
|
- | 315 | mov eax,edx |
|
- | 316 | mov [PARTITION_START],eax |
|
Line 249... | Line 317... | ||
249 | hd_and_partition_ok: |
317 | mov edx, [PARTITION_END] |
250 | mov eax,edx |
318 | sub edx, eax |
251 | mov [PARTITION_START],eax |
319 | inc edx ; edx = length of partition |
252 | 320 | ||
- | 321 | ; mov [hd_setup],1 |
|
- | 322 | mov ebx,buffer |
|
253 | mov [hd_setup],1 |
323 | call hd_read ; read boot sector of partition |
- | 324 | cmp [hd_error], 0 |
|
- | 325 | jz boot_read_ok |
|
- | 326 | cmp [fs_type], 7 |
|
- | 327 | jnz problem_fat_dec_count |
|
- | 328 | ; NTFS duplicates bootsector: |
|
- | 329 | ; NT4/2k/XP+ saves bootsector copy in the end of disk |
|
- | 330 | ; NT 3.51 saves bootsector copy in the middle of disk |
|
- | 331 | and [hd_error], 0 |
|
- | 332 | mov eax, [PARTITION_END] |
|
- | 333 | call hd_read |
|
254 | mov ebx,buffer |
334 | cmp [hd_error], 0 |
- | 335 | jnz @f |
|
- | 336 | call ntfs_test_bootsec |
|
- | 337 | jnc boot_read_ok |
|
- | 338 | @@: |
|
- | 339 | and [hd_error], 0 |
|
- | 340 | mov eax, edx |
|
- | 341 | shr eax, 1 |
|
- | 342 | add eax, [PARTITION_START] |
|
255 | call hd_read ; read boot sector of partition |
343 | call hd_read |
- | 344 | cmp [hd_error], 0 |
|
- | 345 | jnz problem_fat_dec_count ; ¥ áã¤ì¡ ... |
|
- | 346 | boot_read_ok: |
|
Line 256... | Line 347... | ||
256 | cmp [hd_error],0 |
347 | ; mov [hd_setup], 0 |
257 | jne problem_fat_dec_count |
348 | ; if we are running on NTFS, check bootsector |
Line 258... | Line 349... | ||
258 | 349 | cmp [fs_type], 7 |
|
Line 330... | Line 421... | ||
330 | 421 | ||
331 | mov [fatRESERVED],0x0FFFFFF6 |
422 | mov [fatRESERVED],0x0FFFFFF6 |
332 | mov [fatBAD],0x0FFFFFF7 |
423 | mov [fatBAD],0x0FFFFFF7 |
333 | mov [fatEND],0x0FFFFFF8 |
424 | mov [fatEND],0x0FFFFFF8 |
334 | mov [fatMASK],0x0FFFFFFF |
425 | mov [fatMASK],0x0FFFFFFF |
- | 426 | mov [fs_type],32 ; Fat32 |
|
335 | mov [fat_type],32 ; Fat32 |
427 | call free_hd_channel |
336 | mov [hd1_status],0 ; free |
428 | mov [hd1_status],0 ; free |
Line 337... | Line 429... | ||
337 | ret |
429 | ret |
338 | 430 | ||
Line 344... | Line 436... | ||
344 | 436 | ||
345 | mov [fatRESERVED],0x0000FFF6 |
437 | mov [fatRESERVED],0x0000FFF6 |
346 | mov [fatBAD],0x0000FFF7 |
438 | mov [fatBAD],0x0000FFF7 |
347 | mov [fatEND],0x0000FFF8 |
439 | mov [fatEND],0x0000FFF8 |
348 | mov [fatMASK],0x0000FFFF |
440 | mov [fatMASK],0x0000FFFF |
- | 441 | mov [fs_type],16 ; Fat16 |
|
349 | mov [fat_type],16 ; Fat16 |
442 | call free_hd_channel |
350 | mov [hd1_status],0 ; free |
443 | mov [hd1_status],0 ; free |