Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

App to blockread itself

Posted on 2001-08-30
7
Medium Priority
?
261 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 400 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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 response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

661 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