User Tools

Site Tools


outil_d_analyse_des_fichiers_de_configuration_nr3.dat

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
outil_d_analyse_des_fichiers_de_configuration_nr3.dat [2025/03/17 15:05] – fool-duplexoutil_d_analyse_des_fichiers_de_configuration_nr3.dat [2025/03/19 14:22] (current) – external edit 127.0.0.1
Line 1: Line 1:
-Cet outil décode les 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 : Exemple d'utilisation :
Line 48: Line 49:
 #include <string.h> #include <string.h>
  
-// Undefine this for Unix-like systems +#define NRDATSIZE 732
-#define PATH_WINDOWS+
  
-int gExtract = 0;+FILE *gSource = 0;
  
-FILE *gSource = NULL; +unsigned char gBuffer[NRDATSIZE];
-unsigned char *gBuffer = NULL; +
-char *gFilename = NULL; +
-long gSize = 0;+
  
-char gIdentifier[9] = {0}; 
-unsigned char gFileType = 0; 
  
-void TargetApp(unsigned char xByte)+unsigned int GetVersion(char* xBuffer)
 { {
-    switch (xByte) +    return (xBuffer[0]<<8)+xBuffer[1]; 
-    { +}
-    case 0: +
-        printf("unreferenced application"); +
-        break; +
-    case 1: +
-        printf("BASIC 1.0"); +
-        break; +
-    case 2: +
-        printf("LOGO"); +
-        break; +
-    case 3: +
-        printf("LSE"); +
-        break; +
-    default: +
-        printf("unknown application"); +
-    }+
  
 +void GetSystemAppName(char* xBuffer, char* xOutput) 
 +{
 +    xOutput[0] = '/'+xBuffer[2];
 +    xOutput[1] = ':';
 +    memcpy(xOutput+2,xBuffer+3,8);
 +    xOutput[10] = 0;
 } }
  
-void TargetComputer(unsigned char xByte)+unsigned int GetPrinterStatus(char *xBuffer, unsigned int xIndex)
 { {
-     switch (xByte) +    return xBuffer[11+(xIndex&0x03)];    
-    { +
-    case 0: +
-        printf("TO7"); +
-        break; +
-    case 1: +
-        printf("MO5"); +
-        break; +
-    case 2: +
-        printf("TO7/70"); +
-        break; +
-    default: +
-        printf("unknown computer"); +
-    }+
 } }
  
-void PageSwitch(unsigned char xPage)+unsigned int GetSpoolerDisk(char *xBuffer)
 { {
-  switch (xPage) +    return xBuffer[25]; 
-        { +}
-        case 0: +
-            printf("do not switch RAM page"); +
-            break;+
  
-        case 0x40: +unsigned int GetListingHeader(char *xBuffer) 
-        case 0x41: +{ 
-        case 0x42: +    return xBuffer[26];
-        case 0x43: +
-        case 0x44: +
-        case 0x45: +
-            printf("switch to RAM page %d",xPage-0x40); +
-            break; +
- +
-        case 0x80: +
-        case 0x81: +
-        case 0x82: +
-        case 0x83: +
-            printf("switch to 64K RAM expansion page %d",xPage-0x80); +
-            break; +
- +
-        case 0xff: +
-            printf("switch to internal ROM [BASIC]"); +
-            break; +
- +
-        default: +
-            printf("unknown RAM page"); +
-        } +
-        printf(")\n");+
 } }
  
