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

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Red_Squirrel
Posts: 11
Joined: Wed Oct 03, 2007 5:17 pm

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

Post by Red_Squirrel »

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: Select all

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".
Alberto
Posts: 51
Joined: Mon Feb 12, 2007 8:16 pm
Location: Sofia

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

Post by Alberto »

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: Select all

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...
Red_Squirrel
Posts: 11
Joined: Wed Oct 03, 2007 5:17 pm

Post by Red_Squirrel »

Usually i1 contains letters, like "A", "B", "C" or other char as "?", "!", "("...
Red_Squirrel
Posts: 11
Joined: Wed Oct 03, 2007 5:17 pm

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

Post by Red_Squirrel »

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: Select all

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 :(
Mihawk
Posts: 29
Joined: Tue Apr 03, 2007 2:04 am

Post by Mihawk »

hint:

Code: Select all

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.
Red_Squirrel
Posts: 11
Joined: Wed Oct 03, 2007 5:17 pm

Post by Red_Squirrel »

Mihawk wrote:hint:

Code: Select all

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...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

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.
Red_Squirrel
Posts: 11
Joined: Wed Oct 03, 2007 5:17 pm

Post by Red_Squirrel »

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...
Red_Squirrel
Posts: 11
Joined: Wed Oct 03, 2007 5:17 pm

Post by Red_Squirrel »

Ok guys, no problem :)
Thanks to all for the help and see you later ;)
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

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

Jim
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

sceIoWrite takes a pointer as the second argument, not a value.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

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