mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-28 15:34:31 +00:00
Updated Fex file viewer
This commit is contained in:
parent
61b5901fdb
commit
05d6b52acd
74
tools/Fex.c
74
tools/Fex.c
@ -4,6 +4,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "../Kernel/Fex.hpp"
|
||||||
|
|
||||||
void DumpData(const char *Description, unsigned char *Address, unsigned long Length)
|
void DumpData(const char *Description, unsigned char *Address, unsigned long Length)
|
||||||
{
|
{
|
||||||
printf("-------------------------------------------------------------------------\n");
|
printf("-------------------------------------------------------------------------\n");
|
||||||
@ -50,7 +52,7 @@ int main()
|
|||||||
char BufferChar;
|
char BufferChar;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
printf("--- THIS IS NOT A COMPLETE VERSION ---\n\n");
|
printf("--- FEX file viewer ---\n");
|
||||||
FileSelection:
|
FileSelection:
|
||||||
printf("File Name: ");
|
printf("File Name: ");
|
||||||
fgets(FileName, 20, stdin);
|
fgets(FileName, 20, stdin);
|
||||||
@ -69,6 +71,76 @@ FileSelection:
|
|||||||
fread(Buffer, 1, st.st_size, FilePointer);
|
fread(Buffer, 1, st.st_size, FilePointer);
|
||||||
DumpData(FileName, Buffer, st.st_size);
|
DumpData(FileName, Buffer, st.st_size);
|
||||||
|
|
||||||
|
struct Fex *FexFile = Buffer;
|
||||||
|
|
||||||
|
if (FexFile->Magic[0] != 'F' || FexFile->Magic[1] != 'E' || FexFile->Magic[2] != 'X' || FexFile->Magic[3] != '\0')
|
||||||
|
{
|
||||||
|
printf("Invalid FEX header. Checking if it's in an ELF file...\n");
|
||||||
|
if (st.st_size > 0x1000)
|
||||||
|
{
|
||||||
|
struct Fex *FexFile = (struct Fex *)(Buffer + 0x1000);
|
||||||
|
if (FexFile->Magic[0] != 'F' || FexFile->Magic[1] != 'E' || FexFile->Magic[2] != 'X' || FexFile->Magic[3] != '\0')
|
||||||
|
{
|
||||||
|
printf("Invalid FEX header. Exiting...\n");
|
||||||
|
fclose(FilePointer);
|
||||||
|
free(Buffer);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Invalid FEX header. Exiting...\n");
|
||||||
|
fclose(FilePointer);
|
||||||
|
free(Buffer);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FexExtended *FexExtendedFile = (struct FexExtended *)(Buffer + EXTENDED_SECTION_ADDRESS);
|
||||||
|
|
||||||
|
printf("┌FEX File:\n");
|
||||||
|
printf("├Magic: %c%c%c%c\n", FexFile->Magic[0], FexFile->Magic[1], FexFile->Magic[2], FexFile->Magic[3]);
|
||||||
|
printf("├Type: %d\n", FexFile->Type);
|
||||||
|
printf("├Operating System: %d\n", FexFile->OS);
|
||||||
|
printf("├Entry Point: %#lx\n", FexFile->EntryPoint);
|
||||||
|
printf("┊\n");
|
||||||
|
printf("├FEX Extended Header:\n");
|
||||||
|
printf("│ ├Executable:\n");
|
||||||
|
printf("│ │ └<not implemented>\n");
|
||||||
|
// TODO: Add more stuff to executable category.
|
||||||
|
printf("│ ├Driver:\n");
|
||||||
|
printf("│ │ ├Name: %s\n", FexExtendedFile->Driver.Name);
|
||||||
|
printf("│ │ ├Type: %d\n", FexExtendedFile->Driver.Type);
|
||||||
|
printf("│ │ ├Callback: %#lx\n", FexExtendedFile->Driver.Callback);
|
||||||
|
printf("│ │ ├Bind:\n");
|
||||||
|
printf("│ │ │ ├Type: %d\n", FexExtendedFile->Driver.Bind.Type);
|
||||||
|
printf("│ │ │ ├Interrupt:\n");
|
||||||
|
printf("│ │ │ │ └Vectors: ");
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
printf("%#x ", FexExtendedFile->Driver.Bind.Interrupt.Vector[i]);
|
||||||
|
printf("\n");
|
||||||
|
printf("│ │ │ ├Process:\n");
|
||||||
|
printf("│ │ │ │ └Process IDs: ");
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
printf("%d ", FexExtendedFile->Driver.Bind.Process.ProcessId[i]);
|
||||||
|
printf("\n");
|
||||||
|
printf("│ │ │ ├PCI:\n");
|
||||||
|
printf("│ │ │ │ ├Vendor IDs: ");
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
printf("%#x ", FexExtendedFile->Driver.Bind.PCI.VendorID[i]);
|
||||||
|
printf("\n");
|
||||||
|
printf("│ │ │ │ ├Device IDs: ");
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
printf("%#x ", FexExtendedFile->Driver.Bind.PCI.DeviceID[i]);
|
||||||
|
printf("\n");
|
||||||
|
printf("│ │ │ │ ├Class: %#x\n", FexExtendedFile->Driver.Bind.PCI.Class);
|
||||||
|
printf("│ │ │ │ ├SubClass: %#x\n", FexExtendedFile->Driver.Bind.PCI.SubClass);
|
||||||
|
printf("│ │ │ │ └ProgIF: %#x\n", FexExtendedFile->Driver.Bind.PCI.ProgIF);
|
||||||
|
printf("│ │ │ ├Input:\n");
|
||||||
|
printf("│ │ │ │ ├Attach to mouse: %s\n", FexExtendedFile->Driver.Bind.Input.AttachToMouse ? "true" : "false");
|
||||||
|
printf("│ │ │ │ └Attach to keyboard: %s\n", FexExtendedFile->Driver.Bind.Input.AttachToKeyboard ? "true" : "false");
|
||||||
|
printf("┊ ┊ ┊ ┊\n");
|
||||||
|
|
||||||
fclose(FilePointer);
|
fclose(FilePointer);
|
||||||
free(Buffer);
|
free(Buffer);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user