Zapodam Ci fragment nieukończonego (jak zwykle) ciągle jeszcze mojego artykułu. Wycinek dotyczy MSFLSH50:
Jest to najbardziej interesująca sekcja, zawierająca najważniejsze dane i parametry ROMu.
Zaczyna się od napisu "MSFLSH50", czyli od sekwencji 4D 53 46 4C 53 48 35 30, jej długość to maksymalnie 512 bajtów. Powinieneś znaleźć ją pod adresem 0x200, czyli tuż za sekcją Boot.
Tak naprawdę, te 512 bajtów jest zarezerwowane na przyszłe ewentualne wybryki speców robiących ROMy dla urządzeń Oczko Prawdziwa długość sekcji określona jest w 12 bajcie, i dla Wizarda najczęściej jest to wartość 56 bajtów, czyli całkiem sporo zostaje. Ta reszta zostaje wypełniona wartościami 0xFF.
Co możemy z tych 56 bajtów odczytać?
- Początek bloku imgfs (systemu plików). To 4 bajty, począwszy od adresu 0x19. Na przykład: 00 00 00 62, co przekłada się na adres 0x00620000.
Ciekawostka: Nothin, interesujący Cię OS.nb (wiesz, który) ma tutaj wprowadzony adres 0x00300000.
- Liczba sektorów w jednym bloku (0x1F-0x22). Na przykład: 00 80 00 00, czyli 128 sektorów na blok.
- Rozmiar jednego bloku (0x23-0x26). Na przykład: 00 00 00 01, czyli 65536 bajtów.
- Liczba bloków w całym imgfs (0x38-0x39). Na przykład: 2E 03, czyli 0x32E = 814 bloków.
- Powtórzona liczba sektorów w jednym bloku (0x3B-0x3E). Na przykład: 00 80 00 00, czyli 128 sektorów na blok.
- Powtórzony rozmiar jednego bloku (0x3F-0x42). Na przykład: 00 00 00 01, czyli 65536 bajtów.
Do tego dam Ci fragment z Platform Buildera, z pliku romldr.h:
#define ROM_SIGNATURE_OFFSET 64
#define ROM_SIGNATURE 0x43454345
#define ROM_EXTRA 9
typedef struct e32_rom {
unsigned short e32_objcnt; /* Number of memory objects */
unsigned short e32_imageflags; /* Image flags */
unsigned long e32_entryrva; /* Relative virt. addr. of entry point */
unsigned long e32_vbase; /* Virtual base address of module */
unsigned short e32_subsysmajor;/* The subsystem major version number */
unsigned short e32_subsysminor;/* The subsystem minor version number */
unsigned long e32_stackmax; /* Maximum stack size */
unsigned long e32_vsize; /* Virtual size of the entire image */
unsigned long e32_sect14rva; /* section 14 rva */
unsigned long e32_sect14size; /* section 14 size */
struct info e32_unit[ROM_EXTRA]; /* Array of extra info units */
unsigned short e32_subsys; /* The subsystem type */
} e32_rom;
// o32_flags
#define IMAGE_SCN_COMPRESSED 0x00002000 // Section is compressed
typedef struct o32_rom {
unsigned long o32_vsize; /* Virtual memory size */
unsigned long o32_rva; /* Object relative virtual address */
unsigned long o32_psize; /* Physical file size of init. data */
unsigned long o32_dataptr; /* Image pages offset */
unsigned long o32_realaddr; /* pointer to actual */
unsigned long o32_flags; /* Attribute flags for the object */
} o32_rom;
typedef struct ROMHDR {
ULONG dllfirst; // first DLL address
ULONG dlllast; // last DLL address
ULONG physfirst; // first physical address
ULONG physlast; // highest physical address
ULONG nummods; // number of TOCentry's
ULONG ulRAMStart; // start of RAM
ULONG ulRAMFree; // start of RAM free space
ULONG ulRAMEnd; // end of RAM
ULONG ulCopyEntries; // number of copy section entries
ULONG ulCopyOffset; // offset to copy section
ULONG ulProfileLen; // length of PROFentries RAM
ULONG ulProfileOffset; // offset to PROFentries
ULONG numfiles; // number of FILES
ULONG ulKernelFlags; // optional kernel flags from ROMFLAGS .bib config option
ULONG ulFSRamPercent; // Percentage of RAM used for filesystem
// byte 0 = #4K chunks/Mbyte of RAM for filesystem 0-2Mbytes 0-255
// byte 1 = #4K chunks/Mbyte of RAM for filesystem 2-4Mbytes 0-255
// byte 2 = #4K chunks/Mbyte of RAM for filesystem 4-6Mbytes 0-255
// byte 3 = #4K chunks/Mbyte of RAM for filesystem > 6Mbytes 0-255
ULONG ulDrivglobStart; // device driver global starting address
ULONG ulDrivglobLen; // device driver global length
USHORT usCPUType; // CPU (machine) Type
USHORT usMiscFlags; // Miscellaneous flags
void *pExtensions; // pointer to ROM Header extensions
ULONG ulTrackingStart; // tracking memory starting address
ULONG ulTrackingLen; // tracking memory ending address
} ROMHDR;
// followed by nummods <TOCentry>'s
typedef struct TOCentry { // MODULE BIB section structure
DWORD dwFileAttributes;
FILETIME ftTime;
DWORD nFileSize;
LPSTR lpszFileName;
ULONG ulE32Offset; // Offset to E32 structure
ULONG ulO32Offset; // Offset to O32 structure
ULONG ulLoadOffset; // MODULE load buffer offset
} TOCentry, *LPTOCentry;
// followed by numfiles <TOCentry>'s
typedef struct FILESentry { // FILES BIB section structure
DWORD dwFileAttributes;
FILETIME ftTime;
DWORD nRealFileSize;
DWORD nCompFileSize;
LPSTR lpszFileName;
ULONG ulLoadOffset; // FILES load buffer offset
} FILESentry, *LPFILESentry;
typedef struct COPYentry {
ULONG ulSource; // copy source address
ULONG ulDest; // copy destination address
ULONG ulCopyLen; // copy length
ULONG ulDestLen; // copy destination length
// (zero fill to end if > ulCopyLen)
} COPYentry;
#define MAX_ROM 32 // max numbler of XIPs
#define XIP_NAMELEN 32 // max name length of XIP
#define ROM_CHAIN_OFFSET 0x100 // offset for XIPCHAIN_INFO
typedef struct _XIPCHAIN_ENTRY {
LPVOID pvAddr; // address of the XIP
DWORD dwLength; // the size of the XIP
DWORD dwMaxLength; // the biggest it can grow to
USHORT usOrder; // where to put into ROMChain_t
USHORT usFlags; // flags/status of XIP
DWORD dwVersion; // version info
CHAR szName[XIP_NAMELEN]; // Name of XIP, typically the bin file's name, w/o .bin
DWORD dwAlgoFlags; // algorithm to use for signature verification
DWORD dwKeyLen; // length of key in byPublicKey
BYTE byPublicKey[596]; // public key data
} XIPCHAIN_ENTRY, *PXIPCHAIN_ENTRY;
typedef struct _XIPCHAIN_INFO {
DWORD cXIPs;
//
// may contain more than one entry, but we only need the address of first one
//
XIPCHAIN_ENTRY xipEntryStart;
} XIPCHAIN_INFO, *PXIPCHAIN_INFO;
#define PID_LENGTH 10
// pointed to by ROMHDR.pExtensions
typedef struct ROMPID {
union{
DWORD dwPID[PID_LENGTH]; // PID
struct {
char name[(PID_LENGTH - 4) * sizeof(DWORD)];
DWORD type;
PVOID pdata;
DWORD length;
DWORD reserved;
} s;
};
PVOID pNextExt; // pointer to next extension if any
} ROMPID, EXTENSION;