3ds, however, won't work

This commit is contained in:
Morten Delenk 2016-08-14 20:04:41 +02:00
parent d916802eb7
commit e8a05caa89
No known key found for this signature in database
GPG key ID: 3F818D0F65DCB490
6 changed files with 44 additions and 33 deletions

View file

@ -1,4 +1,4 @@
arch = x86_64
arch = 3ds
subvar = 9
MODE = debug
export PATH := $(HOME)/opt/bin:$(PATH)

View file

@ -10,7 +10,7 @@
#define Elf_Phdr Elf32_Phdr
#endif
char *lfb=(char*)0x18346500;
#ifndef ARM9
#ifdef ARM9
#define DIAGPXL(i) (lfb[6*(i)]=lfb[6*(i)+1]=lfb[6*(i)+2]=0xFF)
#else
#define DIAGPXL(i) (0)
@ -65,6 +65,9 @@ void adjustVTable(uintptr_t** obj, uintptr_t mod, int vtableSize) {
* \brief Initializes the kernel
*/
extern "C" void _start(void ** modtable) {
#ifdef ARM11
for(;;);
#endif
DIAGPXL(13);
//for(void(**i)()=&start_ctors;i<&end_ctors;i++)
// (*i)(); //Calling constructors
@ -78,30 +81,38 @@ extern "C" void _start(void ** modtable) {
continue;
// fptr=(void(**(*)(void*))())((uintptr_t)fptr-8);
DIAGPXL(16);
debugNumber((uintptr_t)fptr,50);
// debugNumber((uintptr_t)modtable[i],50+32);
DIAGPXL(17);
void(**table)()=fptr(modtable[i]);
//debugNumber((uintptr_t)table,50+96);
DIAGPXL(18);
#ifndef __LP64__
//Relocate table
table=(void(**)())((uintptr_t)table+(uintptr_t)modtable[i]+0x1000);
#endif
#ifdef ARM9
table = (void(**)())0x27FFFFE8;
#else
#ifdef ARM11
table = (void(**)())0x27FFFFF4;
#endif
#endif
//Relocate table contents
uintptr_t* tbl=(uintptr_t*)table;
uintptr_t* tbl=(uintptr_t*)table;;
tbl[0]+=(uintptr_t)modtable[i]+0x1000;
tbl[1]+=(uintptr_t)modtable[i]+0x1000;
tbl[2]+=(uintptr_t)modtable[i]+0x1000;
debugNumber((uintptr_t)table[0],50+32);
DIAGPXL(500);
ModType type=((getType_type)table[0])(); //Get module type
DIAGPXL(19);
if(type!=ModType::output_text)
continue;
DIAGPXL(20);
DIAGPXL(501);
//if(type!=ModType::output_text)
//continue;
DIAGPXL(502);
size_t size=((sizeof_type)table[1])(); //Get module size
DIAGPXL(21);
debugNumber((uintptr_t)size,50);
DIAGPXL(503);
((spawnAt_type)table[2])((void*)&out);
DIAGPXL(22);
DIAGPXL(504);
adjustVTable((uintptr_t**) &out, (uintptr_t)modtable[i], 1);
out << "HI!\nbye!\n";
#ifdef ARM9
@ -109,8 +120,6 @@ extern "C" void _start(void ** modtable) {
#else
out << "Here arm11!\n";
#endif
char* x=(char*)0xB80000;
x[0]='H';
}
for(void(**i)()=&start_dtors;i<&end_dtors;i++)
(*i)(); //Calling destructors

View file

@ -2,7 +2,7 @@
#include <base/output.hpp>
#include <modstubs.h>
#include "stdfnt.h"
#ifdef ARM9
#ifndef ARM9
uint8_t* vmem = (uint8_t*)0x18300000;
uint8_t* dmem = (uint8_t*)0x18346500;
#else
@ -14,7 +14,7 @@ static int x=0,y=0;
#define CHR_HEIGHT 8
#define CHR_WIDTH 8
#define HEIGHT 29
#ifdef ARM9
#ifndef ARM9
#define WIDTH 50
#else
#define WIDTH 40
@ -100,12 +100,22 @@ private:
};
}
}
void(*tbl[3])()={(void(*)())&getType,(void(*)())&size_of,(void(*)())&spawnAt};
//void(*tbl[3])()={(void(*)())&getType,(void(*)())&size_of,(void(*)())&spawnAt};
table_type getTable() {
x=y=0;
// doCtors();
DIAGPXL(23);
return (table_type)&tbl;
#ifdef ARM9
void(**tbl)() = (void(**)())0x27FFFFE8;
#else
void(**tbl)() = (void(**)())0x27FFFFF4;
#endif
tbl[0]=(void(*)())&getType;
tbl[1]=(void(*)())&size_of;
tbl[2]=(void(*)())&spawnAt;
doCtors();
#ifdef ARM9
return (void(**)())0x27FFFFE8;
#else
return (void(**)())0x27FFFFF4;
#endif
}
auto getType() -> ModType {
DIAGPXL(24);
@ -113,7 +123,7 @@ auto getType() -> ModType {
}
auto spawnAt(void* pos) -> bool {
debugNumber((unsigned int)pos,82);
DIAGPXL(30);
DIAGPXL(530);
new(pos) MTGos::Screen;
return true;
}

View file

@ -8,8 +8,6 @@ SECTIONS
.text : {
*(.text)
*(.text.*)
}
.data : {
start_ctors = .;
KEEP(*( .init_array ));
KEEP(*(SORT_BY_INIT_PRIORITY( .init_array.* )));
@ -20,22 +18,14 @@ SECTIONS
end_dtors = .;
*(.data)
*(.data.*)
}
.rodata : {
*(.rodata)
}
.bss : {
*(.bss)
*(COMMON)
}
.plt : {
*(.plt)
}
.rel.plt : {
*(.rel.plt)
}
.rel.dyn : {
*(.rel.dyn)
*(.got)
*(.got.plt)
}
module_end = .;
}

View file

@ -22,6 +22,8 @@ SECTIONS
*(.plt)
*(.rel.plt)
*(.rel.dyn)
*(.got)
*(.got.plt)
}
module_end = .;
}

BIN
mount/arm9loaderhax.bin Executable file

Binary file not shown.