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

CF_CONNECTION_KEY should be LONGLONG #871

Closed
taufikrh opened this issue Apr 6, 2022 · 5 comments · Fixed by #1187
Closed

CF_CONNECTION_KEY should be LONGLONG #871

taufikrh opened this issue Apr 6, 2022 · 5 comments · Fixed by #1187
Assignees
Labels
rust Critical for Rust adoption

Comments

@taufikrh
Copy link

taufikrh commented Apr 6, 2022

The following TypeDefs is invalid

Native TypeDef CF_CONNECTION_KEY should Int64

Duplicate item NDR_SCONTEXT_1 with _NDR_SCONTEXT

tcp_request_query_information_ex_xp
The Context size (array) should different on each platform

HSTRING_HEADER
The Reserved2 size is should different on each platform

Request
If possible please inject additional union member (struct) for HSTRING_HEADER.
This kind of struct is useful for referencing HSTRING_HEADER from wchar_t*
see
__Platform_Details_HSTRING_HEADER (vccorlib.h) and
hstring_header (winsdkInc\cppwinrt\winrt\base.h)

#define hstring_reference_flag 1 // int

typedef struct HSTRING_HEADER
{
    union {
        PVOID Reserved1;
#if defined(_WIN64)
        char Reserved2[24];
#else
        char Reserved2[20];
#endif
        struct {
            int             flags;             // Bit flags which used for storing extra information
            unsigned int    length;            // length of string's unicode code point
            unsigned int    padding;           // padding for future use
            unsigned int    morepadding;       // padding for future use
            __wchar_t*      stringRef;         // An address pointer which points to a string buffer.
        };
    } Reserved;
} HSTRING_HEADER;
@mikebattista mikebattista added the broken api An API is inaccurate and could lead to runtime failure label Apr 7, 2022
@riverar
Copy link
Collaborator

riverar commented Apr 15, 2022

Hey @taufikrh, good catch. In the future, please open separate issues for each item as bundling several issues together is very confusing.

Native TypeDef CF_CONNECTION_KEY should Int64

Agreed.

#define DECLARE_OPAQUE_KEY( name )                                                                 \
    typedef struct name##__ {                                                                      \
        LONGLONG Internal;                                                                         \
    } name, *P##name

DECLARE_OPAQUE_KEY( CF_CONNECTION_KEY );

Duplicate item NDR_SCONTEXT_1 with _NDR_SCONTEXT

Created new issue #885

tcp_request_query_information_ex_xp
The Context size (array) should different on each platform

Will defer to @mikebattista @sotteson1. These are so poorly documented (and documented as obsolete) that perhaps we should just drop them altogether.

HSTRING_HEADER
The Reserved2 size is should different on each platform

There is no size in metadata today. The FieldOffsets are correct, so don't think there's an issue here?

public struct HSTRING_HEADER
{
	[StructLayout(LayoutKind.Explicit)]
	public struct _Reserved_e__Union
	{
		[FieldOffset(0)]
		public unsafe void* Reserved1;

		[FieldOffset(0)]
		public CHAR[] Reserved2;
	}

	public _Reserved_e__Union Reserved;
}

If possible please inject additional union member (struct) for HSTRING_HEADER.

Sounds reasonable, created a new enhancement to track that #886

@riverar riverar changed the title Some invalid TypeDef CF_CONNECTION_KEY should be LONGLONG Apr 15, 2022
@riverar
Copy link
Collaborator

riverar commented Apr 16, 2022

@sotteson1 @mikebattista How do you want to handle the CF_CONNECTION_KEY?

We have an entry in autoTypes.json (I corrected value type below)

{
  "Namespace": "Windows.Win32.Storage.CloudFilters",
  "Name": "CF_CONNECTION_KEY",
  "ValueType": "long",
  "InvalidHandleValues": [ -1, 0 ]
},

But it's also discovered during scraping (which then gets renamed to CF_CONNECTION_KEY__ to avoid clashing...

public partial struct CF_CONNECTION_KEY__
{
    [NativeTypeName("LONGLONG")]
    public long Internal;
}

We could delete the autoTypes.json entry then append the InvalidHandleValues attributes via emitter.settings.rsp but that feels a bit off. Thoughts?

@taufikrh
Copy link
Author

taufikrh commented Apr 16, 2022

Thanks @riverar
HSTRING_HEADER field offset is correct in both reserver1 and reserved2, its should 0 (union).
Just incorrect array length in Reserved2.

#if defined(_WIN64)
        char Reserved2[24];
#else
        char Reserved2[20];
#endif

See my request additional union member, wchar_t* the size is 4byte on 32bit and 8byte on 64bit.

So, actualy the sizeof(HSTRING_HEADER) is depend on Reserved2

@riverar
Copy link
Collaborator

riverar commented Apr 16, 2022

@taufikrh There are no sizes specified, see the metadata I pasted above. Are you seeing sizes somewhere else?

@taufikrh
Copy link
Author

@taufikrh There are no sizes specified, see the metadata I pasted above. Are you seeing sizes somewhere else?

Yes. No size specified in metadata, we dont have problem with packing size.
We just need to create 2 typedef (HSTRING_HEADER) for both 32bit and 64bit (arch attribute) because Reserved2 length is different on each platform

@kennykerr kennykerr added rust Critical for Rust adoption and removed broken api An API is inaccurate and could lead to runtime failure labels Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Critical for Rust adoption
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants