forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to write a Hex value in a file...

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Red_Squirrel



Joined: 03 Oct 2007
Posts: 11

PostPosted: Thu Jan 17, 2008 1:32 am    Post subject: How to write a Hex value in a file... Reply with quote

Sorry for my bad english, I'm italian ^^'

I want to write a Hex value in a file.
I already made a function to hex modify a file, and I use this code to write in a precious offset:
Code:
int pos = sceIoLseek(fd, 0x46A8, SEEK_SET);
               sceIoWrite(fd, i1, sizeof(i1));


But it writes an ASCII value (i1 is a char value) in the offset position...
I need to modfy the hex value of the offset and not the ASCII one.

Please, could anyone help me? :(

EDIT: the Hex value that i would to write in the offset is "08".
Back to top
View user's profile Send private message Send e-mail
Alberto



Joined: 12 Feb 2007
Posts: 57
Location: Sofia

PostPosted: Thu Jan 17, 2008 2:25 am    Post subject: Re: How to write a Hex value in a file... Reply with quote

Red_Squirrel wrote:

I want to write a Hex value in a file.
I already made a function to hex modify a file, and I use this code to write in a precious offset:
Code:
int pos = sceIoLseek(fd, 0x46A8, SEEK_SET);
               sceIoWrite(fd, i1, sizeof(i1));


But it writes an ASCII value (i1 is a char value) in the offset position...
I need to modfy the hex value of the offset and not the ASCII one.

Please, could anyone help me? :(

EDIT: the Hex value that i would to write in the offset is "08".


and what does i1 contain, as a char??? you should do i1 = 0x08 before writing it to the file, I assume...
Back to top
View user's profile Send private message
Red_Squirrel



Joined: 03 Oct 2007
Posts: 11

PostPosted: Thu Jan 17, 2008 3:11 am    Post subject: Reply with quote

Usually i1 contains letters, like "A", "B", "C" or other char as "?", "!", "("...
Back to top
View user's profile Send private message Send e-mail
Red_Squirrel



Joined: 03 Oct 2007
Posts: 11

PostPosted: Thu Jan 17, 2008 3:37 am    Post subject: Re: How to write a Hex value in a file... Reply with quote

Alberto wrote:
Red_Squirrel wrote:

I want to write a Hex value in a file.
I already made a function to hex modify a file, and I use this code to write in a precious offset:
Code:
int pos = sceIoLseek(fd, 0x46A8, SEEK_SET);
               sceIoWrite(fd, i1, sizeof(i1));


But it writes an ASCII value (i1 is a char value) in the offset position...
I need to modfy the hex value of the offset and not the ASCII one.

Please, could anyone help me? :(

EDIT: the Hex value that i would to write in the offset is "08".


and what does i1 contain, as a char??? you should do i1 = 0x08 before writing it to the file, I assume...


No, it does not work :(
Back to top
View user's profile Send private message Send e-mail
Mihawk



Joined: 03 Apr 2007
Posts: 29

PostPosted: Thu Jan 17, 2008 4:31 am    Post subject: Reply with quote

hint:
Code:
int sceIoWrite(SceUID fd, const void *data, SceSize size);


P.S.:
How do you know that it writes an ASCII value and not a HEX one?
And why don't you like ASCII values? Is it just because HEX sounds cooler? Ok, you say your english is not so good, but do you know what discrimination is?
_________________
Ask and it will be given to you; seek and you will find; knock and the door will be opened to you.
Back to top
View user's profile Send private message
Red_Squirrel



Joined: 03 Oct 2007
Posts: 11

PostPosted: Thu Jan 17, 2008 4:43 am    Post subject: Reply with quote

Mihawk wrote:
hint:
Code:
int sceIoWrite(SceUID fd, const void *data, SceSize size);


P.S.:
How do you know that it writes an ASCII value and not a HEX one?
And why don't you like ASCII values? Is it just because HEX sounds cooler? Ok, you say your english is not so good, but do you know what discrimination is?


I need to insert the "08" hex value in the file... in ASCII it has not a value :|
With a hex editor I saw that "08" value is egual to a "." value, but if I insert with the keyboard the "." value in the ASCII column, in the hex one appear the code "2E"... but I need 08...

Could anyone help me?
Please...
Back to top
View user's profile Send private message Send e-mail
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Thu Jan 17, 2008 5:29 am    Post subject: Reply with quote

Writing data to a file is beginner programming. Go look at a general C tutorial or programming book. We aren't going to help with beginner stuff here.
Back to top
View user's profile Send private message AIM Address
Red_Squirrel



Joined: 03 Oct 2007
Posts: 11

PostPosted: Thu Jan 17, 2008 5:34 am    Post subject: Reply with quote

J.F. wrote:
Writing data to a file is beginner programming. Go look at a general C tutorial or programming book. We aren't going to help with beginner stuff here.


So you don't know how to do it...
Back to top
View user's profile Send private message Send e-mail
Red_Squirrel



Joined: 03 Oct 2007
Posts: 11

PostPosted: Thu Jan 17, 2008 5:59 am    Post subject: Reply with quote

Ok guys, no problem :)
Thanks to all for the help and see you later ;)
Back to top
View user's profile Send private message Send e-mail
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Thu Jan 17, 2008 6:36 am    Post subject: Reply with quote

It's the difference between
unsigned char i1 = 8;
and
unsigned char i1 = '8';

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Thu Jan 17, 2008 6:38 am    Post subject: Reply with quote

sceIoWrite takes a pointer as the second argument, not a value.
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Thu Jan 17, 2008 7:58 am    Post subject: Reply with quote

Again, that's all beginner programming. If the person can't tell the difference between using a pointer and using a value, or between 8 and '8', they aren't ready to program the PSP. They need more lessons in C.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group