Personal tools
From wiki.swiftlytilting.com
Jump to: navigation, search

WinBinder Manual/wb get function address

Contents

Syntax

int wb_get_function_address (string fname [, int idlib])
  • fname is the function name and idlib identifies a library already loaded.
  • The idlib identifier must have been obtained with a call to wb_load_library(). If idlib is not set or is set to NULL, the last library sent to the function will be used.

Returns

Returns the address of a library function.

The function prepends and appends some special characters to the function name until it finds the function name, then it returns the function address or NULL if the function was not found. These special characters are the most common ones encountered in various types of libraries. For example, if fname is set to "MyFunction", wb_get_function_address() looks for the following function names, in order:

  1. MyFunction
  2. MyFunctionA
  3. MyFunctionW
  4. _MyFunction
  5. _MyFunctionA
  6. _MyFunctionW
  7. MyFunction@0, MyFunction@4, MyFunction@8... until MyFunction@80
  8. _MyFunction@0, _MyFunction@4, _MyFunction@8... until MyFunction@80

The last two expansion options include a '@' character followed by the number of parameters times 4, which is a standard way to store function names inside DLLs. The loop starts from zero ("@0") and ends when it reaches 20 parameters ("@80").

NOTE: Function names, including the expansion characters, are limited to 255 characters.

Examples

The mini-program below shows how to call a Windows function in a single PHP line.

<?
// Shows the current ANSI code-page identifier for the operating system.

include "../include/winbinder.php";

wb_message_box(0, "ANSI code-page identifier: " . wb_call_function(wb_get_function_address("GetACP", wb_load_library("KERNEL"))));

?>

The function get_ticks() returns the number of seconds elapsed since the computer started.

function get_ticks()
{
    static $KERNEL = null;
    static $GetTickCount = null;
 
    if($KERNEL === null)
        $KERNEL = wb_load_library("KERNEL");
    if($GetTickCount === null)
        $GetTickCount = wb_get_function_address("GetTickCount", $KERNEL);
    return (int)(wb_call_function($GetTickCount) / 1000);
}

See also

Winbinder Projects