示例#1
0
文件: hook.c 项目: Rolen47/prxpatch
void api_hook_import_syscall(unsigned int address, void * function) {
    //valid address
    if (address) {
        //asm jr $ra
        *(unsigned int *) (address) = 0x03E00008;

        //asm syscall #
        *(unsigned int *) (address + 4) = (((sceKernelQuerySystemCall(function)) << 6) | 12);

        //flush cache
        sceKernelDcacheWritebackInvalidateRange((const void *) address, 8);
        sceKernelIcacheInvalidateRange((const void *) address, 8);
    }
}
示例#2
0
static int place_syscall_stub(void* func, void *addr)
{
	u32 syscall_num;
	extern u32 sceKernelQuerySystemCall(void *func);

	syscall_num = sceKernelQuerySystemCall(func);

	if(syscall_num == (u32)-1) {
		return -1;
	}

	_sw(0x03E00008, (u32)addr);
	_sw(((syscall_num<<6)|12), (u32)(addr+4));

	return 0;
}