Results 1 to 3 of 3

Thread: Subclassing window in other process (winXP)

  1. #1

    Thread Starter
    Hyperactive Member WP's Avatar
    Join Date
    Aug 2000
    Location
    Belgium
    Posts
    278

    Exclamation Subclassing window in other process (winXP)

    Ya guys,
    i used an old VB6 algorithm to subclass a window and made a few changes at the 'hook method' to make it work in .NET.

    Code:
    Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hWnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As delWindowProc) As Integer
    Private Delegate Function delWindowProc(ByVal hwnd As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    Private lpPrevWndProc As Integer
    Public Sub New()
       Dim procAddress As delWindowProc = AddressOf WindowProc
       lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, procAddress)
    End Sub
    Public Function WindowProc(ByVal hwnd As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
       If uMsg = ..... Then
          Return CallWindowProc(lpPrevWndProc, hwnd, WM_CANCELMODE, wParam, lParam)
       Else
          Return CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
       End If
    End Function
    everything is working now, but only at certain windows. i can only subclass windows from the process where my program is located. this is what i conclude from the following helpmessage:

    SetWindowLong:
    GWL_WNDPROC: Sets a new address for the window procedure.
    Windows NT/2000/XP: You cannot change this attribute if the window does not belong to the same process as the calling thread.

    now all the fun of subclassing is gone. how can I make it work on other windows?

    Thanks,

    Visual Basic 6.0 EE SP5 / .Net
    Windows XP

  2. #2
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    It's quite complicated to do what you want in c++, in VB.NET it's even worse

    Search about Dll Injection
    \m/\m/

  3. #3
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Subclassing window in other process (winXP)

    Here is a method of "subclassing" external process windows. It was written for VB6, and then converted to VB.NET. It relies on a dll written in C++ that is supplied in both source code and compiled.

    http://www.vbforums.com/showthread.p...51#post2383351

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width