• 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?".
  • 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.

Darthatron

巨大なトロール。
1,152
Posts
18
Years
  • Before we start:
    Today I'm going to teach you how to make a basic program to Hack Diamond/Pearl in Visual Basic 6.0. :) Please, before reading on make sure you learn the very basics of Visual Basic 6.0 from somewhere, Google it or something. I'd give you links, but I do believe that is against the rules. :P Also, be sure you already own a Copy of VB6, you cannot download it from Microsoft anymore. You will have to find other ways of locating it. :D

    Now, I'm going to show you how to make a Starter Editor for D/P. :D
    _______________

    Before you start coding... Step 1:
    Before you even think of beginning to code you will need several Functions and of course the remarkable 'clsCommonDialog' Class Module. :D

    First off, let's get you the Class Module, it is very helpful. And it stops people from getting the annoying "Component 'comdlg32.ocx' or one of its dependencies not correctly registered: a file is missing or invalid." Error. :) You can get it here. Please note, I have no idea who wrote it, but whoever they were they were truly a genius. :)

    Also, you will need the HEX Editing Module, with all Functions made by me. You can get that here.

    Add those 2 files into your project, and then we can continue.
    _______________

    Now, let's begin. Step 2:
    Now, you will want to make 2 Buttons.
    1 Named "cmdOpen" and the Caption "Open"
    1 Named "cmdSave" and the Caption "Save"

    And also, make 3 ComboBoxes. (These will hold which Pokemon will be in the PokeBalls.)
    1 Named "cmbPoke1" and the Style set to 2.
    1 Named "cmbPoke2" and the Style set to 2.
    1 Named "cmbPoke3" and the Style set to 2.

    You also have to make the List Property of all the ComboBoxes to this:
    Code:
    ??????????
    Bulbasaur
    Ivysaur
    Venusaur
    Charmander
    Charmeleon
    Charizard
    Squirtle
    Wartortle
    Blastoise
    Caterpie
    Metapod
    Butterfree
    Weedle
    Kakuna
    Beedrill
    Pidgey
    Pidgeotto
    Pidgeot
    Rattata
    Raticate
    Spearow
    Fearow
    Ekans
    Arbok
    Pikachu
    Raichu
    Sandshrew
    Sandslash
    Nidoran-F
    Nidorina
    Nidoqueen
    Nidoran-M
    Nidorino
    Nidoking
    Clefairy
    Clefable
    Vulpix
    Ninetales
    Jigglypuff
    Wigglytuff
    Zubat
    Golbat
    Oddish
    Gloom
    Vileplume
    Paras
    Parasect
    Venonat
    Venomoth
    Diglett
    Dugtrio
    Meowth
    Persian
    Psyduck
    Golduck
    Mankey
    Primeape
    Growlithe
    Arcanine
    Poliwag
    Poliwhirl
    Poliwrath
    Abra
    Kadabra
    Alakazam
    Machop
    Machoke
    Machamp
    Bellsprout
    Weepinbell
    Victreebel
    Tentacool
    Tentacruel
    Geodude
    Graveler
    Golem
    Ponyta
    Rapidash
    Slowpoke
    Slowbro
    Magnemite
    Magneton
    Farfetch'd
    Doduo
    Dodrio
    Seel
    Dewgong
    Grimer
    Muk
    Shellder
    Cloyster
    Gastly
    Haunter
    Gengar
    Onix
    Drowzee
    Hypno
    Krabby
    Kingler
    Voltorb
    Electrode
    Exeggcute
    Exeggutor
    Cubone
    Marowak
    Hitmonlee
    Hitmonchan
    Lickitung
    Koffing
    Weezing
    Rhyhorn
    Rhydon
    Chansey
    Tangela
    Kangaskhan
    Horsea
    Seadra
    Goldeen
    Seaking
    Staryu
    Starmie
    Mr.Mime
    Scyther
    Jynx
    Electabuzz
    Magmar
    Pinsir
    Tauros
    Magikarp
    Gyarados
    Lapras
    Ditto
    Eevee
    Vaporeon
    Jolteon
    Flareon
    Porygon
    Omanyte
    Omastar
    Kabuto
    Kabutops
    Aerodactyl
    Snorlax
    Articuno
    Zapdos
    Moltres
    Dratini
    Dragonair
    Dragonite
    Mewtwo
    Mew
    Chikorita
    Bayleef
    Meganium
    Cyndaquil
    Quilava
    Typhlosion
    Totodile
    Croconaw
    Feraligatr
    Sentret
    Furret
    Hoothoot
    Noctowl
    Ledyba
    Ledian
    Spinarak
    Ariados
    Crobat
    Chinchou
    Lanturn
    Pichu
    Cleffa
    Igglybuff
    Togepi
    Togetic
    Natu
    Xatu
    Mareep
    Flaaffy
    Ampharos
    Bellossom
    Marill
    Azumarill
    Sudowoodo
    Politoed
    Hoppip
    Skiploom
    Jumpluff
    Aipom
    Sunkern
    Sunflora
    Yanma
    Wooper
    Quagsire
    Espeon
    Umbreon
    Murkrow
    Slowking
    Misdreavus
    Unown
    Wobbuffet
    Girafarig 
    Pineco
    Forretress
    Dunsparce
    Gligar
    Steelix
    Snubbull
    Granbull
    Qwilfish
    Scizor
    Shuckle
    Heracross
    Sneasel
    Teddiursa
    Ursaring
    Slugma
    Magcargo
    Swinub
    Piloswine
    Corsola
    Remoraid
    Octillery
    Delibird
    Mantine
    Skarmory
    Houndour
    Houndoom
    Kingdra
    Phanpy
    Donphan
    Porygon 2
    Stantler
    Smeargle
    Tyrogue
    Hitmontop
    Smoochum
    Elekid
    Magby
    Miltank
    Blissey
    Raikou
    Entei
    Suicune
    Larvitar
    Pupitar
    Tyranitar
    Lugia
    Ho-oh
    Celebi
    Treecko
    Grovyle
    Sceptile
    Torchic
    Combusken
    Blaziken
    Mudkip
    Marshtomp
    Swampert
    Poochyena
    Mightyena
    Zigzagoon
    Linoone
    Wurmple
    Silcoon
    Beautifly
    Cascoon
    Dustox
    Lotad
    Lombre
    Ludicolo
    Seedot
    Nuzleaf
    Shiftry
    Taillow
    Swellow
    Wingull
    Pelipper
    Ralts
    Kirlia
    Gardevoir
    Surskit
    Masquerain
    Shroomish
    Breloom
    Slakoth
    Vigoroth
    Slaking
    Nincada
    Ninjask
    Shedinja
    Whismur
    Loudred
    Exploud
    Makuhita
    Hariyama
    Azurill
    Nosepass
    Skitty
    Delcatty
    Sableye
    Mawile
    Aron
    Lairon
    Aggron
    Meditite
    Medicham
    Electrike
    Manectric 
    Plusle
    Minun
    Volbeat
    Illumise
    Roselia
    Gulpin
    Swalot
    Carvanha
    Sharpedo
    Wailmer
    Wailord
    Numel
    Camerupt
    Torkoal
    Spoink
    Grumpig
    Spinda
    Trapinch
    Vibrava
    Flygon
    Cacnea
    Cacturne
    Swablu 
    Altaria
    Zangoose
    Seviper
    Lunatone
    Solrock
    Barboach
    Whiscash
    Corphish
    Crawdaunt
    Baltoy
    Claydol
    Lileep
    Cradily
    Anorith
    Armaldo
    Feebas
    Milotic
    Castform
    Kecleon
    Shuppet
    Banette
    Duskull
    Dusclops
    Tropius
    Chimecho
    Absol
    Wynaut
    Snorunt
    Glalie
    Spheal
    Sealeo
    Walrein
    Clamperl
    Huntail
    Gorebyss
    Relicanth
    Luvdisc
    Bagon
    Shellgon
    Salamence
    Beldum
    Metang
    Metagross
    Regirock
    Regice
    Registeel
    Latias
    Latios
    Kyogre
    Groudon
    Rayquaza
    Jirachi
    Deoxys
    Turtwig 
    Grotle
    Torterra 
    Chimchar 
    Monferno 
    Infernape 
    Piplup
    Prinplup
    Empoleon 
    Starly 
    Staravia 
    Staraptor 
    Bidoof 
    Bibarel 
    Kricketot 
    Kricketune 
    Shinx 
    Luxio 
    Luxray
    Budew
    Roserade
    Cranidos 
    Rampardos 
    Shieldon
    Bastiodon 
    Burmy 
    Wormadam 
    Mothim 
    Combee 
    Vespiquen 
    Pachirisu 
    Buizel 
    Floatzel 
    Cherubi 
    Cherrim 
    Shellos 
    Gastrodon 
    Ambipom 
    Drifloon 
    Drifblim
    Buneary 
    Lopunny 
    Mismagius 
    Honchkrow 
    Glameow 
    Purugly 
    Chingling 
    Stunky 
    Skuntank 
    Bronzor 
    Bronzong 
    Bonsly 
    Mime Jr. 
    Happiny 
    Chatot 
    Spiritomb 
    Gible 
    Gabite 
    Garchomp 
    Munchlax 
    Riolu 
    Lucario 
    Hippopotas 
    Hippowdon 
    Skorupi
    Drapion 
    Croagunk 
    Toxicroak 
    Carnivine 
    Finneon 
    Lumineon 
    Mantyke 
    Snover 
    Abomasnow 
    Weavile 
    Magnezone 
    Lickilicky 
    Rhyperior 
    Tangrowth 
    Electivire 
    Magmortar
    Togekiss 
    Yanmega 
    Leafeon 
    Glaceon 
    Gliscor 
    Mamoswine 
    Porygon-Z 
    Gallade 
    Probopass 
    Dusknoir 
    Froslass 
    Rotom
    Uxie 
    Mesprit 
    Azelf 
    Dialga 
    Palkia 
    Heatran 
    Regigigas 
    Giratina 
    Cresselia 
    Phione 
    Manaphy 
    Darkrai 
    Shaymin 
    Arceus
    That is just a list of Pokemon so the User can easily select which Pokemon they want to be in each PokeBall. :)
    _______________

    Now, let's begin coding. Step 3:
    Ok. After reading the basic I'm sure you'll know what this line of code does.
    Code:
    Dim LoadedROM As String
    For those of you who 'forgot' what that line does I shall explain, in very little detail. That line basicly just enabled you to use the Variant "ROMLocation" to store the location of the ROM you let the User select.

    Alright, so put that code at the very start of your Code. That way you can use it all through-out the current Form. :)
    _______________

    Making and decoding the 'Open' Button. Step 4:
    Ok, in the 'View Object' Mode, double click your Open Button. Now, you should get something that looks like this in your code window:
    Code:
    Private Sub cmdOpen_Click()
    
    End Sub
    What we want to do inside there is make the actual 'Open Dialog', and allow the User to choose which ROM they would like to edit. So... In the blank space there put the following code.
    Code:
        Dim cdgOpen As clsCommonDialog
        Set cdgOpen = New clsCommonDialog
        LoadedROM = cdgOpen.ShowOpen(Me.hwnd, "Open Pokemon NDS ROM...", , "NDS ROMs (*.nds)|*.nds")
        cmbPoke1.ListIndex = CInt("&H" & ReverseHEX(ReadHEX(LoadedROM, 2855304, 2)))
        cmbPoke2.ListIndex = CInt("&H" & ReverseHEX(ReadHEX(LoadedROM, 2855308, 2)))
        cmbPoke3.ListIndex = CInt("&H" & ReverseHEX(ReadHEX(LoadedROM, 2855312, 2)))
    In the spoiler I will explain what each line does in as much detail as I can be bothered. :)
    Spoiler:

    _______________

    How to make a 'Save' Button. Step 5:
    Ok, we are nearly there. We just have to make this Save Button, then we are basically finished. :D

    Once again go into 'Design Mode' and double click your Save Button. You should get some code that looks like this:
    Code:
    Private Sub cmdSave_Click()
    
    End Sub
    What we want to do is add some code in there and to write the Data from the Combo Boxes to the ROM.

    Ok... So, in the blank area there, put this code in.
    Code:
        WriteHEX LoadedROM, 2855304, ReverseHEX(Right("0000" & Hex(cmbPoke1.ListIndex), 4))
    What that code does is, it writes the data back into the ROM as the Flipped HEX String. But ofcourse, I will go into detail about what each Function does. :)
    Spoiler:
    Woot! Nearly finished now... All you have to do is add the other 2 ComboBoxes, with the fixed offsets to write to and you are done. :D I'll let you do that, to see if you've learned anything. :)
    _______________

    Pretty your program up a little. Step 6:
    All you got to do here is make your program look nice, add some picture or something. Just something to make it look original, and to help make using your tool more enjoyable. :)
    _______________

    FINISHED!. Step 7:
    Finally, you are done. Your code should now look like this:
    Code:
    Dim LoadedROM As String
    
    Private Sub cmdOpen_Click()
        Dim cdgOpen As clsCommonDialog
        Set cdgOpen = New clsCommonDialog
        LoadedROM = cdgOpen.ShowOpen(Me.hwnd, "Open Pokemon NDS ROM...", , "NDS ROMs (*.nds)|*.nds")
        cmbPoke1.ListIndex = CInt("&H" & ReverseHEX(ReadHEX(LoadedROM, 2855304, 2)))
        cmbPoke2.ListIndex = CInt("&H" & ReverseHEX(ReadHEX(LoadedROM, 2855308, 2)))
        cmbPoke3.ListIndex = CInt("&H" & ReverseHEX(ReadHEX(LoadedROM, 2855312, 2)))
    End Sub
        
    Private Sub cmdSave_Click()
        WriteHEX LoadedROM, 2855304, ReverseHEX(Right("0000" & Hex(cmbPoke1.ListIndex), 4))
        WriteHEX LoadedROM, 2855308, ReverseHEX(Right("0000" & Hex(cmbPoke2.ListIndex), 4))
        WriteHEX LoadedROM, 2855312, ReverseHEX(Right("0000" & Hex(cmbPoke3.ListIndex), 4))
    End Sub
    If it doesn't look something like that, you didn't follow my guise properly. :( Just try again and read carefully. Good luck making some cool Pokemon Hacking Tools! :D

    Disclaimer:

    If you use these Functions you must Credit me, Darthatron. If you do not credit me, I will cry. If you think I should waive this rule for you, please PM me about it.

    If you want to post this on your website or repost it somewhere please PM me.
     
    Last edited by a moderator:

    Swampert 22

    Is making tools for you...
    393
    Posts
    18
    Years
  • Wahaay Darthatron!

    I've been looking through that source code you sent me every day, trying to make heads or tails of it and making <ahem> not much progress!

    This is great that you've taken the time to do this though, I should be able to understand from this. If not, well I guess I'm just not a programmer!

    Well done mate, hopefully aa lot of talent will emerge from this!
     
    1,104
    Posts
    16
    Years
  • I wish you'd posted this before I read through all the source code of other programs. This way looks lots easier than the way I found. I did it everything one byte at a time (without your functions:P). I'll have to read through this in more detail sometime soon. I'll be sure to save a lot of time.
     

    Darthatron

    巨大なトロール。
    1,152
    Posts
    18
    Years
  • Wahaay Darthatron!

    I've been looking through that source code you sent me every day, trying to make heads or tails of it and making <ahem> not much progress!

    This is great that you've taken the time to do this though, I should be able to understand from this. If not, well I guess I'm just not a programmer!

    Well done mate, hopefully aa lot of talent will emerge from this!
    Hell yeah! I rock! :D

    I wish you'd posted this before I read through all the source code of other programs. This way looks lots easier than the way I found. I did it everything one byte at a time (without your functions:P). I'll have to read through this in more detail sometime soon. I'll be sure to save a lot of time.
    Lol sorry, I only wrote it up yesterday. In like an hour and a half. :P

    Great, tut, Now I can make some tools

    Something's wrong with the link

    Which link? D:
    ____________

    I'm gonna add pictures after dinner. :P
     

    Darthatron

    巨大なトロール。
    1,152
    Posts
    18
    Years
  • Thanks for fixing em, by the way how do you replace hex values in a ROM of say 10 bytes?

    To read the string of 10 Bytes:
    Code:
    String = ReadHEX(ROMLocation, Offset, 10)

    To write a string of 10 Bytes:
    Code:
    WriteHEX ROMLocation, Offset, Right("00000000000000000000" & Data, 20)
    You see, you need to use the number of Bytes times 2, for the number of 0's you need to use. So, for 15 Bytes, you need 30 0's. the same goes for the number at the end.
    _______________

    Hope that helped.
     
    Last edited:

    ZodiacDaGreat

    Working on a Mobile System
    429
    Posts
    17
    Years
  • Quote:
    Originally Posted by ZodiacDaGreat View Post
    Thanks for fixing em, by the way how do you replace hex values in a ROM of say 10 bytes?
    To read the string of 10 Bytes:
    Code:

    String = ReadHEX(ROMLocation, Offset, 10)

    To write a string of 10 Bytes:
    Code:

    WriteHEX ROMLocation, Offset, Right("00000000000000000000" & Data, 20)

    You see, you need to use the number of Bytes times 2, for the number of 0's you need to use. So, for 15 Bytes, you need 30 0's. the same goes for the number at the end.
    _______________

    Hope that helped.

    Sorry, again, could you give me an example, ok, if I want to put hex values "47BC89097378" at 0x800000 how do you do it?
    I dont quite understand the procedure
     

    D-Trogh

    Dead
    439
    Posts
    18
    Years
  • Sorry, again, could you give me an example, ok, if I want to put hex values "47BC89097378" at 0x800000 how do you do it?
    I dont quite understand the procedure
    Code:
        Dim Data As String
        Data = "47BC89097378"
        WriteHEX ROMLocation, 8388608, Right("000000000000" & Data, 12))
    Should work..
     

    Chiaki Shinichi

    Beginning Hacker
    118
    Posts
    17
    Years
  • Could anyone tell me how to declare a list of numbers (233243) as byte?

    Dim x as byte
    x = "233243"

    I tried this, it doesn't work, could anyone help?
     

    Darthatron

    巨大なトロール。
    1,152
    Posts
    18
    Years
  • I guess this is how decompiling and recompiling scripts work...

    Yeah, but the easier way would be to use the Select Case Function, if you need more info on how to do that, just PM me.

    Could anyone tell me how to declare a list of numbers (233243) as byte?

    Dim x as byte
    x = "233243"

    I tried this, it doesn't work, could anyone help?

    What do you mean by list of numbers..?
     

    Chiaki Shinichi

    Beginning Hacker
    118
    Posts
    17
    Years
  • What do you mean by list of numbers..?

    You know:

    Dim x as byte
    x = ""

    How do you declare a list of bytes?

    I want to do this:
    Dim Data as Byte
    Data = "23232323"
    Put #FileNum, &H800000, Data

    Inserting 23 23 23 at 800000
     
    Last edited:

    Darthatron

    巨大なトロール。
    1,152
    Posts
    18
    Years
  • You know:

    Dim x as byte
    x = ""

    How do you declare a list of bytes?

    I want to do this:
    Dim Data as Byte
    Data = "23232323"
    Put #FileNum, &H800000, Data

    Inserting 23 23 23 at 800000
    Ohhhh. ALl you have to do is declare the Data as a String. I'm pretty sure that Bytes are just 2 letters long, so that mucks it up...

    So......
    Code:
    Dim Data as String
    Data = "23232323"
    Put #FileNum, CInt("&H800000"), Data
    And I really think you should use my Functions, they make it easier for me to help you...
     

    ZodiacDaGreat

    Working on a Mobile System
    429
    Posts
    17
    Years
  • Um, Darthatron, Im stuck, Could you give a code, how do you use writehex to: write:
    "39600AE202B4024900F000F80F470000" in HEX at Offset "406C0"???


    WriteHEX ROMLocation, Offset, Right("00000000000000000000" & Data, 20)

    should the Offset be in Hex (6digits reversed) or in decimal?
     

    D-Trogh

    Dead
    439
    Posts
    18
    Years
  • Um, Darthatron, Im stuck, Could you give a code, how do you use writehex to: write: "39600AE202B4024900F000F80F470000" in HEX at Offset "406C0"???

    should the Offset be in Hex (6digits reversed) or in decimal?
    Have you seen my post?
    If you've read it, you should know how to write that line of code to your ROM.
    And, as you see, offsets are in decimal ;)
     

    ZodiacDaGreat

    Working on a Mobile System
    429
    Posts
    17
    Years
  • Have you seen my post?
    If you've read it, you should know how to write that line of code to your ROM.
    And, as you see, offsets are in decimal ;)

    Sorry, D-trogh, I didn't notice, well, its fixed now. Thanks alot, I'll credit you.

    One more thing how do you use the reverse hex for writing pointers?
    eg.
    "21348008"?
     
    Back
    Top