Solved

App to blockread itself

Posted on 2001-08-30
7
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 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