don't click here

HEX2ASM

Discussion in 'Engineering & Reverse Engineering' started by Selbi, Dec 12, 2010.

Thread Status:
Not open for further replies.
  1. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    Something I hate about Hex editors is, that I can't do a lot of things I could do in normal text editors. If I'm pissed so much of using them, I always dig out IDA to convert the Hex into an ASM array (with dc.X commands). This, however, is annoying as well, so I decided to make a tiny program for it.

    Running the original menutext.bin file through it (level select text) looks like this:
    [​IMG]

    And the output looks like this:
    Code (ASM):
    1.         dc.b    $17,$22,$15,$15,$1E,$FF,$18,$19,$1C,$1C,$FF,$10,$1F,$1E,$15,$FF,$FF,$23,$24,$11,$17,$15,$FF,$01
    2.         dc.b    $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$23,$24,$11,$17,$15,$FF,$02
    3.         dc.b    $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$23,$24,$11,$17,$15,$FF,$03
    4.         dc.b    $1C,$11,$12,$0F,$22,$19,$1E,$24,$18,$FF,$10,$1F,$1E,$15,$FF,$FF,$FF,$23,$24,$11,$17,$15,$FF,$01
    5.         dc.b    $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$23,$24,$11,$17,$15,$FF,$02
    6.         dc.b    $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$23,$24,$11,$17,$15,$FF,$03
    7.         ...

    Download: http://selbi.hapisan.com/HEX2ASM.exe


    Usage: Just drag'n'drop a file on it. The rest should be pretty obvious. Also download .NET Framework if you don't have it already!


    Special Thanks to MarkeyJester for a 5 minutes beta testing!
     
  2. Sappharad

    Sappharad

    Oldbie
    1,413
    70
    28
    What's the advantage of this over .incbin "file.bin"?
     
  3. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    Technically, there is no. But it's easier to work with this way (at least for me).
     
  4. FraGag

    FraGag

    Tech Member
    This might come in handy... if I can remember that I have it! :v: That's if I do any hacking before completing my own disassembler... I'm not fond of hex editors either, because you can't do any formatting and you can't put any comments (and if an hex editor can do that, that information has to be saved in a separate file anyway).

    By the way, you didn't change the copyright and company attributes on your assembly (see Project Properties, it's Assembly Information or something like that). And ugh, VB.NET.
     
  5. Hanoch

    Hanoch

    Also known as TheKnock, Birashot Member
    491
    0
    0
    Israel
    everything
    Awesome little program, selbi. I always hated to write dc.b over and over again!
    But here's what it really should have:

    - The ability to read from offests
    - If its a music file, create channel indexes (both relative and absolute indexes)
     
  6. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    Totally forget that. Added them and re-uploaded.

    - I thought people are smart enough to highlight and press Del, even though I can do it in future releases of course.
    - This program was not designed for music releated stuff but for pretty much anything, which is why I won't make anything special for Sonic Hacking. (I could provide the Source Code though, even though that will make my horrible ways of do things VB.NET public... :V)
     
  7. FraGag

    FraGag

    Tech Member
    If it's a music file, use S1SMPS2ASM.
     
  8. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,192
    406
    63
    Japan
    As I said on SSRG, this sir, is one of the several most useful tools I've found to use, you wouldn't believe the number of times I've had to manually copy code from a hex editor and reorganise in the assembler's format.
     
  9. Hivebrain

    Hivebrain

    Administrator
    3,047
    154
    43
    53.4N, 1.5W
    Github
    You can copy/paste data straight from a hex editor into asm if you use the "hex" instruction.
    Code (ASM):
    1.  
    2. hex 0001020304
    3.  
     
  10. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    I've been aware of that, but I don't like it that much. I just use dc.X whenever I can.
     

  11. This, basically this. Bravo! So simple and yet so handy! :)
     
  12. Mercury

    Mercury

    His Name Is Sonic Tech Member
    1,740
    21
    18
    Location Location
    AeStHete
    I really like this idea, as it's something I coincidentally needed just recently.

    However, there are a couple of features I think would be nice:
    • Adding labels to the beginning of each line, so you can find your way around.
    • Adding commented labels at the end of each line, so you can still find your way around if the labels are modified.
    • A progress bar
    • A preview so you can tweak the format before exporting it.
    • Not crashing on my system! =P

    I got the urge to code, so I just made a version from scratch with these features myself: hexdc
     
  13. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    Well now that you did that, I doubt that I will need to add those features to my program as well, but I'll probably do it anyway. The progress bar was already done before you posted, but I didn't feel like updating just because of it. :v:

    EDIT: Just finished the comments at the end of the line stuff and my StreamWriter, so the update might already come today!
     
  14. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    Update, v1.1:
    • Data is now directly being written to the output path (using a StreamWriter), rather than storing everything to a variable and then saving it. This allows you to convert huge files in the matter seconds!
    • Added a progress bar.
    • Reading from offsets and setting length (e.g Offset=$0001E000; Length=$2000 bytes).
    • Adding comments at the end of each line, showing you the offset of the first value in that line (Sorry Mercury, labels as well would be... unnecessary).

    But I totally have no interests in working on this program anymore. The source is already fucked up so much... it was hard enough to do the things listed above (I even think that there are still bugs releated to words and longwords when reading from offsets and the progress bar only really works when you convert the entire file).


    Download: http://selbi.hapisan.com/HEX2ASM-v1.1.exe


    That said, here's the source (I'm pretty sure the experienced people in those modern languages will do an epic failpalm now :v:): http://selbi.hapisan.com/HEX2ASM-Source.rar

    If anyone has the patience to crawl through this messy code to clean it up, fix the remaining bugs or add more handy features, just go ahead!
     
  15. SegaLoco

    SegaLoco

    W)(at did you say? Banned
    I'll take you up on that offer. :P

    Edit: Ugg...VB, I'll rewrite it in C

    Edit2: Okay, here it is: http://www.mediafire.com/?y5unt3vt1td454k

    Only thing it doesn't do is the aesthetic arrangement of data like his (I.e. x items on one line) but it does feature start at x offset and only do y lines (note lines, not bytes, I'll implement bytes in a bit *teehee*)

    Edit3: Here's the patch for length of bytes, not lines http://www.mediafire.com/?fc5s3z3shknhsps
     
Thread Status:
Not open for further replies.