Post Reply 
hex
need some lua help...
Author Message
Mr. Shizzy
ɯɹ˙ sɥızzʎ

Posts: 2,973.4020
Threads: 415
Joined: 21st Feb 2007
Reputation: -2.36574
E-Pigs: 160.1496
Offline
Post: #1
hex
Can anyone show me a simple example of how to hex edit a value with lua code ???

Thanks in advance.  

I have a cool idea I would like to work on  [Image: tongue.gif]

PSP 2001 [TA-088v2]: 6.39 ME-9.7
[Image: 4kly6c1.gif]
Sig by Mr_Nick666
08/04/2008 09:33 AM
Find all posts by this user Quote this message in a reply
hibbyware
ʕθ̿␣̅θ̿ʔ ℋiЬЬyℬot™

Posts: 1,048.2613
Threads: 19
Joined: 18th Jul 2007
Reputation: -3.09168
E-Pigs: 7.0196
Offline
Post: #2
RE: hex
 Results from ℋiЬЬyℬot™ - "better than Google"
I don't really do LUA but maybe this could help you,

Not sure about the r+ but looking at http://luanet.net/lua/function/io.open    "r+": update mode, all previous data is preserved;

Code:
file = io.open("myFile.bleh", "r+")
file:seek("set", 0x03)
file:write(0x01)
file:close()


[Image: small_hw_logo_001.png] ʕθ̿␣̅θ̿ʔ ℋiЬЬyℬot™
(This post was last modified: 08/04/2008 11:15 AM by hibbyware.)
08/04/2008 10:59 AM
Find all posts by this user Quote this message in a reply
Mr. Shizzy
ɯɹ˙ sɥızzʎ

Posts: 2,973.4020
Threads: 415
Joined: 21st Feb 2007
Reputation: -2.36574
E-Pigs: 160.1496
Offline
Post: #3
RE: hex
Cool thanks Hibby.

What is the "set" ?
Could you please explain that a little ?

PSP 2001 [TA-088v2]: 6.39 ME-9.7
[Image: 4kly6c1.gif]
Sig by Mr_Nick666
09/04/2008 09:36 AM
Find all posts by this user Quote this message in a reply
hibbyware
ʕθ̿␣̅θ̿ʔ ℋiЬЬyℬot™

Posts: 1,048.2613
Threads: 19
Joined: 18th Jul 2007
Reputation: -3.09168
E-Pigs: 7.0196
Offline
Post: #4
RE: hex
 Results from ℋiЬЬyℬot™ - "better than Google"
Should seek you to the postion in file that you want to edit,  in this case 0x03

file:seek("set", 0x03)

This will write the new value to the position previously set,

file:write(0x01)

So what it should do is write the value 0x01 to position 0x03

[Image: small_hw_logo_001.png] ʕθ̿␣̅θ̿ʔ ℋiЬЬyℬot™
09/04/2008 09:52 AM
Find all posts by this user Quote this message in a reply
SchmilK
Noob

Posts: 4,698.2833
Threads: 359
Joined: 16th Apr 2007
Reputation: 0.38918
E-Pigs: 82.0266
Offline
Post: #5
RE: hex
sounds to me like a psp based prx editor :O

epic win right there!!

limneosgreen Wrote:Take my advice, don't try to install custom themes ... it's possible to brick ur psp.. why just don't change wallpaper
09/04/2008 10:27 AM
Find all posts by this user Quote this message in a reply
Mr. Shizzy
ɯɹ˙ sɥızzʎ

Posts: 2,973.4020
Threads: 415
Joined: 21st Feb 2007
Reputation: -2.36574
E-Pigs: 160.1496
Offline
Post: #6
RE: hex
Thanks Hibby.
A question:

When I use this code: (just a quick example - not actually the file in the pick below...)

Code:
1
2
3
4
5
6
7
8
9
10
11
if pad:cross() and current == 6 then

file = io.open("flash0:/vsh/module/vsh.prx", "r+")
file:seek("set", "0x41290")
file:write(" m.B")
file:close()   
screen:clear()
PrintCentered(120,"DONE !!",green)
screen.flip()
screen.waitVblankStart(200)
end


It will directly enter the values in the right box, instead of the left.
(it alters the data in left box but directly enters it into the right box)

This has been a pain, b/c when I enter a "." in the right box, it will come up with a "2E" value in the left box, instead of the desired "00" value...

Is there a way to either:

1) directly alter the data in the left box

2) make a "." entered in the right, show as a "00" in the left box, instaed of a "2E" ??

or
3) probably the best & easiest solution:

is there code to alter the 32 bit float values of an adrress ??

Here is a screen of the hex editor on PC im using to check my result (just so you know what im referring to with "left box" and "right  box"



Thanks again Hibby.


~shizzy



Attached File(s) Thumbnail(s)
   

PSP 2001 [TA-088v2]: 6.39 ME-9.7
[Image: 4kly6c1.gif]
Sig by Mr_Nick666
(This post was last modified: 22/04/2008 11:44 AM by Mr. Shizzy.)
22/04/2008 11:43 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #7
RE: hex
Mr. Shizzy Wrote:It will directly enter the values in the right box, instead of the left.
Just to make things easier, the "left box" is the hex display, whereas the "right box" is the ASCII display.

Don't know LUA, but from what I can tell, it doesn't really have "data types".  PHP offers a pack() function to convert things to appropriate binary formats, but it doesn't seem LUA has something similar. (typically, you'd define a floating point variable, and just output that directly)

As for outputting strings, typically the language provides escape sequences for the null (0x00) character (eg \0 in C), but I can't seem to find such a thing for LUA (http://www.lua.org/pil/2.4.html).
23/04/2008 01:49 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Mr. Shizzy
ɯɹ˙ sɥızzʎ

Posts: 2,973.4020
Threads: 415
Joined: 21st Feb 2007
Reputation: -2.36574
E-Pigs: 160.1496
Offline
Post: #8
RE: hex
So could something like this be done ??

Code:
1
2
3
4
5
6
function alter_float()
file = io.open("ms0:/paf.prx", "r+")
file:seek("set", 0x1A4AE0)
file:writeFloatvalue("0.5")
file:close()   
end


PSP 2001 [TA-088v2]: 6.39 ME-9.7
[Image: 4kly6c1.gif]
Sig by Mr_Nick666
28/04/2008 09:47 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #9
RE: hex
Dunno, looks okay, give it a try!
28/04/2008 07:42 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

 Quick Theme: