I believe its loaded in user mode because of the attribute.
here is the code i have now, its not done yet. i want to figure out whats going on in psn.
Code: Select all
#include <pspkernel.h>
#include <pspsdk.h>
#include <pspdebug.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <systemctrl.h>
#include <netinet/in.h>
#include <time.h>
#include "intr.h"
PSP_MODULE_INFO("550PSN", 0, 0x0, 0x0);
PSP_MAIN_THREAD_NAME("550PSN");
PSP_HEAP_SIZE_KB(128);
u32 orig_call1[8];
u32 orig_call2[8];
u32 orig_call3[8];
u32 orig_call4[8];
#define LUI(x) (0x3C190000 | (0x0000ffff & x))
#define ORI(x) (0x37390000 | (0x0000ffff & x))
#define JR 0x03200008
ssize_t	(*sceNetInetRecvFromOld)(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
ssize_t (*sceNetInetRecvOld)(int s, void *buf, size_t len, int flags);
ssize_t sceNetInetRecvFromNew(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen)
{
	char name[128];
	sprintf(name, "recDumps/RecvFrom_%d_%d.bin", (int)clock(), len);
	ssize_t res = sceNetInetRecvFromOld(s, buf, len, flags, from, fromlen);
	if(res<=0)
		return res;
	FILE *fp = fopen(name, "w");
	fwrite(buf, res, 1, fp);
	fclose(fp);
	return res;
}
ssize_t sceNetInetRecvNew(int s, void *buf, size_t len, int flags)
{
	char name[128];
	sprintf(name, "recDumps/Recv_%d_%d.bin", (int)clock(), len);
	ssize_t res = sceNetInetRecvOld(s, buf, len, flags);
	if(res<=0)
		return res;
	FILE *fp = fopen(name, "w");
	fwrite(buf, res, 1, fp);
	fclose(fp);
	return res;
}
ssize_t	(*sceNetInetSendOld)(int s, const void *buf, size_t len, int flags);
ssize_t	(*sceNetInetSendtoOld)(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
ssize_t	sceNetInetSendNew(int s, const void *buf, size_t len, int flags)
{
	char name[128];
	sprintf(name, "sendDumps/Send_%d_%d.bin", (int)clock(), len);
	ssize_t res = sceNetInetSendOld(s, buf, len, flags);
	if(res<=0)
		return res;
	FILE *fp = fopen(name, "w");
	fwrite(buf, res, 1, fp);
	fclose(fp);
	return res;
}
ssize_t	sceNetInetSendtoNew(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen)
{
	char name[128];
	sprintf(name, "sendDumps/SendTo_%d_%d.bin", (int)clock(), len);
	ssize_t res = sceNetInetSendtoOld(s, buf, len, flags, to, tolen);
	if(res<=0)
		return res;
	FILE *fp = fopen(name, "w");
	fwrite(buf, res, 1, fp);
	fclose(fp);
	return res;
}
void hook(u32 sfunc, u32 *orig_call, void* func)
{
	orig_call[0] = _lw(sfunc);
	orig_call[1] = _lw(sfunc+4);
	orig_call[2] = _lw(sfunc+8);
	orig_call[3] = _lw(sfunc+12);
	orig_call[4] = LUI((sfunc+16)>>16);
	orig_call[5] = ORI((sfunc+16));
	orig_call[6] = JR;
	orig_call[7] = 0;
	_sw(LUI(((u32)func>>16)),sfunc);
	_sw(ORI((u32)func),sfunc+4);
	_sw(JR,sfunc+8);
	_sw(0,sfunc+12);
}
int main(int argc, char **argv)
{
	//this will only work when psn is loaded for the first time. address will changes afterwords
	sceNetInetRecvFromOld = (void*)orig_call1;
	sceNetInetRecvOld = (void*)orig_call2;
	sceNetInetSendtoOld = (void*)orig_call3;
	sceNetInetSendOld = (void*)orig_call4;
	hook(0x0B8133CC, orig_call1, sceNetInetRecvFromNew);
	hook(0x0B8132F4, orig_call2, sceNetInetRecvNew);
	hook(0x0B812EC8, orig_call3, sceNetInetSendtoNew);
	hook(0x0B812DF4, orig_call4, sceNetInetSendNew);
	sceKernelDcacheWritebackAll();
	sceKernelSleepThread();
	return 0;
}
edit: updated again, all thats left is to study the dumps.