Code: Select all
#include "../cpu/idt.h"
#include "../cpu/isr.h"
#include "../cpu/timer.h"
#include "../drivers/ports.h"
#include "../drivers/hdd.h"
#include "../drivers/display.h"
#define ET(x) printf("Error Trace %s\n", #x);
#define PUSH_ALL asm volatile ( \
"pusha \n\t" \
: : : "memory" );
#define POP_ALL asm volatile ( \
"popa \n\t" \
: : : "memory" );
void* search_signature(void* start_address, size_t size, uint32_t signature) {
for (size_t i = 0; i < size - sizeof(uint32_t) + 1; i++) {
uint32_t value = *((uint32_t*)(start_address + i));
if (value == signature) {
// Signature found, return the address
return (start_address + i);
}
}
// Signature not found in the given range
return NULL;
}
int check = 0;
void start_kernel() {
if(check == 1) {
clear_screen();
ET(start)
while(1) {}
}
PUSH_ALL;
readFromHardDrive(33, 2880, (void*)0x200000);
void* sig = 0x200000;
void* jmp = 0x1000;
while(sig = search_signature(sig, 512*2880, 0xDEADBEEF)) {
printf("signature found at %p\n", sig);
jmp = sig;
sig++;
}
memcpy(0x100000, jmp-9, 0x100000);
hexDump(0x100000, 64); // everything is in place
getch();
POP_ALL;
ET(usw)
check = 1;
// Rufe den Eintrittspunkt von kernel2.bin auf
void (*functionPointer)() = (void*)0x100000; // kernel_start_main;
printf("functionPtr = %p\n", functionPointer);
functionPointer();
ET(etc)
}
Happy Coding! as GPT says.