Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Run Hooking


Basically, I'm creating a new 'Run' dialog and have got to the stage where I need to find a way to actually replace the old one. I've got an idea, but I'm not sure if it's the best way to do it:
Setup a system wide CBT hook to detect activated windows with the class '#32770 (Dialog)' and caption 'Run', then destroy it and show my own Run dialog.

If anyone can think of any other method, please, let me know.

Thanks in advance,
Ed




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Hooking Into Another App
i am a hobby vb'er, but love experimenting with it. i have written some useful stuff to no one but me and a few select co-workers.

problem:i want to hook into an app, not written by me, and make menu, toolbar, and context menu items that will launch or switch to my app, allow manipulation of data (flexgrid text cells), and pass it back to the other app as if the user had typed the data. i want to add some functionality to the other app as an addon/addin. however, the other app is not like an ms office app with a template (normal.dot) that i can insert any vba code into. additionally, the other app is not probably written in vb.

i would really like to add a registry setting that would load my hook anytime the other app is loaded and add my buttons/menus to it on its initialization. anything that will adversely affect the other app is unacceptable. zero fault tolerance.

so from reading numerous vb forums and surfing knowledge bases, i haven't found something that just stands out as the answer.

i understand the terms and purposes of subclassing, hooks, callbacks, and API, but being a hobbiest, have usually found a way around using such things or just do without that functionality. therefore, my knowledge of these issues is nill for all intents and purposes.

but i fear there is no other way. i am using vb6 enterprise, and don't see getting into vb.net anytime soon.

fixing this problem has some real-world functionality, if for no other purpose that to present an idea to the devlopers of the app i am hooking into.

any help and direction is appreciated.

Hooking
Hi there every1...
i wanna make a program that has a main form with buttons, which have code to start a program such as msn messenger, solitaire, internet explorer etc.(basically anything installed on the computer.)
can ne1 help me on this pls i have no clue on how to start but i know it needs API and registry of sum kind in the code... im just not sure wat goes where...

API Hooking
Hi there!
I've a question, please, can you help me?
Question: How can i 'hook' an API??
I'll try to clarify a little. You know that API, GetAsyncKeyState. Would i like to monitor that API in real time. Print on my screen what program is using that API, Process name, path, blablabla... But the main question, HOW to monitor the API? Anybody have a clue, or, did something like it?
Thanks!!

MSN (hooking?)
Hello,

I'm trying to develop a program which has the following purpose:
- Alter data sent and received from the MSN program;
- Block data sent and received from the MSN program;
- Create (fake) data sent and received by the MSN program.
With this, I can create a plugin which makes advanced messaging possible, such as sending nudges and things as often as you wish, generating custom automessages, advanced logging, etcetera.

I've thought of a few ways to do this:
- create a proxy app, through wich I tunnel all the data of MSN;
- create a proxy-like app, through which all the data of MSN is tunneled when I route the DNS to localhost
- create a socket/MSN hook, to intercept dll-calls

The first two ways weren't as successful as I hoped (for an unknown reason it did work for my browser, but msn screwed up when routing it's traffic through my home-made program), so I read something about hooking up programs. After googling for a while, it seemed to be the way to help me out. I've been trying to find some visual-basic source for this, but that's really hard to find.. I did find some source for hooking-up keystrokes, but I'm too unfamiliar with this hooking thing to alter this for my purpose.

Does anyone have some experience with hooking, and knows how to hook up MSN or it's socket? Please help, because I don't know where to start.

API Hooking
Is there a way to hook an API function using VB?

If so, how?

any examples?

API Hooking
I have a source code in C++ that shows you how API Hooking is done but I don't have C++. So I was wondering if it can be generated into VB somehow ?

The source code is attached.

Hooking?
Ok here is my question, I havent dabbled with it much and I havent seen any real documentation on it but does anyone know how to check to see if a program is hooking into another program (if that makes sense)
example:
program1.exe hooks into programb.exe to intercept data being sent to a dll then it takes that data sends it to the dll and gets the return, then it manipulates the return and sends it back to program1.exe

System Hooking In Vb
hi there,
I am new this forum.Hope to get some help.

Is there any way in vb ,that I can hook the printscreen for all activateed application.
That means as long as my application is is active the printscreen button should be disabled for all application.

Any kind of help is highly appriciated.

Thank you in advence

sandy

Hooking The Mouse
Here is an example I made of using hooking (similar to subclassing)
the mouse to get its messages. The program will detect mouse
clicks and movement from anywhere within the program's thread.
Don't stop the program with the stop button, use the 'X' or
the 'Done' button.

