- Delete zoomin because there is a nicely working magnify application, and zoomin development stopped in 2002.
svn path=/trunk/; revision=40344
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "misc.h"
-#include "any_op.h"
-
-
-CPU_INT AnyalsingProcess()
-{
- /* FIXME it will set a name to the memory if we got one */
-
- /* FIXME build the jump table */
-
- return 0;
-}
-
-
+++ /dev/null
-
-#include <windows.h>
-#include <winnt.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "misc.h"
-#include "any_op.h"
-
-/*
- * eax = register 3
- * edx = register 4
- * esp = register 1
- * ebp = register 31
-
- * ecx = 8
- * ebx = 9
- * esi = 10
- * edi = 11
- * mmx/sse/fpu 0 = 12
- * mmx/sse/fpu 1 = 14
- * mmx/sse/fpu 2 = 16
- * mmx/sse/fpu 3 = 18
- * mmx/sse/fpu 4 = 20
- * mmx/sse/fpu 5 = 22
- * mmx/sse/fpu 6 = 24
- * mmx/sse/fpu 7 = 28
- */
-
-static void standardreg(CPU_INT *RegTableCount, CPU_INT reg, CPU_INT setup_ebp, FILE *outfp)
-{
- /* eax */
- if (reg == RegTableCount[3])
- {
- fprintf(outfp,"eax");
- }
- /* ebp */
- else if (reg == RegTableCount[31])
- {
- fprintf(outfp,"ebp");
- }
- /* edx */
- else if (reg == RegTableCount[4])
- {
- fprintf(outfp,"edx");
- }
- /* esp */
- else if (reg == RegTableCount[1])
- {
- fprintf(outfp,"esp");
- }
- /* ecx */
- else if (reg == RegTableCount[8])
- {
- fprintf(outfp,"ecx");
- }
- /* ebx */
- else if (reg == RegTableCount[9])
- {
- fprintf(outfp,"ebx");
- }
- /* esi */
- else if (reg == RegTableCount[10])
- {
- fprintf(outfp,"esi");
- }
- /* edi */
- else if (reg == RegTableCount[11])
- {
- fprintf(outfp,"edi");
- }
- else
- {
- if (setup_ebp == 1)
- fprintf(outfp,"dword [ebx - %d]");
- else
- fprintf(outfp,"; unsuported should not happen it happen :(\n");
- }
-}
-
-CPU_INT ConvertToIA32Process( FILE *outfp,
- PMYBrainAnalys pMystart,
- PMYBrainAnalys pMyend, CPU_INT regbits,
- CPU_INT HowManyRegInUse,
- CPU_INT *RegTableCount)
-{
-
- CPU_INT stack = 0;
- CPU_UNINT tmp;
- CPU_INT setup_ebp = 0 ; /* 0 = no, 1 = yes */
- CPU_INT t=0;
-
- /* Fixme optimze the RegTableCount table */
-
- //if (HowManyRegInUse > 9)
- if (HowManyRegInUse > 8)
- {
- setup_ebp =1; /* we will use ebx as ebp */
- stack = HowManyRegInUse * regbits;
- }
-
- if (RegTableCount[1]!=0)
- t++;
- if (RegTableCount[3]!=0)
- t++;
- if (RegTableCount[4]!=0)
- t++;
- if (RegTableCount[8]!=0)
- t++;
- if (RegTableCount[9]!=0)
- t++;
- if (RegTableCount[10]!=0)
- t++;
- if (RegTableCount[11]!=0)
- t++;
- if (RegTableCount[31]!=0)
- t++;
-
- if (HowManyRegInUse != t)
- {
- /* fixme optimze the table or active the frame pointer */
- setup_ebp =1; /* we will use ebx as ebp */
- stack = HowManyRegInUse * regbits;
- }
-
- fprintf(outfp,"BITS 32\n");
- fprintf(outfp,"GLOBAL _main\n");
- fprintf(outfp,"SECTION .text\n\n");
- fprintf(outfp,"; compile with nasm filename.asm -f win32, ld filename.obj -o filename.exe\n\n");
- fprintf(outfp,"_main:\n");
-
- /* setup a frame pointer */
-
- if (setup_ebp == 1)
- {
- fprintf(outfp,"\n; Setup frame pointer \n");
- fprintf(outfp,"push ebx\n");
- fprintf(outfp,"mov ebx,esp\n");
- fprintf(outfp,"sub esp, %d ; Alloc %d bytes for reg\n\n",stack,stack);
- }
-
-
- fprintf(outfp,"; Start the program \n");
- while (pMystart!=NULL)
- {
- /* fixme the line lookup from anaylysing process */
-
- /* mov not full implement */
- if (pMystart->op == OP_ANY_mov)
- {
- printf("waring OP_ANY_mov are not full implement\n");
-
- if ((pMystart->type & 8)== 8)
- {
- /* dst are register */
- tmp = stack - (pMystart->dst*regbits);
-
- if ((pMystart->type & 2)== 2)
- {
- fprintf(outfp,"mov ");
- standardreg( RegTableCount,
- pMystart->dst,
- setup_ebp, outfp);
- fprintf(outfp," , ");
- standardreg( RegTableCount,
- pMystart->src,
- setup_ebp, outfp);
- fprintf(outfp,"\n");
-
- }
- if ((pMystart->type & 16)== 16)
- {
- /* source are imm */
- if ((pMystart->src == 0) &&
- (setup_ebp == 0))
- {
- /* small optimze */
- fprintf(outfp,"xor ");
- standardreg( RegTableCount,
- pMystart->dst,
- setup_ebp, outfp);
- fprintf(outfp,",");
- standardreg( RegTableCount,
- pMystart->dst,
- setup_ebp, outfp);
- fprintf(outfp,"\n");
- }
- else
- {
- fprintf(outfp,"mov ");
- standardreg( RegTableCount,
- pMystart->dst,
- setup_ebp, outfp);
- fprintf(outfp,",%llu\n",pMystart->src);
- }
- } /* end "source are imm" */
- } /* end pMyBrainAnalys->type & 8 */
-
- if ((pMystart->type & 64)== 64)
- {
- if ((pMystart->type & 2)== 2)
- {
- /* dest [eax - 0x20], source reg */
-
- fprintf(outfp,"mov dword [");
- standardreg( RegTableCount,
- pMystart->dst,
- setup_ebp, outfp);
- if (pMystart->dst_extra>=0)
- fprintf(outfp," +%d], ",pMystart->dst_extra);
- else
- fprintf(outfp," %d], ",pMystart->dst_extra);
-
- standardreg( RegTableCount,
- pMystart->src,
- setup_ebp, outfp);
- fprintf(outfp,"\n");
-
- if ((pMystart->type & 128)== 128)
- {
- fprintf(outfp,"mov ");
- standardreg( RegTableCount,
- pMystart->src,
- setup_ebp, outfp);
- fprintf(outfp," , ");
- standardreg( RegTableCount,
- pMystart->dst,
- setup_ebp, outfp);
- fprintf(outfp," %d\n",pMystart->dst_extra);
- }
- }
- }
-
-
-
-
- }
-
- /* return */
- if (pMystart->op == OP_ANY_ret)
- {
- if (pMyBrainAnalys->ptr_next == NULL)
- {
- if (setup_ebp == 1)
- {
- fprintf(outfp,"\n; clean up after the frame \n");
- fprintf(outfp,"mov esp, ebx\n");
- fprintf(outfp,"pop ebx\n");
- }
- }
- fprintf(outfp,"ret\n");
- }
- if (pMystart == pMyend)
- pMystart=NULL;
- else
- pMystart = (PMYBrainAnalys) pMystart->ptr_next;
-
- }
- return 0;
-}
+++ /dev/null
-
-#include <windows.h>
-#include <winnt.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "misc.h"
-#include "any_op.h"
-
-static void standardreg(CPU_INT *RegTableCount, CPU_UNINT reg,
- CPU_INT setup_ebp, FILE *outfp)
-{
- CPU_INT t, found = 0;
- for (t=0;t<31;t++)
- {
- if (reg == RegTableCount[t])
- {
- fprintf(outfp,"r%d",t);
- found++;
- break;
- }
- }
-
- if (found == 0)
- {
- fprintf(outfp,"r%d",reg);
- }
-}
-
-CPU_INT ConvertToPPCProcess( FILE *outfp,
- PMYBrainAnalys pMystart,
- PMYBrainAnalys pMyend, CPU_INT regbits,
- CPU_INT HowManyRegInUse,
- CPU_INT *RegTableCount)
-{
-
- CPU_INT stack = 0;
- //CPU_UNINT tmp;
- CPU_INT setup_ebp = 0 ; /* 0 = no, 1 = yes */
- CPU_INT t=0;
-
- if (HowManyRegInUse > 31)
- {
- setup_ebp =1; /* we will use ebx as ebp */
- stack = HowManyRegInUse * regbits;
- }
-
- if (RegTableCount[1]!=0)
- t++;
- if (RegTableCount[3]!=0)
- t++;
- if (RegTableCount[4]!=0)
- t++;
- if (RegTableCount[8]!=0)
- t++;
- if (RegTableCount[9]!=0)
- t++;
- if (RegTableCount[10]!=0)
- t++;
- if (RegTableCount[11]!=0)
- t++;
- if (RegTableCount[31]!=0)
- t++;
-
- if (HowManyRegInUse != t)
- {
- /* fixme optimze the table or active the frame pointer */
- setup_ebp =1; /* we will use ebx as ebp */
- stack = HowManyRegInUse * regbits;
- }
-
-
-/* fixme gas compatible
- fprintf(outfp,"BITS 32\n");
- fprintf(outfp,"GLOBAL _main\n");
- fprintf(outfp,"SECTION .text\n\n");
- fprintf(outfp,"; compile with nasm filename.asm -f win32, ld filename.obj -o filename.exe\n\n");
- fprintf(outfp,"_main:\n");
-*/
-
- /* setup a frame pointer */
- if (setup_ebp == 1)
- {
- /* fixme ppc frame pointer */
- // fprintf(outfp,"\n; Setup frame pointer \n");
- }
-
- fprintf(outfp,"; Start the program \n");
- while (pMystart!=NULL)
- {
- /* fixme the line lookup from anaylysing process */
-
- /* mov not full implement */
- if (pMystart->op == OP_ANY_mov)
- {
- printf("waring OP_ANY_mov are not full implement\n");
-
- if ((pMystart->type & 8)== 8)
- {
- /* dst are register */
- // FIXME frame pointer setup
- // tmp = stack - (pMystart->dst*regbits);
-
- if ((pMystart->type & 2)== 2)
- {
- fprintf(outfp,"mr ");
- standardreg( RegTableCount,
- pMystart->dst,
- setup_ebp, outfp);
- fprintf(outfp,",");
- standardreg( RegTableCount,
- pMystart->src,
- setup_ebp, outfp);
- fprintf(outfp,"\n");
- }
-
- if ((pMystart->type & 16)== 16)
- {
- /* source are imm */
- if (setup_ebp == 1)
- fprintf(outfp,"not supporet\n");
- else
- {
- fprintf(outfp,"li ");
- standardreg( RegTableCount,
- pMystart->dst,
- setup_ebp, outfp);
- fprintf(outfp," , %llu\n",pMystart->src);
- }
- }
- } /* end pMyBrainAnalys->type & 8 */
-
- if ((pMystart->type & 64)== 64)
- {
- if ((pMystart->type & 2)== 2)
- {
- /* dest [eax - 0x20], source reg */
- if ((pMystart->type & 128)== 128)
- {
- fprintf(outfp,"stwu ");
- }
- else
- {
- fprintf(outfp,"stw ");
- }
-
- standardreg( RegTableCount,
- pMystart->src,
- setup_ebp, outfp);
- fprintf(outfp,", %d(",pMystart->dst_extra);
-
- standardreg( RegTableCount,
- pMystart->dst,
- setup_ebp, outfp);
- fprintf(outfp,")\n");
- }
- } /* end pMyBrainAnalys->type & 64 */
- }
-
- /* return */
- if (pMystart->op == OP_ANY_ret)
- {
- if (pMyBrainAnalys->ptr_next == NULL)
- {
- if (setup_ebp == 1)
- {
- // FIXME end our own frame pointer
- fprintf(outfp,"\n; clean up after the frame \n");
- }
- }
- fprintf(outfp,"blr\n");
- }
- if (pMystart == pMyend)
- pMystart=NULL;
- else
- pMystart = (PMYBrainAnalys) pMystart->ptr_next;
- }
- return 0;
-}
+++ /dev/null
-#include <windows.h>
-#include <winnt.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "misc.h"
-#include "any_op.h"
-
-/* hack should be in misc.h*/
-
-
-CPU_INT ConvertProcess(FILE *outfp, CPU_INT FromCpuid, CPU_INT ToCpuid)
-{
- CPU_INT ret=0;
- CPU_INT regbits=-1;
- CPU_INT HowManyRegInUse = 0;
- CPU_INT RegTableCount[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- CPU_INT t;
- PMYBrainAnalys pMystart = pStartMyBrainAnalys;
- PMYBrainAnalys pMyend = pMyBrainAnalys;
-
- PMYBrainAnalys ptmpMystart = pStartMyBrainAnalys;
- PMYBrainAnalys ptmpMyend = pMyBrainAnalys;
-
- if ( (FromCpuid == IMAGE_FILE_MACHINE_POWERPC) ||
- (FromCpuid == IMAGE_FILE_MACHINE_I386))
- {
- regbits = 32 / 8;
- }
-
- /* FIXME calc where todo first split */
-
- /* count how many register we got */
- ptmpMystart = pMystart;
- ptmpMyend = pMyend;
- while (ptmpMystart!=NULL)
- {
- if ((ptmpMystart->type & 2) == 2)
- RegTableCount[ptmpMystart->src]++;
-
- if ((ptmpMystart->type & 8) == 8)
- RegTableCount[ptmpMystart->dst]++;
-
- if ((ptmpMystart->type & 32) == 32)
- RegTableCount[ptmpMystart->src]++;
-
- if ((ptmpMystart->type & 64) == 64)
- RegTableCount[ptmpMystart->dst]++;
-
- if (ptmpMystart == ptmpMyend)
- ptmpMystart=NULL;
- else
- ptmpMystart = (PMYBrainAnalys) ptmpMystart->ptr_next;
- }
-
- for (t=0;t<=31;t++)
- {
- if (RegTableCount[t]!=0)
- {
- HowManyRegInUse++;
- RegTableCount[t]=t;
- }
- }
-
-
- /* switch to the acual converting now */
- switch (ToCpuid)
- {
- case IMAGE_FILE_MACHINE_I386:
- ret = ConvertToIA32Process( outfp, pMystart,
- pMyend, regbits,
- HowManyRegInUse,
- RegTableCount);
- if (ret !=0)
- {
- printf("should not happen contact a devloper, x86 fail\n");
- return -1;
- }
- break;
-
- case IMAGE_FILE_MACHINE_POWERPC:
- ret = ConvertToPPCProcess( outfp, pMystart,
- pMyend, regbits,
- HowManyRegInUse,
- RegTableCount);
- if (ret !=0)
- {
- printf("should not happen contact a devloper, x86 fail\n");
- return -1;
- }
- break;
-
- default:
- printf("should not happen contact a devloper, unknown fail\n");
- return -1;
- }
-
- return ret;
-}
+++ /dev/null
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "misc.h"
-#include "any_op.h"
-
-PMYBrainAnalys pMyBrainAnalys = NULL;
-PMYBrainAnalys pStartMyBrainAnalys = NULL;
-
-
-int main(int argc, char * argv[])
-{
- //CPU_UNINT BaseAddress=0;
- //int t=0;
- //char *infile=NULL;
- //char *outfile=NULL;
- //char *cpuid=NULL;
- //CPU_INT type=0;
- //CPU_INT mode = 1;
-
-
- //printf("Usage :\n");
- //printf(" need for -inbin and autodetect if it does not found a PE header \n");
- //printf(" -cpu m68000 : convert motorala 68000/68008 to intel asm \n");
- //printf(" -cpu m68010 : convert motorala 68010 to intel asm \n");
- //printf(" -cpu m68020 : convert motorala 68020 to intel asm \n");
- //printf(" -cpu m68030 : convert motorala 68030 to intel asm \n");
- //printf(" -cpu m68040 : convert motorala 68040 to intel asm \n");
- //printf(" -cpu ppc : convert PowerPC to intel asm \n");
- //printf(" -cpu ARM4 : convert ARM4 to intel asm \n");
- //printf("------------------------------------------------------------------\n");
- //printf(" for -inbin and autodetect if it does not found a PE header or do\n");
- //printf(" not set at all, this options are free to use \n");
- //printf(".......-BaseAddress adr : the start base address only accpect \n");
- //printf("....... dec value");
- //printf("------------------------------------------------------------------\n");
- //printf(" -in filename : try autodetect file type for you");
- //printf(" whant convert\n");
- //printf(" -inBin filename : the bin file you whant convert\n");
- //printf(" -inExe filename : the PE file you whant convert\n");
- //printf(" -OutAsm filename : the Asm file you whant create\n");
- //printf(" -OutDis filename : Do disambler of the source file\n");
- //printf("------------------------------------------------------------------\n");
- //printf("More cpu will be added with the time or options, this is \n");
- //printf("version 0.0.1 of the cpu to intel converter writen by \n");
- //printf("Magnus Olsen (magnus@greatlord.com), it does not do anything \n");
- //printf("yet, more that basic desgin how it should be writen. \n");
- //printf("Copyright 2006 by Magnus Olsen, licen under GPL 2.0 for now. \n");
-
-
- //if (argc <4)
- // return 110;
-
- ///* fixme better error checking for the input param */
- //for (t=1; t<argc;t+=2)
- //{
- // if (stricmp(argv[t],"-in"))
- // {
- // infile = argv[t+1];
- // type=0;
- // }
-
- // if (stricmp(argv[t],"-inBin"))
- // {
- // infile = argv[t+1];
- // type=1;
- // }
-
- // if (stricmp(argv[t],"-inExe"))
- // {
- // infile = argv[t+1];
- // type=1;
- // }
-
- // if (stricmp(argv[t],"-OutAsm"))
- // {
- // outfile = argv[t+1];
- // }
- // if (stricmp(argv[t],"-OutDis"))
- // {
- // outfile = argv[t+1];
- // mode = 0;
- // }
- // if (stricmp(argv[t],"-BaseAddress"))
- // {
- // BaseAddress = atol(argv[t+1]);
- // }
- // if (stricmp(argv[t],"-cpu"))
- // {
- // cpuid = argv[t+1];
- // }
-
- //}
-
- // mode 0 disambler
- // mode 1 convert to intel
- // mode 2 convert to ppc
- //return LoadPFileImage(infile,outfile,BaseAddress,cpuid,type, mode);
- //LoadPFileImage("e:\\testppc.exe","e:\\cputointel.asm",0,0,0,1);
- LoadPFileImage("e:\\testppc.exe","e:\\cputointel.asm",0,0,0,1);
- //pMyBrainAnalys = NULL;
- //pStartMyBrainAnalys = NULL;
- //LoadPFileImage("e:\\testppc.exe","e:\\cputoppc.asm",0,0,0,2);
-
- // return LoadPFileImage("e:\\testms.exe","e:\\cputointel.asm",0,0,0,1); // convert
- return 0;
-}
-
-
-
-
-
-
-
-
+++ /dev/null
-
-#include "../../misc.h"
-
-CPU_INT ARMBrain( CPU_BYTE *cpu_buffer,
- CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size,
- CPU_UNINT BaseAddress,
- CPU_UNINT cpuarch,
- FILE *outfp);
-
-/* here we put the prototype for the opcode api that brain need we show a example for it */
-CPU_INT ARM_(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-
-
-/* Export comment thing see m68k for example
- * in dummy we do not show it, for it is diffent for each cpu
- */
+++ /dev/null
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "ARMBrain.h"
-#include "ARM.h"
-#include "../../misc.h"
-
-/*
- * DummyBrain is example how you create you own cpu brain to translate from
- * cpu to intel assembler, I have not add DummyBrain to the loader it is not
- * need it in our example. When you write you own brain, it must be setup in
- * misc.c function LoadPFileImage and PEFileStart, PEFileStart maybe does not
- * need the brain you have writen so you do not need setup it there then.
- *
- * input param:
- * cpu_buffer : the memory buffer with loaded program we whant translate
- * cpu_pos : the positions in the cpu_buffer
- * cpu_size : the alloced memory size of the cpu_buffer
- * BaseAddress : the virtual memory address we setup to use.
- * cpuarch : the sub arch for the brain, example if it exists more one
- * cpu with same desgin but few other opcode or extend opcode
- * outfp : the output file pointer
- *
- * mode : if we should run disambler of this binary or
- * translate it, Disambler will not calc the
- * the row name right so we simple give each
- row a name. In translations mode we run a
- * analys so we getting better optimzing and
- * only row name there we need.
- * value for mode are :
- * 0 = disambler mode
- * 1 = translate mode intel
- *
- * return value
- * 0 : Ok
- * 1 : unimplemt
- * 2 : Unkonwn Opcode
- * 3 : unimplement cpu
- * 4 : unknown machine
- */
-
-CPU_INT ARMBrain( CPU_BYTE *cpu_buffer,
- CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size,
- CPU_UNINT BaseAddress,
- CPU_UNINT cpuarch,
- FILE *outfp)
-{
- CPU_UNINT cpu_oldpos;
- CPU_INT cpuint;
- CPU_INT retcode = 0;
- CPU_INT retsize;
-
-
- /* now we start the process */
- while (cpu_pos<cpu_size)
- {
- cpu_oldpos = cpu_pos;
-
- cpuint = cpu_buffer[cpu_pos];
-
- /* Add */
- if ((cpuint - (cpuint & GetMaskByte32(cpuARMInit_))) == ConvertBitToByte32(cpuARMInit_))
- {
- retsize = ARM_( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Found all Opcode and breakout and return no error found */
- if (cpu_pos >=cpu_size)
- {
- break;
- }
-
- /* Check if we have found a cpu opcode */
- if (cpu_oldpos == cpu_pos)
- {
- if (retcode == 0)
- {
- /* no unimplement error where found so we return a msg for unknown opcode */
- printf("Unkonwn Opcode found at 0x%8x opcode 0x%2x\n",cpu_oldpos+BaseAddress,(unsigned int)cpu_buffer[cpu_oldpos]);
- retcode = 2;
- }
- }
-
- /* Erorro Found ? */
- if (retcode!=0)
- {
- /* Erorro Found break and return the error code */
- break;
- }
- }
- return retcode;
-}
+++ /dev/null
-
-#include "../../misc.h"
-
-
-/* example how setup a opcode, this opcode is 16bit long (taken from M68K)
- * 0 and 1 mean normal bit, 2 mean mask bit the bit that are determent diffent
- * thing in the opcode, example which reg so on, it can be etither 0 or 1 in
- * the opcode. but a opcode have also normal bit that is always been set to
- * same. thuse bit are always 0 or 1
- */
-CPU_BYTE cpuARMInit_[32] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};
-
+++ /dev/null
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "../../misc.h"
-
-
-/* cpuDummyInit_Add
- * Input param :
- * out : The file pointer that we write to (the output file to intel asm)
- * cpu_buffer : The memory buffer we have our binary code that we whant convert
- * cpu_pos : Current positions in the cpu_buffer
- * cpu_size : The memory size of the cpu_buffer
- * BaseAddress : The base address you whant the binay file should run from
- * cpuarch : if it exists diffent cpu from a manufactor like pentium,
- * pentinum-mmx so on, use this flag to specify which type
- * of cpu you whant or do not use it if it does not exists
- * other or any sub model.
- *
- * mode : if we should run disambler of this binary or
- * translate it, Disambler will not calc the
- * the row name right so we simple give each
- row a name. In translations mode we run a
- * analys so we getting better optimzing and
- * only row name there we need.
- * value for mode are :
- * 0 = disambler mode
- * 1 = translate mode intel
-
- *
- * Return value :
- * value -1 : unimplement
- * value 0 : wrong opcode or not vaild opcode
- * value +1 and higher : who many byte we should add to cpu_pos
- */
-
-CPU_INT ARM_( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-
-{
- /*
- * ConvertBitToByte() is perfect to use to get the bit being in use from a bit array
- * GetMaskByte() is perfect if u whant known which bit have been mask out
- * see M68kopcode.c and how it use the ConvertBitToByte()
- */
-
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Add unimplement\n");
- return -1;
-}
+++ /dev/null
-
-#include "../../misc.h"
-
-CPU_INT IA32Brain( CPU_BYTE *cpu_buffer,
- CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size,
- CPU_UNINT BaseAddress,
- CPU_UNINT cpuarch,
- FILE *outfp);
-
-/* here we put the prototype for the opcode api that brain need we show a example for it */
-CPU_INT IA32_Add(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-
-
-/* Export comment thing see m68k for example
- * in dummy we do not show it, for it is diffent for each cpu
- */
+++ /dev/null
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "IA32Brain.h"
-#include "IA32.h"
-#include "../../any_op.h"
-#include "../../misc.h"
-
-
-
-
-/*
- * DummyBrain is example how you create you own cpu brain to translate from
- * cpu to intel assembler, I have not add DummyBrain to the loader it is not
- * need it in our example. When you write you own brain, it must be setup in
- * misc.c function LoadPFileImage and PEFileStart, PEFileStart maybe does not
- * need the brain you have writen so you do not need setup it there then.
- *
- * input param:
- * cpu_buffer : the memory buffer with loaded program we whant translate
- * cpu_pos : the positions in the cpu_buffer
- * cpu_size : the alloced memory size of the cpu_buffer
- * BaseAddress : the virtual memory address we setup to use.
- * cpuarch : the sub arch for the brain, example if it exists more one
- * cpu with same desgin but few other opcode or extend opcode
- * outfp : the output file pointer
- *
- * mode : if we should run disambler of this binary or
- * translate it, Disambler will not calc the
- * the row name right so we simple give each
- row a name. In translations mode we run a
- * analys so we getting better optimzing and
- * only row name there we need.
- * value for mode are :
- * 0 = disambler mode
- * 1 = translate mode intel
- *
- * return value
- * 0 : Ok
- * 1 : unimplemt
- * 2 : Unkonwn Opcode
- * 3 : unimplement cpu
- * 4 : unknown machine
- */
-
-CPU_INT IA32Brain( CPU_BYTE *cpu_buffer,
- CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size,
- CPU_UNINT BaseAddress,
- CPU_UNINT cpuarch,
- FILE *outfp)
-{
- CPU_UNINT cpu_oldpos;
- CPU_INT cpuint;
- CPU_INT retcode = 0;
- CPU_INT retsize;
-
- /* now we start the process */
- while (cpu_pos<cpu_size)
- {
- cpu_oldpos = cpu_pos;
-
- /* use the GetData32Be or GetData32Le
- to read from the memory the
- Le is for small endian and the
- Be is for big endian
- the 32 is how many bits we should read
- */
- cpuint = GetData32Be(&cpu_buffer[cpu_pos]);
-
- /* Add */
- if ((cpuint - (cpuint & GetMaskByte(cpuIA32Init_Add))) == ConvertBitToByte(cpuIA32Init_Add))
- {
- retsize = IA32_Add( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Found all Opcode and breakout and return no error found */
- if (cpu_pos >=cpu_size)
- {
- break;
- }
-
- /* Check if we have found a cpu opcode */
- if (cpu_oldpos == cpu_pos)
- {
- if (retcode == 0)
- {
- /* no unimplement error where found so we return a msg for unknown opcode */
- printf("Unkonwn Opcode found at 0x%8x opcode 0x%2x\n",cpu_oldpos+BaseAddress,(unsigned int)cpu_buffer[cpu_oldpos]);
- retcode = 2;
- }
- }
-
- /* Erorro Found ? */
- if (retcode!=0)
- {
- /* Erorro Found break and return the error code */
- break;
- }
- }
- return retcode;
-}
+++ /dev/null
-
-
-#include "../../misc.h"
-
-
-/* example how setup a opcode, this opcode is 16bit long (taken from M68K)
- * 0 and 1 mean normal bit, 2 mean mask bit the bit that are determent diffent
- * thing in the opcode, example which reg so on, it can be etither 0 or 1 in
- * the opcode. but a opcode have also normal bit that is always been set to
- * same. thuse bit are always 0 or 1
- */
-CPU_BYTE cpuIA32Init_Add[16] = {1,1,0,1,2,2,2,2,2,2,2,2,2,2,2,2};
-
+++ /dev/null
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "IA32.h"
-#include "../../misc.h"
-
-
-/* cpuDummyInit_Add
- * Input param :
- * out : The file pointer that we write to (the output file to intel asm)
- * cpu_buffer : The memory buffer we have our binary code that we whant convert
- * cpu_pos : Current positions in the cpu_buffer
- * cpu_size : The memory size of the cpu_buffer
- * BaseAddress : The base address you whant the binay file should run from
- * cpuarch : if it exists diffent cpu from a manufactor like pentium,
- * pentinum-mmx so on, use this flag to specify which type
- * of cpu you whant or do not use it if it does not exists
- * other or any sub model.
- *
- * mode : if we should run disambler of this binary or
- * translate it, Disambler will not calc the
- * the row name right so we simple give each
- row a name. In translations mode we run a
- * analys so we getting better optimzing and
- * only row name there we need.
- * value for mode are :
- * 0 = disambler mode
- * 1 = translate mode intel
- *
- * Return value :
- * value -1 : unimplement
- * value 0 : wrong opcode or not vaild opcode
- * value +1 and higher : who many byte we should add to cpu_pos
- */
-
-CPU_INT IA32_Add( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-
-{
- /*
- * ConvertBitToByte() is perfect to use to get the bit being in use from a bit array
- * GetMaskByte() is perfect if u whant known which bit have been mask out
- * see M68kopcode.c and how it use the ConvertBitToByte()
- */
-
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Add unimplement\n");
- return -1;
-}
+++ /dev/null
-
-#include "../../misc.h"
-
-CPU_INT PPCBrain( CPU_BYTE *cpu_buffer,
- CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size,
- CPU_UNINT BaseAddress,
- CPU_UNINT cpuarch,
- FILE *outfp);
-
-
-/* here we put the prototype for the opcode api that brain need we show a example for it */
-CPU_INT PPC_Blr( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT PPC_Li( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT PPC_mr( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT PPC_Stw( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT PPC_Stwu( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-
-/* Export comment thing see m68k for example
- * in dummy we do not show it, for it is diffent for each cpu
- */
-
-
+++ /dev/null
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "PPCBrain.h"
-#include "PPC.h"
-#include "../../misc.h"
-
-/*
- * DummyBrain is example how you create you own cpu brain to translate from
- * cpu to intel assembler, I have not add DummyBrain to the loader it is not
- * need it in our example. When you write you own brain, it must be setup in
- * misc.c function LoadPFileImage and PEFileStart, PEFileStart maybe does not
- * need the brain you have writen so you do not need setup it there then.
- *
- * input param:
- * cpu_buffer : the memory buffer with loaded program we whant translate
- * cpu_pos : the positions in the cpu_buffer
- * cpu_size : the alloced memory size of the cpu_buffer
- * BaseAddress : the virtual memory address we setup to use.
- * cpuarch : the sub arch for the brain, example if it exists more one
- * cpu with same desgin but few other opcode or extend opcode
- * outfp : the output file pointer
- *
- * mode : if we should run disambler of this binary or
- * translate it, Disambler will not calc the
- * the row name right so we simple give each
- row a name. In translations mode we run a
- * analys so we getting better optimzing and
- * only row name there we need.
- * value for mode are :
- * 0 = disambler mode
- * 1 = translate mode intel
- *
- * return value
- * 0 : Ok
- * 1 : unimplemt
- * 2 : Unkonwn Opcode
- * 3 : unimplement cpu
- * 4 : unknown machine
- */
-
-CPU_INT PPCBrain( CPU_BYTE *cpu_buffer,
- CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size,
- CPU_UNINT BaseAddress,
- CPU_UNINT cpuarch,
- FILE *outfp)
-{
- CPU_UNINT cpu_oldpos;
- CPU_INT cpuint;
- CPU_INT retcode = 0;
- CPU_INT retsize;
-
- /* now we start the process */
- while (cpu_pos<cpu_size)
- {
- cpu_oldpos = cpu_pos;
-
- cpuint = GetData32Le(&cpu_buffer[cpu_pos]);
-
- /* blr */
- if ((cpuint - (cpuint & GetMaskByte32(cpuPPCInit_Blr))) == ConvertBitToByte32(cpuPPCInit_Blr))
- {
- retsize = PPC_Blr( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Li*/
- if ((cpuint - (cpuint & GetMaskByte32(cpuPPCInit_Li))) == ConvertBitToByte32(cpuPPCInit_Li))
- {
- retsize = PPC_Li( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* mr */
- if ((cpuint - (cpuint & GetMaskByte32(cpuPPCInit_mr))) == ConvertBitToByte32(cpuPPCInit_mr))
- {
- retsize = PPC_mr( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* stw */
- if ((cpuint - (cpuint & GetMaskByte32(cpuPPCInit_stw))) == ConvertBitToByte32(cpuPPCInit_stw))
- {
- retsize = PPC_Stw( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* stwu */
- if ((cpuint - (cpuint & GetMaskByte32(cpuPPCInit_stwu))) == ConvertBitToByte32(cpuPPCInit_stwu))
- {
- retsize = PPC_Stwu( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Found all Opcode and breakout and return no error found */
- if (cpu_pos >=cpu_size)
- {
- break;
- }
-
- /* Check if we have found a cpu opcode */
- if (cpu_oldpos == cpu_pos)
- {
- if (retcode == 0)
- {
- /* no unimplement error where found so we return a msg for unknown opcode */
- printf("Unkonwn Opcode found at 0x%8x opcode 0x%2x\n",cpu_oldpos+BaseAddress,(unsigned int)cpu_buffer[cpu_oldpos]);
- retcode = 2;
- }
- }
-
- /* Erorro Found ? */
- if (retcode!=0)
- {
- /* Erorro Found break and return the error code */
- break;
- }
- }
-
- return 0; // hack getting dismabler working or converting working
- return retcode;
-}
+++ /dev/null
-
-#include "../../misc.h"
-
-
-/* example how setup a opcode, this opcode is 16bit long (taken from M68K)
- * 0 and 1 mean normal bit, 2 mean mask bit the bit that are determent diffent
- * thing in the opcode, example which reg so on, it can be etither 0 or 1 in
- * the opcode. but a opcode have also normal bit that is always been set to
- * same. thuse bit are always 0 or 1
- */
-
-/* FIXME RA should be 0 in stwu */
-CPU_BYTE cpuPPCInit_Blr[32] = {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, 0,1,0,0,1,1, 1,0};
-/* addi */
-CPU_BYTE cpuPPCInit_Li[32] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0, 0,0,1,1,1,0, 2,2};
-CPU_BYTE cpuPPCInit_stw[32] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 1,0,0,1,0,0, 2,2};
-CPU_BYTE cpuPPCInit_stwu[32] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 1,0,0,1,0,1, 2,2};
-CPU_BYTE cpuPPCInit_mr[32] = {0,1,1,1,1,0,0,0,0,0,0,0,1,0,1,1,2,2,2,2,2,2,2,2, 0,1,1,1,1,1, 2,2};
-CPU_BYTE cpuPPCInit_lwz[32] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 1,0,0,0,0,0, 2,2};
-
-
-
-/* mask */
-/*
- * no mask we implement function getting the reg right
- */
-
-/* bit index
- 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
- 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-*/
-
+++ /dev/null
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "PPC.h"
-#include "../../misc.h"
-#include "../../any_op.h"
-
-/* reg r0-r31
- r3 = eax
- */
-
-/* cpuDummyInit_Add
- * Input param :
- * out : The file pointer that we write to (the output file to intel asm)
- * cpu_buffer : The memory buffer we have our binary code that we whant convert
- * cpu_pos : Current positions in the cpu_buffer
- * cpu_size : The memory size of the cpu_buffer
- * BaseAddress : The base address you whant the binay file should run from
- * cpuarch : if it exists diffent cpu from a manufactor like pentium,
- * pentinum-mmx so on, use this flag to specify which type
- * of cpu you whant or do not use it if it does not exists
- * other or any sub model.
- *
- * Return value :
- * value -1 : unimplement
- * value 0 : wrong opcode or not vaild opcode
- * value +1 and higher : who many byte we should add to cpu_pos
- */
-
-/* Get Dest register */
-#define PPC_GetBitArraySrcReg(opcode) (((opcode & 0x3) << 3) | ((opcode & 0xE000) >> 13))
-
-/* Get Source register */
-CPU_UNINT PPC_GetBitArrayBto31xx(CPU_UNINT opcode)
-{
- CPU_INT x1;
-
- /* FIXME make it to a macro
- * not tested to 100% yet */
- x1 = ((opcode & 0x1F00)>>8);
- return x1;
-}
-
-
-CPU_UNINT PPC_GetBitArrayBto31(CPU_UNINT opcode)
-{
- CPU_INT x1;
- /* FIXME make it to a macro
- * not tested to 100% yet */
- x1 = ((opcode & 0xFFFF0000)>>16);
- return x1;
-}
-
-
-CPU_INT PPC_Blr( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
-
- BaseAddress +=cpu_pos;
-
- /* own translatons langues */
- if (AllocAny()!=0) /* alloc memory for pMyBrainAnalys */
- {
- return -1;
- }
- pMyBrainAnalys->op = OP_ANY_ret;
- pMyBrainAnalys->memAdr=BaseAddress;
-
- return 4;
-}
-
-
-CPU_INT PPC_Li( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- CPU_UNINT opcode;
-
- opcode = GetData32Le(&cpu_buffer[cpu_pos]);
-
- BaseAddress +=cpu_pos;
-
- /* own translatons langues */
- if (AllocAny()!=0) /* alloc memory for pMyBrainAnalys */
- {
- return -1;
- }
- pMyBrainAnalys->op = OP_ANY_mov;
- pMyBrainAnalys->type= 8 + 16; /* 8 dst reg, 16 imm */
- pMyBrainAnalys->src_size = 16;
- pMyBrainAnalys->src = PPC_GetBitArraySrcReg(opcode);
- pMyBrainAnalys->dst = PPC_GetBitArrayBto31(opcode);
- pMyBrainAnalys->memAdr=BaseAddress;
-
- return 4;
-}
-
-
-CPU_INT PPC_mr( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- CPU_UNINT opcode;
-
- opcode = GetData32Le(&cpu_buffer[cpu_pos]);
-
- BaseAddress +=cpu_pos;
-
- /* own translatons langues */
- if (AllocAny()!=0) /* alloc memory for pMyBrainAnalys */
- {
- return -1;
- }
- pMyBrainAnalys->op = OP_ANY_mov;
- pMyBrainAnalys->type= 2 + 8; /* 8 dst reg, 2 src reg */
- pMyBrainAnalys->src_size = 32;
- pMyBrainAnalys->src = PPC_GetBitArraySrcReg(opcode);
- pMyBrainAnalys->dst = PPC_GetBitArrayBto31xx(opcode);
- pMyBrainAnalys->memAdr=BaseAddress;
-
- return 4;
-}
-
-
-CPU_INT PPC_Stw( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- /* r1 store at -0x20(r1) */
-
- CPU_UNINT opcode;
- CPU_SHORT tmp = 0;
-
- opcode = GetData32Le(&cpu_buffer[cpu_pos]);
-
- BaseAddress +=cpu_pos;
-
- /* own translatons langues */
- if (AllocAny()!=0) /* alloc memory for pMyBrainAnalys */
- {
- return -1;
- }
-
- tmp = _byteswap_ushort( ((CPU_SHORT)((opcode >> 16) & 0xffff)));
-
- pMyBrainAnalys->op = OP_ANY_mov;
- pMyBrainAnalys->type= 2 + 64;
- pMyBrainAnalys->src_size = 32;
- pMyBrainAnalys->dst_size = 32;
- pMyBrainAnalys->src = PPC_GetBitArraySrcReg(opcode);
- pMyBrainAnalys->dst = PPC_GetBitArrayBto31xx(opcode);
- pMyBrainAnalys-> dst_extra = tmp;
- pMyBrainAnalys->memAdr=BaseAddress;
-
- return 4;
-}
-
-CPU_INT PPC_Stwu( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- /* r1 store at -0x20(r1) */
-
- CPU_UNINT opcode;
- CPU_INT DstReg;
- CPU_SHORT tmp = 0;
-
- opcode = GetData32Le(&cpu_buffer[cpu_pos]);
-
- DstReg = PPC_GetBitArrayBto31xx(opcode);
- if (DstReg == 0)
- {
- return 0;
- }
-
- BaseAddress +=cpu_pos;
-
- /* own translatons langues */
- if (AllocAny()!=0) /* alloc memory for pMyBrainAnalys */
- {
- return -1;
- }
-
- tmp = _byteswap_ushort( ((CPU_SHORT)((opcode >> 16) & 0xffff)));
-
- pMyBrainAnalys->op = OP_ANY_mov;
- pMyBrainAnalys->type= 2 + 64 + 128;
- pMyBrainAnalys->src_size = 32;
- pMyBrainAnalys->dst_size = 32;
- pMyBrainAnalys->src = PPC_GetBitArraySrcReg(opcode);
- pMyBrainAnalys->dst = DstReg;
- pMyBrainAnalys-> dst_extra = tmp;
- pMyBrainAnalys->memAdr=BaseAddress;
-
- return 4;
-}
+++ /dev/null
-
-#include "../../misc.h"
-
-CPU_INT DummyBrain( CPU_BYTE *cpu_buffer,
- CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size,
- CPU_UNINT BaseAddress,
- CPU_UNINT cpuarch,
- FILE *outfp);
-
-/* here we put the prototype for the opcode api that brain need we show a example for it */
-CPU_INT DUMMY_Add(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-
-
-/* Export comment thing see m68k for example
- * in dummy we do not show it, for it is diffent for each cpu
- */
+++ /dev/null
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "DummyBrain.h"
-#include "Dummy.h"
-#include "../../misc.h"
-
-
-
-/*
- * DummyBrain is example how you create you own cpu brain to translate from
- * cpu to intel assembler, I have not add DummyBrain to the loader it is not
- * need it in our example. When you write you own brain, it must be setup in
- * misc.c function LoadPFileImage and PEFileStart, PEFileStart maybe does not
- * need the brain you have writen so you do not need setup it there then.
- *
- * input param:
- * cpu_buffer : the memory buffer with loaded program we whant translate
- * cpu_pos : the positions in the cpu_buffer
- * cpu_size : the alloced memory size of the cpu_buffer
- * BaseAddress : the virtual memory address we setup to use.
- * cpuarch : the sub arch for the brain, example if it exists more one
- * cpu with same desgin but few other opcode or extend opcode
- * outfp : the output file pointer
- *
- * return value
- * 0 : Ok
- * 1 : unimplemt
- * 2 : Unkonwn Opcode
- * 3 : unimplement cpu
- * 4 : unknown machine
- */
-
-CPU_INT DummyBrain( CPU_BYTE *cpu_buffer,
- CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size,
- CPU_UNINT BaseAddress,
- CPU_UNINT cpuarch,
- FILE *outfp)
-{
- CPU_UNINT cpu_oldpos;
- CPU_INT cpuint;
- CPU_INT retcode = 0;
- CPU_INT retsize;
-
- /* now we start the process */
- while (cpu_pos<cpu_size)
- {
- cpu_oldpos = cpu_pos;
-
- /* use the GetData32Be or GetData32Le
- to read from the memory the
- Le is for small endian and the
- Be is for big endian
- the 32 is how many bits we should read
- */
- cpuint = GetData32Be(&cpu_buffer[cpu_pos]);
-
- /* Add */
- if ((cpuint - (cpuint & GetMaskByte(cpuDummyInit_Add))) == ConvertBitToByte(cpuDummyInit_Add))
- {
- retsize = DUMMY_Add( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Found all Opcode and breakout and return no error found */
- if (cpu_pos >=cpu_size)
- {
- break;
- }
-
- /* Check if we have found a cpu opcode */
- if (cpu_oldpos == cpu_pos)
- {
- if (retcode == 0)
- {
- /* no unimplement error where found so we return a msg for unknown opcode */
- printf("Unkonwn Opcode found at 0x%8x opcode 0x%2x\n",cpu_oldpos+BaseAddress,(unsigned int)cpu_buffer[cpu_oldpos]);
- retcode = 2;
- }
- }
-
- /* Erorro Found ? */
- if (retcode!=0)
- {
- /* Erorro Found break and return the error code */
- break;
- }
- }
- return retcode;
-}
+++ /dev/null
-
-#include "../../misc.h"
-
-
-/* example how setup a opcode, this opcode is 16bit long (taken from M68K)
- * 0 and 1 mean normal bit, 2 mean mask bit the bit that are determent diffent
- * thing in the opcode, example which reg so on, it can be etither 0 or 1 in
- * the opcode. but a opcode have also normal bit that is always been set to
- * same. thuse bit are always 0 or 1
- */
-CPU_BYTE cpuDummyInit_Add[16] = {1,1,0,1,2,2,2,2,2,2,2,2,2,2,2,2};
-
+++ /dev/null
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "Dummy.h"
-#include "../../misc.h"
-
-
-/* cpuDummyInit_Add
- * Input param :
- * out : The file pointer that we write to (the output file to intel asm)
- * cpu_buffer : The memory buffer we have our binary code that we whant convert
- * cpu_pos : Current positions in the cpu_buffer
- * cpu_size : The memory size of the cpu_buffer
- * BaseAddress : The base address you whant the binay file should run from
- * cpuarch : if it exists diffent cpu from a manufactor like pentium,
- * pentinum-mmx so on, use this flag to specify which type
- * of cpu you whant or do not use it if it does not exists
- * other or any sub model.
- * Return value :
- * value -1 : unimplement
- * value 0 : wrong opcode or not vaild opcode
- * value +1 and higher : who many byte we should add to cpu_pos
- */
-
-CPU_INT DUMMY_Add( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-
-{
- /*
- * ConvertBitToByte() is perfect to use to get the bit being in use from a bit array
- * GetMaskByte() is perfect if u whant known which bit have been mask out
- * see M68kopcode.c and how it use the ConvertBitToByte()
- */
-
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Add unimplement\n");
- return -1;
-}
+++ /dev/null
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "M68kBrain.h"
-#include "m68k.h"
-#include "../../misc.h"
-
-/*
- * DummyBrain is example how you create you own cpu brain to translate from
- * cpu to intel assembler, I have not add DummyBrain to the loader it is not
- * need it in our example. When you write you own brain, it must be setup in
- * misc.c function LoadPFileImage and PEFileStart, PEFileStart maybe does not
- * need the brain you have writen so you do not need setup it there then.
- *
- * input param:
- * cpu_buffer : the memory buffer with loaded program we whant translate
- * cpu_pos : the positions in the cpu_buffer
- * cpu_size : the alloced memory size of the cpu_buffer
- * BaseAddress : the virtual memory address we setup to use.
- * cpuarch : the sub arch for the brain, example if it exists more one
- * cpu with same desgin but few other opcode or extend opcode
- * outfp : the output file pointer
- *
- * return value
- * 0 : Ok
- * 1 : unimplemt
- * 2 : Unkonwn Opcode
- * 3 : unimplement cpu
- * 4 : unknown machine
- */
-
-CPU_INT M68KBrain( CPU_BYTE *cpu_buffer,
- CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size,
- CPU_UNINT BaseAddress,
- CPU_UNINT cpuarch,
- FILE *outfp)
-{
- CPU_UNINT cpu_oldpos;
- CPU_INT cpuint;
- CPU_INT retcode = 0;
- CPU_INT retsize;
-
- /* now we start the process */
- while (cpu_pos<cpu_size)
- {
- cpu_oldpos = cpu_pos;
-
- cpuint = cpu_buffer[cpu_pos];
-
- /* Abcd */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Abcd))) == ConvertBitToByte(cpuM68kInit_Abcd))
- {
- retsize = M68k_Abcd( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
- /* Add */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Add))) == ConvertBitToByte(cpuM68kInit_Add))
- {
- retsize = M68k_Add( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
- /* Addi */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Addi))) == ConvertBitToByte(cpuM68kInit_Addi))
- {
- retsize = M68k_Addi( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
- /* Addq */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Addq))) == ConvertBitToByte(cpuM68kInit_Addq))
- {
- retsize = M68k_Addq( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
- /* Addx */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Addx))) == ConvertBitToByte(cpuM68kInit_Addx))
- {
- retsize = M68k_Addx( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
- /* And */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_And))) == ConvertBitToByte(cpuM68kInit_And))
- {
- retsize = M68k_Add( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
- /* Andi */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Andi))) == ConvertBitToByte(cpuM68kInit_Andi))
- {
- retsize = M68k_Andi( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
- /* AndToCCR */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_AndToCCRF))) == ConvertBitToByte(cpuM68kInit_AndToCCRF))
- {
- cpuint = cpu_buffer[cpu_pos+1];
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_AndToCCRS))) == ConvertBitToByte(cpuM68kInit_AndToCCRS))
- {
- cpu_pos++;
- retsize = M68k_AndToCCR( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
- else
- {
- cpuint = cpu_buffer[cpu_pos];
- }
- }
-
- /* Bhi */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Bhi))) == ConvertBitToByte(cpuM68kInit_Bhi))
- {
- retsize = M68k_Bhi( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Bls */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Bls))) == ConvertBitToByte(cpuM68kInit_Bls))
- {
- retsize = M68k_Bls( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Bcc */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Bcc))) == ConvertBitToByte(cpuM68kInit_Bcc))
- {
- retsize = M68k_Bcc( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Bcs */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Bcs))) == ConvertBitToByte(cpuM68kInit_Bcs))
- {
- retsize = M68k_Bcs( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Bne */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Bne))) == ConvertBitToByte(cpuM68kInit_Bne))
- {
- retsize = M68k_Bne( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Beq */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Beq))) == ConvertBitToByte(cpuM68kInit_Beq))
- {
- retsize = M68k_Beq( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Bvc */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Bvc))) == ConvertBitToByte(cpuM68kInit_Bvc))
- {
- retsize = M68k_Bvc( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Bvs */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Bvs))) == ConvertBitToByte(cpuM68kInit_Bvs))
- {
- retsize = M68k_Bvs( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Bpl */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Bpl))) == ConvertBitToByte(cpuM68kInit_Bpl))
- {
- retsize = M68k_Bpl( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Bmi */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Bmi))) == ConvertBitToByte(cpuM68kInit_Bmi))
- {
- retsize = M68k_Bmi( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Bge */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Bge))) == ConvertBitToByte(cpuM68kInit_Bge))
- {
- retsize = M68k_Bge( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Blt */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Blt))) == ConvertBitToByte(cpuM68kInit_Blt))
- {
- retsize = M68k_Blt( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Bgt */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Bgt))) == ConvertBitToByte(cpuM68kInit_Bgt))
- {
- retsize = M68k_Bgt( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Ble */
- if ((cpuint - (cpuint & GetMaskByte(cpuM68kInit_Ble))) == ConvertBitToByte(cpuM68kInit_Ble))
- {
- retsize = M68k_Ble( outfp, cpu_buffer, cpu_pos, cpu_size,
- BaseAddress, cpuarch);
- if (retsize<0)
- retcode = 1;
- else
- cpu_pos += retsize;
- }
-
- /* Found all Opcode and breakout and return no error found */
- if (cpu_pos >=cpu_size)
- {
- break;
- }
-
- /* Check if we have found a cpu opcode */
- if (cpu_oldpos == cpu_pos)
- {
- if (retcode == 0)
- {
- /* no unimplement error where found so we return a msg for unknown opcode */
- printf("Unkonwn Opcode found at 0x%8x opcode 0x%2x\n",cpu_oldpos+BaseAddress,(unsigned int)cpu_buffer[cpu_oldpos]);
- retcode = 2;
- }
- }
-
- /* Erorro Found ? */
- if (retcode!=0)
- {
- /* Erorro Found break and return the error code */
- break;
- }
- }
- return retcode;
-}
+++ /dev/null
-
-#include "../../misc.h"
-
-CPU_BYTE cpuM68kInit_Abcd[16] = {1,1,1,1,2,2,2,1,0,0,0,0,2,2,2,2};
-CPU_BYTE cpuM68kInit_Add[16] = {1,1,0,1,2,2,2,2,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Addi[16] = {0,0,0,0,0,1,1,0,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Addq[16] = {0,1,0,1,2,2,2,0,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Addx[16] = {1,1,0,1,2,2,2,1,2,2,0,0,2,2,2,2};
-CPU_BYTE cpuM68kInit_And[16] = {1,1,0,0,2,2,2,2,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Andi[16] = {0,0,0,0,0,0,1,0,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_AndToCCRF[16] = {0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,0};
-CPU_BYTE cpuM68kInit_AndToCCRS[16] = {0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Asl[16] = {1,1,1,0,2,2,2,0,2,2,2,0,0,2,2,2};
-CPU_BYTE cpuM68kInit_Asr[16] = {1,1,1,0,2,2,2,1,2,2,2,0,0,2,2,2};
-
-CPU_BYTE cpuM68kInit_Bhi[16] = {0,1,1,0,0,0,1,0,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Bls[16] = {0,1,1,0,0,0,1,1,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Bcc[16] = {0,1,1,0,0,1,0,0,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Bcs[16] = {0,1,1,0,0,1,0,1,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Bne[16] = {0,1,1,0,0,1,1,0,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Beq[16] = {0,1,1,0,0,1,1,1,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Bvc[16] = {0,1,1,0,1,0,0,0,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Bvs[16] = {0,1,1,0,1,0,0,1,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Bpl[16] = {0,1,1,0,1,0,1,0,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Bmi[16] = {0,1,1,0,1,0,1,1,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Bge[16] = {0,1,1,0,1,1,0,0,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Blt[16] = {0,1,1,0,1,1,0,1,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Bgt[16] = {0,1,1,0,1,1,1,0,2,2,2,2,2,2,2,2};
-CPU_BYTE cpuM68kInit_Ble[16] = {0,1,1,0,1,1,1,1,2,2,2,2,2,2,2,2};
-
-
-CPU_BYTE M68k_Rx[16] = {0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0};
-CPU_BYTE M68k_RM[16] = {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0};
-CPU_BYTE M68k_Ry[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1};
-CPU_BYTE M68k_Opmode[16] = {0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0};
-CPU_BYTE M68k_Mode[16] = {0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0};
-CPU_BYTE M68k_Size[16] = {0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0};
-
+++ /dev/null
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "m68k.h"
-#include "misc.h"
-
-
-CPU_INT M68k_Abcd( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Abcd unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Add(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- CPU_INT opmode;
- CPU_INT mode;
- CPU_INT Rx;
- CPU_INT Ry;
- //CPU_INT cpuint;
-
- opmode = ConvertBitToByte(M68k_Opmode);
- mode = ConvertBitToByte(M68k_Mode);
- Rx = ConvertBitToByte(M68k_Rx);
- Ry = ConvertBitToByte(M68k_Ry);
-
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- if (opmode == 0x00)
- {
- /* <ea> + Dn -> Dn */
- printf(";Add unimplement of \"<ea> + Dn -> Dn\" \n");
-
- }
-
- if (opmode == 0x01)
- {
- /* <ea> + Dn -> Dn */
- printf(";Add unimplement of \"<ea> + Dn -> Dn\" \n");
- }
-
- if (opmode == 0x02)
- {
- /* <ea> + Dn -> Dn */
- printf(";Add unimplement of \"<ea> + Dn -> Dn\" \n");
- }
-
- if (opmode == 0x03)
- {
- /* <ea> + An -> An */
- printf(";Add unimplement of \"<ea> + An -> An\" \n");
- }
-
- if (opmode == 0x04)
- {
- /* Dn + <ea> -> <ea> */
- printf(";Add unimplement of \"Dn + <ea> -> <ea>\" \n");
- }
-
- if (opmode == 0x05)
- {
- /* Dn + <ea> -> <ea> */
- printf(";Add unimplement of \"Dn + <ea> -> <ea>\" \n");
- }
-
- if (opmode == 0x06)
- {
- /* Dn + <ea> -> <ea> */
- printf(";Add unimplement of \"Dn + <ea> -> <ea>\" \n");
- }
-
- if (opmode == 0x07)
- {
- /* <ea> + An -> An */
- printf(";Add unimplement of \"<ea> + An -> An\" \n");
- }
-
-
-
-
-
- return -1;
-}
-
-CPU_INT M68k_Addi( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Addi unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Addq( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Addq unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Addx( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Addx unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_And( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";And unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Andi( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Andi unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_AndToCCR( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";AndToCCR unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Asl( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Asl unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Asr( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Asr unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Bhi( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Bhi unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Bls( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Bls unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Bcc( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Bcc unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Bcs( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Bcs unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Bne( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Bne unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Beq( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Beq unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Bvc( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Bvc unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Bvs( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Bvs unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Bpl( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Bpl unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Bmi( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Bmi unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Bge( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Bge unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Blt( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Blt unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Bgt( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Bgt unimplement\n");
- return -1;
-}
-
-CPU_INT M68k_Ble( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
-{
- fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
-
- printf(";Ble unimplement\n");
- return -1;
-}
-
-
+++ /dev/null
-
-#include "../../misc.h"
-CPU_INT M68KBrain( CPU_BYTE *cpu_buffer,
- CPU_UNINT cpu_pos,
- CPU_UNINT cpu_size,
- CPU_UNINT BaseAddress,
- CPU_UNINT cpuarch,
- FILE *outfp);
-
-
-CPU_INT M68k_Abcd(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Add(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Addi(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Addq(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Addx(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_And(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Andi(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_AndToCCR(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Asl(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Asr(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Bhi(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Bls(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Bcc(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Bcs(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Bne(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Beq(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Bvc(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Bvs(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Bpl(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Bmi(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Bge(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Blt(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Bgt(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT M68k_Ble(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-
-extern CPU_BYTE M68k_Rx[16];
-extern CPU_BYTE M68k_RM[16];
-extern CPU_BYTE M68k_Ry[16];
-extern CPU_BYTE M68k_Opmode[16];
-extern CPU_BYTE M68k_Mode[16];
-extern CPU_BYTE M68k_Size[16];
+++ /dev/null
-#include <windows.h>\r
-#include <winnt.h>\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include "misc.h"\r
-#include "From/ARM/ARM.h"\r
-#include "From/m68k/m68k.h"\r
-#include "From/PPC/PPC.h"\r
-\r
-static CPU_INT machine_type = 0;\r
-//static CPU_INT ToMachine_type = IMAGE_FILE_MACHINE_I386;\r
-static CPU_INT ToMachine_type = IMAGE_FILE_MACHINE_POWERPC;\r
-/*\r
- * infileName file name to convert or disambler\r
- * outputfileName file name to save to\r
- * BaseAddress the address we should emulate\r
- * cpuid the cpu we choice not vaild for pe loader\r
- * type the loading mode Auto, PE, bin\r
- * mode disambler mode : 0 the arch cpu.\r
- * translate mode : 1 intel\r
- * translate mode : 2 ppc\r
- *\r
- */\r
-\r
-static void SetCPU(CPU_INT FromCpu, CPU_INT mode)\r
-{\r
- machine_type = FromCpu;\r
- switch(mode)\r
- {\r
- case 0:\r
- ToMachine_type = machine_type;\r
- break;\r
-\r
- case 1:\r
- ToMachine_type = IMAGE_FILE_MACHINE_I386;\r
- break;\r
-\r
- case 2:\r
- ToMachine_type = IMAGE_FILE_MACHINE_POWERPC;\r
- break;\r
-\r
- default:\r
- printf("Not supported mode\n");\r
- break;\r
-\r
- }\r
-}\r
-\r
-static void Convert(FILE *outfp, CPU_INT FromCpu, CPU_INT mode)\r
-{\r
- SetCPU(machine_type,mode);\r
- AnyalsingProcess();\r
- ConvertProcess(outfp, machine_type, ToMachine_type);\r
- FreeAny();\r
-}\r
-\r
-\r
-CPU_INT LoadPFileImage( char *infileName, char *outputfileName,\r
- CPU_UNINT BaseAddress, char *cpuid,\r
- CPU_UNINT type, CPU_INT mode)\r
-{\r
- FILE *infp;\r
- FILE *outfp;\r
- CPU_BYTE *cpu_buffer;\r
- CPU_UNINT cpu_pos = 0;\r
- CPU_UNINT cpu_size=0;\r
- CPU_INT ret;\r
- //fopen("testms.exe","RB");\r
-\r
-\r
- /* Open file for read */\r
-\r
- if (!(infp = fopen(infileName, "rb")))\r
- {\r
- printf("Can not open file %s\n",infileName);\r
- return 3;\r
- }\r
-\r
- /* Open file for write */\r
- if (!(outfp = fopen(outputfileName,"wb")))\r
- {\r
- printf("Can not open file %s\n",outputfileName);\r
- return 4;\r
- }\r
-\r
- /* Load the binary file to a memory buffer */\r
- fseek(infp,0,SEEK_END);\r
- if (ferror(infp))\r
- {\r
- printf("error can not seek in the read file");\r
- fclose(infp);\r
- fclose(outfp);\r
- return 5;\r
- }\r
-\r
- /* get the memory size buffer */\r
- cpu_size = ftell(infp);\r
- if (ferror(infp))\r
- {\r
- printf("error can not get file size of the read file");\r
- fclose(infp);\r
- fclose(outfp);\r
- return 6;\r
- }\r
-\r
- /* Load the binary file to a memory buffer */\r
- fseek(infp,0,SEEK_SET);\r
- if (ferror(infp))\r
- {\r
- printf("error can not seek in the read file");\r
- fclose(infp);\r
- fclose(outfp);\r
- return 5;\r
- }\r
-\r
- if (cpu_size==0)\r
- {\r
- printf("error file size is Zero lenght of the read file");\r
- fclose(infp);\r
- fclose(outfp);\r
- return 7;\r
- }\r
-\r
- /* alloc memory now */\r
- ;\r
- if (!(cpu_buffer = (unsigned char *) malloc(cpu_size+1)))\r
- {\r
- printf("error can not alloc %uld size for memory buffer",cpu_size);\r
- fclose(infp);\r
- fclose(outfp);\r
- return 8;\r
- }\r
- ZeroMemory(cpu_buffer,cpu_size);\r
-\r
- /* read from the file now in one sweep */\r
- fread((void *)cpu_buffer,1,cpu_size,infp);\r
- if (ferror(infp))\r
- {\r
- printf("error can not read file ");\r
- fclose(infp);\r
- fclose(outfp);\r
- return 9;\r
- }\r
- fclose(infp);\r
-\r
- if (type==0)\r
- {\r
- if ( PEFileStart(cpu_buffer, 0, BaseAddress, cpu_size, outfp, mode) !=0)\r
- {\r
- type=1;\r
- }\r
- else\r
- {\r
- if (mode > 0)\r
- {\r
- Convert(outfp,machine_type,mode);\r
- }\r
- fclose(outfp);\r
- return 0;\r
- }\r
-\r
- /* fixme */\r
- return -1;\r
- }\r
-\r
- if (type== 1)\r
- {\r
- if (stricmp(cpuid,"m68000"))\r
- {\r
- ret = M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68000,outfp);\r
- if (mode > 1)\r
- {\r
- Convert(outfp,machine_type,mode);\r
- }\r
- fclose(outfp);\r
- }\r
- else if (stricmp(cpuid,"m68010"))\r
- {\r
- ret = M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68010,outfp);\r
- if (mode > 1)\r
- {\r
- Convert(outfp,machine_type,mode);\r
- }\r
- fclose(outfp);\r
- return ret;\r
- }\r
- else if (stricmp(cpuid,"m68020"))\r
- {\r
- ret = M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68020,outfp);\r
- if (mode > 1)\r
- {\r
- Convert(outfp,machine_type,mode);\r
- }\r
- fclose(outfp);\r
- return ret;\r
- }\r
- else if (stricmp(cpuid,"m68030"))\r
- {\r
- ret = M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68030,outfp);\r
- if (mode > 1)\r
- {\r
- Convert(outfp,machine_type,mode);\r
- }\r
- fclose(outfp);\r
- return ret;\r
- }\r
- else if (stricmp(cpuid,"m68040"))\r
- {\r
- ret = M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68040,outfp);\r
- if (mode > 1)\r
- {\r
- Convert(outfp,machine_type,mode);\r
- }\r
- fclose(outfp);\r
- return ret;\r
- }\r
- else if (stricmp(cpuid,"ppc"))\r
- {\r
- ret = PPCBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,0,outfp);\r
- if (mode > 1)\r
- {\r
- Convert(outfp,machine_type,mode);\r
- }\r
- fclose(outfp);\r
- return ret;\r
- }\r
- else if (stricmp(cpuid,"arm4"))\r
- {\r
- ret = ARMBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,4,outfp);\r
- if (mode > 1)\r
- {\r
- Convert(outfp,machine_type,mode);\r
- }\r
- fclose(outfp);\r
- return ret;\r
- }\r
- }\r
-\r
- if (type==2)\r
- {\r
-\r
- ret = PEFileStart(cpu_buffer, 0, BaseAddress, cpu_size, outfp, mode);\r
- if (mode > 1)\r
- {\r
- Convert(outfp,machine_type,mode);\r
- }\r
- fclose(outfp);\r
- return ret;\r
- }\r
-\r
- return 0;\r
-}\r
-\r
-#define MAXSECTIONNUMBER 16\r
-\r
-CPU_INT PEFileStart( CPU_BYTE *memory, CPU_UNINT pos,\r
- CPU_UNINT base, CPU_UNINT size,\r
- FILE *outfp, CPU_INT mode)\r
-{\r
- PIMAGE_DOS_HEADER DosHeader;\r
- PIMAGE_NT_HEADERS NtHeader;\r
- IMAGE_SECTION_HEADER SectionHeader[MAXSECTIONNUMBER] = {NULL};\r
- PIMAGE_SECTION_HEADER pSectionHeader;\r
- PIMAGE_EXPORT_DIRECTORY ExportEntry;\r
- INT NumberOfSections;\r
- INT NumberOfSectionsCount=0;\r
- INT i;\r
-\r
- DosHeader = (PIMAGE_DOS_HEADER)memory;\r
- if ( (DosHeader->e_magic != IMAGE_DOS_SIGNATURE) ||\r
- (size < 0x3c+2) )\r
- {\r
- printf("No MZ file \n");\r
- return -1;\r
- }\r
-\r
- NtHeader = (PIMAGE_NT_HEADERS) (((ULONG)memory) + ((ULONG)DosHeader->e_lfanew));\r
- if (NtHeader->Signature != IMAGE_NT_SIGNATURE)\r
- {\r
- printf("No PE header found \n");\r
- }\r
-\r
- if (!(NtHeader->FileHeader.Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE))\r
- {\r
- printf("No execute image found \n");\r
- return -1;\r
- }\r
-\r
- switch(NtHeader->OptionalHeader.Subsystem)\r
- {\r
- case IMAGE_SUBSYSTEM_EFI_APPLICATION:\r
- fprintf(outfp,"; OS type : IMAGE_SUBSYSTEM_EFI_APPLICATION\n");\r
- printf("This exe file is desgin run in EFI bios as applactions\n");\r
- break;\r
- case IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:\r
- fprintf(outfp,"; OS type : IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER\n");\r
- printf("This exe file is desgin run in EFI bios as service driver\n");\r
- break;\r
- case IMAGE_SUBSYSTEM_EFI_ROM:\r
- fprintf(outfp,"; OS type : IMAGE_SUBSYSTEM_EFI_ROM\n");\r
- printf("This exe file is EFI ROM\n");\r
- break;\r
- case IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:\r
- fprintf(outfp,"; OS type : IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER\n");\r
- printf("This exe file is desgin run in EFI bios as driver\n");\r
- break;\r
- case IMAGE_SUBSYSTEM_NATIVE:\r
- fprintf(outfp,"; OS type : IMAGE_SUBSYSTEM_NATIVE\n");\r
- printf("This exe file does not need any subsystem\n");\r
- break;\r
- case IMAGE_SUBSYSTEM_NATIVE_WINDOWS:\r
- fprintf(outfp,"; OS type : IMAGE_SUBSYSTEM_NATIVE_WINDOWS\n");\r
- printf("This exe file is desgin run on Windows 9x as driver \n");\r
- break;\r
- case IMAGE_SUBSYSTEM_OS2_CUI:\r
- fprintf(outfp,"; OS type : IMAGE_SUBSYSTEM_OS2_CUI\n");\r
- printf("This exe file is desgin run on OS2 as CUI\n");\r
- break;\r
- case IMAGE_SUBSYSTEM_POSIX_CUI:\r
- fprintf(outfp,"; OS type : IMAGE_SUBSYSTEM_POSIX_CUI\n");\r
- printf("This exe file is desgin run on POSIX as CUI\n");\r
- break;\r
- case IMAGE_SUBSYSTEM_WINDOWS_CE_GUI:\r
- fprintf(outfp,"; OS type : IMAGE_SUBSYSTEM_WINDOWS_CE_GUI\n");\r
- printf("This exe file is desgin run on Windows CE as GUI\n");\r
- break;\r
- case IMAGE_SUBSYSTEM_WINDOWS_CUI:\r
- fprintf(outfp,"; OS type : IMAGE_SUBSYSTEM_WINDOWS_CUI\n");\r
- printf("This exe file is desgin run on Windows as CUI\n");\r
- break;\r
- case IMAGE_SUBSYSTEM_WINDOWS_GUI:\r
- fprintf(outfp,"; OS type : IMAGE_SUBSYSTEM_WINDOWS_GUI\n");\r
- printf("This exe file is desgin run on Windows as GUI\n");\r
- break;\r
- case IMAGE_SUBSYSTEM_XBOX:\r
- fprintf(outfp,"; OS type : IMAGE_SUBSYSTEM_XBOX\n");\r
- printf("This exe file is desgin run on X-Box\n");\r
- break;\r
- default:\r
- fprintf(outfp,"; OS type : Unknown\n");\r
- printf("Unknown OS : SubID : %d\n",NtHeader->OptionalHeader.Subsystem);\r
- break;\r
- }\r
-\r
-\r
- printf("Number of object : %d\n",NtHeader->FileHeader.NumberOfSections);\r
- printf("Base Address : %8x\n\n",NtHeader->OptionalHeader.ImageBase);\r
-\r
- pSectionHeader = IMAGE_FIRST_SECTION(NtHeader);\r
-\r
- NumberOfSections = NtHeader->FileHeader.NumberOfSections;\r
-\r
- for (i = 0; i < NumberOfSections; i++)\r
- {\r
- SectionHeader[i] = *pSectionHeader++;\r
- printf("Found Sector : %s \n ",SectionHeader[i].Name);\r
- printf("RVA: %08lX ",SectionHeader[i].VirtualAddress);\r
- printf("Offset: %08lX ",SectionHeader[i].PointerToRawData);\r
- printf("Size: %08lX ",SectionHeader[i].SizeOfRawData);\r
- printf("Flags: %08lX \n\n",SectionHeader[i].Characteristics);\r
- }\r
-\r
- /* Get export data */\r
- if (NtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size != 0)\r
- {\r
- for (i = 0; i < NumberOfSections; i++)\r
- {\r
- if ( SectionHeader[i].VirtualAddress <= (ULONG) NtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress &&\r
- SectionHeader[i].VirtualAddress + SectionHeader[i].SizeOfRawData > (ULONG)NtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress)\r
- {\r
- ExportEntry = (PIMAGE_NT_HEADERS) (((ULONG)memory) +\r
- (ULONG)(NtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress -\r
- SectionHeader[i].VirtualAddress +\r
- SectionHeader[i].PointerToRawData));\r
- }\r
- }\r
- }\r
-\r
-\r
-/* start decoding */\r
-\r
-for (i=0;i < NumberOfSections; i++)\r
-{\r
- if (strnicmp((PCHAR) SectionHeader[i].Name,".text\0",6)==0)\r
- {\r
- switch (NtHeader->FileHeader.Machine)\r
- {\r
- case IMAGE_FILE_MACHINE_ALPHA:\r
- printf("CPU ALPHA Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found Alpha\n");\r
- machine_type = IMAGE_FILE_MACHINE_ALPHA;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_ALPHA64:\r
- printf("CPU ALPHA64/AXP64 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found Alpha64/AXP64\n");\r
- machine_type = IMAGE_FILE_MACHINE_ALPHA64;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_AM33:\r
- printf("CPU AM33 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found AM33\n");\r
- machine_type = IMAGE_FILE_MACHINE_AM33;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_AMD64:\r
- printf("CPU AMD64 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found AMD64\n");\r
- machine_type = IMAGE_FILE_MACHINE_AMD64;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_ARM:\r
- printf("CPU ARM Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found ARM\n");\r
- machine_type = IMAGE_FILE_MACHINE_ARM;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_CEE:\r
- printf("CPU CEE Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found CEE\n");\r
- machine_type = IMAGE_FILE_MACHINE_CEE;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_CEF:\r
- printf("CPU CEF Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found CEF\n");\r
- machine_type = IMAGE_FILE_MACHINE_CEF;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_EBC:\r
- printf("CPU EBC Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found EBC\n");\r
- machine_type = IMAGE_FILE_MACHINE_EBC;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_I386:\r
- printf("CPU I386 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found I386\n");\r
- machine_type = IMAGE_FILE_MACHINE_I386;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_IA64:\r
- printf("CPU IA64 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found IA64\n");\r
- machine_type = IMAGE_FILE_MACHINE_IA64;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_M32R:\r
- printf("CPU M32R Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found M32R\n");\r
- machine_type = IMAGE_FILE_MACHINE_M32R;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_MIPS16:\r
- printf("CPU MIPS16 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found MIPS16\n");\r
- machine_type = IMAGE_FILE_MACHINE_MIPS16;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_MIPSFPU:\r
- printf("CPU MIPSFPU Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found MIPSFPU\n");\r
- machine_type = IMAGE_FILE_MACHINE_MIPSFPU;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_MIPSFPU16:\r
- printf("CPU MIPSFPU16 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found MIPSFPU16\n");\r
- machine_type = IMAGE_FILE_MACHINE_MIPSFPU16;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_POWERPC:\r
- printf("CPU POWERPC Detected partily CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found POWERPC\n");\r
- //PPCBrain(memory, pos, cpu_size, base, 0, outfp);\r
- machine_type = IMAGE_FILE_MACHINE_POWERPC;\r
- PPCBrain(memory+SectionHeader[i].PointerToRawData, 0, SectionHeader[i].SizeOfRawData, NtHeader->OptionalHeader.ImageBase, 0, outfp);\r
- break;\r
-\r
-\r
- case IMAGE_FILE_MACHINE_POWERPCFP:\r
- printf("CPU POWERPCFP Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found POWERPCFP\n");\r
- machine_type = IMAGE_FILE_MACHINE_POWERPCFP;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_R10000:\r
- printf("CPU R10000 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found R10000\n");\r
- machine_type = IMAGE_FILE_MACHINE_R10000;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_R3000:\r
- printf("CPU R3000 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found R3000\n");\r
- machine_type = IMAGE_FILE_MACHINE_R3000;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_R4000:\r
- printf("CPU R4000 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found R4000\n");\r
- machine_type = IMAGE_FILE_MACHINE_R4000;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_SH3:\r
- printf("CPU SH3 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found SH3\n");\r
- machine_type = IMAGE_FILE_MACHINE_SH3;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_SH3DSP:\r
- printf("CPU SH3DSP Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found SH3DSP\n");\r
- machine_type = IMAGE_FILE_MACHINE_SH3DSP;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_SH3E:\r
- printf("CPU SH3E Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found SH3E\n");\r
- machine_type = IMAGE_FILE_MACHINE_SH3E;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_SH4:\r
- printf("CPU SH4 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found SH4\n");\r
- machine_type = IMAGE_FILE_MACHINE_SH4;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_SH5:\r
- printf("CPU SH5 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found SH5\n");\r
- machine_type = IMAGE_FILE_MACHINE_SH5;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_THUMB:\r
- printf("CPU THUMB Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found THUMB\n");\r
- machine_type = IMAGE_FILE_MACHINE_THUMB;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_TRICORE:\r
- printf("CPU TRICORE Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found TRICORE\n");\r
- machine_type = IMAGE_FILE_MACHINE_TRICORE;\r
- return 3;\r
-\r
- case IMAGE_FILE_MACHINE_WCEMIPSV2:\r
- printf("CPU WCEMIPSV2 Detected no CPUBrain implement for it\n");\r
- fprintf(outfp,"; CPU found WCEMIPSV2\n");\r
- machine_type = IMAGE_FILE_MACHINE_WCEMIPSV2;\r
- return 3;\r
-\r
- default:\r
- printf("Unknown Machine : %d",NtHeader->FileHeader.Machine);\r
- return 4;\r
- } /* end case switch*/\r
- } /* end if text sector */\r
-} /* end for */\r
-\r
- return 0;\r
-}\r
+++ /dev/null
-
-PowerPC 32bits
-
-reg = R0-R31
-#imm = a value you set
-
-Bit expain
-0 = mean bit is zero
-1 = mean bit is set
-2 = mean this bit can be 0 or 1
-
-opcode Name Desciptions
-0010 0000 0000 0000 1000 0000 0100 1110 blr return from a functions
-
-0222 2222 2222 2222 2222 2222 0011 1000 Li reg,#imm move a value to a register
-
-2222 2222 2222 2222 2222 2222 1001 0022 stw reg,mem store a value into memory
-
-2222 2222 2222 2222 2222 2222 1001 0122 stwu reg,mem store contain of reg to memory and
- move reg to that memory position
-
-
-
-Here how the primary opcode work
-xxxx xxxx xxxx xxxx DDDS SSSS 3333 33DD
-
-
-3 = it is the primary opcode
-D = Destions register
-S = Source reigters
- opcode
- -------------------------
- |bit order: 5432 10 67 |
- ------- ------- ----------- ----
-34: | 0c 00 | | e1 93 | stw r31,12(r1) 0000 1100 0000 0000 1110 0001 | 1001 00 | 00
-38: | 14 00 | | 01 90 | stw r0,20(r1) 0001 0100 0000 0000 0000 0001 | 1001 00 | 11
- ------- ------- ---------
- | |
- | |--> Get source register R0-R31 (0xE1 & 0x1F) = 1
- | |
- | |--> Get Dest register R0-R31 ((0xE1 & 0xE0)>>5) | ((0x90 & 0x3)<<3) = 31 or 0
- | | (The adding the two last bit on the end is maybe wrong need examine it)
- | |
- | --> Get the opcpde (0x90 & 0xFC)
- \ /
-
- The address offset 12 or 20
-
-opcode
- ---------------------------------------------------------
-|bit order: pos 1111 1111 1111 1111 0000 0000 0000 0000 |
-| 5432 10 |
-|---------------------------------------------------------|
-| bits 0000 1100 0000 0000 1110 0001 1001 0000 |
- ---------------------------------------------------------
-| math (opcode>>2) & 0x3F |
- ---------------------------------------------------------
-
-Dest Register
- ---------------------------------------------------------
-|bit order: pos 1111 1111 1111 1111 0000 0000 0000 0000 |
-| 210 43 |
-|---------------------------------------------------------|
-| bits 0000 1100 0000 0000 1110 0001 1001 0000 |
- ---------------------------------------------------------
-| math (((opcode & 0x3) << 3) | ((opcode & 0xE000) >> 13))|
- ---------------------------------------------------------
-
-source Register
- ---------------------------------------------------------
-|bit order: pos 1111 1111 1111 1111 0000 0000 0000 0000 |
-| x xxxx |
-|---------------------------------------------------------|
-| bits 0000 1100 0000 0000 1110 0001 1001 0000 |
- ---------------------------------------------------------
-| math |
- ---------------------------------------------------------
+++ /dev/null
-CpuToIntel is a experment tools and is strict under havy devloping\r
-\r
-\r
-The Idea\r
-The idea is to converting binary files or win pe files \r
-from one cpu to another cpu, But it does not exists\r
-plan to port over diffent hardware architect like\r
-how diffent hw comucate, example x86 DMA controller\r
-to PPC like that stuff. It is only to convert the \r
-binary or pe files to another cpu. it mean a user \r
-mode apps will always be ported, but if it self \r
-modify code it will not work. But it exists idea how \r
-to deal with self modify code. \r
-\r
-\r
-The idea to handling self modify code\r
-The idea is to add a small emulator or adding \r
-anaylysing process to dectect self modify code \r
-and extract it. This is very hard part todo, some say\r
-imposible, some other say almost imposble. and I say\r
-it is posible todo but extream hard todo. for it is\r
-very diffcul to dectect self modify code with a\r
-analysing process.\r
-\r
-\r
-Why the name are CpuToIntel\r
-When I start write on it it was only ment to convert \r
-from ARM, PPC, m68k to X86 but then I come think of\r
-ReactOS PPC port that is going on. for or later we\r
-will need something that doing convert from x86 to\r
-PPC apps. It exists two way todo it. One is to use \r
-dymatic translation a jit, like UAE or QEMU doing \r
-converting. But it will lose of allot of speed if\r
-it is a game or a havy apps to much. So the idea\r
-is to convert the whole file in one sweep. will give\r
- one other problem it will be a slow process todo it,\r
-and hard dectect self modify program. so not all program\r
-can be really convert with this process. \r
-\r
-\r
-Who will it work \r
-we take it step for step and I will describe the \r
-binary translations how it works. The PE file\r
-work simluare way. \r
-\r
-step 1 : it will disambler the program frist \r
-\r
-step 2 : translate everthing to a middle asm dialect,\r
- it is own asm dialect it is not suite for a real\r
-\r
-step 3 : (not implement) send it to ananalysing processs \r
- to get any name or mark out which row is a new functions\r
-\r
-step 3.5 (not implement) split the code into functions here\r
-\r
-step 4 : Now it start the convert process. \r
-\r
-step 4.5 (not implement) maybe a optimzer. \r
- \r
-step 5 : now it is finish. \r
-\r
-\r
-The arch that are plan \r
-PPC to IA32, PPC (work in progress)\r
-m68k to IA32, PPC (stubed)\r
-ARM to IA32, PPC (stubed)\r
-IA32 to IA32, PPC (work in progress)\r
-\r
-\r
-The Winodws NT PPC and x85 diffrent \r
-R1 The stack pointer equal with x86 esp\r
-R3 The return reg equal with x86 eax\r
-R4 The return reg equal with x86 edx\r
-R31 The base pointer equal with x86 ebp\r
- \r
-
\ No newline at end of file
+++ /dev/null
-
-#ifndef __ANY_OP_H__
-#define __ANY_OP_H__
-
-#define OP_ANY_mov 0x00000000
-#define OP_ANY_ret 0x00000001
-
-/* We are using same abi as PPC
- * eax = register 3
- * edx = register 4
- * esp = register 1
- * ebp = register 31
-
- * ecx = 8
- * ebx = 9
- * esi = 10
- * edi = 11
- * mmx/sse/fpu 0 = 12
- * mmx/sse/fpu 1 = 14
- * mmx/sse/fpu 2 = 16
- * mmx/sse/fpu 3 = 18
- * mmx/sse/fpu 4 = 20
- * mmx/sse/fpu 5 = 22
- * mmx/sse/fpu 6 = 24
- * mmx/sse/fpu 7 = 28
- */
-
-typedef struct _BrainAnalys
-{
- CPU_UNINT op; /* one tranlator for any cpu type set our own opcode */
- CPU_INT type; /* 1 = source are memmory, 2 source are register */
- /* 4 = dest are memmory, 8 dest are register */
- /* 16 = source are imm */
- /* 32 = soucre -xx(r1) or [eax-xx] */
- /* 64 = dest -xx(r1) or [eax-xx] */
- /* 128 = update form the src be update with dest */
-
- CPU_INT src_size; /* who many bits are src not vaild for reg*/
- CPU_INT dst_size; /* who many bits are dst not vaild for reg*/
-
- CPU_UNINT64 src;
- CPU_UNINT64 dst;
-
- CPU_INT src_extra; /* if type == 32 are set */
- CPU_INT dst_extra; /* if type == 32 are set */
-
- CPU_UNINT memAdr; /* where are we in the current memory pos + baseaddress */
-
- CPU_INT row; /* 0 = no row,
- * 1 = row is bcc (conditions),
- * 2 = row is jsr (Call)
- */
-
- /* try translate the Adress to a name */
- CPU_BYTE* ptr_next; /* hook next one */
- CPU_BYTE* ptr_prev; /* hook previus one */
-} MYBrainAnalys, *PMYBrainAnalys;
-
-extern PMYBrainAnalys pMyBrainAnalys; /* current working address */
-extern PMYBrainAnalys pStartMyBrainAnalys; /* start address */
-
-CPU_INT ConvertToIA32Process( FILE *outfp,
- PMYBrainAnalys pMystart,
- PMYBrainAnalys pMyend, CPU_INT regbits,
- CPU_INT HowManyRegInUse,
- CPU_INT *RegTableCount);
-
-CPU_INT ConvertToPPCProcess( FILE *outfp,
- PMYBrainAnalys pMystart,
- PMYBrainAnalys pMyend, CPU_INT regbits,
- CPU_INT HowManyRegInUse,
- CPU_INT *RegTableCount);
-
-#endif
+++ /dev/null
-<module name="cputointel" type="win32cui" installbase="system32" installname="cputointel.exe" stdlib="host">
- <include base="cputointel">.</include>
- <library>kernel32</library>
- <library>user32</library>
-
- <file>CpuToIntel.c</file>
- <file>misc.c</file>
-
- <file>From/ARM/ARMBrain.c</file>
- <file>From/ARM/ARMopcode.c</file>
-
- <file>From/IA32/IA32Brain.c</file>
- <file>From/IA32/IA32opcode.c</file>
-
- <file>From/m68k/M68kBrain.c</file>
- <file>From/m68k/M68kopcode.c</file>
-
- <file>From/PPC/PPCBrain.c</file>
- <file>From/PPC/PPCopcode.c</file>
-
- <file>From/dummycpu/DummyBrain.c</file>
- <file>From/dummycpu/Dummyopcode.c</file>
-
- <file>ImageLoader.c</file>
- <file>AnyalsingProcess.c</file>
- <file>ConvertingProcess.c</file>
- <file>ConvertToIA32Process.c</file>
- <file>ConvertToPPCProcess.c</file>
-
-
-</module>
\ No newline at end of file
+++ /dev/null
-
-/* only for getting the pe struct */
-#include <windows.h>
-#include <winnt.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "misc.h"
-#include "any_op.h"
-#include "From/ARM/ARM.h"
-#include "From/m68k/m68k.h"
-#include "From/PPC/PPC.h"
-
-
-/* retun
- * 0 = Ok
- * 1 = unimplemt
- * 2 = Unkonwn Opcode
- * 3 = can not open read file
- * 4 = can not open write file
- * 5 = can not seek to end of read file
- * 6 = can not get the file size of the read file
- * 7 = read file size is Zero
- * 8 = can not alloc memory
- * 9 = can not read file
- *-------------------------
- * type 0 : auto
- * type 1 : bin
- * type 2 : exe/dll/sys
- */
-
-
-
-/* Conveting bit array to a int byte */
-CPU_UNINT ConvertBitToByte(CPU_BYTE *bit)
-{
- CPU_UNINT Byte = 0;
- CPU_INT t;
- CPU_UNINT size = 15;
-
- for(t=size;t>=0;t--)
- {
- if (bit[size-t] != 2)
- Byte = Byte + (bit[size-t]<<t);
- }
- return Byte;
-}
-
-/* Conveting bit array mask to a int byte mask */
-CPU_UNINT GetMaskByte(CPU_BYTE *bit)
-{
- CPU_UNINT MaskByte = 0;
- CPU_INT t;
- CPU_UNINT size = 15;
-
- for(t=size;t>=0;t--)
- {
- if (bit[size-t] == 2)
- {
- MaskByte = MaskByte + ( (bit[size-t]-1) <<t);
- }
- }
- return MaskByte;
-}
-
-/* Conveting bit array to a int byte */
-CPU_UNINT ConvertBitToByte32(CPU_BYTE *bit)
-{
- CPU_UNINT Byte = 0;
- CPU_INT t;
- CPU_UNINT size = 31;
-
- for(t=size;t>=0;t--)
- {
- if (bit[size-t] != 2)
- Byte = Byte + (bit[size-t]<<t);
- }
- return Byte;
-}
-
-/* Conveting bit array mask to a int byte mask */
-CPU_UNINT GetMaskByte32(CPU_BYTE *bit)
-{
- CPU_UNINT MaskByte = 0;
- CPU_INT t;
- CPU_UNINT size = 31;
-
- for(t=size;t>=0;t--)
- {
- if (bit[size-t] == 2)
- {
- MaskByte = MaskByte + ( (bit[size-t]-1) <<t);
- }
- }
- return MaskByte;
-}
-
-
-
-CPU_UNINT GetData32Le(CPU_BYTE *cpu_buffer)
-{
- CPU_UNINT cpuint;
- CPU_UNINT split1;
- CPU_UNINT split2;
- CPU_UNINT split3;
- CPU_UNINT split4;
-
- cpuint = *((CPU_UNINT*) &cpu_buffer[0]);
-
- split1 = cpu_buffer[0];
- split2 = cpu_buffer[1];
- split3 = cpu_buffer[2];
- split4 = cpu_buffer[3];
-
-
- cpuint = split4+(split3 <<8 )+(split2 <<16 )+(split1 <<24 );
-
- return cpuint;
-}
-
-CPU_UNINT GetData32Be(CPU_BYTE *cpu_buffer)
-{
- CPU_UNINT cpuint;
-
- cpuint = *((CPU_UNINT*) &cpu_buffer[0]);
-
- return cpuint;
-}
-
-
-CPU_INT AllocAny()
-{
-
- if (pMyBrainAnalys== NULL)
- {
- pMyBrainAnalys = (PMYBrainAnalys) malloc(sizeof(MYBrainAnalys));
- if (pMyBrainAnalys==NULL)
- {
- return -1;
- }
- ZeroMemory(pMyBrainAnalys,sizeof(MYBrainAnalys));
- pStartMyBrainAnalys = pMyBrainAnalys;
- }
- else
- {
- PMYBrainAnalys tmp;
- tmp = (PMYBrainAnalys) malloc(sizeof(MYBrainAnalys));
- if (tmp==NULL)
- {
- return -1;
- }
- ZeroMemory(tmp,sizeof(MYBrainAnalys));
-
- pMyBrainAnalys->ptr_next = (CPU_BYTE*)tmp;
- tmp->ptr_prev= (CPU_BYTE*)pMyBrainAnalys;
-
- pMyBrainAnalys = tmp;
- }
-return 0;
-}
-
-CPU_INT FreeAny()
-{
- PMYBrainAnalys tmp = NULL;
-
- if (pMyBrainAnalys == NULL)
- {
- return -1;
- }
-
- tmp = (PMYBrainAnalys)pMyBrainAnalys->ptr_prev;
-
- while (pMyBrainAnalys != NULL)
- {
- if (pMyBrainAnalys == NULL)
- {
- break;
- }
-
- free(pMyBrainAnalys);
-
- if (pMyBrainAnalys != NULL)
- {
- printf("fail to free memory");
- return -1;
- }
-
- pMyBrainAnalys = tmp;
- }
-
- return 0;
-}
-
-
-
-
-
-
+++ /dev/null
-
-
-/* 64bits unsigned */
-#define CPU_UNINT64 unsigned long long
-
-/* 32bits */
-#define CPU_UNINT unsigned int
-#define CPU_INT int
-
-/* 16 bits signed */
-#define CPU_SHORT short
-
-/* 8bits unsigned */
-#define CPU_BYTE unsigned char
-
-/* Prototypes for misc stuff */
-CPU_INT LoadPFileImage(char *infileName, char *outputfileName, CPU_UNINT BaseAddress, char *cpuid, CPU_UNINT type, CPU_INT mode);
-CPU_INT PEFileStart( CPU_BYTE *memory, CPU_UNINT pos, CPU_UNINT base, CPU_UNINT size, FILE *outfp, CPU_INT mode);
-
-CPU_UNINT ConvertBitToByte(CPU_BYTE *bit);
-CPU_UNINT GetMaskByte(CPU_BYTE *bit);
-
-CPU_UNINT ConvertBitToByte32(CPU_BYTE *bit);
-CPU_UNINT GetMaskByte32(CPU_BYTE *bit);
-
-CPU_UNINT GetData32Le(CPU_BYTE *cpu_buffer);
-CPU_UNINT GetData32Be(CPU_BYTE *cpu_buffer);
-
-CPU_INT AllocAny();
-CPU_INT FreeAny();
-CPU_INT AnyalsingProcess();
-
-CPU_INT ConvertProcess(FILE *outfp, CPU_INT FromCpuid, CPU_INT ToCpuid);
-
-
<xi:include href="genguid/genguid.rbuild" />
</directory>
- <directory name="roswebparser">
- <xi:include href="roswebparser/roswebparser.rbuild" />
- </directory>
-
<directory name="syscalldump">
<xi:include href="syscalldump/syscalldump.rbuild" />
</directory>
<directory name="vgafontedit">
<xi:include href="vgafontedit/vgafontedit.rbuild" />
</directory>
-
- <directory name="zoomin">
- <xi:include href="zoomin/zoomin.rbuild" />
- </directory>
</group>
+++ /dev/null
-/*
- * Windows OEM 457 code page table. need by english rc files, area 0x80 to 0x9f should be blank
- */
-
-unsigned short table_Windows28591[256] =
-{
- 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009,
- 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, 0x0010, 0x0011, 0x0012, 0x0013,
- 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D,
- 0x001E, 0x001F, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
- 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, 0x0030, 0x0031,
- 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B,
- 0x003C, 0x003D, 0x003E, 0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045,
- 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
- 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059,
- 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, 0x0060, 0x0061, 0x0062, 0x0063,
- 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D,
- 0x006E, 0x006F, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
- 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F, 0x0080, 0x0081,
- 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B,
- 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095,
- 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
- 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9,
- 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3,
- 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD,
- 0x00BE, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
- 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x00D0, 0x00D1,
- 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9, 0x00DA, 0x00DB,
- 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5,
- 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
- 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9,
- 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF};
+++ /dev/null
-/*
- * Windows OEM 457 code page table. need by english rc files, area 0x80 to 0x9f should be blank
- */
-
-unsigned short table_Windows28592[256] =
-{
- 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009,
- 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, 0x0010, 0x0011, 0x0012, 0x0013,
- 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D,
- 0x001E, 0x001F, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
- 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, 0x0030, 0x0031,
- 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B,
- 0x003C, 0x003D, 0x003E, 0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045,
- 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
- 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059,
- 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, 0x0060, 0x0061, 0x0062, 0x0063,
- 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D,
- 0x006E, 0x006F, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
- 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F, 0x0080, 0x0081,
- 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B,
- 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095,
- 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
- 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7, 0x00A8, 0x0160,
- 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B, 0x00B0, 0x0105, 0x02DB, 0x0142,
- 0x00B4, 0x013E, 0x015B, 0x02C7, 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD,
- 0x017E, 0x017C, 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
- 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, 0x0110, 0x0143,
- 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, 0x0158, 0x016E, 0x00DA, 0x0170,
- 0x00DC, 0x00DD, 0x0162, 0x00DF, 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A,
- 0x0107, 0x00E7, 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
- 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, 0x0159, 0x016F,
- 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9};
-
+++ /dev/null
-/*
- * Windows OEM 457 code page table. need by english rc files
- */
-
-unsigned short table_OEM437[256] =
-{
- 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009,
- 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, 0x0010, 0x0011, 0x0012, 0x0013,
- 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D,
- 0x001E, 0x001F, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
- 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, 0x0030, 0x0031,
- 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B,
- 0x003C, 0x003D, 0x003E, 0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045,
- 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
- 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059,
- 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, 0x0060, 0x0061, 0x0062, 0x0063,
- 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D,
- 0x006E, 0x006F, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
- 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F, 0x00C7, 0x00FC,
- 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF,
- 0x00EE, 0x00EC, 0x00C4, 0x00C5, 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2,
- 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
- 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310,
- 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, 0x2591, 0x2592, 0x2593, 0x2502,
- 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C,
- 0x255B, 0x2510, 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
- 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, 0x2568, 0x2564,
- 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588,
- 0x2584, 0x258C, 0x2590, 0x2580, 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3,
- 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
- 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219,
- 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0};
-
-
-
+++ /dev/null
-/*
- * Windows OEM 850 code page table. need by english rc files
- */
-
-unsigned short table_OEM850[256] =
-{
- 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009,
- 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, 0x0010, 0x0011, 0x0012, 0x0013,
- 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D,
- 0x001E, 0x001F, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
- 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, 0x0030, 0x0031,
- 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B,
- 0x003C, 0x003D, 0x003E, 0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045,
- 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
- 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059,
- 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, 0x0060, 0x0061, 0x0062, 0x0063,
- 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D,
- 0x006E, 0x006F, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
- 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F, 0x00C7, 0x00FC,
- 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF,
- 0x00EE, 0x00EC, 0x00C4, 0x00C5, 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2,
- 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
- 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE,
- 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, 0x2591, 0x2592, 0x2593, 0x2502,
- 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2,
- 0x00A5, 0x2510, 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
- 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, 0x00F0, 0x00D0,
- 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588,
- 0x2584, 0x00A6, 0x00CC, 0x2580, 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5,
- 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
- 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8,
- 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0};
+++ /dev/null
-/*
- * This is a standalone rc langues to xml parser
- * do not use windows or linux specfiy syntax or functions
- * use only pure ansi C, this program is also runing on
- * linux apachie webserver and being use in ReactOS website
- *
- * CopyRight 20/9-2006 by Magnus Olsen (magnus@greatlord.com)
- * Licen GPL version 2.0
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#define true 1
-#define false 0
-
-
-int ansiCodePage(int codepage, unsigned char *inBuffer, unsigned char *outBuffer, int Lenght);
-
-int paraser1(unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format, unsigned char *iso_type);
-
-void find_str(unsigned char asc, unsigned char *buf, long *foundPos);
-void find_str2(unsigned char *asc, unsigned char *buf, long *foundPos, unsigned char * output_resid, unsigned char *output_text );
-void trim(unsigned char* buf);
-void stringbugs(unsigned char *buf, int shift2);
-void stringbugs2(unsigned char *buf, int shift2);
-
-void ParserCMD1(unsigned char *text, unsigned char *output_resid, unsigned char *output_text, unsigned char *output_format);
-void ParserCMD2(unsigned char *text, unsigned char *output_resid, unsigned char *output_text, unsigned char *output_format);
-void ParserCMD3(unsigned char *text, unsigned char *output_resid, unsigned char *output_text, unsigned char *output_format);
-
-void ParserComment(long *pos, unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format);
-void ParserLang(unsigned char *text, unsigned char *output_resid, unsigned char *output_text, unsigned char *output_format);
-void ParserString(long *pos, unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format);
-void ParserDialog(unsigned char *text, long *pos, unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format);
-void DialogCMDBuild1(unsigned char *output_resid, unsigned char *output_format, long pos, unsigned char * text);
-void DialogCMDBuild2(unsigned char *output_resid, unsigned char *output_format, long pos, unsigned char * text);
-void DialogCMDBuild3(unsigned char *output_resid, unsigned char *output_format, long pos, unsigned char * text);
-void ParserAccelerators(long *pos, unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format);
-void ParserMenu(unsigned char *text, long *pos, unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format);
-
-/*
- return -1 : No file found
- return -2 : Fail open file
- return -3 : Fail seek
- return -4 : Fail get size
- return -5 : Fail size of the file is 0 bytes
- return -6 : Fail malloc memory
- return -7 : Fail to read the file
- return -8 : Fail to write to the file
- return -9 : Fail to open write file
-*/
-
-int main(int argc, char * argv[])
-{
- FILE * fp;
- FILE * Outfp;
- unsigned char * buffer;
- unsigned char * output_text;
- unsigned char * output_resid;
- unsigned char * output_format;
-
- long buf_size;
- long buf_size_calc = 0;
-
- if (argc!=4)
- {
- printf("Help\n");
- printf("%s inputfile iso-type\n\n",argv[0]);
- printf("example %s sv.rc 28591 sv.xml\n\n",argv[0]);
- printf("Contry table\n");
- printf("se (Swedish = Windows-28591 (Latin1 ISO-8859-1)\n");
-
- return -1;
- }
-
-
- if ((fp = fopen(argv[1],"rb"))==NULL)
- {
- printf("Fail open file %s by %s\n",argv[1],argv[0]);
- return -2;
- }
-
-
-
- fseek(fp,0,SEEK_END);
- if (ferror(fp) !=0)
- {
- fclose(fp);
- printf("Fail seek\n");
- return -3;
- }
- buf_size = ftell(fp);
- if (ferror(fp) !=0)
- {
- fclose(fp);
- printf("Fail get size\n");
- return -4;
- }
-
-
- /*
- We make sure it is least 4 times + 2K biger
- for we can grow around 2-3 times biger
- so it better to make safe assume how
- much memory we need
- */
-
- buf_size_calc = (buf_size*4) + 2048;
-
- fseek(fp,0,SEEK_SET);
- if (ferror(fp) !=0)
- {
- fclose(fp);
- printf("Fail seek\n");
- return -3;
- }
-
- if (buf_size==0)
- {
- fclose(fp);
- printf("Fail size of the file is 0 bytes\n");
- return -5;
- }
-
- buffer =(char *)malloc(buf_size_calc);
- if (buffer == NULL)
- {
- fclose(fp);
- printf("Fail malloc memory\n");
- return -6;
- }
-
- output_text =(char *)malloc(buf_size_calc);
- if (output_text == NULL)
- {
- free(buffer);
- fclose(fp);
- printf("Fail malloc memory\n");
- return -6;
- }
-
- output_resid =(char *)malloc(buf_size_calc);
- if (output_resid == NULL)
- {
- free(buffer);
- free(output_text);
- fclose(fp);
- printf("Fail malloc memory\n");
- return -6;
- }
-
- output_format =(char *)malloc(buf_size_calc);
- if (output_format == NULL)
- {
- free(buffer);
- free(output_text);
- free(output_resid);
- fclose(fp);
- printf("Fail malloc memory\n");
- return -6;
- }
-
- //fread(buffer,1,buf_size,fp);
- fread(buffer,buf_size,1,fp);
- if (ferror(fp) !=0)
- {
- fclose(fp);
- printf("Fail to read the file\n");
- return -7;
- }
- fclose(fp);
-
- /* Now we can write our parser */
-
- paraser1(buffer, buf_size, output_text, output_resid, output_format,"UTF-8");
- // printf ("%s",output_format);
-
- /* Now we convert to utf-8 */
- memset(output_resid,0,buf_size_calc);
- buf_size_calc = ansiCodePage(atoi(argv[2]), output_format, output_resid, strlen(output_format));
-
- if ((Outfp = fopen(argv[3],"wb")) != NULL )
- {
- fwrite(output_resid,1,buf_size_calc,Outfp);
- fclose(Outfp);
- }
-
-
-
-
- if(buffer!=NULL)
- free(buffer);
- if(output_text!=NULL)
- free(output_text);
- if(output_resid!=NULL)
- free(output_resid);
- if(output_format!=NULL)
- free(output_format);
-
-
- return 0;
-}
-
-int paraser1(unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format, unsigned char *iso_type)
-{
- unsigned char *row;
- long foundPos=0;
- long foundNextPos=0;
- long row_size=0;
- long pos=0;
-
- memset(output_text,0,buf_size);
- memset(output_resid,0,buf_size);
- memset(output_format,0,buf_size);
-
- sprintf(output_format,"<?xml version=\"1.0\" encoding=\"%s\"?>\n<resource>\n",iso_type);
-
- row = output_text;
- while(pos < buf_size)
- {
- foundPos=0;
- foundNextPos=0;
- row_size=0;
-
- /* create a row string so we can easy scan it */
- find_str('\n',&buf[pos],&foundPos);
-
- if (foundPos !=0)
- {
- row_size = foundPos - 1;
-
- /* found a new row */
- strncpy(row, &buf[pos], row_size);
- pos+=foundPos;
- if (foundPos >=2)
- row[row_size -1]=0;
-
- }
- else
- {
- row_size = buf_size - pos;
-
- /* no new row found in the buffer */
- strncpy(row, &buf[pos], buf_size - pos);
- pos= buf_size;
- }
-
- trim(row);
- foundPos=0;
-
- /* Detect Basic command and send it to own paraser */
- if (*row==0)
- continue;
-
- if (strncmp("/*",row,2)==0)
- {
- ParserComment(&pos, buf, buf_size, output_text, output_resid, output_format);
- continue;
- }
-
- if (strncmp("//",row,2)==0)
- {
- ParserComment(&pos, buf, buf_size, output_text, output_resid, output_format);
- continue;
- }
- if (strncmp("#",row,1)==0)
- {
- ParserComment(&pos, buf, buf_size, output_text, output_resid, output_format);
- continue;
- }
-
- stringbugs(row,true);
-
- if (foundPos == 0)
- {
- find_str2 ("LANGUAGE ",row,&foundPos,output_resid,output_text);
- if (foundPos != 0)
- {
- ParserLang("LANGUAGE", output_resid, output_text, output_format);
- continue;
- }
- }
-
- if (foundPos == 0)
- {
- find_str2 ("STRINGTABLE ",row,&foundPos,output_resid,output_text);
- if (foundPos != 0)
- {
- ParserCMD3("STRINGTABLE", output_resid, output_text, output_format);
- ParserString(&pos, buf, buf_size, output_text, output_resid, output_format);
- continue;
- }
- }
-
- if (foundPos == 0)
- {
- find_str2 (" DIALOGEX ",row,&foundPos,output_resid,output_text);
- if (foundPos != 0)
- {
- ParserCMD2("DIALOGEX", output_resid, output_text, output_format);
- ParserDialog("DIALOGEX",&pos, buf, buf_size, output_text, output_resid, output_format);
- continue;
- }
- }
-
- if (foundPos == 0)
- {
- find_str2 (" DIALOG ",row,&foundPos,output_resid,output_text);
- if (foundPos != 0)
- {
- ParserCMD2("DIALOG", output_resid, output_text, output_format);
- ParserDialog("DIALOG",&pos, buf, buf_size, output_text, output_resid, output_format);
- continue;
- }
- }
-
- if (foundPos == 0)
- {
- find_str2 (" ACCELERATORS\0",row,&foundPos,output_resid,output_text);
- if (foundPos != 0)
- {
- ParserCMD1("ACCELERATORS", output_resid, output_text, output_format);
- ParserAccelerators(&pos, buf, buf_size, output_text, output_resid, output_format);
- continue;
- }
- }
-
- if (foundPos == 0)
- {
- find_str2 (" MENU\0",row,&foundPos,output_resid,output_text);
- if (foundPos != 0)
- {
- ParserCMD1("MENU", output_resid, output_text, output_format);
- ParserMenu("MENU",&pos, buf, buf_size, output_text, output_resid, output_format);
- continue;
- }
- }
-
-
- } // end while
- sprintf(output_format,"%s</resource>\n",output_format);
- return false;
-}
-
-/*
- ParserCMD
- data
- input : IDM_MDIFRAME MENU DISCARDABLE LANG LANG_TAG LANG_TAG
- input : IDM_MDIFRAME MENU DISCARDABLE
- input : IDM_MDIFRAME MENU
- input : IDM_MDIFRAME ACCELERATORS DISCARDABLE LANG LANG_TAG LANG_TAG
- input : IDM_MDIFRAME ACCELERATORS DISCARDABLE
- input : IDM_MDIFRAME ACCELERATORS
-
-
- output : <obj type="MENU" rc_name="ID">DISCARDABLE</obj>
- output : <obj type="MENU" rc_name="ID">DISCARDABLE</obj>
- output : <obj type="MENU" rc_name="ID"></obj>
- output : <obj type="ACCELERATORS" rc_name="ID">DISCARDABLE</obj>
- output : <obj type="ACCELERATORS" rc_name="ID">DISCARDABLE</obj>
- output : <obj type="ACCELERATORS" rc_name="ID"></obj>
-
- param : output_resid = rc_name ID
- param : output_text = MENU DISCARDABLE LANG LANG_TAG LANG_TAG
- param : text = type example MENU
- param : output_format = xml data store buffer
-*/
-
-void ParserCMD1(unsigned char *text, unsigned char *output_resid, unsigned char *output_text, unsigned char *output_format)
-{
- long le;
-
- stringbugs(output_resid,false);
- stringbugs(output_text,false);
-
- le = strlen(text);
-
- if (strlen(output_text) == le)
- {
- sprintf(output_format,"%s<group name=\"%s\">\n <obj type=\"%s\" rc_name=\"%s\"></obj>\n",output_format,text,text,output_resid);
- }
- else if (output_text[le]==' ')
- {
- sprintf(output_format,"%s<group name=\"%s\">\n <obj type=\"%s\" rc_name=\"%s\">DISCARDABLE</obj>\n",output_format,text,text,output_resid);
- }
-
-}
-
-/*
- ParserCMD2
- data
- input : IDM_MDIFRAME DIALOG DISCARDABLE 15, 13, 210, 63 LANG LANG_TAG LANG_TAG
- input : IDM_MDIFRAME DIALOG DISCARDABLE 15, 13, 210, 63
- input : IDM_MDIFRAME DIALOGEX DISCARDABLE 15, 13, 210, 63 LANG LANG_TAG LANG_TAG
- input : IDM_MDIFRAME DIALOGEX DISCARDABLE 15, 13, 210, 63
-
-
- output : <obj type="DIALOG" rc_name="ID" top="15" left="13" right="210" bottom="63">DISCARDABLE</obj>
- output : <obj type="DIALOG" rc_name="ID" top="15" left="13" right="210" bottom="63"></obj>
- output : <obj type="DIALOGEX" rc_name="ID" top="15" left="13" right="210" bottom="63">DISCARDABLE</obj>
- output : <obj type="DIALOGEX" rc_name="ID" top="15" left="13" right="210" bottom="63"></obj>
-
-
- param : output_resid = rc_name ID
- param : output_text = DIALOG DISCARDABLE 15, 13, 210, 63 LANG LANG_TAG LANG_TAG
- param : text = type example DIALOG
- param : output_format = xml data store buffer
-
-*/
-
-void ParserCMD2(unsigned char *text, unsigned char *output_resid, unsigned char *output_text, unsigned char *output_format)
-{
- long le;
- long flag = 0;
-
- stringbugs(output_resid,false);
- stringbugs(output_text,false);
-
- le=strlen(text);
-
- sprintf(output_format,"%s<group name=\"%s\">\n <obj type=\"%s\" rc_name=\"%s\" ",output_format,text,text,output_resid);
-
- find_str2 (" DISCARDABLE ",output_text,&flag,output_resid,output_text);
- trim(output_resid);
- trim(output_text);
- if (flag==0)
- {
- *output_resid='\0'; /* not in use futer */
- flag=0; /* DISCARDABLE off */
- sprintf(output_text,"%s",&output_text[le]);
- trim(output_text);
- }
- else
- {
- *output_resid='\0'; /* not in use futer */
- flag=1; /* DISCARDABLE on */
- sprintf(output_text,"%s",&output_text[11]);
- trim(output_text);
- }
-
- /* data is looking like this 0 1 2 3 now */
-
- trim(output_resid);
- trim(output_text);
- find_str2 (" ",output_text,&flag,output_resid,output_text);
- trim(output_resid);
- trim(output_text);
-
- sprintf(output_format,"%sleft=\"%s\" ",output_format,output_resid);
-
- trim(output_resid);
- trim(output_text);
- find_str2 (" ",output_text,&flag,output_resid,output_text);
- trim(output_resid);
- trim(output_text);
-
- sprintf(output_format,"%stop=\"%s\" ",output_format,output_resid);
-
- trim(output_resid);
- trim(output_text);
- find_str2 (" ",output_text,&flag,output_resid,output_text);
- trim(output_resid);
- trim(output_text);
-
- if (flag==0)
- sprintf(output_format,"%swidth=\"%s\" height=\"%s\"></obj>\n",output_format,output_resid,output_text);
- else
- sprintf(output_format,"%swidth=\"%s\" height=\"%s\">DISCARDABLE</obj>\n",output_format,output_resid,output_text);
-}
-
-/*
- ParserCMD3
- data
- input : STRINGTABLE DISCARDABLE LANG LANG_TAG LANG_TAG
- input : STRINGTABLE DISCARDABLE LANG
- input : STRINGTABLE LANG LANG_TAG LANG_TAG
- input : STRINGTABLE
-
-
- output : <obj type="STRINGTABLE">DISCARDABLE</obj>
- output : <obj type="STRINGTABLE">DISCARDABLE</obj>
- output : <obj type="STRINGTABLE"></obj>
- output : <obj type="STRINGTABLE"></obj>
-
-
- param : output_resid = empty
- param : output_text = DIALOG DISCARDABLE 15, 13, 210, 63 LANG LANG_TAG LANG_TAG
- param : text = type example DIALOG
- param : output_format = xml data store buffer
-
-*/
-void ParserCMD3(unsigned char *text, unsigned char *output_resid, unsigned char *output_text, unsigned char *output_format)
-{
- long foundPos=0;
-
- stringbugs(output_resid,false);
- stringbugs(output_text,false);
-
- find_str2 (" ",output_text,&foundPos,output_resid,output_text);
- trim(output_resid);
- trim(output_text);
-
- if(strncmp("STRINGTABLE",output_text,11))
- sprintf(output_format,"%s<group name=\"%s\">\n <obj type=\"%s\">DISCARDABLE</obj>\n",output_format,output_text,output_resid);
- else
- sprintf(output_format,"%s<group name=\"%s\">\n <obj type=\"%s\"></obj>\n",output_format,output_resid,output_text);
-
-}
-/*
- ParserLang
- data
- input : LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
- input : LANGUAGE LANG_ENGLISH SUBLANG_ENGLISH_US
- output : <obj type="LANG" sublang="sub">lang</obj>
- output : <obj type="LANG" sublang="sub">lang</obj>
-
- param : output_resid = not in use
- param : output_text = LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
- param : text = type example LANGUAGE
- param : output_format = xml data store buffer
-*/
-
-void ParserLang(unsigned char *text, unsigned char *output_resid, unsigned char *output_text, unsigned char *output_format)
-{
- long foundPos=0;
-
- stringbugs(output_resid,false);
- stringbugs(output_text,false);
-
- sprintf(output_text,"%s",&output_text[strlen(text)+1]);
-
- /* split the lang into two string */
- find_str2 (" ",output_text,&foundPos,output_resid,output_text);
- trim(output_resid);
- trim(output_text);
- sprintf(output_format,"%s<group name=\"%s\">\n <obj type=\"%s\" sublang=\"%s\">%s</obj>\n</group>\n",output_format,text,text,output_text,output_resid);
-}
-
-
-/*
- ParserComment
- data
- input : / * sadasdas asdasd asdas ... * /
- output :<obj type=\"COMMENT\"><![CDATA[ sadasdas asdasd asdas ... ]]></obj>
-
- input : / * sadasdas asdasd asdas ... * /
- output :<obj type=\"COMMENT\"><![CDATA[ sadasdas asdasd asdas ... ]]></obj>
-
- input : #if x
- output :<obj type=\"COMMENT\"><![CDATA[#if x]]></obj>
-
- input : // hi
- output :<obj type=\"COMMENT\"><![CDATA[// hi]]></obj>
-
- param : pos = current buf position
- param : buf = read in buffer from file rc
- param : buf_size = buf max size
- param : output_text = using internal instead alloc more memory
- param : output_resid = using internal instead alloc more memory
- param : output_format = xml data store buffer
-*/
-
-void ParserComment(long *pos, unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format)
-{
- long foundPos=0;
- long foundNextPos=0;
- long row_size=0;
- unsigned char *row = output_text;
-
-
- row_size = strlen(row);
- if (strncmp("//",&row[0],2)==0)
- {
- sprintf(output_format,"%s<group name=\"COMMENT\">\n <obj type=\"COMMENT\"><![CDATA[%s]]></obj>\n</group>\n",output_format,row);
- return;
- }
- if (strncmp("#",&row[0],1)==0)
- {
- sprintf(output_format,"%s<group name=\"COMMENT\">\n <obj type=\"COMMENT\"><![CDATA[%s]]></obj>\n</group>\n",output_format,row);
- return;
- }
-
- for (foundNextPos=0;foundNextPos<row_size;foundNextPos++)
- {
- if (strncmp("*/",&row[foundNextPos],2)==0)
- {
- //*pos=*pos+foundNextPos+1;
- //*pos=(*pos- (row_size+foundNextPos+2))+foundNextPos+2;
- row[foundNextPos+2]='\0';
- sprintf(output_format,"%s<group name=\"COMMENT\">\n <obj type=\"COMMENT\"><![CDATA[%s]]></obj>\n</group>\n",output_format,row);
- return;
- }
-
- }
-
-
- sprintf(output_format,"%s<group name=\"COMMENT\">\n <obj type=\"COMMENT\"><![CDATA[%s\n",output_format,output_text);
-
- while(*pos < buf_size)
- {
- foundPos=0;
- row_size=0;
-
- /* create a row string so we can easy scan it */
- find_str('\n',&buf[*pos],&foundPos);
- if (foundPos !=0)
- {
- row_size = foundPos - 1;
-
- /* found a new row */
- strncpy(row, &buf[*pos], foundPos);
- *pos+=foundPos;
- if (foundPos >=2)
- {
- row[row_size -1]=0;
- }
-
- }
- else
- {
- row_size = buf_size - *pos;
-
- /* no new row found in the buffer */
- strncpy(row, &buf[*pos], buf_size - *pos);
- *pos= buf_size;
- }
-
- /* Search now after end of comment */
- row_size=strlen(row);
- for (foundNextPos=0;foundNextPos<row_size;foundNextPos++)
- {
- if (strncmp("*/",&row[foundNextPos],2)==0)
- {
- row_size=row_size - (foundNextPos+2);
- *pos-=row_size;
- row[foundNextPos+2]='\0';
- sprintf(output_format,"%s%s]]></obj>\n</group>\n",output_format,row);
- return;
- }
- }
- sprintf(output_format,"%s%s\n",output_format,row);
- }
-
-}
-
-/*
- ParserAccelerators
- data
- input : BEGIN
- input : "^A", CMD_SELECT_ALL
- input : END
-
- output : <obj type="ACCELERATORS" command="BEGIN" />
- output : <obj type="ACCELERATORS" rc_name="CMD_SEARCH"><![CDATA[^F]]></obj>
- output : <obj type="ACCELERATORS" command="END" />
-
- param : pos = current buf position
- param : buf = read in buffer from file rc
- param : buf_size = buf max size
- param : output_text = using internal instead alloc more memory
- param : output_resid = using internal instead alloc more memory
- param : output_format = xml data store buffer
-*/
-void ParserAccelerators(long *pos, unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format)
-{
- long foundPos=0;
- long foundNextPos=0;
- long row_size=0;
- char *row = output_text;
- int start=false;
- long le;
-
- while(*pos < buf_size)
- {
- foundPos=0;
- row_size=0;
-
- /* create a row string so we can easy scan it */
- find_str('\n',&buf[*pos],&foundPos);
- if (foundPos !=0)
- {
- row_size = foundPos - 1;
-
- /* found a new row */
- strncpy(row, &buf[*pos], foundPos);
- *pos+=foundPos;
- if (foundPos >=2)
- {
- row[row_size -1]=0;
- }
-
- }
- else
- {
- row_size = buf_size - *pos;
-
- /* no new row found in the buffer */
- strncpy(row, &buf[*pos], buf_size - *pos);
- *pos= buf_size;
- }
-
- stringbugs(row,true);
- if (start == false)
- {
- if ((strcmp(row,"BEGIN")==0) || (strcmp(row,"{")==0))
- {
- start=true;
- sprintf(output_format,"%s <obj type=\"ACCELERATORS\" command=\"BEGIN\" />\n",output_format);
-
- }
- continue;
- }
-
- if ((strcmp(row,"END")==0) || (strcmp(row,"}")==0))
- {
- sprintf(output_format,"%s <obj type=\"ACCELERATORS\" command=\"END\" />\n</group>\n",output_format);
-
- *output_resid = '\0';
- break;
- }
-
- foundPos=0;
- foundNextPos=0;
- find_str('"',row,&foundPos);
- find_str('"',&row[foundPos],&foundNextPos);
-
- if ((foundPos!=0) && (foundNextPos!=0))
- {
-
- sprintf(output_format,"%s <obj type=\"KEY\" rc_name=\"",output_format);
- le = strlen(output_format);
- sprintf(output_format,"%s%s",output_format,&row[foundNextPos+foundPos]);
- trim(&output_format[le]);
- row[foundNextPos+foundPos]='\0';
- row[foundPos-1]=' ';
- foundPos=0;
- find_str('"',row,&foundPos);
- if (foundPos!=0)
- {
- row[foundPos-1]=' ';
- }
-
- trim(row);
- sprintf(output_format,"%s\"><![CDATA[%s]]></obj>\n",output_format,row);
- }
- }
-}
-
-/*
- ParserString
- data
- input : BEGIN
- input : IDS_HINT_BLANK "text"
- input : END
-
- output : <obj type="STRINGTABLE" command="BEGIN" />
- output : <obj type="STRING" rc_name="rc_id">text</obj>
- output : <obj type="STRINGTABLE" command="END" />
-
- param : pos = current buf position
- param : buf = read in buffer from file rc
- param : buf_size = buf max size
- param : output_text = using internal instead alloc more memory
- param : output_resid = using internal instead alloc more memory
- param : output_format = xml data store buffer
-*/
-void ParserString(long *pos, unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format)
-{
- long foundPos=0;
- long row_size=0;
- unsigned char *row = output_text;
- int start=false;
-
- while(*pos < buf_size)
- {
- foundPos=0;
- row_size=0;
-
- /* create a row string so we can easy scan it */
- find_str('\n',&buf[*pos],&foundPos);
-
- if (foundPos !=0)
- {
- row_size = foundPos - 1;
-
- /* found a new row */
- strncpy(row, &buf[*pos], foundPos);
- *pos+=foundPos;
- if (foundPos >=2)
- {
- row[row_size -1]=0;
- }
-
- }
- else
- {
- row_size = buf_size - *pos;
-
- /* no new row found in the buffer */
- strncpy(row, &buf[*pos], buf_size - *pos);
- *pos= buf_size;
- }
-
- stringbugs(row,true);
-
-
- if (start == false)
- {
- if ((strcmp(row,"BEGIN")==0) || (strcmp(row,"{")==0))
- {
-
- start=true;
- sprintf(output_format,"%s <obj type=\"STRINGTABLE\" command=\"BEGIN\" />\n",output_format);
- }
- continue;
- }
-
- if ((strcmp(row,"END")==0) || (strcmp(row,"}")==0))
- {
- sprintf(output_format,"%s <obj type=\"STRINGTABLE\" command=\"END\" />\n</group>\n",output_format);
-
- *output_resid = '\0';
- break;
- }
-
-
-
- /* the split code here */
- foundPos=0;
- find_str2 (" ",row,&foundPos,output_resid,output_text);
-
- if (foundPos != 0)
- {
- trim(output_text);
- trim(output_resid);
-
- if (*output_resid!='\0')
- sprintf(output_format,"%s <obj type=\"STRING\" rc_name=\"%s\"><![CDATA[%s]]></obj>\n",output_format,output_resid,output_text);
- else
- sprintf(output_format,"%s <obj type=\"STRING\" rc_name=\"%s\"></obj>\n",output_format,output_resid);
- }
-
- }
-}
-
-/*
- ParserDialog
- data
-
- input : BEGIN
- output : <obj type="DIALOG" command="BEGIN" />
- output : <obj type="DIALOGEX" command="BEGIN" />
-
- input : END
- output : <obj type="END" command="BEGIN" />
- output : <obj type="END" command="BEGIN" />
-
- input : {
- output : <obj type="DIALOG" command="BEGIN" />
- output : <obj type="DIALOGEX" command="BEGIN" />
-
- input : }
- output : <obj type="END" command="BEGIN" />
- output : <obj type="END" command="BEGIN" />
-
- input : FONT 8, "MS Shell Dlg"
- output : <obj type="FONT" size="8" name="MS Shell Dlg"></obj>
-
- input : FONT 8, "MS Shell Dlg", 0, 0, 0x1
- output : <obj type="FONT" size="8" name="MS Shell Dlg">0 0 0x1</obj>
-
- input : CONTROL "",101,"Static",SS_SIMPLE | SS_NOPREFIX,3,6,150,10
- output : <obj type="CONTROL" rc_name="IDC_ICON_ALIGN_1" prop="Button" style="BS_OWNERDRAW |BS_BOTTOM | WS_TABSTOP" top="57" left="25" right="46" bottom="44"><![CDATA[left/top right]]></obj>
-
-
- Builder1
- input : DEFPUSHBUTTON "&OK",1,158,6,47,14 xx
- input : PUSHBUTTON "&Cancel",2,158,23,47,14 xx
- input : LTEXT "&Tooltip Text:",IDC_LABEL1,7,44,40,8 xx
- input : GROUPBOX "&Display Mode",IDC_LABEL4,7,96,157,28 xx
- input : ICON "",IDC_PICTURE,173,101,21,20 xx
-
- input : EDITTEXT 201,3,29,134,12,ES_AUTOHSCROLL
- input : LISTBOX IDC_LIST, 4, 16, 104, 46, WS_TABSTOP
- input : COMBOBOX ID_EOLN,54,18,156,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
-
- output : <obj type="COMBOBOX" rc_name="ID_ENCODING" top="54" left="0" right="156" bottom="80" style="CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP"></obj>
- output : <obj type="COMBOBOX" rc_name="ID_ENCODING" top="54" left="0" right="156" bottom="80"></obj>
-
- output : <obj type="GROUPBOX" rc_name="IDC_LABEL4" top="7" left="96" right="157" bottom="28" style="CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP"><![CDATA[&Display Mode]]></obj>
- output : <obj type="GROUPBOX" rc_name="IDC_LABEL4" top="7" left="96" right="157" bottom="28"><![CDATA[&Display Mode]]></obj>
-
- builder2
- input : CAPTION "Execute"
- input : EXSTYLE WS_EX_APPWINDOW
- input : STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-
- output : <obj type="STYLE">DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU</obj>
-
- param : pos = current buf position
- param : buf = read in buffer from file rc
- param : buf_size = buf max size
- param : output_text = using internal instead alloc more memory
- param : output_resid = using internal instead alloc more memory
- param : output_format = xml data store buffer
-*/
-void ParserDialog(unsigned char *text, long *pos, unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format)
-{
- long foundPos=0;
- long foundNextPos=0;
- long row_size=0;
- unsigned char *row = output_text;
- long commandfound=0;
- long le;
-
- *output_resid='\0';
- le=0;
-
- while(*pos < buf_size)
- {
- foundPos=0;
- row_size=0;
-
- /* create a row string so we can easy scan it */
- find_str('\n',&buf[*pos],&foundPos);
- if (foundPos !=0)
- {
- row_size = foundPos - 1;
-
- /* found a new row */
- strncpy(row, &buf[*pos], foundPos);
- *pos+=foundPos;
- if (foundPos >=2)
- {
- row[row_size -1]=0;
- }
-
- }
- else
- {
- row_size = buf_size - *pos;
-
- /* no new row found in the buffer */
- strncpy(row, &buf[*pos], buf_size - *pos);
- *pos= buf_size;
- }
-
- //stringbugs(row,true);
- trim(row);
-
- if ((strcmp(row,"BEGIN")==0) || (strcmp(row,"{")==0))
- commandfound=1;
- if ((strcmp(row,"END")==0) || (strcmp(row,"}")==0))
- commandfound=2;
-
- if (strncmp("STYLE ",row,6)==0)
- commandfound=3;
- if (strncmp("CAPTION ",row,8)==0)
- commandfound=3;
- if (strncmp("FONT ",row,5)==0)
- commandfound=3;
- if (strncmp("CONTROL ",row,8)==0)
- commandfound=3;
- if (strncmp("EDITTEXT ",row,9)==0)
- commandfound=3;
- if (strncmp("DEFPUSHBUTTON ",row,14)==0)
- commandfound=3;
- if (strncmp("PUSHBUTTON ",row,11)==0)
- commandfound=3;
- if (strncmp("LTEXT ",row,6)==0)
- commandfound=3;
- if (strncmp("GROUPBOX ",row,9)==0)
- commandfound=3;
- if (strncmp("ICON ",row,5)==0)
- commandfound=3;
- if (strncmp("EXSTYLE ",row,8)==0)
- commandfound=3;
- if (strncmp(row,"LISTBOX ",8)==0)
- commandfound=3;
- if (strncmp(row,"COMBOBOX ",9)==0)
- commandfound=3;
-
- if ((*output_resid!=0) && (commandfound!=0))
- {
- /* Builder 1*/
- if (strncmp(output_resid,"LTEXT ",6)==0)
- DialogCMDBuild1(output_resid, output_format, 5, "LTEXT");
- if (strncmp(output_resid,"GROUPBOX ",9)==0)
- DialogCMDBuild1(output_resid, output_format, 8, "GROUPBOX");
- if (strncmp(output_resid,"DEFPUSHBUTTON ",14)==0)
- DialogCMDBuild1(output_resid, output_format, 13, "DEFPUSHBUTTON");
- if (strncmp(output_resid,"PUSHBUTTON ",11)==0)
- DialogCMDBuild1(output_resid, output_format, 10, "PUSHBUTTON");
- if (strncmp("ICON ",output_resid,5)==0)
- DialogCMDBuild1(output_resid, output_format, 4, "ICON");
- if (strncmp("EDITTEXT ",output_resid,9)==0)
- DialogCMDBuild1(output_resid, output_format, 8, "EDITTEXT");
- if (strncmp("LISTBOX ",output_resid,8)==0)
- DialogCMDBuild1(output_resid, output_format, 7, "LISTBOX");
- if (strncmp("COMBOBOX ",output_resid,9)==0)
- DialogCMDBuild1(output_resid, output_format, 8, "COMBOBOX");
-
- /* Builder 2*/
- if (strncmp("STYLE ",output_resid,6)==0)
- DialogCMDBuild2(output_resid, output_format, 5, "STYLE");
- if (strncmp("EXSTYLE ",output_resid,8)==0)
- DialogCMDBuild2(output_resid, output_format, 7, "EXSTYLE");
- if (strncmp("CAPTION ",output_resid,8)==0)
- DialogCMDBuild2(output_resid, output_format, 7, "CAPTION");
- if (strncmp("CONTROL ",output_resid,8)==0)
- DialogCMDBuild3(output_resid, output_format, 7, "CONTROL");
-
- /* no builder */
- if (strncmp(output_resid,"FONT ",5)==0)
- {
- stringbugs(output_resid,true);
- /* FONT */
- sprintf(output_resid,"%s",&output_resid[5]);
- trim(output_resid);
- sprintf(output_format,"%s <obj type=\"FONT\" size=\"",output_format);
- le = strlen(output_format);
- sprintf(output_format,"%s%s",output_format,output_resid);
-
- foundPos=0;
- find_str('\"',output_resid,&foundPos);
- output_format[le+foundPos-1]='\0';
- trim(&output_format[le]);
- sprintf(output_format,"%s\" name=",output_format);
- le = strlen(output_format);
- sprintf(output_format,"%s%s",output_format,&output_resid[foundPos-1]);
-
- foundNextPos=0;
- find_str('\"',&output_resid[foundPos],&foundNextPos);
- output_format[le+foundPos+foundNextPos-1]='\0';
- trim(&output_format[le+foundPos]);
- if (output_resid[foundPos+foundNextPos]=='\0')
- {
- sprintf(output_format,"%s></obj>\n",output_format);
- }
- else
- {
- sprintf(output_format,"%s\">%s</obj>\n",output_format,&output_resid[foundPos]);
- }
-
- *output_resid=0;
- }
-
- *output_resid='\0';
- }
-
- if (commandfound==1)
- {
- sprintf(output_format,"%s <obj type=\"%s\" command=\"BEGIN\" />\n",output_format,text);
- }
- if (commandfound==2)
- {
- sprintf(output_format,"%s <obj type=\"%s\" command=\"END\" />\n</group>\n",output_format,text);
- break;
- }
-
- sprintf(output_resid,"%s%s",output_resid,row);
- commandfound=0;
- }
-
-}
-//////////////////////////
-/*
- ParserDialog
- data
-
- input : BEGIN
- output : <obj type="DIALOG" command="BEGIN" />
- output : <obj type="DIALOGEX" command="BEGIN" />
-
- input : END
- output : <obj type="END" command="BEGIN" />
- output : <obj type="END" command="BEGIN" />
-
- input : {
- output : <obj type="DIALOG" command="BEGIN" />
- output : <obj type="DIALOGEX" command="BEGIN" />
-
- input : }
- output : <obj type="END" command="BEGIN" />
- output : <obj type="END" command="BEGIN" />
-
- param : pos = current buf position
- param : buf = read in buffer from file rc
- param : buf_size = buf max size
- param : output_text = using internal instead alloc more memory
- param : output_resid = using internal instead alloc more memory
- param : output_format = xml data store buffer
-*/
-void ParserMenu(unsigned char *text, long *pos, unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format)
-{
- long foundPos=0;
- long foundNextPos=0;
- long row_size=0;
- unsigned char *row = output_text;
- long commandfound=0;
- long le;
- long count=0;
-
- *output_resid='\0';
- le=0;
-
- while(*pos < buf_size)
- {
- foundPos=0;
- row_size=0;
-
- /* create a row string so we can easy scan it */
- find_str('\n',&buf[*pos],&foundPos);
- if (foundPos !=0)
- {
- row_size = foundPos - 1;
-
- /* found a new row */
- strncpy(row, &buf[*pos], foundPos);
- *pos+=foundPos;
- if (foundPos >=2)
- {
- row[row_size -1]=0;
- }
-
- }
- else
- {
- row_size = buf_size - *pos;
-
- /* no new row found in the buffer */
- strncpy(row, &buf[*pos], buf_size - *pos);
- *pos= buf_size;
- }
-
- //stringbugs(row,true);
- stringbugs2(row,true);
-
- if ((strcmp(row,"BEGIN")==0) || (strcmp(row,"{")==0))
- commandfound=1;
- if ((strcmp(row,"END")==0) || (strcmp(row,"}")==0))
- commandfound=2;
-
- if (strncmp("POPUP ",row,6)==0)
- commandfound=3;
- if (strncmp("MENUITEM ",row,8)==0)
- commandfound=3;
-
-
- if ((*output_resid!=0) && (commandfound!=0))
- {
- if (strncmp(output_resid,"POPUP ",6)==0)
- {
- sprintf(output_resid,"%s",&output_resid[5]);
- trim(output_resid);
- sprintf(output_format,"%s<obj type=\"POPUP\"><![CDATA[%s]]></obj>\n",output_format,output_resid);
- *output_resid='\0';
- }
-
- if (strncmp(output_resid,"MENUITEM ",9)==0)
- {
- sprintf(output_resid,"%s",&output_resid[8]);
- trim(output_resid);
- if (strcmp(output_resid,"SEPARATOR")==0)
- {
- sprintf(output_format,"%s<obj type=\"MENUITEMSEPERATOR\"></obj>\n",output_format);
- *output_resid='\0';
- }
- else
- {
- foundPos=0;
- foundNextPos=0;
- find_str('"',output_resid,&foundPos);
- find_str('"',&output_resid[foundPos],&foundNextPos);
-
- stringbugs(&output_resid[foundPos+foundNextPos],true);
-
- if ((foundPos+foundNextPos)==0)
- {
- sprintf(output_format,"%s<obj type=\"MENUITEM\" rc_name=\"%s\"></obj>\n",output_format,&output_resid[foundPos+foundNextPos]);
- }
- else
- {
- sprintf(output_format,"%s<obj type=\"MENUITEM\" rc_name=\"%s\">",output_format,&output_resid[foundPos+foundNextPos]);
-
- output_resid[foundPos+foundNextPos]='\0';
- trim(output_resid);
-
- sprintf(output_format,"%s<![CDATA[%s]]></obj>\n",output_format,output_resid);
- }
-
-
-
- *output_resid='\0';
- }
- }
-
-
-
- *output_resid='\0';
- }
-
- if (commandfound==1)
- {
- count++;
- if (count==1)
- sprintf(output_format,"%s<obj type=\"%s\" command=\"BEGIN\" />\n",output_format,text);
- else
- sprintf(output_format,"%s<obj type=\"POPUP\" command=\"BEGIN\" />\n",output_format);
-
- *output_resid='\0';
- }
- if (commandfound==2)
- {
- count--;
- *output_resid='\0';
-
- if (count<1)
- sprintf(output_format,"%s<obj type=\"%s\" command=\"END\" />\n",output_format,text);
- else
- sprintf(output_format,"%s<obj type=\"POPUP\" command=\"END\" />\n",output_format);
-
- if (count<1)
- {
- sprintf(output_format,"%s</group>\n",output_format);
- break;
- }
- }
-
- sprintf(output_resid,"%s%s",output_resid,row);
- commandfound=0;
- }
-
-}
-
-void stringbugs(unsigned char *buf, int shift2)
-{
- long foundPos=0;
- long foundNextPos=0;
- long t=0;
-
- /* remove , */
- if (shift2== false)
- {
- for (t=0;t<strlen(buf);t++)
- {
- if (foundPos==0)
- {
- if (strncmp(",",&buf[t],1)==0)
- {
- buf[t]=' ';
- }
-
- if (strncmp("\"",&buf[t],1)==0)
- {
- buf[t]=' ';
- }
-
- if (strncmp("/*",&buf[t],2)==0)
- {
- foundPos=t;
- buf[t]=' ';
- buf[t+1]=' ';
- }
- }
- else
- {
- if (strncmp("*/",&buf[t],2)==0)
- {
- buf[t]=' ';
- buf[t+1]=' ';
- foundPos=0;
- }
- else
- {
- buf[t]=' ';
- }
- }
- }
- }
- else
- {
- /* shift */
- for (t=0;t<strlen(buf);t++)
- {
- if ((foundPos==0) && (foundNextPos==0))
- {
- if (strncmp(",",&buf[t],1)==0)
- {
- buf[t]=' ';
- }
-
- if (strncmp("\"",&buf[t],1)==0)
- {
- foundNextPos=t;
- }
-
- if (strncmp("/*",&buf[t],2)==0)
- {
- foundPos=t;
- buf[t]=' ';
- buf[t+1]=' ';
- }
- }
- else
- {
- if (foundPos!=0)
- {
- if (strncmp("*/",&buf[t],2)==0)
- {
- buf[t]=' ';
- buf[t+1]=' ';
- foundPos=0;
- }
- else
- {
- buf[t]=' ';
- }
- }
- if (foundNextPos!=0)
- {
- if (strncmp("\"",&buf[t],1)==0)
- {
- foundNextPos=0;
- }
- }
- }
- }
- }
-
- trim(buf);
- /* have remove all wrong syntax */
-}
-
-void stringbugs2(unsigned char *buf, int shift2)
-{
- long foundPos=0;
- long foundNextPos=0;
- long t=0;
-
- /* remove , */
- if (shift2== false)
- {
- for (t=0;t<strlen(buf);t++)
- {
- if (foundPos==0)
- {
-
- if (strncmp("\"",&buf[t],1)==0)
- {
- buf[t]=' ';
- }
-
- if (strncmp("/*",&buf[t],2)==0)
- {
- foundPos=t;
- buf[t]=' ';
- buf[t+1]=' ';
- }
- }
- else
- {
- if (strncmp("*/",&buf[t],2)==0)
- {
- buf[t]=' ';
- buf[t+1]=' ';
- foundPos=0;
- }
- else
- {
- buf[t]=' ';
- }
- }
- }
- }
- else
- {
- /* shift */
- for (t=0;t<strlen(buf);t++)
- {
- if ((foundPos==0) && (foundNextPos==0))
- {
-
- if (strncmp("\"",&buf[t],1)==0)
- {
- foundNextPos=t;
- }
-
- if (strncmp("/*",&buf[t],2)==0)
- {
- foundPos=t;
- buf[t]=' ';
- buf[t+1]=' ';
- }
- }
- else
- {
- if (foundPos!=0)
- {
- if (strncmp("*/",&buf[t],2)==0)
- {
- buf[t]=' ';
- buf[t+1]=' ';
- foundPos=0;
- }
- else
- {
- buf[t]=' ';
- }
- }
- if (foundNextPos!=0)
- {
- if (strncmp("\"",&buf[t],1)==0)
- {
- foundNextPos=0;
- }
- }
- }
- }
- }
-
- trim(buf);
- /* have remove all wrong syntax */
-}
-
-
-
-void trim(unsigned char* buf)
-{
- size_t le;
-
- if (buf==NULL)
- return;
- if (*buf==0)
- return;
-
- le=strlen(buf);
-
-
- while(le>0)
- {
-
- if (isspace(buf[le-1])!=0)
- {
- buf[le-1]=0;
- le=strlen(buf);
- }
- else
- {
- break;
- }
- }
-
- le=strlen(buf);
- while(le>0)
- {
- if (isspace(buf[0])!=0)
- {
- strncpy(&buf[0],&buf[1],le-1);
- buf[le-1]=0;
- le=strlen(buf);
- }
- else
- {
- break;
- }
- }
-}
-void find_str(unsigned char asc,unsigned char *buf, long *foundPos)
-{
- int t;
- size_t le;
-
- le=strlen(buf);
-
- for (t=0;t<le;t++)
- {
- if (buf[t]==asc)
- {
- *foundPos = *foundPos+t+1;
- break ;
- }
- }
-
- /* for end of line the \ is a special case */
- if ((asc == '\n') && (foundPos!=0) && (buf[t-2]=='\\'))
- {
- long extra=t+1;
-
- find_str(asc, &buf[extra], foundPos);
- }
-
-}
-
-void find_str2(unsigned char *asc, unsigned char *buf, long *foundPos,
- unsigned char * output_resid, unsigned char *output_text)
-{
- int t=0;
- size_t le;
- size_t lec;
-
- le=strlen(buf);
- lec=strlen(asc);
-
- if ((lec==0) || (le==0))
- {
- return;
- }
-
- for (t=0;t<le;t++)
- {
- if (strncmp(&buf[t],asc,lec)==0)
- {
- long softfoundPos=0;
-
- *foundPos = *foundPos+t+lec;
- softfoundPos = *foundPos;
-
- strncpy(output_resid, &buf[0], t);
- output_resid[t]=0;
-
- strncpy(output_text, &buf[t], le-t);
- output_text[ le-t ]=0;
-
- break ;
- }
- }
-}
-
-
-void DialogCMDBuild1(unsigned char *output_resid, unsigned char *output_format, long pos, unsigned char * text)
-{
-
-
- unsigned char extra[1000];
- long foundPos=0;
- long foundNextPos=0;
- long le;
- long size;
-
- stringbugs(output_resid,true);
- sprintf(output_resid,"%s",&output_resid[pos]);
- trim(output_resid);
-
- find_str('"',output_resid,&foundPos);
- find_str('"',&output_resid[foundPos],&foundNextPos);
-
- if ((foundPos!=0) && (foundPos!=0))
- {
- strcpy(extra,&output_resid[foundPos+foundNextPos]);
- trim(extra);
-
- output_resid[foundPos+foundNextPos]='\0';
- trim(output_resid);
- }
- else
- {
- strcpy(extra,output_resid);
- *output_resid='\0';
- }
- // \0
- sprintf(output_format,"%s <obj type=\"%s\" rc_name=\"%s",output_format,text,extra);
- foundPos=0;
- find_str(' ',extra,&foundPos);
- le = (strlen(output_format) - strlen(extra))+foundPos-1;
- output_format[le]='\0';
- sprintf(extra,"%s",&extra[foundPos]);
- trim(extra);
-
- /* top */
- // \0
- sprintf(output_format,"%s\" left=\"%s",output_format,extra);
- foundPos=0;
- find_str(' ',extra,&foundPos);
- le = (strlen(output_format) - strlen(extra))+foundPos-1;
- output_format[le]='\0';
- sprintf(extra,"%s",&extra[foundPos]);
- trim(extra);
-
- /* left */
- // \0
- sprintf(output_format,"%s\" top=\"%s",output_format,extra);
- foundPos=0;
- find_str(' ',extra,&foundPos);
- le = (strlen(output_format) - strlen(extra))+foundPos-1;
- output_format[le]='\0';
- sprintf(extra,"%s",&extra[foundPos]);
- trim(extra);
-
- /* right */
- // \0
- sprintf(output_format,"%s\" width=\"%s",output_format,extra);
- foundPos=0;
- find_str(' ',extra,&foundPos);
- le = (strlen(output_format) - strlen(extra))+foundPos-1;
- output_format[le]='\0';
- sprintf(extra,"%s",&extra[foundPos]);
- trim(extra);
-
- /* bottom */
- // \0
- sprintf(output_format,"%s\" height=\"%s",output_format,extra);
- foundPos=0;
- find_str(' ',extra,&foundPos);
- if (foundPos!=0)
- {
- le = (strlen(output_format) - strlen(extra))+foundPos-1;
- size = strlen(&output_format[le]);
- output_format[le]='\0';
- sprintf(extra,"%s",&output_format[le+1]);
- trim(extra);
-
- /* style */
- size = strlen(output_format) + strlen(extra) + 9;
- sprintf(output_format,"%s\" style=\"%s",output_format,extra);
- output_format[size]='\0';
- foundPos=0;
- find_str(' ',extra,&foundPos);
-
- if (*output_resid!='\0')
- {
- sprintf(output_format,"%s\"><![CDATA[%s]]></obj>\n",output_format,output_resid);
- }
- else
- {
- sprintf(output_format,"%s\"></obj>\n",output_format);
- }
- }
- else
- {
- if (*output_resid!='\0')
- sprintf(output_format,"%s\" style=\"\"><![CDATA[%s]]></obj>\n",output_format,output_resid);
- else
- sprintf(output_format,"%s\" style=\"\"></obj>\n",output_format);
- }
-
- *output_resid='\0';
-}
-
-
-void DialogCMDBuild2(unsigned char *output_resid, unsigned char *output_format, long pos, unsigned char * text)
-{
- long le;
-
- stringbugs(output_resid,true);
- sprintf(output_resid,"%s",&output_resid[pos]);
- trim(output_resid);
-
- le = strlen(output_resid);
- if (*output_resid=='"')
- *output_resid=' ';
- if (output_resid[le-1]=='"')
- output_resid[le-1]=' ';
-
- trim(output_resid);
- sprintf(output_format,"%s <obj type=\"%s\"><![CDATA[%s]]></obj>\n",output_format,text,output_resid);
- *output_resid='\0';
-}
-
-// input : CONTROL "",101,"Static",SS_SIMPLE | SS_NOPREFIX,3,6,150,10
-void DialogCMDBuild3(unsigned char *output_resid, unsigned char *output_format, long pos, unsigned char * text)
-{
- long foundPos=0;
- long foundNextPos=0;
- long le;
- long count=0;
- long save1;
- long save2;
-
- sprintf(output_resid,"%s",&output_resid[pos]);
- trim(output_resid);
-
- find_str('"',output_resid,&foundPos);
- find_str('"',&output_resid[foundPos],&foundNextPos);
-
- save1=foundPos;
- save2=foundNextPos;
-
- sprintf(output_format,"%s <obj type=\"%s\" rc_name=\"",output_format,text);
-
- le=strlen(output_format);
- count=foundNextPos+foundPos;
- if (output_resid[count]==',')
- output_resid[count]=' ';
- foundPos=0;
- find_str(',',&output_resid[count],&foundPos);
- sprintf(output_format,"%s%s\"",output_format,&output_resid[count]);
- output_format[le+foundPos]='\0';
- stringbugs(&output_format[le],false);
- count+=foundPos;
-
- /* prop */
- sprintf(output_format,"%s\" prop=\"",output_format);
- le=strlen(output_format);
- sprintf(output_format,"%s%s",output_format,&output_resid[count]);
-
- if (output_resid[count]==',')
- output_resid[count]=' ';
- foundPos=0;
- find_str(',',&output_resid[count],&foundPos);
- output_format[le+foundPos]='\0';
- stringbugs(&output_format[le],false);
- count+=foundPos;
-
- /* style */
- sprintf(output_format,"%s\" style=\"",output_format);
- le=strlen(output_format);
- sprintf(output_format,"%s%s",output_format,&output_resid[count]);
-
- if (output_resid[count]==',')
- output_resid[count]=' ';
- foundPos=0;
- find_str(',',&output_resid[count],&foundPos);
- output_format[le+foundPos]='\0';
- stringbugs(&output_format[le],false);
- count+=foundPos;
-
- /* top */
- sprintf(output_format,"%s\" left=\"",output_format);
- le=strlen(output_format);
- sprintf(output_format,"%s%s",output_format,&output_resid[count]);
-
- if (output_resid[count]==',')
- output_resid[count]=' ';
- foundPos=0;
- find_str(',',&output_resid[count],&foundPos);
- output_format[le+foundPos]='\0';
- stringbugs(&output_format[le],false);
- count+=foundPos;
-
- /* left */
- sprintf(output_format,"%s\" top=\"",output_format);
- le=strlen(output_format);
- sprintf(output_format,"%s%s",output_format,&output_resid[count]);
-
- if (output_resid[count]==',')
- output_resid[count]=' ';
- foundPos=0;
- find_str(',',&output_resid[count],&foundPos);
- output_format[le+foundPos]='\0';
- stringbugs(&output_format[le],false);
- count+=foundPos;
-
- /* right */
- sprintf(output_format,"%s\" width=\"",output_format);
- le=strlen(output_format);
- sprintf(output_format,"%s%s",output_format,&output_resid[count]);
-
- if (output_resid[count]==',')
- output_resid[count]=' ';
- foundPos=0;
- find_str(',',&output_resid[count],&foundPos);
- output_format[le+foundPos]='\0';
- stringbugs(&output_format[le],false);
- count+=foundPos;
-
- /* bottom */
- sprintf(output_format,"%s\" height=\"",output_format);
- le=strlen(output_format);
- sprintf(output_format,"%s%s",output_format,&output_resid[count]);
- stringbugs(&output_format[le],false);
-
- /* string */
- output_resid[save1+save2]='\0';
- stringbugs(output_resid,true);
-
-
- if (*output_resid!='\0')
- sprintf(output_format,"%s\"><![CDATA[%s]]></obj>\n",output_format,output_resid);
- else
- sprintf(output_format,"%s\"></obj>\n",output_format);
-
- *output_resid='\0';
-}
-
+++ /dev/null
-<module name="roswebparser" type="win32cui" installbase="system32" installname="roswebparser.exe" allowwarnings ="true">
- <include base="zoomin">.</include>
-
- <library>kernel32</library>
-
- <file>roswebparser.c</file>
- <file>utf8.c</file>
-</module>
+++ /dev/null
-
-/*
- * Convert ansi to utf-8
- * it does not support more that utf-16
- * the table we are using is base on utf-16 then we convert the table to utf-8
- *
- * All table lookup the ansi char to utf-16 then we calc the utf-8 format.
- */
-
-#include "oem437.h" /* windows oem 437 */
-#include "oem850.h" /* windows oem 850 */
-#include "Windows28591.h" /* windows 28591 aka ISO-2859-1 (Latin 1) */
-#include "Windows28592.h" /* windows 28592 aka ISO-2859-2 (Latin 2) */
-
-int ansiCodePage(int codepage, unsigned char *inBuffer, unsigned char *outBuffer, int Lenght)
-{
- int t;
- int ch;
- int pos=0;
-
- for (t=0;t<Lenght;t++)
- {
- ch=-1;
- if (codepage == 437)
- {
- ch = (int) table_OEM437[ ((unsigned char)inBuffer[t])];
- }
-
- if (codepage == 850)
- {
- ch = (int) table_OEM850[ ((unsigned char)inBuffer[t])];
- }
-
- if (codepage == 28591)
- {
- ch = (int) table_Windows28591[ ((unsigned char)inBuffer[t])];
- }
- if (codepage == 28592)
- {
- ch = (int) table_Windows28592[ ((unsigned char)inBuffer[t])];
- }
-
-
-
-
- if (ch == -1)
- {
- break;
- }
-
- if (ch <= 0x7F)
- {
- outBuffer[pos]=ch;
- pos++;
- }
- else if (ch <=0x07FF) // 1 1111 11 1111
- {
- outBuffer[pos]= 0xC0 | (0x1F & (ch >> 6)); // 110x xxxx
- outBuffer[pos+1]= 0x80 | (0x3f & ch); // 11xx xxxx
- pos+=2;
- }
-
- else if (ch <=0xFFFF) // 11 11 11 11 11 11 11 11
- {
- outBuffer[pos]= 0xC2 | (0xf & (ch >> 12)); // 1110xxxx
- outBuffer[pos+1]= 0x80 | (0x3f & (ch >> 6)); // 10xxxxxx
- outBuffer[pos+1]= 0x80 | (0x3f & ch); // 10xxxxxx
- pos+=3;
- }
-
- }
-
- return pos;
-}
-
+++ /dev/null
-/*
- * ReactOS zoomin
- *
- * framewnd.c
- *
- * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
- * Copyright (C) 2005 Martin Fuchs <martin-fuchs@gmx.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-#include <windows.h>
-#include <windowsx.h>
-#include <tchar.h>
-
-#include "main.h"
-#include "framewnd.h"
-
-extern void ExitInstance();
-
-////////////////////////////////////////////////////////////////////////////////
-// Global Variables:
-//
-
-static int s_factor = 2; // zoom factor
-
-static POINT s_srcPos = {0, 0}; // source rectangle position
-static RECT s_lastSrc = {-1,-1,-1,-1}; // last cursor position
-
-BOOL s_dragging = FALSE;
-
-
- // zoom range
-
-#define MIN_ZOOM 1
-#define MAX_ZOOM 16
-
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// FUNCTION: SetZoom()
-//
-// PURPOSE: Change zoom level
-//
-
-static void SetZoom(HWND hWnd, int factor)
-{
- TCHAR buffer[MAX_LOADSTRING];
-
- if (factor>=MIN_ZOOM && factor<=MAX_ZOOM) {
- s_factor = factor;
-
- SetScrollPos(hWnd, SB_VERT, s_factor, TRUE);
-
- wsprintf(buffer, TEXT("%s %dx"), szTitle, s_factor);
- SetWindowText(hWnd, buffer);
- }
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
-//
-// PURPOSE: Processes WM_COMMAND messages for the main frame window.
-//
-//
-
-static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch (LOWORD(wParam)) {
- // Parse the menu selections:
- case ID_EDIT_EXIT:
- DestroyWindow(hWnd);
- break;
-
- case ID_EDIT_COPY:
- case ID_EDIT_REFRESH:
- case ID_OPTIONS_REFRESH_RATE:
- case ID_HELP_ABOUT:
- // TODO:
- break;
-
- case ID_REFRESH:
- InvalidateRect(hWnd, NULL, FALSE);
- break;
-
- default:
- return FALSE;
- }
-
- return TRUE;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG)
-//
-// PURPOSE: Processes messages for the main window.
-//
-
-LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch (message) {
- case WM_CREATE:
- SetTimer(hWnd, 0, 200, NULL); // refresh display all 200 ms
- SetScrollRange(hWnd, SB_VERT, 1, MAX_ZOOM, FALSE);
- SetZoom(hWnd, s_factor);
- break;
-
- case WM_COMMAND:
- if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- break;
-
- case WM_PAINT: {
- PAINTSTRUCT ps;
- HDC hdcMem;
- RECT clnt;
- SIZE size;
-
- BeginPaint(hWnd, &ps);
- hdcMem = GetDC(GetDesktopWindow());
-
- GetClientRect(hWnd, &clnt);
- size.cx = (clnt.right + s_factor-1) / s_factor;
- size.cy = (clnt.bottom + s_factor-1) / s_factor;
-
- StretchBlt(ps.hdc, 0, 0, size.cx*s_factor, size.cy*s_factor,
- hdcMem, s_srcPos.x, s_srcPos.y, size.cx, size.cy, SRCCOPY);
-
- ReleaseDC(GetDesktopWindow(), hdcMem);
- EndPaint(hWnd, &ps);
- break;}
-
- case WM_TIMER:
- if (s_dragging && GetCapture()==hWnd) {
- RECT clnt, rect;
-
- int width = GetSystemMetrics(SM_CXSCREEN);
- int height = GetSystemMetrics(SM_CYSCREEN);
-
- GetCursorPos(&s_srcPos);
-
- GetClientRect(hWnd, &clnt);
-
- s_srcPos.x -= clnt.right / s_factor / 2;
- s_srcPos.y -= clnt.bottom / s_factor / 2;
-
- if (s_srcPos.x < 0)
- s_srcPos.x = 0;
- else if (s_srcPos.x+clnt.right/s_factor > width)
- s_srcPos.x = width - clnt.right/s_factor;
-
- if (s_srcPos.y < 0)
- s_srcPos.y = 0;
- else if (s_srcPos.y+clnt.bottom/s_factor > height)
- s_srcPos.y = height - clnt.bottom/s_factor;
-
- if (memcmp(&rect, &s_lastSrc, sizeof(RECT))) {
- HDC hdc = GetDC(0);
-
- if (s_lastSrc.bottom != -1)
- DrawFocusRect(hdc, &s_lastSrc);
-
- rect.left = s_srcPos.x - 1;
- rect.top = s_srcPos.y - 1;
- rect.right = rect.left + clnt.right/s_factor + 2;
- rect.bottom = rect.top + clnt.bottom/s_factor + 2;
- DrawFocusRect(hdc, &rect);
-
- ReleaseDC(0, hdc);
-
- s_lastSrc = rect;
- }
- }
-
- InvalidateRect(hWnd, NULL, FALSE);
- UpdateWindow(hWnd);
- break;
-
- case WM_LBUTTONDOWN:
- s_dragging = TRUE;
- SetCapture(hWnd);
- break;
-
- case WM_LBUTTONUP:
- case WM_CANCELMODE:
- if (s_dragging) {
- HDC hdc = GetDC(0);
- DrawFocusRect(hdc, &s_lastSrc);
- ReleaseDC(0, hdc);
-
- s_lastSrc.bottom = -1;
-
- s_dragging = FALSE;
- ReleaseCapture();
- }
- break;
-
- case WM_VSCROLL:
- switch(wParam) {
- case SB_LINEUP:
- case SB_PAGEUP:
- SetZoom(hWnd, s_factor-1);
- break;
-
- case SB_LINEDOWN:
- case SB_PAGEDOWN:
- SetZoom(hWnd, s_factor+1);
- break;
- }
- break;
-
- case WM_DESTROY:
- KillTimer(hWnd, 0);
- PostQuitMessage(0);
- ExitInstance();
- break;
-
- default:
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
-
- return 0;
-}
+++ /dev/null
-/*
- * ReactOS zoomin
- *
- * framewnd.h
- *
- * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef __FRAMEWND_H__
-#define __FRAMEWND_H__
-
-LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM);
-
-
-#define WNDCLASS_ZOOMIN TEXT("ZOOMIN")
-
-
-#endif // __FRAMEWND_H__
+++ /dev/null
-/* $Id: zoomin.rc 31932 2008-01-21 21:29:59Z dreimer $ */
-
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_ZOOMIN ICON DISCARDABLE "zoomin.ico"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Menu
-//
-
-IDR_ZOOMIN_MENU MENU DISCARDABLE
-BEGIN
- POPUP "&File"
- BEGIN
- MENUITEM "E&xit\tAlt-F4", ID_EDIT_EXIT
- END
- POPUP "&Edit"
- BEGIN
- MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY, GRAYED
- MENUITEM "&Refresh\tF5", ID_EDIT_REFRESH
- END
- POPUP "&Options"
- BEGIN
- MENUITEM "&Refresh Rate...", ID_OPTIONS_REFRESH_RATE, GRAYED
- END
- POPUP "&Help"
- BEGIN
- MENUITEM "&About ...", ID_HELP_ABOUT
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_ABOUTBOX DIALOGEX DISCARDABLE 22, 17, 230, 75
-STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-CAPTION "About"
-FONT 8, "System"
-BEGIN
- ICON IDI_ZOOMIN,IDI_ZOOMIN,14,9,16,16
- LTEXT "ReactOS zoomin Version 1.0",IDC_STATIC,49,10,119,8,
- SS_NOPREFIX
- LTEXT "Copyright (C) 2002 ReactOS Team",IDC_STATIC,49,20,119,8
- DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE DISCARDABLE
-BEGIN
- IDS_APP_TITLE "ReactOS Zoomin"
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Accelerator
-//
-
-IDR_ZOOMIN ACCELERATORS DISCARDABLE
-BEGIN
- VK_F5, ID_REFRESH, VIRTKEY, NOINVERT
-END
+++ /dev/null
-/* $Id: zoomin.rc 31932 2008-01-21 21:29:59Z dreimer $ */
-
-LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_ZOOMIN ICON DISCARDABLE "zoomin.ico"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Menu
-//
-
-IDR_ZOOMIN_MENU MENU DISCARDABLE
-BEGIN
- POPUP "&Archivo"
- BEGIN
- MENUITEM "Sa&lir\tAlt-F4", ID_EDIT_EXIT
- END
- POPUP "&Edición"
- BEGIN
- MENUITEM "&Copiar\tCtrl+C", ID_EDIT_COPY, GRAYED
- MENUITEM "&Actualizar\tF5", ID_EDIT_REFRESH
- END
- POPUP "&Opciones"
- BEGIN
- MENUITEM "&Velocidad de actualización...", ID_OPTIONS_REFRESH_RATE, GRAYED
- END
- POPUP "Ay&uda"
- BEGIN
- MENUITEM "&Acerca de ...", ID_HELP_ABOUT
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_ABOUTBOX DIALOGEX DISCARDABLE 22, 17, 230, 75
-STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-CAPTION "Acerca de"
-FONT 8, "System"
-BEGIN
- ICON IDI_ZOOMIN,IDI_ZOOMIN,14,9,16,16
- LTEXT "ReactOS zoomin Version 1.0",IDC_STATIC,49,10,119,8,
- SS_NOPREFIX
- LTEXT "Copyright (C) 2002 ReactOS Team",IDC_STATIC,49,20,119,8
- DEFPUSHBUTTON "Aceptar",IDOK,195,6,30,11,WS_GROUP
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE DISCARDABLE
-BEGIN
- IDS_APP_TITLE "ReactOS Zoomin"
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Accelerator
-//
-
-IDR_ZOOMIN ACCELERATORS DISCARDABLE
-BEGIN
- VK_F5, ID_REFRESH, VIRTKEY, NOINVERT
-END
+++ /dev/null
-LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_ZOOMIN ICON DISCARDABLE "zoomin.ico"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Menu
-//
-
-IDR_ZOOMIN_MENU MENU DISCARDABLE
-BEGIN
- POPUP "&Fichier"
- BEGIN
- MENUITEM "Quitter\tAlt-F4", ID_EDIT_EXIT
- END
- POPUP "&Édition"
- BEGIN
- MENUITEM "&Copier\tCtrl+C", ID_EDIT_COPY, GRAYED
- MENUITEM "&Rafraîchir\tF5", ID_EDIT_REFRESH
- END
- POPUP "&Options"
- BEGIN
- MENUITEM "Taux de &rafraîchissement...", ID_OPTIONS_REFRESH_RATE, GRAYED
- END
- POPUP "Aide"
- BEGIN
- MENUITEM "&A propos de...", ID_HELP_ABOUT
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_ABOUTBOX DIALOGEX DISCARDABLE 22, 17, 230, 75
-STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-CAPTION "A propos de"
-FONT 8, "System"
-BEGIN
- ICON IDI_ZOOMIN,IDI_ZOOMIN,14,9,16,16
- LTEXT "ReactOS zoomin Version 1.0",IDC_STATIC,49,10,119,8,
- SS_NOPREFIX
- LTEXT "Copyright (C) 2002 ReactOS Team",IDC_STATIC,49,20,119,8
- DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE DISCARDABLE
-BEGIN
- IDS_APP_TITLE "ReactOS Zoomin"
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Accelerator
-//
-
-IDR_ZOOMIN ACCELERATORS DISCARDABLE
-BEGIN
- VK_F5, ID_REFRESH, VIRTKEY, NOINVERT
-END
+++ /dev/null
-/* $Id: zoomin.rc 31932 2008-01-21 21:29:59Z dreimer $ */
-
-LANGUAGE LANG_NORWEGIAN, SUBLANG_NEUTRAL
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_ZOOMIN ICON DISCARDABLE "zoomin.ico"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Menu
-//
-
-IDR_ZOOMIN_MENU MENU DISCARDABLE
-BEGIN
- POPUP "&Fil"
- BEGIN
- MENUITEM "A&vslutt\tAlt-F4", ID_EDIT_EXIT
- END
- POPUP "&Rediger"
- BEGIN
- MENUITEM "&Kopier\tCtrl+C", ID_EDIT_COPY, GRAYED
- MENUITEM "&Oppdater\tF5", ID_EDIT_REFRESH
- END
- POPUP "&Valg"
- BEGIN
- MENUITEM "&Oppdatering hastighet...", ID_OPTIONS_REFRESH_RATE, GRAYED
- END
- POPUP "&Hjelp"
- BEGIN
- MENUITEM "&Om ...", ID_HELP_ABOUT
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_ABOUTBOX DIALOGEX DISCARDABLE 22, 17, 230, 75
-STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-CAPTION "Om"
-FONT 8, "System"
-BEGIN
- ICON IDI_ZOOMIN,IDI_ZOOMIN,14,9,16,16
- LTEXT "ReactOS zoomin versjon 1.0",IDC_STATIC,49,10,119,8,
- SS_NOPREFIX
- LTEXT "Enerett (C) 2002 ReactOS gruppen",IDC_STATIC,49,20,119,8
- DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE DISCARDABLE
-BEGIN
- IDS_APP_TITLE "ReactOS Zoomin"
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Accelerator
-//
-
-IDR_ZOOMIN ACCELERATORS DISCARDABLE
-BEGIN
- VK_F5, ID_REFRESH, VIRTKEY, NOINVERT
-END
+++ /dev/null
-/* TRANSLATOR : Mário Kaèmár /Mario Kacmar/ aka Kario (kario@szm.sk)
- * DATE OF TR.: 04-09-2008
- */
-
-LANGUAGE LANG_SLOVAK, SUBLANG_DEFAULT
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_ZOOMIN ICON DISCARDABLE "zoomin.ico"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Menu
-//
-
-IDR_ZOOMIN_MENU MENU DISCARDABLE
-BEGIN
- POPUP "&Súbor"
- BEGIN
- MENUITEM "&Skonèi\9d\tAlt-F4", ID_EDIT_EXIT
- END
- POPUP "&Upravi\9d"
- BEGIN
- MENUITEM "&Kopírova\9d\tCtrl+C", ID_EDIT_COPY, GRAYED
- MENUITEM "&Obnovi\9d\tF5", ID_EDIT_REFRESH
- END
- POPUP "&Mo\9enos\9di"
- BEGIN
- MENUITEM "&Obnovovací kmitoèet...", ID_OPTIONS_REFRESH_RATE, GRAYED
- END
- POPUP "&Pomocník"
- BEGIN
- MENUITEM "È&o je ...", ID_HELP_ABOUT
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_ABOUTBOX DIALOGEX DISCARDABLE 22, 17, 230, 75
-STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-CAPTION "Èo je Zoomin"
-FONT 8, "System"
-BEGIN
- ICON IDI_ZOOMIN,IDI_ZOOMIN,14,9,16,16
- LTEXT "ReactOS zoomin verzia 1.0",IDC_STATIC,49,10,119,8,
- SS_NOPREFIX
- LTEXT "Autorské práva (C) 2002 ReactOS Team",IDC_STATIC,49,20,119,8
- DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE DISCARDABLE
-BEGIN
- IDS_APP_TITLE "ReactOS Zoomin"
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Accelerator
-//
-
-IDR_ZOOMIN ACCELERATORS DISCARDABLE
-BEGIN
- VK_F5, ID_REFRESH, VIRTKEY, NOINVERT
-END
+++ /dev/null
-/*
- * PROJECT: ReactOS zoomin
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: devutils/zoomin/lang/uk-UA.rc
- * PURPOSE: Ukraianian resource file
- * TRANSLATOR: Artem Reznikov
- */
-
-LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_ZOOMIN ICON DISCARDABLE "zoomin.ico"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Menu
-//
-
-IDR_ZOOMIN_MENU MENU DISCARDABLE
-BEGIN
- POPUP "&Ôàéë"
- BEGIN
- MENUITEM "Â&èõ³ä\tAlt-F4", ID_EDIT_EXIT
- END
- POPUP "&Edit"
- BEGIN
- MENUITEM "&Êîï³þâàòè\tCtrl+C", ID_EDIT_COPY, GRAYED
- MENUITEM "&Îíîâèòè\tF5", ID_EDIT_REFRESH
- END
- POPUP "&Options"
- BEGIN
- MENUITEM "&×àñòîòà îíîâëåííÿ...", ID_OPTIONS_REFRESH_RATE, GRAYED
- END
- POPUP "&Äîâ³äêà"
- BEGIN
- MENUITEM "&Ïðî ïðîãðàìó", ID_HELP_ABOUT
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_ABOUTBOX DIALOGEX DISCARDABLE 22, 17, 230, 75
-STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-CAPTION "Ïðî ïðîãðàìó"
-FONT 8, "System"
-BEGIN
- ICON IDI_ZOOMIN,IDI_ZOOMIN,14,9,16,16
- LTEXT "ReactOS zoomin âåðñ³ÿ 1.0",IDC_STATIC,49,10,119,8,
- SS_NOPREFIX
- LTEXT "Copyright (C) 2002 ReactOS Team",IDC_STATIC,49,20,119,8
- DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE DISCARDABLE
-BEGIN
- IDS_APP_TITLE "ReactOS Zoomin"
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Accelerator
-//
-
-IDR_ZOOMIN ACCELERATORS DISCARDABLE
-BEGIN
- VK_F5, ID_REFRESH, VIRTKEY, NOINVERT
-END
+++ /dev/null
-/*
- * ReactOS zoomin
- *
- * main.c
- *
- * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-#include <windows.h>
-#include <tchar.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "main.h"
-#include "framewnd.h"
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Global Variables:
-//
-
-HWND hFrameWnd;
-HMENU hMenuFrame;
-
-TCHAR szTitle[MAX_LOADSTRING];
-
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// FUNCTION: InitInstance(HANDLE, int)
-//
-// PURPOSE: creates main window
-//
-
-BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
-{
- WNDCLASSEX wcFrame = {
- sizeof(WNDCLASSEX),
- CS_HREDRAW | CS_VREDRAW/*style*/,
- FrameWndProc,
- 0/*cbClsExtra*/,
- 0/*cbWndExtra*/,
- hInstance,
- LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ZOOMIN)),
- LoadCursor(0, IDC_ARROW),
- 0,//(HBRUSH)(COLOR_BTNFACE+1),
- 0/*lpszMenuName*/,
- WNDCLASS_ZOOMIN,
- (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_ZOOMIN), IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
- };
- ATOM hFrameWndClass = RegisterClassEx(&wcFrame); // register frame window class
-
- hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_ZOOMIN_MENU));
-
- hFrameWnd = CreateWindowEx(0, (LPCTSTR)UlongToPtr(hFrameWndClass), szTitle,
- WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE | WS_VSCROLL,
- CW_USEDEFAULT, CW_USEDEFAULT, 250, 250,
- NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
-
- if (!hFrameWnd) {
- return FALSE;
- }
-
- ShowWindow(hFrameWnd, nCmdShow);
- UpdateWindow(hFrameWnd);
-
- return TRUE;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-void ExitInstance(void)
-{
- DestroyMenu(hMenuFrame);
-}
-
-int APIENTRY WinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow)
-{
- MSG msg;
- HACCEL hAccel;
-
- // Initialize global strings
- LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
-
- // Perform application initialization:
- if (!InitInstance(hInstance, nCmdShow)) {
- return FALSE;
- }
-
- hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ZOOMIN));
-
- // Main message loop:
- while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
- if (!TranslateAccelerator(msg.hwnd, hAccel, &msg)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- return msg.wParam;
-}
+++ /dev/null
-/*
- * ReactOS zoomin
- *
- * main.h
- *
- * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef __MAIN_H__
-#define __MAIN_H__
-
-#include "resource.h"
-
-#define MAX_LOADSTRING 100
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Global Variables:
-//
-extern HWND hFrameWnd;
-extern HMENU hMenuFrame;
-
-extern TCHAR szTitle[];
-
-
-#endif // __MAIN_H__
+++ /dev/null
-#define ID_ZOOMIN_MENU 0
-#define ID_FILE_MENU 1
-#define ID_OPTIONS_MENU 2
-#define ID_HELP_MENU 3
-
-#define IDD_ABOUTBOX 103
-#define IDS_APP_TITLE 103
-#define IDI_ZOOMIN 107
-#define IDI_SMALL 108
-#define IDR_ZOOMIN_MENU 109
-#define IDR_ZOOMIN 110
-
-#define ID_EDIT_EXIT 32700
-#define ID_EDIT_COPY 32701
-#define ID_EDIT_REFRESH 32702
-#define ID_OPTIONS_REFRESH_RATE 32704
-#define ID_HELP_ABOUT 32703
-
-#define ID_REFRESH 40001
-
-#define IDC_STATIC -1
-
+++ /dev/null
-<module name="zoomin" type="win32gui" installbase="system32" installname="zoomin.exe">
- <include base="zoomin">.</include>
- <library>kernel32</library>
- <library>gdi32</library>
- <library>user32</library>
- <file>framewnd.c</file>
- <file>main.c</file>
- <file>zoomin.rc</file>
-</module>
+++ /dev/null
-/* $Id$ */
-
-#include <windows.h>
-#include "resource.h"
-
-#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Zoomin Utility\0"
-#define REACTOS_STR_INTERNAL_NAME "zoomin\0"
-#define REACTOS_STR_ORIGINAL_FILENAME "zoomin.exe\0"
-#include <reactos/version.rc>
-
-#include "lang/en-US.rc"
-#include "lang/es-ES.rc"
-#include "lang/fr-FR.rc"
-#include "lang/no-NO.rc"
-#include "lang/sk-SK.rc"
-#include "lang/uk-UA.rc"