Hacking Automating a Wii U utility...

mixelpixx

hardware monkey
OP
Member
Joined
Aug 10, 2014
Messages
133
Trophies
0
Location
y0uR m0mz b0x
XP
366
Country
United States
Howdy,

Since the Wii U is progressing nicely I thought maybe getting a couple of command line tools into a more friendly interface might be something fun to do.

So we have DiscU (@ 2.1b) I thought the first thing would be to convert Hex strings to binary and write them to a file, eliminating doing this manually. I am working in VB / VS 2013, writing code that should be compatible back to 2010. SO far this is a form with a button ( I have more completed

**There will be no posting of actual keys to anything in this thread**

Code:
Public Function Hex2ByteArr(ByVal sHex As String) As Byte()
        Dim n As Long
        Dim nCount As Long
        Dim bArr() As Byte
        'First of all, make sure the length of the hex string is even, if it is not then
        'put a "0" at the beginning
        nCount = Len(sHex)
        If (nCount And 1) = 1 Then
            sHex = "0" & sHex
            nCount = nCount + 1
        End If
        'ReDim the Byte array
        ReDim bArr(nCount \ 2 - 1) 'we subtract 1 since the array is zero based
        For n = 1 To nCount Step 2
            'Convert the hex numbers into decimal values and store them in the byte array
            bArr((n - 1) \ 2) = CByte("&H" & Mid$(sHex, n, 2))
        Next
        'Return the array
        Hex2ByteArr = bArr
    End Function
 
 
 
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
 
        Dim bArr() As Byte
 
        Dim hFile As Integer
 
        bArr = Hex2ByteArr("027C9557648A1A996D25BFCC40F63856")
        'You should of course pass the whole hex string to the function above.
        '--
        'Save it to a file
        hFile = FreeFile()
 
        Using writer As BinaryWriter = New BinaryWriter(File.Open("diskkey.bin", FileMode.Create))
            ' Write each integer.
            For Each value As Int32 In bArr
                writer.Write(value)
            Next
        End Using
 
 
    End Sub


Only issue is how it is creating the binary file. Its been a while so I am sure the mistake is simple, at first I couldn't get it to handle a hexstring that large, now it will write file but it is padding like 4 0's between.

Anyone know where I went wrong?

(also I will include the source (- naughty bits) when this tiny issue gets solved.)
 

yahoo

G͝B͢A͜t͞em҉p̡ R̨e͢g̷ul̨aŗ
Member
Joined
Aug 4, 2014
Messages
345
Trophies
0
XP
532
Country
United States
At first glance it looks like there's potential for off-by-one errors. Do you have any unit tests? Have you tried stepping through your code with a debugger to watch what is happening each loop of the Hex2ByteArray function.
 
  • Like
Reactions: mixelpixx
D

Deleted User

Guest
I could help you with Visual Basic, but I don't know what diskkey.bin should look like :/

this is the result of your code:
Code:
02 00 00 00 7C 00 00 00 95 00 00 00 57 00 00 00 64 00 00 00 8A 00 00 00 1A 00 00 00 99 00 00 00 6D 00 00 00 25 00 00 00 BF 00 00 00 CC 00 00 00 40 00 00 00 F6 00 00 00 38 00 00 00 56 00 00 00
it is supposed to be : ?
Code:
02 00 7C 00 95 00 57 00 64 00 8A 00 1A 00 99 00 6D 00 25 00 BF 00 CC 00 40 00 F6 00 38 00 56 00
or ?
Code:
02 7C 95 57 64 8A 1A 99 6D 25 BF CC 40 F6 38 56
 
  • Like
Reactions: mixelpixx
D

Deleted User

Guest
Code:
        Using writer As BinaryWriter = New BinaryWriter(File.Open("diskkey.bin", FileMode.Create))
            writer.Write(bArr)
        End Using

;)
 
  • Like
Reactions: mixelpixx

Sammi Husky

Well-Known Member
Member
Joined
Jul 6, 2014
Messages
312
Trophies
0
Age
30
XP
508
Country
United States
EDIT:

EDIT:

Code:
        Using writer As BinaryWriter = New BinaryWriter(File.Open("diskkey.bin", FileMode.Create))
            writer.Write(bArr)
        End Using

;)

Or you can do this. Ninja'd lol


Code:
            For Each value As Int32 In bArr
                writer.Write(value)

Change Int32 here in Button1_Click() to byte. That should fix the problemo. The reason it was doing that was just because it's treating (and subsequently writing) the data you're accessing in the array as a 32 bit integer, rather than a single byte like you wanted it to. :)
 
