QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

Help with Byte writing system

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 ...

Reply
 
LinkBack Thread Tools
Old 02-12-2006, 07:34 AM   #1

Party at Las Noches!
 
IchigoKurosaki's Avatar
 
Join Date: Jun 2005
Location: Florida
Posts: 1,648
Trader Feedback: 0
Default Help with Byte writing system

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);
}
__________________
.:Nobis Development Group:.
.:Personal Portfolio:.

Playstation Portable - PSP1001 - 3.90 M33-2
IchigoKurosaki is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-12-2006, 08:22 AM   #2
 
Join Date: Jan 2006
Posts: 923
Trader Feedback: 0
Default

EDIT: NVM, i got it
Flamingwolf is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-12-2006, 08:32 AM   #3

Party at Las Noches!
 
IchigoKurosaki's Avatar
 
Join Date: Jun 2005
Location: Florida
Posts: 1,648
Trader Feedback: 0
Default

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);
}
THIS CODE WILL BRICK YOUR PSP IF USED ON FLASH....
__________________
.:Nobis Development Group:.
.:Personal Portfolio:.

Playstation Portable - PSP1001 - 3.90 M33-2

Last edited by IchigoKurosaki; 02-12-2006 at 08:58 AM..
IchigoKurosaki is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
byte , system , writing

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 11:13 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us