Enjoy! Report any bugs to me by way of Private Message.

Process Hooking
Hello!
Is it possible to "hook" a process in VB? I mean, is it possible to put a whole VB-program into another process(program) and execute it inside?
If this is possible, I'd really like to know how?

Q:Hooking, Please Give Me Some Help.
I am trying to create a hook for a game using vb. What I want to do is intercept it's messages and execute if "CTRL+R" is pressed, maybe even multiple hotkeys.What i need is how i would start and finish this. Please inform about anything regarding this. I already know the basics, i just need to know how to do the following.

"2. Hooking into another process is not so easy in VB - your hook function (KeyboardProc) must be in a DLL, the DLL needs to be loaded in your process, and the hInstance value you pass must be the module handle of the loaded DLL."

any idea on how to do that?

Subclassing, Hooking, Or Other?
What is the correct terminology when I do the following?


Code:
Private Sub Form_Load()

lpPrevWndProc = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf WindowProc)

End Sub

Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

' Do my stuff

WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)

End Function

Subclassing Or Hooking
ok i no its hardly posible to subclass in vb without a dll but i was woundering if there was a way ive got close but what happens msn menus dont work or nuffin

ummcan somone show me a tutorial for making a packet sniffer that works in xp and AND lower
:P
i have made 1 for msn messenger but it only works for xp and 20 users

no not www.rentacoder.com Unless ur gonna pay :P

Hooking And Subclassing
What is Hooking and Subclassing, i read alot about people using it on the forum, but i am not sure what it is.

Hooking Windows
My delima:

I'm writting a program that will copy and send RTTY over ham radio. There is an RTTY engine that I load via a module and send messages back and forth to it via window calls. I have this part work fine from one form but what I need to do is be able to load 2 copies of this engine and have the second copy hook to another form and send message back and forth to it.

I'm new to using windows messages and hookig windows so this is why I need the help
thanks
Rick

Hooking DragDrop
OK I posted this question before but never got exactly what I was looking for and settled for a work around which is a little cowboyish to say the least, I have a webbrowser and a DHTMLEdit control and I want to intercept drag drop events from the browser to the DHTMLEdit the problem being there is no events in either of these controls to tell you when this happens

I know the basics of subclassing but on all the sites I have searched have not found the Windows Message for dragdrops, if anybody can tell me this I would be very grateful

Hooking A Dll File
How do you hook a part of a dll file and how do you "read"the file?

VB Hooking Utopia
Hi there,

it is possible in Visual Basic to "hook" wich file or application an user decided to "doubleclick"?

I'll try to explain better, like in an antivrus app (for eg. Norton) i would "track" what application an user lunch or what file try to open, all in real time.

It is possible ?

Thanks

Problems With Hooking
Let me describe what I'm trying to do and then I'll post the code I'm working with.....

There is a RTTY engine called MMTTY that decodes RTTY signals via a radio. Inthe code that I will post this allworks fine with just one copy of MMTTY running. the program I am working on has a text box to take the text outputtted my MMTTY and places them on the screen. I want to have 2 windows for text and 2 copies of MMTTY.

here is an example of some of the code that is in a module. to start MMTTY the routine StartMMTTY is called.
Like i said if I have 1 window and 1 MMTTY engine everything works fine if I load the second window and call the StartMMTTY routine I get the message bx pop up that says window is already hooked. How do I go about this so I dont get the message and allow things to work correctly???? If I'm not explaing enough please let me know.....


Code:
Public Sub StartMMTTY(meHostForm As Form)
Set HostForm = meHostForm
InitMMTTY HostForm.hWnd
End Sub
Private Sub InitMMTTY(hWnd As Long)
'Procedure to Initialize MMTTY
Dim window As String
Dim x As Long
Dim MMTTYhWnd As Long
Dim HexHwnd As String
HookWindow hWnd
MMTTY_MSG = RegisterWindowMessage("MMTTY")
Shell (App.path & "mmtty.exe " + window + " -h" & HexHwnd)
MMTTYhWnd = FindWindow(vbNullString, SharedMemory.title)
MMTY_HWND = MMTTYhWnd
SetAlwaysOnTop MMTTYonTop, MMTY_HWND, val(mwx), val(mwy), val(mwcx), val(mwcy)
PostMessage MMTY_HWND, MMTTY_MSG, RXM_HANDLE, hWnd
End Sub
This sub is used to Hook..