D

Deleted User

Guest
Change Int32 here in Button1_Click() to byte. That should fix the problemo. The reason it was doing that was just because it's treating (and subsequently writing) the data you're accessing in the array as a 32 bit integer, rather than a single byte like you wanted it to. :)

It's shorter to change
Code:
        Using writer As BinaryWriter = New BinaryWriter(File.Open("diskkey.bin", FileMode.Create))
            ' Write each integer.
            For Each value As Int32 In bArr
                writer.Write(value)
            Next
        End Using
to
Code:
        Using writer As BinaryWriter = New BinaryWriter(File.Open("diskkey.bin", FileMode.Create))
            writer.Write(bArr)
        End Using

but Yes,
Code:
For Each value As Byte In bArr
will work as well.
 
  • Like
Reactions: mixelpixx

mixelpixx

hardware monkey
OP
Member
Joined
Aug 10, 2014
Messages
133
Trophies
0
Location
y0uR m0mz b0x
XP
366
Country
United States
Ok. You guys bit. Thank you. I will post the whole thing this afternoon, and what I am aiming to do, want to add DiscU, maybe some BFRES utilities. Since I was unable to get the source for Disc U I am just wrapping around it, generating a diskkey.bin (and the other key) for whatever title is selected.
 

mixelpixx

hardware monkey
OP
Member
Joined
Aug 10, 2014
Messages
133
Trophies
0
Location
y0uR m0mz b0x
XP
366
Country
United States
you can try it out, and give feedback if you so desire. I would like to add a few more items to it, like being able to edit the games list, folder renaming, etc.

Code:
http://www.ps3hax.net/showthread.php?t=92880
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • Psionic Roshambo @ Psionic Roshambo:
    Today is a laid back day yoga Thai Chi and some light king fun😄
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    @BigOnYa, that's just for entertainment value lol
    +1
  • BigOnYa @ BigOnYa:
    AFC/ NFC championship games on today, so yea lazy day for me too. May goto BW3 n get some wings & beer and watch first half. Have gift cards that expire soon.
    +1
  • Cranesbill @ Cranesbill:
    Gentlemen, emergency, where are the rules of this site?
  • Cranesbill @ Cranesbill:
    Some bastard believes I cant joke around unless it's specifically in the Edge
  • Cranesbill @ Cranesbill:
    Thanks, Quiver
    +1
  • Xdqwerty @ Xdqwerty:
    @Cranesbill, You're welcome
  • Cranesbill @ Cranesbill:
    Gosh these rules are shitty
  • Xdqwerty @ Xdqwerty:
    @Cranesbill, also congrats on 1000 messages
  • Cranesbill @ Cranesbill:
    Only English is allowed?
  • Cranesbill @ Cranesbill:
    Oh, thanks
  • Cranesbill @ Cranesbill:
    Oh my gosh, what kind of site are they trying to make here? Professional? Yeah after 20 years I'm sure y'all succeeded from that. 'ucking dictators
    +1
  • Cranesbill @ Cranesbill:
    Stay on topic? Like like we can stay in topic in real life?? Not
  • Xdqwerty @ Xdqwerty:
    @Cranesbill, wait what
  • Xdqwerty @ Xdqwerty:
    @Cranesbill, also I think the stay on topic part refers to the threads
  • Cranesbill @ Cranesbill:
    Yeah it's all in rules, act like a child so they can think that they dominant you
  • Cranesbill @ Cranesbill:
    @Xdqwerty I get that, but have some leniency, don't delete anything that's slightly off topic from the main topic
    +1
  • Xdqwerty @ Xdqwerty:
    @Cranesbill, Well, life taught me that you always have to be obedient
  • Cranesbill @ Cranesbill:
    No, you do what you love and what's right (As long it's not anything world ending)
  • Xdqwerty @ Xdqwerty:
    @Cranesbill, I learnt it the bad way, mostly irl
  • Cranesbill @ Cranesbill:
    Well you had bad environments and this is the one place where your freedom is at almost no limit
    +1
  • JollyBaker @ JollyBaker:
    Today is Pizza Tower's 2nd anniversary so that's cool
  • Xdqwerty @ Xdqwerty:
    @JollyBaker, I stopped playing it bc it ran like shit on my pc
  • Xdqwerty @ Xdqwerty:
    @Cranesbill, good point
    Xdqwerty @ Xdqwerty: @Cranesbill, good point