Link to home
Start Free TrialLog in
Avatar of t0m3k
t0m3k

asked on

Editing hex codes in exe files.

How do i do if i want to edit a hexcode in a file?
I know the offset - just need to change 4 bytes...
Avatar of elkiors
elkiors

Open the file using type byte, then use SEEK to position the record pointer to your offset, then WRITE to the file whatever you want, then CLOSE the file ... and that's it in a nutshell. If you want me to produce full code snippet for you, let me know.

Darren
Avatar of t0m3k

ASKER

it would be great if u could give me a tiny example.

/t0m3k
Okay bear with me a while and I'll see what I can come up with

Darren

ASKER CERTIFIED SOLUTION
Avatar of elkiors
elkiors

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of t0m3k

ASKER

I've noticed that the offset must be in decimal format - not hexadecimal.
How do I convert, for example 0005:EA89 to decimal?
in decimal that would be... 60121.. Hope this helps :-)

Segment:Offset

0005:EA89

Hex = Offset * 10h + Offset

Hex = 0005 * 10h + EA89
Hex = EAD9
HexToDec = 60121

Cheers,
Viktor
Why do you need to do any hex to dec conversion ? the standard integer can take decimal as well as hex numbers, just prefix the number with $ to designate it as base16, just as I have done in the example code for example,

Distance:=$5EA89;

would assign the decimal value 60121 to Distance.

Hope this helps

Darren

The hex value would be Distance := $EAD9; not Distance := $5EA89;

Cheers,
Viktor
Oh yes, sorry

Any luck with evaluating the answer yet?