Code:
Private Sub HookWindow(hWnd As Long)
If OldWndProc <> 0 And HookedhWnd <> hWnd Then
MsgBox ("Procedure allready hooked!")
Exit Sub
ElseIf OldWndProc <> 0 Then
SetWindowLong hWnd, GWL_WNDPROC, OldWndProc
End If
OldWndProc = GetWindowLong(hWnd, GWL_WNDPROC)
SetWindowLong hWnd, GWL_WNDPROC, AddressOf NewWndProc
HookedhWnd = hWnd
End Sub

This sub is called when the program ends..

Code:
Private Sub UnHookWindow(hWnd As Long)
If HookedhWnd <> hWnd Then
MsgBox ("Window Not Hooked!")
Else
SetWindowLong hWnd, GWL_WNDPROC, OldWndProc
End If
HookedhWnd = 0
OldWndProc = 0
End Sub

Thanks.......

Edit: "Indents" weren't showing up b/c you didn't use the [vb][/vb] tags.

Hooking Vs SubClassing
What is the difference between Hooking and SubClassing?

Subclassing/hooking Help??
im tryin to find a solution to a post in the general discussion area about being able to navigate through items on a popup menu thats shown from the system tray. i impliment subclassing to tell me when the popup is showing or not, no errors.

I create a hook to "try" to capture keyboard events while the menu is visible. the hook gets set when the menu is showing, and I remove the hook when its not showing, I have made sure that the hooks/subclassing is working the way it should be, but i can never get input in my message filter for the hook.

Will someone please take a look at this and see if they provide some insight as to how I can make this work? im aware that my hooking method might not be the implimented in the best way but it doesnt error at all, so im happy for the moment, jyst nothing fires in it.

if not its still a kool little example on the subject(s)

Hooking A Window
What mean Hook Window, I think that is something like catch the window messages and I must do the operation that the message indicates ! Is this hook a window ??

SubClassing Or Hooking
Well i got this problem...
I want my window to intercept messages, WM_KEYDOWN for example. If there is no control on the form that has got focus, subclassing is working fine. But when a control got focus my program does no longer intercept WM_KEYDOWN message cause they are send to the control.
Now is there another way to do it with subclassing or do i need to hook my window.....

code sofar...

Code:
Public Function SubClass(lHwnd As Long) As Boolean
lpPrevWndProc = SetWindowLong(lHwnd, GWL_WNDPROC, AddressOf WndProc)
End Function

