• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Visual Basic 6.0 HEX Editing Functions - For Hacking ROMs.

Swampert 22

Is making tools for you...
393
Posts
18
Years
Hey Darthatron buddy, it's been a while, since I asked you a question, but I need your wisdom to progress!

How do you get a listbox's list values to be data that the program has read from the ROM?

I'll explain what I mean:

I want the list of 'words' in the list box to be Pokémon. But the order is obviously dependant on what the program reads. If I got it to read data at &H30303 for example, and the hex-byte was 0A, I would want it to say "Caterpie", if it was FB I would want it to say "Celebi". This list would have to be as long as there as relevant bytes to change, so the list could be 251 'words' long.

I hope you understand that, cus I don't think i understand what I just wrote lol!

Thanks Darthatron!
 

Darthatron

巨大なトロール。
1,152
Posts
18
Years
Hey Darthatron buddy, it's been a while, since I asked you a question, but I need your wisdom to progress!

How do you get a listbox's list values to be data that the program has read from the ROM?

I'll explain what I mean:

I want the list of 'words' in the list box to be Pokémon. But the order is obviously dependant on what the program reads. If I got it to read data at &H30303 for example, and the hex-byte was 0A, I would want it to say "Caterpie", if it was FB I would want it to say "Celebi". This list would have to be as long as there as relevant bytes to change, so the list could be 251 'words' long.

I hope you understand that, cus I don't think i understand what I just wrote lol!

Thanks Darthatron!

I think I understand....

Code:
ListBox.ListIndex = ReadHEX(LoadedROM, Location, 1)

Is that it? Unless you mean the list of Pokemon is jumbled up and you want to read the Byte, rather than the location?

First off you'd make the ItemData to the actual number of the Pokemon.

Check out this demo source and see if you can understand it. I did comment it, so it shouldn't be too difficult.

CLICK HERE!

Hope I could help? If not try and rephrase the question. :D
 
Last edited:
712
Posts
16
Years
  • Age 31
  • Seen Mar 25, 2024
how do i make a file change its file type..? (example: I'll make a tool that will open a .raw and saving it, it will turn into a .wraw?)
 

Lin

JohtoMap/ZOLE Creator
51
Posts
16
Years
  • Age 29
  • Seen Apr 26, 2014
Hey, just to let you know, I grabbed tiles from a ROM and displayed them. It's very hard though, but I made a function to. Pretty much all of the credits to helping me do it goes to Cearn. He's a genius with this stuff. He's helping me cover saving now, and it's a lot harder than you'd think ;)
 

[HoN] Jereziah

Till DEATH do us part!
651
Posts
15
Years
Can someone Mail me the download link of Visual Basic 6.0...
PLease ... so i can make a tool...
Thanks...

Cool Thread
Can you please Mail me the download link of Visual Basic 6.0
Thanks and in addition Im gonna rate this 5/5...
 
Last edited:

cooley

///Keepin' it simple
1,148
Posts
17
Years
Can someone Mail me the download link of Visual Basic 6.0...
PLease ... so i can make a tool...
Thanks...

Cool Thread
Can you please Mail me the download link of Visual Basic 6.0
Thanks and in addition Im gonna rate this 5/5...
Just download an ISO version of it and mount it with MagicISO.
 

cooley

///Keepin' it simple
1,148
Posts
17
Years
Thanks Darthatron! Look what I made:
untitled-4.jpg


Well with all the0 Gold Data anyways
 

Darthatron

巨大なトロール。
1,152
Posts
18
Years
Thanks Darthatron! Look what I made:
untitled-4.jpg


Well with all the0 Gold Data anyways

Well, from the picture it looks okay, but I can't really see it due it's small size. :( Perhaps you could upload a larger version? :)
____________________________________________________________

In other news I updated the HEX Editing Module, now the WriteHEX Function will be faster and use less memory. :)
 
Last edited:
21
Posts
15
Years
  • Seen Mar 17, 2013
Hey,
I checked out your function "ReverseHex",
And to tell you the truth it gave me the creeps :p,

First i noticed that when you run this its a example
Code:
Dim test As String
test = "01"
msgbox(ReverseHex(test))
msgbox(test)
test will be empty after your function has been used,
And your for loop well you did add a break to it but stil you make it run 2 times it actually needs to loop.
But here's my remake of it.

Code:
Public Function ReverseHex(HexData As String) As String
Dim i As Integer
Dim Temp As String
Dim HexHold As String

HexHold = HexData

    If InStr(Len(HexHold) / 2, ",") > 0 Then HexHold = "0" & HexHold

    For i = 0 To (Len(HexHold) / 2) - 1
        Temp = Left(Right(HexHold, Len(HexHold) - (i * 2)), 2) & Temp
    Next i
    
