Ver Mensaje Individual
  #2 (permalink)  
Antiguo 14/07/2008, 03:57
wyxchari
 
Fecha de Ingreso: junio-2008
Mensajes: 12
Antigüedad: 15 años, 11 meses
Puntos: 1
Estructura de $BadClus en NTFS

Por fin encuentro algo:
http://www.cse.scu.edu/~tschwarz/COEN152_06/Lectures/NTFS.html
http://www.cse.scu.edu/~tschwarz/coen152_05/PPtPre/NTFSFS.ppt
http://data.linux-ntfs.org/ntfsdoc.pdf

Me pillo un pendrive (en mi caso de 1Gb) y lo formateo a FAT simple (tb llamado FAT16), ya que Windows no deja formatear unidades pequeñas a NTFS.

Ahora marco un cluster, el 24, como defectuoso (tranquilo que con un simple formato se borra la marca de defectuoso):
Luego en WinHex, abro la unidad del pendrive como disco lógico.
En Posición, Ir a registro FAT, meto cluster 24, escribo 2 bytes: F7 FF.
Pulso FAT2, voy al cluster 24 y meto igual: F7 FF.
Guardo cambios y cierro WinHex.

Convierto a NTFS desde el Símbolo del sistema:
convert u: /fs:ntfs

Abro de nuevo la unidad en WinHex y voilá, ya tengo una unidad ntfs con clusters defectuosos. Es lo que necesitaba para conocer la estructura de BadClus.

Veamos en FAT tenía el cluster 24 defectuoso que se corresponde con los sectores 1232-1263.
Ahora en NTFS tengo los clusters 154-157 defectuosos que se corresponden con los mismos sectores por supuesto y comprobado.

El archivo $BadClus:$Bad contiene los datos de los clusters defectuosos de todo el disco. Con un tamaño de 16Kb empieza en el sector 1232. Ok.

El archivo \$Bitmap contiene una representación de todos los clusters del disco a nivel de bit. Muestro el principio del archivo:
1EA8A000 FF FF FF FF FF FF FF FF 07 00 00 00 00 00 00 00 ÿÿÿÿÿÿÿÿ........
1EA8A010 00 00 00 3C 00 00 00 00 00 00 00 00 00 00 00 00 ...<............
Se observa que el byte 3C (00111100 en binario) debe corresponder con los 4 clusters 154-157 marcados como defectuosos. En este archivo un bit 0 indica disponible y un bit 1 indica no disponible. Si multiplicamos el desplazamiento del 3C que es 19 bytes, por 8 bit que tiene cada byte, sale 152, más los 2 bit 0 finales del 3C tenemos el cluster 154. Es decir, 3C = 00111100 y los bit en orden son los clusters 0-159, 0-158, 1-157, 1-156, 1-155, 1-154. 0- 153, 0-152. Vemos también que los clusters 1-64 estan ocupados (son los FF) y los 65-67 (es el 07).

Podemos utilizar el archivo \$Bitmap para marcar los clusters defectuosos simulando que están ocupados, poniendo a 1 los bits correspondientes. El problema es que con chkdsk u: saldrán errores de espacio no asignado y nos indicará que pongamos chkdsk u: /f para corregirlo restableciendo así estos bits a 0. Podemos ignorarlo y listo.

Estructura de una MFT record:
Cabecera MFT
Cabecera de atributo
Atributo STANDAR_INFORMATION
Cabecera de atributo
Atributo FILE_NAME
Cabecera de atributo
Atributo DATA
Espacio no usado

MFT Record Structure:
0x00-0x03: Magic Number: "FILE"
0x04-0x05: Offset to the update sequence.
0x06-0x07: Number of entries in fixup array
0x08-0x0f: $LogFile Sequence Number (LSN)
0x10-0x11: Sequence number
0x12-0x13: Hard link count
0x14-0x15: Offset to first attribute
0x16-0x17: Flags: 0x01: record in use, 0x02 directory.
0x18-0x1b: Used size of MFT entry
0x1c-0x1f: Allocated size of MFT entry.
0x20-0x27: File reference to the base FILE record
0x28-0x29: Next attribute ID
0x2a-0x2b: (XP) Align to 4B boundary
0x2c-0x2f: (XP) Number of this MFT record
0x30-0x100: Attributes and fixup value

Números reservados de las MFT record:
1 Master file table $MFT.
2 Master file table mirror $MftMirr.
3 Log file $LogFile.
4 Volume $Volume Attribute definitions $AttrDef.
5 The root folder “.”
6 Cluster bitmap $Bitmap
7 Boot sector $Boot (located at the beginning of partition)
8 Bad cluster file $BadClus
9 Security file $Secure
10 Upcase table $Upcase
11 NTFS extension file $Extend, that is used for future use.

MFT List of possible attributes:
Defined in $AttrDef entry of MFT, but default is:
0x10 STANDARD_INFORMATION
0x20 $ATTRIBUTE_LIST
0x30 $FILE_NAME0
0x40 (NT) $VOLUME_VERSION (2K) $OBJECT_ID
0x50 $SECURITY_DESCRIPTOR
0x60 $VOLUME_NAME
0x70 $VOLUME_INFORMATION
0x80 $DATA
0x90 $INDEX_ROOT
0xA0 $INDEX_ALLOCATION
0xB0 $BITMAP
0xC0 (NT) $SYMBOLIC_LINK, (2K) $REPARSE_POINT
0xD0 $EA_INFORMATION
0xE0 $EA
0xF0 NT$PROPERTY_SET
0x100 (2K) $LOGGED_UTILITY_STREAM

