WiiRd forum

Wii & Development => Wii & Gamecube Hacking Tools => Topic started by: dcx2 on July 20, 2011, 02:19:11 AM



Title: bin to txt
Post by: dcx2 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.


Title: Re: bin to txt
Post by: Stuff on July 26, 2011, 12:06:00 AM
            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.


Title: Re: bin to txt
Post by: dcx2 on July 26, 2011, 12:16:38 AM
Warnings are no big deal.  You can put that line in or leave it out.


Title: Re: bin to txt
Post by: Stuff 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.


Title: Re: bin to txt
Post by: dcx2 on October 20, 2011, 03:49:39 PM
Yeah attachments are broken now.  I'll have to dump this on my mediafire.