Hooking Labels and Progressbars

c++ / delphi package - dll injection and api hooking
Post Reply
stOrM!
Posts: 51
Joined: Thu Jul 15, 2004 7:38 pm

Hooking Labels and Progressbars

Post by stOrM! »

Well I hope you have some patience with me here, because I don't really have an idea about hooking and if this can be done with madcodehook...

The Situation:
I've created a small application where users are able to drag and drop files from the explorer into a Grid....Those Files are all installers... So if the User later clicks the start button, in my application I then enumerate all entrys in the Grid and starting the installers with CreateProcessandWait one by one...

The Problem:
All installer files have a GUI with a Label and a Progressbar showing the installation process... Well I would like to start the installer files hidden, then hook into the label updating and progressbar progress.
Then I could show the Users how far we are with installing while not showing the original Installer Window...


Thanx a lot for patience and all help

kindest regards
s!
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Are those totally different installers? Or all they all "the same", just with different content? I'm asking because taking control of one specific installer logic might be possible. But taking control of different installers will be too difficult, if you ask me.

You should check whether the installers have an option for quiet installation. E.g. I think the Microsoft patch installers have.
stOrM!
Posts: 51
Joined: Thu Jul 15, 2004 7:38 pm

re

Post by stOrM! »

You got 1000.0000 point :-p :crazy:
Seriously you got it really those installers are all microsoft update.exe files in one word hotfixes installer files...

any idea?
best regards and thanx for your patience
s!
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

One of my collegues wrote a script recently to install those patches. I'll ask him how it worked next week when I see him again.

Have you tried starting the patch with "/?"? Or have you searched on google already? I think the information about how to automate patch installation is "out there" somewhere.
stOrM!
Posts: 51
Joined: Thu Jul 15, 2004 7:38 pm

re

Post by stOrM! »

Madshi the problem isn't how to build an automatic installation while using parameters on the installation files like -z -m I'm searching for a way to capture the progressbar position while installing a file from M$ and update my own progressbar for each installation file in my own Application to show the installation process (maybe overall process or for each installation file)... So thats while I asked maybe its possible to hook the progressbar position for each m$ hotfix file while starting it?

Maybe if I could write in german I could be more specific but I hope you get what I mean? Please let me know!

best regards
s!

BTW. Someone in another Forum gave me his sceleton of a hook because he had the same Problem like me and also wasn't able to finish it please see below:

Code: Select all

LIBRARY HookIt; 

USES 
  Windows, 
  CommCtrl, 
  Messages, 

Dialogs;   //(*)Nur fürs ShowMessage 

VAR 
  HookHandle : Cardinal = 0; 
  pBarHandle : Cardinal = 0; 


//Hook Procedure 
FUNCTION HookProc(nCode : Integer; wParam : WPARAM; lParam : LPARAM) : LResult; STDCALL; 
BEGIN 
  IF (nCode >= 0) THEN 
  BEGIN 
    //lParam zeigt auf ein Message Record 
    IF (PCWPSTRUCT(lParam)^.Message = PBM_STEPIT) THEN 
    BEGIN 
      // (*)Weiterleiten an die eigene Progressbar, hab ich noch nciht hinbekommen, 
      // (*)SendMessage(pBarHandle, PBM_STEPIT, wparam, lparam); 
      // (*)deshalb: 
      ShowMessage('STEP!'); 
    END; 
    //evtl. auch noch auf PBM_DELTAPOS und PBM_SETPOS prüfen 

  END; 

  //Hier geben wir den hook weiter an moegliche andere Anwendungen die was gehooked haben 
  Result := CallNextHookEx(HookHandle,nCode,wParam,lParam); 
END; 



