Solved

App to blockread itself

Posted on 2001-08-30
7
241 Views
Last Modified: 2010-04-06
I want to write an app that will blockread only a specific part of itself, and then blockwrite it into a new file.

how do i do this?
0
Comment
Question by:rogueripper
7 Comments
 
LVL 3

Expert Comment

by:VSF
ID: 6440176
You should take a look at this web site:

http://delphi.does.it/

The "Self Modifying" demo demonstrates a nice work around on how to read itself.
The demo uses stream access, but the idea can be easily converted to a blockread approuch!

Direct links
Self Modifying Exe Demo-NEW VERSION!!!
http://www.geocities.com/gacarpenter386/SelfMod.zip

Download the Source for Self Modifying Exe Demo!
http://www.geocities.com/gacarpenter386/SelfModsrc.zip

View ReadMe file for Self Modifying Exe :-)
http://www.geocities.com/gacarpenter386/readme.html

Hope this helps!

VSF
www.victory.hpg.com.br

0
 
LVL 5

Expert Comment

by:Gwena
ID: 6441768
Hi VSF :-)
  I had to move my site back to geocities after the server where it was stored got hacked :-(  the direct links don't work at geo... they have disabled that... but you should be able to right-click on the links and choose 'save target as' :-)

By the way I'm finishing up a unit that will greatly simplify using self-altering exe's

also... you can read a block of data that is in your exe right from the ram... you don't need to get the file from the disk... try this procedure


TForm1.Button1Click(Sender: TObject);
Var x: Byte;
begin
  Form1.Caption := '';
  For X := 80 to 115 do
  begin
    Form1.Caption := Form1.Caption +
    Char(pointer(Hinstance+X)^);
  end;
end;

clicking the button will cause the PE dos stub message to be displayed as the forms caption... you can read any block of data from the exe just by altering the line

For X := 80 to 115 do

for instance using For X := 0 to 2 do
will set the caption to 'MZP' the first 3 bytes of any delphi app ...it's simple to read the bytes into an array or whatever... just grab the block of data you need with this simple technique :-)

To put that block of data into another file on disk I recommend using streams ... it's easier than old style pascal file handling :-)

0
 
LVL 5

Expert Comment

by:Gwena
ID: 6441780
Oh! I forgot to mention that an exe in ram differs ever so slightly from it's image on the disk.... but nearly all of it is identical :-)
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Expert Comment

by:Pedja
ID: 6442131
There is no problem to open exe of the current
application as any other file. There is no difference.

Pedja
0
 
LVL 5

Accepted Solution

by:
Gwena earned 100 total points
ID: 6442572
Hi Pedia :-)

Yes it's easy for an exe to read it's own exe file from disk into a stream while it runs... just do it like this.

var ExeStream: TFileStream;
begin
ExeStream:=TFileStream.Create(Application.ExeName,fmOpenRead or fmShareDenyNone);
  try
  //do whatever you want with the stream here
  finally
  ExeStream.Free;
  end;
end;

when this runs you will have the running exe in the stream
ExeStream
0
 

Author Comment

by:rogueripper
ID: 6443998
WoW! thanx for all the help!

:o)


0
 
LVL 5

Expert Comment

by:Gwena
ID: 6445710
Your welcome!

And thanks for the points :-)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

23 Experts available now in Live!

Get 1:1 Help Now