Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
0 user currently in Programming. | 3 guests |
Acmlm's Board - I2 Archive - Programming - Editing a specific hex value in a file using Visual Basic 6.00 | | | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
User | Post | ||
Sukasa Boomboom Error 349857348734534: The system experienced an error. Level: 57 Posts: 621/1981 EXP: 1446921 For next: 39007 Since: 02-06-05 From: *Shrug* Since last post: 6 days Last activity: 1 day |
| ||
Hey! I am trying to put together a project at school for extra marks, and I am wondering how to edit a specific offset. I kinda mean something like "gosub editthedamnhex (addresstoedit, newvalue)", and "gosub getthedamnhex" with a global value. Could anyone help me, please? | |||
Squash Monster New Age Retro Hippie Togateiru Fohku Kohgeki!! GRUNGE no HAMSTER otona bite Peace love and turnpike! Level: 40 Posts: 578/677 EXP: 430507 For next: 10802 Since: 03-15-04 From: Maryland (of the Country Between Canada and Mexico) Since last post: 5 hours Last activity: 5 hours |
| ||
I'm going to assume that you've already learned VB's version of sequential and random files. Open the file the same as you would with one of those, except open it for Binary instead of Random, Append, Input, or Output, or whatever they called them. Use Get and Put like you would with Random, but instead of giving it a record number, give it an offset. They'll both put as many bytes as whatever variable type you use with them takes, so you probably want to only use the byte type. And VB numbers offsets starting with 1 instead of 0, so keep that in mind. |
|||
interdpth Rex Level: 36 Posts: 462/527 EXP: 294398 For next: 13712 Since: 03-20-04 Since last post: 10 days Last activity: 31 days |
| ||
It's more of open "a.hex" for binary as #1 seek #1, &H6 get #1, ,a get #1, 7, b put #1, 0x533, c close #1 |
|||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 4537/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
I don't recall having to use seek for that. Been a while since I did VB but IIRC, just something like put #1, SomeOffset, SomeValue would work. You should use variable file numbers though:Dim nFileNum as Integer This way you don't need to worry about whether you already have a file open as #1 or what have you. FreeFile will always be a free file number. |
|||
Sukasa Boomboom Error 349857348734534: The system experienced an error. Level: 57 Posts: 628/1981 EXP: 1446921 For next: 39007 Since: 02-06-05 From: *Shrug* Since last post: 6 days Last activity: 1 day |
| ||
Originally posted by interdpth Okay, I do know a bit, but I am at a loss with the seek statement, as well as a little mislead by the get statements. could you please help out a bit more with this? |
|||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 4557/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
If you're just planning to blindly write the value, the get statement isn't necessary, but it's a good idea to make sure the value you're changing is right (to ensure the user opened the right file). Simple examples of using Get and Put in Binary mode: Get #nFileNum, &h1234, X -Reads from file offset 0x1233 (since VB starts at 1) in file #nFileNum into X. Number of bytes read is however many X is. (Byte = 1, Integer = 2, Long = 4.) Put #nFileNum, &h1234, X -Writes X to file offset 0x1233 in file #nFileNum. Again, number of bytes is size of X. The seek doesn't even seem necessary, since Get and Put take direct addresses anyway. It might be possible to use them without to do sequential reading and writing, but I generally just use a local variable and increment it for that. |
|||
Sukasa Boomboom Error 349857348734534: The system experienced an error. Level: 57 Posts: 632/1981 EXP: 1446921 For next: 39007 Since: 02-06-05 From: *Shrug* Since last post: 6 days Last activity: 1 day |
| ||
well, what I am trying to do should be simple enough. I'm going to check a file's header that will be in the file type to be edited already, and compare it to an internal checksum. If they match, the program will allow editing, if not, it won't and will not open the file in the first place. Thanks a ton guys ...for those who were wondering, the program is SMWOE. I had a thread on it a week or two ago in the SMW hacking forum. |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
Acmlm's Board - I2 Archive - Programming - Editing a specific hex value in a file using Visual Basic 6.00 | | | |