Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleatlast committed Mar 27, 2018
0 parents commit 7aa2ce1
Show file tree
Hide file tree
Showing 31 changed files with 3,192 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.o
*.elf
*.prx
np9660_patch.h
29 changes: 29 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
v6.3:
Fixed the crashes when resuming from sleep.

v6.2:
Creates ms0:/PSP/LICENSE folder if it's missing.

v6.1:
Fixed the issue from v6 with launching ISO/CSO games from the XMB.

v6:
Added a patch to allow boot mode 2 (BOOTABLE in PARAM.SFO) to run.

v5.1:
Fixed some checks to prevent this plugin from running on non-PSN games (crashed on ISO/CSO games).

v5:
Fixed issues with 6.20 compatibility.

v4:
Added 6.20 compatibility and support for licensed DLC (no SPRX support yet).

v3:
Added support for licensed game software manuals in the VSH.

v2:
Added a patch to create a fake flash2:/act.dat for PSPs without one.

v1:
Initial release.
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ifeq ($(CONFIG_620), 1)
FW_FLAG = CONFIG_620=1
endif

ifeq ($(CONFIG_660), 1)
FW_FLAG = CONFIG_660=1
endif

ifeq ($(CONFIG_661), 1)
FW_FLAG = CONFIG_661=1
endif

all:
@cd np9660_patch; make $(FW_FLAG); \
bin2c npdrm_free.prx np9660_patch.h np9660_patch; \
mv np9660_patch.h ../loader/src/np9660_patch.h;
@cd loader; make $(FW_FLAG); mv npdrm_free.prx ../npdrm_free.prx;

clean:
@cd np9660_patch; make clean;
@cd loader; make clean;
rm -rf npdrm_free.prx
12 changes: 12 additions & 0 deletions README.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Place npdrm_free.prx in ms0:/seplugins/ and enable it in vsh.txt.
Restart VSH, now you can launch any official EBOOT.PBP without a license.

If a license is not found then a fake one will be created, otherwise the official license will be left alone.

If flash2:/act.dat is not found then a fake one will be created.

To allow PC Engine games to run, either enable the nodrm engine in Pro CFW or install nploader.prx and enable in game.txt.

Game software manuals that require a license will now work without a license using this plugin enabled in vsh.txt.

Licensed DLC should now work and should now be 6.20 compatible.
674 changes: 674 additions & 0 deletions gpl-3.0.txt

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions loader/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
TARGET = npdrm_free
OBJS = src/main.o src/exports.o src/lib.o src/setk1.o src/imports.o src/pgd.o

LIBDIR = libs
LIBS = -lpspsystemctrl_kernel -lpspkubridge

CFLAGS = -Wall -Wextra -O2 -G0
ASFLAGS = $(CFLAGS)

USE_KERNEL_LIBC = 1
USE_KERNEL_LIBS = 1

ifeq ($(CONFIG_620), 1)
CFLAGS += -DCONFIG_620=1
PSP_FW_VERSION=620
endif

ifeq ($(CONFIG_660), 1)
CFLAGS += -DCONFIG_660=1
PSP_FW_VERSION=660
endif

ifeq ($(CONFIG_661), 1)
CFLAGS += -DCONFIG_661=1
PSP_FW_VERSION=661
endif

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.mak
Binary file added loader/libs/libpspkubridge.a
Binary file not shown.
Binary file added loader/libs/libpspsystemctrl_kernel.a
Binary file not shown.
17 changes: 17 additions & 0 deletions loader/src/exports.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PSP_BEGIN_EXPORTS

PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_FUNC(module_start)
PSP_EXPORT_FUNC(module_stop)
PSP_EXPORT_VAR(module_info)
PSP_EXPORT_END

PSP_EXPORT_START(sceNpDrmFree, 0x0011, 0x4001)
PSP_EXPORT_FUNC(sceNpDrmFreeEdataSetupKey)
PSP_EXPORT_FUNC(sceNpDrmFreeEdataGetDataSize)
PSP_EXPORT_FUNC(sceNpDrmFreeOpen)
PSP_EXPORT_FUNC(sceNpDrmFreeRead)
PSP_EXPORT_FUNC(vshCheckBootable)
PSP_EXPORT_END

PSP_END_EXPORTS
42 changes: 42 additions & 0 deletions loader/src/imports.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.set noreorder

#include "pspstub.s"

STUB_START "SystemCtrlForKernel",0x00090000,0x00020005
STUB_FUNC 0x1C90BECB,sctrlHENSetStartModuleHandler
STUB_FUNC 0xCE0A654E,sctrlHENLoadModuleOnReboot
STUB_END

STUB_START "StdioForKernel",0x00010000,0x00010005
STUB_FUNC 0xCAB439DF,printf
STUB_END

STUB_START "scePspNpDrm_driver",0x00090000,0x00020005
STUB_FUNC 0x08D98894,sceNpDrmEdataSetupKey
STUB_FUNC 0x219EF5CC,sceNpDrmEdataGetDataSize
STUB_END

STUB_START "InterruptManagerForKernel",0x00090000,0x00020005
STUB_FUNC 0xF153B371,sceKernelQuerySystemCall_660
STUB_FUNC 0xAC9306F0,sceKernelQuerySystemCall_620
STUB_END

