SASC
DVBSoftCAM

testN2RunEmu.c

Go to the documentation of this file.
00001 
00002 #include <stdlib.h>
00003 #include <stdio.h>
00004 
00005 #include "crypto.h"
00006 #include "data.h"
00007 #include "system-common.h"
00008 #include "systems/nagra/nagra2.h"
00009 
00010 #include "compat.h"
00011 
00012 void printreg(const char *name, unsigned char * ptr, int maxlen)
00013 {
00014   int i;
00015   while(maxlen > 1 && ptr[maxlen-1]==0)
00016     maxlen--;
00017   printf("%s(LE): ", name);
00018   for(i = 0; i < maxlen; i++)
00019     printf("%02x", ptr[i]);
00020   printf("\n");
00021 }
00022 
00023 int main(int argc, char *argv[])
00024 {
00025   if(argc<4) {
00026     printf("usage: %s <plugin-dir> <id> <cmdfile> [LOG]\n",argv[0]);
00027     return 1;
00028     }
00029 
00030   InitAll(argv[1]);
00031   LogAll();
00032   if(argc<=4 || strcasecmp(argv[4],"LOG"))
00033     cLogging::SetModuleOption(LCLASS(L_SYS,L_SYS_DISASM),false);
00034   unsigned char data[4096];
00035   unsigned int len=ReadRaw(argv[3],data,sizeof(data));
00036   int id=strtol(argv[2],0,0);
00037   cN2Prov *emmP=cN2Providers::GetProv(id,N2FLAG_NONE);
00038   HEXDUMP(L_SYS_EMU,data,len,"Input");
00039   if(emmP->RunEmu(data,len,0x90,0x90,0x00,0x00,0x460)>=0)
00040     HEXDUMP(L_SYS_EMU,data,0x460,"Output");
00041 
00042   LogNone();
00043   static unsigned char dumpreg[4096] = {
00044     0x8A,0x9B,0xB6,0x0D,0x88,0x17,0x0D,0xA6, 0x11,0xB7,0x48,0x5F,0xD6,0x00,0xBA,0xB7,
00045     0x44,0x5C,0xD6,0x00,0xBA,0xB7,0x45,0x5C, 0xD6,0x00,0xBA,0x5C,0x89,0xCD,0x38,0x40,
00046     0x85,0xA3,0x0F,0x26,0xE7,0x84,0xB7,0x0D, 0x86,0x81,0x00,0xF0,0x09,0x01,0x00,0x0A,
00047     0x01,0x88,0x0B,0x02,0x10,0x0C,0x02,0x98, 0x0D};
00048   if(emmP->RunEmu(dumpreg,0x100,0x90,0x90,0x00,0x00,0x460)>=0) {
00049     printreg("J",dumpreg+0xf0, 0x08);
00050     printreg("A",dumpreg+0x100,0x88);
00051     printreg("B",dumpreg+0x188,0x88);
00052     printreg("C",dumpreg+0x210,0x88);
00053     printreg("D",dumpreg+0x298,0x88);
00054     }
00055 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines