Jump to content

EXE File!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
SirStorm25

SirStorm25

    Newbie

  • Members
  • Pip
  • 9 posts
Hi all, i was wondering how I would achieve the below:

The user enters some text into a TEdit, then they click a button, when the button is clicked it creates a file (EXE) that when ran displays the text the user entered (Console App). Basically, like a small compiler that can only do the 1 thing.
I've heard about TImageFileHeader, but i've no idea how to use that to create a console app.


procedure TForm1.WritePEHeader(ProgName: string; MsgText: string);


const

  PESig: DWORD = $00004550;


  DOSStub: array[0..111] of Byte = (

    $4D, $5A, $6C, $00, $01, $00, $00, $00, $04, $00, $11, $00, $FF, $FF,

    $03, $00, $00, $01, $00, $00, $00, $00, $00, $00, $40, $00, $00, $00,

    $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,

    $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,

    $00, $00, $00, $00, $70, $00, $00, $00, $0E, $1F, $BA, $0E, $00, $B4,

    $09, $CD, $21, $B8, $00, $4C, $CD, $21, $54, $68, $69, $73, $20, $70,

    $72, $6F, $67, $72, $61, $6D, $20, $72, $65, $71, $75, $69, $72, $65,

    $73, $20, $57, $69, $6E, $33, $32, $0D, $0A, $24, $24, $41, $50, $24);


  IDataRVA = $1000;

  CodeRVA = $2000;

  BSSRVA = $3000;


var

  PEData: TImageFileHeader;


  F: File;

begin

  AssignFile(F, GetCurrentDir + '\output.exe');

  ReWrite(F);

  BlockWrite (F, DOSStub, SizeOf(DOSStub));


  BlockWrite (F, PESig, SizeOf(PESig));

  PEHeader.Machine:= $120;

  PEHeader.NumberOfSections:= $3;

  PEHeader.TimeDateStamp:= $340;

  PEHeader.Characteristics:= $3000;

  BlockWrite(F, PEData, SizeOf(PEData));

end;

But, I don't really know how to make it load as a console app and display the text, then pause.

Hope you can help!
SirStorm25.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What I would do is create a console app that displays some text and then pauses. With that code, you can create a program that will do the same thing.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
abjhon123

abjhon123

    Newbie

  • Members
  • Pip
  • 4 posts
hi
dear. I does not know .exe file. What is .exe file .
say me.
thanks

#4
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts

abjhon123 said:

hi
dear. I does not know .exe file. What is .exe file .
say me.
thanks

Uh... WTF?

An .exe file is the standard Windows executable file... A program..
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#5
Rustix666

Rustix666

    Newbie

  • Members
  • PipPip
  • 15 posts
Yeh :P
If you still need a solution PM me. I have an idea.