ReverseHex = Temp
End Function
I was bored anyway :-),
And dont say i simple made a copy of your and changed it a bit.
I didnt do any speed check but it should be faster.
At least i think its cleaner that your current one.

edit:
Changed a small thing,
Still if your using mine updating would be smart.
Since now it wont alter the input data at all!
 
Last edited:

D-Trogh

Dead
439
Posts
18
Years
Same problem occurs when you want to use your WriteHEX function to write some data a couple of times..
An example:
Code:
WriteHEX sROM, &H<offset1>, sData
WriteHEX sROM, &H<offset2>, sData
WriteHEX sROM, &H<offset3>, sData
Would result in the program writing 'sData' to offset1, but not to offset2 or offset3, as sData is empty..
 
21
Posts
15
Years
  • Seen Mar 17, 2013
Same problem occurs when you want to use your WriteHEX function to write some data a couple of times..
An example:
Code:
WriteHEX sROM, &H<offset1>, sData
WriteHEX sROM, &H<offset2>, sData
WriteHEX sROM, &H<offset3>, sData
Would result in the program writing 'sData' to offset1, but not to offset2 or offset3, as sData is empty..

Yeah its quite a strange thing,
But i think its because he changes the data itself that the function is given,
Like the function gets sData,
In the function itself its called HexData,
He alters HexData but probably in vb6 HexData is simply sData just under a diffrent name,
So because he alters it more like clears it up.
The next time you want to use it its empty,
Its quite easy to fix though,
Simple first Place HexData into a temp and use the temp to alter it ;).
I will take a look maybe i will also recreate that function.
 

D-Trogh

Dead
439
Posts
18
Years
Yeah well..
Maybe 'we' (Read: All people interested in programming ROM Hack tools) should create this module file with good/fast working HEX Edit functions.
Darthatron started all this by sharing his functions.. But as there are some (minor) things that don't work properly..
I also heard Darthatron aren't the fastest.. Haven't checked the latest 'release' though
 
21
Posts
15
Years
  • Seen Mar 17, 2013
Darthatron was kind enough to release his functions,
And people are ofcourse using them,

But so far i have seen nobody has even tryed to fix the problems that the functions still have,
They use them and compain about the problems,

For me i dont even use the functions but i thought why not take a look and thought well this could use some fixing and i did,
People should be more kind to share what they know help each other.
I will when i have time try and make functions like the other 2 that he released,
But when that will be i dont know i was bored so i made ReverseHex.
But thats only took a few minutes and the other functions will take probably about the same time..
But when you calculate the time spend on all 3 it will add up in 1 day time.
And to tell the truth i think making functions like this is boring :p,
So thank god it only needs to be done once and the 2e time to see if any fixes/tweaks are posible :D.

But really people try and be a bit more open source ;).

Well as i still had some time i fixt the function a bit up,
As you where talking about speed it could be because it writes 1 byte at a time..
Not sure why but i kept it that way.
If really intersted i could rewrite it to write multiple byte's at once probably.

Code:
Public Function WriteHex(FilePath As String, Offset As Long, HexData As String)
On Error GoTo ErrHandle

Dim FileNum As Integer
Dim i As Integer
Dim Temp As String
Dim HexHold As String
Dim HexValue() As Byte
HexHold = HexData
FileNum = FreeFile

    If InStr(Len(HexHold) / 2, ",") > 0 Then HexHold = "0" & HexHold

    ReDim HexValue((Len(HexHold) / 2) - 1)
    For i = 0 To (Len(HexHold) / 2) - 1

        HexValue(i) = CLng("&H" & Mid(HexHold, 1 + (i * 2), 2))

    Next i

    Open FilePath For Binary As FileNum
        Put FileNum, Offset + 1, HexValue
    Close FileNum

Exit Function
ErrHandle:
    MsgBox Err.Description, vbOKOnly, "Error: " & Err.Number
End Function
As you see i used mostly his code just tweaked it.
But you should be able to call it using Data as many times you want :).

edit:
D-Trogh, Pointed me to a mistake what i just fixed i had Offset As integer, It should have been Offset As Long
edit2:
I compared my function and Darthatron's function and it seems his is a bit faster so if you want faster you should go for his version.
edit3:
I noticed that DoEvents was the cause of slowness,
But also i updated it even more it now write's all data to file in 1 go!
And as for speed its faster then Darthatron's now did a test writing 5kb 1000 times,
Mine will take around 8 seconds while his will take around 42 seconds.
I really do like speed dont you ?
 
Last edited:

cooley

///Keepin' it simple
1,148
Posts
17
Years
Well, from the picture it looks okay, but I can't really see it due it's small size. :( Perhaps you could upload a larger version? :)
____________________________________________________________

