[Mingw-w64-public] [PATCH] headers: Add ata.h

2021-10-07 Thread Mark Harmstone
Signed-off-by: Mark Harmstone 
---
 mingw-w64-headers/ddk/include/ddk/ata.h | 1732 +++
 1 file changed, 1732 insertions(+)
 create mode 100644 mingw-w64-headers/ddk/include/ddk/ata.h

diff --git a/mingw-w64-headers/ddk/include/ddk/ata.h 
b/mingw-w64-headers/ddk/include/ddk/ata.h
new file mode 100644
index 0..2d95717e8
--- /dev/null
+++ b/mingw-w64-headers/ddk/include/ddk/ata.h
@@ -0,0 +1,1732 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#ifndef _NTATA_
+#define _NTATA_
+
+#pragma pack(push,1)
+
+typedef struct _IDENTIFY_DEVICE_DATA {
+  struct {
+USHORT Reserved1 : 1;
+USHORT Retired3 : 1;
+USHORT ResponseIncomplete : 1;
+USHORT Retired2 : 3;
+USHORT FixedDevice : 1;
+USHORT RemovableMedia : 1;
+USHORT Retired1 : 7;
+USHORT DeviceType : 1;
+  } GeneralConfiguration;
+  USHORT NumCylinders;
+  USHORT SpecificConfiguration;
+  USHORT NumHeads;
+  USHORT Retired1[2];
+  USHORT NumSectorsPerTrack;
+  USHORT VendorUnique1[3];
+  UCHAR SerialNumber[20];
+  USHORT Retired2[2];
+  USHORT Obsolete1;
+  UCHAR FirmwareRevision[8];
+  UCHAR ModelNumber[40];
+  UCHAR MaximumBlockTransfer;
+  UCHAR VendorUnique2;
+  struct {
+USHORT FeatureSupported : 1;
+USHORT Reserved : 15;
+  } TrustedComputing;
+  struct {
+UCHAR CurrentLongPhysicalSectorAlignment : 2;
+UCHAR ReservedByte49 : 6;
+UCHAR DmaSupported : 1;
+UCHAR LbaSupported : 1;
+UCHAR IordyDisable : 1;
+UCHAR IordySupported : 1;
+UCHAR Reserved1 : 1;
+UCHAR StandybyTimerSupport : 1;
+UCHAR Reserved2 : 2;
+USHORT ReservedWord50;
+  } Capabilities;
+  USHORT ObsoleteWords51[2];
+  USHORT TranslationFieldsValid : 3;
+  USHORT Reserved3 : 5;
+  USHORT FreeFallControlSensitivity : 8;
+  USHORT NumberOfCurrentCylinders;
+  USHORT NumberOfCurrentHeads;
+  USHORT CurrentSectorsPerTrack;
+  ULONG CurrentSectorCapacity;
+  UCHAR CurrentMultiSectorSetting;
+  UCHAR MultiSectorSettingValid : 1;
+  UCHAR ReservedByte59 : 3;
+  UCHAR SanitizeFeatureSupported : 1;
+  UCHAR CryptoScrambleExtCommandSupported : 1;
+  UCHAR OverwriteExtCommandSupported : 1;
+  UCHAR BlockEraseExtCommandSupported : 1;
+  ULONG UserAddressableSectors;
+  USHORT ObsoleteWord62;
+  USHORT MultiWordDMASupport : 8;
+  USHORT MultiWordDMAActive : 8;
+  USHORT AdvancedPIOModes : 8;
+  USHORT ReservedByte64 : 8;
+  USHORT MinimumMWXferCycleTime;
+  USHORT RecommendedMWXferCycleTime;
+  USHORT MinimumPIOCycleTime;
+  USHORT MinimumPIOCycleTimeIORDY;
+  struct {
+USHORT ZonedCapabilities : 2;
+USHORT NonVolatileWriteCache : 1;
+USHORT ExtendedUserAddressableSectorsSupported : 1;
+USHORT DeviceEncryptsAllUserData : 1;
+USHORT ReadZeroAfterTrimSupported : 1;
+USHORT Optional28BitCommandsSupported : 1;
+USHORT IEEE1667 : 1;
+USHORT DownloadMicrocodeDmaSupported : 1;
+USHORT SetMaxSetPasswordUnlockDmaSupported : 1;
+USHORT WriteBufferDmaSupported : 1;
+USHORT ReadBufferDmaSupported : 1;
+USHORT DeviceConfigIdentifySetDmaSupported : 1;
+USHORT LPSAERCSupported : 1;
+USHORT DeterministicReadAfterTrimSupported : 1;
+USHORT CFastSpecSupported : 1;
+  } AdditionalSupported;
+  USHORT ReservedWords70[5];
+  USHORT QueueDepth : 5;
+  USHORT ReservedWord75 : 11;
+  struct {
+USHORT Reserved0 : 1;
+USHORT SataGen1 : 1;
+USHORT SataGen2 : 1;
+USHORT SataGen3 : 1;
+USHORT Reserved1 : 4;
+USHORT NCQ : 1;
+USHORT HIPM : 1;
+USHORT PhyEvents : 1;
+USHORT NcqUnload : 1;
+USHORT NcqPriority : 1;
+USHORT HostAutoPS : 1;
+USHORT DeviceAutoPS : 1;
+USHORT ReadLogDMA : 1;
+USHORT Reserved2 : 1;
+USHORT CurrentSpeed : 3;
+USHORT NcqStreaming : 1;
+USHORT NcqQueueMgmt : 1;
+USHORT NcqReceiveSend : 1;
+USHORT DEVSLPtoReducedPwrState : 1;
+USHORT Reserved3 : 8;
+  } SerialAtaCapabilities;
+  struct {
+USHORT Reserved0 : 1;
+USHORT NonZeroOffsets : 1;
+USHORT DmaSetupAutoActivate : 1;
+USHORT DIPM : 1;
+USHORT InOrderData : 1;
+USHORT HardwareFeatureControl : 1;
+USHORT SoftwareSettingsPreservation : 1;
+USHORT NCQAutosense : 1;
+USHORT DEVSLP : 1;
+USHORT HybridInformation : 1;
+USHORT Reserved1 : 6;
+  } SerialAtaFeaturesSupported;
+  struct {
+USHORT Reserved0 : 1;
+USHORT NonZeroOffsets : 1;
+USHORT DmaSetupAutoActivate : 1;
+USHORT DIPM : 1;
+USHORT InOrderData : 1;
+USHORT HardwareFeatureControl : 1;
+USHORT SoftwareSettingsPreservation : 1;
+USHORT DeviceAutoPS : 1;
+USHORT DEVSLP : 1;
+USHORT HybridInformation : 1;
+USHORT Reserved1 : 6;
+  } SerialAtaFeaturesEnabled;
+  USHORT MajorRevision;
+  USHORT MinorRevision;
+  struct {
+USHORT SmartCommands : 1;
+USHORT SecurityMode : 1;
+USHORT RemovableMediaFeature 

Re: [Mingw-w64-public] [PATCH] crt: Check pseudo relocations for overflows and error out clearly

2021-10-07 Thread Martin Storsjö

On Thu, 7 Oct 2021, Jeremy Drake via Mingw-w64-public wrote:


I thought pseudo-relocs were only needed when auto-importing an offset
from an exported symbol (ie, a struct member or something like that), and
that otherwse something in the normal Windows loader was leveraged.


No, they're needed anywhere where you have code accessing a global 
variable (data symbol) from a different DLL, that wasn't marked dllimport 
when the compiler generated the access to it.


(See https://github.com/ziglang/zig/issues/9845#issuecomment-929025888 for 
a bit more detail/nuance about how it works.)


(Also, actually, lld has a trick that even allows avoiding the pseudo 
relocations altogether in many cases, for cases when the compiler 
generated suitable .refptr stubs.)



If this is indeed where the truncated 32-bit relative runtime relocations
happen, it sounds very nice to have an immediate error instead of waiting
until the function happens to be called.


Yup. I _think_ this implementation should be free of false positives, but 
we only know once you rebuild all of msys2 with it and try running those 
packages ;-)



Also, I have seen issues that look like this in GCC, not just Clang.  I
don't recall any manual overriding of the code model either.


Yes it's certainly possible that it happens elsewhere with GCC too (I 
don't know offhand how/where, so each of those instances would be 
cosnidered a bug in either GCC/Clang or mingw-w64-crt, I think), and this 
certainly helps diagnosing those situations.


