1 /**
2  * @namespace   biew_plugins_auto
3  * @file        plugins/bin/sis.c
4  * @brief       This file contains implementation of decoder for Sis (EPOC)
5  *              file format.
6  * @version     -
7  * @remark      this source file is part of Binary vIEW project (BIEW).
8  *              The Binary vIEW (BIEW) is copyright (C) 1995 Nickols_K.
9  *              All rights reserved. This software is redistributable under the
10  *              licence given in the file "Licence.en" ("Licence.ru" in russian
11  *              translation) distributed in the BIEW archive.
12  * @note        Requires POSIX compatible development system
13  *
14  * @author      Nickols_K
15  * @since       1995
16  * @note        Development, fixes and improvements
17 **/
18 #include <stddef.h>
19 
20 #include "reg_form.h"
21 #include "bmfile.h"
22 #include "bconsole.h"
23 #include "biewhelp.h"
24 #include "colorset.h"
25 #include "biewutil.h"
26 #include "biewlib/kbd_code.h"
27 #include "plugins/bin/mmio.h"
28 #include "plugins/disasm.h"
29 
30 struct SisHeader
31 {
32     unsigned long UID1;
33     unsigned long UID2;
34     unsigned long UID3;
35     unsigned long UID4;
36     unsigned short Checksum;
37     unsigned short nLanguages;
38     unsigned short nFiles;
39     unsigned short nRequisites;
40     unsigned short iLanguages;
41     unsigned short iFiles;
42     unsigned short iDrive;
43     unsigned short nCapabilities;
44     unsigned long  InstallVer;
45     unsigned short Options;
46     unsigned short Type;
47     unsigned short MajorVer;
48     unsigned short MinorVer;
49     unsigned long  Variant;
50     unsigned long  LanguagePointer;
51     unsigned long  FilesPointer;
52     unsigned long  RequisitiesPointer;
53     unsigned long  SertificatePointer;
54     unsigned long  ComponentNamePointer;
55 };
56 
sis_check_fmt(void)57 static tBool  __FASTCALL__ sis_check_fmt( void )
58 {
59     unsigned long id1,id2,id3;
60     bmSeek(0,BM_SEEK_SET);
61     id1=bmReadDWordEx(0,BM_SEEK_SET);
62     id2=bmReadDWordEx(4,BM_SEEK_SET);
63     id3=bmReadDWordEx(8,BM_SEEK_SET);
64     if((id2==0x10003A12 || id2==0x1000006D) && id3==0x10000419) return True;
65     /* try s60 3rd */
66     if(id1==0x10201A7A) return True;
67     return False;
68 }
sis_init_fmt(void)69 static void __FASTCALL__ sis_init_fmt( void ) {}
sis_destroy_fmt(void)70 static void __FASTCALL__ sis_destroy_fmt(void) {}
sis_platform(void)71 static int  __FASTCALL__ sis_platform( void) { return DISASM_CPU_ARM; }
72 
Show_Sis3_Header(void)73 static __filesize_t __FASTCALL__ Show_Sis3_Header( void )
74 {
75     ErrMessageBox("Not implemented yet!","Sis v3 header");
76     return BMGetCurrFilePos();
77 }
78 
Show_Sis_Header(void)79 static __filesize_t __FASTCALL__ Show_Sis_Header( void )
80 {
81  unsigned keycode;
82  TWindow * hwnd;
83  char *TypeName;
84  struct SisHeader sis;
85  __filesize_t fpos,fpos2;
86  fpos2=fpos = BMGetCurrFilePos();
87  bmReadBufferEx(&sis,sizeof(sis),0,BM_SEEK_SET);
88  if(sis.UID1==0x10201A7A) return Show_Sis3_Header();
89  switch(sis.Type)
90  {
91     case 0x0000: TypeName="APP"; break;
92     case 0x0001: TypeName="SYSTEM"; break;
93     case 0x0002: TypeName="OPTION"; break;
94     case 0x0003: TypeName="CONFIG"; break;
95     case 0x0004: TypeName="PATCH"; break;
96     case 0x0005: TypeName="UPGRADE"; break;
97     default:     TypeName="unknown"; break;
98  }
99  hwnd = CrtDlgWndnls(" Sis Header ",78,13);
100  twUseWin(hwnd);
101  twGotoXY(1,1);
102  twPrintF("Number of Lang/Files/Req   = %u/%u/%u\n"
103           "Installation Lang/Files/Drv= %u/%u/%u\n"
104           "Number of capabilities     = %u\n"
105           "Installer Version          = 0x%08X\n"
106           "Options                    = 0x%04X(%s %s %s %s)\n"
107           "Type                       = 0x%04X(%s)\n"
108           "Version                    = 0x%04X.%04X\n"
109           "Variant                    = 0x%08X\n"
110           "Language Pointer           = 0x%08X\n"
111           "Files Pointer              = 0x%08X\n"
112           "Requsites Pointer          = 0x%08X\n"
113           "Certificates Pointer       = 0x%08X\n"
114           "Component Name Pointer     = 0x%08X\n"
115 	  ,sis.nLanguages,sis.nFiles,sis.nRequisites
116 	  ,sis.iLanguages,sis.iFiles,sis.iDrive
117 	  ,sis.nCapabilities
118 	  ,sis.InstallVer
119 	  ,sis.Options
120 	  ,sis.Options&0x0001?"Unicode":""
121 	  ,sis.Options&0x0002?"Distrib":""
122 	  ,sis.Options&0x0008?"NoCompr":""
123 	  ,sis.Options&0x0010?"ShutDwn":""
124 	  ,sis.Type,TypeName
125 	  ,sis.MajorVer,sis.MinorVer
126 	  ,sis.Variant
127 	  ,sis.LanguagePointer
128 	  ,sis.FilesPointer
129 	  ,sis.RequisitiesPointer
130 	  ,sis.SertificatePointer
131 	  ,sis.ComponentNamePointer
132 	  );
133  while(1)
134  {
135    keycode = GetEvent(drawEmptyPrompt,NULL,hwnd);
136    if(keycode == KE_F(5) || keycode == KE_ENTER) { fpos = fpos2; break; }
137    else
138      if(keycode == KE_ESCAPE || keycode == KE_F(10)) break;
139  }
140  CloseWnd(hwnd);
141  return fpos;
142 }
143 
144 REGISTRY_BIN sisTable =
145 {
146   "Sis(EPOC) Symbian OS installable file",
147   { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL },
148   { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL },
149   sis_check_fmt,
150   sis_init_fmt,
151   sis_destroy_fmt,
152   Show_Sis_Header,
153   NULL,
154   NULL,
155   sis_platform,
156   NULL,
157   NULL,
158   NULL,
159   NULL,
160   NULL,
161   NULL,
162   NULL,
163   NULL,
164   NULL
165 };
166