In other news I updated the HEX Editing Module, now the WriteHEX Function will be faster and use less memory. :)
Well The programs in the attachment below...
 

Darthatron

巨大なトロール。
1,152
Posts
18
Years
Darthatron was kind enough to release his functions,
And people are ofcourse using them,

But so far i have seen nobody has even tryed to fix the problems that the functions still have,
They use them and compain about the problems,

For me i dont even use the functions but i thought why not take a look and thought well this could use some fixing and i did,
People should be more kind to share what they know help each other.
I will when i have time try and make functions like the other 2 that he released,
But when that will be i dont know i was bored so i made ReverseHex.
But thats only took a few minutes and the other functions will take probably about the same time..
But when you calculate the time spend on all 3 it will add up in 1 day time.
And to tell the truth i think making functions like this is boring :p,
So thank god it only needs to be done once and the 2e time to see if any fixes/tweaks are posible :D.

But really people try and be a bit more open source ;).

Well as i still had some time i fixt the function a bit up,
As you where talking about speed it could be because it writes 1 byte at a time..
Not sure why but i kept it that way.
If really intersted i could rewrite it to write multiple byte's at once probably.

Code:
Public Function WriteHex(FilePath As String, Offset As Long, HexData As String)
On Error GoTo ErrHandle

Dim FileNum As Integer
Dim i As Integer
Dim Temp As String
Dim HexHold As String
Dim HexValue() As Byte
HexHold = HexData
FileNum = FreeFile

    If InStr(Len(HexHold) / 2, ",") > 0 Then HexHold = "0" & HexHold

    ReDim HexValue((Len(HexHold) / 2) - 1)
    For i = 0 To (Len(HexHold) / 2) - 1

        HexValue(i) = CLng("&H" & Mid(HexHold, 1 + (i * 2), 2))

    Next i

    Open FilePath For Binary As FileNum
        Put FileNum, Offset + 1, HexValue
    Close FileNum

Exit Function
ErrHandle:
    MsgBox Err.Description, vbOKOnly, "Error: " & Err.Number
End Function
As you see i used mostly his code just tweaked it.
But you should be able to call it using Data as many times you want :).

edit:
D-Trogh, Pointed me to a mistake what i just fixed i had Offset As integer, It should have been Offset As Long
edit2:
I compared my function and Darthatron's function and it seems his is a bit faster so if you want faster you should go for his version.
edit3:
I noticed that DoEvents was the cause of slowness,
But also i updated it even more it now write's all data to file in 1 go!
And as for speed its faster then Darthatron's now did a test writing 5kb 1000 times,
Mine will take around 8 seconds while his will take around 42 seconds.
I really do like speed dont you ?

Well I feel stupid. :P Then again I did write the first functions about 4 months ago, I have learned a lot from then. Also I'm sure if I re-wrote them they would be up to standard, then again, I'm too busy right now, if you need a faster function use TheGie's version. For now... :)

EDIT: You seemed to have Dimmed "Temp" and not used it, removing it could add precious micro-seconds. :)

EDIT2: After re-writing the WriteHEX Code from scratch I came to realize how bad my old method was. Anyway, I did a Speed Test between my Function and TheGie's. I made each Function run 4000 times. Each 1000 times it would return how fast it was going then at the end it would show the Average, here are the results:
Code:
[Darthatron]
First: 921
Second: 938
Third: 906
Forth: 1047

Average: 953

[TheGie]
First: 1047
Second: 1000
Third: 937
Forth: 953

Average: 984.25
As you can see mine is only slightly faster. I'd also like to note my Computer is VERY slow and these speed should be closer to 500 or 600.

I plan to redo my ReadHEX Function, though I don't think it can get much faster, then again it's pretty sloppy too. :)
 
Last edited:
21
Posts
15
Years
  • Seen Mar 17, 2013
First its not TheGie but ThuGie :D,
Second for the test are you using your rewriten code or the currect one in the package,
Also what kind of test did you do,
I used a bit of a stress test of 5k writing 1000x times,
As size could slow yours down as your writing byte by byte.

And it could be so that yours is faster for smaller sizes but try to run both tests :).
 

Darthatron

巨大なトロール。
1,152
Posts
18
Years
First its not TheGie but ThuGie :D,
Second for the test are you using your rewriten code or the currect one in the package,
Also what kind of test did you do,
I used a bit of a stress test of 5k writing 1000x times,
As size could slow yours down as your writing byte by byte.

And it could be so that yours is faster for smaller sizes but try to run both tests :).

Yes, the test is with my new Function. It writes 1 Byte at a time. It writes 4 by 1000x.

Both Function's run after each other.

Also, sorry about the name I was pretty tired when I wrote everything up. :)
 
Last edited:
Back
Top