// Martin



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH] include/wdm.h: Update IO_STACK_LOCATION struct.

2021-10-07 Thread Mark Harmstone
Signed-off-by: Mark Harmstone 
---
 mingw-w64-headers/ddk/include/ddk/wdm.h | 71 ++---
 1 file changed, 63 insertions(+), 8 deletions(-)

diff --git a/mingw-w64-headers/ddk/include/ddk/wdm.h 
b/mingw-w64-headers/ddk/include/ddk/wdm.h
index 2e4a628a0..64bcbc5c7 100644
--- a/mingw-w64-headers/ddk/include/ddk/wdm.h
+++ b/mingw-w64-headers/ddk/include/ddk/wdm.h
@@ -4360,6 +4360,24 @@ typedef enum _CREATE_FILE_TYPE {
   CreateFileTypeMailslot
 } CREATE_FILE_TYPE;
 
+typedef struct _NAMED_PIPE_CREATE_PARAMETERS {
+  ULONG NamedPipeType;
+  ULONG ReadMode;
+  ULONG CompletionMode;
+  ULONG MaximumInstances;
+  ULONG InboundQuota;
+  ULONG OutboundQuota;
+  LARGE_INTEGER DefaultTimeout;
+  BOOLEAN TimeoutSpecified;
+} NAMED_PIPE_CREATE_PARAMETERS, *PNAMED_PIPE_CREATE_PARAMETERS;
+
+typedef struct _MAILSLOT_CREATE_PARAMETERS {
+  ULONG MailslotQuota;
+  ULONG MaximumMessageSize;
+  LARGE_INTEGER ReadTimeout;
+  BOOLEAN TimeoutSpecified;
+} MAILSLOT_CREATE_PARAMETERS, *PMAILSLOT_CREATE_PARAMETERS;
+
 #define IO_FORCE_ACCESS_CHECK   0x001
 #define IO_NO_PARAMETER_CHECKING0x100
 
