Ok, I've a big problem that i don't know how i must resolve... I'm making a little didactic homebrew that dump flash0 and 1 using vlf library but I've a problem: when i play the homebrew on my psp I receive an error that advices me that a library isn't found by psp... It's astonishing in my opinion... look at the code:
this is the main file:
Code: Select all
#include <pspkernel.h>
#include <stdlib.h>
#include <vlf.h>
#include <pspctrl.h>
#include "dump.h"
#include <pspumd.h>
#include "graphics.h"
PSP_MODULE_INFO("VLFTest", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(0);
void *ReadFileAllocEx(char *file, int seek, int size, int *retSize);
int done = 0;
int exit_callback(int arg1, int arg2, void *common)
{
done = 1;
return 0;
}
int CallbackThread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int app_main(int argc, char *argv[])
{
sceIoUnassign("flash0:");
sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0);
sceIoUnassign("flash1:");
sceIoAssign("flash1:", "lflash1:0,1", "flashfat1:", IOASSIGN_RDWR, NULL, 0);
SceCtrlLatch latch;
SetupCallbacks();
void *bi;
void *data = ReadFileAllocEx("flash0:/vsh/resource/01-12.bmp", 7*6176, 6176, NULL);
if (!data || vlfGuiSetBackgroundFileBuffer(data, 6176) < 0)
{
vlfGuiSetBackgroundPlane(0xFF000000);
}
if (data)
free(data);
vlfGuiCacheResource("system_plugin");
vlfGuiCacheResource("system_plugin_fg");
vlfGuiSetModelSystem();
vlfGuiAddBatteryIconSystem(&bi, 10*1000*1000);
vlfGuiAddClock();
while(!done)
{
vlfGuiDrawFrame();
sceCtrlReadLatch(&latch);
vlfGuiAddText(5, 5, "DumperXflash v.2,0 by blu_eye4\n");
vlfGuiAddText(5, 25, "Ringrazio fortemente il forum ps2dev.org per l'aiuto\n");
vlfGuiAddText(5, 45, "Voglio ringraziare fortemente il forum psp-ita.com\n");
vlfGuiAddText(5, 65, "Non solo per l'aiuto, ma anche perchè mi sopportano :)\n");
vlfGuiAddText(5, 85, "Grazie a tyrannid per gli esempi sdk\n");
vlfGuiAddText(5, 135, "Premere tasto X per dump flash0\n");
vlfGuiAddText(5, 155, "Premere tasto O per dump flash1\n");
if(latch.uiMake & PSP_CTRL_CIRCLE)
{
dump_filesystem("flash1:/", "ms0:/flash1");
vlfGuiAddText(235, 180, "Dump effettuato\n");
vlfGuiAddText(235, 190, "Premere [Home]per tornare nella XMB\n");
}
if(latch.uiMake & PSP_CTRL_CROSS)
{
dump_filesystem("flash0:/", "ms0:/flash0");
vlfGuiAddText(235, 180, "Dump effettuato\n");
vlfGuiAddText(235, 190, "Premere [Home]per tornare nella XMB\n");
}
}
sceKernelExitGame();
return 0;
}
this is my dump header (i know that there aren't my function :():
Code: Select all
#ifndef DUMP_H_INCLUDED
#define DUMP_H_INCLUDED
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspumd.h>
#include <vlf.h>
/* Build a path, append a directory slash if requested */
void build_path(char *output, const char *root, const char *path, int append)
{
while(*root != 0)
{
*output++ = *root++;
}
if(*(root-1) != '/')
{
*output++ = '/';
}
while(*path != 0)
{
*output++ = *path++;
}
if(append)
*output++ = '/';
*output++ = 0;
}
/* Define a write buffer */
char write_buffer[128*1024];
void write_file(const char *read_loc, const char *write_loc, const char *name)
{
int fdin;
int fdout;
char readpath[256];
char writepath[256];
void ScreenClear();
build_path(readpath, read_loc, name, 0);
build_path(writepath, write_loc, name, 0);
vlfGuiAddTextF(100, 100, "scrivendo %s\n", writepath);
ScreenClear();
fdin = sceIoOpen(readpath, PSP_O_RDONLY, 0777);
if(fdin >= 0)
{
int bytesRead = 1;
fdout = sceIoOpen(writepath, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
if(fdout < 0)
{
vlfGuiAddTextF(100, 100, "impossibile aprire %s\n", writepath);
}
bytesRead = sceIoRead(fdin, write_buffer, sizeof(write_buffer));
while((bytesRead > 0) && (fdout >= 0))
{
sceIoWrite(fdout, write_buffer, bytesRead);
bytesRead = sceIoRead(fdin, write_buffer, sizeof(write_buffer));
}
if(fdout >= 0)
{
sceIoClose(fdout);
}
if(fdin >= 0)
{
sceIoClose(fdin);
}
}
else
{
vlfGuiAddTextF(100, 100, "Couldn't open %s\n", readpath);
}
}
/* Dump a filing system */
void dump_filesystem(const char *root, const char *write_loc)
{
int dfd;
char next_root[256];
char next_write[256];
sceIoMkdir(write_loc, 0777);
dfd = sceIoDopen(root);
if(dfd > 0)
{
SceIoDirent dir;
while(sceIoDread(dfd, &dir) > 0)
{
if(dir.d_stat.st_attr & FIO_SO_IFDIR)
{
if(dir.d_name[0] != '.')
{
build_path(next_write, write_loc, dir.d_name, 0);
build_path(next_root, root, dir.d_name, 1);
dump_filesystem(next_root, next_write);
}
}
else
{
write_file(root, write_loc, dir.d_name);
}
}
sceIoDclose(dfd);
}
}
/* Dump memory */
void dump_memory(void)
{
int fd;
vlfGuiAddTextF(100, 100, "Dumping 28Megs from 0x8400000\n");
fd = sceIoOpen("ms0:/MEMORY.BIN", PSP_O_CREAT | PSP_O_TRUNC | PSP_O_WRONLY, 0777);
if(fd >= 0)
{
sceIoWrite(fd, (void *) 0x8400000, 28*1024*1024);
sceIoClose(fd);
}
}
/* Dumps flash rom in bits */
void dump_flashrom(int lower)
{
int fdin;
int fdout;
fdin = sceIoOpen("lflash:", PSP_O_RDONLY, 0777);
if(fdin > 0)
{
int i;
int bytes_read;
if(lower)
{
fdout = sceIoOpen("ms0:/flash_lower.bin", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
}
else
{
fdout = sceIoOpen("ms0:/flash_upper.bin", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
}
if(fdout > 0)
{
for(i = 0; i < ((16 * 1024 * 1024) / sizeof(write_buffer)); i++)
{
bytes_read = sceIoRead(fdin, write_buffer, sizeof(write_buffer));
if(lower)
{
sceIoWrite(fdout, write_buffer, bytes_read);
}
}
if(!lower)
{
for(i = 0; i < ((16 * 1024 * 1024) / sizeof(write_buffer)); i++)
{
bytes_read = sceIoRead(fdin, write_buffer, sizeof(write_buffer));
sceIoWrite(fdout, write_buffer, bytes_read);
}
}
sceIoClose(fdout);
}
sceIoClose(fdin);
}
else
{
vlfGuiAddText(100, 100, "Cannot open lflash: device\n");
sceKernelSleepThread();
}
}
#endif // DUMP_H_INCLUDED
Code: Select all
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdisplay_kernel.h>
#include <pspctrl.h>
#include <pspumd.h>
#include <pspdebug.h>
PSP_MODULE_INFO("myLib", 0x1006, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
u32 k1;
void ScreenClear(){
k1 = pspSdkSetK1(0);
void pspDebugScreenClear(void);
pspDebugScreenClear();
pspSdkSetK1(k1);
}
void CheckUmd(){
k1 = pspSdkSetK1(0);
int sceUmdCheckMedium(void);
sceUmdCheckMedium();
pspSdkSetK1(k1);
}
int padControls(){
k1 = pspSdkSetK1(0);
sceCtrlReadBufferPositive(SceCtrlData *pad_data, int count);
pspSdkSetK1(k1);
return 0;
}
int module_start(SceSize args, void *argp)
{
return 0;
}
int module_stop()
{
return 0;
}
where do I fail? thanks a lot for your help :) ...