Solved

Editing hex codes in exe files.

Posted on 1998-10-25
9
259 Views
Last Modified: 2010-04-06
How do i do if i want to edit a hexcode in a file?
I know the offset - just need to change 4 bytes...
0
Comment
Question by:t0m3k
  • 5
  • 2
  • 2
9 Comments
 

Expert Comment

by:elkiors
ID: 1344224
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
0
 

Author Comment

by:t0m3k
ID: 1344225
it would be great if u could give me a tiny example.

/t0m3k
0
 

Expert Comment

by:elkiors
ID: 1344226
Okay bear with me a while and I'll see what I can come up with

Darren

0
 

Accepted Solution

by:
elkiors earned 50 total points
ID: 1344227
try this: there's no error checking or anything but it illustrates the idea.

procedure TForm1.Button1Click(Sender: TObject);
type
  hfile=RECORD
    hexitem:BYTE;
  END;

var
  hexfile:FILE OF hfile;
  hdata:hfile;
  distance:INTEGER;
  I:INTEGER;

begin
  distance:=152; {or whatever your offset is}
  ASSIGNFILE(hexfile,'C:\Test.Txt'); {or any other file}
  RESET(hexfile);
  SEEK(hexfile,distance);
  for I:=$2A TO $32 do {I've only done this to create data to populate hexitem}
  begin
    hdata.hexitem:=I;
    WRITE(hexfile,hdata);
  end;
  CLOSEFILE(hexfile);
end;

Hope this helps.

If you need anymore help let me know.

Beware changeing the bytes in an EXE file will probably kill it but I suppose you have your reasons.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:t0m3k
ID: 1344228
I've noticed that the offset must be in decimal format - not hexadecimal.
How do I convert, for example 0005:EA89 to decimal?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1344229
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
0
 

Expert Comment

by:elkiors
ID: 1344230
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

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1344231
The hex value would be Distance := $EAD9; not Distance := $5EA89;

Cheers,
Viktor
0
 

Expert Comment

by:elkiors
ID: 1344232
Oh yes, sorry

Any luck with evaluating the answer yet?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now