is vb capable of going to cetrain offsets in a file and editing single bytes?
if so wht do i need to know?
Printable View
is vb capable of going to cetrain offsets in a file and editing single bytes?
if so wht do i need to know?
Not really. You can load an array of bytes and access them using the array index though. Does that help?
Sure it can. The following code opens a file, gets the byte at position 87, checks if it is the letter A and if it isn't sets it to the letter A. Check out these I/O functions in your help file - Open, Get, Put, Seek (statement), Seek (function), LOC, LOF, Close
VB Code:
Dim lngFileNo as Long Dim bytData as Byte lngFileNo = FreeFile Open FileName For Binary As lngFileNo Get lngFileNo, 87, bytData If bytData <> Asc("A") then Put lngFileNo, 87, asc("A") End If Close lngFileNo
ok i need to get to offset 0x3A7E3
and chnage it from 0D to 00
how would i do this?
cuz that way didn't work
Did you try changing the hex value to its decimal equivalent of 239587 and using 13 as the replacement value?
no i did not...i guess i'll have to find my hex calc
I did the math for you.
thanks for that...it will help..not sure if this is resolved cuz i havn't tried it...still gotta another project to get done
btw is there an equation for this....or wht...hex calc?
Windows calculator can do that
plz expand on this
attached
There is no conversion necessary, VB will handle everything. In VB, you represent hexadecimal numbers directly by using the prefix &H instead of 0x.
VB Code:
Dim lngFileNo As Long Dim bytData As Byte lngFileNo = FreeFile Open FileName For Binary As lngFileNo Get lngFileNo, &H3A7E3, bytData If bytData <> &HD Then Put lngFileNo, &H3A7E3, &H0 End If Close lngFileNo
Opps - misread the original request. I thought hacker was refering to memory blocks (assembler background kicked in) not files. Apologies for the bum steer.
But actually, I am wrong again. This explains the first steps of even doing that (using StrPtr, VarPtr and ObjPtr). You live and learn. :thumb:
alright thats awesome thanks alot to all who helped
First off, I am terribly sorry for bringing up a topic thats been buried for 3 years. But I couldn't find any others on my question.
My question is that is there a way to select a region like &H420 to &H430 and check for the things in there and edit it at once? Along the lines of something like:
Code:Dim lngFileNo As Long
Dim bytData As Byte
lngFileNo = FreeFile
Open FileName For Binary As lngFileNo
Get lngFileNo, &H3A7E3, bytData
If bytData <> &HD Then
Put lngFileNo, &H3A7E3, &H0
End If
Close lngFileNo
Get all the bytes in the range and put them into an array.
Just be careful when working with binary files at the byte level. If anything is incorrect the file could become "corrupt"...Code:Dim bytData() as Byte
Redim bytData(&H430 - &H420)
Get lngFileNo, &H3A7E3, bytData
'code to check and change bytData array
'now overwrite the existing data in the file
Put lngFileNo, &H3A7E3, bytData
ah thank you so much for the quick reply
but i have 1 more question, is there a way to put together &H and a variable i want to do &H & var & but it just wont work :S
Next time we'd prefer if you started a new thread.Quote:
Originally Posted by majin