[HELP] Converting a String to Hex? (C#)

Discussion in 'Wii U - Hacking & Backup Loaders' started by Dekirai, Mar 16, 2017.

  1. Dekirai
    OP

    Dekirai GBAtemp Advanced Fan

    Member
    6
    Jun 21, 2016
    Germany
    Hello,

    I searched whole google for a solution, but the sad thing is that nothing of it works with gecko together.

    What I did is this:

    Code:
            private void button3_Click(object sender, RoutedEventArgs e)
            {
                this.tcpGecko.poke32(0x109763F0, 0x73656100);
            }
    

    But I want to use the poke as a Textbox with String.
    So for example;
    I am doing a Maploader for Wind Waker and I want to load the Map "DmSpot0" so I input "DmSpot0" into the Textbox and its getting converted to Hex so that the game will load the map.

    So it should something like this in the end

    Code:
            private void button3_Click(object sender, RoutedEventArgs e)
            {
                this.tcpGecko.poke32(0x109763F0, blablablabla(textBox.Text); // Converted String to Hex
            }
    

    DmSpot0 is btw longer than 32 Bits, so do I have to do something special for it, or does it write auto. to the address "109763F4"?

    Sources I tried:

    http://stackoverflow.com/questions/16999604/convert-string-to-hex-string-in-c-sharp
    https://www.easycalculation.com/ascii-hex.php
    http://stackoverflow.com/questions/18627304/convert-ascii-in-a-byte-array-to-string
    http://stackoverflow.com/questions/15920741/convert-from-string-ascii-to-string-hex
    http://string-functions.com/string-hex.aspx
    https://dotnet-snippets.de/snippet/string-in-hex-wandeln/59

    I'm pretty new into C# so don't blame me please.
     
  2. pwsincd

    pwsincd Garage Flower

    Member
    10
    GBAtemp Patron
    pwsincd is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    Dec 4, 2011
    Manchester UK
    i dunno , would you // string to byte array then byte array to hex ...

    using the System.BitConverter. for the latter ?
     
  3. Dekirai
    OP

    Dekirai GBAtemp Advanced Fan

    Member
    6
    Jun 21, 2016
    Germany
    If I remember right, I already tried this
     
  4. pwsincd

    pwsincd Garage Flower

    Member
    10
    GBAtemp Patron
    pwsincd is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    Dec 4, 2011
    Manchester UK
    Code:
                byte[] vals = { 0x01, 0xAA, 0xB1, 0xDC, 0x10, 0xDD };
    
                string str = BitConverter.ToString(vals);
                Console.WriteLine(str);
    
                str = BitConverter.ToString(vals).Replace("-", "");
                Console.WriteLine(str);
    
                /*Output:
                  01-AA-B1-DC-10-DD
                  01AAB1DC10DD
                 */
    like the example here

    https://msdn.microsoft.com/en-us/library/bb311038.aspx
     
  5. Dekirai
    OP

    Dekirai GBAtemp Advanced Fan

    Member
    6
    Jun 21, 2016
    Germany
    Yea I already tried this.
    Maybe I do something wrong too, but I can't get it to work. :/
     
  6. Dionicio3

    Dionicio3 Skiddo

    Member
    10
    Feb 26, 2017
    United States
    Hollister, CA
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice