Using Delphi XE2 to write a 64-bit UDF with BLOBs

Hello,

We are upgrading a product to Interbase XE (x64) and we use a UDF with BLOBs (written in Delphi). 

Previously (in x86 land) we have used the TBlob definition in IBExternals to allow GetSegment and PutSegment with blobs in the UDF, but in this causes an AV when we build a the UDF as a Win64 DLL in Delphi XE2 for Interbase XE (64-bit on Win7 Pro). 

All the other UDF functions work correctly. The TBlob definition from XE2 is below - what is wrong?

Regards,
Graham

  TISC_BlobGetSegment = function(BlobHandle: PInt;
                                 Buffer: PByte;
                                 BufferSize: Long;
                                 var ResultLength: Long): Short; cdecl;
  TISC_BlobPutSegment = procedure(BlobHandle: PInt;
                                  Buffer: PByte;
                                  BufferLength: Short); cdecl;
  TBlob = record
    GetSegment         : TISC_BlobGetSegment;
    BlobHandle         : PInt;
    SegmentCount       : Long;
    MaxSegmentLength   : Long;
    TotalSize          : Long;
    PutSegment         : TISC_BlobPutSegment;
  end;
  PBlob = ^TBlob;
0
Graham
10/27/2011 8:44:06 PM
embarcadero.interbase.general 923 articles. 0 followers. Follow

2 Replies
1127 Views

Similar Articles

[PageSpeed] 24

Graham Neden-Watts wrote:
> Hello,
> 
> We are upgrading a product to Interbase XE (x64) and we use a UDF with BLOBs (written in Delphi). 
> 
> Previously (in x86 land) we have used the TBlob definition in IBExternals to allow GetSegment and PutSegment with blobs in the UDF, but in this causes an AV when we build a the UDF as a Win64 DLL in Delphi XE2 for Interbase XE (64-bit on Win7 Pro). 
> 
> All the other UDF functions work correctly. The TBlob definition from XE2 is below - what is wrong?
> 
> Regards,
> Graham
> 
>   TISC_BlobGetSegment = function(BlobHandle: PInt;
>                                  Buffer: PByte;
>                                  BufferSize: Long;
>                                  var ResultLength: Long): Short; cdecl;
>   TISC_BlobPutSegment = procedure(BlobHandle: PInt;
>                                   Buffer: PByte;
>                                   BufferLength: Short); cdecl;
>   TBlob = record
>     GetSegment         : TISC_BlobGetSegment;
>     BlobHandle         : PInt;
>     SegmentCount       : Long;
>     MaxSegmentLength   : Long;
>     TotalSize          : Long;
>     PutSegment         : TISC_BlobPutSegment;
>   end;
>   PBlob = ^TBlob;

Getting at the client DLL interface changed in XE2.  Are you sure you are 
resolving those to actual procedure calls?

-- 
Jeff Overcash (TeamB)
       (Please do not email me directly unless  asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted  corridors of Whitehall.
              (Fish)
0
Jeff
10/27/2011 9:59:57 PM
> {quote:title=Jeff Overcash wrote:}{quote}
> Graham Neden-Watts wrote:
> > Hello,
> > 
> > We are upgrading a product to Interbase XE (x64) and we use a UDF with BLOBs (written in Delphi). 
> > 
> > Previously (in x86 land) we have used the TBlob definition in IBExternals to allow GetSegment and PutSegment with blobs in the UDF, but in this causes an AV when we build a the UDF as a Win64 DLL in Delphi XE2 for Interbase XE (64-bit on Win7 Pro). 
> > 
> > All the other UDF functions work correctly. The TBlob definition from XE2 is below - what is wrong?
> > 
> > Regards,
> > Graham
> > 
> >   TISC_BlobGetSegment = function(BlobHandle: PInt;
> >                                  Buffer: PByte;
> >                                  BufferSize: Long;
> >                                  var ResultLength: Long): Short; cdecl;
> >   TISC_BlobPutSegment = procedure(BlobHandle: PInt;
> >                                   Buffer: PByte;
> >                                   BufferLength: Short); cdecl;
> >   TBlob = record
> >     GetSegment         : TISC_BlobGetSegment;
> >     BlobHandle         : PInt;
> >     SegmentCount       : Long;
> >     MaxSegmentLength   : Long;
> >     TotalSize          : Long;
> >     PutSegment         : TISC_BlobPutSegment;
> >   end;
> >   PBlob = ^TBlob;
> 
> Getting at the client DLL interface changed in XE2.  Are you sure you are 
> resolving those to actual procedure calls?
> 
> -- 
> Jeff Overcash (TeamB)
>        (Please do not email me directly unless  asked. Thank You)
> And so I patrol in the valley of the shadow of the tricolor
> I must fear evil. For I am but mortal and mortals can only die.
> Asking questions, pleading answers from the nameless
> faceless watchers that stalk the carpeted  corridors of Whitehall.
>               (Fish)

Jeff, 
Thanks for the reply. I used the XE2 IBExternals unit in the expectation that it would be relevant for x64 and x86. 
The SQL was written years ago, but the ODS has been updated to 15 - and works fine on Interbase XE 32-bit. 
I have searched the Interbase XE documentation for clues on what to change in order to support the 64-bit database, but found very little mention of x64..

I am not entirely sure which part of the Interbase system calls the UDF functions so I am not sure where to look for updated interfaces. Can you pont me where to look? 
I was assuming the problem is related to record sizes with 64-bit pointers and have tried various alternatives (like making the integer values into Int64) but really I am working blind without more information.

The line of code which fails is 

InPkt.GetSegment(InPkt.BlobHandle, PByte(@fPacket), sizeof(fPacket), Count) ;

Where fPacket is a packed record (with no pointers) that is equivalent to the blob size. BlobHandle is non-zero.

All the non-BLOB UDF calls work fine so in general the interface to the UDF DLL is working OK.

Regards,
Graham
0
Graham
10/31/2011 11:05:39 AM
Reply:

Web resources about - Using Delphi XE2 to write a 64-bit UDF with BLOBs - embarcadero.interbase.general

Delphi - Wikipedia, the free encyclopedia
... an archaeological site and a modern town in Greece on the south-western spur of Mount Parnassus in the valley of Phocis . The site of Delphi ...

Delphi Automotive (@DelphiAuto) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Delphi Automotive @ DelphiAuto ...

Delphi Connect for Verizon on the App Store on iTunes
Get Delphi Connect for Verizon on the App Store. See screenshots and ratings, and read customer reviews.


Audi working with Delphi to develop autonomous car tech
Audi is developing an iPad-sized device that will pack all the necessary computing power for a self-driving car

US approves China company's acquisition of Delphi biz
The Committee on Foreign Investment in the United States has formally approved the acquisition of Delphi's global production of braking systems ...

Verizon And Delphi Officially Launch Vehicle Diagnostics Service - $250 For The Module, $5 A Month On ...
If you're a car nut, a paranoid parent, or a small business owner looking to do a little, uh, company vehicle economy analysis, Verizon's teamed ...

Watch out Google: Delphi gives Ars a ride in its self-driving car
The automotive components maker gave Ars a preview ride around the neighborhood. MOUNTAIN VIEW, CA—On Thursday morning I met with Delphi at its ...

The skinny on Delphi's autonomous road trip across the United States
Filed under: Green , Videos , Autonomous Last week, Delphi's autonomous car became the first to complete a coast-to-coast trip across the United ...

Delphi partners with WiTricity on automated wireless charging system
One could easily argue that parking between the white lines at any local hangout presents a challenge for some inexperienced drivers. So, why ...

Resources last updated: 1/5/2016 12:07:27 PM