1

I need to call the windows api :

BOOL WINAPI * ServerSupportFunction(
  _In_  struct _HTTP_FILTER_CONTEXT *pfc,
  _In_  enum SF_REQ_TYPE sfReq,
  _In_  PVOID pData,
  _In_  DWORD ul1,
  DWORD ul2
);

https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ff827495(v=vs.85)

That is translated in delphi like:

function (
  var pfc{: THTTP_FILTER_CONTEXT};
  sfReq: DWORD; 
  pData: Pointer; 
  ul1, ul2: DWORD): BOOL; stdcall;

The winApi doc say that UL1 (DWORD) must Points to an optional null-terminated string that contains the headers to add. So I naively try like this (delphi code) :

Var LUrl: ansiString;
LUrl := 'Location: https://myserver'+#13#10#13#10
pfc.ServerSupportFunction(
  pfc, // var pfc{: THTTP_FILTER_CONTEXT};
  SF_REQ_SEND_RESPONSE_HEADER, // sfReq: DWORD
  PANSIchar('307 Temporary Redirect'), // pData: Pointer
  Dword(@LUrl[1]), // ul1: DWORD
  0);

but this miserably fail with access violation. But as I m on 64 bit, I don't understand how Dword(@LUrl[1]) will even work as @ return 64 bit address

So how I can do ? Is their a way to force a pointer to stay in 32 bit space so that I can convert it to DWORD ? Or I simply miss something ?

zeus
  • 12,173
  • 9
  • 63
  • 184

1 Answers1

1

The doc you linked to is wrong about ul1 and ul2. The main ServerSupportFunction doc that it itself links to shows them as actually being ULONG_PTR, not DWORD:

BOOL WINAPI ServerSupportFunction(
  struct _HTTP_FILTER_CONTEXT pfc, // <- * see note below
  enum SF_REQ_TYPE sfReq,
  PVOID pData,
  ULONG_PTR ul1, // <-- not DWORD!
  ULONG_PTR ul2  // <-- not DWORD!
);

Note: should be struct _HTTP_FILTER_CONTEXT *pfc instead.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • I was just saying that you comment deserve to be an answer when you wrote the answer :) you are very good thank to be here! so do you think I must update the delphi Winapi.Isapi2.pas and rewrite the TFilterServerSupportFunctionProc = function(...ULONG_PTR ) ? – zeus Apr 19 '21 at 18:55
  • 1
    Yes, the Delphi declaration needs to be updated – Remy Lebeau Apr 19 '21 at 19:14