User Tools

Site Tools


outil_d_analyse_des_fichiers_printer.sys

This is an old revision of the document!


Outil d'analyse du fichier PRINTER.SYS

Cet outil décode les fichiers de configuration des imprimantes PRINTER.SYS.

Exemple d'utilisation :

$ nrprinter PRINTER.SYS

nrprinter, version 1.0

Printer 0:
  Type: parallel
  Port: LPT1:
  Name: " TALLY MT80 PC "

  Translation table: no translation table defined.

Printer 1:
  Type: parallel
  Port: LPT2:
  Name: " MICROLINE 84 "

  Translation table:
    7F -> 20
    80 -> 20
    81 -> AD
    82 -> A5
    83 -> A1
    84 -> 20
    85 -> A0
    87 -> AF
    88 -> A4
    89 -> A6
    8A -> A3
    8B -> A8
    8C -> A7
    93 -> A9
    94 -> 20
    96 -> AC
    97 -> AB

Printer 2:
  Type: serial
  Port: COM1:
  Name: " FACIT 4565 "

  Translation table:
    40 -> 20
    5C -> 20
    7B -> 20
    7C -> 20
    7D -> 20
    7E -> 20
    7F -> 20
    80 -> 20
    81 -> 7E 08 75
    82 -> 7B
    83 -> 5E 08 61
    84 -> 7E 08 61
    85 -> 40
    86 -> 20
    87 -> 5C
    88 -> 5E 08 65
    89 -> 7E 08 65
    8A -> 7D
    8B -> 7E 08 69
    8C -> 5E 08 69
    93 -> 5E 08 6F
    94 -> 7E 08 6F
    96 -> 5E 08 75
    97 -> 7C

Printer 3:
  Type: parallel
  Port: LPT3:
  Name: " EPSON FX 100 "

  Translation table:
    81 -> 1B 52 02 7D 1B 52 00
    82 -> 1B 52 01 7B 1B 52 00
    83 -> 5E 08 61
    85 -> 1B 52 01 40 1B 52 00
    87 -> 1B 52 01 5C 1B 52 00
    88 -> 5E 08 65
    89 -> 1B 52 01 7E 08 65 1B 52 00
    8A -> 1B 52 01 7D 1B 52 00
    8B -> 1B 52 01 7E 08 69 1B 52 00
    8C -> 5E 08 69
    93 -> 5E 08 6F
    94 -> 1B 52 02 7C 1B 52 00
    96 -> 5E 08 75
    97 -> 1B 52 01 7C 1B 52 00
    7F -> 20
    80 -> 20
    84 -> 20
    86 -> 20

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_printer.sys.1742247944.txt.gz · Last modified: (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki