From 4aefb10dfcf24216cf000f9ae6f51d6d012c39cf Mon Sep 17 00:00:00 2001 From: SnailMath Date: Thu, 29 Apr 2021 19:56:47 +0200 Subject: [PATCH] Fixed bug with start addr --- launcher/bins.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/launcher/bins.cpp b/launcher/bins.cpp index 4d12cd1..8138f4c 100644 --- a/launcher/bins.cpp +++ b/launcher/bins.cpp @@ -2,11 +2,21 @@ #include #include #include "bins.hpp" -//#include "elf.h" -//#include +#include #define hex2asc(x) ((x)>9?((x)+'A'-10):((x)+'0')) +#define Serial_print(s) Serial_Write((const unsigned char*)s,sizeof(s)-1) + +#define Serial_printhex(x) Serial_WriteSingle( hex2asc( ((x)>>28)&0xf ) );\ + Serial_WriteSingle( hex2asc( ((x)>>24)&0xf ) );\ + Serial_WriteSingle( hex2asc( ((x)>>20)&0xf ) );\ + Serial_WriteSingle( hex2asc( ((x)>>16)&0xf ) );\ + Serial_WriteSingle( hex2asc( ((x)>>12)&0xf ) );\ + Serial_WriteSingle( hex2asc( ((x)>> 8)&0xf ) );\ + Serial_WriteSingle( hex2asc( ((x)>> 4)&0xf ) );\ + Serial_WriteSingle( hex2asc( ((x)>> 0)&0xf ) ); + class File { public: File() : m_opened(false), m_fd(-1) { @@ -166,10 +176,23 @@ namespace Bins { unsigned char* address; f.getAddr(0x0c, (const void**)&address); EntryPoint entrypoint = (EntryPoint)0x8cff0000; - if (address[0]==0x80) + if (address[0]==0x8c) entrypoint = (EntryPoint)((address[0]<<24) + (address[1]<<16) + (address[2]<<8) + (address[3])); - f.read((void*)entrypoint,0x20000); + int length = f.read((void*)entrypoint,0x20000); + //unsigned char mode[] = {0,5,0,0,0,0}; + //Serial_Open(mode); + //Serial_print("The length is: 0x"); + //Serial_printhex(length); + //unsigned char c; + //while(c!='\n') { + // Serial_ReadSingle(&c); + // if(c=='.'){ + // Serial_Close(0); + // return nullptr; + // } + //} + //Serial_Close(0); return entrypoint; } }