Awesome! It's working! Now I can manipulate frmbfr address!
I've done a little test in which I always set frmbfr addr to 0x4000000, and here is what I've got:
Home menu doesn't appear! I can see that it tries to set frmbfr to 882ab500, but my hook doesn't allow this thing :p
But as we aren't hooking width and psm, it sets it and picture becomes ugly
So I suppose there are another low function which allow such things
Maybe it is sceDmacplusLcdcSetFormat? I'm not sure about parameters which it receives
Maybe (int psm,int displaywidth,int frmbfrwidth)?
And as nid's changed I'm not sure about it too :) 0x1B9DA332 ?
I've tried to hook it, but Home menu still change it :( I suppose I've made a mistake somewhere
here is my code:
Code: Select all
#include <pspkernel.h>
#include <string.h>
#include <systemctrl.h>
PSP_MODULE_INFO("FuSa", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
PSP_MAIN_THREAD_STACK_SIZE_KB(0);
#define J_OPCODE 0x08000000
#define NOP 0x00000000
#define REDIRECT_FUNCTION(a, f) _sw(J_OPCODE | (((u32)(f) >> 2) & 0x03ffffff), a); _sw(NOP, a+4);
struct PspModuleImport
{
const char *name;
unsigned short version;
unsigned short attribute;
unsigned char entLen;
unsigned char varCount;
unsigned short funcCount;
u32 *fnids;
u32 *funcs;
u32 *vnids;
u32 *vars;
} __attribute__((packed));
int (* sceDmacplusLcdcSetBaseAddr)(void *addr);
int (* sceDmacplusLcdcSetFormat)(int *pfrmt,int *dwidth,int *fwidth);
int MySetBaseAddr(void *addr)
{
char buf[64];
sprintf(buf,"X = %p",addr);
myPrintf(1,1,buf,0xFFFFFF,0xFFFFFF);
return sceDmacplusLcdcSetBaseAddr(0x4000000);
}
int MySetFormat(int pfrmt,int dwidth,int fwidth)
{
char buf[64];
sprintf(buf,"X = %d %d %d",pfrmt,dwidth,fwidth);
myPrintf(5,5,buf,0xFFFFFF,0xFFFFFF);
return sceDmacplusLcdcSetFormat(0,480,768);
}
u32 FindImport(char *prxname, char *importlib, u32 nid)
{
SceModule2 *pMod;
void *stubTab;
int stubLen;
pMod = sceKernelFindModuleByName(prxname);
if (!pMod)
return 0;
pMod = sceKernelFindModuleByUID(pMod->modid);
if(pMod != NULL)
{
int i = 0;
stubTab = pMod->stub_top;
stubLen = pMod->stub_size;
while(i < stubLen)
{
int count;
struct PspModuleImport *pImp = (struct PspModuleImport *) (stubTab + i);
if(pImp->funcCount > 0)
{
for(count = 0; count < pImp->funcCount; count++)
{
if (pImp->name)
{
if (strcmp(pImp->name, importlib) == 0)
{
if (pImp->fnids[count] == nid)
{
return (u32)&pImp->funcs[count*2];
}
}
}
}
}
i += (pImp->entLen * 4);
}
}
return 0;
}
int module_start(SceSize args, void *argp)
{
sceDmacplusLcdcSetBaseAddr = (void *)sctrlHENFindFunction("sceLowIO_Driver", "sceDmacplus_driver", 0x86106AD9);
u32 import_address = FindImport("sceDisplay_Service", "sceDmacplus_driver", 0x86106AD9);
REDIRECT_FUNCTION(import_address, (u32)MySetBaseAddr);
sceKernelDcacheWritebackAll();
sceKernelIcacheClearAll();
sceDmacplusLcdcSetFormat = (void *)sctrlHENFindFunction("sceLowIO_Driver", "sceDmacplus_driver", 0x1B9DA332);
u32 import_address2 = FindImport("sceDisplay_Service", "sceDmacplus_driver", 0x1B9DA332);
REDIRECT_FUNCTION(import_address2, (u32)MySetFormat);
sceKernelDcacheWritebackAll();
sceKernelIcacheClearAll();
return 0;
sceKernelExitDeleteThread(0);
}
int module_stop(SceSize args, void *argp)
{
return 0;
}
Question in advance:
I also tried to write directly to vram - result: game crashes :(
look at this code:
Code: Select all
int MySetBaseAddr(void *addr)
{
u32* vram = (u32*)addr;
short x;
for (x = 0; x < 480; x++) vram[x]=0xFFFFFFFF;
return sceDmacplusLcdcSetBaseAddr(addr);
}
What's happening?