@@ -5112,6 +5130,11 @@ typedef enum _FILE_INFORMATION_CLASS {
   FileMaximumInformation
 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
 
+typedef enum _DIRECTORY_NOTIFY_INFORMATION_CLASS {
+  DirectoryNotifyInformation = 1,
+  DirectoryNotifyExtendedInformation
+} DIRECTORY_NOTIFY_INFORMATION_CLASS, *PDIRECTORY_NOTIFY_INFORMATION_CLASS;
+
 typedef struct _FILE_POSITION_INFORMATION {
   LARGE_INTEGER CurrentByteOffset;
 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
@@ -6479,26 +6502,51 @@ typedef struct _IO_STACK_LOCATION {
   USHORT ShareAccess;
   ULONG POINTER_ALIGNMENT EaLength;
 } Create;
+struct {
+  PIO_SECURITY_CONTEXT SecurityContext;
+  ULONG Options;
+  USHORT POINTER_ALIGNMENT Reserved;
+  USHORT ShareAccess;
+  PNAMED_PIPE_CREATE_PARAMETERS Parameters;
+} CreatePipe;
+struct {
+  PIO_SECURITY_CONTEXT SecurityContext;
+  ULONG Options;
+  USHORT POINTER_ALIGNMENT Reserved;
+  USHORT ShareAccess;
+  PMAILSLOT_CREATE_PARAMETERS Parameters;
+} CreateMailslot;
 struct {
   ULONG Length;
   ULONG POINTER_ALIGNMENT Key;
+#ifdef _WIN64
+  ULONG Flags;
+#endif
   LARGE_INTEGER ByteOffset;
 } Read;
 struct {
   ULONG Length;
   ULONG POINTER_ALIGNMENT Key;
+#ifdef _WIN64
+  ULONG Flags;
+#endif
   LARGE_INTEGER ByteOffset;
 } Write;
 struct {
   ULONG Length;
   PUNICODE_STRING FileName;
   FILE_INFORMATION_CLASS FileInformationClass;
-  ULONG FileIndex;
+  ULONG POINTER_ALIGNMENT FileIndex;
 } QueryDirectory;
 struct {
   ULONG Length;
-  ULONG CompletionFilter;
+  ULONG POINTER_ALIGNMENT CompletionFilter;
 } NotifyDirectory;
+struct {
+  ULONG Length;
+  ULONG POINTER_ALIGNMENT CompletionFilter;
+  DIRECTORY_NOTIFY_INFORMATION_CLASS POINTER_ALIGNMENT 
DirectoryNotifyInformationClass;
+} NotifyDirectoryEx;
 struct {
   ULONG Length;
   FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
@@ -6520,7 +6568,7 @@ typedef struct _IO_STACK_LOCATION {
   ULONG Length;
   PVOID EaList;
   ULONG EaListLength;
-  ULONG EaIndex;
+  ULONG POINTER_ALIGNMENT EaIndex;
 } QueryEa;
 struct {
   ULONG Length;
@@ -6531,17 +6579,17 @@ typedef struct _IO_STACK_LOCATION {
 } QueryVolume;
 struct {
   ULONG Length;
-  FS_INFORMATION_CLASS FsInformationClass;
+  FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
 } SetVolume;
 struct {
   ULONG OutputBufferLength;
-  ULONG InputBufferLength;
-  ULONG FsControlCode;
+  ULONG POINTER_ALIGNMENT InputBufferLength;
+  ULONG POINTER_ALIGNMENT FsControlCode;
   PVOID Type3InputBuffer;
 } FileSystemControl;
 struct {
   PLARGE_INTEGER Length;
-  ULONG Key;
+  ULONG POINTER_ALIGNMENT Key;
   LARGE_INTEGER ByteOffset;
 } LockControl;
 struct {
@@ -6622,7 +6670,14 @@ typedef struct _IO_STACK_LOCATION {
   PPOWER_SEQUENCE PowerSequence;
 } PowerSequence;
 struct {
-  ULONG SystemContext;
+#if (NTDDI_VERSION >= NTDDI_WINVISTA)
+  _ANONYMOUS_UNION union {
+#endif
+ULONG SystemContext;
+#if (NTDDI_VERSION >= NTDDI_WINVISTA)
+SYSTEM_POWER_STATE_CONTEXT SystemPowerStateContext;
+  } DUMMYUNIONNAME;
+#endif
   POWER_STATE_TYPE POINTER_ALIGNMENT Type;
   POWER_STATE POINTER_ALIGNMENT State;
   POWER_ACTION POINTER_ALIGNMENT ShutdownType;
-- 
2.32.0



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] Latest Windows SDK headers and API support in the MinGW-W64 toolchain

2021-10-07 Thread Biswapriyo Nath
Hi Praveen, the mingw-w64-headers package[1] has been updated in msys2
with these new changes.

[1]: https://packages.msys2.org/base/mingw-w64-headers-git


___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] Patches to fix #515 and 916.

2021-10-07 Thread Martin Storsjö

Hi,

On Sun, 3 Oct 2021, David James wrote:


Oops. Resending patches in .txt files.

I’ve also reattached the test file, to which I added a small amount of 
additional testing.


Thanks, David.


Thanks for your patches - and it's great to have the corresponding 
testcases too! After sitting down and reading through the code, I don't 
think I have any objections to it, so unless others have anything to add, 
I'd push them. (There's a couple cases of stray whitespace changes and 
trailing whitespace that I can fix up.)


// Martin

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH] crt: Check pseudo relocations for overflows and error out clearly

2021-10-07 Thread Martin Storsjö
Normally, when correctly configured, the pseudo relocations should
be in fields that are large enough to hold the full target
offset/address. But if the relocations nevertheless end up truncated,
error out clearly instead of running into a hard to diagnose crash
at runtime.

The pseudo relocations can be applied both on absolute pointers and
relative offsets, so when writing a N bit number, we don't know if
the limits for it are unsigned or signed. Thus carefully allow
values from -(2^(N-1)) to (2^N)-1, covering the full range for both
signed and unsigned N bit numbers. This won't catch all cases where
offsets are out of bounds, but should catch the vast majority, allowing
a clearer error message in those situations.

By default, GCC builds for x86_64 with the medium code model, which
adds .refptr stubs when referencing addresses that might end up
autoimported (i.e. when referencing addresses that can be out of range
for a 32 bit offset). Some users, who don't expect to be autoimporting
any data symbols, might be building with -mcmodel=small [1], which
avoids this extra indirection - but which then silently breaks things
if actually ending up autoimporting data symbols from another DLL.

This can also happen if calling a function which is marked "DATA" in
the def files as it's not meant to be called/used normally (because we
provide a replacement in libmingwex or lib*crt* that we think should
be used instead). If the function that is meant to be called is missing
(this can happen in misconfigured builds where the libraries are lacking
symbols that we expect to provide, see [2]), the linker can end up doing
an autoimport of the function into a 32 bit RIP-relative offset.
(This only happens with Clang; GCC creates a .refptr stub for the
function in these cases, while Clang expects such stubs not to be needed
for functions, only for data.)

[1] 
https://code.videolan.org/videolan/dav1d/-/commit/8f7af99687533d15a9b5d16abc7b9d7b0cd4dcd0
[2] https://github.com/ziglang/zig/issues/9845

Signed-off-by: Martin Storsjö 
---
 mingw-w64-crt/crt/pseudo-reloc.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/mingw-w64-crt/crt/pseudo-reloc.c b/mingw-w64-crt/crt/pseudo-reloc.c
index feab8720f..2452dff5a 100644
--- a/mingw-w64-crt/crt/pseudo-reloc.c
+++ b/mingw-w64-crt/crt/pseudo-reloc.c
@@ -311,6 +311,7 @@ do_pseudo_reloc (void * start, void * end, void * base)
   ptrdiff_t reloc_target = (ptrdiff_t) ((char *)end - (char*)start);
   runtime_pseudo_reloc_v2 *v2_hdr = (runtime_pseudo_reloc_v2 *) start;
   runtime_pseudo_reloc_item_v2 *r;
+  unsigned int bits;
 
   /* A valid relocation list will contain at least one entry, and
* one v1 data structure (the smallest one) requires two DWORDs.
@@ -440,6 +441,23 @@ do_pseudo_reloc (void * start, void * end, void * base)
   reldata -= ((ptrdiff_t) base + r->sym);
   reldata += addr_imp;
 
+  bits = r->flags & 0xff;
+  if (bits < sizeof(ptrdiff_t)*8)
+{
+  /* Check for overflows. We don't know if the target address is
+   * interpreted as a relative offset or as a truncated absolute
+   * address - to avoid false positives, allow offsets within the
+   * whole range of signed and unsigned N bits numbers, but error
+   * out for anything outside of that. Thus for relative offsets,
+   * this won't catch offsets that are only barely too large. */
+  ptrdiff_t max_unsigned = (1LL << bits) - 1;
+  ptrdiff_t min_signed = (~(ptrdiff_t)0) << (bits - 1);
+  if (reldata > max_unsigned || reldata < min_signed)
+   __report_error ("%d bit pseudo relocation at %p out of range, "
+"targeting %p, yielding the value %p.\n",
+bits, reloc_target, addr_imp, reldata);
+}
+
   /* Write the new relocation value back to *reloc_target */
   switch ((r->flags & 0xff))
{
-- 
2.25.1



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH 1/2] crt: Add APIs in computenetwork.def

