function test_lowlevel($window) { global $maintab; $result = "TEST LOW-LEVEL FUNCTIONS\n\n"; $result .= "Peek/poke a string\n"; $str = "Test string."; $addr = wb_get_address($str); $result .= wb_peek($addr) . "\n"; wb_poke($addr, "Roo"); $result .= wb_peek($addr) . "\n"; $result .= "{$str}\n\n"; $result .= "Peek/poke a long integer\n\n"; $num = 1234; $array = unpack("Vnum", wb_peek(wb_get_address($num), 4)); $result .= "{$array['num']}\n"; wb_poke(wb_get_address($num), pack("V", 800), 4); $array = unpack("Vnum", wb_peek(wb_get_address($num), 4)); $result .= "{$array['num']}\n"; $result .= "{$num}\n\n"; $result .= "Peek/poke a double float\n\n"; $num = 100.01; $array = unpack("dnum", wb_peek(wb_get_address($num), 8)); $result .= "{$array['num']}\n"; wb_poke(wb_get_address($num), pack("d", 800.02), 8); $array = unpack("dnum", wb_peek(wb_get_address($num), 8)); $result .= "{$array['num']}\n"; $result .= "{$num}\n\n"; $result .= "Peek/poke control data\n\n"; $id = ID_RESETHANDLER; $result .= "Getting control handle...\n"; $ctrl = wb_get_control($window, $id); $wbobj = unpack(WBOBJ, wb_peek($ctrl, WBOBJ_SIZE)); $result .= sprintf("Original item # is %d\n", $wbobj["item"]); $result .= "Changing the value of member 'item'...\n"; // The offset of member 'item' in struct WBOBJ is 12 wb_poke($ctrl + 12, pack("V", 1200), 4); $wbobj = unpack(WBOBJ, wb_peek($ctrl, WBOBJ_SIZE)); $result .= sprintf("Current item # is now %d\n", $wbobj["item"] . "\n"); $result .= "Peek/poke window callback\n\n"; $result .= "Current window data:\n"; $wbobj = unpack(WBOBJ, wb_peek($window, WBOBJ_SIZE)); $result .= print_r($wbobj, true); $orig_address = wb_get_address($wbobj["handler"]); $orig_handler = wb_peek($wbobj["handler"]); $result .= "Name of original window handler: \"{$orig_handler}\"\n"; $result .= "Changing handler using wb_poke()...\n"; $newname = "dummy_callback"; // The offset of member 'pszCallBackFn' in struct WBOBJ is 28 wb_poke($window + 28, pack("V", wb_get_address($newname)), 4); $wbobj = unpack(WBOBJ, wb_peek($window, WBOBJ_SIZE)); $handler = wb_peek($wbobj["handler"]); $result .= "Window handler is now \"{$handler}\"\n\n"; $result .= "END TESTS\n\n"; wb_set_text(wb_get_control($maintab, IDC_EDIT6002), $result); }
function FreeImage_GetVersion() { global $FI; static $pfn = null; if ($pfn === null) { $pfn = wb_get_function_address("FreeImage_GetVersion", $FI); } // Must use wb_peek because this function returns a string pointer $version = wb_peek(wb_call_function($pfn)); return $version; }
function EnableCloseButton($hwnd, $enable) { global $USER; static $emi = null, $gsm = null; $wbobj = unpack(WBOBJ, wb_peek($hwnd, WBOBJ_SIZE)); if ($emi === null) { $emi = wb_get_function_address("EnableMenuItem", $USER); } if ($gsm === null) { $gsm = wb_get_function_address("GetSystemMenu", $USER); } $sysmenu = wb_call_function($gsm, array($wbobj["hwnd"], false)); return wb_call_function($emi, array($sysmenu, SC_CLOSE, !$enable)); }
/** * fmod_StreamNetState * * Gathers informations about the current netstream like buffer-progress in * percent, playback bitrate, datatype and status. * * @return bool * @access public */ function fmod_StreamNetState() { $statusstr = pack('i', 0); $status = wb_get_address($statusstr); $bufferstr = pack('i', 0); $buffer = wb_get_address($bufferstr); $bitratestr = pack('i', 0); $bitrate = wb_get_address($bitratestr); $flagsstr = pack('i', 0); $flags = wb_get_address($flagsstr); $result = $this->fmodlib_GetNetStatus($this->fmodStream, $status, $buffer, $bitrate, $flags); if ($result) { $bitrate_array = unpack('iBitrate', wb_peek($bitrate, 4)); $buffer_array = unpack('iBuffer', wb_peek($buffer, 4)); $status_array = unpack('iStatus', wb_peek($status, 4)); $flags_array = unpack('iFlags', wb_peek($flags, 4)); $netReturn['buffer'] = $buffer_array['Buffer'] . "%"; $netReturn['bitrate'] = $bitrate_array['Bitrate']; $netReturn['status'] = $status_array['Status']; switch ($status_array['Status']) { case 1: $netReturn['statustext'] = 'Not Connected'; break; case 2: $netReturn['statustext'] = 'Connecting'; break; case 3: $netReturn['statustext'] = 'Playing'; break; case 4: $netReturn['statustext'] = 'Ready'; break; case 5: $netReturn['statustext'] = 'Error'; break; } switch ($flags_array['Flags']) { // Possible Network Resources case 1: $netReturn['format'] = 'Shoutcast'; break; case 2: $netReturn['format'] = 'Icecast'; break; case 4: $netReturn['format'] = 'HTTP'; break; // Stream is type of MPEG // Stream is type of MPEG case 65536: $netReturn['format'] = 'MPEG'; break; case 65537: $netReturn['format'] = 'Shoutcast MPEG'; break; case 65538: $netReturn['format'] = 'Icecast MPEG'; break; case 65540: $netReturn['format'] = 'HTTP MPEG'; break; // Stream is type of OGG // Stream is type of OGG case 131072: $netReturn['format'] = 'OGG'; break; case 131073: $netReturn['format'] = 'Shoutcast OGG'; break; case 131074: $netReturn['format'] = 'Icecast OGG'; break; case 131076: $netReturn['format'] = 'HTTP OGG'; break; } $this->fmodNetStatus = $netReturn; $result = true; } else { $this->fmodLastErrorMsg = $this->fmodlib_GetErrorMessage(); } return $result; }