STUB_START "sceAmctrl_driver",0x00090000,0x00090005
STUB_FUNC 0x0785C974,sceDrmBBCipherUpdate
STUB_FUNC 0x1CCB66D2,sceDrmBBCipherInit
STUB_FUNC 0x525B8218,sceDrmBBMacInit
STUB_FUNC 0x58163FBE,sceDrmBBMacUpdate
STUB_FUNC 0x9227EA79,sceAmctrl_driver_9227EA79
STUB_FUNC 0x9951C50F,sceDrmBBCipherFinal
STUB_FUNC 0xE04ADD4C,sceAmctrl_driver_E04ADD4C
STUB_FUNC 0xEF95A213,sceDrmBBMacFinal
STUB_FUNC 0xF5186D8E,sceDrmBBMacFinal2
STUB_END

STUB_START "semaphore",0x00090000,0x00010005
STUB_FUNC 0x4C537C72,sceUtilsBufferCopyWithRange
STUB_END

STUB_START "SysMemUserForUser",0x00090000,0x00010005
STUB_FUNC 0x3FC9AE6A,sceKernelDevkitVersionForUser
STUB_END
88 changes: 88 additions & 0 deletions loader/src/lib.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright (C) 2014 qwikrazor87
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <pspkernel.h>
#include <psputilsforkernel.h>
#include <string.h>
#include "lib.h"

void ClearCaches(void)
{
sceKernelDcacheWritebackInvalidateAll();
sceKernelIcacheInvalidateAll();
}

u32 FindTextAddrByName(const char *module)
{
u32 kaddr;
for (kaddr = 0x88000000; kaddr < 0x88400000; kaddr += 4) {
if (strcmp((const char *)kaddr, module) == 0) {
if ((*(u32*)(kaddr + 0x64) == *(u32*)(kaddr + 0x78)) && \
(*(u32*)(kaddr + 0x68) == *(u32*)(kaddr + 0x88))) {
if (*(u32*)(kaddr + 0x64) && *(u32*)(kaddr + 0x68))
return *(u32*)(kaddr + 0x64);
}
}
}
return 0;
}

u32 FindExport(const char *module, const char *library, u32 nid)
{
u32 addr = FindTextAddrByName(module);

if (addr) {
u32 maxaddr = 0x88400000;

if (addr >= 0x08800000 && addr < 0x0A000000)
maxaddr = 0x0A000000;
else if (addr >= 0x08400000 && addr < 0x08800000)
maxaddr = 0x08800000;

for (; addr < maxaddr; addr += 4) {
if (strcmp(library, (const char *)addr) == 0) {
u32 libaddr = addr;

while (*(u32*)(addr -= 4) != libaddr);

u32 exports = (u32)(*(u16*)(addr + 10) + *(u8*)(addr + 9));
u32 jump = exports * 4;

addr = *(u32*)(addr + 12);

while (exports--) {
if (*(u32*)addr == nid)
return *(u32*)(addr + jump);

addr += 4;
}

return 0;
}
}
}

return 0;
}

void fillvram(u32 color)
{
u32 vram;

for (vram = 0x44000000; vram < 0x44200000; vram += 4)
_sw(color, vram);
}
72 changes: 72 additions & 0 deletions loader/src/lib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2014 qwikrazor87
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef LIB_H_
#define LIB_H_

#include <psptypes.h>

void fillvram(u32 color);

void ClearCaches(void);

u32 FindTextAddrByName(const char *module);
u32 FindExport(const char *module, const char *library, u32 nid);
u32 pspSdkSetK1(u32 k1);

#define U_EXTRACT_IMPORT(x) ((((u32)_lw((u32)x)) & ~0x08000000) << 2)
#define K_EXTRACT_IMPORT(x) (((((u32)_lw((u32)x)) & ~0x08000000) << 2) | 0x80000000)
#define U_EXTRACT_CALL(x) ((((u32)_lw((u32)x)) & ~0x0C000000) << 2)
#define K_EXTRACT_CALL(x) (((((u32)_lw((u32)x)) & ~0x0C000000) << 2) | 0x80000000)

#define MAKE_JUMP(f) (0x08000000 | (((u32)(f) >> 2) & 0x03FFFFFF))
#define MAKE_CALL(f) (0x0C000000 | (((u32)(f) >> 2) & 0x03FFFFFF))

#define MAKE_JUMP_PATCH(a, f) _sw(0x08000000 | (((u32)(f) & 0x0FFFFFFC) >> 2), a);

#define HIJACK_FUNCTION(a, f, ptr) \
{ \
u32 func = a; \
static u32 patch_buffer[3]; \
_sw(_lw(func), (u32)patch_buffer); \
_sw(_lw(func + 4), (u32)patch_buffer + 8);\
MAKE_JUMP_PATCH((u32)patch_buffer + 4, func + 8); \
_sw(0x08000000 | (((u32)(f) >> 2) & 0x03FFFFFF), func); \
_sw(0, func + 4); \
ptr = (void *)patch_buffer; \
}

int printf(const char *fmt, ...);

typedef struct {
u16 label_offset;
u16 type;
u32 size;
u32 size_padded;
u32 data_offset;
} SFOtable;

typedef struct {
u32 magic;
u32 version;
u32 label;
u32 data;
int entries;
SFOtable sfotable[];
} SFO;

#endif /* LIB_H_ */
Loading

0 comments on commit 7aa2ce1

Please sign in to comment.