# Win32api hook

**URL:** <https://www.ruby-forum.com/t/win32api-hook/175384>\
**Category:** Ruby\
**Created:** [September 12, 2009, 11:55am UTC](https://www.ruby-forum.com/t/win32api-hook/175384 "2009-09-12T11:55:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![romte09](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e79b87/32.png) [@romte09](https://www.ruby-forum.com/u/romte09)\
**Post date:** [September 12, 2009, 11:55am UTC](https://www.ruby-forum.com/t/win32api-hook/175384/1 "2009-09-12T11:55:31Z")

</div>

So i just got into win32api stuff and i would like to make a (c++)dll to  
join in a process. I got some code here but i dont know much about  
win32api & params

* * *

require ‘win32api’

hook = Win32API.new(‘user32’,‘SetWindowsHookEx’, [’’], ‘’)  
library = Win32API.new(‘kernel32’,‘LoadLibrary’, [’’], ‘’)  
procadr = Win32API.new(‘kernel32’,‘GetProcAddress’, [’’], ‘’)

lcall = library.call(‘mylibrary.dll’)  
pcall = procadr.call(lcall, ‘funcname’)

## hook.call(‘WH\_MSGFILTER’,pcall,lcall,0)

Any help?

---

<div class="post-metadata">

**Author:** ![romte09](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e79b87/32.png) [@romte09](https://www.ruby-forum.com/u/romte09)\
**Post date:** [September 12, 2009, 12:40pm UTC](https://www.ruby-forum.com/t/win32api-hook/175384/2 "2009-09-12T12:40:40Z")

</div>

Hi,

2009/9/12 Roomu T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> procadr = Win32API.new(‘kernel32’,‘GetProcAddress’, [‘’], ‘’)
> 
> lcall = library.call(‘mylibrary.dll’)  
> pcall = procadr.call(lcall, ‘funcname’)
> 
> ## hook.call(‘WH\_MSGFILTER’,pcall,lcall,0)
> 
> Any help?  
> Here is a modified code:

* * *

require ‘Win32API’

WH\_MSGFILTER = -1  
hook = Win32API.new(‘user32’,‘SetWindowsHookEx’, ‘ILLL’, ‘L’)  
library = Win32API.new(‘kernel32’,‘LoadLibrary’, ‘P’, ‘L’)  
procadr = Win32API.new(‘kernel32’,‘GetProcAddress’, ‘LP’, ‘L’)

lcall = library.call(‘mylibrary.dll’)  
pcall = procadr.call(lcall, ‘funcname’)

## hook.call(WH\_MSGFILTER,pcall,lcall,0)

Regards,

Park H.

---

<div class="post-metadata">

**Author:** ![romte09](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e79b87/32.png) [@romte09](https://www.ruby-forum.com/u/romte09)\
**Post date:** [September 12, 2009, 1:19pm UTC](https://www.ruby-forum.com/t/win32api-hook/175384/3 "2009-09-12T13:19:49Z")

</div>

Thanks!
