wb_poke

Special warning about wb_poke()

This function provides access to the Windows API and should be used with great care. This function can easily generate a runtime exception or freeze the PHP application. Worse, if you are using Windows 98 or Me, it is not unlikely to crash the whole system when calling this function. For this reason Windows 98 or Windows Me are not recommended for developing WinBinder applications. Always be careful and double-check your source code before running it when using this function.

bool wb_poke (int address, string contents, [, int length])

Sets the contents of a memory area pointed by address. Possible situations are:

contents

length

Action

An empty string

Any

Does nothing

A PHP string

Empty or zero

Affects strlen(contents) bytes

A PHP string shorter than length

Greater than zero

Affects strlen(contents) bytes

A PHP string equal or larger than length

Greater than zero

Affects length bytes

Example

// Change characters in a string

$str = "Test string";
$addr = wb_get_address($str);
echo wb_peek($addr) . "\n";
wb_poke($addr, "Roo");
echo wb_peek($addr) . "\n";
echo "$str\n\n";

// Change the value of an integer

$num = 1234;
$addr = wb_get_address($num);
$array = (unpack("Vnum", wb_peek($addr, 4)));
echo "{$array['num']}\n";
wb_poke($addr, pack("V", 800), 4);
$array = (unpack("Vnum", wb_peek($addr, 4)));
echo "{$array['num']}\n";
echo "$num\n\n";

See also

wb_peek
Low-level functions