Subject Re: Firebird 64 bit and UDF write in Delphi (32 bit)
Author mohamed.banaouas
--- In firebird-support@yahoogroups.com, "Slavomir Skopalik"
<skopalik@...> wrote:
>
> Hi, there is short example:
>
> Also IBX, JCL components are not familiar with Win64.
> Any ASM code have to be replaced by pure pascal code.
> It is recomended to start with some trivial task like RandG or Sleep
> function.
>
> Slavek.

Hi Slavek,
I did a simple 32 bit udf lib "myudf" and tested succesfully sleep
function. But when I added another kind of function
returning PCHAR, none works anymoore.
select mypchar() from rdb$database causes this msg.err:
Invalid token.
invalid request BLR at offset 63.
function MYPCHAR is not defined.
module name or entrypoint could not be found.

here is "myudf" source:

library myudf;
uses
windows, SysUtils, Classes, math, IB_Util;
//
{$IFDEF WINDOWS}
{$IFNDEF FPC}
{$R *.RES}
{$ENDIF FPC}
{$ENDIF WINDOWS}

type
PInt = ^Longint;
// DECLARE EXTERNAL FUNCTION Sleep INTEGER RETURNS INTEGER BY VALUE
ENTRY_POINT 'Sleep' MODULE_NAME 'myudf';
function Sleep(time:PINT):integer; cdecl;
begin
result:=0;
if time=nil then exit;
windows.Sleep(time^);
result := time^;
end;
// declare external function myint returns integer by value
entry_point 'myint' module_name 'myudf';
function myint: integer; cdecl;
begin
Result := 12345;
end;
// declare external function mypchar returns cstring(20) free_it
entry_point 'mypchar' module_name 'myudf';
const
MY_STRING = '1.2.3.4.5';
function mypchar: PChar; cdecl;
begin
Result := ib_util_malloc(Length(MY_STRING)+1);
StrCopy(Result,PChar(MY_STRING));
end;
exports
Sleep, myint, mypchar;
begin
end.