Recent

Author Topic: Windows header files  (Read 498 times)

engine32

  • New Member
  • *
  • Posts: 19
Windows header files
« on: September 25, 2022, 07:11:16 pm »
  Hello,

  How people using Lazarus are dealing with Windows header files ? I have hard time to find them.

  In particular, Microsoft says "The WSAID_MULTIPLE_RIO GUID is defined in the Mswsock.h header file."

  After much search, I found one header file that does not contain this define. I see for example:
Quote
#define WSAID_CONNECTEX {0x25a207b9,0xddf3,0x4660,{0x8e,0xe9,0x76,0xe5,0x8c,0x74,0x06,0x3e}}
but not WSAID_MULTIPLE_RIO GUID .

  I found a piece of code online with the following:
Code: Pascal  [Select][+][-]
  1.                 WSAID_MULTIPLE_RIO := &windows.GUID{0x8509e081, 0x96dd, 0x4005, [8]byte{0xb1, 0x65, 0x9e, 0x2e, 0xe8, 0xc7, 0x9e, 0x3f}}
  2.                 const SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER = 0xc8000024
  3.                 ob := uint32(0)
  4.                 err = windows.WSAIoctl(socket, SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER,
  5.                         (*byte)(unsafe.Pointer(WSAID_MULTIPLE_RIO)), uint32(unsafe.Sizeof(*WSAID_MULTIPLE_RIO)),
  6.                         (*byte)(unsafe.Pointer(&extensionFunctionTable)), uint32(unsafe.Sizeof(extensionFunctionTable)),
  7.                         &ob, nil, 0)
  I created the constants like this:
Code: Pascal  [Select][+][-]
  1.   IOC_IN = $80000000;
  2.   IOC_OUT = $40000000;
  3.   IOC_INOUT = IOC_IN or IOC_OUT;
  4.   IOC_WS2 = $08000000;
  5.   SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER = IOC_INOUT or IOC_WS2 or 36; // 3355443236; // $C8 00 00 24
  6.   WSAID_MULTIPLE_RIO: array [0..15] of byte = ($85, $09, $e0, $81, + $96, + $dd, $40, $05, $b1, $65, $9e, $2e, $e8, $c7, $9e, $3f); // 0x8509e08196dd4005b1659e2ee8c79e3f;
  7.   WSA_FLAG_REGISTERED_IO_BP = 8;
  8.  
run WSASocketW which returns a valid socket handle. However, WSAIoctl returns -1, and subsequent WSAGetLastError zero.
  So, here I am, don't know how to go further.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 528
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Windows header files
« Reply #1 on: September 25, 2022, 07:43:59 pm »
This you can find by installing Indy for Lazarus/FreePascal in file IdWinsock2.pas
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

PascalDragon

  • Hero Member
  • *****
  • Posts: 4749
  • Compiler Developer
Re: Windows header files
« Reply #2 on: September 25, 2022, 09:10:17 pm »
  After much search, I found one header file that does not contain this define. I see for example:
Quote
#define WSAID_CONNECTEX {0x25a207b9,0xddf3,0x4660,{0x8e,0xe9,0x76,0xe5,0x8c,0x74,0x06,0x3e}}
but not WSAID_MULTIPLE_RIO GUID .

Best is to install the Windows SDK and to search through the corresponding include directory.

  I found a piece of code online with the following:
Code: Pascal  [Select][+][-]
  1.                 WSAID_MULTIPLE_RIO := &windows.GUID{0x8509e081, 0x96dd, 0x4005, [8]byte{0xb1, 0x65, 0x9e, 0x2e, 0xe8, 0xc7, 0x9e, 0x3f}}
  2.                 const SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER = 0xc8000024
  3.                 ob := uint32(0)
  4.                 err = windows.WSAIoctl(socket, SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER,
  5.                         (*byte)(unsafe.Pointer(WSAID_MULTIPLE_RIO)), uint32(unsafe.Sizeof(*WSAID_MULTIPLE_RIO)),
  6.                         (*byte)(unsafe.Pointer(&extensionFunctionTable)), uint32(unsafe.Sizeof(extensionFunctionTable)),
  7.                         &ob, nil, 0)

