Windows Hooking

Discussion in 'Perl Misc' started by kann181@rediffmail.com, Mar 30, 2006.

  1. Guest

    I would like to know how to use SetWindowsHookEx in perl for
    WH_JOURNALRECORD & WH_JOURNALPLAYBACK..
    i tried the following but didn't work
    1. Win32::API->Import("User32", "HHOOK SetWindowsHookEx(int idHook,
    HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId)");

    This says that HOOKPROC is Unknown Parameter type.

    2. my $setWindowsHookEx = new Win32::API('User32',
    'SetWindowsHookEx','IKPL', 'P');
    my $callback = Win32::API::Callback->new(
    sub
    {
    my($Code, $wParam, $lParam)
    = @_;
    if($Code eq "0")
    {
    print "Welcome to
    Hooking";
    }
    else
    {
    return
    CallNextHookEx($hook_handle, $code,$wParam, $lparam);
    }
    return 0;
    },"DD", "P",
    );
    my $hook_handle = $setWindowsHookEx->Call(13, $callback, NULL, 0);

    This also didn't work.

    Please if any could rectify my mistakes.....
    , Mar 30, 2006
    #1
    1. Advertising

  2. Dave Guest

    <> wrote in message
    news:...
    >I would like to know how to use SetWindowsHookEx in perl for
    > WH_JOURNALRECORD & WH_JOURNALPLAYBACK..
    > i tried the following but didn't work
    > 1. Win32::API->Import("User32", "HHOOK SetWindowsHookEx(int idHook,
    > HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId)");
    >
    > This says that HOOKPROC is Unknown Parameter type.
    >
    > 2. my $setWindowsHookEx = new Win32::API('User32',
    > 'SetWindowsHookEx','IKPL', 'P');
    > my $callback = Win32::API::Callback->new(
    > sub
    > {
    > my($Code, $wParam, $lParam)
    > = @_;
    > if($Code eq "0")
    > {
    > print "Welcome to
    > Hooking";
    > }
    > else
    > {
    > return
    > CallNextHookEx($hook_handle, $code,$wParam, $lparam);
    > }
    > return 0;
    > },"DD", "P",
    > );
    > my $hook_handle = $setWindowsHookEx->Call(13, $callback, NULL, 0);
    >
    > This also didn't work.
    >
    > Please if any could rectify my mistakes.....
    >


    I can tell you that at HOOKPROC what is expected is the address of the
    callback function (as a long integer pointer). I cannot tell you how or if
    you can do this from perl although I expect the various docs online about
    how to do this from VB should give some pointers (no pun intended).
    Dave, Apr 3, 2006
    #2
    1. Advertising

  3. robic0 Guest

    On 30 Mar 2006 09:58:19 -0800, wrote:

    >I would like to know how to use SetWindowsHookEx in perl for
    >WH_JOURNALRECORD & WH_JOURNALPLAYBACK..
    >i tried the following but didn't work
    >1. Win32::API->Import("User32", "HHOOK SetWindowsHookEx(int idHook,
    >HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId)");
    >
    >This says that HOOKPROC is Unknown Parameter type.
    >
    >2. my $setWindowsHookEx = new Win32::API('User32',
    >'SetWindowsHookEx','IKPL', 'P');
    >my $callback = Win32::API::Callback->new(
    > sub
    > {
    > my($Code, $wParam, $lParam)
    >= @_;
    > if($Code eq "0")
    > {
    > print "Welcome to
    >Hooking";
    > }
    > else
    > {
    > return
    >CallNextHookEx($hook_handle, $code,$wParam, $lparam);
    > }
    > return 0;
    > },"DD", "P",
    > );
    >my $hook_handle = $setWindowsHookEx->Call(13, $callback, NULL, 0);
    >
    >This also didn't work.
    >
    >Please if any could rectify my mistakes.....


    Hahahaaaaaaaaaaaaaaaaaa!!!!!
    Now theres a new one, hooking the api with Perl.
    Don't stop there, go straight to Perl::Rootkit!!
    robic0, Apr 3, 2006
    #3
  4. robic0 Guest

    On Mon, 03 Apr 2006 15:15:30 -0700, robic0 wrote:

    >On 30 Mar 2006 09:58:19 -0800, wrote:
    >
    >>I would like to know how to use SetWindowsHookEx in perl for
    >>WH_JOURNALRECORD & WH_JOURNALPLAYBACK..
    >>i tried the following but didn't work
    >>1. Win32::API->Import("User32", "HHOOK SetWindowsHookEx(int idHook,
    >>HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId)");
    >>
    >>This says that HOOKPROC is Unknown Parameter type.
    >>
    >>2. my $setWindowsHookEx = new Win32::API('User32',
    >>'SetWindowsHookEx','IKPL', 'P');
    >>my $callback = Win32::API::Callback->new(
    >> sub
    >> {
    >> my($Code, $wParam, $lParam)
    >>= @_;
    >> if($Code eq "0")
    >> {
    >> print "Welcome to
    >>Hooking";
    >> }
    >> else
    >> {
    >> return
    >>CallNextHookEx($hook_handle, $code,$wParam, $lparam);
    >> }
    >> return 0;
    >> },"DD", "P",
    >> );
    >>my $hook_handle = $setWindowsHookEx->Call(13, $callback, NULL, 0);
    >>
    >>This also didn't work.
    >>
    >>Please if any could rectify my mistakes.....

    >
    >Hahahaaaaaaaaaaaaaaaaaa!!!!!
    >Now theres a new one, hooking the api with Perl.
    >Don't stop there, go straight to Perl::Rootkit!!


    BTW, there's no doubt that a user mode dll with a
    Perl interface cannot be used to control '.sys' drivers.
    Now all you have to do is get somebody to do the driver
    as well. Hint: I won't do it for free...
    robic0, Apr 3, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raja
    Replies:
    1
    Views:
    386
    Gabriele G. Ponti
    Jan 21, 2004
  2. Yovi Oktofianus

    Hooking Post Back Event

    Yovi Oktofianus, Oct 17, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    576
    Jalil Vaidya
    Oct 18, 2003
  3. Dave A
    Replies:
    2
    Views:
    6,813
    Dave A
    Nov 29, 2005
  4. Al

    system wide hooking

    Al, May 1, 2006, in forum: Java
    Replies:
    4
    Views:
    365
    Thomas Weidenfeller
    May 2, 2006
  5. Sean
    Replies:
    1
    Views:
    606
    Salt_Peter
    Dec 6, 2006
Loading...

Share This Page