Public Function WndProc(ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Select Case msg

Case WM_DESTROY
Call UnClass(hwnd)

Case WM_KEYDOWN
MsgBox "WM_KEYDOWN: wParam = " & wParam & " & lParam=" & lParam

Case WM_KEYUP
MsgBox "WM_KEYUP: wParam = " & wParam & " & lParam=" & lParam

Case WM_CHAR
MsgBox "WM_CHAR: wParam = " & wParam & " & lParam=" & lParam

Case Else
WndProc = CallWindowProc(lpPrevWndProc, hwnd, msg, wParam, lParam)

End Select

End Function

Public Function UnClass(lHwnd As Long)
SetWindowLong lHwnd, GWL_WNDPROC, lpPrevWndProc
End Function

Hooking Other Programs
This is like "injecting" your app into other app's isn't it? Can someone direct me on where to go to get started with this?

Problem With Hooking!
VB Code:
I have a problem when attempting to hook something.Here's my code: Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPublic Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPublic Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPublic DiabloWindow As LongPublic DiabloHook As LongPublic Const GWL_WNDPROC As Long = (-4) Public Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long    WindowProc = CallWindowProc(DiabloHook, hw, uMsg, wParam, lParam)    Select Case uMsg        Case WM_SIZE            Debug.Print lParam & " " & wParam    End SelectEnd Function Public Sub FindDiablo()    If DiabloWindow = 0 Then        DiabloWindow = FindWindowEx(0&, 0&, "Diablo II", vbNullString)        Debug.Print "WINDOW VALUE " & DiabloWindow    End If    If DiabloHook = 0 And Not DiabloWindow = 0 Then        DiabloHook = SetWindowLong(DiabloWindow, GWL_WNDPROC, AddressOf WindowProc)        Debug.Print "HOOKED VALUE " & DiabloHook    End IfEnd Sub


Now, the problem resides in function FindDiablo. It says the correct handle, but it says "HOOKED VALUE 0" in the debug, always!

I tried replacing "DiabloWindow" with Form1.hWnd, and it worked just fine. Is Diablo II somehow blocking incomming messages?

Hooking Menu
Hi experts!

I did this:
http://www.vbforums.com/showpost.php...39&postcount=1
Everything worked fine.
Except for 1 thing. When I add a submenu in a program(in this case Swift 3D)
the submenu is disabled
When I do it with notepad, everything works fine!

thanx

Hooking VB6 To SQL Server2000
I am considering migrating my VB Code from MS Access DB to MS SQL Server DB ,What should be done to get it going??

Hooking HTML Help To VB 6
Hi all,

Can anyone give the code for hooking a chm (compiled HTML help) file to my VB project?

The chm file is in the same directory as the project, I want the help contents to show up everytime Help >> Contents (mnuHelpContents) is clicked in the main menu.

I have associated F1 keypress with mnuHelpContents through menu editor.

Thanks in advance.

Yet Another Hooking Question
dear all,

i've searched these forums and around the net for this, i hope there's a way to do it (i've seen programs do it, i just need to create my own).

i'd like to get and modify existing captions and text boxes of an external program.

for instance, let's say a simple program has caption1 with 'wildcat' in it and a text1 box with 'my text here'.

i need a program able to read 'wildcat' from caption1 (almost done on this one), but especially i need to modify 'my text here' from my program.

does someone know where to start this?...

thanks,

wc.

Key Board Hooking In VB 6.0
Dears,

Hariom..(A Word to wish)

How to use the Keyboard Hooking API?

Maitrey Ji

DirectX Hooking
How to hook direct x graphics from a game. Im basically trying to develope a window mode for a game.( Make it in my window)

Hooking Using WH_GetMessage
Hi,

I am trying to hook MSN Messenger and wait for the WM_Close message in order to execute some code. The problem is, I have little experience with Hooks. I tried a couple of times and ended up crashing my PC, LOL. Can someone point me in the right direction on how to create a WH_GetMessage hook and wait for the WM_Close message from the MSN Messenger window?

Thank you for your time,
VIP3R

Hooking Other Windows ?
It is possible to hook or subclass another window? For example, when another window is clicked, my program carries out an action. Is this possible ?

Thanks....

Hooking Question
on my html page, i have a print button, when it is pressed i want to open page setup dialog box, set values in paper size listbox and margins text box and close the dialog. It may be done either in JavaScript or ActiveX Control.

Thanks in advance

Subclassing Or Hooking (again)
For the 1000th, subclassing or hooking. I've been looking here and there for over an hour trying to find out a way to handle messages sent to a particular running application (or window). For simplicity, assume I want to receive all messages sent to Notepad (sort of like tracking what's happening to it).


First, subclassing. This is a bolded line taken from the MSDN article Safe Subclassing in Win32

Quote:





Subclassing is allowed only within a process. An application cannot subclass a window or class that belongs to another process.






How do people go around this rule and use subclassing globally with other windows?
Unless I want to do "superclassing", which I think is not what I need.
(a questoin on the side, I use SetWindowLong(), right?)

Now, hooking. Also discussed in About Hooks . I tried it, it works fine, but I need the "application handle" (rather than the "window handle") which I can't get a hold of given a window handle. I can get the app handle of MY application, but that's not what I need.
Also, hooking is kind of limited. It limits you to these "callback procedures" (rather than all WM messages):


Quote:





WH_CALLWNDPROC
WH_CALLWNDPROCRET
WH_CBT
WH_FOREGROUNDIDLE
WH_GETMESSAGE
WH_JOURNALPLAYBACK
WH_JOURNALRECORD
WH_KEYBOARD
WH_MOUSE
WH_MSGFILTER
WH_SHELL
WH_SYSMSGFILTER






(of course these are used with SetWindowsHookEx())

Come to think of it again, WH_CALLWNDPROC, WH_CALLWNDPROCRET, and WH_GETMESSAGE sound very very useful (at least for my "Notepad" example), but how can I get an app handle?


For my case, which was similar to some, some people prefer subclassing, and some prefer hooking. I want to know the ups and downs for both. Much appreciated. Much much appreciated!

Hooking Controls?
hey all

anyone got any idea how to hook a control in vb6 so i can capture its events?

what i want to do is monitor a control in another program (also written in vb oddly enough), to see when the user presses enter, and before it sends i want to capture the text entered.

any ideas?

thanks in anticipation

Hooking A Window???
How can I hook a window to intercept all messages sent to it, and is there a way to blobk certian messages from getting through???

Any help greatly appreciated

Hooking Listview
Greetings and Salutations!

I am looking for a way to tap in to a listview control and known when the first item has entered or when the last item has been removed.

The adding and removing will be done from several areas so I was hoping for one location that can take action when the list count has been changed.

Looking for a was other then calling a sub to do the checking. Is there a way to Hook it?

Thanks!!

Question About Hooking....
Can someone provide me with some insight or code that will explain to me a little more about hooking a window?

basically this is my goal.. i want to hook a window to a program that is not one of my applications and view all the windows messages that are sent to it... i would have the class name or window handle of the target window... how could this be accomplished?

Hooking Up My FlexGrid
I'm trying to populate an MSFlexGrid with data from a database.

Ideally I would like to do this in the click event to a command button - ie once I press ok, the grid is populated.

Could anyone help me with the code for moving my query/recordset into the grid?


Thanks, in advance for your help

Sam

Hooking IDE TreeView
I'm trying to hook the VB6 IDE project treeview. I can get it working with a WH_CALLWNDPROC SetWindowsHookEx call, but only in'debug' i.e. I haven't made a C dll for it.

So, I was trying to use the WH_JOURNALRECORD hook, as per other threads in these forums, to avoid the C dll, but I can't make it work (I don't get a hook!).

