Codes
WiiRd forum
March 29, 2024, 02:34:36 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome on the new server

Update 4.3 - do NOT update!
Gecko 1.9.3.1
Should I get a USB Gecko, I wanna hack?
How do I use my USB Gecko
Where can I get WiiRd?
 
   Home   CODE DATABASE GAMEHACKING Help Search Login Register  
Pages: [1]
  Print  
Author Topic: bin to txt  (Read 3000 times)
dcx2
Computer Engineer
Moderator
Legendary Member
*****

Karma: 165
Posts: 3468


WWW
« on: July 20, 2011, 02:19:11 AM »

I made some lists by dumping the table of string pointers for all the items and stuff like that.  Then, I had the app read a pointer, and then read the string from a dump, and then create a table out of the data.

http://wiird.l0nk.org/forum/index.php/topic,8455.msg70489.html#msg70489

http://wiird.l0nk.org/forum/index.php/topic,8455.msg71537.html#msg71537

http://wiird.l0nk.org/forum/index.php/topic,1840.msg69664.html#msg69664

http://wiird.l0nk.org/forum/index.php/topic,1840.msg70169.html#msg70169

In the event that you would like to do something similar, here's the source.  It's a bit messy - I make a new copy of main and comment out the last one each time - but it should help.  Note that it's designed for MS Visual Studio Express 2008 (the free version).  To pass in command line arguments while debugging (useful), open the project properties and go to the Debug tab.

* binToTxt.zip (7.14 KB - downloaded 97 times.)
Logged

Stuff
Hacker
Sr. Member
*****

Karma: 31
Posts: 415


0x80000000 = -0


« Reply #1 on: July 26, 2011, 12:06:00 AM »

Spoiler for "unused variable":
            catch (ArgumentException e)
            {
                System.Console.WriteLine(e.ToString());
                result += '\0';
                return result;
            }
            catch (EndOfStreamException e)
            {
                System.Console.WriteLine(e.ToString());
                result += '\0';
                return result;
            }
I had to add that red text to get rid of the unused variable warning. It worked anyway but it didn't want to build. Or maybe it did build cuz it's just a warning, but all I saw was WARNING. I bet it's not even necessary but it was buggin me. It's hard to continue messing with code while seeing 2 weird warnings. idk if the ToString() is necessary though. I assume it is because the exceptions aren't strings.
Logged

.make Stuff happen.
Dropbox. If you don't have one, get it NOW! +250MB free if you follow my link tongue.

Mod code Generator ~50% complete but very usable:
http://dl.dropbox.com/u/24514984/modcodes/modcodes.htm
dcx2
Computer Engineer
Moderator
Legendary Member
*****

Karma: 165
Posts: 3468


WWW
« Reply #2 on: July 26, 2011, 12:16:38 AM »

Warnings are no big deal.  You can put that line in or leave it out.
Logged

Stuff
Hacker
Sr. Member
*****

Karma: 31
Posts: 415


0x80000000 = -0


« Reply #3 on: October 20, 2011, 03:11:51 PM »

For getDumpString(), it is an awesome function, but I think this would be better
Code:
        public static string getDumpString(BinaryReader input, UInt32 pointer)
        {
            pointer &= 0x0FFFFFFF; //this
            input.BaseStream.Seek(pointer, SeekOrigin.Begin);

            return readNullTerminatedString(input);
        }
before it was pointer -=0x80000000; and I was having trouble with it. The fault was mine though..I was passing an array with the pointers already minused. >.> My solution at the time was to add the 80000000 back before passing it, but after playing are with it for a while and learning about AND and masking, I made dumpAscii(). While writing that I remembered my huge array hat I don't feel like fixing, but I wanted dumpAscii() to be more useful than to just titles...And if I wanted to dump names for whatever reason, I'd have to change dumpAscii(). So I remembered looking at swap to learn how it works and:

Code:
        public static void DumpAscii(BinaryReader binread, string outtxt, UInt32 beginTable , UInt32 endTable)
        {
            string arrayout = Path.GetDirectoryName("DUMP80.BIN");
            arrayout = Path.Combine(arrayout, outtxt);
            TextWriter arraywrite = new StreamWriter(arrayout, true);
            int t = 0;
            //incase I do that thing with the array again
            beginTable &= 0x0FFFFFFF;
            endTable &= 0x0FFFFFFF;
            while (beginTable <= endTable)
            {
                if (binread.BaseStream.Position >= binread.BaseStream.Length) break;
                binread.BaseStream.Seek(beginTable, SeekOrigin.Begin);
                UInt32 pointerHere = Swap(binread.ReadUInt32());
                string txtTable = getDumpString(binread, pointerHere);
                arraywrite.WriteLine(String.Format("{0:x2}", t).ToUpper() + " = " + txtTable);//8bit digit
                //arraywrite.WriteLine(String.Format("{0:x4}", t).ToUpper() + " = " + txtTable);//16bit digit
                //arraywrite.WriteLine(String.Format("{0:x8}", t).ToUpper() + " = " + txtTable);//32bit...wut?
                beginTable += 0x4;
                t++;
            }
            arraywrite.WriteLine();
            arraywrite.Flush();
            arraywrite.Close();
            return;
        }
So I remembered the getDumpString(). I'm sure there will never be a time when you have to read past 0FFFFFFFF.

Also, the attachment doesn't work. I could put what I have in my dropbox when I get home.
Logged

.make Stuff happen.
Dropbox. If you don't have one, get it NOW! +250MB free if you follow my link tongue.

Mod code Generator ~50% complete but very usable:
http://dl.dropbox.com/u/24514984/modcodes/modcodes.htm
dcx2
Computer Engineer
Moderator
Legendary Member
*****

Karma: 165
Posts: 3468


WWW
« Reply #4 on: October 20, 2011, 03:49:39 PM »

Yeah attachments are broken now.  I'll have to dump this on my mediafire.
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!