Can any one tell me how can i make a program which uses commandline parameters to create another .exe file showing

a message box who's text and caption are set in the commandline ??

Thakyou for reading this.
Posted on 2003-05-06 09:09:53 by telophase
If you say only had one message box and a max length for the string, You could have a dummy PE and overwrite the data section with whatever value you wanted. For example in your dummy PE you have something like this....

stringdata db 256 DUP (" ")

invoke messagebox,NULL,stringdata,NULL,NULL

when you want to change the text you have only to find the offset of stringdata in your dummy PE and write in what you want. The offset wouldn't change so you can hard-code it in your program.

Just an idea, I've never tried it so I can't say 100% it'll work but it should. You may even be able to store the dummy PE as data in you resource section (RCDATA)

EDIT : Duh !
Posted on 2003-05-06 09:27:40 by donkey
How much do you pay for working example code?
Posted on 2003-05-06 09:34:02 by bazik

How much do you pay for working example code?

Hi Bazik,

My idea won't work ? Like I said I've never tried it and it's not something that I can ever see doing so I'm not too concerned. I'd be interested to know why not though, seems pretty logical and I can do it with a hex editor so doing it within an exe should be the same.
Posted on 2003-05-06 09:46:39 by donkey


Hi Bazik,

My idea won't work ? Like I said I've never tried it and it's not something that I can ever see doing so I'm not too concerned. I'd be interested to know why not though, seems pretty logical and I can do it with a hex editor so doing it within an exe should be the same.


I ment telophase not you ;)
Posted on 2003-05-06 09:49:10 by bazik
Awhile back I posted a gui version example of this exact type of program. It's here .

I'll leave it up to you to add the command line handling.



cheers,
will
Posted on 2003-05-06 13:45:18 by Will
Thankyou will and donkey for your help...
Posted on 2003-05-07 01:35:28 by telophase
will,

your gui program has helped me a lot but i didn't get the offset part:-

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

invoke SendMessage,hEdit1,WM_GETTEXT,63,addr ExeTemplate+0840h
invoke SendMessage,hEdit2,WM_GETTEXT,63,addr ExeTemplate+0800h

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

how did u actually get the offset's where you wanted to place the messagebox data??:confused:
Posted on 2003-05-07 02:29:42 by telophase
Iirc, I answered that question in that post.

I'm pretty sure that what I did was make a couple of calls to SetWindowText that don't get executed with the offsets to those variables. Then I got the offsets from a disassembler.


hope that answered the question,
will
Posted on 2003-05-07 11:04:38 by Will
+800 = offset to szcaption
+840 = offset to sztitle

I think... And i suppose the buffer allocated for the szcaption and sztitle is only 64(40h).
Posted on 2003-05-07 11:25:39 by roticv
i still cant get it why did u choose the 800h offset when i tried using the 700h offset the program didn't create

exe with my caption??:(
Posted on 2003-05-07 23:51:45 by telophase
Can't you make a seperate message box with seperate buffer and unstead of Appname call it Appname2 ?
Posted on 2003-05-08 00:28:45 by mrgone
Hi telophase,

You can get the offset by looking at the file with a hex editor. Put something in your buffer then find it in a hexeditor...
.386

.model flat,stdcall
option casemap:none

;###################################
; Include files

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

;###################################
; Libraries

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.data
buffer BYTE "my Buffer starts here",0


.data?
hInstance DWORD ?

.code

start:

invoke GetModuleHandle,NULL
mov hInstance,eax
invoke MessageBox,NULL,ADDR buffer,NULL,NULL
invoke ExitProcess,eax

end start
This is a screen shot of the hex editor (notice the offset is 800h)
Posted on 2003-05-08 00:45:29 by donkey
Thakx donkey ur idea has helped me but what if the buffer is empty somthing like

buffer db 255 dup(?)

then how do i find it??
Posted on 2003-05-08 00:55:14 by telophase
telophase,

Well then you have a problem :) Why not just use this then you can find it !

.data
buffer db 255 dup("Z")

After all who cares what's in there, it's going to be overwritten anyway.
Posted on 2003-05-08 01:01:31 by donkey
gr8 idea....
Thankyou once again but isn't there any other easier way rather then to mess around with Hex-Strings?
Posted on 2003-05-08 01:05:32 by telophase
Ah, I find that way incredibly easy. I mean you can't really ask for much easier than that. create your file then look for 05A5A5A5Ah (BTW that's a DWORD pans out as "ZZZZ")
Posted on 2003-05-08 01:10:00 by donkey
thnakyou very much for solving such a complicated problem;)
Posted on 2003-05-08 01:14:11 by telophase
That works fine too. What I had done was put in a couple of calls referencing those 2 buffers that would never be executed:

jmp around
invoke MessageBox,0,addr buffer1,addr buffer1,0
around:
.....
.....


Then you can disassemble it with w32dasm for example. Find the string reference to those buffers, and you'll have the offsets.


hope that cleared it up,
will
Posted on 2003-05-08 10:17:55 by Will
I think the data section is always aligned at a 2k boundary above the code section, that would pretty much explain the 800h and the fact that 2K is the smallest Win32 executable size.
Posted on 2003-05-08 10:29:53 by donkey