Author: greatlrd Date: Sat Jan 13 12:56:05 2007 New Revision: 25434
URL: http://svn.reactos.org/svn/reactos?rev=25434&view=rev Log: 1. finish the peloader, left todo add decoder for each sectionheader, add the base address when u call a brain, and some other minior fix 2. fix some comment that was wrong.
Modified: trunk/rosapps/devutils/cputointel/ImageLoader.c trunk/rosapps/devutils/cputointel/PPC/PPCBrain.c trunk/rosapps/devutils/cputointel/dummycpu/DummyBrain.c trunk/rosapps/devutils/cputointel/m68k/M68kBrain.c
Modified: trunk/rosapps/devutils/cputointel/ImageLoader.c URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/ImageLo... ============================================================================== --- trunk/rosapps/devutils/cputointel/ImageLoader.c (original) +++ trunk/rosapps/devutils/cputointel/ImageLoader.c Sat Jan 13 12:56:05 2007 @@ -8,6 +8,10 @@ #include "ARM/ARM.h" #include "m68k/m68k.h" #include "PPC/PPC.h" + +/* + * + */
CPU_INT LoadPFileImage( char *infileName, char *outputfileName, CPU_UNINT BaseAddress, char *cpuid, @@ -135,10 +139,11 @@ CPU_UNINT base, CPU_UNINT size, FILE *outfp) { - //INT sizeofHeader = IMAGE_NT_SIGNATURE; PIMAGE_DOS_HEADER DosHeader; PIMAGE_NT_HEADERS NtHeader; PIMAGE_SECTION_HEADER SectionHeader; + INT NumberOfSections; + INT NumberOfSectionsCount=0;
DosHeader = (PIMAGE_DOS_HEADER)memory; if ( (DosHeader->e_magic != IMAGE_DOS_SIGNATURE) || @@ -147,8 +152,6 @@ printf("No MZ file \n"); return -1; } - -
NtHeader = (PIMAGE_NT_HEADERS) (((ULONG)memory) + ((ULONG)DosHeader->e_lfanew)); if (NtHeader->Signature != IMAGE_NT_SIGNATURE) @@ -217,9 +220,6 @@ printf("Unknown OS : SubID : %d\n",NtHeader->OptionalHeader.Subsystem); break; } - - -
/* SectionHeader->Name == ".tls$" @@ -248,141 +248,147 @@ SectionHeader->Name == ".textbss" // bss segment */
- - //*base = NtHeader->OptionalHeader.AddressOfEntryPoint;
- SectionHeader = IMAGE_FIRST_SECTION(NtHeader); - while (SectionHeader != NULL) - { - if (strcmpi(SectionHeader->Name,".rsrc")) + SectionHeader = IMAGE_FIRST_SECTION(NtHeader); + NumberOfSections = NtHeader->FileHeader.NumberOfSections; + + for (NumberOfSectionsCount = 0; NumberOfSectionsCount < NumberOfSections; NumberOfSectionsCount++, SectionHeader++) + { + if (strnicmp(SectionHeader->Name,".rsrc",5)==0) { /* FIXME add a rc bin to text scanner */ }
- else if (strcmpi(SectionHeader->Name,".textbss")) + else if (strnicmp(SectionHeader->Name,".textbss",8)==0) { /* FIXME add a bss to text scanner */ }
- else if (strcmpi(SectionHeader->Name,".text")) + + else if (strnicmp(SectionHeader->Name,".text",5)==0) { switch (NtHeader->FileHeader.Machine) { case IMAGE_FILE_MACHINE_ALPHA: printf("CPU ALPHA Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_ALPHA64: printf("CPU ALPHA64/AXP64 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_AM33: printf("CPU AM33 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_AMD64: printf("CPU AMD64 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_ARM: printf("CPU ARM Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_CEE: printf("CPU CEE Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_CEF: printf("CPU CEF Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_EBC: printf("CPU EBC Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_I386: printf("CPU I386 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_IA64: printf("CPU IA64 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_M32R: printf("CPU M32R Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_MIPS16: printf("CPU MIPS16 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_MIPSFPU: printf("CPU MIPSFPU Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_MIPSFPU16: printf("CPU MIPSFPU16 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_POWERPC: printf("CPU POWERPC Detected no CPUBrain implement for it\n"); - return -1; + //PPCBrain(memory, pos, cpu_size, base, 0, outfp); + return PPCBrain(memory+SectionHeader->PointerToRawData, 0, SectionHeader->SizeOfRawData, 0, 0, outfp); + + return 3;
case IMAGE_FILE_MACHINE_POWERPCFP: printf("CPU POWERPCFP Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_R10000: printf("CPU R10000 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_R3000: printf("CPU R3000 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_R4000: printf("CPU R4000 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_SH3: printf("CPU SH3 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_SH3DSP: printf("CPU SH3DSP Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_SH3E: printf("CPU SH3E Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_SH4: printf("CPU SH4 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_SH5: printf("CPU SH5 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_THUMB: printf("CPU THUMB Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_TRICORE: printf("CPU TRICORE Detected no CPUBrain implement for it\n"); - return -1; + return 3;
case IMAGE_FILE_MACHINE_WCEMIPSV2: printf("CPU WCEMIPSV2 Detected no CPUBrain implement for it\n"); - return -1; + return 3;
default: printf("Unknown Machine : %d",NtHeader->FileHeader.Machine); - return -1; + return 4; + /* End case swich */ } + /* End if .text statment */ } - /* FIXME add couter to next sections */ + /* End for loop */ }
return 0;
Modified: trunk/rosapps/devutils/cputointel/PPC/PPCBrain.c URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/PPC/PPC... ============================================================================== --- trunk/rosapps/devutils/cputointel/PPC/PPCBrain.c (original) +++ trunk/rosapps/devutils/cputointel/PPC/PPCBrain.c Sat Jan 13 12:56:05 2007 @@ -25,6 +25,8 @@ * 0 : Ok * 1 : unimplemt * 2 : Unkonwn Opcode + * 3 : unimplement cpu + * 4 : unknown machine */
CPU_INT PPCBrain( CPU_BYTE *cpu_buffer,
Modified: trunk/rosapps/devutils/cputointel/dummycpu/DummyBrain.c URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/dummycp... ============================================================================== --- trunk/rosapps/devutils/cputointel/dummycpu/DummyBrain.c (original) +++ trunk/rosapps/devutils/cputointel/dummycpu/DummyBrain.c Sat Jan 13 12:56:05 2007 @@ -27,6 +27,8 @@ * 0 : Ok * 1 : unimplemt * 2 : Unkonwn Opcode + * 3 : unimplement cpu + * 4 : unknown machine */
CPU_INT DummyBrain( CPU_BYTE *cpu_buffer,
Modified: trunk/rosapps/devutils/cputointel/m68k/M68kBrain.c URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/m68k/M6... ============================================================================== --- trunk/rosapps/devutils/cputointel/m68k/M68kBrain.c (original) +++ trunk/rosapps/devutils/cputointel/m68k/M68kBrain.c Sat Jan 13 12:56:05 2007 @@ -6,16 +6,11 @@ #include "../misc.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 + * 0 : Ok + * 1 : unimplemt + * 2 : Unkonwn Opcode + * 3 : unimplement cpu + * 4 : unknown machine */
CPU_INT M68KBrain( CPU_BYTE *cpu_buffer,