Calling Windows APIs
The simplest example came to my mind is calling the MessageBoxA function. If we take a look at the MSDN of MessageBoxA function, we’ll find at very beginning the function description and its arguments and returns. At the Requirements section, we’ll find the required DLL to call MessageBoxA function which is User32.dll library.
Let’s do it,
That’s was really easy! but, is going to be deprecated or it’s already deprecated at the moment you read this part. Ruby have moved all dealing with C, dll functions to Fiddle
class which is a wrapper of C library which provides a portable interface to allow languages to call code from another language.
If we build our MessageBoxA script again using Fiddle
it will be like
At that point, I was wondering if I can write something like an old frind application call arwin which finds a Function location in a Windows library. With the help of MSDN and GetProcAddress documentations let’s do it.
arwin.rb
Results