Click here to Skip to main content
15,886,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

As the title says I need help with Finding and replacing hex values.

I have this code which is awesome !!
VB
Public Class MainForm
    Dim FP = "C:\AlMnara.dll"
    Dim FS As System.IO.FileStream
    Dim BW As System.IO.BinaryWriter
  Private Sub Replace_Click(sender As Object, e As EventArgs) Handles Replace.Click
      FS = New System.IO.FileStream(FP & ".Replaced", IO.FileMode.OpenOrCreate)
      BW = New System.IO.BinaryWriter(FS)
      FS.Position = &H10D4
      BW.Write(&H8838)
      FS.Close()
      BW.Close()
  End Sub
End Class


But my problem is that i cant always open the ".dll" and search for the Offset then "copy-Paste" it and make an update to my Application.

So is there a code that it could search and replace the hex values without giving the "Offset" ?

Original hex value = &H9939
New hex value = &H8838

Thanks in Advance :D
Posted
Updated 11-Dec-14 16:05pm
v2
Comments
PIEBALDconsult 11-Dec-14 22:25pm    
It's just bytes, it shouldn't be a problem, unless it replaced the wrong bytes.
Tomas Takac 12-Dec-14 2:57am    
I don't understand. First of all you are not touching the .dll in your code but opening the .replaced file. Secondly, if you don't want to use the offset then what do you want to do? Loop trough all 2-byte words in the files and replace one value with another? Sounds pretty wild, I'm wondering what this is good for.
Fa3o 12-Dec-14 7:02am    
1-Yes you're right, But i meant it will be ".Replaced".
Original line is : FS = New System.IO.FileStream(FP, IO.FileMode.OpenOrCreate)

2-Yes i want to loop, But it seems when I loop it only can search for 1 byte and replace it with 2 bytes which obviously will crash the application.

3-Yes its WILD that's why i never found it while I tried to search for it, Also it's good for "People" The "AlMnara" Application has a bug and they Developer cant seems to get it when i told him about these codes, So i said if its OK to re-write the files and he is OK with it, but he said to give him some credits.
PS: the application is for Religion stuff on "Paltalk" chat
Tomas Takac 12-Dec-14 9:15am    
You would need to read the file byte per byte and keep a sliding 2 byte window which you will compare to your two byte. Sorry, it's long time I've been working with VB so I cannot help you with the code.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900