opening a DialogEX from outside the EXE

Posted on 2006-06-18
Last Modified: 2010-04-05
Hi guys, i'm kinda stuck with a idea.

I have a program that have some Custon Dialogs.

These dialogs have their handles when they are opened. When they get closed the only handle that remains is the main program.

1 - Is there a way to open these Custon Dialogs from outside the program (like if another program force them to show) ?
2 - If yes, what information I need to know to perform this action ?

I can find some Custom Dialogs inside the EXE by using the PE Explorer but i don't know if the information PE Explorer gives to me is enough to perform my action.

ty in adv
Question by:furmiga
  • 3
  • 2
  • 2
LVL 17

Accepted Solution

TheRealLoki earned 250 total points
ID: 16931078
to show a dialog in another application, where you have the handle for the dialog, you *can* do
    showwindow(thehandle, sw_show);
I'm not sure how it would handle the close message though (ie. if youthen tried to close the dialog)
Also, if you have not previously shown the dialog, you may not get the controls appearing.
if program A had not created the form, or it uses "ShowModal" or frees it, then you will not have a handle.

If you wrote both programs, then you could have Program B simply ask Program A to show it
ie. Program B does: PostMessage(program1handl, wm_uer+100, 1, 0); // 1 meaning "please show dialog 1 thanks"
(Program A has a routine to catch this message)

If you want Program B to get any properties from the dialog, then you may be better off putting the dialogs in a shared DLL for both programs to access.

Author Comment

ID: 16931423
Hey man thx for the reply.

The problem is that after I close the dialog, the hadler created for it disappears and even if I save the handle I cant open it from outside the program.

LVL 17

Expert Comment

ID: 16931597
if you just do a show, and a close, you can "reshow" it again
I did a simple demo
where i had 2 forms in the .dpr being created, and form 1 had a button that said ""
and button2 said caption := inttostr(form2.handle)
the handle was the same.. in fact, if i put text in an edit box on form2, it stays the same also.
I then tried "showwindow(thehandle, sw_show);" from another application, which worked.
so um.. my point is, you can reshow it, but not if you are dynamically creating it
(e.g. with TMyDialog1.create(self) do try showmodal; finally free; end; ) <-- this will lose the handle

Does "Program 2" need to get data from the dialog?
Are you writing Program 1 and Program 2? (ie. how much design scope do you have, so we can get this working)
Does this have to work from a remote machine, or are they both on the same machine?
When Program 2 makes the dialog appear, do you want program 1 to "wait" until the dialog is closed?
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.


Author Comment

ID: 16934935
All i want is activate the menu in program 2, using the program 1 for it. The menu in program 2 is a normal menu "file - etc - etc - about" but this menu only exists inside the EXE. It never shows. When you use some resource app you can see the menu inside it but, again, it never really shows. The app don't allocate handlers for the menu either. I'm just wondering if there is a possibility to show this menu (or inject a code to force it to open). There is no possibility to change the code in app2 since all i have is it's executable.
LVL 33

Assisted Solution

Slick812 earned 250 total points
ID: 16936152
hello furmiga , , I am not sure about some of the things you talk about, ,
First, in the program that you want to call the "DialogEx" and "Menu", , are these 2 a "Resource" compiled, ,  or are they "run time created" without any resouce reference. . .  as far as I can tell from your comments, They are in the programs resource set.
If these are in the resource, then I beleive you can load the executable as a library as in
hLibrary := LoadLibrary('C:\\Folder1.prog.exe');
 , and then do an API like CreateDialog( ) or  DialogBox( ) and use the hLibray as the resource hInstance.
Seems like there is also a LoadMenu( ) function

Author Comment

ID: 16936639
Hi Slick thanks for the reply.

Look what I have:

PE Explorer.exe --> This program alows anyone to view and change some dll / exe resources. It shows Dialogs, menus, strings, icons etc.

Program.exe --> This is the program I want to change.

Now, when I load Program.exe into PE Explorer I can see 3 menus and some dialogs.

These menu / Dialogs never appear in the Program.exe (when it's running) But they are inside the Program.exe somewhere as we can see in the PE Explorer.

My question is: How can I "force" program.exe to open these Dialogs while its running ? I don't know if they will interact with the proram.exe since they are not actualy beeing called by real situations but still, is there any chance to open them ?

LVL 33

Expert Comment

ID: 16938899
OH, I see a little more now, ,  
The program called  Program.exe, when it is running, will be doing what it was designed to do (programming of its code), but you want to have another program (your program) run code inside this running Program.exe. . . as I understand your last comment? . . .
I have tried to "Hack" into other running programs to try and get some minor information, but I can tell you, trying to do anything in another program (other memory space) is a really difficult thing. . . and for the most part (my opinion) a NON Productive effort, you may could execute a resource DIALOGEX in another process memory space, however, you will have no easy way (maybe no way) to route that DIALOGEX window to use the "code" (window message function ect) inside that other program,  I think it may be posible to dis-assemble some 32-bit programs and get some hints as to the function memory positions, but I do not think here at EE Delphi, that this is the place for such advanced programming methods.
Have you any experience in getting into the memory space of anothe running program? It is a hassel, much trouble for me.

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
calling procedure inside activexForm from secondform 1 207
Mydac connection data base issue 3 106
code issue 8 84
Printing problem 2 72
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now