Can some one in the know look at my code and tell me what's up with it?

Cheers

Hooking The Keyboard
Hey,

Can someone please tell me how to disable the Microsoft Keys on the new keyboards. I wrote a program that can only be exited by the admins (password), but it is useless if I cannot disable those keys.

It's kind of urgent

Hooking Up To Word
Does ANybody have a copy of some code I can use to hook to my app to a Document in Word??? So to open Word from VB. I also want to paste some fields from a DB into the Word document so any samples to look at of that would be excellant to! Thanks.

Hooking Files
I did a few searches but didn't find anything relating to this.

I was just wondering if it was possbile to use VB to hook files. Basically, I need to run a VB app in the background that knows when files, such as documents, have been created/modified.

Any suggestions?

Trouble Un-hooking
Hello all, hope you can clear this puzzle for me.
On the main form in load event I have
CODE    Dim Lng_Menu&
    Lng_Menu = GetSystemMenu(hwnd, False)
    AppendMenuA Lng_Menu, MF_SEPARATOR, 0, vbNullString
    AppendMenuA Lng_Menu, MF_CALLBACKS, &HF, "About"
    If Not Hooked Then
        lpOldProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf Handler)
        Hooked = True
    End If

Little Hooking Problem (VB)
I'm using this code to try to hook to winamp so I can catch some messages but it doesn't seem to work (hHook is always equal to 0).  I know that both my hWinamp and winampProcess are OK since I compared to the Spy++ and the Task Manager PID. What's wrong in it??

    hWinamp = FindWindow("Winamp v1.x", vbNullString)
    Me.Text3.Text = GetWindowThreadProcessId(hWinamp, winampProcess)
    Me.Text1.Text = winampProcess
    hHook = SetWindowsHookEx(WH_CALLWNDPROC, AddressOf wndProc, App.hInstance, winampProcess)
    Me.Text1.Text = Me.Text1.Text & vbCrLf & hHook


Thank you!

Hooking Functions?
Hi,

I was wondering if it's possible to make some sort of hook, like you can hook on the message queue, but now on a dll. I want to get notified in case the BitBlt function is called. Is there any way I can do this by hooking into the dll or another way perhaps (maybe even a message?).

Thanks in advance,

LuCkY

Hooking Troubles
I am using a JournalRecord hook to monitor the keyboard and mouse, and a GetMessage hook to monitor if that hook gets removed with ctrl-esc or ctrl-alt-del so I can reinstall it.  Everything works great except:

Small problem: hit the volume key on the keyboard and the entire system freezes, and you have to use some clever ctrl-alt-deleting to close the program.  The mouse and keyboard are unresponsive until you "refresh" with a ctrl-alt-del or ctrl-esc.

Any ideas as to what might cause this or how I can prevent this from happening? ____________________________________________________________________________
There are only 10 types of people in the world.  Those that know binary and those that don't

Brent

Hooking A Menu
Hello folks!  I'm working on a front-end for Microsoft Internet Explorer which incorporates tabbed browsing and Direct Document Object Model Editing.  Anyway, I've run into a strange problem with the code I'm using to hook the Favorites menu.  The Favorites menu works flawlessly, but when I click the ComboBox I'm using as an address bar, the application crashes immediately.  This happens in debug mode and as a stand-alone EXE.  When I comment out the code to hook the menu, everything works fine, except I cannot open my Favorites.  Here's the code I am using to hook my Favorites menu:
CODE    ProcRet& = GetWindowLong(Main.HwND, GWL_WNDPROC)
    Call SetWindowLong(Main.HwND, GWL_WNDPROC, AddressOf MenuProc)

Copyright © 2005-08 www.BigResource.com, All rights reserved