2021-10-07 Thread Biswapriyo Nath

From f381f33abc67c51626ff564155bfa7d9aabc8f7a Mon Sep 17 00:00:00 2001
From: Biswapriyo Nath 
Date: Thu, 7 Oct 2021 23:36:16 +0530
Subject: [PATCH 1/2] crt: Add APIs in computenetwork.def

Signed-off-by: Biswapriyo Nath 
---
 mingw-w64-crt/lib-common/computenetwork.def | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/mingw-w64-crt/lib-common/computenetwork.def 
b/mingw-w64-crt/lib-common/computenetwork.def
index 5c339e6..119a041 100644
--- a/mingw-w64-crt/lib-common/computenetwork.def
+++ b/mingw-w64-crt/lib-common/computenetwork.def
@@ -36,9 +36,11 @@ HcnDeleteLoadBalancer
 HcnDeleteNamespace
 HcnDeleteNetwork
 HcnEnumerateEndpoints
+HcnEnumerateGuestNetworkPortReservations
 HcnEnumerateLoadBalancers
 HcnEnumerateNamespaces
 HcnEnumerateNetworks
+HcnFreeGuestNetworkPortReservations
 HcnModifyEndpoint
 HcnModifyLoadBalancer
 HcnModifyNamespace
@@ -48,8 +50,12 @@ HcnOpenLoadBalancer
 HcnOpenNamespace
 HcnOpenNetwork
 HcnQueryEndpointProperties