MFT Attribute Layout:
0x00 Attribute Type Identifier
0x04 Length of Attribute
0x08 non-resident flag
0x09 length of name
0x0a offset to name
0x0c flags
0x0e Attribute Identifier
0x10

Si es residente 0x08=0:
0x10 Size of content
0x14 Offset to content
0x16 Indexed flag
0x17 Padding
0x18

Si es no residente 0x08=1:
0x10 Starting Virtual Cluster Number of the runlist
0x18 Ending Virtual Cluster Number of the runlist
0x20 Offset to the runlist
0x22 Compression unit size
0x24 Unused
0x28 Allocated size of the attribute content
0x30 Actual size of attribute content
0x38 Initialized size of the attribute content
0x40

STANDAR Info Attribute:
0x00 C Time - File Creation
0x08 A Time - File Altered
0x10 M Time - MFT Changed
0x18 R Time - File Read
0x20 DOS File Permissions
0x24 Maximum Number of Versions
0x28 Version Number
0x2C Class Id
0x30 Owner Id 2K
0x34 Security Id 2K
0x38 Quota Charged 2K
0x40 Update Sequence Number (USN) 2K
0x48

$FILE_NAME attribute:
0x00 File Reference to parent directory
0x08 File creation time.
0x10 File modification time
0x18 MFT modification time
0x20 File access time.
0x28 Allocated size of file
0x30 Real size of file
0x38 Flags
0x3c Used by EAs and Reparse
0x40 Filename length in unicode characters
0x41 Filename namespace
0x42 File Name in Unicode

El archivo \$BadClus:
00000000 46 49 4C 45 30 00 03 00 6A 10 20 00 00 00 00 00 FILE0...j. .....
00000010 08 00 01 00 38 00 01 00 80 01 00 00 00 04 00 00 ....8...€.......
00000020 00 00 00 00 00 00 00 00 05 00 00 00 08 00 00 00 ................
00000030 02 00 00 00 00 00 00 00 10 00 00 00 60 00 00 00 ............`...
00000040 00 00 18 00 00 00 00 00 48 00 00 00 18 00 00 00 ........H.......
00000050 20 04 0F 95 42 E6 C8 01 20 04 0F 95 42 E6 C8 01 ..•BæÈ. ..•BæÈ.
00000060 20 04 0F 95 42 E6 C8 01 20 04 0F 95 42 E6 C8 01 ..•BæÈ. ..•BæÈ.
00000070 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000080 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 ................
00000090 00 00 00 00 00 00 00 00 30 00 00 00 70 00 00 00 ........0...p...
000000A0 00 00 18 00 00 00 03 00 52 00 00 00 18 00 01 00 ........R.......
000000B0 05 00 00 00 00 00 05 00 20 04 0F 95 42 E6 C8 01 ........ ..•BæÈ.
000000C0 20 04 0F 95 42 E6 C8 01 20 04 0F 95 42 E6 C8 01 ..•BæÈ. ..•BæÈ.
000000D0 20 04 0F 95 42 E6 C8 01 00 00 00 00 00 00 00 00 ..•BæÈ.........
000000E0 00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 ................
000000F0 08 03 24 00 42 00 61 00 64 00 43 00 6C 00 75 00 ..$.B.a.d.C.l.u.
00000100 73 00 00 00 00 00 00 00 80 00 00 00 18 00 00 00 s.......€.......
00000110 00 00 18 00 00 00 02 00 00 00 00 00 18 00 00 00 ................
00000120 80 00 00 00 58 00 00 00 01 04 40 00 00 00 01 00 €...X.....@.....
00000130 00 00 00 00 00 00 00 00 FE D4 03 00 00 00 00 00 ........þÔ......
00000140 48 00 00 00 00 00 00 00 00 F0 4F 3D 00 00 00 00 H........ðO=....
00000150 00 F0 4F 3D 00 00 00 00 00 00 00 00 00 00 00 00 .ðO=............
00000160 24 00 42 00 61 00 64 00 02 9A 00 21 04 9A 00 03 $.B.a.d..š.!.š..
00000170 61 D4 03 00 00 00 00 00 FF FF FF FF 00 00 00 00 aÔ......ÿÿÿÿ....
00000180 80 00 00 00 18 00 00 00 00 00 18 00 00 00 02 00 €...............
00000190 00 00 00 00 18 00 00 00 80 00 00 00 58 00 00 00 ........€...X...
000001A0 01 04 40 00 00 00 01 00 00 00 00 00 00 00 00 00 ..@.............
000001B0 FE D4 03 00 00 00 00 00 48 00 00 00 00 00 00 00 þÔ......H.......
000001C0 00 F0 4F 3D 00 00 00 00 00 F0 4F 3D 00 00 00 00 .ðO=.....ðO=....
000001D0 00 00 00 00 00 00 00 00 24 00 42 00 61 00 64 00 ........$.B.a.d.
000001E0 02 9A 00 21 04 9A 00 03 61 D4 03 00 00 00 00 00 .š.!.š..aÔ......
000001F0 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 02 00 ÿÿÿÿ............

Última edición por wyxchari; 15/07/2008 a las 13:06