Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function pointers in EXTENSION_CONTROL_BLOCK are IntPtr in the metadata #983

Closed
ChrisDenton opened this issue Jun 30, 2022 · 1 comment
Closed
Assignees
Labels
broken api An API is inaccurate and could lead to runtime failure

Comments

@ChrisDenton
Copy link
Contributor

See EXTENSION_CONTROL_BLOCK. The abbreviated C definition is:

typedef struct _EXTENSION_CONTROL_BLOCK EXTENSION_CONTROL_BLOCK {
      ...
      BOOL (WINAPI * GetServerVariable) ();
      BOOL (WINAPI * WriteClient) ();
      BOOL (WINAPI * ReadClient) ();
      BOOL (WINAPI * ServerSupportFunction) ();
} EXTENSION_CONTROL_BLOCK;

But in the metadata it's:

public struct EXTENSION_CONTROL_BLOCK
{
      ...
      public IntPtr GetServerVariable;
      public IntPtr WriteClient;
      public IntPtr ReadClient;
      public IntPtr ServerSupportFunction;
}
@mikebattista mikebattista added the broken api An API is inaccurate and could lead to runtime failure label Aug 1, 2022
@AArnott AArnott changed the title Function pointers in EXTENSION_CONTROL_BLOCK are InPtr in the metadata Function pointers in EXTENSION_CONTROL_BLOCK are IntPtr in the metadata Oct 5, 2022
@mikebattista
Copy link
Contributor

The emitted C# contains more information in the NativeTypeName attribute that isn't represented in the winmd.

[NativeTypeName("BOOL (*)(HCONN, LPSTR, LPVOID, LPDWORD) __attribute__((stdcall))")]        public IntPtr GetServerVariable;
[NativeTypeName("BOOL (*)(HCONN, LPVOID, LPDWORD, DWORD) __attribute__((stdcall))")]        public IntPtr WriteClient;
[NativeTypeName("BOOL (*)(HCONN, LPVOID, LPDWORD) __attribute__((stdcall))")]        public IntPtr ReadClient;
[NativeTypeName("BOOL (*)(HCONN, DWORD, LPVOID, LPDWORD, LPDWORD) __attribute__((stdcall))")]        public IntPtr ServerSupportFunction;

#1006 tracks another issue where NativeTypeName context in the generated C# isn't being translated to the winmd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broken api An API is inaccurate and could lead to runtime failure
Projects
None yet
Development

No branches or pull requests

3 participants