+HcnQueryEndpointStats
 HcnQueryLoadBalancerProperties
 HcnQueryNamespaceProperties
 HcnQueryNetworkProperties
 HcnRegisterServiceCallback
+HcnReleaseGuestNetworkServicePortReservationHandle
+HcnReserveGuestNetworkServicePort
+HcnReserveGuestNetworkServicePortRange
 HcnUnregisterServiceCallback
-- 
2.33.0

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH 2/2] headers: Add APIs in computenetwork.h

2021-10-07 Thread Biswapriyo Nath

From 57f1cca0c582f655a18fda5c177c56131f8c99bb Mon Sep 17 00:00:00 2001
From: Biswapriyo Nath 
Date: Thu, 7 Oct 2021 23:36:52 +0530
Subject: [PATCH 2/2] headers: Add APIs in computenetwork.h

Signed-off-by: Biswapriyo Nath 
---
 mingw-w64-headers/include/computenetwork.h | 50 ++
 1 file changed, 50 insertions(+)

diff --git a/mingw-w64-headers/include/computenetwork.h 
b/mingw-w64-headers/include/computenetwork.h
index 6d2b8a0..3fc8080 100644
--- a/mingw-w64-headers/include/computenetwork.h
+++ b/mingw-w64-headers/include/computenetwork.h
@@ -25,6 +25,12 @@ typedef enum HCN_NOTIFICATIONS {
   HcnNotificationNetworkDelete = 0x0004,
   HcnNotificationNamespaceCreate = 0x0005,
   HcnNotificationNamespaceDelete = 0x0006,
+  HcnNotificationGuestNetworkServiceCreate = 0x0007,
+  HcnNotificationGuestNetworkServiceDelete = 0x0008,
+  HcnNotificationNetworkEndpointAttached = 0x0009,
+  HcnNotificationNetworkEndpointDetached = 0x0010,
+  HcnNotificationGuestNetworkServiceStateChanged = 0x0011,
+  HcnNotificationGuestNetworkServiceInterfaceStateChanged = 0x0012,
   HcnNotificationServiceDisconnect = 0x0100,
   HcnNotificationFlagsReserved = 0xF000
 } HCN_NOTIFICATIONS;
