Solved

App to blockread itself

Posted on 2001-08-30
7
248 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 323
Using idhttp to login to instagram 2 106
JAudiorecorder record freezing the app 29 74
Firemonkey DbLookupComboBox equivalent ? 2 54
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

840 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