-void AnalyseBinExt(unsigned char *xpBuffer)+unsigned int GetDisk(char *xBuffer, unsigned int xIndex)
 { {
-    long lOffset = 38; +    return xBuffer[15+xIndex];
-    unsigned int lSection = 1, lSize = 0, lAddress = 0; +
-    char lBuffer[33] = {0}; +
-    char *lFilename = NULL; +
-    unsigned char lPage = 0; +
-    FILE *lDump = NULL; +
- +
-    printf("   Target computer: "); +
-    TargetComputer(xpBuffer[1]); +
-    printf("\n"); +
- +
-    printf("   Target application: "); +
-    TargetApp(xpBuffer[2]); +
-    printf("\n"); +
- +
-    printf("   Loading flags: "); +
-    if (xpBuffer[3]&0x80) +
-    { +
-        printf("broadcast"); +
-    } +
-    if (xpBuffer[3]&0x40) +
-    { +
-        if (xpBuffer[3]&0x80) +
-        { +
-            printf(", "); +
-        } +
-        printf("load application first"); +
-    } +
-    printf("\n"); +
- +
-    strncpy(lBuffer,(char*)xpBuffer+6,32); +
-    printf("   Application: \"%s\"\n\n",lBuffer); +
- +
-    while (xpBuffer[lOffset]!=3) +
-    { +
-        printf("   Code section %d:\n",lSection); +
-        lSize = xpBuffer[lOffset+1]*256+xpBuffer[lOffset+2]; +
-        lPage = xpBuffer[lOffset+5]; +
-        printf("      Size: %d bytes\n",lSize); +
-        lAddress = xpBuffer[lOffset+3]*256+xpBuffer[lOffset+4]; +
-        printf("      Load address: %02X-%04X (",lPage,lAddress); +
- +
-        PageSwitch(lPage); +
-        printf("\n"); +
- +
-        if (gExtract) +
-        { +
-            lFilename = (char*)malloc(strlen(gFilename+11)); +
-            sprintf(lFilename,"%s-%02x-%04x.bin",gFilename,lPage,lAddress); +
-            lDump = fopen(lFilename,"wb"); +
-            fwrite(xpBuffer+lOffset+6,lSize,1,lDump); +
-            fclose(lDump); +
-            printf("      Section has been dumped to %s.\n\n",lFilename); +
-            free(lFilename); +
-        } +
- +
-        lOffset += 6+lSize; +
- +
-        lSection++; +
-    } +
- +
-    lPage = xpBuffer[lOffset+5]; +
-    printf("   Execution address: %02X-%04X (",lPage,xpBuffer[lOffset+3]*256+xpBuffer[lOffset+4]); +
-    PageSwitch(lPage);+
 } }
  
-void AnalyseBinSimple(unsigned char *xpBuffer)+unsigned int GetSignatureCount(char *xBuffer)
 { {
-    long lOffset = 0; +    return xBuffer[27];
-    unsigned int lSection = 1, lSize = 0, lAddress = 0; +
-    char *lFilename = NULL; +
-    FILE *lDump = NULL; +
- +
-    while (xpBuffer[lOffset]==0) +
-    { +
-        printf("   Code section %d:\n",lSection); +
-        lSize = xpBuffer[lOffset+1]*256+xpBuffer[lOffset+2]; +
-        printf("      Size: %d bytes\n",lSize); +
-        lAddress = xpBuffer[lOffset+3]*256+xpBuffer[lOffset+4]; +
-        printf("      Load address: %04X\n",lAddress); +
-        printf("\n"); +
- +
-        if (gExtract) +
-        { +
-            lFilename = (char*)malloc(strlen(gFilename+11)); +
-            sprintf(lFilename,"%s-%04x.bin",gFilename,lAddress); +
-            lDump = fopen(lFilename,"wb"); +
-            fwrite(xpBuffer+lOffset+6,lSize,1,lDump); +
-            fclose(lDump); +
-            printf("      Section has been dumped to %s.\n\n",lFilename); +
-            free(lFilename); +
-        } +
- +
-        lOffset += 5+lSize; +
-        lSection++; +
-    } +
- +
-    printf("   Execution address: %04X\n",xpBuffer[lOffset+3]*256+xpBuffer[lOffset+4]);+
 } }
  
-void AnalyseBin(unsigned char *xpBuffer)+void GetSignature(char *xBuffer, unsigned int xIndex, char* xOutput)
 { {
-    printf("Binary contents:\n   Format: "); +    unsigned int i; 
-    if (xpBuffer[0] == 1) + 
-    { +    for (i=0;i<32;i++) { 
-       printf("extended\n"); +        sprintf(xOutput+i*2,"%02X", xBuffer[28+i+xIndex*44]&0xff); 
-       AnalyseBinExt(xpBuffer); +    }    
-    } else +    xOutput[64]=0;
-    { +
-       printf("simple\n\n"); +
-       AnalyseBinSimple(xpBuffer); +
-    }+
 } }
  
