Need Help [Media.PK2 Edit]

06/02/2011 19:38 lvszoc#1
Hi,
I wanna write a mediapatcher with vb.net...

I can wrote IP adresses in media.pk2 but silkroad crashes...

Please help me.

Code:
Dim fs As New FileStream("C:\Program Files (x86)\Silkroad\Media.pk2", FileMode.Open, FileAccess.Write)
        Dim br As New BinaryWriter(fs)
        Dim bytes() As Byte
        'IP1
        br.BaseStream.Position = "&H25F24011"
        bytes = System.Text.Encoding.Default.GetBytes(ip1.Text)
        br.Write(bytes)
        If ip1.TextLength <> 16 Then
            For i = 1 To 16 - ip1.TextLength
                Dim tmp As Byte = &H0
                br.Write(tmp)
            Next
        End If
        'IP2
        br.BaseStream.Position = "&H25F24026"
        bytes = System.Text.Encoding.Default.GetBytes(ip2.Text)
        br.Write(bytes)
        If ip2.TextLength <> 16 Then
            For i = 1 To 16 - ip2.TextLength
                Dim tmp As Byte = &H0
                br.Write(tmp)
            Next
        End If
        'IP3
        br.BaseStream.Position = "&H25F2403B"
        bytes = System.Text.Encoding.Default.GetBytes(ip3.Text)
        br.Write(bytes)
        If ip3.TextLength <> 16 Then
            For i = 1 To 16 - ip3.TextLength
                Dim tmp As Byte = &H0
                br.Write(tmp)
            Next
        End If
        'IP4
        br.BaseStream.Position = "&H25F24050"
        bytes = System.Text.Encoding.Default.GetBytes(ip4.Text)
        br.Write(bytes)
        If ip4.TextLength <> 16 Then
            For i = 1 To 16 - ip4.TextLength
                Dim tmp As Byte = &H0
                br.Write(tmp)
            Next
        End If
        'port
        br.BaseStream.Position = "&H25F24461"
        bytes = System.Text.Encoding.Default.GetBytes(port.Text)
        br.Write(bytes)
        If ip4.TextLength <> 5 Then
            For i = 1 To 5 - port.TextLength
                Dim tmp As Byte = &H0
                br.Write(tmp)
            Next
        End If
        br.Close()
        fs.Close()
06/02/2011 20:13 bootdisk#2
I don't know c# but...

Code:
br.BaseStream.Position = "&H25F24050"
are you sure about those offsets?
where did you get those? are the actual offsets?
06/02/2011 20:31 lvszoc#3
[Only registered and activated users can see links. Click Here To Register...]

ps: and this code is vb.net :P not c#
06/03/2011 02:38 bootdisk#4
first of all you should update the lengths if the new string is greater or smaller than the actual one.
second, previous to those strings there is a DWORD telling how many bytes will follow (haven't checked... I just saw your picture).

3rd... it might be vb.net but for me they all look the same xD

Edit: what about if it's greater? it will start writing other files present in the pk2 file.
So it's like:
DWORD <-- size of the string
BYTES <-- null terminated string
06/03/2011 21:05 lesderid#5
Quote:
Originally Posted by bootdisk View Post
3rd... it might be vb.net but for me they all look the same xD
Noob. xD

VB.Net is English-like syntax.
C# is C-like syntax.