How exactly did you translate the code, cause it essentially looks like a mixture of C and Pascal.

440bx

  • Hero Member
  • *****
  • Posts: 3156
Re: Windows header files
« Reply #3 on: September 25, 2022, 10:14:30 pm »
  How people using Lazarus are dealing with Windows header files ? I have hard time to find them.
I don't know if this will be helpful but, when I'm having a hard time finding something in the C header files, I write a tiny C program that declares a variable of the type I'm looking for, after its compiled, Visual Studio can go directly to where it's defined (courtesy of its intellisense thingy.)  It also works with things other than types.

I have a grab-bag C program just for that. :)
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 SP1 64bit.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 10399
  • FPC developer.
Re: Windows header files
« Reply #4 on: September 25, 2022, 10:28:15 pm »
mswsock.h has a nice comment:

Code: C  [Select][+][-]
  1. #define WSAID_MULTIPLE_RIO /* 8509e081-96dd-4005-b165-9e2ee8c79e3f */ \

So you just copy that into a declaration with the style of a GUID declaration from e.g. activex.pp:

Code: Pascal  [Select][+][-]
  1. const
  2.    WSAID_MULTIPLE_RIO : TGUID = '{8509e081-96dd-4005-b165-9e2ee8c79e3f}';
  3.  

I probably can add it to winsock2 if needed.
« Last Edit: September 26, 2022, 10:55:52 am by marcov »

engine32

  • New Member
  • *
  • Posts: 19
Re: Windows header files
« Reply #5 on: September 25, 2022, 11:00:57 pm »
  Thank you all, now it works

  @PascalDragon, that code I found while wandering on internet for the header file with GUID. I just did a test like this:
Code: Pascal  [Select][+][-]
  1.   IOC_IN = $80000000;
  2.   IOC_OUT = $40000000;
  3.   IOC_INOUT = IOC_IN or IOC_OUT;
  4.   IOC_WS2 = $08000000;
  5.   SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER = IOC_INOUT or IOC_WS2 or 36; // 3355443236; // $C8 00 00 24
  6.   WSAID_MULTIPLE_RIO : TGUID = '{8509e081-96dd-4005-b165-9e2ee8c79e3f}';
  7.   WSA_FLAG_REGISTERED_IO_BP = 8;
  8. ..
  9.   u32OutBytes := 0;
  10.   rRioExtensionFunctionTable.u32Size := 0;
  11.   i32Err := WSAIoctl(hSockTest, SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER, @WSAID_MULTIPLE_RIO, sizeof(WSAID_MULTIPLE_RIO), @rRioExtensionFunctionTable, sizeof(rRioExtensionFunctionTable), @u32OutBytes, 0, 0);
  12.  

  It looks that the issue was that before I provided the GUID as an array of bytes and it did not work. Now with the new format it works, although sizeof(WSAID_MULTIPLE_RIO) reports the same size of 16.

  I will install Visual Studio and Indy for Lazarus just for this issue, still better than spending hours for it.

  Does Indy for Lazarus supports REGISTERED I/O ?

KodeZwerg

  • Hero Member
  • *****
  • Posts: 528
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Windows header files
« Reply #6 on: September 26, 2022, 12:20:33 am »
  Does Indy for Lazarus supports REGISTERED I/O ?
Yes.
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 528
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Windows header files
« Reply #7 on: September 26, 2022, 12:22:11 am »
But I do not know how Indy works hand-in-hand with selfmade Api calls together, so I would realize everything within Indy.
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1158
    • Lebeau Software
Re: Windows header files
« Reply #8 on: September 26, 2022, 08:27:49 pm »
Does Indy for Lazarus supports REGISTERED I/O ?
Yes.

Actually, no.  Although Indy does declare the RIO types and constants, it does not actually use them for anything.  They are provided strictly for end-user code to make use of.  Why, I don't know (I didn't write that code). It seems a little counter-intuitive for Indy to waste effort declaring APIs it doesn't use for itself.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

 

TinyPortal © 2005-2018