-void ExtractFilename(char *xSrcStr, char **xStrDst)+void GetBootApplicationFilename(char *xBuffer, unsigned int xIndex, char* xOutput)
 { {
-    char *lPtr = strrchr(xSrcStr, +    unsigned int i,j = 0;
-#ifdef PATH_WINDOWS +
-    '\\' +
-#else +
-    '/' +
-#endif // PATH_WINDOWS +
-    );+
  
-    if (lPtr==NULL) +    xOutput[0] = '/'+xBuffer[xIndex*44+60]; 
-    { +    xOutput[1] = ':'; 
-        *xStrDst = (char*) malloc(strlen(xSrcStr)); + 
-        strcpy(*xStrDst,xSrcStr); +    while ((xBuffer[xIndex*44+61+i]!=' ')&&(i<8)) xOutput[2+i] = xBuffer[xIndex*44+61+i++]; 
-    } +    xOutput[2+i++] = '.'; 
-    else +     
-    { +    while ((xBuffer[xIndex*44+69+j]!=' ')&&(j<3)) xOutput[2+i++] = xBuffer[xIndex*44+69+j++]; 
-        *xStrDst = (char*) malloc(strlen(lPtr)); +    xOutput[2+i] = 0; 
-        strcpy(*xStrDst,lPtr+1); +    
-    }+
 } }
 +
  
 void usage() void usage()
 { {
-    printf("Usage: nrfile [-e] filename\n");+    printf("Usage: nrdatview filename\n");
 } }
  
 int main(int argc, char *argv[]) int main(int argc, char *argv[])
 { {
-    long i;+    unsigned int lTmpuInt, i; 
 +    char lTmpStr[65];
  
-    printf("NRFile, version 1.0\n"); +    printf("NRDATView, version 1.0\n\n"); 
-    if ((argc!=2)&&(argc!=3))+    if ((argc!=2))
     {     {
         usage();         usage();
Line 289: Line 137:
     }     }
  
-    if (argv[1][0]=='-') +    gSource = fopen(argv[1],"rb");
-    { +
-        if (argc!=3) +
-        { +
-           usage(); +
-           return -1; +
-        } +
-        if (argv[1][1] == 'e') +
-        { +
-            gExtract = 1; +
-        } +
-        else +
-        { +
-           usage(); +
-           return -1; +
-        } +
-    } else if (argc!=2) +
-    { +
-           usage(); +
-           return -1; +
-    } +
- +
- +
- +
-    if (gExtract) +
-    { +
-        ExtractFilename(argv[2],&gFilename); +
-        gSource = fopen(argv[2],"rb"); +
-    } else +
-    { +
-        ExtractFilename(argv[1],&gFilename); +
-        gSource = fopen(argv[1],"rb"); +
-    } +
     if (gSource == NULL)     if (gSource == NULL)
     {     {
         printf("Error: cannot open file.\n");         printf("Error: cannot open file.\n");
-        free(gFilename); 
         return -2;         return -2;
     }     }
  
-    fseek(gSource,0,SEEK_END); +    fread(gBuffer,1,NRDATSIZE,gSource); 
-    gSize = ftell(gSource); +    fclose(gSource); 
-    fseek(gSource,0,SEEK_SET); +  
- +    lTmpuInt = GetVersion(gBuffer); 
-    gBuffer = malloc(gSize); +    if ((lTmpuInt!=0x0301)&&(lTmpuInt!=0x0303))
-    if (gBuffer == NULL)+
     {     {
-        printf("Error: cannot allocate memory.\n"); +        printf("Error: incorrect file version (%u.%u).\n",(lTmpuInt>>8)&0xff,lTmpuInt&0xff);
-        free(gFilename); +
-        fclose(gSource);+
         return -3;         return -3;
     }     }
-    memset(gBuffer,0,gSize); 
  
-    fread(gBuffer,1,gSize,gSource); +    printf("Nanoreseau version: %u.%u\n\n",(lTmpuInt>>8)&0xff,lTmpuInt&0xff);
-    fclose(gSource);+
  
-    if (strnicmp((char*)gBuffer,"*NRUSTL*",8)) +    GetSystemAppName(gBuffer,lTmpStr); 
-    { +    printf("System application: %s (.MO5/.TO7)\n\n",lTmpStr);
-        printf("Error: this file is not Nanoreseau compatible.\n"); +
-        free(gBuffer); +
-        free(gFilename); +
-        return -4; +
-    }+
  
-    printf("\nFile: %s (%lu bytes)\n\n",gFilename,gSize); +    for (i=0;i<4;i++)
-    printf("Header:\n"); +
- +
-    strncpy(gIdentifier,(char *)gBuffer+8,8); +
-    printf("   Station identifier: \"%s\"",gIdentifier); +
-    if (strncmp(gIdentifier,"        ",8) == 0)+
     {     {
-        printf(" (default)");+        printf("Printer %01u is %sinstalled.\n",i,GetPrinterStatus(gBuffer,i)?"":"not ");
     }     }
-    printf("\n"); 
  
-    gFileType = gBuffer[17]; +    printf("The spooler is on disk %c:\n",'/'+GetSpoolerDisk(gBuffer)); 
-    printf("   File type: "); +    lTmpuInt = GetListingHeader(gBuffer); 
-    switch (gFileType) +    printf("Listing header: %s\n",lTmpuInt&0x10?"one line":"one page"); 
-    { +    printf("Listing footer: %s\n",lTmpuInt&0x10?"three lines":"next page");
-    case 0: +
-        printf("BASIC program"); +
-        break; +
-    case 1: +
-        printf("BASIC data"); +
-        break; +
-    case 2: +
-        printf("binary"); +
-        break; +
-    case 3: +
-        printf("source code"); +
-        break; +
-    case 5: +
-        printf("indexed data"); +
-        break; +
-    default: +
-        printf("unknown"); +
-    } +
-    printf("\n");+
  
-    printf("   File mode: "); +    printf("\n"); 
-    switch (gBuffer[18]) +
-    { +
-    case 0: +
-        printf("binary"); +
-        break; +
-    case 0xff: +
-        printf("ASCII"); +
-        break; +
-    default: +
-        printf("unknown"); +
-    } +
-    printf("\n");+
  
-    printf("   File status: "); +    for (i=0;i<10;i++) { 
-    switch (gBuffer[23]) +        lTmpuInt = GetDisk(gBuffer,i); 
-    { +        printf("Disk %01u: is ",i); 
-    case 0: +        if (lTmpuInt) { 
-        printf("read/write"); +            printf("assigned to %c:\n",lTmpuInt+'A'-1); 
-        break; +        } else
-    case 0xff: +
-        printf("write protected"); +
-        break; +
-    default: +
-        printf("unknown"); +
-    } +
-    printf("\n"); +
- +
-    printf("   Nanoreseau version: %d.%d\n",gBuffer[24],gBuffer[25]); +
- +
-    printf("   Creation date: %02d/%02d/%02d\n",gBuffer[28],gBuffer[27],gBuffer[26]); +
-    printf("   Last modification date: "); +
-    if ((gBuffer[29] == 0)&&(gBuffer[30] == 0)&&(gBuffer[31] == 0)) +
-    { +
-        printf("never"); +
-    } +
-    else +
-    { +
-        printf("%02d/%02d/%02d",gBuffer[31],gBuffer[30],gBuffer[29]); +
-    } +
-    printf("\n"); +
- +
-    printf("   Created on a: "); +
-    TargetComputer(gBuffer[32]); +
-    printf("\n"); +
- +
-    printf("   Created with: "); +
-    TargetApp(gBuffer[33]); +
-    printf("\n"); +
- +
-    printf("   File attributes: "); +
-    for (i=80;i<96;i++) +
-    { +
-        printf("%02X ",gBuffer[i]); +
-    } +
-    for (i=96;i<128;i++) +
-    { +
-        if (i%16==0)+
         {         {
-            printf("\n                    ");+            printf("not assigned.\n");
         }         }
-        printf("%02X ",gBuffer[i]); 
- 
     }     }
-    printf("\n\n"); 
  
-    if (gFileType == 2)+    lTmpuInt = GetSignatureCount(gBuffer); 
 +    printf("\nSignature table (%u entries):\n",lTmpuInt); 
 +    for (i=0;i<lTmpuInt;i++) 
     {     {
-        AnalyseBin(gBuffer+128);+        GetSignature(gBuffer,i,lTmpStr); 
 +        printf("   %s  ",lTmpStr); 
 +        GetBootApplicationFilename(gBuffer,i,lTmpStr); 
 +        printf("%s\n",lTmpStr);
     }     }
  
-    free(gBuffer); 
-    free(gFilename); 
     return 0;     return 0;
 } }
- 
 </code> </code>
outil_d_analyse_des_fichiers_de_configuration_nr3.dat.1742220309.txt.gz · Last modified: (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki