Permalink
Browse files

Initial commmit

  • Loading branch information...
0 parents commit b699740caee696a5a7e6028b94c06e9255217f2a @root670 committed Apr 5, 2015
@@ -0,0 +1,7 @@
+[CheatDevicePS2]
+database = cb10.cdb
+boot1 = mass:BOOT/BOOT.ELF
+boot2 = mass:BOOT/ESR.ELF
+boot3 = mc0:BOOT/BOOT.ELF
+boot4 = mc1:BOOT/BOOT.ELF
+boot5 = rom:OSDSYS
Oops, something went wrong.
@@ -0,0 +1,79 @@
+#
+# Cheat Device for PlayStation 2
+# by root670
+#
+
+EE_BIN = cheatdevice.elf
+
+# Helper libraries
+OBJS += libraries/upng.o
+OBJS += libraries/miniz.o
+OBJS += libraries/ini.o
+
+# Main
+OBJS += util.o
+OBJS += startgame.o
+OBJS += database.o
+OBJS += cheats.o
+OBJS += graphics.o
+OBJS += storage.o
+OBJS += menus.o
+OBJS += settings.o
+
+# Graphic resources
+OBJS += background_png.o
+OBJS += check_png.o
+OBJS += gamepad_png.o
+OBJS += cube_png.o
+OBJS += cogs_png.o
+
+# Engine
+OBJS += engine_erl.o
+
+# Bootstrap ELF
+OBJS += bootstrap_elf.o
+
+GSKIT = $(PS2DEV)/gsKit
+
+EE_LIBS += -lpad -lgskit_toolkit -lgskit -ldmakit -lc -lkernel -lmc -lpatches -lerl -lcdvd
+EE_LDFLAGS += -L$(PS2SDK)/ee/lib -L$(GSKIT)/lib -s
+EE_INCS += -I$(GSKITSRC)/ee/gs/include -I$(GSKITSRC)/ee/dma/include -I$(GSKITSRC)/ee/toolkit/include
+
+IRX_OBJS += usbd_irx.o usb_mass_irx.o iomanX_irx.o
+
+EE_OBJS = $(IRX_OBJS) $(OBJS) main.o
+
+all: modules main
+
+modules:
+ # IRX Modules
+ bin2o resources/iomanX.irx iomanX_irx.o _iomanX_irx
+ bin2o resources/usbd.irx usbd_irx.o _usbd_irx
+ bin2o resources/usb_mass.irx usb_mass_irx.o _usb_mass_irx
+
+ # Graphics
+ bin2o resources/background.png background_png.o _background_png
+ bin2o resources/check.png check_png.o _check_png
+ bin2o resources/gamepad.png gamepad_png.o _gamepad_png
+ bin2o resources/cube.png cube_png.o _cube_png
+ bin2o resources/cogs.png cogs_png.o _cogs_png
+
+ # Engine
+ bin2o resources/engine.erl engine_erl.o _engine_erl
+
+ # Bootstrap
+ cd bootstrap && $(MAKE)
+ bin2o bootstrap/bootstrap.elf bootstrap_elf.o _bootstrap_elf
+
+main: $(EE_BIN)
+ rm -f *.o
+ rm -f libraries/*.o
+ rm -f bootstrap/*.elf bootstrap/*.o
+
+clean:
+ rm -f *.o *.elf
+ rm -f libraries/*.o
+ rm -f bootstrap/*.elf
+
+include $(PS2SDK)/samples/Makefile.pref
+include $(PS2SDK)/samples/Makefile.eeglobal
@@ -0,0 +1,41 @@
+Cheat Device for PS2
+====================
+Cheat Device is a game enhancer for PlayStation 2 games, similar to Action
+Replay or CodeBreaker. It supports booting retail, disc based games as well as
+ELF files (such as OpenPS2Loader, ESR, etc.) stored on a flashdrive or memory
+card. Cheat databases are stored in files created with makecdb, which will
+convert cheat lists using a this simple format:
+
+"Game Name"
+Cheat 1
+27654321 12345678
+Cheat 2
+12345678 98765432
+
+# Settings File
+Settings are stored in an ini file named "CheatDevicePS2.ini", which needs to
+be located in the directory Cheat Device is run from. The cheat database path
+and additional boot paths are set here. See the included settings file for an
+example.
+
+# Features
+* Easy to navigate menu system similar to CodeBreaker
+* Supports retail discs and loader ELFs
+* Fast loading of large cheat lists
+* Powered by ps2rd's powerful cheat engine
+
+# Compiling
+Compile Cheat Device
+ cd cheatdeviceps2
+ make all
+
+Compile makecdb
+ cd cheatdeviceps2/makecdb
+ make all
+
+# License
+Cheat Device is not licensed, sponsored, endorsed by Sony Computer
+Entertainment, Inc. This program comes with ABSOLUTELY NO WARRANTY. Cheat
+Device is licensed under GNU GPL-3. See LICENSE for details. The cheat
+engine is from ps2rd by Mathias Lafedlt. The bootstrap is based on EE_CORE
+from OpenPS2Loader.
@@ -0,0 +1,28 @@
+EE_BIN = bootstrap.elf
+EE_OBJS = main.o
+
+#EE_LDFLAGS = -s -Ttext 0x00090000
+#EE_LDFLAGS = -s -Ttext 0x01900000
+#EE_LDFLAGS = -s -Ttext 0x000F3000
+#EE_LIBS += -lkernel -lpatches -lerl
+
+EE_CFLAGS := -mips3 -ffreestanding -fno-builtin -G0 \
+ -fshort-double -mlong64 -mhard-float -mno-abicalls -O2 -EL -Wall \
+ $(EE_INCS) $(EE_CFLAGS)
+
+EE_ASFLAGS := -EL -G0 $(EE_ASFLAGS)
+
+LOADADDR = 0x90000
+STACKADDR = 0xA8000
+STACKSIZE = 0x04000
+
+LDPARAMS := -Wl,--defsym -Wl,_stack_size=$(STACKSIZE) -Wl,--defsym -Wl,_stack=$(STACKADDR)
+
+EE_LDFLAGS += -Wl,-Ttext -Wl,$(LOADADDR) -s $(LDPARAMS)
+
+all: $(EE_BIN)
+ ee-strip -s -d -R .mdebug.eabi64 -R .reginfo -R .comment $(EE_BIN)
+ rm -f *.o *.s
+
+include $(PS2SDK)/samples/Makefile.pref
+include $(PS2SDK)/samples/Makefile.eeglobal
@@ -0,0 +1,11 @@
+The following is no longer valid! The bootstrap process has been changed...
+
+Run this with the path to an ELF to run as an argument.
+
+Basic process:
+1. loop through code list
+ - copy hooks to hooklist and regular codes to codelist
+ - set numhooks & numcodes
+2. hook SetupThread
+3. hook LoadExecPS2
+4. LoadExecPS2(ELF path, 0, NULL);
@@ -0,0 +1,173 @@
+#include <tamtypes.h>
+#include <kernel.h>
+#include <syscallnr.h>
+#include <ee_regs.h>
+#include <ps2lib_err.h>
+#include <ps2_reg_defs.h>
+#include <loadfile.h>
+#include <sifrpc.h>
+#include <string.h>
+#include <stdio.h>
+
+int (*get_num_hooks)(void);
+int (*add_hook)(u32 addr, u32 val);
+
+/* Debug colors. Now NTSC Safe! At least I believe they are... */
+int red = 0x1010B4; /* RED: Opening elf */
+int green = 0x10B410; /* GREEN: Reading elf */
+int blue = 0xB41010; /* BLUE: Installing elf header */
+int yellow = 0x10B4B4; /* YELLOW: ExecPS2 */
+int orange = 0x0049E6; /* ORANGE: SifLoadElf */
+int pink = 0xB410B4; /* PINK: Launching OSDSYS */
+int white = 0xEBEBEB; /* WHITE: Failed to launch OSDSYS */
+int purple = 0x801080; /* PURPLE: Launching uLaunchELF */
+int black = 0x101010;
+
+#define ELF_MAGIC 0x464c457f
+#define ELF_PT_LOAD 1
+
+int g_argc;
+char *g_argv[16];
+#define GS_BGCOLOUR *((vu32*)0x120000e0)
+static char ElfPath[0x30];
+
+struct _lf_elf_load_arg {
+ union
+ {
+ u32 epc;
+ int result;
+ } p;
+ u32 gp;
+ char path[LF_PATH_MAX];
+ char secname[LF_ARG_MAX];
+} __attribute__((aligned (16)));
+
+typedef struct {
+ u8 ident[16];
+ u16 type;
+ u16 machine;
+ u32 version;
+ u32 entry;
+ u32 phoff;
+ u32 shoff;
+ u32 flags;
+ u16 ehsize;
+ u16 phentsize;
+ u16 phnum;
+ u16 shentsize;
+ u16 shnum;
+ u16 shstrndx;
+} elf_header_t;
+
+typedef struct {
+ u32 type;
+ u32 offset;
+ void *vaddr;
+ u32 paddr;
+ u32 filesz;
+ u32 memsz;
+ u32 flags;
+ u32 align;
+} elf_pheader_t;
+
+/* From NetCheat */
+void MyLoadElf(char *elfpath)
+{
+ ResetEE(0x7f);
+
+ /* Clear user memory */
+ int i;
+ for (i = 0x00100000; i < 0x02000000; i += 64) {
+ __asm__ (
+ "\tsq $0, 0(%0) \n"
+ "\tsq $0, 16(%0) \n"
+ "\tsq $0, 32(%0) \n"
+ "\tsq $0, 48(%0) \n"
+ :: "r" (i)
+ );
+ }
+
+ /* Clear scratchpad memory */
+ memset((void*)0x70000000, 0, 16 * 1024);
+
+ char *args[1];
+ t_ExecData sifelf;
+ int r;
+
+ memset(&sifelf, 0, sizeof(t_ExecData));
+
+ elf_header_t boot_header;
+ elf_pheader_t boot_pheader;
+ int size = 0, fd = 0;
+ fioInit();
+ GS_BGCOLOUR = red; /* RED: Opening elf */
+ fd = fioOpen(elfpath, O_RDONLY); //Open the elf
+ if (fd < 0) { fioClose(fd); return; } //If it doesn't exist, return
+
+ GS_BGCOLOUR = blue;
+
+ if(read(fd, &boot_header, sizeof(elf_header_t)) != sizeof(elf_header_t)) {
+ close(fd);
+ }
+
+ GS_BGCOLOUR = white;
+
+ /* check ELF magic */
+ if ((*(u32*)boot_header.ident) != ELF_MAGIC) {
+ close(fd);
+ }
+
+ /* copy loadable program segments to RAM */
+ for (i = 0; i < boot_header.phnum; i++) {
+ lseek(fd, boot_header.phoff+(i*sizeof(elf_pheader_t)), SEEK_SET);
+ read(fd, &boot_pheader, sizeof(elf_pheader_t));
+
+ if (boot_pheader.type != ELF_PT_LOAD)
+ continue;
+
+ lseek(fd, boot_pheader.offset, SEEK_SET);
+ read(fd, boot_pheader.vaddr, boot_pheader.filesz);
+
+ if (boot_pheader.memsz > boot_pheader.filesz)
+ memset(boot_pheader.vaddr + boot_pheader.filesz, 0,
+ boot_pheader.memsz - boot_pheader.filesz);
+
+ }
+
+ close(fd);
+
+ // Booting part
+ GS_BGCOLOUR = yellow; /* YELLOW: ExecPS2 */
+
+ /* IOP reboot routine from ps2rd */
+ SifInitRpc(0);
+
+ while (!SifIopReset("rom0:UDNL rom0:EELOADCNF", 0))
+ ;
+ while (!SifIopSync())
+ ;
+
+ /* exit services */
+ fioExit();
+ SifExitIopHeap();
+ SifLoadFileExit();
+ SifExitRpc();
+ SifExitCmd();
+
+ FlushCache(0);
+ FlushCache(2);
+
+ args[0] = elfpath;
+ ExecPS2((u32*)boot_header.entry, 0, 1, args);
+}
+
+/*
+argv[0] = elf path
+*/
+
+int main(int argc, char *argv[])
+{
+ MyLoadElf(argv[0]);
+
+ return 0;
+}
Oops, something went wrong.

0 comments on commit b699740

Please sign in to comment.