├── .gitignore ├── Makefile ├── README.md ├── VitaShell.bin ├── font.c ├── graphics.c ├── graphics.h ├── main.c └── sce_sys ├── icon0.png └── livearea └── contents ├── bg.png ├── startup.png └── template.xml /.gitignore: -------------------------------------------------------------------------------- 1 | *.elf 2 | *.velf 3 | *.vpk 4 | *.o 5 | eboot.bin 6 | param.sfo 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TITLE_ID = HBINJECT0 2 | TARGET = HBInjector 3 | OBJS = main.o graphics.o font.o 4 | 5 | LIBS = -lSceLibKernel_stub -lSceVshBridge_stub -lSceDisplay_stub -lScePower_stub -lSceIofilemgr_stub -lSceCtrl_stub 6 | 7 | PREFIX = arm-vita-eabi 8 | CC = $(PREFIX)-gcc 9 | CFLAGS = -Wl,-q -Wall -O3 10 | ASFLAGS = $(CFLAGS) 11 | 12 | all: $(TARGET).vpk 13 | 14 | %.vpk: eboot.bin 15 | vita-mksfoex -s TITLE_ID=$(TITLE_ID) "$(TARGET)" param.sfo 16 | vita-pack-vpk -s param.sfo -b eboot.bin $@ 17 | zip -ur $@ VitaShell.bin 18 | zip -ur $@ sce_sys 19 | 20 | eboot.bin: $(TARGET).velf 21 | vita-make-fself $< $@ 22 | 23 | %.velf: %.elf 24 | vita-elf-create $< $@ 25 | 26 | $(TARGET).elf: $(OBJS) 27 | $(CC) $(CFLAGS) $^ $(LIBS) -o $@ 28 | 29 | clean: 30 | @rm -rf $(TARGET).vpk $(TARGET).velf $(TARGET).elf $(OBJS) \ 31 | eboot.bin param.sfo 32 | 33 | vpksend: $(TARGET).vpk 34 | curl -T $(TARGET).vpk ftp://$(PSVITAIP):1337/ux0:/ 35 | @echo "Sent." 36 | 37 | send: eboot.bin 38 | curl -T eboot.bin ftp://$(PSVITAIP):1337/ux0:/app/$(TITLE_ID)/ 39 | @echo "Sent." 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HBInjector 2 | 3 | Replaces System Apps with VitaShell. This stops them being lost when formatting. This is useful for HENkaku Enso on 3.65, as it is difficult to regain access to VitaShell again after a format. 4 | 5 | ## Please don't use this 6 | 7 | This is obselete now because there's a working exploit on 3.65. Don't even use the code to learn from, it's actual garbage. 8 | 9 | ## Credits 10 | 11 | - [gnmmarechal](https://github.com/gnmmarechal/) 12 | - [StepS-](https://github.com/StepS-) 13 | - [Icon Source](https://kuvshinov-ilya.deviantart.com/art/--682565941) 14 | - People on the r/vitahacks Discord Server who helped me 15 | - [devingDev](https://github.com/devingDev/) 16 | - [SKGleba](https://github.com/SKGleba/) 17 | - [MyLegGuy](https://github.com/mylegguy) 18 | - [CelesteBlue](https://github.com/CelesteBlue-dev/) 19 | - Some more people I've forgotten 20 | -------------------------------------------------------------------------------- /VitaShell.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emiyl/HBInjector/eef4fdc2326c541ec9b05d9b1f425776c929890d/VitaShell.bin -------------------------------------------------------------------------------- /font.c: -------------------------------------------------------------------------------- 1 | /* 2 | * PSP Software Development Kit - http://www.pspdev.org 3 | * ----------------------------------------------------------------------- 4 | * Licensed under the BSD license, see LICENSE in PSPSDK root for details. 5 | * 6 | * font.c - Debug Font. 7 | * 8 | * Copyright (c) 2005 Marcus R. Brown 9 | * Copyright (c) 2005 James Forshaw 10 | * Copyright (c) 2005 John Kelley 11 | * 12 | * $Id: font.c 540 2005-07-08 19:35:10Z warren $ 13 | */ 14 | 15 | unsigned char msx[]= 16 | "\x00\x00\x00\x00\x00\x00\x00\x00\x3c\x42\xa5\x81\xa5\x99\x42\x3c" 17 | "\x3c\x7e\xdb\xff\xff\xdb\x66\x3c\x6c\xfe\xfe\xfe\x7c\x38\x10\x00" 18 | "\x10\x38\x7c\xfe\x7c\x38\x10\x00\x10\x38\x54\xfe\x54\x10\x38\x00" 19 | "\x10\x38\x7c\xfe\xfe\x10\x38\x00\x00\x00\x00\x30\x30\x00\x00\x00" 20 | "\xff\xff\xff\xe7\xe7\xff\xff\xff\x38\x44\x82\x82\x82\x44\x38\x00" 21 | "\xc7\xbb\x7d\x7d\x7d\xbb\xc7\xff\x0f\x03\x05\x79\x88\x88\x88\x70" 22 | "\x38\x44\x44\x44\x38\x10\x7c\x10\x30\x28\x24\x24\x28\x20\xe0\xc0" 23 | "\x3c\x24\x3c\x24\x24\xe4\xdc\x18\x10\x54\x38\xee\x38\x54\x10\x00" 24 | "\x10\x10\x10\x7c\x10\x10\x10\x10\x10\x10\x10\xff\x00\x00\x00\x00" 25 | "\x00\x00\x00\xff\x10\x10\x10\x10\x10\x10\x10\xf0\x10\x10\x10\x10" 26 | "\x10\x10\x10\x1f\x10\x10\x10\x10\x10\x10\x10\xff\x10\x10\x10\x10" 27 | "\x10\x10\x10\x10\x10\x10\x10\x10\x00\x00\x00\xff\x00\x00\x00\x00" 28 | "\x00\x00\x00\x1f\x10\x10\x10\x10\x00\x00\x00\xf0\x10\x10\x10\x10" 29 | "\x10\x10\x10\x1f\x00\x00\x00\x00\x10\x10\x10\xf0\x00\x00\x00\x00" 30 | "\x81\x42\x24\x18\x18\x24\x42\x81\x01\x02\x04\x08\x10\x20\x40\x80" 31 | "\x80\x40\x20\x10\x08\x04\x02\x01\x00\x10\x10\xff\x10\x10\x00\x00" 32 | "\x00\x00\x00\x00\x00\x00\x00\x00\x20\x20\x20\x20\x00\x00\x20\x00" 33 | "\x50\x50\x50\x00\x00\x00\x00\x00\x50\x50\xf8\x50\xf8\x50\x50\x00" 34 | "\x20\x78\xa0\x70\x28\xf0\x20\x00\xc0\xc8\x10\x20\x40\x98\x18\x00" 35 | "\x40\xa0\x40\xa8\x90\x98\x60\x00\x10\x20\x40\x00\x00\x00\x00\x00" 36 | "\x10\x20\x40\x40\x40\x20\x10\x00\x40\x20\x10\x10\x10\x20\x40\x00" 37 | "\x20\xa8\x70\x20\x70\xa8\x20\x00\x00\x20\x20\xf8\x20\x20\x00\x00" 38 | "\x00\x00\x00\x00\x00\x20\x20\x40\x00\x00\x00\x78\x00\x00\x00\x00" 39 | "\x00\x00\x00\x00\x00\x60\x60\x00\x00\x00\x08\x10\x20\x40\x80\x00" 40 | "\x70\x88\x98\xa8\xc8\x88\x70\x00\x20\x60\xa0\x20\x20\x20\xf8\x00" 41 | "\x70\x88\x08\x10\x60\x80\xf8\x00\x70\x88\x08\x30\x08\x88\x70\x00" 42 | "\x10\x30\x50\x90\xf8\x10\x10\x00\xf8\x80\xe0\x10\x08\x10\xe0\x00" 43 | "\x30\x40\x80\xf0\x88\x88\x70\x00\xf8\x88\x10\x20\x20\x20\x20\x00" 44 | "\x70\x88\x88\x70\x88\x88\x70\x00\x70\x88\x88\x78\x08\x10\x60\x00" 45 | "\x00\x00\x20\x00\x00\x20\x00\x00\x00\x00\x20\x00\x00\x20\x20\x40" 46 | "\x18\x30\x60\xc0\x60\x30\x18\x00\x00\x00\xf8\x00\xf8\x00\x00\x00" 47 | "\xc0\x60\x30\x18\x30\x60\xc0\x00\x70\x88\x08\x10\x20\x00\x20\x00" 48 | "\x70\x88\x08\x68\xa8\xa8\x70\x00\x20\x50\x88\x88\xf8\x88\x88\x00" 49 | "\xf0\x48\x48\x70\x48\x48\xf0\x00\x30\x48\x80\x80\x80\x48\x30\x00" 50 | "\xe0\x50\x48\x48\x48\x50\xe0\x00\xf8\x80\x80\xf0\x80\x80\xf8\x00" 51 | "\xf8\x80\x80\xf0\x80\x80\x80\x00\x70\x88\x80\xb8\x88\x88\x70\x00" 52 | "\x88\x88\x88\xf8\x88\x88\x88\x00\x70\x20\x20\x20\x20\x20\x70\x00" 53 | "\x38\x10\x10\x10\x90\x90\x60\x00\x88\x90\xa0\xc0\xa0\x90\x88\x00" 54 | "\x80\x80\x80\x80\x80\x80\xf8\x00\x88\xd8\xa8\xa8\x88\x88\x88\x00" 55 | "\x88\xc8\xc8\xa8\x98\x98\x88\x00\x70\x88\x88\x88\x88\x88\x70\x00" 56 | "\xf0\x88\x88\xf0\x80\x80\x80\x00\x70\x88\x88\x88\xa8\x90\x68\x00" 57 | "\xf0\x88\x88\xf0\xa0\x90\x88\x00\x70\x88\x80\x70\x08\x88\x70\x00" 58 | "\xf8\x20\x20\x20\x20\x20\x20\x00\x88\x88\x88\x88\x88\x88\x70\x00" 59 | "\x88\x88\x88\x88\x50\x50\x20\x00\x88\x88\x88\xa8\xa8\xd8\x88\x00" 60 | "\x88\x88\x50\x20\x50\x88\x88\x00\x88\x88\x88\x70\x20\x20\x20\x00" 61 | "\xf8\x08\x10\x20\x40\x80\xf8\x00\x70\x40\x40\x40\x40\x40\x70\x00" 62 | "\x00\x00\x80\x40\x20\x10\x08\x00\x70\x10\x10\x10\x10\x10\x70\x00" 63 | "\x20\x50\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x00" 64 | "\x40\x20\x10\x00\x00\x00\x00\x00\x00\x00\x70\x08\x78\x88\x78\x00" 65 | "\x80\x80\xb0\xc8\x88\xc8\xb0\x00\x00\x00\x70\x88\x80\x88\x70\x00" 66 | "\x08\x08\x68\x98\x88\x98\x68\x00\x00\x00\x70\x88\xf8\x80\x70\x00" 67 | "\x10\x28\x20\xf8\x20\x20\x20\x00\x00\x00\x68\x98\x98\x68\x08\x70" 68 | "\x80\x80\xf0\x88\x88\x88\x88\x00\x20\x00\x60\x20\x20\x20\x70\x00" 69 | "\x10\x00\x30\x10\x10\x10\x90\x60\x40\x40\x48\x50\x60\x50\x48\x00" 70 | "\x60\x20\x20\x20\x20\x20\x70\x00\x00\x00\xd0\xa8\xa8\xa8\xa8\x00" 71 | "\x00\x00\xb0\xc8\x88\x88\x88\x00\x00\x00\x70\x88\x88\x88\x70\x00" 72 | "\x00\x00\xb0\xc8\xc8\xb0\x80\x80\x00\x00\x68\x98\x98\x68\x08\x08" 73 | "\x00\x00\xb0\xc8\x80\x80\x80\x00\x00\x00\x78\x80\xf0\x08\xf0\x00" 74 | "\x40\x40\xf0\x40\x40\x48\x30\x00\x00\x00\x90\x90\x90\x90\x68\x00" 75 | "\x00\x00\x88\x88\x88\x50\x20\x00\x00\x00\x88\xa8\xa8\xa8\x50\x00" 76 | "\x00\x00\x88\x50\x20\x50\x88\x00\x00\x00\x88\x88\x98\x68\x08\x70" 77 | "\x00\x00\xf8\x10\x20\x40\xf8\x00\x18\x20\x20\x40\x20\x20\x18\x00" 78 | "\x20\x20\x20\x00\x20\x20\x20\x00\xc0\x20\x20\x10\x20\x20\xc0\x00" 79 | "\x40\xa8\x10\x00\x00\x00\x00\x00\x00\x00\x20\x50\xf8\x00\x00\x00" 80 | "\x70\x88\x80\x80\x88\x70\x20\x60\x90\x00\x00\x90\x90\x90\x68\x00" 81 | "\x10\x20\x70\x88\xf8\x80\x70\x00\x20\x50\x70\x08\x78\x88\x78\x00" 82 | "\x48\x00\x70\x08\x78\x88\x78\x00\x20\x10\x70\x08\x78\x88\x78\x00" 83 | "\x20\x00\x70\x08\x78\x88\x78\x00\x00\x70\x80\x80\x80\x70\x10\x60" 84 | "\x20\x50\x70\x88\xf8\x80\x70\x00\x50\x00\x70\x88\xf8\x80\x70\x00" 85 | "\x20\x10\x70\x88\xf8\x80\x70\x00\x50\x00\x00\x60\x20\x20\x70\x00" 86 | "\x20\x50\x00\x60\x20\x20\x70\x00\x40\x20\x00\x60\x20\x20\x70\x00" 87 | "\x50\x00\x20\x50\x88\xf8\x88\x00\x20\x00\x20\x50\x88\xf8\x88\x00" 88 | "\x10\x20\xf8\x80\xf0\x80\xf8\x00\x00\x00\x6c\x12\x7e\x90\x6e\x00" 89 | "\x3e\x50\x90\x9c\xf0\x90\x9e\x00\x60\x90\x00\x60\x90\x90\x60\x00" 90 | "\x90\x00\x00\x60\x90\x90\x60\x00\x40\x20\x00\x60\x90\x90\x60\x00" 91 | "\x40\xa0\x00\xa0\xa0\xa0\x50\x00\x40\x20\x00\xa0\xa0\xa0\x50\x00" 92 | "\x90\x00\x90\x90\xb0\x50\x10\xe0\x50\x00\x70\x88\x88\x88\x70\x00" 93 | "\x50\x00\x88\x88\x88\x88\x70\x00\x20\x20\x78\x80\x80\x78\x20\x20" 94 | "\x18\x24\x20\xf8\x20\xe2\x5c\x00\x88\x50\x20\xf8\x20\xf8\x20\x00" 95 | "\xc0\xa0\xa0\xc8\x9c\x88\x88\x8c\x18\x20\x20\xf8\x20\x20\x20\x40" 96 | "\x10\x20\x70\x08\x78\x88\x78\x00\x10\x20\x00\x60\x20\x20\x70\x00" 97 | "\x20\x40\x00\x60\x90\x90\x60\x00\x20\x40\x00\x90\x90\x90\x68\x00" 98 | "\x50\xa0\x00\xa0\xd0\x90\x90\x00\x28\x50\x00\xc8\xa8\x98\x88\x00" 99 | "\x00\x70\x08\x78\x88\x78\x00\xf8\x00\x60\x90\x90\x90\x60\x00\xf0" 100 | "\x20\x00\x20\x40\x80\x88\x70\x00\x00\x00\x00\xf8\x80\x80\x00\x00" 101 | "\x00\x00\x00\xf8\x08\x08\x00\x00\x84\x88\x90\xa8\x54\x84\x08\x1c" 102 | "\x84\x88\x90\xa8\x58\xa8\x3c\x08\x20\x00\x00\x20\x20\x20\x20\x00" 103 | "\x00\x00\x24\x48\x90\x48\x24\x00\x00\x00\x90\x48\x24\x48\x90\x00" 104 | "\x28\x50\x20\x50\x88\xf8\x88\x00\x28\x50\x70\x08\x78\x88\x78\x00" 105 | "\x28\x50\x00\x70\x20\x20\x70\x00\x28\x50\x00\x20\x20\x20\x70\x00" 106 | "\x28\x50\x00\x70\x88\x88\x70\x00\x50\xa0\x00\x60\x90\x90\x60\x00" 107 | "\x28\x50\x00\x88\x88\x88\x70\x00\x50\xa0\x00\xa0\xa0\xa0\x50\x00" 108 | "\xfc\x48\x48\x48\xe8\x08\x50\x20\x00\x50\x00\x50\x50\x50\x10\x20" 109 | "\xc0\x44\xc8\x54\xec\x54\x9e\x04\x10\xa8\x40\x00\x00\x00\x00\x00" 110 | "\x00\x20\x50\x88\x50\x20\x00\x00\x88\x10\x20\x40\x80\x28\x00\x00" 111 | "\x7c\xa8\xa8\x68\x28\x28\x28\x00\x38\x40\x30\x48\x48\x30\x08\x70" 112 | "\x00\x00\x00\x00\x00\x00\xff\xff\xf0\xf0\xf0\xf0\x0f\x0f\x0f\x0f" 113 | "\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00" 114 | "\x00\x00\x00\x3c\x3c\x00\x00\x00\xff\xff\xff\xff\xff\xff\x00\x00" 115 | "\xc0\xc0\xc0\xc0\xc0\xc0\xc0\xc0\x0f\x0f\x0f\x0f\xf0\xf0\xf0\xf0" 116 | "\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\x03\x03\x03\x03\x03\x03\x03\x03" 117 | "\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x11\x22\x44\x88\x11\x22\x44\x88" 118 | "\x88\x44\x22\x11\x88\x44\x22\x11\xfe\x7c\x38\x10\x00\x00\x00\x00" 119 | "\x00\x00\x00\x00\x10\x38\x7c\xfe\x80\xc0\xe0\xf0\xe0\xc0\x80\x00" 120 | "\x01\x03\x07\x0f\x07\x03\x01\x00\xff\x7e\x3c\x18\x18\x3c\x7e\xff" 121 | "\x81\xc3\xe7\xff\xff\xe7\xc3\x81\xf0\xf0\xf0\xf0\x00\x00\x00\x00" 122 | "\x00\x00\x00\x00\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x00\x00\x00\x00" 123 | "\x00\x00\x00\x00\xf0\xf0\xf0\xf0\x33\x33\xcc\xcc\x33\x33\xcc\xcc" 124 | "\x00\x20\x20\x50\x50\x88\xf8\x00\x20\x20\x70\x20\x70\x20\x20\x00" 125 | "\x00\x00\x00\x50\x88\xa8\x50\x00\xff\xff\xff\xff\xff\xff\xff\xff" 126 | "\x00\x00\x00\x00\xff\xff\xff\xff\xf0\xf0\xf0\xf0\xf0\xf0\xf0\xf0" 127 | "\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\xff\xff\xff\xff\x00\x00\x00\x00" 128 | "\x00\x00\x68\x90\x90\x90\x68\x00\x30\x48\x48\x70\x48\x48\x70\xc0" 129 | "\xf8\x88\x80\x80\x80\x80\x80\x00\xf8\x50\x50\x50\x50\x50\x98\x00" 130 | "\xf8\x88\x40\x20\x40\x88\xf8\x00\x00\x00\x78\x90\x90\x90\x60\x00" 131 | "\x00\x50\x50\x50\x50\x68\x80\x80\x00\x50\xa0\x20\x20\x20\x20\x00" 132 | "\xf8\x20\x70\xa8\xa8\x70\x20\xf8\x20\x50\x88\xf8\x88\x50\x20\x00" 133 | "\x70\x88\x88\x88\x50\x50\xd8\x00\x30\x40\x40\x20\x50\x50\x50\x20" 134 | "\x00\x00\x00\x50\xa8\xa8\x50\x00\x08\x70\xa8\xa8\xa8\x70\x80\x00" 135 | "\x38\x40\x80\xf8\x80\x40\x38\x00\x70\x88\x88\x88\x88\x88\x88\x00" 136 | "\x00\xf8\x00\xf8\x00\xf8\x00\x00\x20\x20\xf8\x20\x20\x00\xf8\x00" 137 | "\xc0\x30\x08\x30\xc0\x00\xf8\x00\x18\x60\x80\x60\x18\x00\xf8\x00" 138 | "\x10\x28\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\xa0\x40" 139 | "\x00\x20\x00\xf8\x00\x20\x00\x00\x00\x50\xa0\x00\x50\xa0\x00\x00" 140 | "\x00\x18\x24\x24\x18\x00\x00\x00\x00\x30\x78\x78\x30\x00\x00\x00" 141 | "\x00\x00\x00\x00\x30\x00\x00\x00\x3e\x20\x20\x20\xa0\x60\x20\x00" 142 | "\xa0\x50\x50\x50\x00\x00\x00\x00\x40\xa0\x20\x40\xe0\x00\x00\x00" 143 | "\x00\x38\x38\x38\x38\x38\x38\x00\x00\x00\x00\x00\x00\x00\x00"; 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /graphics.c: -------------------------------------------------------------------------------- 1 | #include "graphics.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #define SCE_DISPLAY_UPDATETIMING_NEXTVSYNC SCE_DISPLAY_SETBUF_NEXTFRAME 8 | #include 9 | #include 10 | #include 11 | 12 | enum { 13 | SCREEN_WIDTH = 960, 14 | SCREEN_HEIGHT = 544, 15 | LINE_SIZE = 960, 16 | FRAMEBUFFER_SIZE = 2 * 1024 * 1024, 17 | FRAMEBUFFER_ALIGNMENT = 256 * 1024 18 | }; 19 | 20 | typedef union 21 | { 22 | int rgba; 23 | struct 24 | { 25 | char r; 26 | char g; 27 | char b; 28 | char a; 29 | } c; 30 | } color_t; 31 | 32 | extern u8 msx[]; 33 | void* g_vram_base; 34 | static int gX = 0; 35 | static int gY = 0; 36 | 37 | static Color g_fg_color; 38 | static Color g_bg_color; 39 | 40 | static Color* getVramDisplayBuffer() 41 | { 42 | Color* vram = (Color*) g_vram_base; 43 | return vram; 44 | } 45 | 46 | void *psvDebugScreenGetVram() { 47 | return g_vram_base; 48 | } 49 | 50 | int psvDebugScreenGetX() { 51 | return gX; 52 | } 53 | 54 | int psvDebugScreenGetY() { 55 | return gY; 56 | } 57 | 58 | void psvDebugScreenSetXY(int x, int y) { 59 | gX = x; 60 | gY = y; 61 | } 62 | 63 | // #define LOG(args...) vita_logf (__FILE__, __LINE__, args) ///< Write a log entry 64 | 65 | int g_log_mutex; 66 | 67 | void psvDebugScreenInit() { 68 | g_log_mutex = sceKernelCreateMutex("log_mutex", 0, 0, NULL); 69 | 70 | SceKernelAllocMemBlockOpt opt = { 0 }; 71 | opt.size = sizeof(opt); 72 | opt.attr = 0x00000004; 73 | opt.alignment = FRAMEBUFFER_ALIGNMENT; 74 | SceUID displayblock = sceKernelAllocMemBlock("display", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, FRAMEBUFFER_SIZE, &opt); 75 | printf("displayblock: 0x%08x", displayblock); 76 | void *base; 77 | sceKernelGetMemBlockBase(displayblock, &base); 78 | // LOG("base: 0x%08x", base); 79 | 80 | SceDisplayFrameBuf framebuf = { 0 }; 81 | framebuf.size = sizeof(framebuf); 82 | framebuf.base = base; 83 | framebuf.pitch = SCREEN_WIDTH; 84 | framebuf.pixelformat = SCE_DISPLAY_PIXELFORMAT_A8B8G8R8; 85 | framebuf.width = SCREEN_WIDTH; 86 | framebuf.height = SCREEN_HEIGHT; 87 | 88 | g_vram_base = base; 89 | 90 | sceDisplaySetFrameBuf(&framebuf, SCE_DISPLAY_UPDATETIMING_NEXTVSYNC); 91 | 92 | g_fg_color = 0xFFFFFFFF; 93 | g_bg_color = 0x00000000; 94 | } 95 | 96 | void psvDebugScreenClear(int bg_color) 97 | { 98 | gX = gY = 0; 99 | int i; 100 | color_t *pixel = (color_t *)getVramDisplayBuffer(); 101 | for(i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; i++) { 102 | pixel->rgba = bg_color; 103 | pixel++; 104 | } 105 | } 106 | 107 | static void printTextScreen(const char * text) 108 | { 109 | int c, i, j, l; 110 | u8 *font; 111 | Color *vram_ptr; 112 | Color *vram; 113 | 114 | for (c = 0; c < strlen(text); c++) { 115 | if (gX + 16 > SCREEN_WIDTH) { 116 | gY += 16; 117 | gX = 0; 118 | } 119 | if (gY + 16 > SCREEN_HEIGHT) { 120 | gY = 0; 121 | psvDebugScreenClear(g_bg_color); 122 | } 123 | char ch = text[c]; 124 | if (ch == '\n') { 125 | gX = 0; 126 | gY += 16; 127 | continue; 128 | } else if (ch == '\r') { 129 | gX = 0; 130 | continue; 131 | } 132 | 133 | vram = getVramDisplayBuffer() + gX + gY * LINE_SIZE; 134 | 135 | font = &msx[ (int)ch * 8]; 136 | for (i = l = 0; i < 8; i++, l += 8, font++) { 137 | vram_ptr = vram; 138 | for (j = 0; j < 8; j++) { 139 | if ((*font & (128 >> j))) { 140 | *(uint32_t *)(vram_ptr) = g_fg_color; 141 | *(uint32_t *)(vram_ptr + 1) = g_fg_color; 142 | *(uint32_t *)(vram_ptr + LINE_SIZE) = g_fg_color; 143 | *(uint32_t *)(vram_ptr + LINE_SIZE + 1) = g_fg_color; 144 | } else { 145 | *(uint32_t *)(vram_ptr) = g_bg_color; 146 | *(uint32_t *)(vram_ptr + 1) = g_bg_color; 147 | *(uint32_t *)(vram_ptr + LINE_SIZE) = g_bg_color; 148 | *(uint32_t *)(vram_ptr + LINE_SIZE + 1) = g_bg_color; 149 | } 150 | vram_ptr += 2; 151 | } 152 | vram += 2 * LINE_SIZE; 153 | } 154 | gX += 16; 155 | } 156 | } 157 | 158 | void psvDebugScreenPrintf(const char *format, ...) { 159 | char buf[1024]; 160 | 161 | sceKernelLockMutex(g_log_mutex, 1, NULL); 162 | 163 | va_list opt; 164 | va_start(opt, format); 165 | vsnprintf(buf, sizeof(buf), format, opt); 166 | printTextScreen(buf); 167 | va_end(opt); 168 | 169 | sceKernelUnlockMutex(g_log_mutex, 1); 170 | } 171 | 172 | Color psvDebugScreenSetFgColor(Color color) { 173 | Color prev_color = g_fg_color; 174 | g_fg_color = color; 175 | return prev_color; 176 | } 177 | 178 | Color psvDebugScreenSetBgColor(Color color) { 179 | Color prev_color = g_bg_color; 180 | g_bg_color = color; 181 | return prev_color; 182 | } -------------------------------------------------------------------------------- /graphics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef unsigned char u8; 4 | typedef unsigned u32; 5 | typedef u32 Color; 6 | 7 | // allocates memory for framebuffer and initializes it 8 | void psvDebugScreenInit(); 9 | 10 | // clears screen with a given color 11 | void psvDebugScreenClear(int bg_color); 12 | 13 | // printf to the screen 14 | void psvDebugScreenPrintf(const char *format, ...); 15 | 16 | // set foreground (text) color 17 | Color psvDebugScreenSetFgColor(Color color); 18 | 19 | // set background color 20 | Color psvDebugScreenSetBgColor(Color color); 21 | 22 | void *psvDebugScreenGetVram(); 23 | int psvDebugScreenGetX(); 24 | int psvDebugScreenGetY(); 25 | void psvDebugScreenSetXY(); 26 | 27 | enum { 28 | COLOR_CYAN = 0xFFFFFF00, 29 | COLOR_WHITE = 0xFFFFFFFF, 30 | COLOR_BLACK = 0xFF000000, 31 | COLOR_RED = 0xFF0000FF, 32 | COLOR_YELLOW = 0xFF00FFFF, 33 | COLOR_GREY = 0xFF808080, 34 | COLOR_GREEN = 0xFF00FF00, 35 | }; 36 | -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "graphics.h" 15 | 16 | #define printf psvDebugScreenPrintf 17 | /* Why Emily wants this, I have no idea, it's her fault. */ 18 | #define begone sceIoRemove 19 | /* holy shit i was kidding lmao */ 20 | #define WRAPVAL(v, min, max) (v < min ? max : v > max ? min : v) 21 | 22 | int cp(const char *to, const char *from) { 23 | SceUID fd_to, fd_from; 24 | char buf[16*1024]; 25 | ssize_t nread; 26 | int saved_errno; 27 | 28 | fd_from = sceIoOpen(from, SCE_O_RDONLY, 0777); 29 | if (fd_from < 0) 30 | return -1; 31 | 32 | fd_to = sceIoOpen(to, SCE_O_WRONLY|SCE_O_CREAT, 0777); 33 | if (fd_to < 0) 34 | goto out_error; 35 | 36 | while (nread = sceIoRead(fd_from, buf, sizeof buf), nread > 0) 37 | { 38 | char *out_ptr = buf; 39 | ssize_t nwritten; 40 | 41 | do { 42 | nwritten = sceIoWrite(fd_to, out_ptr, nread); 43 | 44 | if (nwritten >= 0) 45 | { 46 | nread -= nwritten; 47 | out_ptr += nwritten; 48 | } 49 | else if (errno != EINTR) 50 | { 51 | goto out_error; 52 | } 53 | } while (nread > 0); 54 | } 55 | 56 | if (nread == 0) 57 | { 58 | if (sceIoClose(fd_to) < 0) 59 | { 60 | fd_to = -1; 61 | goto out_error; 62 | } 63 | sceIoClose(fd_from); 64 | 65 | return 0; 66 | } 67 | 68 | out_error: 69 | saved_errno = errno; 70 | 71 | sceIoClose(fd_from); 72 | if (fd_to >= 0) 73 | sceIoClose(fd_to); 74 | 75 | errno = saved_errno; 76 | return -1; 77 | } 78 | 79 | static const char* sysTitles[][2] = { 80 | {"NPXS10000", "near"}, 81 | {"NPXS10094", "Parental Controls"}, 82 | {"NPXS10012", "PS3 Remote Play"}, 83 | {"NPXS10004", "Photos"}, 84 | {"NPXS10006", "Friends"}, 85 | {"NPXS10008", "Trophies"}, 86 | {"NPXS10009", "Music"}, 87 | {"NPXS10010", "Video"}, 88 | {"NPXS10013", "PS4 Link"}, 89 | {"NPXS10014", "Messages"}, 90 | {"NPXS10072", "Mail"}, 91 | {"NPXS10095", "Panoramic Camera"}, 92 | {"NPXS10091", "Calendar"}, 93 | }; 94 | 95 | #define TITLEID(n) sysTitles[n][0] 96 | #define TITLENAME(n) sysTitles[n][1] 97 | #define TITLEMAX sizeof(sysTitles) / sizeof(sysTitles[0]) - 1 98 | 99 | static unsigned buttons[] = { 100 | SCE_CTRL_SELECT, 101 | SCE_CTRL_START, 102 | SCE_CTRL_UP, 103 | SCE_CTRL_RIGHT, 104 | SCE_CTRL_DOWN, 105 | SCE_CTRL_LEFT, 106 | SCE_CTRL_LTRIGGER, 107 | SCE_CTRL_RTRIGGER, 108 | SCE_CTRL_TRIANGLE, 109 | SCE_CTRL_CIRCLE, 110 | SCE_CTRL_CROSS, 111 | SCE_CTRL_SQUARE, 112 | }; 113 | 114 | int get_key(void) { 115 | static unsigned prev = 0; 116 | SceCtrlData pad; 117 | while (1) { 118 | memset(&pad, 0, sizeof(pad)); 119 | sceCtrlPeekBufferPositive(0, &pad, 1); 120 | unsigned new = prev ^ (pad.buttons & prev); 121 | prev = pad.buttons; 122 | for (int i = 0; i < sizeof(buttons)/sizeof(*buttons); ++i) 123 | if (new & buttons[i]) 124 | return buttons[i]; 125 | 126 | sceKernelDelayThread(1000); // 1s 127 | } 128 | } 129 | 130 | int WriteFile(char *file, void *buf, int size) { 131 | SceUID fd = sceIoOpen(file, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777); 132 | if (fd < 0) 133 | return fd; 134 | 135 | int written = sceIoWrite(fd, buf, size); 136 | 137 | sceIoClose(fd); 138 | return written; 139 | } 140 | 141 | int main(int argc, char *argv[]) { 142 | psvDebugScreenInit(); 143 | const char *version = ("1.2.6") ; 144 | const char *titleid = "", *title = ""; 145 | int nTitle = 0; 146 | int mode = 0; 147 | char header[255]; 148 | char backupDir[255], backupPath[255], sysappPath[255], flagPath[255]; 149 | sceIoMkdir("ux0:data/HBInjector", 0777); 150 | sceIoMkdir("ux0:data/HBInjector/flags", 0777); 151 | 152 | psvDebugScreenClear( COLOR_BLACK ); 153 | snprintf(header, sizeof(header), "\n HBInjector v%s\n -----------------\n\n", version); 154 | printf("%s%s", 155 | header, 156 | " This will replace a system application with VitaShell\n" 157 | " Backups will be stored in ux0:data/HBInjector\n" 158 | " Icon layout will be reset\n" 159 | "\n" 160 | " The system application selected will not be able to be\n" 161 | " used for its original purpose until you restore it\n" 162 | "\n" 163 | " If you are looking to install this before updating Enso on\n" 164 | " 3.65, remember that when updating all system apps are\n" 165 | " reset to stock, including HBInjected Applications\n" 166 | "\n" 167 | " Press X to continue\n" 168 | " Press O to exit\n" 169 | ); 170 | 171 | while(1) switch (get_key()) { 172 | case SCE_CTRL_CROSS: 173 | one: 174 | psvDebugScreenClear( COLOR_BLACK ); 175 | 176 | title = TITLENAME(nTitle); 177 | titleid = TITLEID(nTitle); 178 | 179 | printf( 180 | " %s" 181 | " Select Title:\n\n" 182 | " < %s >\n\n" 183 | " Use the D-Pad to select a title\n" 184 | " Use the L and R buttons to change the mode\n" 185 | "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" 186 | " Mode: %s", 187 | header, title, mode == 0 ? "Inject" : "Restore" 188 | ); 189 | 190 | while(1) switch (get_key()) { 191 | case SCE_CTRL_CROSS: 192 | if (mode == 0) 193 | goto inject; 194 | else 195 | goto restore; 196 | break; 197 | 198 | case SCE_CTRL_RIGHT: 199 | nTitle = WRAPVAL(nTitle+1, 0, TITLEMAX); 200 | goto one; 201 | 202 | case SCE_CTRL_LEFT: 203 | nTitle = WRAPVAL(nTitle-1, 0, TITLEMAX); 204 | goto one; 205 | 206 | case SCE_CTRL_RTRIGGER: 207 | case SCE_CTRL_LTRIGGER: 208 | mode = !mode; 209 | goto one; 210 | } 211 | 212 | inject: 213 | psvDebugScreenClear( COLOR_BLACK ); 214 | 215 | printf( 216 | "%s" 217 | " Installing VitaShell to %s\n" 218 | " Press X to continue\n" 219 | " Press O to go cancel\n\n", 220 | header, title 221 | ); 222 | 223 | while (1) { 224 | switch(get_key()) { 225 | case SCE_CTRL_CROSS: 226 | break; 227 | case SCE_CTRL_CIRCLE: 228 | goto one; 229 | default: 230 | continue; 231 | } 232 | break; 233 | } 234 | 235 | snprintf(backupDir, sizeof(backupDir), "ux0:data/HBInjector/%s", titleid); 236 | snprintf(backupPath, sizeof(backupPath), "%s/eboot.bin", backupDir); 237 | snprintf(sysappPath, sizeof(sysappPath), "vs0:app/%s/eboot.bin", titleid); 238 | snprintf(flagPath, sizeof(flagPath), "ux0:data/HBInjector/flags/%s.flg", titleid); 239 | 240 | sceIoMkdir(backupDir, 0777); 241 | sceIoMkdir("ux0:data/HBInjector/appdb", 0777); 242 | SceUID fd; 243 | if (access(flagPath, F_OK) != -1) { 244 | printf( 245 | " VitaShell is already installed\n" 246 | " If not, delete %s\n" 247 | " Press any key to cancel", 248 | flagPath 249 | ); 250 | get_key(); 251 | goto one; 252 | } 253 | else { 254 | if (cp(backupPath, sysappPath) != 0) { 255 | printf( 256 | " Failed to backup %s\n" 257 | " Title likely doesn't exist\n" 258 | " Press any key to cancel", 259 | title 260 | ); 261 | get_key(); 262 | goto one; 263 | } 264 | else { 265 | vshIoUmount(0x300, 0, 0, 0); 266 | _vshIoMount(0x300, 0, 2, malloc(0x100)); 267 | printf(" Backing up %s...\n\n", title); 268 | } 269 | } 270 | fd = sceIoOpen("app0:VitaShell.bin", SCE_O_RDONLY, 0777); 271 | if (fd >= 0) { 272 | printf(" Copying VitaShell to System...\n"); 273 | begone(sysappPath); 274 | if (cp(sysappPath, "app0:VitaShell.bin") >= 0) 275 | printf(" Copied VitaShell to System\n\n"); 276 | else { 277 | printf( 278 | " Failed to copy VitaShell to system\n" 279 | " Likely due to vs0 not mounting correctly\n" 280 | " Press any key to reboot" 281 | ); 282 | get_key(); 283 | goto end; 284 | } 285 | } 286 | else { 287 | printf( 288 | " ERROR: VitaShell not found!\n" 289 | " Press any key to reboot" 290 | ); 291 | get_key(); 292 | goto end; 293 | } 294 | 295 | printf(" Rebuilding database...\n\n"); 296 | begone("ux0:data/HBInjector/appdb/app.db"); 297 | cp("ux0:data/HBInjector/appdb/app.db", "ur0:shell/db/app.db"); 298 | begone("ur0:shell/db/app.db"); 299 | WriteFile(flagPath, 0, 1); 300 | 301 | printf(" Press any key to reboot\n\n"); 302 | get_key(); 303 | goto end; 304 | 305 | restore: 306 | psvDebugScreenClear( COLOR_BLACK ); 307 | 308 | printf( 309 | "%s" 310 | " Restoring %s to system\n" 311 | " Press X to continue\n" 312 | " Press O to go cancel\n\n", 313 | header, title 314 | ); 315 | 316 | while (1) { 317 | switch(get_key()) { 318 | case SCE_CTRL_CROSS: 319 | break; 320 | case SCE_CTRL_CIRCLE: 321 | goto one; 322 | default: 323 | continue; 324 | } 325 | break; 326 | } 327 | 328 | snprintf(backupPath, sizeof(backupPath), "ux0:data/HBInjector/%s/eboot.bin", titleid); 329 | snprintf(sysappPath, sizeof(sysappPath), "vs0:app/%s/eboot.bin", titleid); 330 | snprintf(flagPath, sizeof(flagPath), "ux0:data/HBInjector/flags/%s.flg", titleid); 331 | 332 | vshIoUmount(0x300, 0, 0, 0); 333 | _vshIoMount(0x300, 0, 2, malloc(0x100)); 334 | 335 | sceIoMkdir("ux0:data/HBInjector/appdb", 0777); 336 | fd = sceIoOpen(backupPath, SCE_O_RDONLY, 0777); 337 | if (fd >= 0) { 338 | printf(" Restoring %s to system...\n", title); 339 | if (cp(sysappPath, backupPath) >= 0) 340 | printf(" Restored %s to system\n\n", title); 341 | else { 342 | printf( 343 | " Failed to restore %s to system\n" 344 | " Likely due to vs0 not mounting correctly\n" 345 | " Press any key to reboot", 346 | title 347 | ); 348 | get_key(); 349 | goto end; 350 | } 351 | } else { 352 | printf( 353 | " ERROR: %s backup not found!\n" 354 | " Likely due to vs0 not mounting correctly\n" 355 | " Press any key to reboot", 356 | title 357 | ); 358 | get_key(); 359 | goto end; 360 | } 361 | 362 | printf(" Rebuilding database...\n\n"); 363 | begone("ux0:data/HBInjector/appdb/app.db"); 364 | cp("ux0:data/HBInjector/appdb/app.db", "ur0:shell/db/app.db"); 365 | begone("ur0:shell/db/app.db"); 366 | begone(flagPath); 367 | 368 | printf(" Press any key to reboot\n\n"); 369 | get_key(); 370 | goto end; 371 | 372 | case SCE_CTRL_CIRCLE: 373 | sceKernelExitProcess(0); 374 | break; 375 | } 376 | end: 377 | scePowerRequestColdReset(); 378 | return 0; 379 | } 380 | -------------------------------------------------------------------------------- /sce_sys/icon0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emiyl/HBInjector/eef4fdc2326c541ec9b05d9b1f425776c929890d/sce_sys/icon0.png -------------------------------------------------------------------------------- /sce_sys/livearea/contents/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emiyl/HBInjector/eef4fdc2326c541ec9b05d9b1f425776c929890d/sce_sys/livearea/contents/bg.png -------------------------------------------------------------------------------- /sce_sys/livearea/contents/startup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emiyl/HBInjector/eef4fdc2326c541ec9b05d9b1f425776c929890d/sce_sys/livearea/contents/startup.png -------------------------------------------------------------------------------- /sce_sys/livearea/contents/template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bg.png 6 | 7 | 8 | 9 | startup.png 10 | 11 | 12 | 13 | 14 | 15 | HBInjector 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | by emiyl 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | v1.2.6 32 | 33 | 34 | 35 | 36 | --------------------------------------------------------------------------------