outil_d_analyse_des_fichiers_de_configuration_nr3.dat
Outil d'analyse des fichiers NR3.DAT
Cet outil décode le fichier de configuration NR3.DAT.
Exemple d'utilisation :
$ nrdatview NR3.DAT NRDATView, version 1.0 Nanoreseau version: 3.1 System application: 0:NRDOS (.MO5/.TO7) Printer 0 is installed. Printer 1 is not installed. Printer 2 is not installed. Printer 3 is not installed. The spooler is on disk 0: Listing header: one line Listing footer: three lines Disk 0: is assigned to A: Disk 1: is assigned to B: Disk 2: is not assigned. Disk 3: is not assigned. Disk 4: is not assigned. Disk 5: is not assigned. Disk 6: is not assigned. Disk 7: is not assigned. Disk 8: is not assigned. Disk 9: is not assigned. Signature table (8 entries): 4100FF203D4C0160203C4F0105203F9C1925031193151025328A7EFFE1FDE941 0:MENU.MO5 3F444F015245034D4905464106534F084C410A53490CF6F7F8F9FAFBFCFDE941 0:MENU.MO5 0000000000004C4F474F0432312D30322D383500581600000000000000FFB0A5 0:LOGORAM.MO5 204241534943204D4943524F534F465420312E3004000000000060FF379B379C 0:MENU.TO7 4C5345472D45444C20204D4F352076332E31320459F10000000000000000B02C 0:LSEROM.MO5 202A2A2020204C5345472D45444C20332E32202020202A2A20040100004F004C 0:LSEROM.TO7 4100FF203D4C0160203C4F0105203F9C1925031193151025328A7EFFE4FDE935 0:MENU.MO5 4100FF203D4C0160203C4F0105203F9C1925031193151025328A7EFFE13DE941 0:MENU.MO5
Code source :
#include <stdio.h> #include <stdlib.h> #include <string.h> #define NRDATSIZE 732 FILE *gSource = 0; unsigned char gBuffer[NRDATSIZE]; unsigned int GetVersion(char* xBuffer) { return (xBuffer[0]<<8)+xBuffer[1]; } void GetSystemAppName(char* xBuffer, char* xOutput) { xOutput[0] = '/'+xBuffer[2]; xOutput[1] = ':'; memcpy(xOutput+2,xBuffer+3,8); xOutput[10] = 0; } unsigned int GetPrinterStatus(char *xBuffer, unsigned int xIndex) { return xBuffer[11+(xIndex&0x03)]; } unsigned int GetSpoolerDisk(char *xBuffer) { return xBuffer[25]; } unsigned int GetListingHeader(char *xBuffer) { return xBuffer[26]; } unsigned int GetDisk(char *xBuffer, unsigned int xIndex) { return xBuffer[15+xIndex]; } unsigned int GetSignatureCount(char *xBuffer) { return xBuffer[27]; } void GetSignature(char *xBuffer, unsigned int xIndex, char* xOutput) { unsigned int i; for (i=0;i<32;i++) { sprintf(xOutput+i*2,"%02X", xBuffer[28+i+xIndex*44]&0xff); } xOutput[64]=0; } void GetBootApplicationFilename(char *xBuffer, unsigned int xIndex, char* xOutput) { unsigned int i,j = 0; xOutput[0] = '/'+xBuffer[xIndex*44+60]; xOutput[1] = ':'; while ((xBuffer[xIndex*44+61+i]!=' ')&&(i<8)) xOutput[2+i] = xBuffer[xIndex*44+61+i++]; xOutput[2+i++] = '.'; while ((xBuffer[xIndex*44+69+j]!=' ')&&(j<3)) xOutput[2+i++] = xBuffer[xIndex*44+69+j++]; xOutput[2+i] = 0; } void usage() { printf("Usage: nrdatview filename\n"); } int main(int argc, char *argv[]) { unsigned int lTmpuInt, i; char lTmpStr[65]; printf("NRDATView, version 1.0\n\n"); if ((argc!=2)) { usage(); return -1; } gSource = fopen(argv[1],"rb"); if (gSource == NULL) { printf("Error: cannot open file.\n"); return -2; } fread(gBuffer,1,NRDATSIZE,gSource); fclose(gSource); lTmpuInt = GetVersion(gBuffer); if ((lTmpuInt!=0x0301)&&(lTmpuInt!=0x0303)) { printf("Error: incorrect file version (%u.%u).\n",(lTmpuInt>>8)&0xff,lTmpuInt&0xff); return -3; } printf("Nanoreseau version: %u.%u\n\n",(lTmpuInt>>8)&0xff,lTmpuInt&0xff); GetSystemAppName(gBuffer,lTmpStr); printf("System application: %s (.MO5/.TO7)\n\n",lTmpStr); for (i=0;i<4;i++) { printf("Printer %01u is %sinstalled.\n",i,GetPrinterStatus(gBuffer,i)?"":"not "); } printf("The spooler is on disk %c:\n",'/'+GetSpoolerDisk(gBuffer)); lTmpuInt = GetListingHeader(gBuffer); printf("Listing header: %s\n",lTmpuInt&0x10?"one line":"one page"); printf("Listing footer: %s\n",lTmpuInt&0x10?"three lines":"next page"); printf("\n"); for (i=0;i<10;i++) { lTmpuInt = GetDisk(gBuffer,i); printf("Disk %01u: is ",i); if (lTmpuInt) { printf("assigned to %c:\n",lTmpuInt+'A'-1); } else { printf("not assigned.\n"); } } lTmpuInt = GetSignatureCount(gBuffer); printf("\nSignature table (%u entries):\n",lTmpuInt); for (i=0;i<lTmpuInt;i++) { GetSignature(gBuffer,i,lTmpStr); printf(" %s ",lTmpStr); GetBootApplicationFilename(gBuffer,i,lTmpStr); printf("%s\n",lTmpStr); } return 0; }
outil_d_analyse_des_fichiers_de_configuration_nr3.dat.txt · Last modified: 2025/03/17 22:47 by fool-duplex