FUNCTION InstallHook(h : HWND) : Boolean; STDCALL; 
BEGIN 
  Result := False; 

  IF (HookHandle = 0) THEN 
  BEGIN 
    //Erstmal Hook installieren 
    //First install the hook 
    HookHandle := SetWindowsHookEx(WH_CALLWNDPROC, @HookProc, HInstance, 0); 

    //Uebergebenes Fensterhandle sichern 
    //Save the given window handle 
    pBarHandle := h; 

    Result := True; 
  END; 
END; 


FUNCTION UninstallHook : Boolean; STDCALL; 
BEGIN 
//Hook aus der Hookchain entfernen 
//Uninstall hook from hook chain 
  Result := UnhookWindowsHookEx(HookHandle); 
  HookHandle := 0; 
END; 


EXPORTS 
//Installations- und Deinstallationsroutine exportieren 
//Export the installation and deinstallation routine 
  InstallHook, 
  UninstallHook; 
END.
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Well, I don't know how it works. I guess there is a way to get the progress somehow, I mean Windows Update shows a progress bar for all batch installations, too, doesn't it? But I simply don't know how it works, sorry.
stOrM!
Posts: 51
Joined: Thu Jul 15, 2004 7:38 pm

re

Post by stOrM! »

Yes all of the Update.exe Files have a GUI with a Progressbar and a Label or two that depends...

What really? Now I'm more then surprised, if the "Master" don't know how to capture a Progressbar from another Application then I'm lost I know!

So I better should give it up, unless you have another Idea when not hooking will work of how this can be realized...? :confused:

best regards and thanx a lot for time and patience!
s!
fsurfer
Posts: 23
Joined: Thu Jul 08, 2004 9:53 am

Tracking events or interfaces ?

Post by fsurfer »

madshi wrote:Well, I don't know how it works. I guess there is a way to get the progress somehow, I mean Windows Update shows a progress bar for all batch installations, too, doesn't it? But I simply don't know how it works, sorry.
Microsoft must use any interface or event handler to manage that ?
the idea would be to trap alle the messages associated with a process, or the interfaces ?

hard work though...

Guillaume
stOrM!
Posts: 51
Joined: Thu Jul 15, 2004 7:38 pm

re

Post by stOrM! »

Make sense to me but wouldnt it just be enough to capture the progressbar steps?

best regards
s!
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: re

Post by madshi »

stOrM! wrote:What really? Now I'm more then surprised, if the "Master" don't know how to capture a Progressbar from another Application then I'm lost I know!
I haven't googled for this problem and I also haven't tried to solve it myself. Maybe the solution can be found by googling. Or maybe I would be able to solve it myself. But I simply don't have time for either...
stOrM!
Posts: 51
Joined: Thu Jul 15, 2004 7:38 pm

re

Post by stOrM! »

Maybe Madshi whenever you got some time would be nice if you can inform me if you found a solution for it... Maybe I do more searches if I found something I'll be back and post it here if you like?

best regards
s!
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Sorry, but I won't have time for this in the next months. I've more stuff to do than I can fit into my time table... :cry:
c78
Posts: 14
Joined: Mon Nov 22, 2004 4:44 pm

Post by c78 »

You won't need madcollection for this. The example code you pasted early is what you need. What that example illustrates is taking the window handle of the progress bar inside the setup program and hooking it's message queue. You intercept its message signal STEPIT, pass it on to the real setup program, after notifying your own application. But to do this you have to calculate the value of STEPIT so you can match your app's progress bar accordingly.

Here's what I would do:

Instead of intercepting the progress bar object's messages, I'd hook the label objects instead. Intercepting the WM_SETTEXT message. This will include the progress bar's "percentage complete" string (ie, "57%"). Use that string to update your own program's progress indicators.
c78
Posts: 14
Joined: Mon Nov 22, 2004 4:44 pm

Post by c78 »

Also I should add, that in order to find the window handle of the label objects, first find it's parent handle using FindWindow, or from the return value of CreateProcess (u used this to execute the setup program). After finding the main window's handle, use EnumChildWindows API to find your percentage label handle.
Post Reply