@@ -83,6 +89,50 @@ typedef HCN_SERVICE* PHCN_SERVICE;
 HRESULT WINAPI HcnRegisterServiceCallback (HCN_NOTIFICATION_CALLBACK Callback, 
void *Context, HCN_CALLBACK *CallbackHandle);
 HRESULT WINAPI HcnUnregisterServiceCallback (HCN_CALLBACK CallbackHandle);
 
+typedef void* HCN_GUESTNETWORKSERVICE;
+typedef HCN_GUESTNETWORKSERVICE* PHCN_GUESTNETWORKSERVICE;
+
+HRESULT WINAPI HcnRegisterGuestNetworkServiceCallback (HCN_GUESTNETWORKSERVICE 
GuestNetworkService, HCN_NOTIFICATION_CALLBACK Callback, void* Context, 
HCN_CALLBACK* CallbackHandle);
+HRESULT WINAPI HcnUnregisterGuestNetworkServiceCallback (HCN_CALLBACK 
CallbackHandle);
+HRESULT WINAPI HcnCreateGuestNetworkService (REFGUID Id, PCWSTR Settings, 
PHCN_GUESTNETWORKSERVICE GuestNetworkService, PWSTR* ErrorRecord);
+HRESULT WINAPI HcnCloseGuestNetworkService (HCN_GUESTNETWORKSERVICE 
GuestNetworkService);
+HRESULT WINAPI HcnModifyGuestNetworkService (HCN_GUESTNETWORKSERVICE 
GuestNetworkService, PCWSTR Settings, PWSTR* ErrorRecord);
+HRESULT WINAPI HcnDeleteGuestNetworkService (REFGUID Id, PWSTR* ErrorRecord);
+
+typedef enum tagHCN_PORT_PROTOCOL {
+  HCN_PORT_PROTOCOL_TCP = 0x01,
+  HCN_PORT_PROTOCOL_UDP = 0x02,
+  HCN_PORT_PROTOCOL_BOTH = 0x03
+} HCN_PORT_PROTOCOL;
+
+typedef enum tagHCN_PORT_ACCESS {
+  HCN_PORT_ACCESS_EXCLUSIVE = 0x01,
+  HCN_PORT_ACCESS_SHARED = 0x02
+} HCN_PORT_ACCESS;
+
+typedef struct tagHCN_PORT_RANGE_RESERVATION {
+  USHORT startingPort;
+  USHORT endingPort;
+} HCN_PORT_RANGE_RESERVATION;
+
+typedef struct tagHCN_PORT_RANGE_ENTRY {
+  GUID OwningPartitionId;
+  GUID TargetPartitionId;
+  HCN_PORT_PROTOCOL Protocol;
+  UINT64 Priority;
+  UINT32 ReservationType;
+  UINT32 SharingFlags;
+  UINT32 DeliveryMode;
+  UINT16 StartingPort;
+  UINT16 EndingPort;
+} HCN_PORT_RANGE_ENTRY, *PHCN_PORT_RANGE_ENTRY;
+
+HRESULT WINAPI HcnReserveGuestNetworkServicePort (HCN_GUESTNETWORKSERVICE 
GuestNetworkService, HCN_PORT_PROTOCOL Protocol, HCN_PORT_ACCESS Access, USHORT 
Port, HANDLE* PortReservationHandle);
+HRESULT WINAPI HcnReserveGuestNetworkServicePortRange (HCN_GUESTNETWORKSERVICE 
GuestNetworkService, USHORT PortCount, HCN_PORT_RANGE_RESERVATION* 
PortRangeReservation, HANDLE* PortReservationHandle);
+HRESULT WINAPI HcnReleaseGuestNetworkServicePortReservationHandle (HANDLE 
PortReservationHandle);
+HRESULT WINAPI HcnEnumerateGuestNetworkPortReservations (ULONG* ReturnCount, 
HCN_PORT_RANGE_ENTRY** PortEntries);
+VOID WINAPI HcnFreeGuestNetworkPortReservations (HCN_PORT_RANGE_ENTRY* 
PortEntries);
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.33.0

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] crt: Check pseudo relocations for overflows and error out clearly

2021-10-07 Thread Jeremy Drake via Mingw-w64-public
On Thu, 7 Oct 2021, Martin Storsjö wrote:

> This can also happen if calling a function which is marked "DATA" in
> the def files as it's not meant to be called/used normally (because we
> provide a replacement in libmingwex or lib*crt* that we think should
> be used instead). If the function that is meant to be called is missing
> (this can happen in misconfigured builds where the libraries are lacking
> symbols that we expect to provide, see [2]), the linker can end up doing
> an autoimport of the function into a 32 bit RIP-relative offset.
> (This only happens with Clang; GCC creates a .refptr stub for the
> function in these cases, while Clang expects such stubs not to be needed
> for functions, only for data.)

I thought pseudo-relocs were only needed when auto-importing an offset
from an exported symbol (ie, a struct member or something like that), and
that otherwse something in the normal Windows loader was leveraged.

If this is indeed where the truncated 32-bit relative runtime relocations
happen, it sounds very nice to have an immediate error instead of waiting
until the function happens to be called.

Also, I have seen issues that look like this in GCC, not just Clang.  I
don't recall any manual overriding of the code model either.
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public