![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on Help with Byte writing system within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; I need some help with this... It currently didn't work... it's mostly based off the WAB Multi-loader :icon_wink Code: #include ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() ![]() Party at Las Noches!
|
I need some help with this... It currently didn't work... it's mostly based off the WAB Multi-loader :icon_wink
Code:
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspiofilemgr.h>
#include <pspgu.h>
#include <stdlib.h>
#include <string.h>
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
PSP_MODULE_INFO("FlashMod", 0, 1, 1);
int exist = 0;
char write_buffer[128*1024];
int exit_callback(int arg1, int arg2, void *common);
int CallbackThread(SceSize args, void *argp);
int SetupCallbacks(void);
void check(const char* zFile);
int main() {
int source, target;
int lFileLength;
char *szBuffer;
char szString1[] = { 0x10 };
SetupCallbacks();
source = sceIoOpen("ms0:/test.prx",PSP_O_RDONLY , 0);
sceIoLseek(source, 10, PSP_SEEK_SET);
lFileLength = sceIoLseek(source, 0, PSP_SEEK_END);
sceIoLseek(source, 10, PSP_SEEK_SET);
szBuffer = (char *)malloc(lFileLength);
target = sceIoOpen("ms0:/test.prx",PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
memcpy(szBuffer, szString1, 1);
sceIoWrite(target, szBuffer ,lFileLength);
sceIoClose(target);
sceIoClose(source);
sceKernelExitGame();
return 0;
}
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
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;
}
void check(const char* zFile){
int fd3;
fd3 = sceIoOpen(zFile, PSP_O_RDONLY, 0);
if(fd3 < 0) {
exist = 0;
}
else {
exist = 1;
}
sceIoClose(fd3);
}
__________________
|
|
|
|
|
|
#3 |
![]() ![]() Party at Las Noches!
|
Got it working
![]() Code:
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspiofilemgr.h>
#include <pspgu.h>
#include <stdlib.h>
#include <string.h>
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
PSP_MODULE_INFO("FlashMod", 0, 1, 1);
int exist = 0;
char write_buffer[128*1024];
int exit_callback(int arg1, int arg2, void *common);
int CallbackThread(SceSize args, void *argp);
int SetupCallbacks(void);
void check(const char* zFile);
int main() {
int source, target;
int lFileLength;
char *szBuffer;
char szString1[] = { 0x10 };
SetupCallbacks();
source = sceIoOpen("ms0:/test.prx",PSP_O_RDONLY , 0);
sceIoLseek(source, 0, PSP_SEEK_END);
lFileLength = sceIoLseek(source, 0, PSP_SEEK_END);
sceIoLseek(source, 0, PSP_SEEK_SET);
szBuffer = (char *)malloc(lFileLength);
target = sceIoOpen("ms0:/test2.prx",PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
memcpy(&szBuffer[10], szString1, 1);
sceIoWrite(target, szBuffer ,lFileLength);
sceIoClose(target);
sceIoClose(source);
sceIoRemove("ms0:/test.prx");
sceIoRename("ms0:/test2.prx", "ms0:/test.prx");
sceKernelExitGame();
return 0;
}
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
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;
}
void check(const char* zFile){
int fd3;
fd3 = sceIoOpen(zFile, PSP_O_RDONLY, 0);
if(fd3 < 0) {
exist = 0;
}
else {
exist = 1;
}
sceIoClose(fd3);
}
__________________
Last edited by IchigoKurosaki; 02-12-2006 at 08:58 AM.. |
|
|
|
![]() |
| Tags |
| byte , system , writing |
| Thread Tools | |
|
|