From win-pv-devel-bounces@lists.xenproject.org Wed Jun 04 08:29:12 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 04 Jun 2025 08:29:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1005223.1384734 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uMjUk-0002x5-SN; Wed, 04 Jun 2025 08:29:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1005223.1384734; Wed, 04 Jun 2025 08:29:10 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uMjUk-0002wy-PY; Wed, 04 Jun 2025 08:29:10 +0000
Received: by outflank-mailman (input) for mailman id 1005223;
 Wed, 04 Jun 2025 08:29:09 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=c4px=YT=cloud.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1uMjUj-0002wq-AZ
 for win-pv-devel@lists.xenproject.org; Wed, 04 Jun 2025 08:29:09 +0000
Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com
 [2a00:1450:4864:20::131])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id faf4c9fb-411d-11f0-a300-13f23c93f187;
 Wed, 04 Jun 2025 10:29:08 +0200 (CEST)
Received: by mail-lf1-x131.google.com with SMTP id
 2adb3069b0e04-551fe46934eso770072e87.1
 for <win-pv-devel@lists.xenproject.org>; Wed, 04 Jun 2025 01:29:06 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: faf4c9fb-411d-11f0-a300-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=cloud.com; s=cloud; t=1749025746; x=1749630546; darn=lists.xenproject.org;
        h=cc:to:subject:message-id:date:from:in-reply-to:references
         :mime-version:from:to:cc:subject:date:message-id:reply-to;
        bh=qG0mVfVH2bxLakJ34IP+VA151vzN/OpUARX0W4c5QtI=;
        b=SC3W9wKI2MvPYs0A0iNne4cOSiAB+hThoI1vD9Wt8yvdSiC1Lcft7nK/BLnJVTU3eS
         IxZ4ZziQS4QMIZxpkCnGY4aynhRghmbwF3PglxANLymoB0x5IVH6yPf4KI2vkVf0ms7t
         +aVGp6haERKI6nZwh/m7B+nP5ZZ6ZSRHNsPUg=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1749025746; x=1749630546;
        h=cc:to:subject:message-id:date:from:in-reply-to:references
         :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=qG0mVfVH2bxLakJ34IP+VA151vzN/OpUARX0W4c5QtI=;
        b=A+oNC3Tp3QwIlystt+Y4x0Rp1gc+xdQAQIwMsggGe4TLqnhh5mHc5DTwvp+4iy1hY+
         ZFI/rNkY9GcQoFGxCPJY2y2s2FLb+7xeN2MWFu3uNFKroIXQMl7nKDCTTQuYe4snBbFp
         Z6Q2toRQ9NkJ2lWU8XLrY0iz9ekmVWnjUKPPkrALkyCzkr0205moRBu96IFC47waSzBl
         Ma57yxwuKzWhiExxxTY9wLZ+t3nTnHDJ+jxBSL1NnP0lIBevxo0cs/9ITzAdsNYusOiA
         e+Cg9hO77BSYcwweh5PxuoTFp0ipxcF3/wSvEsXdV4VAeoufeEiN094mK0e4tsI5KWE7
         tlPg==
X-Gm-Message-State: AOJu0YzzdFnvTjSw17xw/PBSZ2C8tmdZS314TwRr5dlYdp8fTdmt/64z
	pycQeYW7XDEO7gBi7I66hK3Y/VbjQBqbG027EEXskM/N+YVR2KV9oN79LGFH1k03jtkAROGySkk
	tOsq1vi5+9d+1dqT1uLtHudoxtAG11wlBDqAmLfvaWn24kKTwBE4=
X-Gm-Gg: ASbGncuur8N1OxHscpOm0+xZaSrPI8kwxOoWUw0g2koJvozHjKg/I9jNgNWNhNq7EH3
	wBfZAM2X74+4CLJX/4UCn0Rz9zRwcbQW9zmF6l5v3AlFZhsAqJ5ecum1w7EB2EZ0Zxjo/fnKnKM
	8p6ruYg6Bcidn0LtzvNGM1UYJjqId0Wm2w
X-Google-Smtp-Source: AGHT+IG0zs2jGnsmKA08wtjHRRRPiSgc89/O0mdAuk8/T5fWUpqcFkn6iTQBjm95Jfzg1mKbIfKLGybmnkf6hhI6Wdg=
X-Received: by 2002:a05:6512:ac3:b0:551:e99c:de65 with SMTP id
 2adb3069b0e04-5535316cc9bmr1715861e87.15.1749025746188; Wed, 04 Jun 2025
 01:29:06 -0700 (PDT)
MIME-Version: 1.0
References: <20250531194524.1865-1-ngoc-tu.dinh@vates.tech> <20250531194524.1865-2-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250531194524.1865-2-ngoc-tu.dinh@vates.tech>
From: Owen Smith <owen.smith@cloud.com>
Date: Wed, 4 Jun 2025 09:28:53 +0100
X-Gm-Features: AX0GCFuw3PMdXOHzAQxaGScyD1id2b-hbK6GOiue-eM9hAbvVNtwxID3WJXIsEU
Message-ID: <CAC_UY88GciO52JNjswRt-6tBa5716Eufyh96-kERf4SGNUqwLw@mail.gmail.com>
Subject: Re: [XENBUS PATCH 1/2] Add autoreboot retry logic
To: Tu Dinh <ngoc-tu.dinh@vates.tech>
Cc: win-pv-devel@lists.xenproject.org, Paul Durrant <paul@xen.org>
Content-Type: multipart/alternative; boundary="0000000000004e0ca30636bacae2"

--0000000000004e0ca30636bacae2
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Looks good.
The AutoReboot option does require the VM admin to set a registry key, so
its opt in and may not need a cancel option with the 'system busy' check.

Reviewed-by: Owen Smith <owen.smith@cloud.com>


On Sat, May 31, 2025 at 8:46=E2=80=AFPM Tu Dinh <ngoc-tu.dinh@vates.tech> w=
rote:

> Add a new context flag RebootRequested, to be set in PromptForReboot.
> Add a timer that calls TryAutoReboot() every minute if reboot has been
> requested beforehand.
>
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
> IMO the autoreboot logic needs some changes. At the moment, autoreboot is
> triggered without giving the user a chance to cancel the reboot.
> ---
>  src/monitor/monitor.c | 74 +++++++++++++++++++++++++++++++++++--------
>  1 file changed, 60 insertions(+), 14 deletions(-)
>
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 185838f..faf1155 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -57,10 +57,13 @@ typedef struct _MONITOR_CONTEXT {
>      HANDLE                  EventLog;
>      HANDLE                  StopEvent;
>      HANDLE                  RequestEvent;
> +    HANDLE                  Timer;
>      HKEY                    RequestKey;
>      PTCHAR                  Title;
>      PTCHAR                  Text;
>      PTCHAR                  Question;
> +    BOOL                    RebootRequested;
> +    PTCHAR                  RebootRequestedBy;
>      BOOL                    RebootPending;
>  } MONITOR_CONTEXT, *PMONITOR_CONTEXT;
>
> @@ -604,17 +607,24 @@ PromptForReboot(
>
>      Log("=3D=3D=3D=3D> (%s)", DriverName);
>
> +    Context->RebootRequested =3D TRUE;
> +    if (!Context->RebootRequestedBy) {
> +        Context->RebootRequestedBy =3D _tcsdup(DriverName);
> +        if (!Context->RebootRequestedBy)
> +            goto fail1;
> +    }
> +
>      Title =3D Context->Title;
>      TitleLength =3D (DWORD)((_tcslen(Context->Title) +
>                             1) * sizeof (TCHAR));
>
>      // AutoReboot is set, DoReboot has been called
> -    if (TryAutoReboot(DriverName))
> +    if (TryAutoReboot(Context->RebootRequestedBy))
>          goto done;
>
> -    DisplayName =3D GetDisplayName(DriverName);
> +    DisplayName =3D GetDisplayName(Context->RebootRequestedBy);
>      if (DisplayName =3D=3D NULL)
> -        goto fail1;
> +        goto fail2;
>
>      Description =3D _tcsrchr(DisplayName, ';');
>      if (Description =3D=3D NULL)
> @@ -631,7 +641,7 @@ PromptForReboot(
>
>      Text =3D calloc(1, TextLength);
>      if (Text =3D=3D NULL)
> -        goto fail2;
> +        goto fail3;
>
>      Result =3D StringCbPrintf(Text,
>                              TextLength,
> @@ -647,7 +657,7 @@ PromptForReboot(
>                                     &SessionInfo,
>                                     &Count);
>      if (!Success)
> -        goto fail3;
> +        goto fail4;
>
>      for (Index =3D 0; Index < Count; Index++) {
>          DWORD                   SessionId =3D SessionInfo[Index].Session=
Id;
> @@ -678,7 +688,7 @@ PromptForReboot(
>                                   TRUE);
>
>          if (!Success)
> -            goto fail4;
> +            goto fail5;
>
>          Context->RebootPending =3D TRUE;
>
> @@ -697,28 +707,31 @@ done:
>
>      return;
>
> -fail4:
> -    Log("fail4");
> +fail5:
> +    Log("fail5");
>
>      WTSFreeMemory(SessionInfo);
>
> +fail4:
> +    Log("fail4");
> +
>  fail3:
>      Log("fail3");
>
> -fail2:
> -    Log("fail2");
> -
>      free(DisplayName);
>
> -fail1:
> +fail2:
>      Error =3D GetLastError();
>
>      {
>          PTCHAR  Message;
>          Message =3D GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        Log("fail2 (%s)", Message);
>          LocalFree(Message);
>      }
> +
> +fail1:
> +    Log("fail1");
>  }
>
>  static VOID
> @@ -1243,6 +1256,7 @@ MonitorMain(
>      PTCHAR              RequestKeyName;
>      BOOL                Success;
>      HRESULT             Error;
> +    LARGE_INTEGER       DueTime;
>
>      UNREFERENCED_PARAMETER(argc);
>      UNREFERENCED_PARAMETER(argv);
> @@ -1314,16 +1328,32 @@ MonitorMain(
>      if (!Success)
>          goto fail9;
>
> +    Context->Timer =3D CreateWaitableTimer(NULL, FALSE, NULL);
> +    if (Context->Timer =3D=3D NULL)
> +        goto fail10;
> +
> +    DueTime.QuadPart =3D -600000000; // 1 minute
> +
> +    Success =3D SetWaitableTimer(Context->Timer,
> +                               &DueTime,
> +                               60000,
> +                               NULL,
> +                               NULL,
> +                               FALSE);
> +    if (!Success)
> +        goto fail11;
> +
>      SetEvent(Context->RequestEvent);
>
>      ReportStatus(SERVICE_RUNNING, NO_ERROR, 0);
>
>      for (;;) {
> -        HANDLE  Events[2];
> +        HANDLE  Events[3];
>          DWORD   Object;
>
>          Events[0] =3D Context->StopEvent;
>          Events[1] =3D Context->RequestEvent;
> +        Events[2] =3D Context->Timer;
>
>          Log("waiting (%u)...", ARRAYSIZE(Events));
>          Object =3D WaitForMultipleObjects(ARRAYSIZE(Events),
> @@ -1342,12 +1372,20 @@ MonitorMain(
>              CheckRequestKey();
>              break;
>
> +        case WAIT_OBJECT_0 + 2:
> +            if (Context->RebootRequested)
> +                TryAutoReboot(Context->RebootRequestedBy);
> +            break;
> +
>          default:
>              break;
>          }
>      }
>
>  done:
> +    CancelWaitableTimer(Context->Timer);
> +    CloseHandle(Context->Timer);
> +
>      (VOID) RegDeleteTree(Context->RequestKey, NULL);
>
>      free(Context->Question);
> @@ -1369,6 +1407,14 @@ done:
>
>      return;
>
> +fail11:
> +    Log("fail11");
> +
> +    CloseHandle(Context->Timer);
> +
> +fail10:
> +    Log("fail10");
> +
>  fail9:
>      Log("fail9");
>
> --
> 2.49.0.windows.1
>
>
>
> Ngoc Tu Dinh | Vates XCP-ng Developer
>
> XCP-ng & Xen Orchestra - Vates solutions
>
> web: https://vates.tech
>
>
>

--0000000000004e0ca30636bacae2
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:monospac=
e">Looks good.<br>The AutoReboot option does require the VM admin to set a =
registry key, so its opt in and may not need a cancel option with the &#39;=
system busy&#39; check.<br><br>Reviewed-by: Owen Smith &lt;<a href=3D"mailt=
o:owen.smith@cloud.com">owen.smith@cloud.com</a>&gt;</div><div class=3D"gma=
il_default" style=3D"font-family:monospace"><br></div></div><br><div class=
=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr=
">On Sat, May 31, 2025 at 8:46=E2=80=AFPM Tu Dinh &lt;ngoc-tu.dinh@vates.te=
ch&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Ad=
d a new context flag RebootRequested, to be set in PromptForReboot.<br>
Add a timer that calls TryAutoReboot() every minute if reboot has been<br>
requested beforehand.<br>
<br>
Signed-off-by: Tu Dinh &lt;ngoc-tu.dinh@vates.tech&gt;<br>
---<br>
IMO the autoreboot logic needs some changes. At the moment, autoreboot is<b=
r>
triggered without giving the user a chance to cancel the reboot.<br>
---<br>
=C2=A0src/monitor/monitor.c | 74 +++++++++++++++++++++++++++++++++++-------=
-<br>
=C2=A01 file changed, 60 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c<br>
index 185838f..faf1155 100644<br>
--- a/src/monitor/monitor.c<br>
+++ b/src/monitor/monitor.c<br>
@@ -57,10 +57,13 @@ typedef struct _MONITOR_CONTEXT {<br>
=C2=A0 =C2=A0 =C2=A0HANDLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 EventLog;<br>
=C2=A0 =C2=A0 =C2=A0HANDLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 StopEvent;<br>
=C2=A0 =C2=A0 =C2=A0HANDLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 RequestEvent;<br>
+=C2=A0 =C2=A0 HANDLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 Timer;<br>
=C2=A0 =C2=A0 =C2=A0HKEY=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 RequestKey;<br>
=C2=A0 =C2=A0 =C2=A0PTCHAR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 Title;<br>
=C2=A0 =C2=A0 =C2=A0PTCHAR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 Text;<br>
=C2=A0 =C2=A0 =C2=A0PTCHAR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 Question;<br>
+=C2=A0 =C2=A0 BOOL=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 RebootRequested;<br>
+=C2=A0 =C2=A0 PTCHAR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 RebootRequestedBy;<br>
=C2=A0 =C2=A0 =C2=A0BOOL=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 RebootPending;<br>
=C2=A0} MONITOR_CONTEXT, *PMONITOR_CONTEXT;<br>
<br>
@@ -604,17 +607,24 @@ PromptForReboot(<br>
<br>
=C2=A0 =C2=A0 =C2=A0Log(&quot;=3D=3D=3D=3D&gt; (%s)&quot;, DriverName);<br>
<br>
+=C2=A0 =C2=A0 Context-&gt;RebootRequested =3D TRUE;<br>
+=C2=A0 =C2=A0 if (!Context-&gt;RebootRequestedBy) {<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Context-&gt;RebootRequestedBy =3D _tcsdup(Driv=
erName);<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!Context-&gt;RebootRequestedBy)<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto fail1;<br>
+=C2=A0 =C2=A0 }<br>
+<br>
=C2=A0 =C2=A0 =C2=A0Title =3D Context-&gt;Title;<br>
=C2=A0 =C2=A0 =C2=A0TitleLength =3D (DWORD)((_tcslen(Context-&gt;Title) +<b=
r>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 1) * sizeof (TCHAR));<br>
<br>
=C2=A0 =C2=A0 =C2=A0// AutoReboot is set, DoReboot has been called<br>
-=C2=A0 =C2=A0 if (TryAutoReboot(DriverName))<br>
+=C2=A0 =C2=A0 if (TryAutoReboot(Context-&gt;RebootRequestedBy))<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto done;<br>
<br>
-=C2=A0 =C2=A0 DisplayName =3D GetDisplayName(DriverName);<br>
+=C2=A0 =C2=A0 DisplayName =3D GetDisplayName(Context-&gt;RebootRequestedBy=
);<br>
=C2=A0 =C2=A0 =C2=A0if (DisplayName =3D=3D NULL)<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 goto fail1;<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 goto fail2;<br>
<br>
=C2=A0 =C2=A0 =C2=A0Description =3D _tcsrchr(DisplayName, &#39;;&#39;);<br>
=C2=A0 =C2=A0 =C2=A0if (Description =3D=3D NULL)<br>
@@ -631,7 +641,7 @@ PromptForReboot(<br>
<br>
=C2=A0 =C2=A0 =C2=A0Text =3D calloc(1, TextLength);<br>
=C2=A0 =C2=A0 =C2=A0if (Text =3D=3D NULL)<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 goto fail2;<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 goto fail3;<br>
<br>
=C2=A0 =C2=A0 =C2=A0Result =3D StringCbPrintf(Text,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0TextLength,<br>
@@ -647,7 +657,7 @@ PromptForReboot(<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &amp;SessionInfo,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &amp;Count);<br>
=C2=A0 =C2=A0 =C2=A0if (!Success)<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 goto fail3;<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 goto fail4;<br>
<br>
=C2=A0 =C2=A0 =C2=A0for (Index =3D 0; Index &lt; Count; Index++) {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0DWORD=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0SessionId =3D SessionInfo[Index].SessionI=
d;<br>
@@ -678,7 +688,7 @@ PromptForReboot(<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 TRUE);<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!Success)<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto fail4;<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto fail5;<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Context-&gt;RebootPending =3D TRUE;<br>
<br>
@@ -697,28 +707,31 @@ done:<br>
<br>
=C2=A0 =C2=A0 =C2=A0return;<br>
<br>
-fail4:<br>
-=C2=A0 =C2=A0 Log(&quot;fail4&quot;);<br>
+fail5:<br>
+=C2=A0 =C2=A0 Log(&quot;fail5&quot;);<br>
<br>
=C2=A0 =C2=A0 =C2=A0WTSFreeMemory(SessionInfo);<br>
<br>
+fail4:<br>
+=C2=A0 =C2=A0 Log(&quot;fail4&quot;);<br>
+<br>
=C2=A0fail3:<br>
=C2=A0 =C2=A0 =C2=A0Log(&quot;fail3&quot;);<br>
<br>
-fail2:<br>
-=C2=A0 =C2=A0 Log(&quot;fail2&quot;);<br>
-<br>
=C2=A0 =C2=A0 =C2=A0free(DisplayName);<br>
<br>
-fail1:<br>
+fail2:<br>
=C2=A0 =C2=A0 =C2=A0Error =3D GetLastError();<br>
<br>
=C2=A0 =C2=A0 =C2=A0{<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0PTCHAR=C2=A0 Message;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Message =3D GetErrorMessage(Error);<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 Log(&quot;fail1 (%s)&quot;, Message);<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Log(&quot;fail2 (%s)&quot;, Message);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0LocalFree(Message);<br>
=C2=A0 =C2=A0 =C2=A0}<br>
+<br>
+fail1:<br>
+=C2=A0 =C2=A0 Log(&quot;fail1&quot;);<br>
=C2=A0}<br>
<br>
=C2=A0static VOID<br>
@@ -1243,6 +1256,7 @@ MonitorMain(<br>
=C2=A0 =C2=A0 =C2=A0PTCHAR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
RequestKeyName;<br>
=C2=A0 =C2=A0 =C2=A0BOOL=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 Success;<br>
=C2=A0 =C2=A0 =C2=A0HRESULT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
Error;<br>
+=C2=A0 =C2=A0 LARGE_INTEGER=C2=A0 =C2=A0 =C2=A0 =C2=A0DueTime;<br>
<br>
=C2=A0 =C2=A0 =C2=A0UNREFERENCED_PARAMETER(argc);<br>
=C2=A0 =C2=A0 =C2=A0UNREFERENCED_PARAMETER(argv);<br>
@@ -1314,16 +1328,32 @@ MonitorMain(<br>
=C2=A0 =C2=A0 =C2=A0if (!Success)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto fail9;<br>
<br>
+=C2=A0 =C2=A0 Context-&gt;Timer =3D CreateWaitableTimer(NULL, FALSE, NULL)=
;<br>
+=C2=A0 =C2=A0 if (Context-&gt;Timer =3D=3D NULL)<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 goto fail10;<br>
+<br>
+=C2=A0 =C2=A0 DueTime.QuadPart =3D -600000000; // 1 minute<br>
+<br>
+=C2=A0 =C2=A0 Success =3D SetWaitableTimer(Context-&gt;Timer,<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&amp;DueTime,<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A060000,<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0NULL,<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0NULL,<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0FALSE);<br>
+=C2=A0 =C2=A0 if (!Success)<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 goto fail11;<br>
+<br>
=C2=A0 =C2=A0 =C2=A0SetEvent(Context-&gt;RequestEvent);<br>
<br>
=C2=A0 =C2=A0 =C2=A0ReportStatus(SERVICE_RUNNING, NO_ERROR, 0);<br>
<br>
=C2=A0 =C2=A0 =C2=A0for (;;) {<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 HANDLE=C2=A0 Events[2];<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 HANDLE=C2=A0 Events[3];<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0DWORD=C2=A0 =C2=A0Object;<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Events[0] =3D Context-&gt;StopEvent;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Events[1] =3D Context-&gt;RequestEvent;<b=
r>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Events[2] =3D Context-&gt;Timer;<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Log(&quot;waiting (%u)...&quot;, ARRAYSIZ=
E(Events));<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Object =3D WaitForMultipleObjects(ARRAYSI=
ZE(Events),<br>
@@ -1342,12 +1372,20 @@ MonitorMain(<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0CheckRequestKey();<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;<br>
<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 case WAIT_OBJECT_0 + 2:<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (Context-&gt;RebootRequested)=
<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 TryAutoReboot(Cont=
ext-&gt;RebootRequestedBy);<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;<br>
+<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0default:<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<br>
=C2=A0 =C2=A0 =C2=A0}<br>
<br>
=C2=A0done:<br>
+=C2=A0 =C2=A0 CancelWaitableTimer(Context-&gt;Timer);<br>
+=C2=A0 =C2=A0 CloseHandle(Context-&gt;Timer);<br>
+<br>
=C2=A0 =C2=A0 =C2=A0(VOID) RegDeleteTree(Context-&gt;RequestKey, NULL);<br>
<br>
=C2=A0 =C2=A0 =C2=A0free(Context-&gt;Question);<br>
@@ -1369,6 +1407,14 @@ done:<br>
<br>
=C2=A0 =C2=A0 =C2=A0return;<br>
<br>
+fail11:<br>
+=C2=A0 =C2=A0 Log(&quot;fail11&quot;);<br>
+<br>
+=C2=A0 =C2=A0 CloseHandle(Context-&gt;Timer);<br>
+<br>
+fail10:<br>
+=C2=A0 =C2=A0 Log(&quot;fail10&quot;);<br>
+<br>
=C2=A0fail9:<br>
=C2=A0 =C2=A0 =C2=A0Log(&quot;fail9&quot;);<br>
<br>
-- <br>
2.49.0.windows.1<br>
<br>
<br>
<br>
Ngoc Tu Dinh | Vates XCP-ng Developer<br>
<br>
XCP-ng &amp; Xen Orchestra - Vates solutions<br>
<br>
web: <a href=3D"https://vates.tech" rel=3D"noreferrer" target=3D"_blank">ht=
tps://vates.tech</a><br>
<br>
<br>
</blockquote></div>

--0000000000004e0ca30636bacae2--


From win-pv-devel-bounces@lists.xenproject.org Wed Jun 04 08:29:17 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 04 Jun 2025 08:29:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1005224.1384738 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uMjUr-0002zH-Tj; Wed, 04 Jun 2025 08:29:17 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1005224.1384738; Wed, 04 Jun 2025 08:29:17 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uMjUr-0002z9-RD; Wed, 04 Jun 2025 08:29:17 +0000
Received: by outflank-mailman (input) for mailman id 1005224;
 Wed, 04 Jun 2025 08:29:16 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=c4px=YT=cloud.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1uMjUq-0002wq-Dn
 for win-pv-devel@lists.xenproject.org; Wed, 04 Jun 2025 08:29:16 +0000
Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com
 [2a00:1450:4864:20::131])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 006870d2-411e-11f0-a300-13f23c93f187;
 Wed, 04 Jun 2025 10:29:16 +0200 (CEST)
Received: by mail-lf1-x131.google.com with SMTP id
 2adb3069b0e04-54b10594812so7835930e87.1
 for <win-pv-devel@lists.xenproject.org>; Wed, 04 Jun 2025 01:29:16 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 006870d2-411e-11f0-a300-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=cloud.com; s=cloud; t=1749025755; x=1749630555; darn=lists.xenproject.org;
        h=cc:to:subject:message-id:date:from:in-reply-to:references
         :mime-version:from:to:cc:subject:date:message-id:reply-to;
        bh=Y5oefyfRwIVqW4OIxCSUCxxx1HxKDxBYRjICC4Az6WY=;
        b=e7wFyQtmydF7yMIiBgr8ztGnV4OPxD6Y70vW9GRRNItP38rDawLlVLqiqjDCojYDtL
         LOMmOXUU7T/gQmSUGMJ0v+TOlJUW9GWLM0hQDEasdrtsgANeZqaLATnL1TfcMzIFqn0R
         rZw0En+aQWpZkpNCs/biNCe6OwDMncBLAHRQU=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1749025755; x=1749630555;
        h=cc:to:subject:message-id:date:from:in-reply-to:references
         :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=Y5oefyfRwIVqW4OIxCSUCxxx1HxKDxBYRjICC4Az6WY=;
        b=sodevx+1ajpZ8BnFgOKEydeifFFL4GMDkc0gBnHgnCCnZzKEynXP/c1pMOHEdZsBo7
         ZLRAgvx3J61i15ZeBQx/ZAhn8CL3/7NE1VnBdR/y+AsTbFoAVRnLXs0A5xIE/dQSSEGw
         h3ovyvR+CqaJ31uGir0jltMwIInx0PM5gqDa6+DKyYBZ8LUouGwlDxsTy8qPZILaiU0l
         XaQ673F4vnAF0191Z1vlbSemBEyl0Jhzx1ImXOusgYbWpXOxA3HtNHb9liu3wtA12pNV
         STwbTc6NNF0So9y0SxwMJTc5FfTfsXAy4BqLGnnik8SdIWb3ibjws1v8fz+olCsthH+e
         dy6g==
X-Gm-Message-State: AOJu0YwqMRfBYgq26DqzdjGEfd2RnM74RbBJgozrexIYEQIN8g0GKSwC
	+JB2MRqNi1Ji9YlXohWbl0Zo8zeFynvHhQ0tPAb0OHzgDnhCAY5TZjz8IBfFwdjUVAcSp7tLOuD
	AyDMOaF6r4qojnfMJuqwbcz/D00xGyKYH/YbPc7Mv
X-Gm-Gg: ASbGncuRguwBckYoPiD8yYPKTNjKk5wFglNKlBpzq/ZiDg52VDML7me5D/ZmkhLQf+p
	12KI2Knx3sho5ccugl9AilJgXShIFUZq6U1xawgsfyHMMK4T2h1Pt8wGO9F62TT2zOYI2shvuOr
	t+8SmLyb7BGBKEDaGHJuGc9OJFd7nOEMP0DamhrL3IkBU=
X-Google-Smtp-Source: AGHT+IFDAHpxahGW+KVD6Bd80vgNOOg5kq0DPlWiFS61LT8ETtVxLQO5Xix9VoFW6Ws6psCsfcsF9oyOfeFy3wNcfDg=
X-Received: by 2002:a05:6512:b11:b0:553:3665:d18a with SMTP id
 2adb3069b0e04-55356aeb830mr512094e87.18.1749025755454; Wed, 04 Jun 2025
 01:29:15 -0700 (PDT)
MIME-Version: 1.0
References: <20250531194524.1865-1-ngoc-tu.dinh@vates.tech> <20250531194524.1865-3-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250531194524.1865-3-ngoc-tu.dinh@vates.tech>
From: Owen Smith <owen.smith@cloud.com>
Date: Wed, 4 Jun 2025 09:29:03 +0100
X-Gm-Features: AX0GCFv0bBCH9b81g6XNrQ692jzT1y4pB-rbSLSxp2fiM588TiV3sD8VKxvrloc
Message-ID: <CAC_UY898JBTM9i5coVXvY0C8zqr=Dh294VGmi7UTtvPd+HfuiQ@mail.gmail.com>
Subject: Re: [XENBUS PATCH 2/2] Don't autoreboot during ES_SYSTEM_REQUIRED
To: Tu Dinh <ngoc-tu.dinh@vates.tech>
Cc: win-pv-devel@lists.xenproject.org, Paul Durrant <paul@xen.org>
Content-Type: multipart/alternative; boundary="000000000000db77380636baca20"

--000000000000db77380636baca20
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Reviewed-by: Owen Smith <owen.smith@cloud.com>

On Sat, May 31, 2025 at 8:45=E2=80=AFPM Tu Dinh <ngoc-tu.dinh@vates.tech> w=
rote:

> Programs may set the ES_SYSTEM_REQUIRED execution state when they're
> busy with some activity (media playback, downloads, updates etc.)
>
> We don't want to autoreboot in these situations.
>
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
>  src/monitor/monitor.c                        | 12 ++++++++++++
>  vs2019/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
>  vs2022/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
>  3 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index faf1155..c9cbcc8 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -36,6 +36,8 @@
>  #include <strsafe.h>
>  #include <wtsapi32.h>
>  #include <cfgmgr32.h>
> +#include <winternl.h>
> +#include <powrprof.h>
>  #include <malloc.h>
>  #include <assert.h>
>
> @@ -473,6 +475,16 @@ TryAutoReboot(
>      PTCHAR              Text;
>      DWORD               TextLength;
>      HRESULT             Error;
> +    NTSTATUS            Status;
> +    ULONG               PowerInfo;
> +
> +    Status =3D CallNtPowerInformation(SystemExecutionState,
> +                                    NULL,
> +                                    0,
> +                                    &PowerInfo,
> +                                    sizeof(PowerInfo));
> +    if (Status < 0 || (PowerInfo & ES_SYSTEM_REQUIRED))
> +        goto done;
>
>      Length =3D sizeof (DWORD);
>
> diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> index 2a2c00f..047166e 100644
> --- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> +++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> @@ -34,7 +34,7 @@
>        <RuntimeLibrary
> Condition=3D"'$(UseDebugLibraries)'=3D=3D'false'">MultiThreaded</RuntimeL=
ibrary>
>      </ClCompile>
>      <Link>
> -
> <AdditionalDependencies>wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencie=
s)</AdditionalDependencies>
> +
> <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(Addition=
alDependencies)</AdditionalDependencies>
>        <CETCompat>true</CETCompat>
>        <GenerateMapFile>true</GenerateMapFile>
>        <MapExports>true</MapExports>
> diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> index 4d26331..0437024 100644
> --- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> +++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> @@ -34,7 +34,7 @@
>        <RuntimeLibrary
> Condition=3D"'$(UseDebugLibraries)'=3D=3D'false'">MultiThreaded</RuntimeL=
ibrary>
>      </ClCompile>
>      <Link>
> -
> <AdditionalDependencies>wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencie=
s)</AdditionalDependencies>
> +
> <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(Addition=
alDependencies)</AdditionalDependencies>
>        <CETCompat>true</CETCompat>
>        <GenerateMapFile>true</GenerateMapFile>
>        <MapExports>true</MapExports>
> --
> 2.49.0.windows.1
>
>
>
> Ngoc Tu Dinh | Vates XCP-ng Developer
>
> XCP-ng & Xen Orchestra - Vates solutions
>
> web: https://vates.tech
>
>

--000000000000db77380636baca20
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:monospac=
e">Reviewed-by: Owen Smith &lt;<a href=3D"mailto:owen.smith@cloud.com">owen=
.smith@cloud.com</a>&gt;</div></div><br><div class=3D"gmail_quote gmail_quo=
te_container"><div dir=3D"ltr" class=3D"gmail_attr">On Sat, May 31, 2025 at=
 8:45=E2=80=AFPM Tu Dinh &lt;ngoc-tu.dinh@vates.tech&gt; wrote:<br></div><b=
lockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-le=
ft:1px solid rgb(204,204,204);padding-left:1ex">Programs may set the ES_SYS=
TEM_REQUIRED execution state when they&#39;re<br>
busy with some activity (media playback, downloads, updates etc.)<br>
<br>
We don&#39;t want to autoreboot in these situations.<br>
<br>
Signed-off-by: Tu Dinh &lt;ngoc-tu.dinh@vates.tech&gt;<br>
---<br>
=C2=A0src/monitor/monitor.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 12 ++++++++++++<br>
=C2=A0vs2019/xenbus_monitor/xenbus_monitor.vcxproj |=C2=A0 2 +-<br>
=C2=A0vs2022/xenbus_monitor/xenbus_monitor.vcxproj |=C2=A0 2 +-<br>
=C2=A03 files changed, 14 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c<br>
index faf1155..c9cbcc8 100644<br>
--- a/src/monitor/monitor.c<br>
+++ b/src/monitor/monitor.c<br>
@@ -36,6 +36,8 @@<br>
=C2=A0#include &lt;strsafe.h&gt;<br>
=C2=A0#include &lt;wtsapi32.h&gt;<br>
=C2=A0#include &lt;cfgmgr32.h&gt;<br>
+#include &lt;winternl.h&gt;<br>
+#include &lt;powrprof.h&gt;<br>
=C2=A0#include &lt;malloc.h&gt;<br>
=C2=A0#include &lt;assert.h&gt;<br>
<br>
@@ -473,6 +475,16 @@ TryAutoReboot(<br>
=C2=A0 =C2=A0 =C2=A0PTCHAR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
Text;<br>
=C2=A0 =C2=A0 =C2=A0DWORD=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0TextLength;<br>
=C2=A0 =C2=A0 =C2=A0HRESULT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
Error;<br>
+=C2=A0 =C2=A0 NTSTATUS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Status;<br=
>
+=C2=A0 =C2=A0 ULONG=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
PowerInfo;<br>
+<br>
+=C2=A0 =C2=A0 Status =3D CallNtPowerInformation(SystemExecutionState,<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 NULL,<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0,<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &amp;PowerInfo,<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sizeof(PowerInfo));<br=
>
+=C2=A0 =C2=A0 if (Status &lt; 0 || (PowerInfo &amp; ES_SYSTEM_REQUIRED))<b=
r>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 goto done;<br>
<br>
=C2=A0 =C2=A0 =C2=A0Length =3D sizeof (DWORD);<br>
<br>
diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj b/vs2019/xenbus_m=
onitor/xenbus_monitor.vcxproj<br>
index 2a2c00f..047166e 100644<br>
--- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj<br>
+++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj<br>
@@ -34,7 +34,7 @@<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0&lt;RuntimeLibrary Condition=3D&quot;&#39;$(UseD=
ebugLibraries)&#39;=3D=3D&#39;false&#39;&quot;&gt;MultiThreaded&lt;/Runtime=
Library&gt;<br>
=C2=A0 =C2=A0 =C2=A0&lt;/ClCompile&gt;<br>
=C2=A0 =C2=A0 =C2=A0&lt;Link&gt;<br>
-=C2=A0 =C2=A0 =C2=A0 &lt;AdditionalDependencies&gt;wtsapi32.lib;cfgmgr32.l=
ib;%(AdditionalDependencies)&lt;/AdditionalDependencies&gt;<br>
+=C2=A0 =C2=A0 =C2=A0 &lt;AdditionalDependencies&gt;powrprof.lib;wtsapi32.l=
ib;cfgmgr32.lib;%(AdditionalDependencies)&lt;/AdditionalDependencies&gt;<br=
>
=C2=A0 =C2=A0 =C2=A0 =C2=A0&lt;CETCompat&gt;true&lt;/CETCompat&gt;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0&lt;GenerateMapFile&gt;true&lt;/GenerateMapFile&=
gt;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0&lt;MapExports&gt;true&lt;/MapExports&gt;<br>
diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj b/vs2022/xenbus_m=
onitor/xenbus_monitor.vcxproj<br>
index 4d26331..0437024 100644<br>
--- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj<br>
+++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj<br>
@@ -34,7 +34,7 @@<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0&lt;RuntimeLibrary Condition=3D&quot;&#39;$(UseD=
ebugLibraries)&#39;=3D=3D&#39;false&#39;&quot;&gt;MultiThreaded&lt;/Runtime=
Library&gt;<br>
=C2=A0 =C2=A0 =C2=A0&lt;/ClCompile&gt;<br>
=C2=A0 =C2=A0 =C2=A0&lt;Link&gt;<br>
-=C2=A0 =C2=A0 =C2=A0 &lt;AdditionalDependencies&gt;wtsapi32.lib;cfgmgr32.l=
ib;%(AdditionalDependencies)&lt;/AdditionalDependencies&gt;<br>
+=C2=A0 =C2=A0 =C2=A0 &lt;AdditionalDependencies&gt;powrprof.lib;wtsapi32.l=
ib;cfgmgr32.lib;%(AdditionalDependencies)&lt;/AdditionalDependencies&gt;<br=
>
=C2=A0 =C2=A0 =C2=A0 =C2=A0&lt;CETCompat&gt;true&lt;/CETCompat&gt;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0&lt;GenerateMapFile&gt;true&lt;/GenerateMapFile&=
gt;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0&lt;MapExports&gt;true&lt;/MapExports&gt;<br>
-- <br>
2.49.0.windows.1<br>
<br>
<br>
<br>
Ngoc Tu Dinh | Vates XCP-ng Developer<br>
<br>
XCP-ng &amp; Xen Orchestra - Vates solutions<br>
<br>
web: <a href=3D"https://vates.tech" rel=3D"noreferrer" target=3D"_blank">ht=
tps://vates.tech</a><br>
<br>
</blockquote></div>

--000000000000db77380636baca20--


From win-pv-devel-bounces@lists.xenproject.org Wed Jun 04 08:43:15 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 04 Jun 2025 08:43:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1005252.1384743 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uMjiL-0005Yj-UM; Wed, 04 Jun 2025 08:43:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1005252.1384743; Wed, 04 Jun 2025 08:43:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uMjiL-0005Yb-RG; Wed, 04 Jun 2025 08:43:13 +0000
Received: by outflank-mailman (input) for mailman id 1005252;
 Wed, 04 Jun 2025 08:43:12 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=T/jd=YT=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uMjiK-0005YV-FY
 for win-pv-devel@lists.xenproject.org; Wed, 04 Jun 2025 08:43:12 +0000
Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com
 [2a00:1450:4864:20::333])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id f19ddd69-411f-11f0-b894-0df219b8e170;
 Wed, 04 Jun 2025 10:43:10 +0200 (CEST)
Received: by mail-wm1-x333.google.com with SMTP id
 5b1f17b1804b1-450ce3a2dd5so57712205e9.3
 for <win-pv-devel@lists.xenproject.org>; Wed, 04 Jun 2025 01:43:10 -0700 (PDT)
Received: from [192.168.7.126] (54-240-197-239.amazon.com. [54.240.197.239])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3a4f00a00f5sm21133217f8f.95.2025.06.04.01.43.08
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 04 Jun 2025 01:43:08 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: f19ddd69-411f-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1749026590; x=1749631390; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=h4zwPjDzRg7dfbzu2RufNsf2GLPlXNr0LtdltfRrcX8=;
        b=Y3ohR6LE92yHa4ttvg2WqIzR4XTMkHetquvbL/sqXdrClnhTeQcm26rMuJKTEzwXA5
         skcg+cu8kwDvei+5g7GCImgKcEIKxUkdJ4H1fVCZi8Ewrh2rSk1dki9GLXywlgZR7SmK
         SZj+jmNfsQ/2XQRga9V1pwSMyvooP7OB3jF9AaZvYGGMANyLG6sCsnPlyahS/BIOKwaJ
         dVed6rC3wt56gDP/pivq0tLQX2gHhGeYp1tmt0XGYnv/BLKO4BGpYUOMOptDSTs/3wiO
         73TgLbMgXpQ7ub7MlXguncP7A+losFnn/fhIOjOZ/9i5/p4rmxSc43audOtPN8jrxjmt
         ORyQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1749026590; x=1749631390;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=h4zwPjDzRg7dfbzu2RufNsf2GLPlXNr0LtdltfRrcX8=;
        b=aQiI7MgGB5vqKYXoamdYVV5SvQWUmzeJMPviWRMQM/gjdSp/1GtQNtQEauy2TPSV3S
         vJxBULRka+y4tY7aQopB6YWg/9vvsYTklInMEqRDnoWsscCfLTMpXKTan+Mn2jajazpT
         7Ef9gG18KAAC/33/ZhelzocPKrkSvvhPlC9y/Jp6BSIpg3hbQ4O8n+MF8Rp0l3P1/+jr
         zW9o3wCqJLZTvbsiRZ8UPxFYGOZQio5Cr8nw1lcjG6F3zVS56+A1PLbF8tZl0KaTlI1j
         QP8bn2UBt6XrRiWz0iTXUn5onxdtKK2et+Q3OLfR843orr6eTekhmKcfgsqLHcPk9ELD
         f6cw==
X-Forwarded-Encrypted: i=1; AJvYcCXrpF1Xac9DqL0zeWUSp9qBAXS125SNQ9WjPlfJwh+gJbtfw6O7BN4j0phHw4sKIZObIJElnNVCm5rFcKQ=@lists.xenproject.org
X-Gm-Message-State: AOJu0YxNA96adHlW+eH4L60xO3LNBWrutuDCFJUeGe2c3pgzblDJpSSr
	9MYtdTGL+tPtGPGYDOrENEDGI922hiLWVGBYTGnQxzzQwIJyV+mg0CYz
X-Gm-Gg: ASbGncs8+g2AaN/y4RyVekLXuyHqwDfXsr9D8MZRfPkfbuic4p4YzZH/QsLYEL+CQ0A
	vLCGNEhifd2HoiQ6V8nImJen5JGn4LDT5SGvYqc7sHX+8bWFg5MSXH72waUQjhW8OPkIRQs5dZI
	axfaf7L9X57leoEJBwcOinDUIDV5XWtcmU2xvb319Hq1hJoc7UDdZBeV/HfT1EQR6j4DBC+nnIU
	vNU/6m0XW8wuurmip3jEL58iEAEu4AnftHc89LQpV8klZyU1WSGStPyq2mgVWLHx+qYpkKxZbzp
	BStPT9sKGe9dIzpRJ4NVoZiAX6fTgJ6TNvQi+gOS3OfKZqBkaqpMTUOjm9Yq3R6+mMm7x8Pwon6
	6628HlEJZqCUwdGa1Wg==
X-Google-Smtp-Source: AGHT+IG3yfh04m78RhnL0OIceiROAYPzyz5cRCWErrewFDX+9SUo8qG6ErYFfJ3OUlIf2fEsZro8RA==
X-Received: by 2002:a05:600c:a49:b0:450:d61f:dd45 with SMTP id 5b1f17b1804b1-451f0a72e20mr16224445e9.4.1749026589290;
        Wed, 04 Jun 2025 01:43:09 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <be0dbf58-b9eb-4c82-b539-8a2a6db0625b@xen.org>
Date: Wed, 4 Jun 2025 09:43:07 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [XENBUS PATCH 1/2] Add autoreboot retry logic
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
References: <20250531194524.1865-1-ngoc-tu.dinh@vates.tech>
 <20250531194524.1865-2-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <20250531194524.1865-2-ngoc-tu.dinh@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 31/05/2025 20:45, Tu Dinh wrote:
> Add a new context flag RebootRequested, to be set in PromptForReboot.
> Add a timer that calls TryAutoReboot() every minute if reboot has been
> requested beforehand.
> 
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
> IMO the autoreboot logic needs some changes. At the moment, autoreboot is
> triggered without giving the user a chance to cancel the reboot.
> ---
>   src/monitor/monitor.c | 74 +++++++++++++++++++++++++++++++++++--------
>   1 file changed, 60 insertions(+), 14 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 185838f..faf1155 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -57,10 +57,13 @@ typedef struct _MONITOR_CONTEXT {
>       HANDLE                  EventLog;
>       HANDLE                  StopEvent;
>       HANDLE                  RequestEvent;
> +    HANDLE                  Timer;
>       HKEY                    RequestKey;
>       PTCHAR                  Title;
>       PTCHAR                  Text;
>       PTCHAR                  Question;
> +    BOOL                    RebootRequested;

This could be dropped. RebootRequestedBy != NULL could be tested instead.

> +    PTCHAR                  RebootRequestedBy;
>       BOOL                    RebootPending;
>   } MONITOR_CONTEXT, *PMONITOR_CONTEXT;
>   
> @@ -604,17 +607,24 @@ PromptForReboot(
>   
>       Log("====> (%s)", DriverName);
>   
> +    Context->RebootRequested = TRUE;
> +    if (!Context->RebootRequestedBy) {
> +        Context->RebootRequestedBy = _tcsdup(DriverName);

I'm not seeing where this is freed.

> +        if (!Context->RebootRequestedBy)
> +            goto fail1;
> +    }
> +
>       Title = Context->Title;
>       TitleLength = (DWORD)((_tcslen(Context->Title) +
>                              1) * sizeof (TCHAR));
>   
>       // AutoReboot is set, DoReboot has been called
> -    if (TryAutoReboot(DriverName))
> +    if (TryAutoReboot(Context->RebootRequestedBy))
>           goto done;
>   
> -    DisplayName = GetDisplayName(DriverName);
> +    DisplayName = GetDisplayName(Context->RebootRequestedBy);
>       if (DisplayName == NULL)
> -        goto fail1;
> +        goto fail2;
>   
>       Description = _tcsrchr(DisplayName, ';');
>       if (Description == NULL)
> @@ -631,7 +641,7 @@ PromptForReboot(
>   
>       Text = calloc(1, TextLength);
>       if (Text == NULL)
> -        goto fail2;
> +        goto fail3;
>   
>       Result = StringCbPrintf(Text,
>                               TextLength,
> @@ -647,7 +657,7 @@ PromptForReboot(
>                                      &SessionInfo,
>                                      &Count);
>       if (!Success)
> -        goto fail3;
> +        goto fail4;
>   
>       for (Index = 0; Index < Count; Index++) {
>           DWORD                   SessionId = SessionInfo[Index].SessionId;
> @@ -678,7 +688,7 @@ PromptForReboot(
>                                    TRUE);
>   
>           if (!Success)
> -            goto fail4;
> +            goto fail5;
>   
>           Context->RebootPending = TRUE;
>   
> @@ -697,28 +707,31 @@ done:
>   
>       return;
>   
> -fail4:
> -    Log("fail4");
> +fail5:
> +    Log("fail5");
>   
>       WTSFreeMemory(SessionInfo);
>   
> +fail4:
> +    Log("fail4");
> +
>   fail3:
>       Log("fail3");
>   
> -fail2:
> -    Log("fail2");
> -
>       free(DisplayName);
>   
> -fail1:
> +fail2:
>       Error = GetLastError();
>   
>       {
>           PTCHAR  Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        Log("fail2 (%s)", Message);
>           LocalFree(Message);
>       }
> +
> +fail1:
> +    Log("fail1");
>   }
>   
>   static VOID
> @@ -1243,6 +1256,7 @@ MonitorMain(
>       PTCHAR              RequestKeyName;
>       BOOL                Success;
>       HRESULT             Error;
> +    LARGE_INTEGER       DueTime;
>   
>       UNREFERENCED_PARAMETER(argc);
>       UNREFERENCED_PARAMETER(argv);
> @@ -1314,16 +1328,32 @@ MonitorMain(
>       if (!Success)
>           goto fail9;
>   
> +    Context->Timer = CreateWaitableTimer(NULL, FALSE, NULL);
> +    if (Context->Timer == NULL)
> +        goto fail10;
> +
> +    DueTime.QuadPart = -600000000; // 1 minute
> +
> +    Success = SetWaitableTimer(Context->Timer,
> +                               &DueTime,
> +                               60000,
> +                               NULL,
> +                               NULL,
> +                               FALSE);
> +    if (!Success)
> +        goto fail11;
> +
>       SetEvent(Context->RequestEvent);
>   
>       ReportStatus(SERVICE_RUNNING, NO_ERROR, 0);
>   
>       for (;;) {
> -        HANDLE  Events[2];
> +        HANDLE  Events[3];
>           DWORD   Object;
>   
>           Events[0] = Context->StopEvent;
>           Events[1] = Context->RequestEvent;
> +        Events[2] = Context->Timer;
>   
>           Log("waiting (%u)...", ARRAYSIZE(Events));
>           Object = WaitForMultipleObjects(ARRAYSIZE(Events),
> @@ -1342,12 +1372,20 @@ MonitorMain(
>               CheckRequestKey();
>               break;
>   
> +        case WAIT_OBJECT_0 + 2:
> +            if (Context->RebootRequested)
> +                TryAutoReboot(Context->RebootRequestedBy);
> +            break;
> +
>           default:
>               break;
>           }
>       }
>   
>   done:
> +    CancelWaitableTimer(Context->Timer);
> +    CloseHandle(Context->Timer);
> +
>       (VOID) RegDeleteTree(Context->RequestKey, NULL);
>   
>       free(Context->Question);
> @@ -1369,6 +1407,14 @@ done:
>   
>       return;
>   
> +fail11:
> +    Log("fail11");
> +
> +    CloseHandle(Context->Timer);
> +
> +fail10:
> +    Log("fail10");
> +
>   fail9:
>       Log("fail9");
>   



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 04 08:44:46 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 04 Jun 2025 08:44:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1005262.1384747 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uMjjq-0005fD-2Q; Wed, 04 Jun 2025 08:44:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1005262.1384747; Wed, 04 Jun 2025 08:44:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uMjjp-0005f6-W3; Wed, 04 Jun 2025 08:44:45 +0000
Received: by outflank-mailman (input) for mailman id 1005262;
 Wed, 04 Jun 2025 08:44:44 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=T/jd=YT=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uMjjo-0005bh-JC
 for win-pv-devel@lists.xenproject.org; Wed, 04 Jun 2025 08:44:44 +0000
Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com
 [2a00:1450:4864:20::62e])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 2979f887-4120-11f0-a300-13f23c93f187;
 Wed, 04 Jun 2025 10:44:44 +0200 (CEST)
Received: by mail-ej1-x62e.google.com with SMTP id
 a640c23a62f3a-addda47ebeaso545668566b.1
 for <win-pv-devel@lists.xenproject.org>; Wed, 04 Jun 2025 01:44:44 -0700 (PDT)
Received: from [192.168.7.126] (54-240-197-239.amazon.com. [54.240.197.239])
 by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-adb32e347fasm887972066b.168.2025.06.04.01.44.42
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 04 Jun 2025 01:44:42 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 2979f887-4120-11f0-a300-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1749026683; x=1749631483; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=/uoMbGUbpTJxaD42FlzT3Gh03FCIj6EUa96nIRzV05I=;
        b=I/wzC2M9wYl3a9GO+lxi1kN/IVp3sLBkVaiN6cLvhAePuj2SE+HTtX0Limt2tSHgip
         tmxXGaNlu0WUIqRsvqNJA3uj8yNjvO3DrKc4qWAMwzfe4XGbZFSUEZJPtNDPy+tQrm56
         zfd+dLhTM3gNyO0FBkywC/Eb604d74A4sLXCQPFWlbZz5d9uMP4zmUqp3B0458xb1MdP
         oACirQydnCmAvDZa3uFzJhioVDnY7dgBxzX1PA3EHlhM7/+/Xe/cAsTY+7w6VNifew9d
         6xVtwd8TIaIQ1N4nXqKCRFyd/iQSNUaQGtZAYtE2Ziwb24ncRi7mf223sfR3i+6Bg9pL
         mGqw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1749026683; x=1749631483;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=/uoMbGUbpTJxaD42FlzT3Gh03FCIj6EUa96nIRzV05I=;
        b=jpVjRJi1IviOBLSTFf+ZQAIiUTgg8XLrWocTTozdJx1v6rfqSgZ2IPazopuCkslAkG
         HFVK2f7AGO8ewc0hesthFaVP05sT9dvIZ24W2/ZdHVb69Kp27RHM8tG5E9BkKTDqJnUe
         cvDjYtb91tXGOWGHWFkUqvRZWmMJ4lKuyiyVJ3pbRDHtC8E1TsIuyoxBcrB1gWgTW/3Q
         KzEDGT+rCGlpLCKpknIVp0d9nR3k/aBPE57S47jgSpJAwhl8tSqmbpbFjKVs9Z23l8mk
         /AxNFboy1UYcgGL2G7a4gwbDEBo9GYZqtXNCLaBUwoI791PY5bjBue6w6eDBTtwjfnMW
         6Iwg==
X-Forwarded-Encrypted: i=1; AJvYcCWQF1d7N0ajZOB/v77jCC+QvFZwV0rjRR/nGx2V3RlpNJB94YzXJQiVHY8EsRpn3H2rrmfDq3BwTicvmeM=@lists.xenproject.org
X-Gm-Message-State: AOJu0YzhXBM4VbKLS8AOvCXQP9BQX/3R0VbsWKJwoZBAYoK9YayjM3zT
	KM5o4O9f++RdtGltGwTXjZlFhJuC+aFzDfAP3cIkFb5NOL/bCu24dQSq
X-Gm-Gg: ASbGncucOP3Fbvbc4Xeqgu2/GPokHg1fzTmSWXAsJ0NRLYx0nchRYFzUHCjgYA1Bk77
	6J5Uub1xLakyNcSvw3/I15bPDcIGqKjimOoVm12pZ16caD1cwb1BcTHdoOnXVAfsZ5s+xe463IO
	IcMHfL+VP62B+1+UWtwl9oZHOk5vgiYldABS/WCnX0NyS/8Hq8x6VkhWk6+6S2yW4Uke0kDC1TI
	LCfdL7NkYBFma3+aX+DDI+Ls4z+/Y2Y7XeUO+/oE+Tq4fvHmz7tVT3H4R8FCcT40GmW6t+PPz/W
	SPjv7rPr3zAn3hJWLFsujeNWqt2SuUEZE+kjZpHgd1GRTvfWYcU/lbKYWvEfn8EDGU36U8oMTjR
	r6i7IQuKjcN/vzz1amA==
X-Google-Smtp-Source: AGHT+IGf4JwGwWB2R1JhH4LB7+UojU3sxZF6wHGvHsmVhzRLXmxr4nu8P6MwYInlI17Y2VZpiPgKgA==
X-Received: by 2002:a17:906:6a16:b0:ad8:9e80:6bb8 with SMTP id a640c23a62f3a-addf8cc9d56mr171947366b.6.1749026683109;
        Wed, 04 Jun 2025 01:44:43 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <33624e50-b66e-4365-91d5-5ae74402da9e@xen.org>
Date: Wed, 4 Jun 2025 09:44:42 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [XENBUS PATCH 2/2] Don't autoreboot during ES_SYSTEM_REQUIRED
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
References: <20250531194524.1865-1-ngoc-tu.dinh@vates.tech>
 <20250531194524.1865-3-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <20250531194524.1865-3-ngoc-tu.dinh@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 31/05/2025 20:45, Tu Dinh wrote:
> Programs may set the ES_SYSTEM_REQUIRED execution state when they're
> busy with some activity (media playback, downloads, updates etc.)
> 
> We don't want to autoreboot in these situations.
> 
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
>   src/monitor/monitor.c                        | 12 ++++++++++++
>   vs2019/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
>   vs2022/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
>   3 files changed, 14 insertions(+), 2 deletions(-)
> 

Reviewed-by: Paul Durrant <paul@xen.org>


From win-pv-devel-bounces@lists.xenproject.org Mon Jun 09 14:00:09 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 09 Jun 2025 14:00:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1010270.1388429 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd2l-00049Y-Kb; Mon, 09 Jun 2025 14:00:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1010270.1388429; Mon, 09 Jun 2025 14:00:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd2l-00049Q-HS; Mon, 09 Jun 2025 14:00:07 +0000
Received: by outflank-mailman (input) for mailman id 1010270;
 Mon, 09 Jun 2025 14:00:06 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=xbe5=YY=bounce.vates.tech=bounce-md_30504962.6846e8e2.v1-38a066e25bee492a8cc3203ee772f064@srs-se1.protection.inumbo.net>)
 id 1uOd2k-0003zs-Js
 for win-pv-devel@lists.xenproject.org; Mon, 09 Jun 2025 14:00:06 +0000
Received: from mail36.us4.mandrillapp.com (mail36.us4.mandrillapp.com
 [205.201.136.36]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 0a3398e4-453a-11f0-a305-13f23c93f187;
 Mon, 09 Jun 2025 16:00:04 +0200 (CEST)
Received: from pmta15.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail36.us4.mandrillapp.com (Mailchimp) with ESMTP id 4bGD82206TzS62LNh
 for <win-pv-devel@lists.xenproject.org>; Mon,  9 Jun 2025 14:00:02 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 38a066e25bee492a8cc3203ee772f064; Mon, 09 Jun 2025 14:00:02 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 0a3398e4-453a-11f0-a305-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749477602; x=1749747602;
	bh=aXlk/KNhosituFOjtsGcFZTp0YzgZq+DRDh0dRIu5QY=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=OUX2QBEs8WiHL55k2ixLH5pMIz6A+jnrVtc1K5c0Of4xKHvRrO9zF3rllcd7M8YhE
	 xOrH5aG3jViNYFnUN7SJjsO0kHDtDxpelcxeFEmPPPeeh9RYk8aKoMQn7GSPxqD/T0
	 XDUFxs3fiNDPrHNqG4p0Ho1XrLurEEjGjoBa9VRMfOzcv/5voMHuuyTMF0jsAf9Nup
	 8AmqruywcxjfPhWeKiD6W+7727syGzB4RJ8F0xAhstDqQYAREq2zYlziM17kwDVCJ8
	 QJmnOoAp9w1ucUUM4rKIsg+fpIcGRpDXSPQpqa0zRnHGC1tfvyD/QCreN6iYfnhrA5
	 8JIOVX7VU+UBQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749477602; x=1749738102; i=ngoc-tu.dinh@vates.tech;
	bh=aXlk/KNhosituFOjtsGcFZTp0YzgZq+DRDh0dRIu5QY=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=LvJY9QspBrUSBpU/A80QJgFT1pwneb/ZyNxIvOJtLT/HxBL/Sg5d9x70dMH3XcUa/
	 +eLgcIUgfgEhIJMY+p2DaxWPtuMv36w2VsAfQ32Hwow9ixecFKKqOdgNfiQ+UbMgCQ
	 TgqZvenQeFa7bqXDfkmQTLfVXrbsrVSCtoWYnq9r1EY0A7Lu3zg/IyXkdNFssEgGIj
	 cvGrFZrtOT2lj7lJRWxgwsVE29D9CCdMHB9aRHI8R6SG85eD3DtVPlHkl1LoBsKrn/
	 Q9qAZbkaxXF2Yb7bz0cbEW63rNWYpyRlfaq7lSVmsQXV/TBfpGnueZYL1ac3qai0l/
	 WwxlgCzEdQmZA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v2=201/5]=20Cleanup=20duplicate=20error=20variables=20in=20TryAutoReboot?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749477601576
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250609135941.309-2-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
References: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.38a066e25bee492a8cc3203ee772f064?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250609:md
Date: Mon, 09 Jun 2025 14:00:02 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

These variables should also be DWORD instead of HRESULT.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/monitor.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 185838f..3a166db 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -459,7 +459,6 @@ TryAutoReboot(
     )
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
-    HRESULT             Result;
     DWORD               Type;
     DWORD               AutoReboot;
     DWORD               RebootCount;
@@ -469,7 +468,7 @@ TryAutoReboot(
     PTCHAR              Description;
     PTCHAR              Text;
     DWORD               TextLength;
-    HRESULT             Error;
+    DWORD               Error;
 
     Length = sizeof (DWORD);
 
@@ -547,12 +546,12 @@ TryAutoReboot(
     if (Text == NULL)
         goto fail2;
 
-    Result = StringCbPrintf(Text,
-                            TextLength,
-                            TEXT("%s %s"),
-                            Description,
-                            Context->Text);
-    assert(SUCCEEDED(Result));
+    Error = StringCbPrintf(Text,
+                           TextLength,
+                           TEXT("%s %s"),
+                           Description,
+                           Context->Text);
+    assert(SUCCEEDED(Error));
 
     free(DisplayName);
 
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 09 14:00:09 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 09 Jun 2025 14:00:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1010271.1388432 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd2m-0004B5-LY; Mon, 09 Jun 2025 14:00:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1010271.1388432; Mon, 09 Jun 2025 14:00:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd2m-0004B1-In; Mon, 09 Jun 2025 14:00:08 +0000
Received: by outflank-mailman (input) for mailman id 1010271;
 Mon, 09 Jun 2025 14:00:07 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=rRYH=YY=bounce.vates.tech=bounce-md_30504962.6846e8e2.v1-dc4b159d2f9045c78f42a667292d3b84@srs-se1.protection.inumbo.net>)
 id 1uOd2l-0003zs-9X
 for win-pv-devel@lists.xenproject.org; Mon, 09 Jun 2025 14:00:07 +0000
Received: from mail132-4.atl131.mandrillapp.com
 (mail132-4.atl131.mandrillapp.com [198.2.132.4])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 0b165c8d-453a-11f0-a305-13f23c93f187;
 Mon, 09 Jun 2025 16:00:05 +0200 (CEST)
Received: from pmta09.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail132-4.atl131.mandrillapp.com (Mailchimp) with ESMTP id 4bGD8210g1zlfcHB
 for <win-pv-devel@lists.xenproject.org>; Mon,  9 Jun 2025 14:00:02 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 dc4b159d2f9045c78f42a667292d3b84; Mon, 09 Jun 2025 14:00:02 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 0b165c8d-453a-11f0-a305-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749477602; x=1749747602;
	bh=hxOmKhhkVPGlZ3JLzMmcgWYzAK17QOpFMuw9IV+/gvs=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=vzyeVk104oVXQ6w47F5Pkp4Mwu2nPZ+v0cXFGAo8cb3iQp7S4ihNHb/eHbv4hqYPn
	 ugknSRJ3m9pEkHzvw9ZYRfYheDv5OwEYV5ksCuB/1aA942RnDh5ErhpqmD3LKBUNQc
	 o3+MXDuqOhECwl5haEW98kDmZv8K8uSVz1pJnkSOkqoigZvrfkPGT8SMI5LNljpEK3
	 iqK3wDZpEXKuUPsyvy0LEbT4ORCYLHLenu+obTDbW8WFQXSJ9/XjL8vHEceMfJ/K7B
	 GCK1i4C0zdNc/42aF6SA+ne+Yy2UYgfLK6z3pm2FzSssr7Zey3+ERj6FCCIK+4cLMw
	 qmGrV43sNOLbg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749477602; x=1749738102; i=ngoc-tu.dinh@vates.tech;
	bh=hxOmKhhkVPGlZ3JLzMmcgWYzAK17QOpFMuw9IV+/gvs=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=obqGURrjxqPuM2yMCCEI+MCtR/QAU+BjqdkfPvxzuojzBtctd8yE/D//yACi/f/Nx
	 LuW5q9w56i/+kQtHop2QrKYQFzd98RcnU0uMjjG3qQduX7YYosI4iYpbeYl1lbc0YG
	 xaXiHSd4/bux4Lr/s9K73ouuikEtjyB5hZD1RapHwf6fc5nG4xlga0GRSq6ZBqcvlk
	 24CA+97l6eHgRwwJsQABil5nl2uYCJvOqWLV6h54LKjMcUHHNkNHLeaHZqvWWKJP8h
	 udRLOE3depBBK4jLTMTF+tSxyzY60uEwEcY5UyKLwVUfvRjXxnKOCiL9+n5iKNWQpB
	 +pAYgBeKJseWQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v2=200/5]=20Autoreboot=20rework?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749477601152
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.dc4b159d2f9045c78f42a667292d3b84?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250609:md
Date: Mon, 09 Jun 2025 14:00:02 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Rework and clean up reboot prompt and check logic:
* Since autoreboot takes precedence over reboot prompts, make TryAutoReboot
  call PromptForReboot instead of the other way around.
* Any reboot request sets Context->RebootRequestedBy with the driver name.
* Reboot requests can be paused by active installations, system power requests
  or denied by the user (made explicit in the initial check).
* Run the session prompts in a separate thread to avoid blocking main monitor.
* Retry reboot request every minute (if exists).

v2 changes:
* Integrated Paul's feedback.
* Reworked and reorganized the monitor code.
* Made the retry actually work.
* Added check for active installations.
* Added commit to cleanup error variables in TryAutoReboot.
v1: https://lists.xenproject.org/archives/html/win-pv-devel/2025-05/msg00007.html

Tu Dinh (5):
  Cleanup duplicate error variables in TryAutoReboot
  Rework autoreboot retry logic
  Repeat TryAutoReboot() with timer
  Don't autoreboot during ES_SYSTEM_REQUIRED
  Check for active installation before autoreboot

 src/monitor/monitor.c                        | 522 +++++++++++++------
 vs2019/xenbus_monitor/xenbus_monitor.vcxproj |   2 +-
 vs2022/xenbus_monitor/xenbus_monitor.vcxproj |   2 +-
 3 files changed, 357 insertions(+), 169 deletions(-)

--
2.49.0.windows.1


Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 09 14:00:09 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 09 Jun 2025 14:00:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1010272.1388438 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd2n-0004Cr-OP; Mon, 09 Jun 2025 14:00:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1010272.1388438; Mon, 09 Jun 2025 14:00:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd2n-0004Cg-KC; Mon, 09 Jun 2025 14:00:09 +0000
Received: by outflank-mailman (input) for mailman id 1010272;
 Mon, 09 Jun 2025 14:00:08 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=OTUE=YY=bounce.vates.tech=bounce-md_30504962.6846e8e3.v1-a0b200f8afcb43b3b2ff0a478c5113af@srs-se1.protection.inumbo.net>)
 id 1uOd2m-0003zs-9o
 for win-pv-devel@lists.xenproject.org; Mon, 09 Jun 2025 14:00:08 +0000
Received: from mail132-4.atl131.mandrillapp.com
 (mail132-4.atl131.mandrillapp.com [198.2.132.4])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 0c2ec90a-453a-11f0-a305-13f23c93f187;
 Mon, 09 Jun 2025 16:00:07 +0200 (CEST)
Received: from pmta09.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail132-4.atl131.mandrillapp.com (Mailchimp) with ESMTP id 4bGD8356yVzlfcGY
 for <win-pv-devel@lists.xenproject.org>; Mon,  9 Jun 2025 14:00:03 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 a0b200f8afcb43b3b2ff0a478c5113af; Mon, 09 Jun 2025 14:00:03 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 0c2ec90a-453a-11f0-a305-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749477603; x=1749747603;
	bh=lqQe60VKdt7f+L3ZKsVqISQECQRr5i//ijbtl1LLF6A=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=l3GVC0BTpJiaOsg5xd2lYPpTUHzite7b2Aamc6xa32zKfGqa+6Q+/p/BgUmTJtmgZ
	 iEVysScAO9V3jIWctzXEVkP51BJvKcBw+7HMc9mOKg3VaJqICBnfUWYUMJ6XS88tnA
	 Do1cufdFlTcLFkHzbzLInBNJG/05AvmBYdYBegvQ6ZkLSU0iL7hDJYj2CGyIfFNwqq
	 6BITfJH6ofbCJTNnfronJw8TAOpozgCmjvhRL5VjGMHIfRHFAODQyFMOkeEuocSNmI
	 dfH3IIYrwZqtj6n8d3AfAzPXtJRazQ0REcnwvFh4F4N7AXW353oTg1265Y3MYjuVOg
	 LA1is5teJOwhw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749477603; x=1749738103; i=ngoc-tu.dinh@vates.tech;
	bh=lqQe60VKdt7f+L3ZKsVqISQECQRr5i//ijbtl1LLF6A=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=eudox0D7uR+PQI1f/HjYT3MSAAUf8gMM6Oy+W8nJ22ngCIv+NsGWWlalUto7e/S4B
	 R5YpRp4Hdiw+WtbChWjBLI7pEioJBY85Eg2FYRon1oMsQSYa/YcI49mqvsfcpqvTbQ
	 TDzA1Et3SEyf05KpzsuE8N35cpyznlFo9Rid24cFOg6VzYzgoSp9wIG9cmaC6fsl0e
	 a22tH40pbCjvrOZadVC3qPyqGFRgUREC25xkcJNK6LQBOlykCxtL1YYGtM9s1S11ex
	 yv6xp17wKMHa9TOD9xdQlD1OYn5T+lezecVenqvqqTi8vjKpoH+lBz22cBuOPrirq7
	 0MqTA3QEblTZg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v2=205/5]=20Check=20for=20active=20installation=20before=20autoreboot?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749477602588
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250609135941.309-6-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
References: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.a0b200f8afcb43b3b2ff0a478c5113af?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250609:md
Date: Mon, 09 Jun 2025 14:00:03 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

If the _MSIExecute mutex is set, an MSI installation is under way.
We don't want to autoreboot in these situations either.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/monitor.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index be41012..e1e8f1a 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -685,6 +685,7 @@ TryAutoReboot(
     )
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
+    HANDLE              MsiMutex;
     DWORD               Type;
     DWORD               AutoReboot;
     DWORD               RebootCount;
@@ -710,6 +711,22 @@ TryAutoReboot(
     if (Context->Response == IDNO)
         goto done;
 
+    // Check if there's an installation under way.
+    MsiMutex = OpenMutex(SYNCHRONIZE,
+                         FALSE,
+                         TEXT("Global\\_MSIExecute"));
+    if (MsiMutex != NULL) {
+        Error = WaitForSingleObject(MsiMutex, 0);
+        if (Error == WAIT_OBJECT_0 || Error == WAIT_ABANDONED)
+            ReleaseMutex(MsiMutex);
+
+        CloseHandle(MsiMutex);
+
+        if (Error == WAIT_TIMEOUT)
+            // The only case where an installation is definitely running.
+            goto done;
+    }
+
     Status = CallNtPowerInformation(SystemExecutionState,
                                     NULL,
                                     0,
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 09 14:00:10 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 09 Jun 2025 14:00:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1010273.1388440 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd2o-0004F3-PI; Mon, 09 Jun 2025 14:00:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1010273.1388440; Mon, 09 Jun 2025 14:00:10 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd2o-0004Ew-LX; Mon, 09 Jun 2025 14:00:10 +0000
Received: by outflank-mailman (input) for mailman id 1010273;
 Mon, 09 Jun 2025 14:00:09 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=wYpg=YY=bounce.vates.tech=bounce-md_30504962.6846e8e2.v1-b2b1823de6a64da197bf639743acb3d2@srs-se1.protection.inumbo.net>)
 id 1uOd2m-0004BI-Vv
 for win-pv-devel@lists.xenproject.org; Mon, 09 Jun 2025 14:00:08 +0000
Received: from mail132-4.atl131.mandrillapp.com
 (mail132-4.atl131.mandrillapp.com [198.2.132.4])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 0b3d42b3-453a-11f0-b894-0df219b8e170;
 Mon, 09 Jun 2025 16:00:05 +0200 (CEST)
Received: from pmta09.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail132-4.atl131.mandrillapp.com (Mailchimp) with ESMTP id 4bGD825Pl3zlfcJ9
 for <win-pv-devel@lists.xenproject.org>; Mon,  9 Jun 2025 14:00:02 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 b2b1823de6a64da197bf639743acb3d2; Mon, 09 Jun 2025 14:00:02 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 0b3d42b3-453a-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749477602; x=1749747602;
	bh=sPGGmJvIPZ6INN91YbkGVoej5ox0+HZtXfSVsp2QOSo=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=p2gpvtrPgDbacZnt7SX6E4At5OAQJkTewAWahx9+K8rkbn97T+DYjlCcW/2YggCR6
	 C9C07u43HKA013mNv6nTuvoXOW5Sp7IgQHTOr9S4KQwU/QpJBMByO2atdJmz3B/N2y
	 JkuNv7I3A2/jqLuRmKwoS1FlPi8IIdzukS1LANs2hYGpe16pzaRIeMmqMfTIAvKNRj
	 Zk6ePw7HgvK1kiWw1n4TtdceqTA5UFXiKI9l2mVYlyhPLcKrUZ/MQr8Lslf++uN/iD
	 3NnOlXm9/rmse9dLFUi0J8EuwUyBIBxAw+6j9nYLhoFtDAP1+Z3w4RvIUvFuOgqSB/
	 T3G5qr0nSKp4Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749477602; x=1749738102; i=ngoc-tu.dinh@vates.tech;
	bh=sPGGmJvIPZ6INN91YbkGVoej5ox0+HZtXfSVsp2QOSo=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=UYqkhUMc7nUz1t4i9j3wdliPzuLnDH0itRwrDB0Rm+q9kbv4LuTLSXQBgGmAtIAsX
	 cJQ+yIwV/Eq9EfAM28uB2sfc+w0bwPkfNA3k9+YpL1EREgS+CWQMxiwAuUkAF4J+am
	 Uj3+s8e3slZ0siW0jkdsWN+RQB+JijJahi0LWLKMTRGUmisb7AuoLBhFbRQFZqzMmY
	 SpnynF18nsIontzKWyYNA6FDkU8b7zfKhH7We6YsDI75rWiHdADaLkP9XYmFmtVmP5
	 Eh/3/UH+3gRZzwIRNeSvrkjyQ7bkj9hKpTRQiswaevHtAChoWYa41wkwVtRsm8mVV2
	 SDAzX2xYm+/6A==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v2=203/5]=20Repeat=20TryAutoReboot()=20with=20timer?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749477602055
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250609135941.309-4-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
References: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.b2b1823de6a64da197bf639743acb3d2?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250609:md
Date: Mon, 09 Jun 2025 14:00:02 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Add a timer that calls TryAutoReboot() every minute if reboot has been
requested beforehand.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/monitor.c | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index f76e255..fde04be 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -57,6 +57,7 @@ typedef struct _MONITOR_CONTEXT {
     HANDLE                  EventLog;
     HANDLE                  StopEvent;
     HANDLE                  RequestEvent;
+    HANDLE                  Timer;
     HKEY                    RequestKey;
     PTCHAR                  Title;
     PTCHAR                  Text;
@@ -77,6 +78,7 @@ typedef struct _REBOOT_PROMPT {
 MONITOR_CONTEXT MonitorContext;
 
 #define MAXIMUM_BUFFER_SIZE 1024
+#define REBOOT_RETRY_DELAY  60000L // 1 minute
 
 #define SERVICES_KEY "SYSTEM\\CurrentControlSet\\Services"
 
@@ -1346,6 +1348,7 @@ MonitorMain(
     PTCHAR              RequestKeyName;
     BOOL                Success;
     HRESULT             Error;
+    LARGE_INTEGER       DueTime;
 
     UNREFERENCED_PARAMETER(argc);
     UNREFERENCED_PARAMETER(argv);
@@ -1425,17 +1428,33 @@ MonitorMain(
     if (!Success)
         goto fail10;
 
+    Context->Timer = CreateWaitableTimer(NULL, FALSE, NULL);
+    if (Context->Timer == NULL)
+        goto fail11;
+
+    DueTime.QuadPart = -10000LL * REBOOT_RETRY_DELAY;
+
+    Success = SetWaitableTimer(Context->Timer,
+                               &DueTime,
+                               REBOOT_RETRY_DELAY,
+                               NULL,
+                               NULL,
+                               FALSE);
+    if (!Success)
+        goto fail12;
+
     SetEvent(Context->RequestEvent);
 
     ReportStatus(SERVICE_RUNNING, NO_ERROR, 0);
 
     for (;;) {
-        HANDLE  Events[3];
+        HANDLE  Events[4];
         DWORD   Object;
 
         Events[0] = Context->StopEvent;
         Events[1] = Context->RequestEvent;
         Events[2] = Context->ResponseEvent;
+        Events[3] = Context->Timer;
 
         Log("waiting (%u)...", ARRAYSIZE(Events));
         Object = WaitForMultipleObjects(ARRAYSIZE(Events),
@@ -1459,12 +1478,21 @@ MonitorMain(
                 DoReboot(NULL, 0);
             break;
 
+        case WAIT_OBJECT_0 + 3:
+            if (Context->RebootRequestedBy)
+                TryAutoReboot(Context->RebootRequestedBy);
+            break;
+
         default:
             break;
         }
     }
 
 done:
+    free(Context->RebootRequestedBy);
+    CancelWaitableTimer(Context->Timer);
+    CloseHandle(Context->Timer);
+
     (VOID) RegDeleteTree(Context->RequestKey, NULL);
 
     free(Context->Question);
@@ -1487,6 +1515,14 @@ done:
 
     return;
 
+fail12:
+    Log("fail12");
+
+    CloseHandle(Context->Timer);
+
+fail11:
+    Log("fail11");
+
 fail10:
     Log("fail10");
 
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 09 14:00:10 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 09 Jun 2025 14:00:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1010274.1388447 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd2o-0004FN-Sx; Mon, 09 Jun 2025 14:00:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1010274.1388447; Mon, 09 Jun 2025 14:00:10 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd2o-0004F8-Mm; Mon, 09 Jun 2025 14:00:10 +0000
Received: by outflank-mailman (input) for mailman id 1010274;
 Mon, 09 Jun 2025 14:00:09 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ik+F=YY=bounce.vates.tech=bounce-md_30504962.6846e8e3.v1-26afbf65d54341fe8ec34c1aa391013f@srs-se1.protection.inumbo.net>)
 id 1uOd2n-0004BI-KX
 for win-pv-devel@lists.xenproject.org; Mon, 09 Jun 2025 14:00:09 +0000
Received: from mail36.us4.mandrillapp.com (mail36.us4.mandrillapp.com
 [205.201.136.36]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 0c42f570-453a-11f0-b894-0df219b8e170;
 Mon, 09 Jun 2025 16:00:07 +0200 (CEST)
Received: from pmta15.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail36.us4.mandrillapp.com (Mailchimp) with ESMTP id 4bGD831T9KzS62SJR
 for <win-pv-devel@lists.xenproject.org>; Mon,  9 Jun 2025 14:00:03 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 26afbf65d54341fe8ec34c1aa391013f; Mon, 09 Jun 2025 14:00:03 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 0c42f570-453a-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749477603; x=1749747603;
	bh=2b2JBQcktfWin8uxQsE2bDNc7ixRqZmHUVUtaAUJD9M=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=OBhFeAJv8lh+EEbmTE65srt8Nu/YgwlJV9e+ERNV8OGRgl6OndwjR58R2eULrhqG8
	 aR5UhcF4AcUq+8r6q5NcpntERsSM3Xpon2OFduwkvki13uWMdpnQtR8FRW0nEF9kJe
	 tQMgnXEf04QmjHB+4SVYom+01mz9K5xC6gw1Rx1IEOvCb1rqDmV0oWxXYxoDt4RAdn
	 jhkAnUQdA9X7H8/4FctHGpTmPzMj4SIO3LB0h2CW2uFQf1uBRqieZ4kiyv4nVS9Q7g
	 hNFFvLGuDsy2Tp+WWpwdmO9cacV3voxa173m/PnmCiJ0B3Ju/rRBIMd6KcKbkMR7IS
	 KPRH4wcINDZsw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749477603; x=1749738103; i=ngoc-tu.dinh@vates.tech;
	bh=2b2JBQcktfWin8uxQsE2bDNc7ixRqZmHUVUtaAUJD9M=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=YQtB0HLH1zy7HGgA/hRL79Nt4pSbLt7JHl0+e7f2n74EXrBbrBCFiQcbUzF1QcqLv
	 oYlC/UpkyW9kWHmYmvW8RVcIRZSJcz4O7E85abNysdB5JAUN4CPNDrpD0rDD4s5beF
	 AdxYFmxVFuE68mEnnzh1AprYWYpSWzC1BK4FXGnJWPSLSyd1p/s17AarjNDp7DvSeS
	 zEZqVayTxdYIfx1wt9tGReTMconF75zL6BcPGCYSUmR7N5KyRe1eaz91QpocznDA8P
	 fTD3P9kc6RQsmSPgVg+w3YY+o6Jaa0qYM6zfWev+dEVG6QSCaP3GTldJivAqV/Salm
	 NORrzC78G+uOw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v2=204/5]=20Don't=20autoreboot=20during=20ES=5FSYSTEM=5FREQUIRED?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749477602288
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250609135941.309-5-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
References: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.26afbf65d54341fe8ec34c1aa391013f?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250609:md
Date: Mon, 09 Jun 2025 14:00:03 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Programs may set the ES_SYSTEM_REQUIRED execution state when they're
busy with some activity (media playback, downloads, updates etc.)

We don't want to autoreboot in these situations.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
Reviewed-by: Owen Smith <owen.smith@cloud.com>
Reviewed-by: Paul Durrant <paul@xen.org>
---
 src/monitor/monitor.c                        | 12 ++++++++++++
 vs2019/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
 vs2022/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index fde04be..be41012 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -36,6 +36,8 @@
 #include <strsafe.h>
 #include <wtsapi32.h>
 #include <cfgmgr32.h>
+#include <winternl.h>
+#include <powrprof.h>
 #include <malloc.h>
 #include <assert.h>
 
@@ -692,6 +694,8 @@ TryAutoReboot(
     PTCHAR              Description;
     PTCHAR              Text;
     DWORD               TextLength;
+    ULONG               PowerInfo;
+    NTSTATUS            Status;
     DWORD               Error;
 
     if (!Context->RebootRequestedBy) {
@@ -706,6 +710,14 @@ TryAutoReboot(
     if (Context->Response == IDNO)
         goto done;
 
+    Status = CallNtPowerInformation(SystemExecutionState,
+                                    NULL,
+                                    0,
+                                    &PowerInfo,
+                                    sizeof(PowerInfo));
+    if (Status < 0 || (PowerInfo & ES_SYSTEM_REQUIRED))
+        goto done;
+
     Length = sizeof (DWORD);
 
     Error = RegQueryValueEx(Context->ParametersKey,
diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
index 2a2c00f..047166e 100644
--- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
@@ -34,7 +34,7 @@
       <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <CETCompat>true</CETCompat>
       <GenerateMapFile>true</GenerateMapFile>
       <MapExports>true</MapExports>
diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
index 4d26331..0437024 100644
--- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
@@ -34,7 +34,7 @@
       <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <CETCompat>true</CETCompat>
       <GenerateMapFile>true</GenerateMapFile>
       <MapExports>true</MapExports>
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 09 14:00:11 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 09 Jun 2025 14:00:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1010275.1388449 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd2p-0004Ir-Rf; Mon, 09 Jun 2025 14:00:11 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1010275.1388449; Mon, 09 Jun 2025 14:00:11 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd2p-0004Ij-Ot; Mon, 09 Jun 2025 14:00:11 +0000
Received: by outflank-mailman (input) for mailman id 1010275;
 Mon, 09 Jun 2025 14:00:10 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=lWI4=YY=bounce.vates.tech=bounce-md_30504962.6846e8e2.v1-60dcdb97522d4ec09af962e289aad54e@srs-se1.protection.inumbo.net>)
 id 1uOd2o-0004BI-Kf
 for win-pv-devel@lists.xenproject.org; Mon, 09 Jun 2025 14:00:10 +0000
Received: from mail36.us4.mandrillapp.com (mail36.us4.mandrillapp.com
 [205.201.136.36]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 0a42551b-453a-11f0-b894-0df219b8e170;
 Mon, 09 Jun 2025 16:00:04 +0200 (CEST)
Received: from pmta15.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail36.us4.mandrillapp.com (Mailchimp) with ESMTP id 4bGD8240ZGzS62v7l
 for <win-pv-devel@lists.xenproject.org>; Mon,  9 Jun 2025 14:00:02 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 60dcdb97522d4ec09af962e289aad54e; Mon, 09 Jun 2025 14:00:02 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 0a42551b-453a-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749477602; x=1749747602;
	bh=uwLA5andF8LE0SoNGkO9qhlrRrlWU38ioX8O16ydBOQ=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=LewKqKwq8XzjWRqitDEizQKFQPVGYmcwC72ZNNW7QLw2mE1SrL4IoY4C2lXpDkwfr
	 cCCEORawYpmItWtYAuP+Bc7jsr9P1jDcoG05dv2lPADcdZNQdyRn+nOEcs2h376h0e
	 It+tFGPiObgJDala3nTDZS+46PaGtEry6irFcn0vUvo69ub/QnyNeEdajeMWlugXSE
	 rocA1u772p5Z+TeCoxKtT62qOuBanQaLSrfA8nWSPN4a9m31ObtrWBzpDqh1VbDUAB
	 gmJkRAI9J+3ynjTJfUvBlU4D+jpXSmsaMNYl0fZLPo1qlp2TuGrWPjgc1RQK3Q5Ug8
	 sIjfasApi+1jg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749477602; x=1749738102; i=ngoc-tu.dinh@vates.tech;
	bh=uwLA5andF8LE0SoNGkO9qhlrRrlWU38ioX8O16ydBOQ=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=PuGu4VTVQRkoB3+kOqgy46nXbr4snyA1yLe1uFdnjmazYrVXd8upchC/y7Ri/mG60
	 UME5GVJmg3c+AzQIcbK0u9UrfH3YUA8mrof1Exc/D8MprZGyuwKa4RNwUdUp4U5Okb
	 B4DaA+m1OdjE48kpBAAfb+gAZOUoEkOQ06gX59UZyoP6OkSO5/jz8ba5d+CXjs0ljy
	 6p3xLDcyfckFhWcSjHJu8qvZ/Da4dYz5mz/9CKPeeBAhNIJ1CMvOaH9zcmtClEfdPY
	 9upBoz630B+FCwsL+EfolywVY0luin+dB4RXrvbu3/qYBS2nbNX+FofpeeJ5fPW6tL
	 Lrq83ump9gJ+A==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v2=202/5]=20Rework=20autoreboot=20retry=20logic?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749477601825
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250609135941.309-3-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
References: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.60dcdb97522d4ec09af962e289aad54e?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250609:md
Date: Mon, 09 Jun 2025 14:00:02 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Since autoreboot takes precedence over reboot prompts, reorganize the
monitor to make TryAutoReboot the reboot entry point instead of
PromptForReboot.

- Prompt for reboot from another thread to avoid blocking main thread.
  Also save the reboot prompt response for later use.
- Add a new context entry RebootRequestedBy, set in PromptForReboot.
- Replace the RebootPending check with an one-time check of
  Context->RebootPrompted at prompt time.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/monitor.c | 442 +++++++++++++++++++++++++++---------------
 1 file changed, 283 insertions(+), 159 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 3a166db..f76e255 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -61,9 +61,19 @@ typedef struct _MONITOR_CONTEXT {
     PTCHAR                  Title;
     PTCHAR                  Text;
     PTCHAR                  Question;
-    BOOL                    RebootPending;
+    BOOL                    RebootPrompted;
+    PTCHAR                  RebootRequestedBy;
+    HANDLE                  ResponseEvent;
+    DWORD                   Response;
 } MONITOR_CONTEXT, *PMONITOR_CONTEXT;
 
+typedef struct _REBOOT_PROMPT {
+    PTCHAR                  Title;
+    PTCHAR                  Text;
+    HANDLE                  ResponseEvent;
+    PDWORD                  PResponse;
+} REBOOT_PROMPT, *PREBOOT_PROMPT;
+
 MONITOR_CONTEXT MonitorContext;
 
 #define MAXIMUM_BUFFER_SIZE 1024
@@ -453,7 +463,219 @@ fail1:
     return NULL;
 }
 
-static BOOL
+static VOID
+RebootPromptFree(
+    PREBOOT_PROMPT      Prompt
+    )
+{
+    if (Prompt) {
+        free(Prompt->Text);
+        free(Prompt->Title);
+        free(Prompt);
+    }
+}
+
+static DWORD WINAPI
+DoPromptForReboot(
+    LPVOID lpThreadParameter
+    )
+{
+    PREBOOT_PROMPT      Prompt = lpThreadParameter;
+    DWORD               TitleLength;
+    DWORD               TextLength;
+    DWORD               Timeout;
+    PWTS_SESSION_INFO   SessionInfo;
+    DWORD               Count;
+    DWORD               Index;
+    BOOL                Success;
+    DWORD               Error;
+
+    assert(Prompt);
+    assert(Prompt->ResponseEvent && Prompt->PResponse);
+    assert(Prompt->Title && Prompt->Text);
+
+    Error = ERROR_SUCCESS;
+
+    TitleLength = (DWORD)((_tcslen(Prompt->Title) +
+                           1) * sizeof (TCHAR));
+    TextLength = (DWORD)((_tcslen(Prompt->Text) +
+                           1) * sizeof (TCHAR));
+
+    Success = WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
+                                   0,
+                                   1,
+                                   &SessionInfo,
+                                   &Count);
+    if (!Success) {
+        Error = GetLastError();
+        goto fail1;
+    }
+
+    Timeout = GetPromptTimeout();
+
+    *Prompt->PResponse = 0;
+
+    for (Index = 0; Index < Count; Index++) {
+        DWORD                   SessionId = SessionInfo[Index].SessionId;
+        PTCHAR                  Name = SessionInfo[Index].pWinStationName;
+        WTS_CONNECTSTATE_CLASS  State = SessionInfo[Index].State;
+        DWORD                   Response;
+
+        Log("[%u]: %s [%s]",
+            SessionId,
+            Name,
+            WTSStateName(State));
+
+        if (State != WTSActive)
+            continue;
+
+        Success = WTSSendMessage(WTS_CURRENT_SERVER_HANDLE,
+                                 SessionId,
+                                 Prompt->Title,
+                                 TitleLength,
+                                 Prompt->Text,
+                                 TextLength,
+                                 MB_YESNO | MB_ICONEXCLAMATION,
+                                 Timeout,
+                                 &Response,
+                                 TRUE);
+
+        if (!Success)
+            goto fail2;
+
+        *Prompt->PResponse = Response;
+        (VOID) SetEvent(Prompt->ResponseEvent);
+
+        break;
+    }
+
+    WTSFreeMemory(SessionInfo);
+    RebootPromptFree(Prompt);
+
+    return ERROR_SUCCESS;
+
+fail2:
+    Log("fail2");
+    *Prompt->PResponse = 0;
+
+fail1:
+    RebootPromptFree(Prompt);
+
+    return Error;
+}
+
+static VOID
+PromptForReboot(
+    IN PTCHAR           DriverName
+    )
+{
+    PMONITOR_CONTEXT    Context = &MonitorContext;
+    HRESULT             Result;
+    PREBOOT_PROMPT      Prompt;
+    PTCHAR              DisplayName;
+    PTCHAR              Description;
+    HANDLE              PromptThread;
+    DWORD               TextLength;
+    DWORD               Error;
+
+    assert(DriverName);
+
+    /*
+     * Can't use Context->Response here since a previous prompt may not have
+     * gotten a response.
+     */
+    if (Context->RebootPrompted)
+        return;
+    Context->RebootPrompted = TRUE;
+
+    Log("====> (%s)", DriverName);
+
+    Prompt = calloc(1, sizeof (REBOOT_PROMPT));
+    if (Prompt == NULL) {
+        Error = ERROR_OUTOFMEMORY;
+        goto fail1;
+    }
+    Prompt->ResponseEvent = Context->ResponseEvent;
+    Prompt->PResponse = &Context->Response;
+
+    Prompt->Title = _tcsdup(Context->Title);
+    if (Prompt->Title == NULL) {
+        Error = ERROR_OUTOFMEMORY;
+        goto fail2;
+    }
+
+    DisplayName = GetDisplayName(DriverName);
+    if (DisplayName == NULL) {
+        Error = GetLastError();
+        goto fail3;
+    }
+
+    Description = _tcsrchr(DisplayName, ';');
+    if (Description == NULL)
+        Description = DisplayName;
+    else
+        Description++;
+
+    TextLength = (DWORD)((_tcslen(Description) +
+                          1 + // ' '
+                          _tcslen(Context->Text) +
+                          1 + // ' '
+                          _tcslen(Context->Question) +
+                          1) * sizeof (TCHAR));
+
+    Prompt->Text = calloc(1, TextLength);
+    if (Prompt->Text == NULL) {
+        Error = ERROR_OUTOFMEMORY;
+        goto fail4;
+    }
+
+    Result = StringCbPrintf(Prompt->Text,
+                            TextLength,
+                            TEXT("%s %s %s"),
+                            Description,
+                            Context->Text,
+                            Context->Question);
+    assert(SUCCEEDED(Result));
+
+    PromptThread = CreateThread(NULL,
+                                0,
+                                &DoPromptForReboot,
+                                Prompt,
+                                0,
+                                NULL);
+    if (PromptThread == NULL) {
+        Error = GetLastError();
+        goto fail4;
+    }
+
+    CloseHandle(PromptThread);
+    free(DisplayName);
+    // ownership of Prompt handed to prompt thread
+
+    return;
+
+fail4:
+    Log("fail4");
+    free(DisplayName);
+
+fail3:
+    Log("fail3");
+
+fail2:
+    Log("fail2");
+
+fail1:
+    {
+        PTCHAR  Message;
+        Message = GetErrorMessage(Error);
+        Log("fail1 (%s)", Message);
+        LocalFree(Message);
+    }
+
+    RebootPromptFree(Prompt);
+}
+
+static VOID
 TryAutoReboot(
     IN PTCHAR           DriverName
     )
@@ -470,6 +692,18 @@ TryAutoReboot(
     DWORD               TextLength;
     DWORD               Error;
 
+    if (!Context->RebootRequestedBy) {
+        Context->RebootRequestedBy = _tcsdup(DriverName);
+        if (!Context->RebootRequestedBy) {
+            Error = ERROR_OUTOFMEMORY;
+            goto fail1;
+        }
+    }
+
+    // We don't want to suddenly reboot if the user's already said no.
+    if (Context->Response == IDNO)
+        goto done;
+
     Length = sizeof (DWORD);
 
     Error = RegQueryValueEx(Context->ParametersKey,
@@ -483,7 +717,7 @@ TryAutoReboot(
         AutoReboot = 0;
 
     if (AutoReboot == 0)
-        goto done;
+        goto prompt;
 
     Length = sizeof (DWORD);
 
@@ -498,7 +732,7 @@ TryAutoReboot(
         RebootCount = 0;
 
     if (RebootCount >= AutoReboot)
-        goto done;
+        goto prompt;
 
     Log("AutoRebooting (reboot %u of %u)\n",
         RebootCount,
@@ -515,8 +749,6 @@ TryAutoReboot(
 
     (VOID) RegFlushKey(Context->ParametersKey);
 
-    Context->RebootPending = TRUE;
-
     Error = RegQueryValueEx(Context->ParametersKey,
                             "AutoRebootTimeout",
                             NULL,
@@ -527,9 +759,11 @@ TryAutoReboot(
         Type != REG_DWORD)
         Timeout = 60;
 
-    DisplayName = GetDisplayName(DriverName);
-    if (DisplayName == NULL)
-        goto fail1;
+    DisplayName = GetDisplayName(Context->RebootRequestedBy);
+    if (DisplayName == NULL) {
+        Error = GetLastError();
+        goto fail2;
+    }
 
     Description = _tcsrchr(DisplayName, ';');
     if (Description == NULL)
@@ -543,8 +777,10 @@ TryAutoReboot(
                           1) * sizeof (TCHAR));
 
     Text = calloc(1, TextLength);
-    if (Text == NULL)
-        goto fail2;
+    if (Text == NULL) {
+        SetLastError(ERROR_OUTOFMEMORY);
+        goto fail3;
+    }
 
     Error = StringCbPrintf(Text,
                            TextLength,
@@ -559,165 +795,33 @@ TryAutoReboot(
 
     free(Text);
 
-    return TRUE;
-
-done:
-    return FALSE;
-
-fail2:
-    Log("fail2");
-
-    free(DisplayName);
-
-fail1:
-    Error = GetLastError();
-
-    {
-        PTCHAR  Message;
-        Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
-        LocalFree(Message);
-    }
-
-    return FALSE;
-}
-
-static VOID
-PromptForReboot(
-    IN PTCHAR           DriverName
-    )
-{
-    PMONITOR_CONTEXT    Context = &MonitorContext;
-    HRESULT             Result;
-    PTCHAR              Title;
-    DWORD               TitleLength;
-    PTCHAR              DisplayName;
-    PTCHAR              Description;
-    PTCHAR              Text;
-    DWORD               TextLength;
-    PWTS_SESSION_INFO   SessionInfo;
-    DWORD               Count;
-    DWORD               Index;
-    BOOL                Success;
-    HRESULT             Error;
-
-    Log("====> (%s)", DriverName);
-
-    Title = Context->Title;
-    TitleLength = (DWORD)((_tcslen(Context->Title) +
-                           1) * sizeof (TCHAR));
-
-    // AutoReboot is set, DoReboot has been called
-    if (TryAutoReboot(DriverName))
-        goto done;
-
-    DisplayName = GetDisplayName(DriverName);
-    if (DisplayName == NULL)
-        goto fail1;
-
-    Description = _tcsrchr(DisplayName, ';');
-    if (Description == NULL)
-        Description = DisplayName;
-    else
-        Description++;
-
-    TextLength = (DWORD)((_tcslen(Description) +
-                          1 + // ' '
-                          _tcslen(Context->Text) +
-                          1 + // ' '
-                          _tcslen(Context->Question) +
-                          1) * sizeof (TCHAR));
-
-    Text = calloc(1, TextLength);
-    if (Text == NULL)
-        goto fail2;
-
-    Result = StringCbPrintf(Text,
-                            TextLength,
-                            TEXT("%s %s %s"),
-                            Description,
-                            Context->Text,
-                            Context->Question);
-    assert(SUCCEEDED(Result));
-
-    Success = WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
-                                   0,
-                                   1,
-                                   &SessionInfo,
-                                   &Count);
-    if (!Success)
-        goto fail3;
-
-    for (Index = 0; Index < Count; Index++) {
-        DWORD                   SessionId = SessionInfo[Index].SessionId;
-        PTCHAR                  Name = SessionInfo[Index].pWinStationName;
-        WTS_CONNECTSTATE_CLASS  State = SessionInfo[Index].State;
-        DWORD                   Timeout;
-        DWORD                   Response;
-
-        Log("[%u]: %s [%s]",
-            SessionId,
-            Name,
-            WTSStateName(State));
-
-        if (State != WTSActive)
-            continue;
-
-        Timeout = GetPromptTimeout();
-
-        Success = WTSSendMessage(WTS_CURRENT_SERVER_HANDLE,
-                                 SessionId,
-                                 Title,
-                                 TitleLength,
-                                 Text,
-                                 TextLength,
-                                 MB_YESNO | MB_ICONEXCLAMATION,
-                                 Timeout,
-                                 &Response,
-                                 TRUE);
-
-        if (!Success)
-            goto fail4;
-
-        Context->RebootPending = TRUE;
-
-        if (Response == IDYES || Response == IDTIMEOUT)
-            DoReboot(NULL, 0);
-
-        break;
-    }
+    return;
 
-    WTSFreeMemory(SessionInfo);
+prompt:
+    PromptForReboot(Context->RebootRequestedBy);
 
-    free(DisplayName);
+    return;
 
 done:
-    Log("<====");
-
     return;
 
-fail4:
-    Log("fail4");
-
-    WTSFreeMemory(SessionInfo);
-
 fail3:
     Log("fail3");
 
+    free(DisplayName);
+
 fail2:
     Log("fail2");
 
-    free(DisplayName);
-
 fail1:
-    Error = GetLastError();
-
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
     }
+
+    return;
 }
 
 static VOID
@@ -818,8 +922,8 @@ loop:
 found:
     RegCloseKey(SubKey);
 
-    if (!Context->RebootPending)
-        PromptForReboot(SubKeyName);
+    if (!Context->RebootRequestedBy)
+        TryAutoReboot(SubKeyName);
 
 done:
     free(SubKeyName);
@@ -1293,9 +1397,17 @@ MonitorMain(
     if (Context->RequestEvent == NULL)
         goto fail6;
 
+    Context->ResponseEvent = CreateEvent(NULL,
+                                         FALSE,
+                                         FALSE,
+                                         NULL);
+    if (Context->ResponseEvent == NULL)
+        goto fail7;
+    Context->Response = 0;
+
     Success = GetRequestKeyName(&RequestKeyName);
     if (!Success)
-        goto fail7;
+        goto fail8;
 
     Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
                            RequestKeyName,
@@ -1307,22 +1419,23 @@ MonitorMain(
                            &Context->RequestKey,
                            NULL);
     if (Error != ERROR_SUCCESS)
-        goto fail8;
+        goto fail9;
 
     Success = GetDialogParameters();
     if (!Success)
-        goto fail9;
+        goto fail10;
 
     SetEvent(Context->RequestEvent);
 
     ReportStatus(SERVICE_RUNNING, NO_ERROR, 0);
 
     for (;;) {
-        HANDLE  Events[2];
+        HANDLE  Events[3];
         DWORD   Object;
 
         Events[0] = Context->StopEvent;
         Events[1] = Context->RequestEvent;
+        Events[2] = Context->ResponseEvent;
 
         Log("waiting (%u)...", ARRAYSIZE(Events));
         Object = WaitForMultipleObjects(ARRAYSIZE(Events),
@@ -1341,6 +1454,11 @@ MonitorMain(
             CheckRequestKey();
             break;
 
+        case WAIT_OBJECT_0 + 2:
+            if (Context->Response == IDYES || Context->Response == IDTIMEOUT)
+                DoReboot(NULL, 0);
+            break;
+
         default:
             break;
         }
@@ -1354,6 +1472,7 @@ done:
     free(Context->Title);
     CloseHandle(Context->RequestKey);
     free(RequestKeyName);
+    CloseHandle(Context->ResponseEvent);
     CloseHandle(Context->RequestEvent);
     CloseHandle(Context->StopEvent);
 
@@ -1368,15 +1487,20 @@ done:
 
     return;
 
+fail10:
+    Log("fail10");
+
+    CloseHandle(Context->RequestKey);
+
 fail9:
     Log("fail9");
 
-    CloseHandle(Context->RequestKey);
+    free(RequestKeyName);
 
 fail8:
     Log("fail8");
 
-    free(RequestKeyName);
+    CloseHandle(Context->ResponseEvent);
 
 fail7:
     Log("fail7");
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 09 14:06:10 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 09 Jun 2025 14:06:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1010309.1388452 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd8b-0004da-9z; Mon, 09 Jun 2025 14:06:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1010309.1388452; Mon, 09 Jun 2025 14:06:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd8b-0004dT-70; Mon, 09 Jun 2025 14:06:09 +0000
Received: by outflank-mailman (input) for mailman id 1010309;
 Mon, 09 Jun 2025 14:06:08 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=y3X0=YY=bounce.vates.tech=bounce-md_30504962.6846ea4d.v1-63e3d8abde234e5687fc55988a087234@srs-se1.protection.inumbo.net>)
 id 1uOd8a-0004dI-2S
 for win-pv-devel@lists.xenproject.org; Mon, 09 Jun 2025 14:06:08 +0000
Received: from mail36.us4.mandrillapp.com (mail36.us4.mandrillapp.com
 [205.201.136.36]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e2d38f26-453a-11f0-a305-13f23c93f187;
 Mon, 09 Jun 2025 16:06:07 +0200 (CEST)
Received: from pmta15.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail36.us4.mandrillapp.com (Mailchimp) with ESMTP id 4bGDH170f1zS62Lnb
 for <win-pv-devel@lists.xenproject.org>; Mon,  9 Jun 2025 14:06:05 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 63e3d8abde234e5687fc55988a087234; Mon, 09 Jun 2025 14:06:05 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e2d38f26-453a-11f0-a305-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749477966; x=1749747966;
	bh=emnci1kgGIh1ariwdR1huX9RqZPw55dTxNSi5cmM6ZU=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=fpTI3rUlUDAMVrh58XHKg2L93hU/xmcYPChtfeZSr2RraQuDAub/Y757KSVThflB1
	 q1O89T4yXBpim5qJuGuQOL14/1b/R0KFN2y8nVi9Yf9xl2Rj9ctpFNIP0HfGB8unTj
	 0gIm7lw0tdvwYnheGgcp2OBnlBqg9y+U38znDajCRsw3eN0j1xN9JgOdzb8qI4NRAp
	 OT+UZgWcPgD5xHLqp5M2tS7KwjUrIKT2JIYz1CmOWrg2dsByFJ6/cs9eznD483oYgM
	 BxCGcQbQLAd/L3NRygtVLTX/6OTsy+JS3kOex3beEZWna0PMaU0ZDds1l2dw7vanFP
	 nc415yeDbpRvQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749477966; x=1749738466; i=ngoc-tu.dinh@vates.tech;
	bh=emnci1kgGIh1ariwdR1huX9RqZPw55dTxNSi5cmM6ZU=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=KcD7ubT+VYHsblanY7gI1HBycSQVGeNj4HSev76bknqbQu62Mna+fUEc6atCBNjs/
	 uVP2+iAtMg+ZZrDOtmVSLvZJT7NULA8q8qplHe0cQBzgSjrS+KABiN7josotY9Ihjp
	 eZD3RTSfC3fVl/ejIC6c1QN7oFIgctqQs9s7xOpulTQuJlXhhu/0k8mdRl4TCdhzu8
	 sp0ergBkKtfbJKhwTsOpmv/Ksdsp0H7gKybuWihwkwaYVRh1jGrj4AgXGLCZA6R/Wf
	 Pd5WfzXk0EN4JB8Ju9zSN30ztQ+hYrGfgyAjnkBuL2XGO/j6BrrqgtWWjFvKscTx+m
	 FmuXwlBKTgj4Q==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=202/2]=20balloon:=20Specify=20MM=5FALLOCATE=5FPREFER=5FCONTIGUOUS?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749477965289
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250609140543.1454-2-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250609140543.1454-1-ngoc-tu.dinh@vates.tech>
References: <20250609140543.1454-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.63e3d8abde234e5687fc55988a087234?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250609:md
Date: Mon, 09 Jun 2025 14:06:05 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

This flag, available from Windows 7, instructs the kernel allocator to
avoid physical memory fragmentation.

Tested on Server 2022 by decreasing memory from 8GB->5GB:
* Before: 98 balloon allocations containing 6518 contiguous ranges
* After: 98 balloon allocations containing 649 contiguous ranges

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenbus/balloon.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/xenbus/balloon.c b/src/xenbus/balloon.c
index 690e45f..e1d0e94 100644
--- a/src/xenbus/balloon.c
+++ b/src/xenbus/balloon.c
@@ -219,6 +219,7 @@ BalloonAllocatePagesForMdl(
                                   TotalBytes,
                                   MmCached,
                                   MM_DONT_ZERO_ALLOCATION |
+                                  MM_ALLOCATE_PREFER_CONTIGUOUS |
                                   MM_ALLOCATE_AND_HOT_REMOVE);
     if (Mdl == NULL)
         goto done;
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 09 14:06:10 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 09 Jun 2025 14:06:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1010310.1388457 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd8c-0004fH-Bu; Mon, 09 Jun 2025 14:06:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1010310.1388457; Mon, 09 Jun 2025 14:06:10 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOd8c-0004fA-8V; Mon, 09 Jun 2025 14:06:10 +0000
Received: by outflank-mailman (input) for mailman id 1010310;
 Mon, 09 Jun 2025 14:06:08 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=FCW+=YY=bounce.vates.tech=bounce-md_30504962.6846ea4d.v1-dfef849ec468491ca789daf99c1b0d2e@srs-se1.protection.inumbo.net>)
 id 1uOd8a-0004dI-Mj
 for win-pv-devel@lists.xenproject.org; Mon, 09 Jun 2025 14:06:08 +0000
Received: from mail36.us4.mandrillapp.com (mail36.us4.mandrillapp.com
 [205.201.136.36]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e2cece13-453a-11f0-a305-13f23c93f187;
 Mon, 09 Jun 2025 16:06:07 +0200 (CEST)
Received: from pmta15.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail36.us4.mandrillapp.com (Mailchimp) with ESMTP id 4bGDH15Z8kzS62JQM
 for <win-pv-devel@lists.xenproject.org>; Mon,  9 Jun 2025 14:06:05 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 dfef849ec468491ca789daf99c1b0d2e; Mon, 09 Jun 2025 14:06:05 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e2cece13-453a-11f0-a305-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749477965; x=1749747965;
	bh=LxKV6Y/XqHujx/u3R2jpvt3NB5JMVXxIaWGdddSO52M=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=Hrmr6z7qb4GeYx2LLHSqgZDQIn6iHO1+N+mADvT88KF13cMr+LaOa5V/KcP7thyMk
	 ITfu3fVNgPDokwARiFOLvAnmvYjgpOyWskEv/PQYWi+SZgpgOXRopEhY0jMJjtT0i9
	 fOvhzHgav3Hs3iu9oQqgPc5tK8J4CphJxBw+wor9fqvm+1w8/lFr1EUmk0JZyJaZLv
	 t9pQmlRzeu0JPT0c2VFyU8VdbVFoMNCTGGCUy9J27FfHnAHwimf0FoouVWPxlob+V3
	 zmS8Wo34M9SQqlZMPoGevj7RuRDho3GbHmmnPl9TkOPT5HqnzIySLyXXf9vSKq7myJ
	 DPuFB6wDrzGGg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749477965; x=1749738465; i=ngoc-tu.dinh@vates.tech;
	bh=LxKV6Y/XqHujx/u3R2jpvt3NB5JMVXxIaWGdddSO52M=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=Qi5xvN006GJ+JJTj7cf7nCA04UR9FmA/2mgpdnZK0PnGaOQKaY/4gojKfdjotnbae
	 lVE9RghJeE1N9twxmY2JRzsIjHbeLnX1+MHd2zQeg9MLbru5DRKEPrQ/XYswlzGFb+
	 Br3+d+kO6tV4y+UJ/eEAM3BGeFrzRzIzWRMs/fiHR2YWEcFNdw5yPdjgcwpT7KN1d1
	 unIH1MhzXeSdGDBXT8BgIPeMIafFgENrI7wg58usdJ7vVEy8E/lbTFje7fTcC9lbi/
	 g3NH8ShLadCClcrbXdVGzITrUhfCsxFL3sscQWngoYzJ4V0SJBDZQRH1iWs7koerPe
	 JItK2ffIX825A==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=201/2]=20Use=20Windows=2010=20APIs=20to=20inflate/deflate=20balloon.?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749477964847
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250609140543.1454-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.dfef849ec468491ca789daf99c1b0d2e?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250609:md
Date: Mon, 09 Jun 2025 14:06:05 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Windows 10 provides MM_ALLOCATE_AND_HOT_REMOVE to remove pages from
the physical memory pool. The removed pages can be added back with
MmAddPhysicalMemory.

Implement balloon inflation using calls to MmAddPhysicalMemory on
contiguous PFN ranges.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenbus/balloon.c | 38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/xenbus/balloon.c b/src/xenbus/balloon.c
index 8d7e2c2..690e45f 100644
--- a/src/xenbus/balloon.c
+++ b/src/xenbus/balloon.c
@@ -194,6 +194,7 @@ BalloonSort(
         ASSERT3U(PfnArray[Index], <, PfnArray[Index + 1]);
 }
 
+__drv_requiresIRQL(PASSIVE_LEVEL)
 static PMDL
 BalloonAllocatePagesForMdl(
     IN  ULONG       Count
@@ -205,6 +206,8 @@ BalloonAllocatePagesForMdl(
     SIZE_T          TotalBytes;
     PMDL            Mdl;
 
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
     LowAddress.QuadPart = 0ull;
     HighAddress.QuadPart = ~0ull;
     SkipBytes.QuadPart = 0ull;
@@ -215,7 +218,8 @@ BalloonAllocatePagesForMdl(
                                   SkipBytes,
                                   TotalBytes,
                                   MmCached,
-                                  MM_DONT_ZERO_ALLOCATION);
+                                  MM_DONT_ZERO_ALLOCATION |
+                                  MM_ALLOCATE_AND_HOT_REMOVE);
     if (Mdl == NULL)
         goto done;
 
@@ -238,6 +242,9 @@ BalloonFreePagesFromMdl(
 {
     volatile UCHAR  *Mapping;
     ULONG           Index;
+    PPFN_NUMBER     Pfn;
+    PFN_NUMBER      RangeStart, RangeEnd;
+    NTSTATUS        Status;
 
     if (!Check)
         goto done;
@@ -280,7 +287,34 @@ BalloonFreePagesFromMdl(
     MmUnmapLockedPages((PVOID)Mapping, Mdl);
 
 done:
-    MmFreePagesFromMdl(Mdl);
+    Pfn = MmGetMdlPfnArray(Mdl);
+
+    RangeStart = 0;
+    while (RangeStart < (MmGetMdlByteCount(Mdl) >> PAGE_SHIFT)) {
+        PHYSICAL_ADDRESS    StartAddress;
+        LARGE_INTEGER       NumberOfBytes;
+
+        for (RangeEnd = RangeStart;
+             RangeEnd < (MmGetMdlByteCount(Mdl) >> PAGE_SHIFT);
+             RangeEnd++) {
+            if (Pfn[RangeEnd] != Pfn[RangeStart] + (RangeEnd - RangeStart))
+                break;
+        }
+
+        StartAddress.QuadPart = Pfn[RangeStart] << PAGE_SHIFT;
+        NumberOfBytes.QuadPart = (RangeEnd - RangeStart) << PAGE_SHIFT;
+
+        Status = MmAddPhysicalMemory(&StartAddress, &NumberOfBytes);
+        if (!NT_SUCCESS(Status)) {
+            Error("MmAddPhysicalMemory failed: %08x (PFN %llx + %llx pages)\n",
+                  Status,
+                  Pfn[RangeStart],
+                  RangeEnd - RangeStart);
+            break;
+        }
+
+        RangeStart = RangeEnd;
+    }
 }
 
 #define XENBUS_BALLOON_MIN_PAGES_PER_S 1000ull
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 09 14:24:16 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 09 Jun 2025 14:24:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1010355.1388461 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOdQ6-0006uO-KN; Mon, 09 Jun 2025 14:24:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1010355.1388461; Mon, 09 Jun 2025 14:24:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOdQ6-0006uH-HR; Mon, 09 Jun 2025 14:24:14 +0000
Received: by outflank-mailman (input) for mailman id 1010355;
 Mon, 09 Jun 2025 14:24:13 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=/eOO=YY=bounce.vates.tech=bounce-md_30504962.6846ee89.v1-9abaf3321399469493dcb3432d9d4d8a@srs-se1.protection.inumbo.net>)
 id 1uOdQ5-0006uB-2Z
 for win-pv-devel@lists.xenproject.org; Mon, 09 Jun 2025 14:24:13 +0000
Received: from mail132-4.atl131.mandrillapp.com
 (mail132-4.atl131.mandrillapp.com [198.2.132.4])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 69118061-453d-11f0-a305-13f23c93f187;
 Mon, 09 Jun 2025 16:24:11 +0200 (CEST)
Received: from pmta09.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail132-4.atl131.mandrillapp.com (Mailchimp) with ESMTP id 4bGDgs6jkLzlfcHW
 for <win-pv-devel@lists.xenproject.org>; Mon,  9 Jun 2025 14:24:09 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 9abaf3321399469493dcb3432d9d4d8a; Mon, 09 Jun 2025 14:24:09 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 69118061-453d-11f0-a305-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749479049; x=1749749049;
	bh=FoJsyw5IaQH60JYK0YmHdbZ2f8agCt+nwbolI0+ufC0=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=IcCbqHtf3VYIbtG0y5u8IrbCtfQ+pLbTO/JGkICSz2D/TJfIYrrivVdj33B6tFXdV
	 fdzzAK9SRNRiYVik+ruRhsin7PsD3sq7jh9Q2FCduoANb02mbcJaVI6Id4pKRIdPM8
	 zRxmfL8ah3ozXLBY6Sajp1caD1Z0Gbtve/2mbxGmVIT4WH6w5Lsa9c/Fc8vLWyC3lR
	 xb9NSuXdhU/oYOjJDE2S4nCvAl9Zzjslaf3CsFSqaOh5OQ8/QbKRoXq9s0NF4FGBYw
	 slz8JyfZVjr6t2ctoAkm0nLcOAiS7Fl7UYRml26z7EMYubcUil1rqsS0p1HFR2g2p1
	 G5qyYEfqfi6Sw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749479049; x=1749739549; i=ngoc-tu.dinh@vates.tech;
	bh=FoJsyw5IaQH60JYK0YmHdbZ2f8agCt+nwbolI0+ufC0=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=b4Ww9Yco/zKBSTC+7Z2LxRilZ2TFNjUKctrNXp2NXsrac/xBzA2FlAyHj/P2cXSTg
	 HKFm1zpeq5CYITIEqqklq3zlfML6SNGEqJMOJS8/IqXtprTCXkQ8ymrgLtW9zoC9gj
	 ru3hf/yyhiaJpm4fnlFfhe/BxUaTNikxlktjBQOYZPZ+846anJ0ejQHRGR9eFTUems
	 alYewliPmKeUwrjiZcGjEfHJY+/YnLNrJTMWY6Im9d4ILLPpeSTTj5FEUCzDpJwuTE
	 9joZdUyQTwCU9paTTQsZ9HM0SUXa/AVFtMqVzZ7/ou802zASJX9YIefsakWXYdOR33
	 ViZU+nKoXFKnQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH]=20Invalidate=20FDOs=20when=20no=20devices=20are=20present?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749479048812
Message-Id: <8acb2c49-e9cf-4ba9-ac48-5f1b981bb78c@vates.tech>
To: "Paul Durrant" <paul@xen.org>, win-pv-devel@lists.xenproject.org
Cc: "Paul Durrant" <pdurrant@amazon.com>
References: <20241202120633.1121-1-paul@xen.org>
In-Reply-To: <20241202120633.1121-1-paul@xen.org>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.9abaf3321399469493dcb3432d9d4d8a?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250609:md
Date: Mon, 09 Jun 2025 14:24:09 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Hi Paul,

Sorry for the late reply.

On 02/12/2024 13:06, Paul Durrant wrote:
> From: Tu Dinh <ngoc-tu.dinh@vates.tech>
> 
> In cases where the entire xenstore device key is removed, FdoScan()
> currently skips reenumeration entirely. This causes it to not pass the
> removal event to xennet. Fix the issue by reenumerating devices even if
> xenstore key does not exist.
> 
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> 
> Ported from XENVIF.
> 
> Signed-off-by: Paul Durrant <pdurrant@amazon.com>
> ---
>   src/xenvkbd/fdo.c | 86 ++++++++++++++++++++++++++---------------------
>   1 file changed, 48 insertions(+), 38 deletions(-)
> 
> diff --git a/src/xenvkbd/fdo.c b/src/xenvkbd/fdo.c
> index 7a87ead0801a..98297fc1a1a1 100644
> --- a/src/xenvkbd/fdo.c
> +++ b/src/xenvkbd/fdo.c
> @@ -756,36 +756,38 @@ __FdoEnumerate(
>               Name = PdoGetName(Pdo);
>               Missing = TRUE;
>   
> -            // If the PDO already exists and its name is in the device list
> -            // then we don't want to remove it.
> -            for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
> -                PANSI_STRING Device = &Devices[Index];
> -
> -                if (Device->Length == 0)
> -                    continue;
> -
> -                if (strcmp(Name, Device->Buffer) == 0) {
> -                    Missing = FALSE;
> -                    Device->Length = 0;  // avoid duplication
> -                    break;
> +            if (Devices != NULL) {
> +                // If the PDO already exists and its name is in the device list
> +                // then we don't want to remove it.
> +                for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
> +                    PANSI_STRING Device = &Devices[Index];
> +
> +                    if (Device->Length == 0)
> +                        continue;
> +
> +                    if (strcmp(Name, Device->Buffer) == 0) {
> +                        Missing = FALSE;
> +                        Device->Length = 0;  // avoid duplication
> +                        break;
> +                    }
>                   }
> -            }
>   
> -            if (!PdoIsMissing(Pdo)) {
> -                if (PdoIsEjectRequested(Pdo)) {
> -                    IoRequestDeviceEject(PdoGetDeviceObject(Pdo));
> -                } else if (Missing) {
> -                    PdoSetMissing(Pdo, "device disappeared");
> -
> -                    // If the PDO has not yet been enumerated then we can
> -                    // go ahead and mark it as deleted, otherwise we need
> -                    // to notify PnP manager and wait for the REMOVE_DEVICE
> -                    // IRP.
> -                    if (PdoGetDevicePnpState(Pdo) == Present) {
> -                        PdoSetDevicePnpState(Pdo, Deleted);
> -                        PdoDestroy(Pdo);
> -                    } else {
> -                        NeedInvalidate = TRUE;
> +                if (!PdoIsMissing(Pdo)) {
> +                    if (PdoIsEjectRequested(Pdo)) {
> +                        IoRequestDeviceEject(PdoGetDeviceObject(Pdo));
> +                    } else if (Missing) {
> +                        PdoSetMissing(Pdo, "device disappeared");
> +
> +                        // If the PDO has not yet been enumerated then we can
> +                        // go ahead and mark it as deleted, otherwise we need
> +                        // to notify PnP manager and wait for the REMOVE_DEVICE
> +                        // IRP.
> +                        if (PdoGetDevicePnpState(Pdo) == Present) {
> +                            PdoSetDevicePnpState(Pdo, Deleted);
> +                            PdoDestroy(Pdo);
> +                        } else {
> +                            NeedInvalidate = TRUE;
> +                        }
>                       }
>                   }
>               }

With the ported patch, the `if (!PdoIsMissing(Pdo))` check becomes 
subordinate to the `if (Devices != NULL)` check:

     if (Devices != NULL) {
         for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
             // ...
         }

         if (!PdoIsMissing(Pdo)) {
             // ...
         }
     }

Shouldn't it be outside that check (like in Xenvif):

     if (Devices != NULL) {
         for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
             // ...
         }
     }

     if (!PdoIsMissing(Pdo)) {
         // ...
     }

> @@ -795,15 +797,17 @@ __FdoEnumerate(
>       }
>   
>       // Walk the class list and create PDOs for any new device
> -    for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
> -        PANSI_STRING Device = &Devices[Index];
> +    if (Devices != NULL) {
> +        for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
> +            PANSI_STRING Device = &Devices[Index];
>   
> -        if (Device->Length == 0)
> -            continue;
> +            if (Device->Length == 0)
> +                continue;
>   
> -        status = PdoCreate(Fdo, Device);
> -        if (NT_SUCCESS(status))
> -            NeedInvalidate = TRUE;
> +            status = PdoCreate(Fdo, Device);
> +            if (NT_SUCCESS(status))
> +                NeedInvalidate = TRUE;
> +        }
>       }
>   
>       __FdoReleaseMutex(Fdo);
> @@ -950,8 +954,12 @@ FdoScan(
>               Devices = NULL;
>           }
>   
> -        if (Devices == NULL)
> -            goto loop;
> +        if (Devices == NULL) {
> +            if (status == STATUS_OBJECT_PATH_NOT_FOUND)
> +                goto invalidate;
> +            else
> +                goto loop;
> +        }
>   
>           if (ParametersKey != NULL) {
>               status = RegistryQuerySzValue(ParametersKey,
> @@ -991,9 +999,11 @@ FdoScan(
>           if (UnsupportedDevices != NULL)
>               RegistryFreeSzValue(UnsupportedDevices);
>   
> +invalidate:
>           NeedInvalidate = __FdoEnumerate(Fdo, Devices);
>   
> -        __FdoFreeAnsi(Devices);
> +        if (Devices != NULL)
> +            __FdoFreeAnsi(Devices);
>   
>           if (NeedInvalidate) {
>               NeedInvalidate = FALSE;



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Jun 10 11:29:34 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 10 Jun 2025 11:29:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1010702.1388875 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOxAa-0004sX-1e; Tue, 10 Jun 2025 11:29:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1010702.1388875; Tue, 10 Jun 2025 11:29:32 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uOxAZ-0004sP-VA; Tue, 10 Jun 2025 11:29:31 +0000
Received: by outflank-mailman (input) for mailman id 1010702;
 Tue, 10 Jun 2025 11:29:30 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=xLw9=YZ=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uOxAX-0004sF-Tj
 for win-pv-devel@lists.xenproject.org; Tue, 10 Jun 2025 11:29:29 +0000
Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com
 [2a00:1450:4864:20::32f])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 2abd7bff-45ee-11f0-b894-0df219b8e170;
 Tue, 10 Jun 2025 13:29:27 +0200 (CEST)
Received: by mail-wm1-x32f.google.com with SMTP id
 5b1f17b1804b1-450cf0120cdso46315615e9.2
 for <win-pv-devel@lists.xenproject.org>; Tue, 10 Jun 2025 04:29:27 -0700 (PDT)
Received: from [192.168.0.239] (54-240-197-232.amazon.com. [54.240.197.232])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-45209bc6d50sm138990565e9.5.2025.06.10.04.29.26
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 10 Jun 2025 04:29:26 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 2abd7bff-45ee-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1749554967; x=1750159767; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=WWA6eNKO/hIhx5An0QdZJ+gyVO5Q4WVDfZ22Ljm8hG4=;
        b=Pe7krQaooLafMjIvpoBbAzS3B2EelSj5b4iEZP4UnRnqGyS2dDAmJGZkdzXqK1vnoa
         4ab9HjHxd710DDyJOBVY4xLeJmxeGWOzGAnxYCirJMkVKNfTZJWlTRdEz2ZVK2NVuxI8
         LA8YKMIeQx/FUiBWo76qkkF2KYxN7RkUo6szriAzls53jjCbbHB0k2jsa1w3U1NiJD++
         dL8xbTorPqlVZqDvxzZm7wEPOHIxily/Mklg3hPPerO19LTEaMeyJ7OwAcuqb2t0+68l
         AJrMAGmnKOSxpykZuGvKT9IShUCANuzVLOX3QjdegkhsTXlMKI+F5b7fEYUHBr9c9CKi
         F++Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1749554967; x=1750159767;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=WWA6eNKO/hIhx5An0QdZJ+gyVO5Q4WVDfZ22Ljm8hG4=;
        b=diuzSb8yFxPFganSUX/az/PEHQyfDuHDTkmSNGEK/Jrzf9l2r80QGewdZ1NVIanuWM
         CTzV/tef63e/39SgDwQOpiAvd0QHtn95U3MCCYBRZF8Qikn+uMLO8oQjPEox2AHdCXmF
         8SdBKASeFUoU9KKA/gDmWUsn9fbLQxJJgcghqQc8YXODokU2+iNSrdjxTpQwzhTEb3BA
         8Iixw5a4v3XuBpneYqfZH7c+5JW1ypFtIBuAwEhDNRRLIoPo8Q8faQPmLlQtX2vWowp/
         1xxKb89kB1BJEDcv8ydE9wJ5K6z9V/CrBUbcAc1B6iHFbaydR2pdmfyXH6GbSRPQ7fpA
         siuw==
X-Forwarded-Encrypted: i=1; AJvYcCXs+b+iNjXxz+h4Xt1TFFNsxNUOpFBzSX982nV1HfK9udBXMf2w473r7MczDKfRpqrERXvdSePhSFJMSW4=@lists.xenproject.org
X-Gm-Message-State: AOJu0Yw1Jh4wYK6IXtzwXvo0Ezds0jokLpXLz5CtOPCsbi/aSasBx0Mn
	3eyhjqxfX7VQ8hTVDcpUvawZV5cIxG7G+gFwWTOjXW5v4I/+YuXKuUll
X-Gm-Gg: ASbGncuGajJFiQ3O2xq7np+e0yPPFRwEawpR70NR0mvSYrRQAdEs1UhgW5Wo0vjxIn2
	hBDMEKaTjDHDxEjuVqMDfFpcQI+o7EFa32n+WXdPjI5290YzJo3ss90rQYWKC9D+wJaYNEs7+AI
	bwgFW3nP5dS3Q1fj/s0CltdlWZfW54bwJWinA9g3tFt/b87bSUrZuUz2M2wMnlElqGiaidHxzdb
	WgKlapbqckmRUFFyKSZOzv8Eh2NsdCLBFKVYKtIKlpDeXoz74WOgCzsbso04p1uW2E7/ynDOSh9
	wWdTuyWgQWQMrOr/HRRLXrFPbZsq/6oyDvwYTjEqLSvF+W9VTsRX841e07w2/s9tXCdmFk6Cb9d
	7/xKBmKTOD0hT6KnLBcYXeyqWb00e
X-Google-Smtp-Source: AGHT+IH7NndsfBdpYS+0IITLloWGAshSR/o5TgI33CSjGnCF+WtMonNOD5i0R+RhBWEBu8g/WohkRQ==
X-Received: by 2002:a05:600c:83cf:b0:442:f97b:87e with SMTP id 5b1f17b1804b1-45201340828mr149397655e9.6.1749554966875;
        Tue, 10 Jun 2025 04:29:26 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <e9595c79-6184-4752-b38b-5ba2763e9804@xen.org>
Date: Tue, 10 Jun 2025 12:29:25 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [PATCH] Invalidate FDOs when no devices are present
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
References: <20241202120633.1121-1-paul@xen.org>
 <8acb2c49-e9cf-4ba9-ac48-5f1b981bb78c@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <8acb2c49-e9cf-4ba9-ac48-5f1b981bb78c@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 09/06/2025 15:24, Tu Dinh wrote:
> Hi Paul,
> 
> Sorry for the late reply.
> 
> On 02/12/2024 13:06, Paul Durrant wrote:
>> From: Tu Dinh <ngoc-tu.dinh@vates.tech>
>>
>> In cases where the entire xenstore device key is removed, FdoScan()
>> currently skips reenumeration entirely. This causes it to not pass the
>> removal event to xennet. Fix the issue by reenumerating devices even if
>> xenstore key does not exist.
>>
>> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
>>
>> Ported from XENVIF.
>>
>> Signed-off-by: Paul Durrant <pdurrant@amazon.com>
>> ---
>>    src/xenvkbd/fdo.c | 86 ++++++++++++++++++++++++++---------------------
>>    1 file changed, 48 insertions(+), 38 deletions(-)
>>
>> diff --git a/src/xenvkbd/fdo.c b/src/xenvkbd/fdo.c
>> index 7a87ead0801a..98297fc1a1a1 100644
>> --- a/src/xenvkbd/fdo.c
>> +++ b/src/xenvkbd/fdo.c
>> @@ -756,36 +756,38 @@ __FdoEnumerate(
>>                Name = PdoGetName(Pdo);
>>                Missing = TRUE;
>>    
>> -            // If the PDO already exists and its name is in the device list
>> -            // then we don't want to remove it.
>> -            for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
>> -                PANSI_STRING Device = &Devices[Index];
>> -
>> -                if (Device->Length == 0)
>> -                    continue;
>> -
>> -                if (strcmp(Name, Device->Buffer) == 0) {
>> -                    Missing = FALSE;
>> -                    Device->Length = 0;  // avoid duplication
>> -                    break;
>> +            if (Devices != NULL) {
>> +                // If the PDO already exists and its name is in the device list
>> +                // then we don't want to remove it.
>> +                for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
>> +                    PANSI_STRING Device = &Devices[Index];
>> +
>> +                    if (Device->Length == 0)
>> +                        continue;
>> +
>> +                    if (strcmp(Name, Device->Buffer) == 0) {
>> +                        Missing = FALSE;
>> +                        Device->Length = 0;  // avoid duplication
>> +                        break;
>> +                    }
>>                    }
>> -            }
>>    
>> -            if (!PdoIsMissing(Pdo)) {
>> -                if (PdoIsEjectRequested(Pdo)) {
>> -                    IoRequestDeviceEject(PdoGetDeviceObject(Pdo));
>> -                } else if (Missing) {
>> -                    PdoSetMissing(Pdo, "device disappeared");
>> -
>> -                    // If the PDO has not yet been enumerated then we can
>> -                    // go ahead and mark it as deleted, otherwise we need
>> -                    // to notify PnP manager and wait for the REMOVE_DEVICE
>> -                    // IRP.
>> -                    if (PdoGetDevicePnpState(Pdo) == Present) {
>> -                        PdoSetDevicePnpState(Pdo, Deleted);
>> -                        PdoDestroy(Pdo);
>> -                    } else {
>> -                        NeedInvalidate = TRUE;
>> +                if (!PdoIsMissing(Pdo)) {
>> +                    if (PdoIsEjectRequested(Pdo)) {
>> +                        IoRequestDeviceEject(PdoGetDeviceObject(Pdo));
>> +                    } else if (Missing) {
>> +                        PdoSetMissing(Pdo, "device disappeared");
>> +
>> +                        // If the PDO has not yet been enumerated then we can
>> +                        // go ahead and mark it as deleted, otherwise we need
>> +                        // to notify PnP manager and wait for the REMOVE_DEVICE
>> +                        // IRP.
>> +                        if (PdoGetDevicePnpState(Pdo) == Present) {
>> +                            PdoSetDevicePnpState(Pdo, Deleted);
>> +                            PdoDestroy(Pdo);
>> +                        } else {
>> +                            NeedInvalidate = TRUE;
>> +                        }
>>                        }
>>                    }
>>                }
> 
> With the ported patch, the `if (!PdoIsMissing(Pdo))` check becomes
> subordinate to the `if (Devices != NULL)` check:
> 
>       if (Devices != NULL) {
>           for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
>               // ...
>           }
> 
>           if (!PdoIsMissing(Pdo)) {
>               // ...
>           }
>       }
> 
> Shouldn't it be outside that check (like in Xenvif):
> 
>       if (Devices != NULL) {
>           for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
>               // ...
>           }
>       }
> 
>       if (!PdoIsMissing(Pdo)) {
>           // ...
>       }
> 

Probably. XENVIF is general definitive as it has more widely used and 
has been around for longer; hence has had more debug time.

    Paul


From win-pv-devel-bounces@lists.xenproject.org Wed Jun 11 10:48:03 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Jun 2025 10:48:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1011507.1389963 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPIzx-000497-I2; Wed, 11 Jun 2025 10:48:01 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1011507.1389963; Wed, 11 Jun 2025 10:48:01 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPIzx-000490-FY; Wed, 11 Jun 2025 10:48:01 +0000
Received: by outflank-mailman (input) for mailman id 1011507;
 Wed, 11 Jun 2025 10:48:00 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gLDH=Y2=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uPIzw-00048u-9f
 for win-pv-devel@lists.xenproject.org; Wed, 11 Jun 2025 10:48:00 +0000
Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com
 [2a00:1450:4864:20::332])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 892bdd14-46b1-11f0-b894-0df219b8e170;
 Wed, 11 Jun 2025 12:47:58 +0200 (CEST)
Received: by mail-wm1-x332.google.com with SMTP id
 5b1f17b1804b1-45300c82c1cso13974055e9.3
 for <win-pv-devel@lists.xenproject.org>; Wed, 11 Jun 2025 03:47:57 -0700 (PDT)
Received: from [192.168.4.241] (54-240-197-232.amazon.com. [54.240.197.232])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3a53229de70sm14559380f8f.5.2025.06.11.03.47.56
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 11 Jun 2025 03:47:56 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 892bdd14-46b1-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1749638877; x=1750243677; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:reply-to
         :content-language:references:to:subject:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=8iHfaIZzpKhXN8qmeVwnl/waGYV0W91kHeGwtvZiHUc=;
        b=W0SK3dC1FUAQDq9kUi5X11lmsAA7c+3JoI/Qq79uCDCGcKHHCQqdHFWsKu2PBjcG+2
         L3rCVefDE0rdQav4LM5x13+QyU/vnqXKZZ1dEyHwCAJ1n7ns8sebJhDPRjkCiGOpfCOC
         OtuMX1tp0VhNgMyqtn2rcujlYrvSHo8LuIkeuJVms7hLp9O6iVNgC4JJRS+2wwmemjx8
         vb/JfmreF/eXnokxi4+/KbP/wW3i3JaYwJ+mD8LDE6zoblqTgNBgDblWWEMga6hoyh9b
         nN0y46GFOfnLXIrYI3R0icrFCWChvijPJgw4xqXGyt14lf1IENSxyyBANHXRES+HUP2a
         zbSw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1749638877; x=1750243677;
        h=content-transfer-encoding:in-reply-to:organization:reply-to
         :content-language:references:to:subject:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=8iHfaIZzpKhXN8qmeVwnl/waGYV0W91kHeGwtvZiHUc=;
        b=R8/1Oog3WB9BOrCAhsmuW34mNMpva9qQrLtm5VSb8HtexU0GrWptwFLxjbipCxWV3N
         nJ6iJnvvxQWu+PtsSKPj96QuqQrzorutor3VA0VqFe2GpRm7P7xNNNRuncbKbwtA6A1C
         7y8ptjKdTJhYEkKzj2swpNzrM7IjMzw69zEfB2p9zkLIckXWdMM01om5uXciDc8QrOHJ
         oiJeq9NoE2zzTqROxc1Ps4QH4TZ5Q+D6ldV/1vX9hyxzShO6WO6p9j/b77bvd3i2yX13
         GLCVzyMpACRATPtD29uvYAOOO2Xmgt0KdRoW+1LnVo5nszOH21w/XjoRlECA9jqQE+dW
         yOhQ==
X-Gm-Message-State: AOJu0Yw7oVIUhN4L+fpKMbRHWzB2i8+HB1SW6bKdDBHcK6XwCp21Hd8H
	qtaaeIZIgVMpqwBTcbCP3WwNS6fYh1NLM/HketIH2ZT/7tVZLjsCzv9p93O3Lb0n
X-Gm-Gg: ASbGncvke4a4UwCh0LdbqQ5hJF3Vs28u/R1Yz97ZriJoIUYaJtrpNT2c30baEpeOQc6
	0VramRNVDO2HwFQJauIl6eResvDU7GkcKnBd27T2/XKELqpCpUQb9wF3t3QQTGbCKIKkqv+2oxF
	7ZEjoE74GmjT2t8RyVYN+taqU+NNsDtjibqXBNDhHF03tufbs8ps7LE3jXrs0qozlaGfLUbsWWg
	lTws7FeGeA7bZiJOla+cyHZjUeoHtWY8pMNNEiXORYUMJ2ncgpgoOUP1wtRau5xzMLO0WVp7vx3
	prFuR8c7BzExnCORv4n+kzLAVs2ktCgx6Qnen2fsAtHaQYl25lPtiCeAvbGPRPofAEa5wJNbW2/
	4V2OHauoYdHKKwD4XTg==
X-Google-Smtp-Source: AGHT+IF+kcRC2pn3gRC3qnCq27YsiVBZJ8o0L78jEiKSA9ngKguorN0IEEdk69BYZkQVNPOYM0Ac2w==
X-Received: by 2002:a05:6000:2382:b0:3a4:ee3f:8e1e with SMTP id ffacd0b85a97d-3a558afddeamr2133225f8f.39.1749638876611;
        Wed, 11 Jun 2025 03:47:56 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <dc0a7333-7a08-4536-9ce1-d73c7df9977c@xen.org>
Date: Wed, 11 Jun 2025 11:47:55 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [XENBUS PATCH v2 1/5] Cleanup duplicate error variables in
 TryAutoReboot
To: win-pv-devel@lists.xenproject.org
References: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
 <20250609135941.309-2-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
Reply-To: paul@xen.org
Organization: Xen Project
In-Reply-To: <20250609135941.309-2-ngoc-tu.dinh@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 09/06/2025 15:00, Tu Dinh wrote:
> These variables should also be DWORD instead of HRESULT.
> 

Why? According to the docs I have read StringCbPrintf() returns an HRESULT.

> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
>   src/monitor/monitor.c | 15 +++++++--------
>   1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 185838f..3a166db 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -459,7 +459,6 @@ TryAutoReboot(
>       )
>   {
>       PMONITOR_CONTEXT    Context = &MonitorContext;
> -    HRESULT             Result;
>       DWORD               Type;
>       DWORD               AutoReboot;
>       DWORD               RebootCount;
> @@ -469,7 +468,7 @@ TryAutoReboot(
>       PTCHAR              Description;
>       PTCHAR              Text;
>       DWORD               TextLength;
> -    HRESULT             Error;
> +    DWORD               Error;
>   
>       Length = sizeof (DWORD);
>   
> @@ -547,12 +546,12 @@ TryAutoReboot(
>       if (Text == NULL)
>           goto fail2;
>   
> -    Result = StringCbPrintf(Text,
> -                            TextLength,
> -                            TEXT("%s %s"),
> -                            Description,
> -                            Context->Text);
> -    assert(SUCCEEDED(Result));
> +    Error = StringCbPrintf(Text,
> +                           TextLength,
> +                           TEXT("%s %s"),
> +                           Description,
> +                           Context->Text);
> +    assert(SUCCEEDED(Error));
>   
>       free(DisplayName);
>   



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 11 10:53:49 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Jun 2025 10:53:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1011536.1389997 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPJ5Y-0007E2-Ky; Wed, 11 Jun 2025 10:53:48 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1011536.1389997; Wed, 11 Jun 2025 10:53:48 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPJ5Y-0007Dv-IQ; Wed, 11 Jun 2025 10:53:48 +0000
Received: by outflank-mailman (input) for mailman id 1011536;
 Wed, 11 Jun 2025 10:53:47 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=MjKM=Y2=bounce.vates.tech=bounce-md_30504962.6849602d.v1-da129d642b0f44be8bc0c2bc938ef260@srs-se1.protection.inumbo.net>)
 id 1uPJ5X-0007Dp-33
 for win-pv-devel@lists.xenproject.org; Wed, 11 Jun 2025 10:53:47 +0000
Received: from mail132-4.atl131.mandrillapp.com
 (mail132-4.atl131.mandrillapp.com [198.2.132.4])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 51e02bd6-46b2-11f0-a307-13f23c93f187;
 Wed, 11 Jun 2025 12:53:35 +0200 (CEST)
Received: from pmta09.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail132-4.atl131.mandrillapp.com (Mailchimp) with ESMTP id 4bHMvx1mdHzlfh4B
 for <win-pv-devel@lists.xenproject.org>; Wed, 11 Jun 2025 10:53:33 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 da129d642b0f44be8bc0c2bc938ef260; Wed, 11 Jun 2025 10:53:33 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 51e02bd6-46b2-11f0-a307-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749639213; x=1749909213;
	bh=MuC8VqVENBbMCxeiWdaMDBxke5l4fD66si6TvK/m+B8=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=GVQEhnj3w3PKXswam2iAfTu1kRXbtJEEBOF9HhFQL41CQ2s/N45IbMIwdzR/f+MHh
	 MyKMmedp0ksdl3Xskw9BHjfXcoCy5Hv5MJJdn2Y1eNmdVrEUumrimHG5UK6TeWjS4K
	 ktXVWq7TgC9dur1KhRgi+Gpktld92KTCCNj8Pdr4P0HMyhMigk02Gery2bKMfPV/zB
	 +CQ5tuyIplz/7Ts01+vPV3VWv7JitCNyjkdN9p0Uw8xh3pd1MJ1AQHD4TMLzAjBfYO
	 da4Cnqjq7dFEOpzX++AqrN3+iSveL7RUYF+ZVVkJxQQVjnB7LVw1J3hKGmWKftkDEB
	 LNVmoi+kcNM4A==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749639213; x=1749899713; i=ngoc-tu.dinh@vates.tech;
	bh=MuC8VqVENBbMCxeiWdaMDBxke5l4fD66si6TvK/m+B8=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=aBh+eFGlrAEfn3mLK2v+zaBhJODVZK/7eBCXXZGYeDsTlIoXJhbm6aszB7d1HY8jo
	 pqdZN/X4EAH7ohumzGM2jp2uHpzS7JWGLGiSFXfZzhQxoxmaoNWXvRA//1PdjG3oSo
	 7RHzVg+/J4vTtnraPQhoqZc6u1EKSFBYhys9dxt+1eNPFEAkFVWXDFrdXikF0BUqBn
	 x2mZbjkIo/+4mc6L1TXJsBlVbcwaaThgMby3M99eILZ+Ke2Mxtbmi9EZUORCzo7+DT
	 cBWOKUDeFSdd5lBWOquRhHvsX3CO7TkhQ2f0NDrvAb7WC+wD0EkTqTAdg5+YqbR1O7
	 w1zXKn9McvBsg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[XENBUS=20PATCH=20v2=201/5]=20Cleanup=20duplicate=20error=20variables=20in=20TryAutoReboot?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749639212625
Message-Id: <e4dd2e14-afd7-47ea-9ff6-5016c5f2d27c@vates.tech>
To: paul@xen.org, win-pv-devel@lists.xenproject.org
References: <20250609135941.309-1-ngoc-tu.dinh@vates.tech> <20250609135941.309-2-ngoc-tu.dinh@vates.tech> <dc0a7333-7a08-4536-9ce1-d73c7df9977c@xen.org>
In-Reply-To: <dc0a7333-7a08-4536-9ce1-d73c7df9977c@xen.org>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.da129d642b0f44be8bc0c2bc938ef260?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250611:md
Date: Wed, 11 Jun 2025 10:53:33 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 11/06/2025 12:48, Paul Durrant wrote:
> On 09/06/2025 15:00, Tu Dinh wrote:
>> These variables should also be DWORD instead of HRESULT.
>>
> 
> Why? According to the docs I have read StringCbPrintf() returns an HRESULT.
> 

I saw it used with a bunch of Reg* functions and missed it being used 
with StringCbPrintf as well. I'll split it into two variables then.

Best regards,


 | Vates

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 11 10:57:05 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Jun 2025 10:57:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1011546.1390002 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPJ8i-0007Lv-TM; Wed, 11 Jun 2025 10:57:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1011546.1390002; Wed, 11 Jun 2025 10:57:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPJ8i-0007Lo-Qi; Wed, 11 Jun 2025 10:57:04 +0000
Received: by outflank-mailman (input) for mailman id 1011546;
 Wed, 11 Jun 2025 10:57:03 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gLDH=Y2=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uPJ8h-0007Li-9u
 for win-pv-devel@lists.xenproject.org; Wed, 11 Jun 2025 10:57:03 +0000
Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com
 [2a00:1450:4864:20::32f])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id cd6fc683-46b2-11f0-b894-0df219b8e170;
 Wed, 11 Jun 2025 12:57:01 +0200 (CEST)
Received: by mail-wm1-x32f.google.com with SMTP id
 5b1f17b1804b1-441d437cfaaso41530805e9.1
 for <win-pv-devel@lists.xenproject.org>; Wed, 11 Jun 2025 03:57:01 -0700 (PDT)
Received: from [192.168.4.241] (54-240-197-232.amazon.com. [54.240.197.232])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-4532518dc68sm17434045e9.26.2025.06.11.03.57.00
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 11 Jun 2025 03:57:00 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: cd6fc683-46b2-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1749639421; x=1750244221; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=JXxONJtiLuhwh42M8Z6LKzalU0y1qb3LZYyA6d6pvzc=;
        b=ZawKVsrlhrPdmo31JgElWUsYsvmPP5EGqTKrsWjLH+CgZrkz9fS44E+KyUbx+Pl5Ed
         hLK4aOtOL7Acs4t3Zvqlogp/dEHEg0yuC+FmyxdRfQJIC+YxHZYliWsJUDG5tT75LKnV
         w3Nn8q2Ydi7HU8qogjKZt9d9O21N8fyspfiunzUs46VRyVj9wPBprGv29Hp5DaNN+LOP
         9OTvfegGDRTj4Kr4LKJiuw/64vT76FMXILe5z1e0easkRS19FHgJWCLLMHUK0Ls4RLmR
         yOeGgskzhBjRvPl4PzkcVqJ59YFBDnTgc1hhsrN/60RF1iohN4BGbkkCpCU7kLCcyBL/
         408A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1749639421; x=1750244221;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=JXxONJtiLuhwh42M8Z6LKzalU0y1qb3LZYyA6d6pvzc=;
        b=nkX7q/GKo/DZACEdjznGY9WS/ePWU0AZ28WsFs4u0r/4bd7hZedpQq0uzA5D6KbRY4
         ya4OD1hmBoktajWePS5XdHBf+lm/Qd0TdmRgmamYH0uAIpPfI5ghaWllNTQ2y/5cKHJG
         Tl/lqWofjeE9b4NC/IuLtJDbgEgymKH8HhN361cml+mQr94B0yV70vI3tGIh6xhgenlH
         n0ULg8cPSGfzUdml3XD1/QcBhm/YjQF7W/AxeeRLGHePdOK4WMCpLmZEkq82jiQI4Z5N
         nD38wjjaYALMPKcLNJSZHVNuAKphgH9ObgCv/aG+Mwt/Fs02oSxBYPZvGR7+8bDxLavs
         7PWw==
X-Forwarded-Encrypted: i=1; AJvYcCXoiQEE39dWOrAtO7FUIZvQWqKSDwb6l0rcocGnTle63hOL8TcBbj4ABRGfg51Vnzh6z1P5U26Ta4x5jfY=@lists.xenproject.org
X-Gm-Message-State: AOJu0YyJ+/yuFB8ZB4HAjp9b5i+fcbgE7jhTi1NEaSb3fC9L+gvvDAhN
	/zKFhZiwrkU4FjBT1/3cL4Mrip+zXKNiu16myoboaJMVtFXVeDs0k4cO
X-Gm-Gg: ASbGnctqpNESj7wNbZAY4KhX+mYRx9iaft5TYldjjI57/EbV84HbPLk9lsG3Y7e4YTr
	pYnPD1dbIZ2xVPYLn4Dge6EIZzbvnRlWWeRTaVUTuDOHsy3DpA3E9nHI+YAK5hK/ZVWNmBEGVr0
	IdByZfNfrHGgQyH6SPJumFaX3kAUaE06+JxttyDlXVHxUFnr3zi5RYtxezdk5IvelNSap3ys5GA
	Ky4OvnFiOhaqAxkkuaLolPIStPgncJg+M/yi5XFRGNeO6ccJq8ai79gZu6FcN9+ppKlz1hAGF+Q
	qKageuJPL/hzh9Ofcxf2Wyxl1BYye/FZaeIZoKBiBnJ8Kf0rkROQezwm+LRN8Hbq15LBv2RdyUK
	1DCEBfRjnDD5s3hQJkg==
X-Google-Smtp-Source: AGHT+IHbW0TaWRiYP1C+iBQgQQjuuhNfkMvc3/OIJ1uEfmTZec6NWiRCxcQ/jJqruPiUmoDSjY1Kvg==
X-Received: by 2002:a05:600c:1c02:b0:43c:eeee:b70a with SMTP id 5b1f17b1804b1-45324f06421mr18042585e9.22.1749639420790;
        Wed, 11 Jun 2025 03:57:00 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <4d5cb5f9-5393-44ec-82a3-be09f3f5b984@xen.org>
Date: Wed, 11 Jun 2025 11:56:59 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [XENBUS PATCH v2 2/5] Rework autoreboot retry logic
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
References: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
 <20250609135941.309-3-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <20250609135941.309-3-ngoc-tu.dinh@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 09/06/2025 15:00, Tu Dinh wrote:
> Since autoreboot takes precedence over reboot prompts, reorganize the
> monitor to make TryAutoReboot the reboot entry point instead of
> PromptForReboot.
> 
> - Prompt for reboot from another thread to avoid blocking main thread.
>    Also save the reboot prompt response for later use.
> - Add a new context entry RebootRequestedBy, set in PromptForReboot.
> - Replace the RebootPending check with an one-time check of
>    Context->RebootPrompted at prompt time.
> 
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
>   src/monitor/monitor.c | 442 +++++++++++++++++++++++++++---------------
>   1 file changed, 283 insertions(+), 159 deletions(-)
> 

Reviewed-by: Paul Durrant <paul@xen.org>


From win-pv-devel-bounces@lists.xenproject.org Wed Jun 11 11:08:14 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Jun 2025 11:08:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1011573.1390027 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPJJV-0001cO-5g; Wed, 11 Jun 2025 11:08:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1011573.1390027; Wed, 11 Jun 2025 11:08:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPJJV-0001cH-2H; Wed, 11 Jun 2025 11:08:13 +0000
Received: by outflank-mailman (input) for mailman id 1011573;
 Wed, 11 Jun 2025 11:08:12 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gLDH=Y2=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uPJJU-0001cB-7z
 for win-pv-devel@lists.xenproject.org; Wed, 11 Jun 2025 11:08:12 +0000
Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com
 [2a00:1450:4864:20::433])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 5b7aa9c6-46b4-11f0-b894-0df219b8e170;
 Wed, 11 Jun 2025 13:08:09 +0200 (CEST)
Received: by mail-wr1-x433.google.com with SMTP id
 ffacd0b85a97d-3a5123c1533so3767225f8f.2
 for <win-pv-devel@lists.xenproject.org>; Wed, 11 Jun 2025 04:08:09 -0700 (PDT)
Received: from [192.168.4.241] (54-240-197-232.amazon.com. [54.240.197.232])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3a532464e7fsm14909275f8f.96.2025.06.11.04.08.07
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 11 Jun 2025 04:08:08 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 5b7aa9c6-46b4-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1749640089; x=1750244889; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=exfxKdXX8qKY78+yqb2AumAIFDo4TBxNCAzU9BmE7aY=;
        b=AaHvmPdmF40lj3e0iLuOaoHTwCbc1QB9jn2RcE8kqKbfk8iZc73RfFlb0RzzZIdNkH
         kaaMmu/cN9g9NwcI3t0OHjcuTVQnUhBP/fY/syue1hPj30cp4GzgGZVTYjtL5nG4sqTP
         k1abp0v9xNBen5TiqII1nndGh05F7WGCs9bNzWKAKBJ9yL2yf6awBKQlLv1YnEmoJ+ID
         3ruSNvTb6HkQPD0DxIjBVywq53PV7m5mO6e9we7Kosc0cGYuKjwqat1tmvYU8ysWh01q
         aqMLywWhBcj2ouF6zUOP2tFyssiPxhse3SCoDsTKa2M4mVuFw8gueQCnNN4qDUYpCIJ7
         BP/Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1749640089; x=1750244889;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=exfxKdXX8qKY78+yqb2AumAIFDo4TBxNCAzU9BmE7aY=;
        b=jlzu3FuAfQK6OYHPqmxa81G5x2noECJwduZyd2nsOWQweh1xwAzZrqeya5N5yBHoj9
         QRybN9RuNqtLdl4ihcgbdmHfphVdw5hreFYPh+5gG+/2ipZhCCZaqSP3RO+WGdmvvF25
         V+YNuqSGVGuT6usSvrprB/806GcnNqHkJxVUUym+UatVHRCmUIS0IjP82ZIasXQVYVX2
         j45AGAJ8E62an7y7av5ysi9P1obCrCRow+XsShsjMs7hTRncOgFPFuQyrpapVIjLfHUE
         Buo1OrrS5ToPDL01kKg89sMC5rxtUiBoCl5lj7xNhdXUtch/qKznzNpgree6uP20GwQ5
         ODXA==
X-Forwarded-Encrypted: i=1; AJvYcCXzdPTGSDX2kwdmwELc+Imp5/qE+XKVZ7V7ab4It1ia9SEM4/ljcW+96r/J89L++qYwlSeG72TNaRGSPqg=@lists.xenproject.org
X-Gm-Message-State: AOJu0YyvElnVkO5r0P2Mvv//fRmL5eF6oNgJSxrGumoCF0iVv6lN/yMR
	FRaUZx5KBqebXWoYZfw3PQ1UAJC6rShOI4iDiX9dYhrjgyuPrATENyEt
X-Gm-Gg: ASbGncv17R/S7jUMRPrw6zQ+OIvpTSRLpSohYovfrjWt751/+pt1qNp/SYzkB/z9mDK
	NtH4RNWk7zwNWvJRU0ftowwou9DDvmsDvIfSHdwmavP8TZb+x9QEbj5S+22D2luRJcQGmCAHt6a
	Qd9b29+39Ff94rXmmj3rk8Lf0CKejQFByIxhLNxy9LYrUE8nEj19ZppHEPiZwvqkeSeUMttsrHp
	XJZjLm+TR8QK9Bp9A0DSap9b8ySzneM9xwuZwOfI7Q1tmUNDt7PE+/bevrl+S9cFIYON1yCVWfw
	5ueDEFOdc8GfTKD+LbGY3bAg59UYC6ryau3iIz5Zxz3YnqtlpIugIuMYy/HS0YH1bXw0tjLBFLT
	BU3lb9gaWYOw0xMfpBg==
X-Google-Smtp-Source: AGHT+IELXrmNCNEaCewwiJOSaepdHXcXP+OXTTN3Tn46QlFoBPsf2s0I6dBuiUvO7WL3mvO/jN+9QA==
X-Received: by 2002:a05:6000:290a:b0:3a4:eeeb:7e76 with SMTP id ffacd0b85a97d-3a558aa5ad4mr2052078f8f.9.1749640088492;
        Wed, 11 Jun 2025 04:08:08 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <56bee588-f30b-4477-b43c-8efde3239773@xen.org>
Date: Wed, 11 Jun 2025 12:08:07 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [XENBUS PATCH v2 3/5] Repeat TryAutoReboot() with timer
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
References: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
 <20250609135941.309-4-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <20250609135941.309-4-ngoc-tu.dinh@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 09/06/2025 15:00, Tu Dinh wrote:
> Add a timer that calls TryAutoReboot() every minute if reboot has been
> requested beforehand.
> 
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
>   src/monitor/monitor.c | 38 +++++++++++++++++++++++++++++++++++++-
>   1 file changed, 37 insertions(+), 1 deletion(-)
> 

Reviewed-by: Paul Durrant <paul@xen.org>


From win-pv-devel-bounces@lists.xenproject.org Wed Jun 11 11:09:14 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Jun 2025 11:09:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1011583.1390029 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPJKU-0001iy-8W; Wed, 11 Jun 2025 11:09:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1011583.1390029; Wed, 11 Jun 2025 11:09:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPJKU-0001ir-5w; Wed, 11 Jun 2025 11:09:14 +0000
Received: by outflank-mailman (input) for mailman id 1011583;
 Wed, 11 Jun 2025 11:09:13 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gLDH=Y2=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uPJKT-0001iJ-DD
 for win-pv-devel@lists.xenproject.org; Wed, 11 Jun 2025 11:09:13 +0000
Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com
 [2a00:1450:4864:20::332])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 813ee07c-46b4-11f0-a307-13f23c93f187;
 Wed, 11 Jun 2025 13:09:12 +0200 (CEST)
Received: by mail-wm1-x332.google.com with SMTP id
 5b1f17b1804b1-450cb2ddd46so38460845e9.2
 for <win-pv-devel@lists.xenproject.org>; Wed, 11 Jun 2025 04:09:12 -0700 (PDT)
Received: from [192.168.4.241] (54-240-197-232.amazon.com. [54.240.197.232])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-453251a5ca5sm17799105e9.35.2025.06.11.04.09.10
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 11 Jun 2025 04:09:10 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 813ee07c-46b4-11f0-a307-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1749640152; x=1750244952; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:reply-to
         :content-language:references:to:subject:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=U0S61s7FpUxf5/Y5LRilr+9XU9kdwEGiEBV112NNEvw=;
        b=ONzScgTFAoTlLZk20LKD3PkENFMgLPF6rCaHX+GcaWD/PACExzMlsPbSwKgz5AE7HQ
         kYokXMqR2ZcdfiXtN2faHgOp67cQOvV+VVSs2H8FfTLdht8m5qi6ve6axUXoQ3iTfSWn
         5tdkyfAjrXkTvrJ1zfOndlqhdMR9bs4E40+NjCgrJY004qT78CqjmFUD7Rv/qQHE4dzP
         7yJBRJ+dFttV2V5npOKoyFA4642wI5L6IL4x7Q56m5HvlOpJ55VK6T0dh+v0HDsVjKbv
         y9SMkm8RApLmiBqMDkByw97yAcal5cAzS8vFA9CnJ0DhXmsjbEq5ykLoIma0B0FkGGSZ
         P6Pw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1749640152; x=1750244952;
        h=content-transfer-encoding:in-reply-to:organization:reply-to
         :content-language:references:to:subject:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=U0S61s7FpUxf5/Y5LRilr+9XU9kdwEGiEBV112NNEvw=;
        b=dWGQrJH7oI5Xd0mIy7VXB/5s6S3SmBMSzMZuSv9klHP5ouoURq9aleroOKjb68h1nY
         pHH+ev0fcZ+E8HBYE8bMiKZV2ijgiIsS07XlRoBsiDa3wTSwngv5QpXYo8XF1gs5KyeT
         6z1MTnt5ZVSDDZLM6GWtibSkOOIGyHcrLXS/mSrhEOS5O4jjXt6feKca3YwCXebZnPLb
         8v02SWdLOGB6ncfuw/jHDH8T+qkte9qyrk0Wj6g1Mj3NR4EOrTWvPpnU1qLEd6qN+L80
         nm93rbZ9XPxJIWcEqjclYMgjZ1d0m66JQoCYi7Plj067nAejkdWvuKINJ0mTDGbA0gSG
         lM4w==
X-Gm-Message-State: AOJu0YxIw80PJaI1z9Tjl2F98PcexTuzenTYXfy/f95X2+4MoIjHA/5m
	BlqcYr+MJGIZ5+ppX+DaQRUvdFHtw6omXs/mAFpVNsKggYISk7ruwsvGYNq7RIs7
X-Gm-Gg: ASbGncugK3bGmk8fnEuTPpQPn6fBRENFKdNRMaAiF/o+Isc4P+hMyIdQiE/mwxmyqUE
	eGxxG6/MvWzzIaUF3uZ2Z4AXYDW0USxtWyej2bD8F20pz9d7+bJcN+4B4PnQt+RW2oZBzZLRoeA
	7uC43kmaXAAFnhF5uzm/efNQwfky6XJ+6ZkFT3jeIa7PbXryM2UMg1c0OpCgeuX83N5tCUfM9uu
	l3qy3l23tGAAk/74T15ioF3g9rI04xNgbTaHTUnRWmrds6cXmxgD08Kx4Z2QghHx5OxQG5pJwPC
	WhprwScJA14YeS4mi8yO8JYsBgj+ilesiiwYv+21zOaI2YQrE8xef7p/kfeBNztSLiZFXf3ZY4U
	SEfs7E00W/n0qAKTkHw==
X-Google-Smtp-Source: AGHT+IEICBvJJiELbN8Dk+IQPrVskn8Xs0qOItoCqp1Zo7fLtbGlMgHoe5hh0G/Q+3iAscRVWq7mYA==
X-Received: by 2002:a05:6000:4013:b0:3a4:e2d8:75e2 with SMTP id ffacd0b85a97d-3a5586e8dc1mr2131465f8f.50.1749640151975;
        Wed, 11 Jun 2025 04:09:11 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <7c47c3d6-b491-4594-a0bc-032b64725518@xen.org>
Date: Wed, 11 Jun 2025 12:09:10 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [XENBUS PATCH v2 5/5] Check for active installation before
 autoreboot
To: win-pv-devel@lists.xenproject.org
References: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
 <20250609135941.309-6-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
Reply-To: paul@xen.org
Organization: Xen Project
In-Reply-To: <20250609135941.309-6-ngoc-tu.dinh@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 09/06/2025 15:00, Tu Dinh wrote:
> If the _MSIExecute mutex is set, an MSI installation is under way.
> We don't want to autoreboot in these situations either.
> 
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
>   src/monitor/monitor.c | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)
> 

Reviewed-by: Paul Durrant <paul@xen.org>


From win-pv-devel-bounces@lists.xenproject.org Wed Jun 11 11:11:22 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Jun 2025 11:11:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1011593.1390034 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPJMY-00032A-Dy; Wed, 11 Jun 2025 11:11:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1011593.1390034; Wed, 11 Jun 2025 11:11:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPJMY-000323-BJ; Wed, 11 Jun 2025 11:11:22 +0000
Received: by outflank-mailman (input) for mailman id 1011593;
 Wed, 11 Jun 2025 11:11:21 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gLDH=Y2=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uPJMX-00030h-Kb
 for win-pv-devel@lists.xenproject.org; Wed, 11 Jun 2025 11:11:21 +0000
Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com
 [2a00:1450:4864:20::42d])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id cd8ecc75-46b4-11f0-a307-13f23c93f187;
 Wed, 11 Jun 2025 13:11:20 +0200 (CEST)
Received: by mail-wr1-x42d.google.com with SMTP id
 ffacd0b85a97d-3a35c894313so5724294f8f.2
 for <win-pv-devel@lists.xenproject.org>; Wed, 11 Jun 2025 04:11:20 -0700 (PDT)
Received: from [192.168.4.241] (54-240-197-232.amazon.com. [54.240.197.232])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3a53244df34sm15228377f8f.71.2025.06.11.04.11.19
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 11 Jun 2025 04:11:19 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: cd8ecc75-46b4-11f0-a307-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1749640280; x=1750245080; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=hZnPMk260te80iXfM2CmWgjhdj7u3WnzA/jf1nyDHOk=;
        b=iChCssQwbL9r/NbEjeL4b/eKWDq5/GLVRGbJmYm6NAAATzlEXLwArBytQvEu7Lhh3q
         OweB1rtYwgQ2dQ5Jk041gvwsPmXzIFdp0pPBvD5ZPUXcAHGQVvutaSCc5SL1PUNNlCG/
         eFDoSVSJBXsXDChdWgNLM53PrWE4Vv01UKHN/wY/cv07eOLxqjQGgd+Mhf6zzQoaK/my
         +0w1oFrxOYmqM2U1kW+6rKkY/QqBdhp2g9/c1RCR7hLe2s7EHN11PB3OA1AxceowMR2y
         h7Leul4Le/JXpBpvxBS1r2rhpQGPYOvt7PCgCsTplKf5Q+7sDtJ+uvWACgn0XCRpwq0d
         sigQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1749640280; x=1750245080;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=hZnPMk260te80iXfM2CmWgjhdj7u3WnzA/jf1nyDHOk=;
        b=czss5i3W+S0ohUq1W5kufU3hDTSuVQDaUSocCeWFQ8LFg6WWImZVJoWgKvW6WnqmkW
         /kP8ubwr0QcWqFU1i81oJc4gGtEi+HUkbqP/2Pp4luJ4UxLzOHoUZyArUs3M6nAFdLLI
         nkXqkpGaXtj7O50ZsutieeJMcSu00Lq9NxvQFn5cc6CzyZ35Xtf7cy5kJlpLoP4u7kMa
         1K+zpbXoF0qRIRHGHOO1XJscjhuOR5pgywOfYUmlLK9RAtSenwfFoIxIqpNWWXcrCm1l
         YWsmHJj2gTsbZP/fRTA7yYqSUMG750u2mizb0OtOvwmCBQZC4oYJCYr/5e2Xj4Tt2bYi
         IDVQ==
X-Forwarded-Encrypted: i=1; AJvYcCUv5YZzD2CjtcZaZ/Yr3lMN+T6iHhQDGXDO5IfPAodhH8JP2DtlIIuI2Jty+bpbMN+mzC056E0wRaDdriM=@lists.xenproject.org
X-Gm-Message-State: AOJu0YxcsPl0wn7ZRNYuMoK32BEB15C7Ustgvt/lB3MMxSmtRYV+v46r
	EwdIV5h/BzsPbwfLyhfXVJoX5+ZvgEYaoKz89vaJjE65NWHbOGtBJOic
X-Gm-Gg: ASbGncunq5XOSQgk8vtC3bJPI21HizZwhzCCUTr/vEZma12Ir0RRSzN5sznXdIrFGCJ
	hCuVKozeBwx37Tyt5xdtNDJT8ZPxeZNbU/STcDL9cPUSeaX3X0E/qgfc6UMONxUzm1z0RGKWRKF
	Ky4qgwMUuVcBezk2PGT+sqUHqhSjByNo4z78kK5sThfHvfka84WkWdM3OQw85sslk5gVv/FOfRt
	cD5on47tMpf09AsNn/RGFju8B6eA/CFC8tYdSk/lggQb3ZKlgHDiWWNCkp4GOeKObm0W5itPjAv
	7i7r6oBnHh0fnNMHTsKmMiRJErgtIq+PJMwryIWtTPoNUTUHHqZ/yuKkhomrswh0uoFSkrgEZ5Y
	bB7jHlBRAGPAh2Zg4rQ==
X-Google-Smtp-Source: AGHT+IEBQNapnySHK7sg2U6I9Ym39oFJgzr4UwueDVpqLVQP/oxe3xD88ux3Cbn5O0DQayBKYV79RA==
X-Received: by 2002:a05:6000:22c1:b0:3a5:300d:ead0 with SMTP id ffacd0b85a97d-3a558a1aedbmr2248330f8f.43.1749640279995;
        Wed, 11 Jun 2025 04:11:19 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <da350c67-2b9b-4c1a-ba2c-8b1278c82cb8@xen.org>
Date: Wed, 11 Jun 2025 12:11:18 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [XENBUS PATCH 1/2] Use Windows 10 APIs to inflate/deflate
 balloon.
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
References: <20250609140543.1454-1-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <20250609140543.1454-1-ngoc-tu.dinh@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 09/06/2025 15:06, Tu Dinh wrote:
> Windows 10 provides MM_ALLOCATE_AND_HOT_REMOVE to remove pages from
> the physical memory pool. The removed pages can be added back with
> MmAddPhysicalMemory.
> 
> Implement balloon inflation using calls to MmAddPhysicalMemory on
> contiguous PFN ranges.

Can you put something in the commit comment to say why this is an 
improvement?


From win-pv-devel-bounces@lists.xenproject.org Wed Jun 11 12:37:02 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Jun 2025 12:37:02 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1011677.1390141 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPKhR-00025E-Dq; Wed, 11 Jun 2025 12:37:01 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1011677.1390141; Wed, 11 Jun 2025 12:37:01 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPKhR-000257-BJ; Wed, 11 Jun 2025 12:37:01 +0000
Received: by outflank-mailman (input) for mailman id 1011677;
 Wed, 11 Jun 2025 12:37:00 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=K+vp=Y2=bounce.vates.tech=bounce-md_30504962.68497868.v1-27f68b4669e04e02bfb08857a7a96227@srs-se1.protection.inumbo.net>)
 id 1uPKhQ-000251-L8
 for win-pv-devel@lists.xenproject.org; Wed, 11 Jun 2025 12:37:00 +0000
Received: from mail36.us4.mandrillapp.com (mail36.us4.mandrillapp.com
 [205.201.136.36]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id c320a30f-46c0-11f0-b894-0df219b8e170;
 Wed, 11 Jun 2025 14:36:57 +0200 (CEST)
Received: from pmta15.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail36.us4.mandrillapp.com (Mailchimp) with ESMTP id 4bHQCD3CT5zS62MB5
 for <win-pv-devel@lists.xenproject.org>; Wed, 11 Jun 2025 12:36:56 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 27f68b4669e04e02bfb08857a7a96227; Wed, 11 Jun 2025 12:36:56 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: c320a30f-46c0-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749645416; x=1749915416;
	bh=6gflSudvFWcTkhv1+7MnuZ6fpKRUychXbUpmbP3D/yk=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=G8Sl5BOTR29JodljwGOgCwE5ICfD7Z2Ha4d2kxs1N3z7tsri1Sg3mVuEBI6orIh0v
	 dcd/IEW5VmZuzm9pm1RlMFlIvS4TK9DHuvfP3zxgd0XwzdYMH8/GHummRyl2ze8HA3
	 ET6MOZ+RZB/OAbGU5IixIRASBcOSh4sDoNLuxvp9nGupa/mKqyCB/HcCzfKPbYRBMc
	 /ZYqOw5eG7jUFExpjPFfS9pB3i7hduk0k7KkTlB/Lkj/+Wv6xsS3Mr4O4IsOsI8Wb6
	 XsdqchGqv+8a1tyib6IC7FDwIxJping+1RJ4Oem4gkgol8tffjqLCIdv9M1YtluZhW
	 o3G86jV1PBMew==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749645416; x=1749905916; i=ngoc-tu.dinh@vates.tech;
	bh=6gflSudvFWcTkhv1+7MnuZ6fpKRUychXbUpmbP3D/yk=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=FW2+btGZBc4mxb+gB/aAqgqJw7pARt03EA9MWIRTsgSsuEycwSiYKqVGN6RASufpI
	 Bmi4ITq7FdBP5HCK6tENL0x+s1I5vNND+RuH9HSy3ZdJNak6mQKCrHOvpIMgMILVCp
	 o06SdNEqt41DmghqRwnONLviqItuKf454m5YL/Z+7Rh+4vxhpaUnXotvILxwlynL8u
	 0Nq4eBililCxSF5penfGtpcTvF2hrUk8ZNmdNX8Crck88YTOZLyzgj5GEp0MnJu0VR
	 MQ1i9QwF5Z3xwA2BFUROHApPLhpUB7f7qtmscob9lS8PL/ouHVMUqEK35RRlNI4hKe
	 +VGccSV5O22jw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v2=201/2]=20Use=20Windows=2010=20APIs=20to=20inflate/deflate=20balloon?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749645415568
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250611123641.192-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.27f68b4669e04e02bfb08857a7a96227?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250611:md
Date: Wed, 11 Jun 2025 12:36:56 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Currently the balloon driver allocates pages as normal memory, which
causes Windows to report the ballooned memory as kernel-allocated
instead of unavailable.

Windows 10 provides MM_ALLOCATE_AND_HOT_REMOVE to remove pages from
the physical memory pool. The removed pages can be added back with
MmAddPhysicalMemory.

Using this feature, the real VM memory capacity will be correctly
reported in Task Manager.

Balloon deflation is implemented using calls to MmAddPhysicalMemory on
contiguous PFN ranges.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
v2: Updated commit message to say what the patch does. No code change.
---
 src/xenbus/balloon.c | 38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/xenbus/balloon.c b/src/xenbus/balloon.c
index 8d7e2c2..690e45f 100644
--- a/src/xenbus/balloon.c
+++ b/src/xenbus/balloon.c
@@ -194,6 +194,7 @@ BalloonSort(
         ASSERT3U(PfnArray[Index], <, PfnArray[Index + 1]);
 }
 
+__drv_requiresIRQL(PASSIVE_LEVEL)
 static PMDL
 BalloonAllocatePagesForMdl(
     IN  ULONG       Count
@@ -205,6 +206,8 @@ BalloonAllocatePagesForMdl(
     SIZE_T          TotalBytes;
     PMDL            Mdl;
 
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
     LowAddress.QuadPart = 0ull;
     HighAddress.QuadPart = ~0ull;
     SkipBytes.QuadPart = 0ull;
@@ -215,7 +218,8 @@ BalloonAllocatePagesForMdl(
                                   SkipBytes,
                                   TotalBytes,
                                   MmCached,
-                                  MM_DONT_ZERO_ALLOCATION);
+                                  MM_DONT_ZERO_ALLOCATION |
+                                  MM_ALLOCATE_AND_HOT_REMOVE);
     if (Mdl == NULL)
         goto done;
 
@@ -238,6 +242,9 @@ BalloonFreePagesFromMdl(
 {
     volatile UCHAR  *Mapping;
     ULONG           Index;
+    PPFN_NUMBER     Pfn;
+    PFN_NUMBER      RangeStart, RangeEnd;
+    NTSTATUS        Status;
 
     if (!Check)
         goto done;
@@ -280,7 +287,34 @@ BalloonFreePagesFromMdl(
     MmUnmapLockedPages((PVOID)Mapping, Mdl);
 
 done:
-    MmFreePagesFromMdl(Mdl);
+    Pfn = MmGetMdlPfnArray(Mdl);
+
+    RangeStart = 0;
+    while (RangeStart < (MmGetMdlByteCount(Mdl) >> PAGE_SHIFT)) {
+        PHYSICAL_ADDRESS    StartAddress;
+        LARGE_INTEGER       NumberOfBytes;
+
+        for (RangeEnd = RangeStart;
+             RangeEnd < (MmGetMdlByteCount(Mdl) >> PAGE_SHIFT);
+             RangeEnd++) {
+            if (Pfn[RangeEnd] != Pfn[RangeStart] + (RangeEnd - RangeStart))
+                break;
+        }
+
+        StartAddress.QuadPart = Pfn[RangeStart] << PAGE_SHIFT;
+        NumberOfBytes.QuadPart = (RangeEnd - RangeStart) << PAGE_SHIFT;
+
+        Status = MmAddPhysicalMemory(&StartAddress, &NumberOfBytes);
+        if (!NT_SUCCESS(Status)) {
+            Error("MmAddPhysicalMemory failed: %08x (PFN %llx + %llx pages)\n",
+                  Status,
+                  Pfn[RangeStart],
+                  RangeEnd - RangeStart);
+            break;
+        }
+
+        RangeStart = RangeEnd;
+    }
 }
 
 #define XENBUS_BALLOON_MIN_PAGES_PER_S 1000ull
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 11 12:37:08 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Jun 2025 12:37:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1011678.1390146 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPKhY-00027M-Fd; Wed, 11 Jun 2025 12:37:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1011678.1390146; Wed, 11 Jun 2025 12:37:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPKhY-00027F-Cr; Wed, 11 Jun 2025 12:37:08 +0000
Received: by outflank-mailman (input) for mailman id 1011678;
 Wed, 11 Jun 2025 12:37:07 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=uVX2=Y2=bounce.vates.tech=bounce-md_30504962.68497868.v1-e9404466999149fbbb37a36fc51c6eff@srs-se1.protection.inumbo.net>)
 id 1uPKhX-000251-Pt
 for win-pv-devel@lists.xenproject.org; Wed, 11 Jun 2025 12:37:07 +0000
Received: from mail132-4.atl131.mandrillapp.com
 (mail132-4.atl131.mandrillapp.com [198.2.132.4])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id c350a9c2-46c0-11f0-b894-0df219b8e170;
 Wed, 11 Jun 2025 14:36:58 +0200 (CEST)
Received: from pmta09.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail132-4.atl131.mandrillapp.com (Mailchimp) with ESMTP id 4bHQCD4FzJzlfcsq
 for <win-pv-devel@lists.xenproject.org>; Wed, 11 Jun 2025 12:36:56 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 e9404466999149fbbb37a36fc51c6eff; Wed, 11 Jun 2025 12:36:56 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: c350a9c2-46c0-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749645416; x=1749915416;
	bh=emnci1kgGIh1ariwdR1huX9RqZPw55dTxNSi5cmM6ZU=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=BgNHdAwGAFEGLuPIXEEAqeKJnrMtjJ3TGRsjfa9EFApEafiA7ZJ475V5nUliQN12P
	 rCBki75/+JsNEFSXwyo4J/q8pRwwvM/WCytVDrADYFXwLoDB5LT4JMESYSOewbCiov
	 pdUSXCqcfX/+tQZnbBBgp5RbTkTHK3SGCj6nL3XTSy8oK+kK9VHXwJda+nouZrMkaB
	 GCT/FJmEeldZvvWe/likhttEKz6HvlUET1/HamPKktU3JZgG5IaZWxseSMTHFYKMKS
	 TvNwyd7hdnlczL2H881K72sjHHUj+NA0O9g5QOLC9zL9eS0UXlJIn+Mr4zB5ooMccf
	 YyWItj8jU52dg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749645416; x=1749905916; i=ngoc-tu.dinh@vates.tech;
	bh=emnci1kgGIh1ariwdR1huX9RqZPw55dTxNSi5cmM6ZU=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=d+R5ptL1P9VTAAQ24QFuladSqxvTdA7S0RL7dYgTKg4In27uSuCF0vXh/eE6enYSc
	 oY7JXHZNIjqdppeukseBF0CbpHyUph67gKMXKPuPXvwJxEOUBLLGPZ6GO6nbH95Pl1
	 FHYxGIzmkyq+n4qmwemMDU1mFmGceBM7WfHmgteHcuyKRc8i2XFalcw5n1uG9jHDqP
	 zWqai6KyU3yzr7pFn3Gp8xAJkp2wfEo5O4PyzCOeMSdOsNVId1TkGeUKBUAbQUsPR3
	 6KMX+O1NoLHvJIQjJxNzYhqguujPHAOpn1RbimRCtiK3fE1t7rcE/XH1sWQM1OunPJ
	 zvl+EDsvzMO4A==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v2=202/2]=20balloon:=20Specify=20MM=5FALLOCATE=5FPREFER=5FCONTIGUOUS?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749645415907
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250611123641.192-2-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250611123641.192-1-ngoc-tu.dinh@vates.tech>
References: <20250611123641.192-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.e9404466999149fbbb37a36fc51c6eff?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250611:md
Date: Wed, 11 Jun 2025 12:36:56 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

This flag, available from Windows 7, instructs the kernel allocator to
avoid physical memory fragmentation.

Tested on Server 2022 by decreasing memory from 8GB->5GB:
* Before: 98 balloon allocations containing 6518 contiguous ranges
* After: 98 balloon allocations containing 649 contiguous ranges

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenbus/balloon.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/xenbus/balloon.c b/src/xenbus/balloon.c
index 690e45f..e1d0e94 100644
--- a/src/xenbus/balloon.c
+++ b/src/xenbus/balloon.c
@@ -219,6 +219,7 @@ BalloonAllocatePagesForMdl(
                                   TotalBytes,
                                   MmCached,
                                   MM_DONT_ZERO_ALLOCATION |
+                                  MM_ALLOCATE_PREFER_CONTIGUOUS |
                                   MM_ALLOCATE_AND_HOT_REMOVE);
     if (Mdl == NULL)
         goto done;
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Jun 12 09:08:51 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 12 Jun 2025 09:08:51 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1012597.1391086 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPdvV-0002xo-D2; Thu, 12 Jun 2025 09:08:49 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1012597.1391086; Thu, 12 Jun 2025 09:08:49 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPdvV-0002xh-A5; Thu, 12 Jun 2025 09:08:49 +0000
Received: by outflank-mailman (input) for mailman id 1012597;
 Thu, 12 Jun 2025 09:08:48 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=taIv=Y3=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uPdvU-0002xb-OJ
 for win-pv-devel@lists.xenproject.org; Thu, 12 Jun 2025 09:08:48 +0000
Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com
 [2a00:1450:4864:20::42d])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id d9505588-476c-11f0-a309-13f23c93f187;
 Thu, 12 Jun 2025 11:08:47 +0200 (CEST)
Received: by mail-wr1-x42d.google.com with SMTP id
 ffacd0b85a97d-3a507e88b0aso766480f8f.1
 for <win-pv-devel@lists.xenproject.org>; Thu, 12 Jun 2025 02:08:47 -0700 (PDT)
Received: from [192.168.29.179] (54-240-197-239.amazon.com. [54.240.197.239])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3a561a3c936sm1384586f8f.57.2025.06.12.02.08.46
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Thu, 12 Jun 2025 02:08:46 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: d9505588-476c-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1749719327; x=1750324127; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=pPKu6N8h00Qdb2pPq6MVRAOPCeB2SIlSuXK9zM+nzSA=;
        b=TalkWPc0E1q7Nuv+UNxHQ+DL0y7xsu9+lA5KeKHBRb+j7FM9JvpVFM3YVc1HN+YlGh
         7H5jTkGSXJdJNEJOTzFmrz2h4igQpi95Z6FG91dnTgZIEqmTbUpY7KDgwsr+ILTLYAc1
         qbh4pvcNJIVzzF0RBUbZ97OBggEPM0AYqRjB7uZzvURasc8+xHR7x0b9UXg4juPPBNcY
         xysjK/MSkIVYugp/E9ghfnv1xYfcLVYUmYyMEZXp0hIURVBs7ex/KQAjnFAdbNWgLgDj
         FSq2Xx0hOEqmCNOdXnrY3yaXnk14EVnuUBTsVe5M8mzIf9FFsLjHuQakmoIqBZVYPKgy
         k7xQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1749719327; x=1750324127;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=pPKu6N8h00Qdb2pPq6MVRAOPCeB2SIlSuXK9zM+nzSA=;
        b=a+LJBP3y8tZP+QN9UDtSD7R6fD5FyCriA36OwxZJtvmqUzXb4mSbZws9TBwMm82zkq
         zsPyNyK1+8ePrNyUyWRUeM2Ucx3OkizOYqz3IRW1FnhxSGndiIh9lHy1eUBabJ/hDNCq
         KANP4FnnMbKfBrJTFN6WZoJL0ERFP6MkYp7YCI6Q4TT4sduNLA0LPySOLgQM2ySA5dfe
         83wme3L/udCd6QzCbmiBIFQNH20eyKBOEgILt3lxDlZHxOZvFJF+bca3k54+0N4QIgML
         XD9HCoJ2QKZg5cf+k+ZFX7HzUL/VRTZBJAS66+o1XLZUkfUkwBOtExIHQ1C2NjsfJ9QC
         2PjA==
X-Forwarded-Encrypted: i=1; AJvYcCXLDQgcaOMf6qfwN3rHg33ym9ljN1I7bmi+bCNfEOC0PNoHphsC+fMopIkrg+6TADtmig1oxtZl941sb4g=@lists.xenproject.org
X-Gm-Message-State: AOJu0YxZ4UBS1zXV6KWayZAXJEixmWychVIF7zDHEdgNaQZs9h2pBNNz
	ZLWeAp9mnHxdFX04AT9UsawxCCpI0QbWNKQypzDKQX+M89rWuLGJbycJ
X-Gm-Gg: ASbGncscYVxv9ogncuPFawi/EGZXaK+ixCUNq/ph5mfPcJJ38JtGfDgcPXPCt+q013m
	ONVgKlgvN+bGe/KBb6lRBvO67HZA9OhF5oX5UzKveLE4ZwP59jmXKmh9YJz55d5mhIi9tQ2nuJa
	sR9k7yHXcIa65wDNFJJVlLt+W0ElbvBAvM3rXrNV6Io6NSFYFh4cFXFR7ci2GryJkUcuJpkP8/c
	zp7EVRDYGc1nCPWYbCs/YbZnK505Wtp3Un1SvXK8TtL5E1LL4QRZBfAgiS3DKcgbgwsKh/HYqdq
	6LQm2z1FcYWs07FQDVi31RHtVnQyNipme0ICfmzWkvWYwCOlneLgkO7/qFXK1INrj7eJVuYkPX5
	XP36L/Sjdirp95KvxuzQ=
X-Google-Smtp-Source: AGHT+IEv3BLLxPEtGU2x3pXpmOvmcaymjRpFeHWibe7b9GHCR1+MmePVTC8ne/ZF5HZa3KyfM/j/YQ==
X-Received: by 2002:a05:6000:2089:b0:3a4:c713:7d8 with SMTP id ffacd0b85a97d-3a56075f9bcmr2158271f8f.16.1749719326995;
        Thu, 12 Jun 2025 02:08:46 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <ee147fb7-4c6f-4456-a2a7-5fa80214ffcd@xen.org>
Date: Thu, 12 Jun 2025 10:08:45 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [XENBUS PATCH v2 1/2] Use Windows 10 APIs to inflate/deflate
 balloon
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
References: <20250611123641.192-1-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <20250611123641.192-1-ngoc-tu.dinh@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 11/06/2025 13:36, Tu Dinh wrote:
> Currently the balloon driver allocates pages as normal memory, which
> causes Windows to report the ballooned memory as kernel-allocated
> instead of unavailable.
> 
> Windows 10 provides MM_ALLOCATE_AND_HOT_REMOVE to remove pages from
> the physical memory pool. The removed pages can be added back with
> MmAddPhysicalMemory.
> 
> Using this feature, the real VM memory capacity will be correctly
> reported in Task Manager.
> 
> Balloon deflation is implemented using calls to MmAddPhysicalMemory on
> contiguous PFN ranges.
> 
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
> v2: Updated commit message to say what the patch does. No code change.
> ---
>   src/xenbus/balloon.c | 38 ++++++++++++++++++++++++++++++++++++--
>   1 file changed, 36 insertions(+), 2 deletions(-)
> 

Reviewed-by: Paul Durrant <paul@xen.org>


From win-pv-devel-bounces@lists.xenproject.org Thu Jun 12 09:10:02 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 12 Jun 2025 09:10:02 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1012606.1391090 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPdwg-0003Cg-Gu; Thu, 12 Jun 2025 09:10:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1012606.1391090; Thu, 12 Jun 2025 09:10:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPdwg-0003CN-Dz; Thu, 12 Jun 2025 09:10:02 +0000
Received: by outflank-mailman (input) for mailman id 1012606;
 Thu, 12 Jun 2025 09:10:01 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=taIv=Y3=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uPdwf-00035C-A3
 for win-pv-devel@lists.xenproject.org; Thu, 12 Jun 2025 09:10:01 +0000
Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com
 [2a00:1450:4864:20::336])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 03de4ef1-476d-11f0-b894-0df219b8e170;
 Thu, 12 Jun 2025 11:09:59 +0200 (CEST)
Received: by mail-wm1-x336.google.com with SMTP id
 5b1f17b1804b1-45024721cbdso5772395e9.2
 for <win-pv-devel@lists.xenproject.org>; Thu, 12 Jun 2025 02:09:59 -0700 (PDT)
Received: from [192.168.29.179] (54-240-197-231.amazon.com. [54.240.197.231])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3a561b4b5afsm1368601f8f.75.2025.06.12.02.09.57
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Thu, 12 Jun 2025 02:09:58 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 03de4ef1-476d-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1749719398; x=1750324198; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=g4vssVfAV4LNkBlyE3ZO5X3yjTkNM9HdGoSYsKlamrs=;
        b=jLu7uL4ffjQ1RsV9qBF5orFrsXqXpH2Xstb2pbBUCeI8S6vfugG4LJPid+sbV/wPfp
         gGXKa15aM5YRy0GbVCexe5divnDQ0gZjY4BTkR7pANjsqKV+JIv8xqFoialYBV2G5BDe
         wh2YWjnpY9MTrbVkJDYLuXYp8cXK85dVyAffnyV9vLXK+ABN0WE5teWVuRBeuL5qpktM
         EdutL+EJTs8u3HBXnqOiGhQzo6mn9o46jcxipNeAeDJ0uv/fI5F6nZFZiSo+5J7xUuMX
         x9IzkY+yicyiBPjOHufE0l2Wu4NvWzrXweA+C0EdvcuZKBe3lpui4P8PGp9IFCA82KJF
         LD6A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1749719398; x=1750324198;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=g4vssVfAV4LNkBlyE3ZO5X3yjTkNM9HdGoSYsKlamrs=;
        b=Ekw9o5Wd2AgBJ4+apGVGaor92lRVFo1xedhPOSt6i7BlcHtttaTOPoVeC0CxqH+sbR
         Czc+J0sJBayrRbJ6q5RiyWwUlReiqLP/0D/4/oVsEn0Fl3Avu4+/LfjejVcgDhqE3VOh
         76keVcc0HRha30Rc+4r+NkmrJsvxyX7P0TxE1Ecc9SORYHpw2A1XeNqQ/8ggl3zCN0NY
         mkpS3ULaYE7h4xa2nUmPuzsGF54CXSLmqKRotDYdKxcwny+FOqWV2dDE1G4ntx+AVyNd
         MduGCVx+yae+6bJZSAdvDZJYH87XZFBfB+MDpodSTU/Um1QMgZucch78xi6wgS8nMnib
         vZKg==
X-Forwarded-Encrypted: i=1; AJvYcCUCZKlsxLzhCPH++D2U4wus5upgh0ZQP1ej/+PhTXo2vGHHvE4B9ZK7HYFHAblke3PfxZb3z8UkM/QaKiU=@lists.xenproject.org
X-Gm-Message-State: AOJu0Yxs2tVw1nyt4JzxQn8zeC8JOoxBN5puGZh3LRxPPZTcpqFV01My
	kdG64MZxW8/6ZB7JHJoX2F8z+9gxKT9/aE7grFyZytNjpNx/rd36TuL6
X-Gm-Gg: ASbGnctWKpqjvIZQ/3EyDAkcssahIIizvsBCz956nORKl3rdPPWMbW+TeLTPgXKmbTm
	bkDGtBtkUU6/7kUok8nHNIwoVt6LzUwy8qc9AeXpGaZ8xBCPl3s7wzg5E4/MbIUk30edN3aABmU
	TWYs1GLmgKAavfuUKp3DLZqHQtHaEeXfmX79FIcUzDoWtsbu0h788ElYggnCa0DpRTPqSbyoLmU
	FnDi0floaGo6ElJ/5To4t07J2qjL5rbSbHuQch0E/0zPs0Twm+RWBdTbERrzqBWPbhoS8+LogLm
	AgREYlQLfuyOIgFhJMH0XrEMUPR4MpN8vMVwREIK0ilAoEeoZj+G8lO/IBdCORQbGTaLQwb2eJW
	NZAL7NqEqPOub3Z5re/g=
X-Google-Smtp-Source: AGHT+IF6i+WTVdDBOM9kPZU1D1jfBzeMb0FpDmgO3gfeTt7ajaPQIp/kvnBaJHD9K7kxAkQEDJ6bCQ==
X-Received: by 2002:a05:6000:18a7:b0:3a4:dbac:2dc1 with SMTP id ffacd0b85a97d-3a558a437b7mr5095897f8f.54.1749719398486;
        Thu, 12 Jun 2025 02:09:58 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <f96f3e7b-d560-43f6-abfb-331b0314aa7a@xen.org>
Date: Thu, 12 Jun 2025 10:09:57 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [XENBUS PATCH v2 2/2] balloon: Specify
 MM_ALLOCATE_PREFER_CONTIGUOUS
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
References: <20250611123641.192-1-ngoc-tu.dinh@vates.tech>
 <20250611123641.192-2-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <20250611123641.192-2-ngoc-tu.dinh@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 11/06/2025 13:36, Tu Dinh wrote:
> This flag, available from Windows 7, instructs the kernel allocator to
> avoid physical memory fragmentation.
> 
> Tested on Server 2022 by decreasing memory from 8GB->5GB:
> * Before: 98 balloon allocations containing 6518 contiguous ranges
> * After: 98 balloon allocations containing 649 contiguous ranges
> 
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
>   src/xenbus/balloon.c | 1 +
>   1 file changed, 1 insertion(+)
> 

Reviewed-by: Paul Durrant <paul@xen.org>


From win-pv-devel-bounces@lists.xenproject.org Thu Jun 12 11:00:47 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 12 Jun 2025 11:00:47 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1012842.1391358 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPffr-00014B-A2; Thu, 12 Jun 2025 11:00:47 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1012842.1391358; Thu, 12 Jun 2025 11:00:47 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPffr-000144-6t; Thu, 12 Jun 2025 11:00:47 +0000
Received: by outflank-mailman (input) for mailman id 1012842;
 Thu, 12 Jun 2025 11:00:46 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=VAjE=Y3=bounce.vates.tech=bounce-md_30504962.684ab356.v1-349c1c8ac37d41dd9a0ae4c6408d2699@srs-se1.protection.inumbo.net>)
 id 1uPffq-00013w-DW
 for win-pv-devel@lists.xenproject.org; Thu, 12 Jun 2025 11:00:46 +0000
Received: from mail36.us4.mandrillapp.com (mail36.us4.mandrillapp.com
 [205.201.136.36]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 79ead547-477c-11f0-b894-0df219b8e170;
 Thu, 12 Jun 2025 13:00:43 +0200 (CEST)
Received: from pmta15.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail36.us4.mandrillapp.com (Mailchimp) with ESMTP id 4bJ01g06ftzS62Lnj
 for <win-pv-devel@lists.xenproject.org>; Thu, 12 Jun 2025 11:00:39 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 349c1c8ac37d41dd9a0ae4c6408d2699; Thu, 12 Jun 2025 11:00:38 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 79ead547-477c-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749726039; x=1749996039;
	bh=DWWTpGtFv6ljO5FJygjmjsZrbOIXicgYKql8Vnmyqlo=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=zmeYQTEzUzx4A6nbGlNP/To4PATDOTZbox3mNFxNKCtLTprWvSv7NvzkaluFMpZkF
	 BHGrrnBSV0K+YSaGsQ3Vu60EJuukopAQqwrqcw5l8t/G9aCS17vphVGpguj9Smrkq7
	 dlymsm33l+MigmIB9+mdppN665feUCpcxf21GduE8OFm1xi8AwESEE2Zr+dU0gAIhH
	 Jx3rHpqd+HXE6I5srG8j2CYxNfrjHe0ORYtoZkcUsV5FAUI+gW3oeQ1KECQqoWmJNZ
	 jzKM7/x77w1HCmiKrFUVI1Xf2z67RrURFU/ig3X7fbXgwlhDKv/TMsLlLqp8uPuy+f
	 17s8PPkEUGrXA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749726039; x=1749986539; i=ngoc-tu.dinh@vates.tech;
	bh=DWWTpGtFv6ljO5FJygjmjsZrbOIXicgYKql8Vnmyqlo=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=pD98WGObEDYqQhffLwIaI3+2PKkNhoMZDpFnS/BTGv2ZpYAo13Ir88+4597p++gew
	 B0VXBWk2ZoJL7YPt+xV+S5hyEQdgf6HhDyDCX17Vf7ck6J70FAZRN6eBCUGCOM34oo
	 7V9opc+APbVNOwVBfU+TcoBB6J8wDnKnwMugPNYX5et7h29rqQMFpeENEHE2M0gqNT
	 /YypLXoGLpd/9IdDgfR+dIhIOCo/0vPt/vZViUQnZ5T1cKGx7vFvH739fCOR5NmcaK
	 1fKVWVh3H62NlOtwT7UscQ3MlU8sP/uUfcqHflBMgrYmmO04Vjxri5J2ENdPiIb4Z/
	 HxTNJEiYP1RNg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v3=201/2]=20Use=20Windows=2010=20APIs=20to=20inflate/deflate=20balloon?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749726038112
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250612110018.1493-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.349c1c8ac37d41dd9a0ae4c6408d2699?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250612:md
Date: Thu, 12 Jun 2025 11:00:38 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Currently the balloon driver allocates pages as normal memory, which
causes Windows to report the ballooned memory as kernel-allocated
instead of unavailable.

Windows 10 provides MM_ALLOCATE_AND_HOT_REMOVE to remove pages from
the physical memory pool. The removed pages can be added back with
MmAddPhysicalMemory.

Using this feature, the real VM memory capacity will be correctly
reported in Task Manager.

Balloon deflation is implemented using calls to MmAddPhysicalMemory on
contiguous PFN ranges.

Note that MM_ALLOCATE_AND_HOT_REMOVE actually removes the pages from
memory space, so the resulting MDL will have the MDL_IO_SPACE flag;
similarly, when probing the freed MDL on deflation, we'll also have to
set MDL_IO_SPACE.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
v3: Fix the issue where hot-removed memory will be in I/O space.
v2: Updated commit message to say what the patch does. No code change.
---
 src/xenbus/balloon.c | 43 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 38 insertions(+), 5 deletions(-)

diff --git a/src/xenbus/balloon.c b/src/xenbus/balloon.c
index 8d7e2c2..528928c 100644
--- a/src/xenbus/balloon.c
+++ b/src/xenbus/balloon.c
@@ -194,6 +194,7 @@ BalloonSort(
         ASSERT3U(PfnArray[Index], <, PfnArray[Index + 1]);
 }
 
+__drv_requiresIRQL(PASSIVE_LEVEL)
 static PMDL
 BalloonAllocatePagesForMdl(
     IN  ULONG       Count
@@ -205,6 +206,8 @@ BalloonAllocatePagesForMdl(
     SIZE_T          TotalBytes;
     PMDL            Mdl;
 
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
     LowAddress.QuadPart = 0ull;
     HighAddress.QuadPart = ~0ull;
     SkipBytes.QuadPart = 0ull;
@@ -215,7 +218,8 @@ BalloonAllocatePagesForMdl(
                                   SkipBytes,
                                   TotalBytes,
                                   MmCached,
-                                  MM_DONT_ZERO_ALLOCATION);
+                                  MM_DONT_ZERO_ALLOCATION |
+                                  MM_ALLOCATE_AND_HOT_REMOVE);
     if (Mdl == NULL)
         goto done;
 
@@ -223,8 +227,7 @@ BalloonAllocatePagesForMdl(
                              MDL_PARTIAL_HAS_BEEN_MAPPED |
                              MDL_PARTIAL |
                              MDL_PARENT_MAPPED_SYSTEM_VA |
-                             MDL_SOURCE_IS_NONPAGED_POOL |
-                             MDL_IO_SPACE)) == 0);
+                             MDL_SOURCE_IS_NONPAGED_POOL)) == 0);
 
 done:
     return Mdl;
@@ -238,6 +241,9 @@ BalloonFreePagesFromMdl(
 {
     volatile UCHAR  *Mapping;
     ULONG           Index;
+    PPFN_NUMBER     Pfn;
+    PFN_NUMBER      RangeStart, RangeEnd;
+    NTSTATUS        Status;
 
     if (!Check)
         goto done;
@@ -280,7 +286,34 @@ BalloonFreePagesFromMdl(
     MmUnmapLockedPages((PVOID)Mapping, Mdl);
 
 done:
-    MmFreePagesFromMdl(Mdl);
+    Pfn = MmGetMdlPfnArray(Mdl);
+
+    RangeStart = 0;
+    while (RangeStart < (MmGetMdlByteCount(Mdl) >> PAGE_SHIFT)) {
+        PHYSICAL_ADDRESS    StartAddress;
+        LARGE_INTEGER       NumberOfBytes;
+
+        for (RangeEnd = RangeStart;
+             RangeEnd < (MmGetMdlByteCount(Mdl) >> PAGE_SHIFT);
+             RangeEnd++) {
+            if (Pfn[RangeEnd] != Pfn[RangeStart] + (RangeEnd - RangeStart))
+                break;
+        }
+
+        StartAddress.QuadPart = Pfn[RangeStart] << PAGE_SHIFT;
+        NumberOfBytes.QuadPart = (RangeEnd - RangeStart) << PAGE_SHIFT;
+
+        Status = MmAddPhysicalMemory(&StartAddress, &NumberOfBytes);
+        if (!NT_SUCCESS(Status)) {
+            Error("MmAddPhysicalMemory failed: %08x (PFN %llx + %llx pages)\n",
+                  Status,
+                  Pfn[RangeStart],
+                  RangeEnd - RangeStart);
+            break;
+        }
+
+        RangeStart = RangeEnd;
+    }
 }
 
 #define XENBUS_BALLOON_MIN_PAGES_PER_S 1000ull
@@ -548,7 +581,7 @@ BalloonFreePfnArray(
 
     Mdl->Next = NULL;
     Mdl->Size = (SHORT)(sizeof(MDL) + (sizeof(PFN_NUMBER) * Requested));
-    Mdl->MdlFlags = MDL_PAGES_LOCKED;
+    Mdl->MdlFlags = MDL_PAGES_LOCKED | MDL_IO_SPACE;
     Mdl->Process = NULL;
     Mdl->MappedSystemVa = NULL;
     Mdl->StartVa = NULL;
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Jun 12 11:00:47 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 12 Jun 2025 11:00:47 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1012841.1391353 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPffp-00012Y-8W; Thu, 12 Jun 2025 11:00:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1012841.1391353; Thu, 12 Jun 2025 11:00:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uPffp-00012R-5X; Thu, 12 Jun 2025 11:00:45 +0000
Received: by outflank-mailman (input) for mailman id 1012841;
 Thu, 12 Jun 2025 11:00:44 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=oivH=Y3=bounce.vates.tech=bounce-md_30504962.684ab358.v1-b34c7e2c61054ce8ac171a2997b612bd@srs-se1.protection.inumbo.net>)
 id 1uPffo-00012L-7K
 for win-pv-devel@lists.xenproject.org; Thu, 12 Jun 2025 11:00:44 +0000
Received: from mail36.us4.mandrillapp.com (mail36.us4.mandrillapp.com
 [205.201.136.36]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 7aeb43fa-477c-11f0-a309-13f23c93f187;
 Thu, 12 Jun 2025 13:00:42 +0200 (CEST)
Received: from pmta15.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail36.us4.mandrillapp.com (Mailchimp) with ESMTP id 4bJ01h5V03zS62TTK
 for <win-pv-devel@lists.xenproject.org>; Thu, 12 Jun 2025 11:00:40 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 b34c7e2c61054ce8ac171a2997b612bd; Thu, 12 Jun 2025 11:00:40 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7aeb43fa-477c-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749726040; x=1749996040;
	bh=xCMlz33xfrcNi45qBqvIugwG57w1Kc5N/PLqzWvrhO4=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=DWvuiZi8T0otTezzS3tM2GJMR+5N9Kum7FbulNtEiIwh/7gwA41V25A/CicVU3mCE
	 eT0VI4yuPOz7454UE5e89fh1UxyPxFbpNTw4SuqyRXqg2JaohhU3NZAHISHyLyGR+l
	 cAw9CCDgG3Pm10/NqODJ0n7QpQmcZK3fw8DuoQVzqiVjhogVt7gA2cOgNXGdw7HNDE
	 tP0EvXmzyP040tdOvjeAIiyRHQr9X6jXk9ihnxNtF2O1ndVKsSLTEwTqcrZb3hSsKz
	 3dLJWoAWtIHRyQOmRVRecGDgtddgIvIGxBFtaCM5AH5t0zEpQHDEnSXLdH9qfVR9Oi
	 1f5eIOOX4Kjnw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749726040; x=1749986540; i=ngoc-tu.dinh@vates.tech;
	bh=xCMlz33xfrcNi45qBqvIugwG57w1Kc5N/PLqzWvrhO4=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=wKD5utwWxroLc0A7VpzbfcPzaB3deeIOb90YmY13zmvVMqlUQyzM6BKE3gn6p7Kc4
	 8Co1gwJJPc2WWriXpGql/H5U1UETxFTlu+bKxCyHBYo30UVjEcLNITY0zbyFBmVIpT
	 P8Yk8695bJPmlCWeH2C0O8d1Y5l0oDWfYWASOkzN0bvafuB3PQhGGG9RAgAL6i5t9Z
	 lJ8qZV0l7g2xrUMK72/l4Y4eecBla3cZOLBlwpByoCQXQ0kUOwDimoQnut/hQ9cG+n
	 F9dpkm6660TN+BqjVeebFOg2pZ3zTgpEjd0I9cICZKg2Qigp82/aZ4kyaSR2HpFFSz
	 cMexevX/zm1Gg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v3=202/2]=20balloon:=20Specify=20MM=5FALLOCATE=5FPREFER=5FCONTIGUOUS?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749726038436
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250612110018.1493-2-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250612110018.1493-1-ngoc-tu.dinh@vates.tech>
References: <20250612110018.1493-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.b34c7e2c61054ce8ac171a2997b612bd?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250612:md
Date: Thu, 12 Jun 2025 11:00:40 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

This flag, available from Windows 7, instructs the kernel allocator to
avoid physical memory fragmentation.

Tested on Server 2022 by decreasing memory from 8GB->5GB:
* Before: 98 balloon allocations containing 6518 contiguous ranges
* After: 98 balloon allocations containing 649 contiguous ranges

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
Reviewed-by: Paul Durrant <paul@xen.org>
---
 src/xenbus/balloon.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/xenbus/balloon.c b/src/xenbus/balloon.c
index 528928c..0e2ef05 100644
--- a/src/xenbus/balloon.c
+++ b/src/xenbus/balloon.c
@@ -219,6 +219,7 @@ BalloonAllocatePagesForMdl(
                                   TotalBytes,
                                   MmCached,
                                   MM_DONT_ZERO_ALLOCATION |
+                                  MM_ALLOCATE_PREFER_CONTIGUOUS |
                                   MM_ALLOCATE_AND_HOT_REMOVE);
     if (Mdl == NULL)
         goto done;
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Jun 13 10:36:36 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Jun 2025 10:36:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1014211.1392449 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uQ1lx-00019V-US; Fri, 13 Jun 2025 10:36:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1014211.1392449; Fri, 13 Jun 2025 10:36:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uQ1lx-00019O-RY; Fri, 13 Jun 2025 10:36:33 +0000
Received: by outflank-mailman (input) for mailman id 1014211;
 Fri, 13 Jun 2025 10:36:32 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=XjEW=Y4=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uQ1lw-00019I-Tz
 for win-pv-devel@lists.xenproject.org; Fri, 13 Jun 2025 10:36:32 +0000
Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com
 [2a00:1450:4864:20::336])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 456950bf-4842-11f0-a309-13f23c93f187;
 Fri, 13 Jun 2025 12:36:32 +0200 (CEST)
Received: by mail-wm1-x336.google.com with SMTP id
 5b1f17b1804b1-452f9735424so6853865e9.3
 for <win-pv-devel@lists.xenproject.org>; Fri, 13 Jun 2025 03:36:32 -0700 (PDT)
Received: from [10.95.102.158] (54-240-197-227.amazon.com. [54.240.197.227])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3a568b628ecsm1964435f8f.92.2025.06.13.03.36.30
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Fri, 13 Jun 2025 03:36:30 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 456950bf-4842-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1749810991; x=1750415791; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=1SAubM7DZmbAwyxzhWVxkFPn1wdDnpsoHlsMQoFQDeY=;
        b=nnUYJmCBO18JXd3QM8X2nAnwDhYuTtH+UDAl4pZQts+GvvjL4ff2JLSXoqQZSJKTxW
         NGtOH10dRCtYwTIEpeJMIO9WyvLo1abkTTDFSeXGW4D0psHpNDYAPa9th3QHGoHUfLJ3
         g2AONf4yZt1VCtvwRzwzIa189IAE6XnTsbi4WEiZhoeRp9rIp+vXe7BFI8k+i/cQay+u
         JDmywDafQBTMci7VMx0uwPbgghJMODjQxuhzOWO9RQbaNq1s4Tfa1sQg93FGkcGk4v4w
         i2Rg4S6OvnFAbPfZowq8lSJXhu4xbkx3zTZSmTdxiyBVCU9Q5XzMTKF7kUccd282bm1k
         UNBg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1749810991; x=1750415791;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=1SAubM7DZmbAwyxzhWVxkFPn1wdDnpsoHlsMQoFQDeY=;
        b=S2lxuZ6qt7AngFBPJdlp53JeQYa8wVQHjNe/lT95OSDwL9Kmru/tc7+vahR2Z2LlFh
         CrIWqkxm7tmygUcbdg2OSZwr5n+prINKOIDd+Ek6q70Jep47gpYWhFrcMgA0h5NhJI5N
         c+XTMtok97nRRZjju+nTvIYisniVG7R6TDt1cohTRiOue5aBI2+UIS7a8mlZabsgx8Y5
         SDz5vUAdlXKGCkrROOpbe7QtHPyU+h1R7fhcMOZ5Fm8G/mJ0h4Y7uvtW56w7f+OL+ZQS
         5pV0Wchl4FrZ5EY4zwGN4j3pU1Lzru6Qfh3d2tWD8RG1aPVbwxSzwc/V91OzMwby6HWh
         L6MA==
X-Forwarded-Encrypted: i=1; AJvYcCWiN6F25TrVVsd1xW7ZVoZSneOtXofucX743bkmNpwGvFx0YXqGprrPu7bLg62VIcsQi0I2fOjfbamDC+w=@lists.xenproject.org
X-Gm-Message-State: AOJu0YzYNHZPLkTClUd5SktZgOB1ZTd84MbbBTyttsWSWLyEdqbg72tM
	Kpc9uUjRzCGGO9HLfXxQhK+4Q6jF57GXNbuMQWn5PQXjWXWfz6MG2K6+
X-Gm-Gg: ASbGncsxho7UCo8P8Skusn5bde2JBfgeKLTs2TfzXKLKZLD2/kHaE/4zkdwho5BMns4
	5H+O8Y1kdJu1mf9uUBbKuKMzoYPrUwoKerAVXr6mJfmvhj+Ma+Xd7O8rotF8PinIayqytP2mnSJ
	BWpQoig1UXGOJzFcJNAELBmFsefYKMF4+ZNgq6No4S6EYjUuhouS5zfSXZZe/fkPQaScCU5JNSJ
	Yv+02bgzhKjG6ci9oNFCy1ygbOXm71PJAYLtqe5sLWGPTr8O4wxqAoYo+BEX5GgKRwT9M46Po0c
	YSeZHZTOtuPqqxg69oNL7/8KdIJ5i4dnmkFk1BTKA5dH1+sxkBhthvB+HYTmxiCYHu9vqpZOGAv
	LpXI7N4Agbvr8+xE6zA==
X-Google-Smtp-Source: AGHT+IHSMc0J9XLWQBBVt78gibRF5uqPDKQq+4eNJHLn4fhqY6WWAXtbftxRFzfkNYcy5emyP4N8VA==
X-Received: by 2002:a05:600c:811a:b0:43b:cc42:c54f with SMTP id 5b1f17b1804b1-45334a83db1mr27053155e9.14.1749810991086;
        Fri, 13 Jun 2025 03:36:31 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <f6cd579a-eadd-4800-9194-591dd203d5af@xen.org>
Date: Fri, 13 Jun 2025 11:36:29 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [XENBUS PATCH v3 1/2] Use Windows 10 APIs to inflate/deflate
 balloon
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
References: <20250612110018.1493-1-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <20250612110018.1493-1-ngoc-tu.dinh@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 12/06/2025 12:00, Tu Dinh wrote:
> Currently the balloon driver allocates pages as normal memory, which
> causes Windows to report the ballooned memory as kernel-allocated
> instead of unavailable.
> 
> Windows 10 provides MM_ALLOCATE_AND_HOT_REMOVE to remove pages from
> the physical memory pool. The removed pages can be added back with
> MmAddPhysicalMemory.
> 
> Using this feature, the real VM memory capacity will be correctly
> reported in Task Manager.
> 
> Balloon deflation is implemented using calls to MmAddPhysicalMemory on
> contiguous PFN ranges.
> 
> Note that MM_ALLOCATE_AND_HOT_REMOVE actually removes the pages from
> memory space, so the resulting MDL will have the MDL_IO_SPACE flag;
> similarly, when probing the freed MDL on deflation, we'll also have to
> set MDL_IO_SPACE.
> 
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
> v3: Fix the issue where hot-removed memory will be in I/O space.
> v2: Updated commit message to say what the patch does. No code change.
> ---
>   src/xenbus/balloon.c | 43 ++++++++++++++++++++++++++++++++++++++-----
>   1 file changed, 38 insertions(+), 5 deletions(-)
> 

How much testing has this had? v3 came out of nowhere.


From win-pv-devel-bounces@lists.xenproject.org Fri Jun 13 10:41:17 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Jun 2025 10:41:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1014239.1392473 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uQ1qX-0003oB-Mb; Fri, 13 Jun 2025 10:41:17 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1014239.1392473; Fri, 13 Jun 2025 10:41:17 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uQ1qX-0003o3-Jf; Fri, 13 Jun 2025 10:41:17 +0000
Received: by outflank-mailman (input) for mailman id 1014239;
 Fri, 13 Jun 2025 10:41:16 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=A+ss=Y4=bounce.vates.tech=bounce-md_30504962.684c003c.v1-3fa886b31aeb4b608945defc5c5f2ca9@srs-se1.protection.inumbo.net>)
 id 1uQ1qV-0002hC-V3
 for win-pv-devel@lists.xenproject.org; Fri, 13 Jun 2025 10:41:16 +0000
Received: from mail145-24.atl61.mandrillapp.com
 (mail145-24.atl61.mandrillapp.com [198.2.145.24])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e5f8ab8e-4842-11f0-a309-13f23c93f187;
 Fri, 13 Jun 2025 12:41:01 +0200 (CEST)
Received: from pmta06.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail145-24.atl61.mandrillapp.com (Mailchimp) with ESMTP id
 4bJbXX33m6zGlspMC
 for <win-pv-devel@lists.xenproject.org>; Fri, 13 Jun 2025 10:41:00 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 3fa886b31aeb4b608945defc5c5f2ca9; Fri, 13 Jun 2025 10:41:00 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e5f8ab8e-4842-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749811260; x=1750081260;
	bh=jyTLyrmf/JIkPxy6M7q+vKJT1fQuR30zq1JM4lSaN9U=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=JVjlVR9iArhnmTk6sOUVO928mMxJXwyuAqXMQ35Pan3pUIezTSm46Zqt6E9VIudGD
	 Oto72JIImaEpEJoKJAjUF6UDseAzztTc7h7iUkwg0r9/xmFqaLADW9eNQ8B3XtR3op
	 tNCqAeWcMYm5Tuhu0R0aVed3J6DjEaGk+eUleeRJ3MwBEMCS7HAEFY8PkIGznYG2w2
	 foJIzWqRUWe0c7g+3t8Xoc2w5+BvKXG09zxB4WNQyuugaMKasZHbpcEs4qDTQ89Cai
	 5mbNs94ID9BN7r+nTW74NZrkBKd5SqMqyKi1ZzpNvFe6zs40W04t5paF0xGmbqrMQ8
	 GLuHtUZexGjqA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749811260; x=1750071760; i=ngoc-tu.dinh@vates.tech;
	bh=jyTLyrmf/JIkPxy6M7q+vKJT1fQuR30zq1JM4lSaN9U=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=k9aPiYcOO6QFdk2VUhsGUP0HYckNwMPxoCx/bSRDcrmoRvjmPhg+tcVe3/okzBP7g
	 m1W+jiOqGvmbiC2GBbm74jHJp69+XyJiNm8QBGd4b79Tm/R9woWXmf43CvlQ4BsDE7
	 sYx6XWefAPj2SjFP7EumO3O/XA0i9bXiWXGDz/ZtIZkfXHM3DOwQU0PUzUF9iT4+t6
	 D3yNIQSNF1uhyRkiG0dvXfpTPnoiOenOMxjqbCoNoiep+Luw01BGJLVEUxOy71z5Hl
	 HABeQ5dORH6QhW6/AwGkNpOg1sdJP7muxAqGWAOEz9Drcjhi5ntx5ZDJO7ZNTW26U+
	 qkl5gGVZieZ4Q==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[XENBUS=20PATCH=20v3=201/2]=20Use=20Windows=2010=20APIs=20to=20inflate/deflate=20balloon?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749811259490
Message-Id: <c62e0c53-1ef0-4328-8b5f-09240bbdd0f6@vates.tech>
To: paul@xen.org, win-pv-devel@lists.xenproject.org
Cc: "Owen Smith" <owen.smith@cloud.com>
References: <20250612110018.1493-1-ngoc-tu.dinh@vates.tech> <f6cd579a-eadd-4800-9194-591dd203d5af@xen.org>
In-Reply-To: <f6cd579a-eadd-4800-9194-591dd203d5af@xen.org>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.3fa886b31aeb4b608945defc5c5f2ca9?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250613:md
Date: Fri, 13 Jun 2025 10:41:00 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

On 13/06/2025 12:36, Paul Durrant wrote:
> On 12/06/2025 12:00, Tu Dinh wrote:
>> Currently the balloon driver allocates pages as normal memory, which
>> causes Windows to report the ballooned memory as kernel-allocated
>> instead of unavailable.
>>
>> Windows 10 provides MM_ALLOCATE_AND_HOT_REMOVE to remove pages from
>> the physical memory pool. The removed pages can be added back with
>> MmAddPhysicalMemory.
>>
>> Using this feature, the real VM memory capacity will be correctly
>> reported in Task Manager.
>>
>> Balloon deflation is implemented using calls to MmAddPhysicalMemory on
>> contiguous PFN ranges.
>>
>> Note that MM_ALLOCATE_AND_HOT_REMOVE actually removes the pages from
>> memory space, so the resulting MDL will have the MDL_IO_SPACE flag;
>> similarly, when probing the freed MDL on deflation, we'll also have to
>> set MDL_IO_SPACE.
>>
>> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
>> ---
>> v3: Fix the issue where hot-removed memory will be in I/O space.
>> v2: Updated commit message to say what the patch does. No code change.
>> ---
>> =C2=A0 src/xenbus/balloon.c | 43 ++++++++++++++++++++++++++++++++++++++-=
----
>> =C2=A0 1 file changed, 38 insertions(+), 5 deletions(-)
>>
> 
> How much testing has this had? v3 came out of nowhere.

The v3 fix came from manually testing the ballooning feature with a 
debug build under Driver Verifier (standard + a few extra checks). Aside 
from that I've done CodeQL and VS code analysis on the driver.

On a side note, the Xen PV drivers use old annotations which are not 
checked by VS. Is there interest in upgrading to SAL 2.0? I tried doing 
so with xenbus and it caught a couple small issues.

Best regards,


Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




From win-pv-devel-bounces@lists.xenproject.org Fri Jun 13 18:31:03 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Jun 2025 18:31:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1014826.1392910 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uQ9B7-0004y3-Cm; Fri, 13 Jun 2025 18:31:01 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1014826.1392910; Fri, 13 Jun 2025 18:31:01 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uQ9B7-0004xw-AE; Fri, 13 Jun 2025 18:31:01 +0000
Received: by outflank-mailman (input) for mailman id 1014826;
 Fri, 13 Jun 2025 18:31:00 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=pj84=Y4=bounce.vates.tech=bounce-md_30504962.684c6e5e.v1-df0585cfea24467d8374b9a3e89f540f@srs-se1.protection.inumbo.net>)
 id 1uQ9B6-0004xq-ML
 for win-pv-devel@lists.xenproject.org; Fri, 13 Jun 2025 18:31:00 +0000
Received: from mail145-24.atl61.mandrillapp.com
 (mail145-24.atl61.mandrillapp.com [198.2.145.24])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 8b40821b-4884-11f0-a309-13f23c93f187;
 Fri, 13 Jun 2025 20:30:59 +0200 (CEST)
Received: from pmta06.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail145-24.atl61.mandrillapp.com (Mailchimp) with ESMTP id
 4bJnyk58DBzGlss4X
 for <win-pv-devel@lists.xenproject.org>; Fri, 13 Jun 2025 18:30:54 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 df0585cfea24467d8374b9a3e89f540f; Fri, 13 Jun 2025 18:30:54 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 8b40821b-4884-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1749839454; x=1750109454;
	bh=r8RA5iSi5pfEEQKd2AscC+gtpW8oiWlbvkT7FXadEtA=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=WLKM4kWrBe0NQhFo70KmGBaXcnBrrt2zaQdr3F1mKAo1OLkLk2mocNMhujC7Nzolo
	 tjiVJ+hMJcxS1F/LZ3BzfMZTT3sDr5o71jqk/KB2gudq1kNZbTkpFgPqM27RJ4CvX4
	 qwScY6IbgwA659ZswUR4p867EqtBQrwvevy8OvE/4YXbkRDpAJKZGS3ZUdbi5QjSf7
	 quDeBUaXzAqpB1UbDUixIPlw9vuhaRZc3h63Q/Qw2X7rHXEZmqPZrtc9SxJ4Fx80l0
	 CZ+86TeZMTFXAyjQhzIq77SnV3JuqKB0X1S4E+ZwtK18lSBb+XZW5JFeN4tpR/xn5G
	 DxagtHaUi+r/w==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1749839454; x=1750099954; i=ngoc-tu.dinh@vates.tech;
	bh=r8RA5iSi5pfEEQKd2AscC+gtpW8oiWlbvkT7FXadEtA=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=M0uKbtdffa2I7OU2wNrauHRGQBImx42FHzEQXrgjeM6nE0bLZP4mIzThrg+T1ZjhT
	 vWrmcC187IaC377zURbH3nbW3LP6TfNYbpT6YVZ9a163enWjkelrCOeiuvyrHvrLvM
	 0zHy388jQ0AyNnIxGaEJ4Dakz5gvgw4rzShujMsE4e6D2tBIORjv4fqWh+okXPp9va
	 A+NV7jgS+bLXYeQpCOSPdF1C3XsIbFeHmtyU2fIro4b74uXA7w0ACFreNGUO4z2DNu
	 02XlvS173rZVp7b6EsFtkuzg4P3Erpy2AcvVS6s4Bfi25z+hejgE6FwnAhoXyj2i5u
	 pC0kaJQbWgEnw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH]=20Kick=20the=20balloon=20thread=20in=20FdoStartDevice?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1749839453788
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250613183051.619-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.df0585cfea24467d8374b9a3e89f540f?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250613:md
Date: Fri, 13 Jun 2025 18:30:54 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Xenbus currently doesn't apply the dynamic memory targets at boot time.

Force the balloon thread to update memory targets at boot.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenbus/fdo.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index 3a4a1a2..c2e69fa 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -3949,6 +3949,9 @@ not_active:
 
         ASSERT(__FdoIsActive(Fdo));
 
+        KeClearEvent(&Fdo->BalloonEvent);
+        ThreadWake(Fdo->BalloonThread);
+
         //
         // Balloon inflation should complete within a reasonable
         // time (otherwise the target is probably unreasonable).
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 16 15:49:10 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 16 Jun 2025 15:49:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017420.1394409 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRC54-0004ZK-Id; Mon, 16 Jun 2025 15:49:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017420.1394409; Mon, 16 Jun 2025 15:49:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRC54-0004ZD-Fs; Mon, 16 Jun 2025 15:49:06 +0000
Received: by outflank-mailman (input) for mailman id 1017420;
 Mon, 16 Jun 2025 15:49:05 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=pyGc=Y7=bounce.vates.tech=bounce-md_30504962.68503ced.v1-6ece8105323b4a9cb8c449dcdb68d79c@srs-se1.protection.inumbo.net>)
 id 1uRC53-0004Z7-TU
 for win-pv-devel@lists.xenproject.org; Mon, 16 Jun 2025 15:49:05 +0000
Received: from mail145-24.atl61.mandrillapp.com
 (mail145-24.atl61.mandrillapp.com [198.2.145.24])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 67d4d375-4ac9-11f0-b894-0df219b8e170;
 Mon, 16 Jun 2025 17:48:55 +0200 (CEST)
Received: from pmta06.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail145-24.atl61.mandrillapp.com (Mailchimp) with ESMTP id
 4bLZDY638fzGlsp3j
 for <win-pv-devel@lists.xenproject.org>; Mon, 16 Jun 2025 15:49:01 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 6ece8105323b4a9cb8c449dcdb68d79c; Mon, 16 Jun 2025 15:49:01 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 67d4d375-4ac9-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750088941; x=1750358941;
	bh=UjxLiER8sUbYd14kFl1gi/IqSPeMBySdiigr5HE0NQo=;
	h=From:Subject:Message-Id:To:Cc:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=f4r05xYa3NJ6Sq8umwWK0Pr/d3Sjwxb96rEU2GEqolOXqzlByAW75XMb0oLouXc/X
	 x47jNBoVDFjyrlVB9hjXnG8Uwg9+P1WI7fJMC9C54bPDXwMFhEXJ72HACB6R9Ff2S0
	 MezcxiW+XSYZzrKh6vr5Mxdl9yJdIuR78B9IuXLNjsAf7c+SEpRvZdhcJp8diT5DRN
	 jLmwSM54wysMb3s26YozwxLsKox+91a2HP6XqNpvlWx0ojz+SVpoehua5Vt5RIHXxi
	 mzM6PCyZ2pHuHBLKRXxnSVpb3AEH+CUpb9qAM/hJHCE+yse8f6L8uiHdWaTaCXS0zB
	 qZ1jmYmXiuAdQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750088941; x=1750349441; i=ngoc-tu.dinh@vates.tech;
	bh=UjxLiER8sUbYd14kFl1gi/IqSPeMBySdiigr5HE0NQo=;
	h=From:Subject:Message-Id:To:Cc:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=rpex7DPLl+MLlPCUh6/cUNHZ3NhYaFy8H6EbzNtdAxmAzM6UyvlPgLQDI1ei0yGrC
	 Xtn6UWoJ2a250FIgL+eAYiIRWXDbEdfR/GRZtHpDroC3UJTXiir8AEmYDdlOyhd0Z0
	 4LMSXQ0Cb73yxXHTHjlqGiYtBDCsnPfj8uaYgMZ1wNKLUKrKppTKONg3xqD7eMMDx/
	 rrWTofA0AvLFFANxaLvjydXeXQh0lmN06bAS8KMKTa324k4Tcmm+RKqiUJFJexsKEF
	 LtBXF2MpX5p7iwd1M7lHwXJRDBuV40sHXvawL3rU/l3Cd1uVm+tptgHBXJRlqHq0CX
	 zkDEGWmbn+MGA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?CI=20infrastructure=20for=20Windows=20PV=20drivers?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750088935929
Message-Id: <3390640e-cc46-404e-a497-847881de12e9@vates.tech>
To: win-pv-devel@lists.xenproject.org
Cc: "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>, cody.zuschlag@xenproject.org
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.6ece8105323b4a9cb8c449dcdb68d79c?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250616:md
Date: Mon, 16 Jun 2025 15:49:01 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Hi,

I'm currently interested in preparing a CI infrastructure for the 
Windows PV drivers.

While I don't think there's currently interest in official signed 
drivers from the Xen Project, a CI infrastructure will still be useful 
for automated tests. In particular, I'm looking at the following:

- Automated testsigned builds;
- CodeQL checks;
- Rudimentary automated tests for driver features, under Driver Verifier.

Here are the needed resources:
- Build server running some flavor of Windows;
- Build tools: Visual Studio (Community?), WDK, etc.
- Several test VMs running various supported OSes on Xen (client, 
server, etc.)
     - These VMs are preferably snapshot-capable to ease testing.

I can volunteer to prepare the build scripts and tests. Cody pointed out 
to me during the last community call that we can get professional 
support to keep the build and test servers up to date and secure.

I'd appreciate your input on this matter.

Best regards,


Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 16 16:03:36 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 16 Jun 2025 16:03:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017470.1394462 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRCJ5-0002Ds-RY; Mon, 16 Jun 2025 16:03:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017470.1394462; Mon, 16 Jun 2025 16:03:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRCJ5-0002Dl-P0; Mon, 16 Jun 2025 16:03:35 +0000
Received: by outflank-mailman (input) for mailman id 1017470;
 Mon, 16 Jun 2025 16:03:34 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=2poU=Y7=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uRCJ4-0002Dd-9t
 for win-pv-devel@lists.xenproject.org; Mon, 16 Jun 2025 16:03:34 +0000
Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com
 [2a00:1450:4864:20::330])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 73b75c0c-4acb-11f0-a309-13f23c93f187;
 Mon, 16 Jun 2025 18:03:33 +0200 (CEST)
Received: by mail-wm1-x330.google.com with SMTP id
 5b1f17b1804b1-450cb2ddd46so26367255e9.2
 for <win-pv-devel@lists.xenproject.org>; Mon, 16 Jun 2025 09:03:32 -0700 (PDT)
Received: from [192.168.28.243] (54-240-197-224.amazon.com. [54.240.197.224])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-4532dea17d7sm147038395e9.10.2025.06.16.09.03.30
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Mon, 16 Jun 2025 09:03:30 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 73b75c0c-4acb-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1750089811; x=1750694611; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=VpD08+JAeeRiThJaiLOpZVkcrhss+3kBnhwMZPxuCQc=;
        b=j27kia5eJcEGX/p0cbuej7Bt6LZGnTJ2eQsdOVCkBfQCA8jWSxXEgn1uDh8Q5mhkOd
         HT94IbqGMOp6t8wafxpr8xeKz0Rttkla0b8oNJE5mDycS4tizioZ4Bmo4+hPMkG9oCV2
         2YFB5jqGBrznaOMTyDgMIfs7ZFXtB2gBdOiJMpZ+vLXsPtjXtdpooMR460ZlY1NF1/sz
         mcjxaA2RI65ZH/l+kgwMJdgSojeI0JvyCyq0wHYdGFW0rrEeecsujQ4CW/m5tBTYejVR
         LeCGb2yr9vuydb7k6UqRHZxsiRM+KpUJk5VPqpSEShxXDH/7Xy6JQ+l12C+tfzbuB8wU
         CzEw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1750089811; x=1750694611;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=VpD08+JAeeRiThJaiLOpZVkcrhss+3kBnhwMZPxuCQc=;
        b=taiACOBH/DZbOmG8wUiTVl2/ZXPmY5chpGqHCXfcG+Ih2tahn6LlMOI5YkRO255LXm
         YCzsx+0bIEE8Lx7DVmxSGtFadhAi3smNu0yEfl00h/C5g6DbagGFk92d1MkdMqB9B8Zm
         8CPreLP7LRKvW3D0Y+5BMonKZZyM6YlDYTi8hQbTHO+hQ9xRIyokKs0dLBcEeukpAuzw
         56wsBveHovuk8UyY69jGSmt4WMuHzKKXXJfWknS3elZiTXkSrQItzHu5MBy9l24cDSFC
         3WM1AtZnUgzYJPxqzpEgj/e9Tw6at5UozbYItBljwktHdEiBcmCLgMb+1gSvLiYjF+UQ
         ucyg==
X-Forwarded-Encrypted: i=1; AJvYcCVXRdaZ2koMc/Vz2cal0s9lrkgKpWv7zANX1xpC1bo17+w8OpKwqECAQTYp3QhE1+pcvbddBsKm1JOLimk=@lists.xenproject.org
X-Gm-Message-State: AOJu0YzlIHC92C2D7gHRi3MM4QNCM7aXP8gg+f70S8+23yRvaW1nTkOp
	AWTy7wlws9uOGX3OHspzfLHObbslKvCeKPDe+aV2jHtGAor/OHPWWycK
X-Gm-Gg: ASbGncv1Q2s/+ytQFgt4UiH47MRKXntu6tUcUVQn/qjBWu5uB71bKjhBvIc16pmR4gC
	ZwQ0zaawBwDkgKRaTjsPnD+LZo3VdCNYHDcvRlpaqCz7TU/qQIx/S0RHOSHOG1nqnxNiWa9qNH1
	WB89R6VCittQs3N5xp8ZCPb7/qx5kWzBepchNjrQAG/MmAnuv7Wer7uR9tMb/J9Cy6MbJQJsx5V
	yuga67e7U64C4+Bwzyf4BFQcOxxQYyZ/tvCKHmK0C5RMYjaKCbR/62gKgd5Hih+vMQslmHzOFzV
	9ERYjRqz8L5o3C3MQ3SPxHCHJRebywjpDKJq+rBx0eeyQnAcJAvaXItcrCKYNNEViYYNeOuz1Ta
	dCdt+sPz3LrVUfOwq6xM=
X-Google-Smtp-Source: AGHT+IG2YcTpOQFR/YIS4WvYrjhJ/93oMTy6P6odrXR42gluhOpILLXkGqhP9h2oLq3Bs9xkTNlluA==
X-Received: by 2002:a5d:588c:0:b0:3a4:f7f3:2d02 with SMTP id ffacd0b85a97d-3a5723715fcmr8001849f8f.17.1750089810881;
        Mon, 16 Jun 2025 09:03:30 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <608468bf-9835-49d0-90aa-44a3f64679b7@xen.org>
Date: Mon, 16 Jun 2025 18:03:29 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: CI infrastructure for Windows PV drivers
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>, cody.zuschlag@xenproject.org
References: <3390640e-cc46-404e-a497-847881de12e9@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <3390640e-cc46-404e-a497-847881de12e9@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 16/06/2025 16:49, Tu Dinh wrote:
> Hi,
> 
> I'm currently interested in preparing a CI infrastructure for the
> Windows PV drivers.
>

Good :-)

> While I don't think there's currently interest in official signed
> drivers from the Xen Project, a CI infrastructure will still be useful
> for automated tests. In particular, I'm looking at the following:
> 
> - Automated testsigned builds;
> - CodeQL checks;
> - Rudimentary automated tests for driver features, under Driver Verifier.
> 
> Here are the needed resources:
> - Build server running some flavor of Windows;
> - Build tools: Visual Studio (Community?), WDK, etc.

I usually build using the EWDK so there's no need to install.

> - Several test VMs running various supported OSes on Xen (client,
> server, etc.)
>       - These VMs are preferably snapshot-capable to ease testing.
> 
> I can volunteer to prepare the build scripts and tests. Cody pointed out
> to me during the last community call that we can get professional
> support to keep the build and test servers up to date and secure.
> 
> I'd appreciate your input on this matter.
> 

CI is a very good thing, which we have been lacking for too long. The 
old system was turned off due to lack of maintenance causing a security 
issue so clearly we don't want that to happen again.

Cheers,

   Paul


From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 06:54:56 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 06:54:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017752.1394747 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQDe-0002Ke-IX; Tue, 17 Jun 2025 06:54:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017752.1394747; Tue, 17 Jun 2025 06:54:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQDe-0002KX-FL; Tue, 17 Jun 2025 06:54:54 +0000
Received: by outflank-mailman (input) for mailman id 1017752;
 Tue, 17 Jun 2025 06:54:53 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=0kdh=ZA=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uRQDd-0001qt-1v
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 06:54:53 +0000
Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com
 [2a00:1450:4864:20::429])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id f7fbf464-4b47-11f0-a309-13f23c93f187;
 Tue, 17 Jun 2025 08:54:52 +0200 (CEST)
Received: by mail-wr1-x429.google.com with SMTP id
 ffacd0b85a97d-3a54700a46eso3414874f8f.1
 for <win-pv-devel@lists.xenproject.org>; Mon, 16 Jun 2025 23:54:52 -0700 (PDT)
Received: from [192.168.19.180] (54-240-197-235.amazon.com. [54.240.197.235])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3a568b19b32sm13198561f8f.67.2025.06.16.23.54.50
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Mon, 16 Jun 2025 23:54:51 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: f7fbf464-4b47-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1750143292; x=1750748092; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=txWdnlULDfDTB0rBrBm9zoMHxddjYo65f5GLAoD0aXQ=;
        b=RTYqSz4qjGjshs7ZJBkyiSg1eZmkU6Y8YOf9SDs0zJWdVwwuca28iSfgrcy83YEijW
         Njna6QNO7sAlWHSKIhCXH/i3KfcpRqgVCNmf3675epa9dl/bnJI26eaXDetog7Ga8imT
         3PQxksHEIVvtmvJ6WC06hTmaQcB/2Ysu3t5mNmnWq+FrzSALoeeSnm30c1/yOuVIHAal
         peEI35OUQPU7PM5EAaeUBaywbVsJsUH7lonsrS7NO1wxt8asoDQMNzVzJ6Py9lxkZcht
         ikb+0A35ugKwnolINyDyVgDtGSquACIE2fa0/WuGSYTCPDQ3+Ilsfz5VRm4K/NP1NZdW
         FooA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1750143292; x=1750748092;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=txWdnlULDfDTB0rBrBm9zoMHxddjYo65f5GLAoD0aXQ=;
        b=CbvnXAMAxSBMkQv+NnegbvB3VH3VyCQDpjTFNxoEU2YeWUy3BqWApxiIrQWnsjFEvP
         47L3u3MG7EGoW2GnEIjZM9+b8DPKDsPAltV0RC4ik8J/N1/FJKROreXmuNsDbf9eC5Tm
         4sHvk5wxJg+Fq8EULvbP4tD5rJ+GeZXIfUXXLmYDhwpLAQF03etx1iVOAPdXd4gAOWTE
         gaFU4eL1oVxejTjQ98BPLVtVIIEOPdeb/7D7HLYgXtuwleqAY6GgEE4TfWQPq+JVRQTn
         17lbdURHVhhFJ70y8W6BxKTk0KIm2hj/A8prGbgmBb+BE6BBmCxc9J+6aCoz2kdalHFK
         ZkYw==
X-Forwarded-Encrypted: i=1; AJvYcCWjwdvvV2XgIP/afsEuHriWbS70lNvdvVKhMdZlL8veSwlU02DYWxeOAWj8+t353Z4pPctpDZ6xi+yGaTU=@lists.xenproject.org
X-Gm-Message-State: AOJu0YzRPVcaxDymLqvBlmIluEksnyPExsM8vu7ZGYi+JmPw2zG1S0kQ
	BrSTPlbWfIenjtw+tVyhRVSNylKq9E4U1vMd0IeDRH+C6/yiaxniHKX2Uza4EWb+SKc=
X-Gm-Gg: ASbGncuTtB8FlMSV/AZhepxyBYDH2cLB7JzjWDfoyL8v59ZhOU9S6G/VYWBRcDSBe89
	m1Nt5oDhm9ZNhZxFPavyvfOv91mThRTItXrLS8Z4Apj0mZ3O60XMCAjacWAdGliOthcaM7BK5k0
	Rn1haf00JslmK7BdjbyNbbfxiTd9Io4S72VZITZd8AEIr+dkhOSMkygs5mPnlhpPwySMXpcS1d5
	g1sSX5ZDnY4puJ33i5NIDP32Zs2Q/sfoGKjla+AwBAmX/22+WnUThjshepLP3aAm4adq9f0m+7W
	sg4fBrp8CQq4nABzvSoSpUzS5FXpoTmiIwt3j4oNoTFZwHng2Bl04+gTmHKJugjZv9HCFVftnuJ
	2XqFsjkQVs7b4i+iMtHAGPrI4dYdZww==
X-Google-Smtp-Source: AGHT+IFLH6fKwglgdPJS93ju6v11LWRImn5dr7hjBASANxAx6w5cVkHFhdxwNtXC3r1J9RHXwDbgmA==
X-Received: by 2002:a05:6000:1886:b0:3a4:d6ed:8df8 with SMTP id ffacd0b85a97d-3a5723af293mr9644462f8f.39.1750143291648;
        Mon, 16 Jun 2025 23:54:51 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <92f7fad6-26be-4dd5-a7b1-13017963c46a@xen.org>
Date: Tue, 17 Jun 2025 08:54:50 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [XENBUS PATCH] Kick the balloon thread in FdoStartDevice
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
References: <20250613183051.619-1-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <20250613183051.619-1-ngoc-tu.dinh@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 13/06/2025 19:30, Tu Dinh wrote:
> Xenbus currently doesn't apply the dynamic memory targets at boot time.
> 

How so?

The xenstore watch on memory/target signals the balloon thread's event 
so the watch registration in __FdoD3ToD0() should always wake the thread 
(since any watch registration triggers a spurious watch event).

> Force the balloon thread to update memory targets at boot.
> 
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
>   src/xenbus/fdo.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
> index 3a4a1a2..c2e69fa 100644
> --- a/src/xenbus/fdo.c
> +++ b/src/xenbus/fdo.c
> @@ -3949,6 +3949,9 @@ not_active:
>   
>           ASSERT(__FdoIsActive(Fdo));
>   
> +        KeClearEvent(&Fdo->BalloonEvent);
> +        ThreadWake(Fdo->BalloonThread);
> +
>           //
>           // Balloon inflation should complete within a reasonable
>           // time (otherwise the target is probably unreasonable).



From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 07:22:48 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 07:22:48 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017822.1394822 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQec-00019G-T4; Tue, 17 Jun 2025 07:22:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017822.1394822; Tue, 17 Jun 2025 07:22:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQec-000198-QG; Tue, 17 Jun 2025 07:22:46 +0000
Received: by outflank-mailman (input) for mailman id 1017822;
 Tue, 17 Jun 2025 07:22:45 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=0kdh=ZA=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uRQeb-000192-6f
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 07:22:45 +0000
Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com
 [2a00:1450:4864:20::32b])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id dc53f323-4b4b-11f0-a309-13f23c93f187;
 Tue, 17 Jun 2025 09:22:44 +0200 (CEST)
Received: by mail-wm1-x32b.google.com with SMTP id
 5b1f17b1804b1-450cfb6a794so31093325e9.1
 for <win-pv-devel@lists.xenproject.org>; Tue, 17 Jun 2025 00:22:44 -0700 (PDT)
Received: from [192.168.19.180] (54-240-197-235.amazon.com. [54.240.197.235])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3a568a5407csm13265576f8f.12.2025.06.17.00.22.42
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 17 Jun 2025 00:22:43 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: dc53f323-4b4b-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1750144964; x=1750749764; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=xAH6QgBKyp+RqFPllHVNNzc7WggIRFFaOx4R4R3MGJw=;
        b=VcfUrEdxXE+SbLiI1Yqj22g5V5StOKm7kGYWcdzX3GxQUT5YI6tsv3ISmH6h0l+1Ha
         hANncpz9twZAcBhol/+Ci4NAtIgV5AfqXWZs0lHljsgtV/ZKsGw3uptEMyWJgwCZ9HXB
         fs6O4WIcLMbHxYM/mBm6TN/zgjr+XJu/isz0cGY4ZRYKKdLYG/1QD90v6zSwCgOOumQk
         LJQRZIh8S2Iw4ukMydd97L4lPvWrDvhnIah19rqGK5xeiQyjiH3oZxvvvzvbYhyETu5b
         wzh63+HUQGnzKc+gEPqdTlK20o0sYYIDzsSqOdKoGHniaRdGcmrB6NFpGFHr6h++7TB6
         pfDA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1750144964; x=1750749764;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=xAH6QgBKyp+RqFPllHVNNzc7WggIRFFaOx4R4R3MGJw=;
        b=PFaBbgGn1l3uHqKsNwplcu/fSjT7vAjG/jqjKsArqqptft1oWjs+DTOezvlj5J28V3
         XEjxUZU7laDXjlWGL9jmLPjHarRPBqc2h0rbKBH+5e7Ynf3JNfGoUP1ZhZRd3zdstEhT
         cWjG/5DVjkXYS171cIcMREXQkXpWstZnrUT8zRnXEnufRPh/GZOJabvNKcVz1Nda+UkX
         tcRFWKRPNbZB3tZRtFgcRZ8bLK+iMl+osTvcntQzTReTdSYVPX5of01tUqHSNY+nOERf
         xMZt0VZTPPy7DY/FDECVlA9Z5i9WBHEvK3EjLzk/tvBqfimy+zeD+tt+QyzhY1iSMnj8
         ptFg==
X-Forwarded-Encrypted: i=1; AJvYcCWYxhpLUQdge7zBlPgnn2vLHlpQo4qTNKKFItlSAAWzj1TQlwGYpozxO1sEMyhL+xDX+7tvM9Ka0sKUrXk=@lists.xenproject.org
X-Gm-Message-State: AOJu0YznsZT1N8RYiftmmTQUpdt3uPrXrKEIfYE4E0VKXqmvHIIxRWAC
	yl3qgt7XDIDGaNqoxbZKV5wkfsOf7GaJoQ1PW8eIrMWWvqlNMuWMcLaA
X-Gm-Gg: ASbGnctvpAp2MjHHVTmo9zy5QnT53gJyRgRNXNUgMGSPeh+8rLSqyWY1C0XNpXC0O3s
	WCQo+vaweEQ4miTOWgZf8PVyI/Us+bij2c6Z+ltSDNR3SwkoGeiMMNPYMPzJDe/HUXoRli6aM6J
	upTxsO2Z9PGJAVSxBBDV/ic1nZZxiUKBUqjyPZ02+TNVJMhI0r2Gi90pJGV9j5dcxFAnQeC9cCb
	lgk6u6kaeUEtvaMCsZTht1jFw+B1k27VwRXSvfvkdTKJukDYQVWYczur4E+uk3fNeFJxn1RukSo
	QjSfQ5c6m579VVfNtm+h9CHl2vZLPrAA0MzqSAGC11ZeYeYY0VujhIJ0AqZKcQz4Kjmy62Tk70C
	7XXxG6EOlIYGtNqoCQLUjkvvl5zocGA==
X-Google-Smtp-Source: AGHT+IFQupPzt3IvsaqpWjI/TDx/JJ0f637RWJBy4SAwEdIXoLGfCC/bUEnMGdIDQXZNEoNabipGAQ==
X-Received: by 2002:a5d:5f8d:0:b0:3a5:5270:a52c with SMTP id ffacd0b85a97d-3a57189727dmr10305469f8f.0.1750144963665;
        Tue, 17 Jun 2025 00:22:43 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <73a5ac75-3f80-4d45-a633-bd62d5e5e192@xen.org>
Date: Tue, 17 Jun 2025 09:22:42 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [XENBUS PATCH v2 0/5] Autoreboot rework
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
References: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <20250609135941.309-1-ngoc-tu.dinh@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 09/06/2025 15:00, Tu Dinh wrote:
> Rework and clean up reboot prompt and check logic:
> * Since autoreboot takes precedence over reboot prompts, make TryAutoReboot
>    call PromptForReboot instead of the other way around.
> * Any reboot request sets Context->RebootRequestedBy with the driver name.
> * Reboot requests can be paused by active installations, system power requests
>    or denied by the user (made explicit in the initial check).
> * Run the session prompts in a separate thread to avoid blocking main monitor.
> * Retry reboot request every minute (if exists).
>
> v2 changes:
> * Integrated Paul's feedback.
> * Reworked and reorganized the monitor code.
> * Made the retry actually work.
> * Added check for active installations.
> * Added commit to cleanup error variables in TryAutoReboot.
> v1: https://lists.xenproject.org/archives/html/win-pv-devel/2025-05/msg00007.html
> 
> Tu Dinh (5):
>    Cleanup duplicate error variables in TryAutoReboot
>    Rework autoreboot retry logic
>    Repeat TryAutoReboot() with timer
>    Don't autoreboot during ES_SYSTEM_REQUIRED
>    Check for active installation before autoreboot
> 
>   src/monitor/monitor.c                        | 522 +++++++++++++------
>   vs2019/xenbus_monitor/xenbus_monitor.vcxproj |   2 +-
>   vs2022/xenbus_monitor/xenbus_monitor.vcxproj |   2 +-
>   3 files changed, 357 insertions(+), 169 deletions(-)
> 

Are you planning to send a v3 without patch 1 (or with an amended patch 
1)? I can apply 2, 3, 4 and 5 as they stand but with fuzz rather than 
cleanly.


From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 07:29:16 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 07:29:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017832.1394827 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQkt-0001Iq-C6; Tue, 17 Jun 2025 07:29:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017832.1394827; Tue, 17 Jun 2025 07:29:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQkt-0001Ij-9Y; Tue, 17 Jun 2025 07:29:15 +0000
Received: by outflank-mailman (input) for mailman id 1017832;
 Tue, 17 Jun 2025 07:29:13 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=0kdh=ZA=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uRQkr-0001Id-Og
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 07:29:13 +0000
Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com
 [2a00:1450:4864:20::332])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id c32e2f1c-4b4c-11f0-b894-0df219b8e170;
 Tue, 17 Jun 2025 09:29:11 +0200 (CEST)
Received: by mail-wm1-x332.google.com with SMTP id
 5b1f17b1804b1-450ce3a2dd5so50433715e9.3
 for <win-pv-devel@lists.xenproject.org>; Tue, 17 Jun 2025 00:29:11 -0700 (PDT)
Received: from [192.168.19.180] (54-240-197-235.amazon.com. [54.240.197.235])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-4532e261ebdsm172348765e9.39.2025.06.17.00.29.09
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 17 Jun 2025 00:29:10 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: c32e2f1c-4b4c-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1750145351; x=1750750151; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=se/6I/L7oJX6hASl2+XzhmWuomcmPuReiipKCBZMnAw=;
        b=jdEkIZDq5Tx9/7p228EHhKvsJ1zCa09ypfchDWv6HLyZzDKDbVx4z2gPOrV1ZKr5bi
         8403XWEGMSN/vNzIqHtr+7UmO1L4El1+uwqZaiPO8Vr6uOOqDRyiFOtHB806RzGhkr0G
         6OJoCSFAQciyWCcaGIawLFSnI3+8KySIMjSjL++ubj7cPiMItTtwAYjCRcGzdPfC6znz
         x6IXpEOY2tWvmELDs+6SFSMVqzyCoI8/XEOHOj4kDQZaVsjOEOR309EJFQkQgbMDaBhh
         8SUoTQZ5BGTNVXPs+PAx1P8KBZRG5urx0pZ1e5Mts2RmY7wbLcMw7jBeryYMPze5kAAO
         9njQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1750145351; x=1750750151;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=se/6I/L7oJX6hASl2+XzhmWuomcmPuReiipKCBZMnAw=;
        b=Adn8L/7VPDyLrluy1gY63QSYk7o0UqGcoeJ5evjGqjIND3eUjwKafV7HgV9F9wJ8OK
         89qSNJetbv76mnbqvuv1WTvDBkpk4Agf7v9hmHMj/mZrao0JW1bUSlkcEeGSl4q2v/G2
         Ex3ImfYXf1MLIEVlRlz6QGZ1k8bvoUyL1jET0oLPKJSr3GAxGLDnvzH3HYKEKgG/kdUI
         BXOyB0pgBpws4LUmZLSGvXPjNOJNC9j06kVFNuYzeR9cH1ggMMY/OrPJmoC7CPl2yy8l
         vTDuLpTejRYWyKkWe1u7Iyw4TzAzgZlgFC7o8mCF9lfjADtFJDDiGaiOmGgRby+Keor+
         CHiA==
X-Forwarded-Encrypted: i=1; AJvYcCVbQsLfTVdE48a3ako8KekCgv15oy9j9Zn0XxSFJv/MH0hn7quHXs2YFIfofCp7FkXnm8zGyYDQXazVf5s=@lists.xenproject.org
X-Gm-Message-State: AOJu0YzapVDoiUdIsfW5p7poW5IuHdRrXcnoEGVECim8ncDPOI84kic+
	PYARWGyXLo8hwd6fEg4Xjkzd8pzLNRBOmAjgEacJoc6GFrDlLfMMAAKo
X-Gm-Gg: ASbGnctGxd2k5HpCOrZnhnTe9OBURfW0K+U9esd24HyT8EvTEkLh9isAS5hdCtcycuj
	NSrlvdtZnODVEUIJxP4cBl/DCMRJ/o8ouvcaZd0isWSPhwIIPyIrFvkWX5kdyNIsGFovk0lZgCB
	jgfdY/kIsJlMiLJVpilIK9RYQp1w/I64mO+FAaMs4sLqfkeWY6XjdOvqwcO6EXlHHXOhsS4QEbv
	uVhr4cKoHVAyAJ11AO+4U5C1xzUszVmJ5s8tSiE10Vjg8hMH1KWO1ukoFu/J1TilEURU/tkj9Wv
	G6TpP7iWueWas5/k8lk7YIaJufETJ4+t/umGzSArkawS/CsT1SokRtAbNgPznXJrYTQ4+Beikye
	YcNRbf3NkSkZlUYg+LHw=
X-Google-Smtp-Source: AGHT+IFJkWnr7xAoSfj3/77t4bxaWHs1vmaGcykRKKUo/0MNeBmTPVQbPxgf8EIyMal7QVfhPX/gjQ==
X-Received: by 2002:a05:600c:6207:b0:43c:fe15:41cb with SMTP id 5b1f17b1804b1-4533ca76ff8mr126381795e9.15.1750145350563;
        Tue, 17 Jun 2025 00:29:10 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <df5e45eb-eb32-4574-b8af-a0a24bbab8e8@xen.org>
Date: Tue, 17 Jun 2025 09:29:09 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [XENBUS PATCH v3 1/2] Use Windows 10 APIs to inflate/deflate
 balloon
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
References: <20250612110018.1493-1-ngoc-tu.dinh@vates.tech>
 <f6cd579a-eadd-4800-9194-591dd203d5af@xen.org>
 <c62e0c53-1ef0-4328-8b5f-09240bbdd0f6@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <c62e0c53-1ef0-4328-8b5f-09240bbdd0f6@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

On 13/06/2025 11:41, Tu Dinh wrote:
> On 13/06/2025 12:36, Paul Durrant wrote:
>> On 12/06/2025 12:00, Tu Dinh wrote:
>>> Currently the balloon driver allocates pages as normal memory, which
>>> causes Windows to report the ballooned memory as kernel-allocated
>>> instead of unavailable.
>>>
>>> Windows 10 provides MM_ALLOCATE_AND_HOT_REMOVE to remove pages from
>>> the physical memory pool. The removed pages can be added back with
>>> MmAddPhysicalMemory.
>>>
>>> Using this feature, the real VM memory capacity will be correctly
>>> reported in Task Manager.
>>>
>>> Balloon deflation is implemented using calls to MmAddPhysicalMemory on
>>> contiguous PFN ranges.
>>>
>>> Note that MM_ALLOCATE_AND_HOT_REMOVE actually removes the pages from
>>> memory space, so the resulting MDL will have the MDL_IO_SPACE flag;
>>> similarly, when probing the freed MDL on deflation, we'll also have to
>>> set MDL_IO_SPACE.
>>>
>>> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
>>> ---
>>> v3: Fix the issue where hot-removed memory will be in I/O space.
>>> v2: Updated commit message to say what the patch does. No code change.
>>> ---
>>>    src/xenbus/balloon.c | 43 ++++++++++++++++++++++++++++++++++++++-----
>>>    1 file changed, 38 insertions(+), 5 deletions(-)
>>>
>>
>> How much testing has this had? v3 came out of nowhere.
> 
> The v3 fix came from manually testing the ballooning feature with a
> debug build under Driver Verifier (standard + a few extra checks). Aside
> from that I've done CodeQL and VS code analysis on the driver.
> 
> On a side note, the Xen PV drivers use old annotations which are not
> checked by VS. Is there interest in upgrading to SAL 2.0? I tried doing
> so with xenbus and it caught a couple small issues.
> 

Series applied


From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 07:34:16 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 07:34:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017848.1394831 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQpj-00031c-Ok; Tue, 17 Jun 2025 07:34:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017848.1394831; Tue, 17 Jun 2025 07:34:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQpj-00031V-Ll; Tue, 17 Jun 2025 07:34:15 +0000
Received: by outflank-mailman (input) for mailman id 1017848;
 Tue, 17 Jun 2025 07:34:14 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=MAa4=ZA=bounce.vates.tech=bounce-md_30504962.68511a73.v1-5f16002aa1424f82be7be56aa644293c@srs-se1.protection.inumbo.net>)
 id 1uRQpi-00031F-97
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 07:34:14 +0000
Received: from mail145-24.atl61.mandrillapp.com
 (mail145-24.atl61.mandrillapp.com [198.2.145.24])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 7679a365-4b4d-11f0-a309-13f23c93f187;
 Tue, 17 Jun 2025 09:34:12 +0200 (CEST)
Received: from pmta06.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail145-24.atl61.mandrillapp.com (Mailchimp) with ESMTP id
 4bLzC74yv6zGlspRd
 for <win-pv-devel@lists.xenproject.org>; Tue, 17 Jun 2025 07:34:11 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 5f16002aa1424f82be7be56aa644293c; Tue, 17 Jun 2025 07:34:11 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7679a365-4b4d-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750145651; x=1750415651;
	bh=c4pWURnZfyM00uIkY/jM508CNfn7XFCbpiB0iovD3hI=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=CLgv63g2FJAozAZUbD5ifjBCLNZCYwkY04Nia6DvDi4K7Azj2971BUNAhI3jn3/u1
	 6oF2ilNjTR0Aimej+zk6lNPkv7HSwhOvcy2UAwCl930V6RDIMBk2lGbYtlagGSp4pM
	 iVZm5/GPbDityrw6FJtKwEM8KE5BRaNE8BKbwY4qU/AQdI6RgQJQMOsxuMirKxwLdj
	 qfgWJsU2iuDUlNgSuEr+EWAm2xZWrVlPOUQ2hGO8aHmANcNXpKnGkyb9Kx4xFrNxna
	 pyY5/rOi2KZaBCq4AOSQI46vc4AI5QltomaFeBGH4FCAOw1iMOi1y7+nQgxWQXmbU6
	 cxjcpXxhL9c4g==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750145651; x=1750406151; i=ngoc-tu.dinh@vates.tech;
	bh=c4pWURnZfyM00uIkY/jM508CNfn7XFCbpiB0iovD3hI=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=U5rljJC1NyoV92UHWeLCxhiw0fIfJVr8rfLJ2s9hkFYBEK2EVARD6ZyNMHp6M+GbJ
	 903HbfIgeis4gv+PCYPjEEC1s+qknQ7e3fThmPDQXYP+HOV8y2FXCsrW7z47pmp+J2
	 5Dbo9aBZ5hIgvMlPiNVGoXNxDxJHYVYOx9hqUHGSzpb7GuawXdnL6M/hkhJqHzf0on
	 UyXLopk9DyEzn3WK9/Tc7qabD4UR8ZdcsLeV0LIY9lezWfY3NSTohK1sX62aymFuWp
	 TfClJQItMiGuj7CipawwnmlDLjeVaOkwPooiE8Az6v1gaDAx5++VyEmmyZuX/IUY9n
	 PD7oBP679V9BA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v3=201/5]=20Fix=20error=20variable=20type=20in=20TryAutoReboot?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750145650988
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250617073403.117-2-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250617073403.117-1-ngoc-tu.dinh@vates.tech>
References: <20250617073403.117-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.5f16002aa1424f82be7be56aa644293c?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250617:md
Date: Tue, 17 Jun 2025 07:34:11 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Error variables used with Reg* should be DWORD instead of HRESULT.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 185838f..c87a42f 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -469,7 +469,7 @@ TryAutoReboot(
     PTCHAR              Description;
     PTCHAR              Text;
     DWORD               TextLength;
-    HRESULT             Error;
+    DWORD               Error;
 
     Length = sizeof (DWORD);
 
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 07:34:16 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 07:34:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017849.1394833 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQpj-00031v-RK; Tue, 17 Jun 2025 07:34:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017849.1394833; Tue, 17 Jun 2025 07:34:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQpj-00031j-N1; Tue, 17 Jun 2025 07:34:15 +0000
Received: by outflank-mailman (input) for mailman id 1017849;
 Tue, 17 Jun 2025 07:34:14 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=O7Uj=ZA=bounce.vates.tech=bounce-md_30504962.68511a73.v1-6c0c2298de8f4349aa8eae977f8c9538@srs-se1.protection.inumbo.net>)
 id 1uRQpi-000318-Bg
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 07:34:14 +0000
Received: from mail187-14.suw11.mandrillapp.com
 (mail187-14.suw11.mandrillapp.com [198.2.187.14])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 7668a960-4b4d-11f0-b894-0df219b8e170;
 Tue, 17 Jun 2025 09:34:12 +0200 (CEST)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4bLzC739ggz8XXVnC
 for <win-pv-devel@lists.xenproject.org>; Tue, 17 Jun 2025 07:34:11 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 6c0c2298de8f4349aa8eae977f8c9538; Tue, 17 Jun 2025 07:34:11 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7668a960-4b4d-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750145651; x=1750415651;
	bh=u+/DNnmY0uiK43knqEgkOJ3LltDLw5P+iMSuXd0g9I8=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=1lRO9Hd8VoUweWpUv+4m/CpIGr7Hs9F+ok8c/uZPFhp6UgSJYoOp+2VgsHCLvDBro
	 s24h7iKQ3MIVDlBDnvPxCihxb5i2S4W5ITY7bgsUcvFcieEvpMG7/DmCnHn9DpxjMb
	 RNO8DUXGeJJBjLkYRu+35qGICknwVEvXszLhp/7ySWDMeVYMW0qqieg9S2B8bNRaSg
	 KJsjkcX34DxEweDHpaDiTobgbsElGdu6QoBeaklOsDtwZLsq8Fb9BjqQ7uVkQRGOMV
	 iqqDm0uE1WeRFisinRsY/ntNeUHicubie4nfuuk0tD77B2v+47Ll8ZNvnw+6wyx/Jt
	 7AIjGtVuAFb5w==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750145651; x=1750406151; i=ngoc-tu.dinh@vates.tech;
	bh=u+/DNnmY0uiK43knqEgkOJ3LltDLw5P+iMSuXd0g9I8=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=PI8A5aExnXvgrI1UoC6WRTGndlxOfgQiw8DBPokuMh15blB4oPjl6qZbIF6wHIBET
	 0jtPth1dK5sRqciQJ3b0PUvw0M4Nh6epqKNmN0laO9GrbYJvR6LvYGvxnnUjnEn6vT
	 xYgxR3UQEpNEysDiDILqL5L+ANhD8HHc8CNWsUl0whOmkUhcSa9vd65RXJFAvKQf+z
	 VKiZvnRxEd0FSDJMMJEpH0GoeBgHprZlo9w5PE7AdIyHpe8/TvMD14dKnccQ40idr2
	 AEEpM74NYxQlj9BrhAshJf/B0chCJ6ThV8qPyCrxEXKFpizdUjXOUaOtBgBCMOr7yS
	 lTRA2URxH9HVA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v3=200/5]=20Autoreboot=20rework?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750145650629
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250617073403.117-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.6c0c2298de8f4349aa8eae977f8c9538?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250617:md
Date: Tue, 17 Jun 2025 07:34:11 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Rework and clean up reboot prompt and check logic:
* Since autoreboot takes precedence over reboot prompts, make TryAutoReboot
  call PromptForReboot instead of the other way around.
* Any reboot request sets Context->RebootRequestedBy with the driver name.
* Reboot requests can be paused by active installations, system power requests
  or denied by the user (made explicit in the initial check).
* Run the session prompts in a separate thread to avoid blocking main monitor.
* Retry reboot request every minute (if exists).

v3: Fix error variable type for Reg* functions in TryAutoReboot
v2: https://lists.xenproject.org/archives/html/win-pv-devel/2025-06/msg00005.html
v1: https://lists.xenproject.org/archives/html/win-pv-devel/2025-05/msg00007.html

Tu Dinh (5):
  Fix error variable type in TryAutoReboot
  Rework autoreboot retry logic
  Repeat TryAutoReboot() with timer
  Don't autoreboot during ES_SYSTEM_REQUIRED
  Check for active installation before autoreboot

 src/monitor/monitor.c                        | 509 +++++++++++++------
 vs2019/xenbus_monitor/xenbus_monitor.vcxproj |   2 +-
 vs2022/xenbus_monitor/xenbus_monitor.vcxproj |   2 +-
 3 files changed, 351 insertions(+), 162 deletions(-)

-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 07:34:17 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 07:34:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017850.1394839 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQpk-00035D-RU; Tue, 17 Jun 2025 07:34:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017850.1394839; Tue, 17 Jun 2025 07:34:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQpk-000356-OM; Tue, 17 Jun 2025 07:34:16 +0000
Received: by outflank-mailman (input) for mailman id 1017850;
 Tue, 17 Jun 2025 07:34:15 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=jWAb=ZA=bounce.vates.tech=bounce-md_30504962.68511a74.v1-6f5afccb069b420a85e99343ba34e6fe@srs-se1.protection.inumbo.net>)
 id 1uRQpj-000318-Bz
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 07:34:15 +0000
Received: from mail187-14.suw11.mandrillapp.com
 (mail187-14.suw11.mandrillapp.com [198.2.187.14])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 76ab092c-4b4d-11f0-b894-0df219b8e170;
 Tue, 17 Jun 2025 09:34:13 +0200 (CEST)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4bLzC81Jwsz8XXVnV
 for <win-pv-devel@lists.xenproject.org>; Tue, 17 Jun 2025 07:34:12 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 6f5afccb069b420a85e99343ba34e6fe; Tue, 17 Jun 2025 07:34:12 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 76ab092c-4b4d-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750145652; x=1750415652;
	bh=4h3d8fbsJDIj+McWcV2m9HZqFC0/TWn78hPVD0u73t8=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=iHDGm2lUKc9Bw/05XSr+3iZ/lKgBuDPmL3hIBUIoiG9texyHNWZt/tKqiNt7PPAlR
	 WXgp2+gIGS9Pcn0bQs389amIri/hJ7zlsT9DVKM+mVX0uoTI5m9+c6OcvNrLLvEyxI
	 ZKH729T9rgoqP1FHk9vi+kUYFd215KLWAV+09pnTu7srvx2WoEHzLSsWwYw2hPPM8R
	 mFmAH6HQNdORbMTy4xQkgOCwt3BbWzdVHPH1KjTxveMrZNi2VYZ1AFgt7lXf76l0cf
	 otZhbU+re9T95uO9EC43/PMdGcp2deL2ldNfy8VL2I76xoJswwCHeGTJguyS1q5Bli
	 2ibnzddMqFPJQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750145652; x=1750406152; i=ngoc-tu.dinh@vates.tech;
	bh=4h3d8fbsJDIj+McWcV2m9HZqFC0/TWn78hPVD0u73t8=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=ag0+nH0VZB6gPUvEwQsn4lxwdzmoXDJuQNaMKqv4oses1Cc9VO6ixUJC3AtqVS9Qk
	 b3MsJyIkLyCg6T4F8N39gS1araE7jnARB5/ltxS9SK7Rp+MOsUUFntBXcYqAaXcTzL
	 WKbtgsKu4AXsOY3vZxmtxt5VhqDHmVxcfsBEBySOj0LXqRBfzDyfMUgISWKOZK2acY
	 UTlhMZvtM7yAe3SzlVe1ZIcwjEdYcnK73v4qVG6Zyn6vL3DUE8OXF5uu2V+IwXUjtT
	 fugotRBsQhp6a1u4kM/5weQEdbwmZwj/lJTutUjXmLBTyRLvfRVKzJsNkJfTan8vpN
	 0BUUdsWLurDog==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v3=202/5]=20Rework=20autoreboot=20retry=20logic?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750145651297
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250617073403.117-3-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250617073403.117-1-ngoc-tu.dinh@vates.tech>
References: <20250617073403.117-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.6f5afccb069b420a85e99343ba34e6fe?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250617:md
Date: Tue, 17 Jun 2025 07:34:12 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Since autoreboot takes precedence over reboot prompts, reorganize the
monitor to make TryAutoReboot the reboot entry point instead of
PromptForReboot.

- Prompt for reboot from another thread to avoid blocking main thread.
  Also save the reboot prompt response for later use.
- Add a new context entry RebootRequestedBy, set in PromptForReboot.
- Replace the RebootPending check with an one-time check of
  Context->RebootPrompted at prompt time.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
Reviewed-by: Paul Durrant <paul@xen.org>
---
 src/monitor/monitor.c | 442 +++++++++++++++++++++++++++---------------
 1 file changed, 283 insertions(+), 159 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index c87a42f..1bb4705 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -61,9 +61,19 @@ typedef struct _MONITOR_CONTEXT {
     PTCHAR                  Title;
     PTCHAR                  Text;
     PTCHAR                  Question;
-    BOOL                    RebootPending;
+    BOOL                    RebootPrompted;
+    PTCHAR                  RebootRequestedBy;
+    HANDLE                  ResponseEvent;
+    DWORD                   Response;
 } MONITOR_CONTEXT, *PMONITOR_CONTEXT;
 
+typedef struct _REBOOT_PROMPT {
+    PTCHAR                  Title;
+    PTCHAR                  Text;
+    HANDLE                  ResponseEvent;
+    PDWORD                  PResponse;
+} REBOOT_PROMPT, *PREBOOT_PROMPT;
+
 MONITOR_CONTEXT MonitorContext;
 
 #define MAXIMUM_BUFFER_SIZE 1024
@@ -453,7 +463,219 @@ fail1:
     return NULL;
 }
 
-static BOOL
+static VOID
+RebootPromptFree(
+    PREBOOT_PROMPT      Prompt
+    )
+{
+    if (Prompt) {
+        free(Prompt->Text);
+        free(Prompt->Title);
+        free(Prompt);
+    }
+}
+
+static DWORD WINAPI
+DoPromptForReboot(
+    LPVOID lpThreadParameter
+    )
+{
+    PREBOOT_PROMPT      Prompt = lpThreadParameter;
+    DWORD               TitleLength;
+    DWORD               TextLength;
+    DWORD               Timeout;
+    PWTS_SESSION_INFO   SessionInfo;
+    DWORD               Count;
+    DWORD               Index;
+    BOOL                Success;
+    DWORD               Error;
+
+    assert(Prompt);
+    assert(Prompt->ResponseEvent && Prompt->PResponse);
+    assert(Prompt->Title && Prompt->Text);
+
+    Error = ERROR_SUCCESS;
+
+    TitleLength = (DWORD)((_tcslen(Prompt->Title) +
+                           1) * sizeof (TCHAR));
+    TextLength = (DWORD)((_tcslen(Prompt->Text) +
+                           1) * sizeof (TCHAR));
+
+    Success = WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
+                                   0,
+                                   1,
+                                   &SessionInfo,
+                                   &Count);
+    if (!Success) {
+        Error = GetLastError();
+        goto fail1;
+    }
+
+    Timeout = GetPromptTimeout();
+
+    *Prompt->PResponse = 0;
+
+    for (Index = 0; Index < Count; Index++) {
+        DWORD                   SessionId = SessionInfo[Index].SessionId;
+        PTCHAR                  Name = SessionInfo[Index].pWinStationName;
+        WTS_CONNECTSTATE_CLASS  State = SessionInfo[Index].State;
+        DWORD                   Response;
+
+        Log("[%u]: %s [%s]",
+            SessionId,
+            Name,
+            WTSStateName(State));
+
+        if (State != WTSActive)
+            continue;
+
+        Success = WTSSendMessage(WTS_CURRENT_SERVER_HANDLE,
+                                 SessionId,
+                                 Prompt->Title,
+                                 TitleLength,
+                                 Prompt->Text,
+                                 TextLength,
+                                 MB_YESNO | MB_ICONEXCLAMATION,
+                                 Timeout,
+                                 &Response,
+                                 TRUE);
+
+        if (!Success)
+            goto fail2;
+
+        *Prompt->PResponse = Response;
+        (VOID) SetEvent(Prompt->ResponseEvent);
+
+        break;
+    }
+
+    WTSFreeMemory(SessionInfo);
+    RebootPromptFree(Prompt);
+
+    return ERROR_SUCCESS;
+
+fail2:
+    Log("fail2");
+    *Prompt->PResponse = 0;
+
+fail1:
+    RebootPromptFree(Prompt);
+
+    return Error;
+}
+
+static VOID
+PromptForReboot(
+    IN PTCHAR           DriverName
+    )
+{
+    PMONITOR_CONTEXT    Context = &MonitorContext;
+    HRESULT             Result;
+    PREBOOT_PROMPT      Prompt;
+    PTCHAR              DisplayName;
+    PTCHAR              Description;
+    HANDLE              PromptThread;
+    DWORD               TextLength;
+    DWORD               Error;
+
+    assert(DriverName);
+
+    /*
+     * Can't use Context->Response here since a previous prompt may not have
+     * gotten a response.
+     */
+    if (Context->RebootPrompted)
+        return;
+    Context->RebootPrompted = TRUE;
+
+    Log("====> (%s)", DriverName);
+
+    Prompt = calloc(1, sizeof (REBOOT_PROMPT));
+    if (Prompt == NULL) {
+        Error = ERROR_OUTOFMEMORY;
+        goto fail1;
+    }
+    Prompt->ResponseEvent = Context->ResponseEvent;
+    Prompt->PResponse = &Context->Response;
+
+    Prompt->Title = _tcsdup(Context->Title);
+    if (Prompt->Title == NULL) {
+        Error = ERROR_OUTOFMEMORY;
+        goto fail2;
+    }
+
+    DisplayName = GetDisplayName(DriverName);
+    if (DisplayName == NULL) {
+        Error = GetLastError();
+        goto fail3;
+    }
+
+    Description = _tcsrchr(DisplayName, ';');
+    if (Description == NULL)
+        Description = DisplayName;
+    else
+        Description++;
+
+    TextLength = (DWORD)((_tcslen(Description) +
+                          1 + // ' '
+                          _tcslen(Context->Text) +
+                          1 + // ' '
+                          _tcslen(Context->Question) +
+                          1) * sizeof (TCHAR));
+
+    Prompt->Text = calloc(1, TextLength);
+    if (Prompt->Text == NULL) {
+        Error = ERROR_OUTOFMEMORY;
+        goto fail4;
+    }
+
+    Result = StringCbPrintf(Prompt->Text,
+                            TextLength,
+                            TEXT("%s %s %s"),
+                            Description,
+                            Context->Text,
+                            Context->Question);
+    assert(SUCCEEDED(Result));
+
+    PromptThread = CreateThread(NULL,
+                                0,
+                                &DoPromptForReboot,
+                                Prompt,
+                                0,
+                                NULL);
+    if (PromptThread == NULL) {
+        Error = GetLastError();
+        goto fail4;
+    }
+
+    CloseHandle(PromptThread);
+    free(DisplayName);
+    // ownership of Prompt handed to prompt thread
+
+    return;
+
+fail4:
+    Log("fail4");
+    free(DisplayName);
+
+fail3:
+    Log("fail3");
+
+fail2:
+    Log("fail2");
+
+fail1:
+    {
+        PTCHAR  Message;
+        Message = GetErrorMessage(Error);
+        Log("fail1 (%s)", Message);
+        LocalFree(Message);
+    }
+
+    RebootPromptFree(Prompt);
+}
+
+static VOID
 TryAutoReboot(
     IN PTCHAR           DriverName
     )
@@ -471,6 +693,18 @@ TryAutoReboot(
     DWORD               TextLength;
     DWORD               Error;
 
+    if (!Context->RebootRequestedBy) {
+        Context->RebootRequestedBy = _tcsdup(DriverName);
+        if (!Context->RebootRequestedBy) {
+            Error = ERROR_OUTOFMEMORY;
+            goto fail1;
+        }
+    }
+
+    // We don't want to suddenly reboot if the user's already said no.
+    if (Context->Response == IDNO)
+        goto done;
+
     Length = sizeof (DWORD);
 
     Error = RegQueryValueEx(Context->ParametersKey,
@@ -484,7 +718,7 @@ TryAutoReboot(
         AutoReboot = 0;
 
     if (AutoReboot == 0)
-        goto done;
+        goto prompt;
 
     Length = sizeof (DWORD);
 
@@ -499,7 +733,7 @@ TryAutoReboot(
         RebootCount = 0;
 
     if (RebootCount >= AutoReboot)
-        goto done;
+        goto prompt;
 
     Log("AutoRebooting (reboot %u of %u)\n",
         RebootCount,
@@ -516,8 +750,6 @@ TryAutoReboot(
 
     (VOID) RegFlushKey(Context->ParametersKey);
 
-    Context->RebootPending = TRUE;
-
     Error = RegQueryValueEx(Context->ParametersKey,
                             "AutoRebootTimeout",
                             NULL,
@@ -528,9 +760,11 @@ TryAutoReboot(
         Type != REG_DWORD)
         Timeout = 60;
 
-    DisplayName = GetDisplayName(DriverName);
-    if (DisplayName == NULL)
-        goto fail1;
+    DisplayName = GetDisplayName(Context->RebootRequestedBy);
+    if (DisplayName == NULL) {
+        Error = GetLastError();
+        goto fail2;
+    }
 
     Description = _tcsrchr(DisplayName, ';');
     if (Description == NULL)
@@ -544,8 +778,10 @@ TryAutoReboot(
                           1) * sizeof (TCHAR));
 
     Text = calloc(1, TextLength);
-    if (Text == NULL)
-        goto fail2;
+    if (Text == NULL) {
+        SetLastError(ERROR_OUTOFMEMORY);
+        goto fail3;
+    }
 
     Result = StringCbPrintf(Text,
                             TextLength,
@@ -560,165 +796,33 @@ TryAutoReboot(
 
     free(Text);
 
-    return TRUE;
-
-done:
-    return FALSE;
-
-fail2:
-    Log("fail2");
-
-    free(DisplayName);
-
-fail1:
-    Error = GetLastError();
-
-    {
-        PTCHAR  Message;
-        Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
-        LocalFree(Message);
-    }
-
-    return FALSE;
-}
-
-static VOID
-PromptForReboot(
-    IN PTCHAR           DriverName
-    )
-{
-    PMONITOR_CONTEXT    Context = &MonitorContext;
-    HRESULT             Result;
-    PTCHAR              Title;
-    DWORD               TitleLength;
-    PTCHAR              DisplayName;
-    PTCHAR              Description;
-    PTCHAR              Text;
-    DWORD               TextLength;
-    PWTS_SESSION_INFO   SessionInfo;
-    DWORD               Count;
-    DWORD               Index;
-    BOOL                Success;
-    HRESULT             Error;
-
-    Log("====> (%s)", DriverName);
-
-    Title = Context->Title;
-    TitleLength = (DWORD)((_tcslen(Context->Title) +
-                           1) * sizeof (TCHAR));
-
-    // AutoReboot is set, DoReboot has been called
-    if (TryAutoReboot(DriverName))
-        goto done;
-
-    DisplayName = GetDisplayName(DriverName);
-    if (DisplayName == NULL)
-        goto fail1;
-
-    Description = _tcsrchr(DisplayName, ';');
-    if (Description == NULL)
-        Description = DisplayName;
-    else
-        Description++;
-
-    TextLength = (DWORD)((_tcslen(Description) +
-                          1 + // ' '
-                          _tcslen(Context->Text) +
-                          1 + // ' '
-                          _tcslen(Context->Question) +
-                          1) * sizeof (TCHAR));
-
-    Text = calloc(1, TextLength);
-    if (Text == NULL)
-        goto fail2;
-
-    Result = StringCbPrintf(Text,
-                            TextLength,
-                            TEXT("%s %s %s"),
-                            Description,
-                            Context->Text,
-                            Context->Question);
-    assert(SUCCEEDED(Result));
-
-    Success = WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
-                                   0,
-                                   1,
-                                   &SessionInfo,
-                                   &Count);
-    if (!Success)
-        goto fail3;
-
-    for (Index = 0; Index < Count; Index++) {
-        DWORD                   SessionId = SessionInfo[Index].SessionId;
-        PTCHAR                  Name = SessionInfo[Index].pWinStationName;
-        WTS_CONNECTSTATE_CLASS  State = SessionInfo[Index].State;
-        DWORD                   Timeout;
-        DWORD                   Response;
-
-        Log("[%u]: %s [%s]",
-            SessionId,
-            Name,
-            WTSStateName(State));
-
-        if (State != WTSActive)
-            continue;
-
-        Timeout = GetPromptTimeout();
-
-        Success = WTSSendMessage(WTS_CURRENT_SERVER_HANDLE,
-                                 SessionId,
-                                 Title,
-                                 TitleLength,
-                                 Text,
-                                 TextLength,
-                                 MB_YESNO | MB_ICONEXCLAMATION,
-                                 Timeout,
-                                 &Response,
-                                 TRUE);
-
-        if (!Success)
-            goto fail4;
-
-        Context->RebootPending = TRUE;
-
-        if (Response == IDYES || Response == IDTIMEOUT)
-            DoReboot(NULL, 0);
-
-        break;
-    }
+    return;
 
-    WTSFreeMemory(SessionInfo);
+prompt:
+    PromptForReboot(Context->RebootRequestedBy);
 
-    free(DisplayName);
+    return;
 
 done:
-    Log("<====");
-
     return;
 
-fail4:
-    Log("fail4");
-
-    WTSFreeMemory(SessionInfo);
-
 fail3:
     Log("fail3");
 
+    free(DisplayName);
+
 fail2:
     Log("fail2");
 
-    free(DisplayName);
-
 fail1:
-    Error = GetLastError();
-
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
     }
+
+    return;
 }
 
 static VOID
@@ -819,8 +923,8 @@ loop:
 found:
     RegCloseKey(SubKey);
 
-    if (!Context->RebootPending)
-        PromptForReboot(SubKeyName);
+    if (!Context->RebootRequestedBy)
+        TryAutoReboot(SubKeyName);
 
 done:
     free(SubKeyName);
@@ -1294,9 +1398,17 @@ MonitorMain(
     if (Context->RequestEvent == NULL)
         goto fail6;
 
+    Context->ResponseEvent = CreateEvent(NULL,
+                                         FALSE,
+                                         FALSE,
+                                         NULL);
+    if (Context->ResponseEvent == NULL)
+        goto fail7;
+    Context->Response = 0;
+
     Success = GetRequestKeyName(&RequestKeyName);
     if (!Success)
-        goto fail7;
+        goto fail8;
 
     Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
                            RequestKeyName,
@@ -1308,22 +1420,23 @@ MonitorMain(
                            &Context->RequestKey,
                            NULL);
     if (Error != ERROR_SUCCESS)
-        goto fail8;
+        goto fail9;
 
     Success = GetDialogParameters();
     if (!Success)
-        goto fail9;
+        goto fail10;
 
     SetEvent(Context->RequestEvent);
 
     ReportStatus(SERVICE_RUNNING, NO_ERROR, 0);
 
     for (;;) {
-        HANDLE  Events[2];
+        HANDLE  Events[3];
         DWORD   Object;
 
         Events[0] = Context->StopEvent;
         Events[1] = Context->RequestEvent;
+        Events[2] = Context->ResponseEvent;
 
         Log("waiting (%u)...", ARRAYSIZE(Events));
         Object = WaitForMultipleObjects(ARRAYSIZE(Events),
@@ -1342,6 +1455,11 @@ MonitorMain(
             CheckRequestKey();
             break;
 
+        case WAIT_OBJECT_0 + 2:
+            if (Context->Response == IDYES || Context->Response == IDTIMEOUT)
+                DoReboot(NULL, 0);
+            break;
+
         default:
             break;
         }
@@ -1355,6 +1473,7 @@ done:
     free(Context->Title);
     CloseHandle(Context->RequestKey);
     free(RequestKeyName);
+    CloseHandle(Context->ResponseEvent);
     CloseHandle(Context->RequestEvent);
     CloseHandle(Context->StopEvent);
 
@@ -1369,15 +1488,20 @@ done:
 
     return;
 
+fail10:
+    Log("fail10");
+
+    CloseHandle(Context->RequestKey);
+
 fail9:
     Log("fail9");
 
-    CloseHandle(Context->RequestKey);
+    free(RequestKeyName);
 
 fail8:
     Log("fail8");
 
-    free(RequestKeyName);
+    CloseHandle(Context->ResponseEvent);
 
 fail7:
     Log("fail7");
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 07:34:17 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 07:34:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017851.1394842 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQpl-000378-Tr; Tue, 17 Jun 2025 07:34:17 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017851.1394842; Tue, 17 Jun 2025 07:34:17 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQpl-000373-QR; Tue, 17 Jun 2025 07:34:17 +0000
Received: by outflank-mailman (input) for mailman id 1017851;
 Tue, 17 Jun 2025 07:34:16 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=0Vbn=ZA=bounce.vates.tech=bounce-md_30504962.68511a74.v1-68381056a2bb4e6ba24db72ee4992d02@srs-se1.protection.inumbo.net>)
 id 1uRQpk-00031F-21
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 07:34:16 +0000
Received: from mail187-14.suw11.mandrillapp.com
 (mail187-14.suw11.mandrillapp.com [198.2.187.14])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 77df4886-4b4d-11f0-a309-13f23c93f187;
 Tue, 17 Jun 2025 09:34:15 +0200 (CEST)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4bLzC82HPPz8XXVnW
 for <win-pv-devel@lists.xenproject.org>; Tue, 17 Jun 2025 07:34:12 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 68381056a2bb4e6ba24db72ee4992d02; Tue, 17 Jun 2025 07:34:12 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 77df4886-4b4d-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750145652; x=1750415652;
	bh=CQSfwdgiD+Oim6J91Z4hDALCorpQTwfTXqJfxzZLIwk=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=sfJASEolKepaXMED8sN1KabK3DEgi3aICMUS5QSyQ0sTf2URU5myIOBrjJ8DKf2jy
	 qp3DN68Lf34zTUdvrnuCoch7+y2Llh3rw51M5TBqhJ7NSQUcTP08m24Rh2+IX7MQYf
	 LNh1PWLTvTGT7nqFgIkwNCyJarJmiR23vVvSJIF3cXmrMvYOXKl+SZj8F11d1E0jmx
	 d8niw2zGsrc0LHVW8Het/gdNjGEBz2OBtNWtMA8eEjzWmV6Dldav/0cyRf+XwZXanr
	 NfcdGWbixWsw0d/NTaJJGH/pqamQOorxsiv42Y/uxiBXtnsh70V0MUr6T3+Wk9gaTC
	 tX52aUJW1RPxQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750145652; x=1750406152; i=ngoc-tu.dinh@vates.tech;
	bh=CQSfwdgiD+Oim6J91Z4hDALCorpQTwfTXqJfxzZLIwk=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=12xVxFpRqtuJMxsdbw7xS+5A5S/ehtKbvPd8KBzou7vHkS6d9jDjws1i86W8HaJZk
	 VbohStk5xxuAuEP+nMWYCyesi0o3EfK7UxqyJftkQot44TsQ7Lkb/kLOGBHk+BLzQd
	 dtVCW7JiN+an56wfQ1C+ZpNsJnXYodnNULO8zQTjc1hbJ2YGy++zSFI2ucQMJdsh9J
	 vUL2a/R7FCd0oNn5yxPzzEQZo+UZzBXliy4PNfrldW0j1ex8+pKs7vB2UZbpsJatVU
	 Vij4Ay9PYGAMCvHZM2dqO8IKOEXiGe78RzqvfzUHMW2QDO1bU0yA5jgkrvHCbZyC6m
	 +QM/6SQ01TrPw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v3=203/5]=20Repeat=20TryAutoReboot()=20with=20timer?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750145651597
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250617073403.117-4-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250617073403.117-1-ngoc-tu.dinh@vates.tech>
References: <20250617073403.117-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.68381056a2bb4e6ba24db72ee4992d02?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250617:md
Date: Tue, 17 Jun 2025 07:34:12 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Add a timer that calls TryAutoReboot() every minute if reboot has been
requested beforehand.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
Reviewed-by: Paul Durrant <paul@xen.org>
---
 src/monitor/monitor.c | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 1bb4705..ccb2d8a 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -57,6 +57,7 @@ typedef struct _MONITOR_CONTEXT {
     HANDLE                  EventLog;
     HANDLE                  StopEvent;
     HANDLE                  RequestEvent;
+    HANDLE                  Timer;
     HKEY                    RequestKey;
     PTCHAR                  Title;
     PTCHAR                  Text;
@@ -77,6 +78,7 @@ typedef struct _REBOOT_PROMPT {
 MONITOR_CONTEXT MonitorContext;
 
 #define MAXIMUM_BUFFER_SIZE 1024
+#define REBOOT_RETRY_DELAY  60000L // 1 minute
 
 #define SERVICES_KEY "SYSTEM\\CurrentControlSet\\Services"
 
@@ -1347,6 +1349,7 @@ MonitorMain(
     PTCHAR              RequestKeyName;
     BOOL                Success;
     HRESULT             Error;
+    LARGE_INTEGER       DueTime;
 
     UNREFERENCED_PARAMETER(argc);
     UNREFERENCED_PARAMETER(argv);
@@ -1426,17 +1429,33 @@ MonitorMain(
     if (!Success)
         goto fail10;
 
+    Context->Timer = CreateWaitableTimer(NULL, FALSE, NULL);
+    if (Context->Timer == NULL)
+        goto fail11;
+
+    DueTime.QuadPart = -10000LL * REBOOT_RETRY_DELAY;
+
+    Success = SetWaitableTimer(Context->Timer,
+                               &DueTime,
+                               REBOOT_RETRY_DELAY,
+                               NULL,
+                               NULL,
+                               FALSE);
+    if (!Success)
+        goto fail12;
+
     SetEvent(Context->RequestEvent);
 
     ReportStatus(SERVICE_RUNNING, NO_ERROR, 0);
 
     for (;;) {
-        HANDLE  Events[3];
+        HANDLE  Events[4];
         DWORD   Object;
 
         Events[0] = Context->StopEvent;
         Events[1] = Context->RequestEvent;
         Events[2] = Context->ResponseEvent;
+        Events[3] = Context->Timer;
 
         Log("waiting (%u)...", ARRAYSIZE(Events));
         Object = WaitForMultipleObjects(ARRAYSIZE(Events),
@@ -1460,12 +1479,21 @@ MonitorMain(
                 DoReboot(NULL, 0);
             break;
 
+        case WAIT_OBJECT_0 + 3:
+            if (Context->RebootRequestedBy)
+                TryAutoReboot(Context->RebootRequestedBy);
+            break;
+
         default:
             break;
         }
     }
 
 done:
+    free(Context->RebootRequestedBy);
+    CancelWaitableTimer(Context->Timer);
+    CloseHandle(Context->Timer);
+
     (VOID) RegDeleteTree(Context->RequestKey, NULL);
 
     free(Context->Question);
@@ -1488,6 +1516,14 @@ done:
 
     return;
 
+fail12:
+    Log("fail12");
+
+    CloseHandle(Context->Timer);
+
+fail11:
+    Log("fail11");
+
 fail10:
     Log("fail10");
 
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 07:34:18 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 07:34:18 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017852.1394847 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQpm-00037T-0e; Tue, 17 Jun 2025 07:34:18 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017852.1394847; Tue, 17 Jun 2025 07:34:17 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQpl-00037F-Rj; Tue, 17 Jun 2025 07:34:17 +0000
Received: by outflank-mailman (input) for mailman id 1017852;
 Tue, 17 Jun 2025 07:34:16 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=kn1P=ZA=bounce.vates.tech=bounce-md_30504962.68511a74.v1-d6ea924171c0499781d94a69c1496ffe@srs-se1.protection.inumbo.net>)
 id 1uRQpk-00031F-MN
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 07:34:16 +0000
Received: from mail187-14.suw11.mandrillapp.com
 (mail187-14.suw11.mandrillapp.com [198.2.187.14])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 782dcf70-4b4d-11f0-a309-13f23c93f187;
 Tue, 17 Jun 2025 09:34:15 +0200 (CEST)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4bLzC83wYMz8XXVn6
 for <win-pv-devel@lists.xenproject.org>; Tue, 17 Jun 2025 07:34:12 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 d6ea924171c0499781d94a69c1496ffe; Tue, 17 Jun 2025 07:34:12 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 782dcf70-4b4d-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750145652; x=1750415652;
	bh=2XEG+LLYYVptmX7j6yd2N6oOp8mt5Ya6bkySpl5tHBI=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=Sako6G262bq8kfEb4TdntnnmdwVjp2RfwToCm4WGib28t5h05izlVgp3CbCVGtFXp
	 E4B2QC8pWhmesFG7pOXKut30xJQYbKSKFfoFpSCwOhaITdEv+cV0SEn4YnVx0qMN6B
	 d3U3iII4Ya7F8m6Vf7wAKrE/VKV9EdsxtoQAqrskrer0WnSiVdm5e7+mrkcQkh4QEj
	 MQWvY54cKHUTdHxKjBUS12R0lus8QtqN7rwx7sCzLrgpnWsZ4tQJ2d/3/BEFLh0TML
	 H8dM3JO5VkiECedL3RbBQ+e7r6Tqq3+mawhIEwrbY7qozFx3agpLPbOHGkWFr5Ou7f
	 LCkC18RhWb0rQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750145652; x=1750406152; i=ngoc-tu.dinh@vates.tech;
	bh=2XEG+LLYYVptmX7j6yd2N6oOp8mt5Ya6bkySpl5tHBI=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=bIpqcfO545FgKeLvjfLAeXBdroh74LhEZddBEgLsw+L9v60m8L9oM+MpoYbgizW7y
	 CKbsYFJINwZVtlnAUQlVKIhNE/hLBe3o3edIMy0oBY8jvXQqr5ncgV3QTbb/bPy+Gy
	 jWrRNxkjRRyDeKXy8KyyawXNf+BP7THSdl/kgJS7wUz659sqv/s5HAk+KAaIDl7Fyi
	 j9EPHArwH/4T4hmzPxA5W5ot9Oq4RI6Hu4EuWhOMEbMhnbD3o2QZpu4j8EygmJgNVp
	 AMoW2+0oJjDi+BZfh9ieN4ftvbGfWTA6QECHPOtYdPS0DT8pYQ/N1GwnqZsMbE6Tjj
	 v5W434m0qdIVg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v3=204/5]=20Don't=20autoreboot=20during=20ES=5FSYSTEM=5FREQUIRED?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750145651846
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250617073403.117-5-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250617073403.117-1-ngoc-tu.dinh@vates.tech>
References: <20250617073403.117-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.d6ea924171c0499781d94a69c1496ffe?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250617:md
Date: Tue, 17 Jun 2025 07:34:12 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Programs may set the ES_SYSTEM_REQUIRED execution state when they're
busy with some activity (media playback, downloads, updates etc.)

We don't want to autoreboot in these situations.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
Reviewed-by: Owen Smith <owen.smith@cloud.com>
Reviewed-by: Paul Durrant <paul@xen.org>
---
 src/monitor/monitor.c                        | 12 ++++++++++++
 vs2019/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
 vs2022/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index ccb2d8a..8a56c11 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -36,6 +36,8 @@
 #include <strsafe.h>
 #include <wtsapi32.h>
 #include <cfgmgr32.h>
+#include <winternl.h>
+#include <powrprof.h>
 #include <malloc.h>
 #include <assert.h>
 
@@ -693,6 +695,8 @@ TryAutoReboot(
     PTCHAR              Description;
     PTCHAR              Text;
     DWORD               TextLength;
+    ULONG               PowerInfo;
+    NTSTATUS            Status;
     DWORD               Error;
 
     if (!Context->RebootRequestedBy) {
@@ -707,6 +711,14 @@ TryAutoReboot(
     if (Context->Response == IDNO)
         goto done;
 
+    Status = CallNtPowerInformation(SystemExecutionState,
+                                    NULL,
+                                    0,
+                                    &PowerInfo,
+                                    sizeof(PowerInfo));
+    if (Status < 0 || (PowerInfo & ES_SYSTEM_REQUIRED))
+        goto done;
+
     Length = sizeof (DWORD);
 
     Error = RegQueryValueEx(Context->ParametersKey,
diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
index 2a2c00f..047166e 100644
--- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
@@ -34,7 +34,7 @@
       <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <CETCompat>true</CETCompat>
       <GenerateMapFile>true</GenerateMapFile>
       <MapExports>true</MapExports>
diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
index 4d26331..0437024 100644
--- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
@@ -34,7 +34,7 @@
       <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <CETCompat>true</CETCompat>
       <GenerateMapFile>true</GenerateMapFile>
       <MapExports>true</MapExports>
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 07:34:20 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 07:34:20 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017853.1394851 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQpo-0003Bt-00; Tue, 17 Jun 2025 07:34:20 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017853.1394851; Tue, 17 Jun 2025 07:34:19 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQpn-0003Bk-T3; Tue, 17 Jun 2025 07:34:19 +0000
Received: by outflank-mailman (input) for mailman id 1017853;
 Tue, 17 Jun 2025 07:34:18 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=cYMQ=ZA=bounce.vates.tech=bounce-md_30504962.68511a77.v1-2f60d80774dc42ec884b4aecb08ca5f4@srs-se1.protection.inumbo.net>)
 id 1uRQpm-000318-6O
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 07:34:18 +0000
Received: from mail145-24.atl61.mandrillapp.com
 (mail145-24.atl61.mandrillapp.com [198.2.145.24])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 78a2118e-4b4d-11f0-b894-0df219b8e170;
 Tue, 17 Jun 2025 09:34:16 +0200 (CEST)
Received: from pmta06.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail145-24.atl61.mandrillapp.com (Mailchimp) with ESMTP id
 4bLzCC1F80zGlspK1
 for <win-pv-devel@lists.xenproject.org>; Tue, 17 Jun 2025 07:34:15 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 2f60d80774dc42ec884b4aecb08ca5f4; Tue, 17 Jun 2025 07:34:15 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 78a2118e-4b4d-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750145655; x=1750415655;
	bh=OzuK4pC/gxiSz1X6L+EjtAV4U50zPs/4zAER/EIl5yo=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=pr4b9CIvVI1nj2yHovTGo5ZJug9/I4Fp2Fs/k2RoDwzWbtdt7S9fkGq+tG3IREMXf
	 4gjS2H24znhF+VUHP21HT0fQ4XdbijbMTx6WZYStOpi371+gIES2xt4UiVhnXdOKSz
	 c/RH1wjjUY8ZT1wfv5Np+hBFnkZ5I+T32Oz+dqOTRzGkezwT3/v8U0N8lhYoYpz42o
	 7mQHJmG2DOZMdcTQW8HnybcRF7k+bmkCMe4o9NzhhCpFPvc9ehZ7qe5001OTHxiu9E
	 LWQ5phBMwtPfIMHYAQ6EoIKsTFV05VeHxt6QY6C4syGjoMR6Bt+E8uTcvK+D9jUx6M
	 TMOGj13PSk4UQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750145655; x=1750406155; i=ngoc-tu.dinh@vates.tech;
	bh=OzuK4pC/gxiSz1X6L+EjtAV4U50zPs/4zAER/EIl5yo=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=J+oExd4Vi7LVvEdcb3+fGFA7PP9NNYI+fJK0r/tjLJfdO5MDoIUF3eAfgDfPZR2J0
	 SQjEMMJchrUHfCayrY1Iioi04TtQePHNDeLLbm8KB3MdmKeH9doldo+7h8epBla8fy
	 keXXtenwhm4B7QS/vG2oH78jDS0pPssW8D0PKKL53RyZJBGTMpO1MUAougVZDdQvnw
	 UIO+uQCEoapoybokSl6rPHZHUOftlwcwpxkXFDjtNVIQPKYsMb+inl6SEaQGQqOJvK
	 yOF2bUeeybyXbm637d3dRwskDZlxJQrAhtVXL4E7vp8lAgKZydzi4+LLXU4bhlEXvO
	 fVdtCTbnaqI+g==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=20v3=205/5]=20Check=20for=20active=20installation=20before=20autoreboot?=
X-Mailer: git-send-email 2.49.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750145652158
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>, "Paul Durrant" <paul@xen.org>
Message-Id: <20250617073403.117-6-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250617073403.117-1-ngoc-tu.dinh@vates.tech>
References: <20250617073403.117-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.2f60d80774dc42ec884b4aecb08ca5f4?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250617:md
Date: Tue, 17 Jun 2025 07:34:15 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

If the _MSIExecute mutex is set, an MSI installation is under way.
We don't want to autoreboot in these situations either.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
Reviewed-by: Paul Durrant <paul@xen.org>
---
 src/monitor/monitor.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 8a56c11..dd5fc13 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -686,6 +686,7 @@ TryAutoReboot(
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
     HRESULT             Result;
+    HANDLE              MsiMutex;
     DWORD               Type;
     DWORD               AutoReboot;
     DWORD               RebootCount;
@@ -711,6 +712,22 @@ TryAutoReboot(
     if (Context->Response == IDNO)
         goto done;
 
+    // Check if there's an installation under way.
+    MsiMutex = OpenMutex(SYNCHRONIZE,
+                         FALSE,
+                         TEXT("Global\\_MSIExecute"));
+    if (MsiMutex != NULL) {
+        Error = WaitForSingleObject(MsiMutex, 0);
+        if (Error == WAIT_OBJECT_0 || Error == WAIT_ABANDONED)
+            ReleaseMutex(MsiMutex);
+
+        CloseHandle(MsiMutex);
+
+        if (Error == WAIT_TIMEOUT)
+            // The only case where an installation is definitely running.
+            goto done;
+    }
+
     Status = CallNtPowerInformation(SystemExecutionState,
                                     NULL,
                                     0,
-- 
2.49.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 07:40:51 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 07:40:51 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017899.1394865 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQw6-00052y-N8; Tue, 17 Jun 2025 07:40:50 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017899.1394865; Tue, 17 Jun 2025 07:40:50 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRQw6-00052q-KJ; Tue, 17 Jun 2025 07:40:50 +0000
Received: by outflank-mailman (input) for mailman id 1017899;
 Tue, 17 Jun 2025 07:40:49 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=69na=ZA=bounce.vates.tech=bounce-md_30504962.68511a99.v1-f3b9abf158f34ac6b0ca6cf0b2f27e0f@srs-se1.protection.inumbo.net>)
 id 1uRQqK-00031F-GM
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 07:34:52 +0000
Received: from mail145-24.atl61.mandrillapp.com
 (mail145-24.atl61.mandrillapp.com [198.2.145.24])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 8d08dca6-4b4d-11f0-a309-13f23c93f187;
 Tue, 17 Jun 2025 09:34:50 +0200 (CEST)
Received: from pmta06.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail145-24.atl61.mandrillapp.com (Mailchimp) with ESMTP id
 4bLzCs70G5zGlspPC
 for <win-pv-devel@lists.xenproject.org>; Tue, 17 Jun 2025 07:34:49 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 f3b9abf158f34ac6b0ca6cf0b2f27e0f; Tue, 17 Jun 2025 07:34:49 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 8d08dca6-4b4d-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750145690; x=1750415690;
	bh=E/9tIHl8DYbpAAloD/a09LYFpEkDg7rNY9dttJjuRSo=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=ArqHAmGD1hslYpHLVOMV29h9o9Bbo1G2WcQ09xZak2rtw+8tJvloGIUx5LEq6ivgP
	 WkQLSWSHa1BHJ8PPz7SEq0xsdqfBBlJqEO7DpiRBHcqCh7Ft0LIJ+CqLKOH2kGUV7Z
	 niHT1mf3lc9FUpdPIUkKkCLtVwGQKoDFXiasnjwjgn6u0CwhQ0biwe+Mft6swJL/FX
	 JYFZd8laoXXemjovbdmO/wyTm7B7FkGuFrcMKDlj2frC/+FYAyHT7U0tJGhz4lacil
	 IrYfGVZJ5JuCPQqxEQXTBmBRhfiWUSFnxUZntyDUFl2AKXm+7xQMtxnIDXxUIIRZLl
	 uKJmlOflMwXaA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750145690; x=1750406190; i=ngoc-tu.dinh@vates.tech;
	bh=E/9tIHl8DYbpAAloD/a09LYFpEkDg7rNY9dttJjuRSo=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=XFQe/wZvrQzLtWM7WK99wgYw6DCLyu1bQrKK3v5jHyVTEPYpyrMhUxg0me8JSuGf3
	 LQR4SSou0W4Oue65Iw4DNACPWJg6gxtzh5lMgDfPSqpuiJWpQNvoZUrQiWEAfMY5cz
	 qncFAg2GRxqqG6R5tI0uoPGHI2haAOASOUfuEGVjGJw8Tdls7dgIWUq2KMDFn3d+fz
	 F0KJZ5zA9NjxkZZzv+BmgGebNHfCSAFgALj0AfwiXradhCgw9CDLDw5onnt4VGc8qf
	 XlDEpA49qEEOJyGAt61pFrLcet4Nl2nJ+S5NSnfXbcmRSBcGwErFwrAGn7CuRLCZBJ
	 55njj4G+nEtWQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[XENBUS=20PATCH=20v2=200/5]=20Autoreboot=20rework?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750145689272
Message-Id: <3ead2c58-540b-4cdb-929c-2726b31d9653@vates.tech>
To: paul@xen.org, win-pv-devel@lists.xenproject.org
Cc: "Owen Smith" <owen.smith@cloud.com>
References: <20250609135941.309-1-ngoc-tu.dinh@vates.tech> <73a5ac75-3f80-4d45-a633-bd62d5e5e192@xen.org>
In-Reply-To: <73a5ac75-3f80-4d45-a633-bd62d5e5e192@xen.org>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.f3b9abf158f34ac6b0ca6cf0b2f27e0f?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250617:md
Date: Tue, 17 Jun 2025 07:34:49 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Paul,

On 17/06/2025 09:22, Paul Durrant wrote:
> On 09/06/2025 15:00, Tu Dinh wrote:
>> Rework and clean up reboot prompt and check logic:
>> * Since autoreboot takes precedence over reboot prompts, make 
>> TryAutoReboot
>> =C2=A0=C2=A0 call PromptForReboot instead of the other way around.
>> * Any reboot request sets Context->RebootRequestedBy with the driver 
>> name.
>> * Reboot requests can be paused by active installations, system power 
>> requests
>> =C2=A0=C2=A0 or denied by the user (made explicit in the initial check).
>> * Run the session prompts in a separate thread to avoid blocking main 
>> monitor.
>> * Retry reboot request every minute (if exists).
>>
>> v2 changes:
>> * Integrated Paul's feedback.
>> * Reworked and reorganized the monitor code.
>> * Made the retry actually work.
>> * Added check for active installations.
>> * Added commit to cleanup error variables in TryAutoReboot.
>> v1: https://lists.xenproject.org/archives/html/win-pv-devel/2025-05/ 
>> msg00007.html
>>
>> Tu Dinh (5):
>> =C2=A0=C2=A0 Cleanup duplicate error variables in TryAutoReboot
>> =C2=A0=C2=A0 Rework autoreboot retry logic
>> =C2=A0=C2=A0 Repeat TryAutoReboot() with timer
>> =C2=A0=C2=A0 Don't autoreboot during ES_SYSTEM_REQUIRED
>> =C2=A0=C2=A0 Check for active installation before autoreboot
>>
>> =C2=A0 src/monitor/monitor.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 | 522 +++++++++++++------
>> =C2=A0 vs2019/xenbus_monitor/xenbus_monitor.vcxproj |=C2=A0=C2=A0 2 +-
>> =C2=A0 vs2022/xenbus_monitor/xenbus_monitor.vcxproj |=C2=A0=C2=A0 2 +-
>> =C2=A0 3 files changed, 357 insertions(+), 169 deletions(-)
>>
> 
> Are you planning to send a v3 without patch 1 (or with an amended patch 
> 1)? I can apply 2, 3, 4 and 5 as they stand but with fuzz rather than 
> cleanly.

I've sent in v3 with a fixed patch 1.

Best regards,


Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 07:49:49 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 07:49:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017933.1394869 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRR4m-0005Oy-CK; Tue, 17 Jun 2025 07:49:48 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017933.1394869; Tue, 17 Jun 2025 07:49:48 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRR4m-0005Or-9X; Tue, 17 Jun 2025 07:49:48 +0000
Received: by outflank-mailman (input) for mailman id 1017933;
 Tue, 17 Jun 2025 07:49:47 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=0kdh=ZA=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uRR4l-0005Oe-Ak
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 07:49:47 +0000
Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com
 [2a00:1450:4864:20::334])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id a25cbe1a-4b4f-11f0-b894-0df219b8e170;
 Tue, 17 Jun 2025 09:49:44 +0200 (CEST)
Received: by mail-wm1-x334.google.com with SMTP id
 5b1f17b1804b1-442e9c00bf4so45802295e9.3
 for <win-pv-devel@lists.xenproject.org>; Tue, 17 Jun 2025 00:49:44 -0700 (PDT)
Received: from [192.168.19.180] (54-240-197-235.amazon.com. [54.240.197.235])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-4532e2522b1sm164662785e9.25.2025.06.17.00.49.43
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 17 Jun 2025 00:49:43 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: a25cbe1a-4b4f-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1750146584; x=1750751384; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=ZNayVMfA5y1yeYEJGeBszBC5iBZ60PhQUf90OV2pJzU=;
        b=XOypfIl2GhQ28HSar9yp5FZe4kOSpOlFlsXihKVdx4VnUn9MsIrI4OPt2FI3AQDP4j
         T5voqSbX5L7AYN9cu3kHWarRG//9m9reEVGa65uF0UmXfqMc3RKHInVmMitOTxwbaKYb
         N3xambbQ8hhmlpnp+VQzaU2719HqpcIMLMEkpl6+WlSbWfSe5+znNwNN1loHfn/JgVb8
         8HSkqIbz8YLs7A/YcTQS2oqQtevWJIS6gIKk4k1ucXyzUyS4ipbT2BbcylMn1hXince3
         hBeoIv8eO/r+OLKUwjKnPzyJrLBBHX6fI4ZsR0ulrpOK0clheepRCU36l+vxbcYa6Xd9
         SmEA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1750146584; x=1750751384;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=ZNayVMfA5y1yeYEJGeBszBC5iBZ60PhQUf90OV2pJzU=;
        b=soj5PEKPqzB6MPNzmfRvj7QebYqIIYcGGLzY4DXnJe9tcVpV/6uKmJFp6YxINH/dVH
         PYe2N/f6jKWcNkoAnBWNyLLG9IqRltHJVzP+QidhMxOIOHGAEhSp7Jzhvabb9BCJ/wXN
         6Our6OkBgvHtZQVwYaLQ+mJ0KNZQJg3zHD7GqxrivY13JIyKW0SbKOno5UU5ejfJJTbo
         aKBjK6XQT4OH9W78USkAzRGP4ueUaSXPSTN+XNDou8YkVZjvWphnPIJ+mZzr7r8tNDF4
         KcPBsD4zqDDy6btEGeePUJE/1eeW3qvlOtyBMk2yAs+OIx+sI/DxhAEXCmrd+S/6g5DW
         yqIA==
X-Forwarded-Encrypted: i=1; AJvYcCVfPJCw/rL9lLUHaOc7v2PNTZ8QDjssW4zVBh84eoOgBrUHXNwdgq/dS5g1NvWW59byOeAVdLSgRKpVhac=@lists.xenproject.org
X-Gm-Message-State: AOJu0Yw4vJsdu6z1N+yp3fLA1l5MgVw0sTz8d7e3fdkkmeL22lfx+C+V
	DwnbaNSmcIGuKT6DaWoOpd3crjXBcyml0BxpQqV9rQPVTRXt6IiZb371
X-Gm-Gg: ASbGncvTTvqajq9MeXpxRNaXD1jqglmoRiFpw/lnT0c9NtCkg1C+WJRdC/y0o7K24mz
	XW/gTGMaH1adv2WfYRrI7S+0/ZLgEcTMpCXPIv2RPCfUUSf+s8oPHh33O7NbB9yvogVWOWwk1qs
	oSzIcMKqdE+CjXIdCG5Po8+6kaalctswiEwZHNBhxwTlOLpbxDW1i7owZyjnLSAck80XVU4oe3u
	sIuZvTuJ/JZl+dLK6mNTgW99rVHna6xj1ebiJhYUj2zpg0a6dQg4A9a0onRMuOCbXo01AvCEwiX
	5rETL3gTQNx/y/+MemofNA6Nueguz+6V3BKti32aoAxgkKk3fI9HtZ4PQxLi3XT62mozlKaZty9
	uqYx7Ahk5K5/IP1xvGC0=
X-Google-Smtp-Source: AGHT+IGLDvjvXl2F5iDRjOH91QQ/b045pbWrDkkn4SD1gygl35D4UThZiJFesYBSGiVxzGAODaRTVA==
X-Received: by 2002:a05:600c:3543:b0:43d:ea:51d2 with SMTP id 5b1f17b1804b1-4533ca91fbfmr122063555e9.14.1750146584150;
        Tue, 17 Jun 2025 00:49:44 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <b0fc7ed0-82a6-4d1d-9ae6-cddeae1ecf67@xen.org>
Date: Tue, 17 Jun 2025 09:49:42 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [XENBUS PATCH v3 0/5] Autoreboot rework
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
References: <20250617073403.117-1-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <20250617073403.117-1-ngoc-tu.dinh@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 17/06/2025 08:34, Tu Dinh wrote:
> Rework and clean up reboot prompt and check logic:
> * Since autoreboot takes precedence over reboot prompts, make TryAutoReboot
>    call PromptForReboot instead of the other way around.
> * Any reboot request sets Context->RebootRequestedBy with the driver name.
> * Reboot requests can be paused by active installations, system power requests
>    or denied by the user (made explicit in the initial check).
> * Run the session prompts in a separate thread to avoid blocking main monitor.
> * Retry reboot request every minute (if exists).
> 
> v3: Fix error variable type for Reg* functions in TryAutoReboot
> v2: https://lists.xenproject.org/archives/html/win-pv-devel/2025-06/msg00005.html
> v1: https://lists.xenproject.org/archives/html/win-pv-devel/2025-05/msg00007.html
> 
> Tu Dinh (5):
>    Fix error variable type in TryAutoReboot
>    Rework autoreboot retry logic
>    Repeat TryAutoReboot() with timer
>    Don't autoreboot during ES_SYSTEM_REQUIRED
>    Check for active installation before autoreboot
> 
>   src/monitor/monitor.c                        | 509 +++++++++++++------
>   vs2019/xenbus_monitor/xenbus_monitor.vcxproj |   2 +-
>   vs2022/xenbus_monitor/xenbus_monitor.vcxproj |   2 +-
>   3 files changed, 351 insertions(+), 162 deletions(-)
> 

Series applied


From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 07:53:23 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 07:53:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017944.1394872 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRR8F-0006Zk-Lr; Tue, 17 Jun 2025 07:53:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017944.1394872; Tue, 17 Jun 2025 07:53:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRR8F-0006Zd-JJ; Tue, 17 Jun 2025 07:53:23 +0000
Received: by outflank-mailman (input) for mailman id 1017944;
 Tue, 17 Jun 2025 07:53:22 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=c0bW=ZA=bounce.vates.tech=bounce-md_30504962.68511eef.v1-05713f333f2a45d681ba8c48fc9565e1@srs-se1.protection.inumbo.net>)
 id 1uRR8E-0006ZE-HL
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 07:53:22 +0000
Received: from mail187-14.suw11.mandrillapp.com
 (mail187-14.suw11.mandrillapp.com [198.2.187.14])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 22d6daa0-4b50-11f0-a309-13f23c93f187;
 Tue, 17 Jun 2025 09:53:21 +0200 (CEST)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4bLzdC4kbNz8XXVnh
 for <win-pv-devel@lists.xenproject.org>; Tue, 17 Jun 2025 07:53:19 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 05713f333f2a45d681ba8c48fc9565e1; Tue, 17 Jun 2025 07:53:19 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 22d6daa0-4b50-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750146799; x=1750416799;
	bh=66qi5uOkcWZo69xOVGIwA89ZUxHrAdSjl4ZeWZ2/vuc=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=iGxyDSAXKaBAEjKRlu9+04ji/1qm5FNq5gkXm25a28elM1jFXAdu/W1EO8wtDHtUq
	 o4kR7Hi1lFkwv5Z3nntIOaH+PW4dpEFGWFNJWmwnkE2QwSG+GRQ1z5J/Ki8qLNYoKR
	 yBvCIn+sAT0OIed79ScJLVC3+Tr6HkyaC9v/GAg8wX9blc7hl8dRdyHMiUrHGUT8Nl
	 +eZblaiDCmzrIWMCYis4Bt9J0hnE+EF5DH+/SYwMCHXKDUNzOoUNL4pzQwuyWgmJuQ
	 wiq+3kvmG70hkUhpdrAJ74C7pko0yKRbn6rOUauQNO6p/Ca5qF4wUyQhOedqyPVWxA
	 mTJCGdWY9D85g==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750146799; x=1750407299; i=ngoc-tu.dinh@vates.tech;
	bh=66qi5uOkcWZo69xOVGIwA89ZUxHrAdSjl4ZeWZ2/vuc=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=wP9XtzSwymDBh+PhMz1qHaktNwCok8R+f3I2Q0yxbfHMMBdlcOAXFb4vX6Fd2f/Rv
	 uDQwM2ibXdw55u+6oCdFunWt7XU6B78hZbVnDalc6Yys0mypM9R2XPNQmIuFnfHyU3
	 a5QzFHC+qmjzfUxzo/jSTUxmiRPw7mVq99DHehDE/RYrNkMXTPmMb3MfnSzfPkrBnb
	 g44CVxV9jxGHQw2fZLkj2Ernybj42PQHulM4Qz9kulTtnEtwE+nzxGco0cQA7/+Hxc
	 W2QkxXkkrvNEBOgQbQkOI1/3Gke/FWoQTzEc5EA4unKtRWJiqQxxxCHcCwPI83LcX6
	 s6PMguBj3dvYg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[XENBUS=20PATCH]=20Kick=20the=20balloon=20thread=20in=20FdoStartDevice?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750146798856
Message-Id: <b9f78a48-fca7-4142-b2e9-45e6673271ad@vates.tech>
To: paul@xen.org, win-pv-devel@lists.xenproject.org
Cc: "Owen Smith" <owen.smith@cloud.com>
References: <20250613183051.619-1-ngoc-tu.dinh@vates.tech> <92f7fad6-26be-4dd5-a7b1-13017963c46a@xen.org>
In-Reply-To: <92f7fad6-26be-4dd5-a7b1-13017963c46a@xen.org>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.05713f333f2a45d681ba8c48fc9565e1?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250617:md
Date: Tue, 17 Jun 2025 07:53:19 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

On 17/06/2025 08:54, Paul Durrant wrote:
> On 13/06/2025 19:30, Tu Dinh wrote:
>> Xenbus currently doesn't apply the dynamic memory targets at boot time.
>>
> 
> How so?
> 
> The xenstore watch on memory/target signals the balloon thread's event 
> so the watch registration in __FdoD3ToD0() should always wake the thread 
> (since any watch registration triggers a spurious watch event).

The problem is timing-related: FdoD3ToD0 sets the watch before setting 
power state to D0, but the watch thread goes to sleep if it's not in D0 
power state. Also, my VMs won't apply the memory target at boot without 
this patch.

> 
>> Force the balloon thread to update memory targets at boot.
>>
>> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
>> ---
>> =C2=A0 src/xenbus/fdo.c | 3 +++
>> =C2=A0 1 file changed, 3 insertions(+)
>>
>> diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
>> index 3a4a1a2..c2e69fa 100644
>> --- a/src/xenbus/fdo.c
>> +++ b/src/xenbus/fdo.c
>> @@ -3949,6 +3949,9 @@ not_active:
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ASSERT(__FdoIsAct=
ive(Fdo));
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 KeClearEvent(&Fdo->BalloonEv=
ent);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ThreadWake(Fdo->BalloonThrea=
d);
>> +
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 //
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // Balloon inflat=
ion should complete within a reasonable
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // time (otherwis=
e the target is probably unreasonable).
> 

Best regards,


Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 07:54:33 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 07:54:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017953.1394877 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRR9M-0006fz-RA; Tue, 17 Jun 2025 07:54:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017953.1394877; Tue, 17 Jun 2025 07:54:32 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRR9M-0006fr-NC; Tue, 17 Jun 2025 07:54:32 +0000
Received: by outflank-mailman (input) for mailman id 1017953;
 Tue, 17 Jun 2025 07:54:31 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1uRR9L-0006fl-O6
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 07:54:31 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.96)
 (envelope-from <paul@xen.org>) id 1uRR9L-0066Yh-1e;
 Tue, 17 Jun 2025 07:54:31 +0000
Received: from 54-240-197-235.amazon.com ([54.240.197.235]
 helo=REM-PW02S00X.ant.amazon.com)
 by xenbits.xenproject.org with esmtpsa (TLS1.3) tls
 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96)
 (envelope-from <paul@xen.org>) id 1uRR9L-008Bjk-0c;
 Tue, 17 Jun 2025 07:54:31 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:
	Subject:Cc:To:From; bh=5bDz+xCT2bZNhv/Swoy5usWNcSoIIiVJYFeb6OQtDyQ=; b=vmlP48
	DBgloQA97gUi9TLfMpXNg83/vopNZRVDJ/oe0HzhRKn0pcugSvfa+mQQYaYWjqvOB0o/F87ZMP8Ax
	qLhcugg35pfrW02xMJtQBfpQKEWAC2dbZMnfNl8z2uG95oAukhL2v+e8miO4s1BehM3NZI1QHBDrv
	LLFKHPVbumQ=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH] Remove myself as a maintainer
Date: Tue, 17 Jun 2025 09:53:50 +0200
Message-Id: <20250617075349.1393-1-paul@xen.org>
X-Mailer: git-send-email 2.25.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

From: Paul Durrant <pdurrant@amazon.com>

I am no longer in a position to do the job.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 MAINTAINERS | 2 --
 1 file changed, 2 deletions(-)

This applies to all the PV drivers

diff --git a/MAINTAINERS b/MAINTAINERS
index 6cbbb5661da3..7326c9e5367d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -43,6 +43,4 @@ We also request you follow these basic guidelines:
 Maintainers List
 ----------------
 
-* Paul Durrant <paul@xen.org>
-
 * Owen Smith <owen.smith@cloud.com>
-- 
2.25.1



From win-pv-devel-bounces@lists.xenproject.org Tue Jun 17 07:55:56 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 17 Jun 2025 07:55:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1017964.1394881 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRRAg-0006lD-UD; Tue, 17 Jun 2025 07:55:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1017964.1394881; Tue, 17 Jun 2025 07:55:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRRAg-0006l6-Rc; Tue, 17 Jun 2025 07:55:54 +0000
Received: by outflank-mailman (input) for mailman id 1017964;
 Tue, 17 Jun 2025 07:55:54 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=0kdh=ZA=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1uRRAg-0006l0-0X
 for win-pv-devel@lists.xenproject.org; Tue, 17 Jun 2025 07:55:54 +0000
Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com
 [2a00:1450:4864:20::336])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 7df35a7d-4b50-11f0-a309-13f23c93f187;
 Tue, 17 Jun 2025 09:55:53 +0200 (CEST)
Received: by mail-wm1-x336.google.com with SMTP id
 5b1f17b1804b1-450ce671a08so33298405e9.3
 for <win-pv-devel@lists.xenproject.org>; Tue, 17 Jun 2025 00:55:53 -0700 (PDT)
Received: from [192.168.19.180] (54-240-197-235.amazon.com. [54.240.197.235])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-4532e232e0asm164014525e9.14.2025.06.17.00.55.51
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 17 Jun 2025 00:55:52 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7df35a7d-4b50-11f0-a309-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1750146952; x=1750751752; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:from:to:cc:subject:date:message-id:reply-to;
        bh=sW4lQTJlWl4MiH1jjS7lH9mPWY8nZ7yVst7xTnDpA/8=;
        b=BUDfvK2yA37K0Wabtn1LyZFJ5NLnz5VA7ccPaIbpImx7P0Fxa1YgxSUA4d5+RTktfm
         UZRNoyz4elFSVizZm7vtI2ctD8AeRIa8OR0pkBGxxqvDN0x17aSmUnobPAdsxQ8Wtxbp
         /SFirQYbZ12EjAQQtrKDaYENsr3O071VeihosICghPeyLrjFY9hzECoJYAGLRF5dnzUJ
         v5Ll+VwwOBG2e9iidndDFpE8a+MOKJeCr7OS625ixoraSs/2SkUn8TmDWhMHmNwUWb9u
         241clPpQ85CV/KARyoD+mdmo+JicMmPwJDU02J4ga403xYMvN99gkdIs4bX+FKVWCezq
         Zong==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1750146952; x=1750751752;
        h=content-transfer-encoding:in-reply-to:organization:content-language
         :references:cc:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to;
        bh=sW4lQTJlWl4MiH1jjS7lH9mPWY8nZ7yVst7xTnDpA/8=;
        b=pWlfVPejYkZK1XJ9942Dm5+pXNxFOQJK6hXkyY0mZSqBeJ5OjCxQbomP9jA689tl8X
         jJ5BLHYU0nbHrM6LW1YlWMsITxhdKh58mh2BWuiDMvYlEcvuzvzgUh57JAtbN9+Qhmva
         3Te750M10FSNE/qx9Y/vDngt04mjsOG2HnP9bhjwt1H9XW6+UQRWI7kw0RcdNrLmAkbh
         fqUHgAAe/PSRGxfnAXbCJWU4q83ruAcfieTxZuyeU4z7u9A48GObNaLijVSd81t3gUho
         1uFRsEUBlImaWC/gE5D2Li18ktzV7tbW16yPtCU4BMshV31UwK/2o3qF8QDMgMKnUN5o
         AYmg==
X-Forwarded-Encrypted: i=1; AJvYcCWpNNVS7hf6d/lnIK3YPCiBmG0j87H1vGb2sTrKWHR4tbqrvCG7KLCrChN0sGuGBw/BsmhzVvxV0mVuTJA=@lists.xenproject.org
X-Gm-Message-State: AOJu0Yx5s8A8HNWjtcxndEy+UKmjuhA/Bw+QpOHl5paxkPsLezB2c9WI
	NLj3trBOG+YbF4mCnXfPk0NOfyXuUrhzGlZr54E4GWtu3+6LHZjCt68E
X-Gm-Gg: ASbGnctVIItpLf0DJwddlL6a2NtNUV2f4/ZQmh0a0jbwT/yiUNf5VbyF8wAM/FoyBFX
	jwyCUTXRTv40av/I/aN92qKbIM0VpYY3kM7Ss90op6OIH/m8q0JNthtiWxyHERV0qu8LrRNJNNq
	h56cXf6kg0E9MbFNrDwuvVg01iEtH495EAQop1hI3reUzQYJoWViPi+S8KowDhOlZvHMfv339z8
	t55B/0OvRbB5VG+xUb79sPlrY2UHjkNcN9JqmkSL8uxf1xl4BJQr+VcM6a93j8lzt2nd4xi3ESx
	IkZrhjGoM8dGmYXamwYd1x9+2u+Gap1VanyDEIEcokmRbio0WPU4uS3aWYuu7jvuRfdwRvdaQtG
	nrtDaN1vDr+I8pTbGC7C9rE8giShx+g==
X-Google-Smtp-Source: AGHT+IGUo7EsCsvaQ/L4RuMawEt1q63KU6nqGJa2Q7YPUpFhfolLOXKv7Lq78blyiwOPWDkT+Ua4Zw==
X-Received: by 2002:a05:600c:8b02:b0:43d:77c5:9c1a with SMTP id 5b1f17b1804b1-4533cadf85dmr117503905e9.4.1750146952552;
        Tue, 17 Jun 2025 00:55:52 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <af7f89c8-8249-45ee-bc47-ca8519b7204f@xen.org>
Date: Tue, 17 Jun 2025 09:55:51 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [XENBUS PATCH] Kick the balloon thread in FdoStartDevice
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
References: <20250613183051.619-1-ngoc-tu.dinh@vates.tech>
 <92f7fad6-26be-4dd5-a7b1-13017963c46a@xen.org>
 <b9f78a48-fca7-4142-b2e9-45e6673271ad@vates.tech>
Content-Language: en-US
Organization: Xen Project
In-Reply-To: <b9f78a48-fca7-4142-b2e9-45e6673271ad@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

On 17/06/2025 08:53, Tu Dinh wrote:
> On 17/06/2025 08:54, Paul Durrant wrote:
>> On 13/06/2025 19:30, Tu Dinh wrote:
>>> Xenbus currently doesn't apply the dynamic memory targets at boot time.
>>>
>>
>> How so?
>>
>> The xenstore watch on memory/target signals the balloon thread's event
>> so the watch registration in __FdoD3ToD0() should always wake the thread
>> (since any watch registration triggers a spurious watch event).
> 
> The problem is timing-related: FdoD3ToD0 sets the watch before setting
> power state to D0, but the watch thread goes to sleep if it's not in D0
> power state. Also, my VMs won't apply the memory target at boot without
> this patch.
> 

That's new then. This always worked in the XenServer env... for years.

   Paul

>>
>>> Force the balloon thread to update memory targets at boot.
>>>
>>> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
>>> ---
>>>    src/xenbus/fdo.c | 3 +++
>>>    1 file changed, 3 insertions(+)
>>>
>>> diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
>>> index 3a4a1a2..c2e69fa 100644
>>> --- a/src/xenbus/fdo.c
>>> +++ b/src/xenbus/fdo.c
>>> @@ -3949,6 +3949,9 @@ not_active:
>>>            ASSERT(__FdoIsActive(Fdo));
>>> +        KeClearEvent(&Fdo->BalloonEvent);
>>> +        ThreadWake(Fdo->BalloonThread);
>>> +
>>>            //
>>>            // Balloon inflation should complete within a reasonable
>>>            // time (otherwise the target is probably unreasonable).
>>
> 
> Best regards,
> 
> 
> Ngoc Tu Dinh | Vates XCP-ng Developer
> 
> XCP-ng & Xen Orchestra - Vates solutions
> 
> web: https://vates.tech
> 
> 



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 18 12:21:18 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 18 Jun 2025 12:21:18 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1019115.1395945 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRrn1-0005uk-TZ; Wed, 18 Jun 2025 12:21:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1019115.1395945; Wed, 18 Jun 2025 12:21:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uRrn1-0005uc-Ql; Wed, 18 Jun 2025 12:21:15 +0000
Received: by outflank-mailman (input) for mailman id 1019115;
 Wed, 18 Jun 2025 12:21:14 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=ACUg=ZB=kotan.hu=info@srs-se1.protection.inumbo.net>)
 id 1uRrn0-0005uU-1Q
 for win-pv-devel@lists.xenproject.org; Wed, 18 Jun 2025 12:21:14 +0000
Received: from mx1.faircomp.hu (mx1.faircomp.hu [185.80.49.45])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id b7ee0758-4c3e-11f0-a30a-13f23c93f187;
 Wed, 18 Jun 2025 14:21:12 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b7ee0758-4c3e-11f0-a30a-13f23c93f187
X-FairComp-Spam-Status: No
X-Faircomp-MailScanner-From: info@kotan.hu
X-Faircomp-MailScanner: Found to be clean
X-Faircomp-MailScanner-ID: 45DBB805F6.A8D08
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=kotan.hu; s=mail;
	t=1750249264; bh=C57cADTsZnZZhp7+8VekX4LxNQDvh5hs3HJAEymYs1U=;
	h=Date:Subject:To:References:From:In-Reply-To:From;
	b=UqaRkxyChz8BRwtvNwQu1tJcqRDxqhi7lylI4L+RIYnq8Fq8fkfQxHxAzMWECP+3m
	 ELou+kmV8Lu6vXupCrbKyWy0nGVo85jQAPkpLfXgwCbsHkG1+S4GrY2lBdNmXh7lPP
	 UIMOGxUFS95+C4Aa8hxEHgfw2FtY94we1Wt2sCUbevFA6LPlV5PQDnkq9xrfW0j9/K
	 Cc6GtShv+dOQKNiuCpv0M4Buk8qHP78bO9a7NxzKt2eyf7d39lZHYzHdzNuSjA0bon
	 W0a3p5iEvaXYTXtW8akPrxIZBkv7lNKeIdxCj1bZ5uDoocJCeUCRcKY7fhUtE7hjvp
	 2G3eZ5VpUByDw==
Content-Type: multipart/alternative;
 boundary="------------hMNUSVHUtmaxaEXKnu7dq63V"
Message-ID: <c8d65656-356c-435b-aee7-10c197ffd9a3@kotan.hu>
Date: Wed, 18 Jun 2025 14:21:03 +0200
MIME-Version: 1.0
User-Agent: Mozilla-Thunderbird
Subject: Re: CI infrastructure for Windows PV drivers
To: win-pv-devel@lists.xenproject.org
References: <3390640e-cc46-404e-a497-847881de12e9@vates.tech>
Content-Language: hu
From: =?UTF-8?Q?Kot=C3=A1n_Attila?= <info@kotan.hu>
In-Reply-To: <3390640e-cc46-404e-a497-847881de12e9@vates.tech>

This is a multi-part message in MIME format.
--------------hMNUSVHUtmaxaEXKnu7dq63V
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hello,

Im not an developer, but maybe i can offer:
- web storage (Apache + PHP + Mariadb)
- XEN VMs (HVM or PVM) without administrative access.
I have two DELL server with Debian 10 XEN environment, located in a 
server hosting, dedicated 1Gbps internet access.

I would also support the signed driver, im happy when i can help for a 
release.

Best regards!
Attila

2025. 06. 16. 17:49 keltezéssel, Tu Dinh írta:
> Hi,
>
> I'm currently interested in preparing a CI infrastructure for the
> Windows PV drivers.
>
> While I don't think there's currently interest in official signed
> drivers from the Xen Project, a CI infrastructure will still be useful
> for automated tests. In particular, I'm looking at the following:
>
> - Automated testsigned builds;
> - CodeQL checks;
> - Rudimentary automated tests for driver features, under Driver Verifier.
>
> Here are the needed resources:
> - Build server running some flavor of Windows;
> - Build tools: Visual Studio (Community?), WDK, etc.
> - Several test VMs running various supported OSes on Xen (client,
> server, etc.)
>       - These VMs are preferably snapshot-capable to ease testing.
>
> I can volunteer to prepare the build scripts and tests. Cody pointed out
> to me during the last community call that we can get professional
> support to keep the build and test servers up to date and secure.
>
> I'd appreciate your input on this matter.
>
> Best regards,
>
>
> Ngoc Tu Dinh | Vates XCP-ng Developer
>
> XCP-ng & Xen Orchestra - Vates solutions
>
> web:https://vates.tech
>
>

--------------hMNUSVHUtmaxaEXKnu7dq63V
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Hello, <br>
    <br>
    Im not an developer, but maybe i can offer: <br>
    - web storage (Apache + PHP + Mariadb)<br>
    - XEN VMs (HVM or PVM) without administrative access.<br>
    I have two DELL server with Debian 10 XEN environment, located in a
    server hosting, dedicated 1Gbps internet access. <br>
    <br>
    <span class="HwtZe" lang="en"><span class="jCAhz ChMk0b"><span
          class="ryNqvb">I would also support the signed driver, im
          happy when i can help for a release. <br>
          <br>
          Best regards! <br>
          Attila<br>
        </span></span></span><br>
    <div class="moz-cite-prefix">2025. 06. 16. 17:49 keltezéssel, Tu
      Dinh írta:<br>
    </div>
    <blockquote type="cite"
      cite="mid:3390640e-cc46-404e-a497-847881de12e9@vates.tech">
      <pre wrap="" class="moz-quote-pre">Hi,

I'm currently interested in preparing a CI infrastructure for the 
Windows PV drivers.

While I don't think there's currently interest in official signed 
drivers from the Xen Project, a CI infrastructure will still be useful 
for automated tests. In particular, I'm looking at the following:

- Automated testsigned builds;
- CodeQL checks;
- Rudimentary automated tests for driver features, under Driver Verifier.

Here are the needed resources:
- Build server running some flavor of Windows;
- Build tools: Visual Studio (Community?), WDK, etc.
- Several test VMs running various supported OSes on Xen (client, 
server, etc.)
     - These VMs are preferably snapshot-capable to ease testing.

I can volunteer to prepare the build scripts and tests. Cody pointed out 
to me during the last community call that we can get professional 
support to keep the build and test servers up to date and secure.

I'd appreciate your input on this matter.

Best regards,


Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng &amp; Xen Orchestra - Vates solutions

web: <a class="moz-txt-link-freetext" href="https://vates.tech">https://vates.tech</a>


</pre>
    </blockquote>
    <br>
  </body>
</html>

--------------hMNUSVHUtmaxaEXKnu7dq63V--


From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:20 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:20 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025006.1400756 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCc-00087J-KH; Wed, 25 Jun 2025 14:34:18 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025006.1400756; Wed, 25 Jun 2025 14:34:18 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCc-00087C-HE; Wed, 25 Jun 2025 14:34:18 +0000
Received: by outflank-mailman (input) for mailman id 1025006;
 Wed, 25 Jun 2025 14:34:17 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=pSt4=ZI=bounce.vates.tech=bounce-md_30504962.685c08e5.v1-9607734f1f0e43b584b3774e349dc53c@srs-se1.protection.inumbo.net>)
 id 1uURCb-000871-An
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:17 +0000
Received: from mail180-2.suw31.mandrillapp.com
 (mail180-2.suw31.mandrillapp.com [198.2.180.2])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 7755bff2-51d1-11f0-b894-0df219b8e170;
 Wed, 25 Jun 2025 16:34:14 +0200 (CEST)
Received: from pmta11.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail180-2.suw31.mandrillapp.com (Mailchimp) with ESMTP id 4bS4853PBqzS62RvB
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:13 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 9607734f1f0e43b584b3774e349dc53c; Wed, 25 Jun 2025 14:34:13 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7755bff2-51d1-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862053; x=1751132053;
	bh=QahFmrnLWzOLEmrBTE139HXqfiIumT+aQG+08fHrd6A=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=diTJZUkbXj7Qk7U4aqmTD2QTxA5xubv0Pri2MO8LoSVVSu+rLP6Nm31T97/gP/PMH
	 d4VNExiZN9FQBQ+f55TaiP0pnKHHpnYJtWJbtjwF7NyKnmDPpnDQwPPEkZLBWR9X0B
	 HI6NB691R3WxY/jIgC4raUMDCnFFWXGT2eOynr55o0xBZx3pLnKVC7VWR+e/3B5SlY
	 1nI8zdM7n4n6AZz0HOyehrmovoqhJgYKdH3jeKY0rZH8fbUjL64LfZTu7ZQe1gc1Pg
	 +TZhOgrW6EsXkvkmqHSQYbxbqk0p80UB5k3NyrZ+YLHXlV5G3flgOU4Wos5p9jlxit
	 Rvays9crJEv+Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862053; x=1751122553; i=ngoc-tu.dinh@vates.tech;
	bh=QahFmrnLWzOLEmrBTE139HXqfiIumT+aQG+08fHrd6A=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=NCELsAlHh8fI5VR5nCxis6TnAqAEe1aHT7DfSh49Rv3ObGLVzUH4JiGqBpPDXHLZL
	 j7y59kvAL/u6gW7oykCERbNoDEy2U4LWYKpbgqXKVqv7aST/rbNUT3XOAWAaoQDK0n
	 gY05VwunAdK/k/MtXd8krFmXx0sTqWAXTZMmWwV4QjStijk8ODNBL2y5EFxQHkANtf
	 Ax7WdaQ2MTrpndu8onQhvSsdR+H1bs7Q18SggiX5eHsOBbhi/hNb/reOZslbq5Ecff
	 XOnrSsLIISMsaVrMP2kH2xeSG+cdwwH+zsVpvzFGf5G7bBsyRutZfnjlB1k1qN7awO
	 zVgcZoGG5byrA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2003/13]=20Refine=20function=20annotations?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862052679
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-4-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
References: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.9607734f1f0e43b584b3774e349dc53c?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:13 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

* Replace __analysis_assume with _Analysis_assume_ or assertions
* Add more assertions when appropriate
* Adjust annotations of functions where annotations don't match usage

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/common/assert.h      |  4 +-
 src/common/util.h        | 11 +++--
 src/monitor/monitor.c    |  4 +-
 src/xen/driver.c         | 42 +++++++++---------
 src/xenbus/balloon.c     |  2 +-
 src/xenbus/bus.c         |  8 ++++
 src/xenbus/debug.c       | 18 ++++----
 src/xenbus/evtchn.c      | 10 ++---
 src/xenbus/fdo.c         | 95 ++++++++++++++++++++++++++++------------
 src/xenbus/fdo.h         | 22 +++++-----
 src/xenbus/pdo.c         |  6 ++-
 src/xenbus/pdo.h         |  2 +-
 src/xenbus/shared_info.c |  2 +-
 src/xenbus/store.c       |  1 +
 src/xenfilt/fdo.c        |  2 +
 15 files changed, 144 insertions(+), 85 deletions(-)

diff --git a/src/common/assert.h b/src/common/assert.h
index 1c1104d..90a839f 100644
--- a/src/common/assert.h
+++ b/src/common/assert.h
@@ -89,7 +89,7 @@ __Bug(
 #define ASSERT(_EXP)                    \
         do {                            \
             __ASSERT(_EXP);             \
-            __analysis_assume(_EXP);    \
+            _Analysis_assume_(_EXP);    \
         } while (FALSE)
 
 #define ASSERT3U(_X, _OP, _Y)                       \
@@ -132,7 +132,7 @@ __Bug(
 
 #define ASSERT(_EXP)                    \
         do {                            \
-            __analysis_assume(_EXP);    \
+            _Analysis_assume_(_EXP);    \
         } while (FALSE)
 
 #define ASSERT3U(_X, _OP, _Y)           \
diff --git a/src/common/util.h b/src/common/util.h
index 9398daa..dbf64fd 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -150,13 +150,14 @@ __AllocatePoolWithTag(
 {
     PUCHAR          Buffer;
 
-    __analysis_assume(PoolType == NonPagedPool ||
+    _Analysis_assume_(PoolType == NonPagedPool ||
                       PoolType == PagedPool);
 
     if (NumberOfBytes == 0)
         return NULL;
 
 #if (_MSC_VER >= 1928) // VS 16.9 (EWDK 20344 or later)
+#pragma warning(suppress:28160) // annotation error
     Buffer = ExAllocatePoolUninitialized(PoolType, NumberOfBytes, Tag);
 #else
 #pragma warning(suppress:28160) // annotation error
@@ -278,7 +279,9 @@ static FORCEINLINE PSTR
 __strtok_r(
     _In_opt_ PSTR   Buffer,
     _In_ PSTR       Delimiter,
-    _Inout_ PSTR    *Context
+    _When_(Buffer != NULL, _Outptr_)
+    _When_(Buffer == NULL, _Inout_)
+    PSTR            *Context
     )
 {
     PSTR            Token;
@@ -316,7 +319,9 @@ static FORCEINLINE PWSTR
 __wcstok_r(
     _In_opt_ PWSTR  Buffer,
     _In_ PWSTR      Delimiter,
-    _Inout_ PWSTR   *Context
+    _When_(Buffer != NULL, _Outptr_)
+    _When_(Buffer == NULL, _Inout_)
+    PWSTR           *Context
     )
 {
     PWSTR           Token;
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index f6e39f8..ae20ac7 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -119,8 +119,8 @@ __Log(
 
     Length = __min(MAXIMUM_BUFFER_SIZE - 1, Length + 2);
 
-    __analysis_assume(Length < MAXIMUM_BUFFER_SIZE);
-    __analysis_assume(Length >= 2);
+    _Analysis_assume_(Length < MAXIMUM_BUFFER_SIZE);
+    _Analysis_assume_(Length >= 2);
     Buffer[Length] = '\0';
     Buffer[Length - 1] = '\n';
     Buffer[Length - 2] = '\r';
diff --git a/src/xen/driver.c b/src/xen/driver.c
index 48fe169..b44753c 100644
--- a/src/xen/driver.c
+++ b/src/xen/driver.c
@@ -164,14 +164,14 @@ __DriverGetMemoryKey(
 
 static FORCEINLINE NTSTATUS
 __DriverSetPfnArray(
-    _In_ PSTR       Name,
-    _In_ ULONG      Count,
-    _In_ PFN_NUMBER PfnArray[]
+    _In_ PSTR                       Name,
+    _In_ ULONG                      Count,
+    _In_reads_(Count) PFN_NUMBER    PfnArray[]
     )
 {
-    HANDLE          Key = __DriverGetMemoryKey();
-    LONG            Index;
-    NTSTATUS        status;
+    HANDLE                          Key = __DriverGetMemoryKey();
+    LONG                            Index;
+    NTSTATUS                        status;
 
     Index = 0;
     while (Index < (LONG)Count) {
@@ -224,17 +224,17 @@ fail1:
 
 static FORCEINLINE NTSTATUS
 __DriverAllocatePfnArray(
-    _In_ PSTR           Name,
-    _In_ ULONG          Count,
-    _Out_ PFN_NUMBER    PfnArray[]
+    _In_ PSTR                           Name,
+    _In_ ULONG                          Count,
+    _Out_writes_all_(Count) PFN_NUMBER  PfnArray[]
     )
 {
-    PHYSICAL_ADDRESS    LowAddress;
-    PHYSICAL_ADDRESS    HighAddress;
-    LARGE_INTEGER       SkipBytes;
-    SIZE_T              TotalBytes;
-    PMDL                Mdl;
-    NTSTATUS            status;
+    PHYSICAL_ADDRESS                    LowAddress;
+    PHYSICAL_ADDRESS                    HighAddress;
+    LARGE_INTEGER                       SkipBytes;
+    SIZE_T                              TotalBytes;
+    PMDL                                Mdl;
+    NTSTATUS                            status;
 
     LowAddress.QuadPart = 0ull;
     HighAddress.QuadPart = ~0ull;
@@ -289,14 +289,14 @@ fail1:
 
 static FORCEINLINE NTSTATUS
 __DriverGetPfnArray(
-    _In_ PSTR                       Name,
-    _In_ ULONG                      Count,
-    _Out_writes_(Count) PFN_NUMBER  PfnArray[]
+    _In_ PSTR                           Name,
+    _In_ ULONG                          Count,
+    _Out_writes_all_(Count) PFN_NUMBER  PfnArray[]
     )
 {
-    HANDLE                          Key = __DriverGetMemoryKey();
-    ULONG                           Index;
-    NTSTATUS                        status;
+    HANDLE                              Key = __DriverGetMemoryKey();
+    ULONG                               Index;
+    NTSTATUS                            status;
 
     for (Index = 0; Index < Count; Index++) {
         CHAR    ValueName[MAXNAMELEN];
diff --git a/src/xenbus/balloon.c b/src/xenbus/balloon.c
index 7afd387..544628a 100644
--- a/src/xenbus/balloon.c
+++ b/src/xenbus/balloon.c
@@ -323,7 +323,7 @@ static ULONG
 BalloonAllocatePfnArray(
     _In_ PXENBUS_BALLOON_CONTEXT    Context,
     _In_ ULONG                      Requested,
-    _Inout_ PBOOLEAN                Slow
+    _Out_ PBOOLEAN                  Slow
     )
 {
     LARGE_INTEGER                   Start;
diff --git a/src/xenbus/bus.c b/src/xenbus/bus.c
index c97759c..f9c8021 100644
--- a/src/xenbus/bus.c
+++ b/src/xenbus/bus.c
@@ -103,6 +103,8 @@ BusTranslateAddress(
 {
     PXENBUS_BUS_CONTEXT         Context = _Context;
 
+    ASSERT(Context != NULL);
+
     return PdoTranslateBusAddress(Context->Pdo,
                                   BusAddress,
                                   Length,
@@ -123,6 +125,8 @@ BusGetDmaAdapter(
     PXENBUS_BUS_CONTEXT         Context = _Context;
     XENBUS_DMA_ADAPTER_TYPE     Type;
 
+    ASSERT(Context != NULL);
+
     if (Context->InterceptDmaAdapter != 0) {
         RTL_OSVERSIONINFOEXW    VersionInformation;
         NTSTATUS                status;
@@ -161,6 +165,8 @@ BusSetData(
 {
     PXENBUS_BUS_CONTEXT Context = _Context;
 
+    ASSERT(Context != NULL);
+
     return PdoSetBusData(Context->Pdo,
                          DataType,
                          Buffer,
@@ -182,6 +188,8 @@ BusGetData(
 {
     PXENBUS_BUS_CONTEXT Context = _Context;
 
+    ASSERT(Context != NULL);
+
     return PdoGetBusData(Context->Pdo,
                          DataType,
                          Buffer,
diff --git a/src/xenbus/debug.c b/src/xenbus/debug.c
index a0bb27d..7fc1430 100644
--- a/src/xenbus/debug.c
+++ b/src/xenbus/debug.c
@@ -91,17 +91,17 @@ RtlCaptureStackBackTrace(
 
 static NTSTATUS
 DebugRegister(
-    _In_ PINTERFACE                     Interface,
-    _In_ PSTR                           Prefix,
-    _In_ XENBUS_DEBUG_FUNCTION          Function,
-    _In_opt_ PVOID                      Argument,
-    _Out_opt_ PXENBUS_DEBUG_CALLBACK    *Callback
+    _In_ PINTERFACE                 Interface,
+    _In_ PSTR                       Prefix,
+    _In_ XENBUS_DEBUG_FUNCTION      Function,
+    _In_opt_ PVOID                  Argument,
+    _Out_ PXENBUS_DEBUG_CALLBACK    *Callback
     )
 {
-    PXENBUS_DEBUG_CONTEXT               Context = Interface->Context;
-    ULONG                               Length;
-    KIRQL                               Irql;
-    NTSTATUS                            status;
+    PXENBUS_DEBUG_CONTEXT           Context = Interface->Context;
+    ULONG                           Length;
+    KIRQL                           Irql;
+    NTSTATUS                        status;
 
     *Callback = __DebugAllocate(sizeof (XENBUS_DEBUG_CALLBACK));
 
diff --git a/src/xenbus/evtchn.c b/src/xenbus/evtchn.c
index 8927938..4344bae 100644
--- a/src/xenbus/evtchn.c
+++ b/src/xenbus/evtchn.c
@@ -1084,13 +1084,13 @@ EvtchnWaitVersion5(
                       Timeout);
 }
 
-static KSERVICE_ROUTINE EvtchnInterruptCallback;
-
-_Use_decl_annotations_
+_Function_class_(KSERVICE_ROUTINE)
+_IRQL_requires_(HIGH_LEVEL)
+_IRQL_requires_same_
 static BOOLEAN
 EvtchnInterruptCallback(
-    PKINTERRUPT                 InterruptObject,
-    PVOID                       Argument
+    _In_opt_ PKINTERRUPT        InterruptObject,
+    _In_ PVOID                  Argument
     )
 {
     PXENBUS_EVTCHN_PROCESSOR    Processor = Argument;
diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index c673ae0..89595ed 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -435,7 +435,7 @@ FdoTranslateBusAddress(
     _In_ PXENBUS_FDO        Fdo,
     _In_ PHYSICAL_ADDRESS   BusAddress,
     _In_ ULONG              Length,
-    _Inout_ PULONG          AddressSpace,
+    _Out_ PULONG            AddressSpace,
     _Out_ PPHYSICAL_ADDRESS TranslatedAddress
     )
 {
@@ -453,11 +453,11 @@ FdoTranslateBusAddress(
 
 ULONG
 FdoSetBusData(
-    _In_ PXENBUS_FDO        Fdo,
-    _In_ ULONG              DataType,
-    _In_ PVOID              Buffer,
-    _In_ ULONG              Offset,
-    _In_ ULONG              Length
+    _In_ PXENBUS_FDO                Fdo,
+    _In_ ULONG                      DataType,
+    _In_reads_bytes_(Length) PVOID  Buffer,
+    _In_ ULONG                      Offset,
+    _In_range_(!=, 0) ULONG         Length
     )
 {
     PBUS_INTERFACE_STANDARD BusInterface;
@@ -474,18 +474,19 @@ FdoSetBusData(
 
 ULONG
 FdoGetBusData(
-    _In_ PXENBUS_FDO        Fdo,
-    _In_ ULONG              DataType,
-    _In_ PVOID              Buffer,
-    _In_ ULONG              Offset,
-    _In_ ULONG              Length
+    _In_ PXENBUS_FDO                    Fdo,
+    _In_ ULONG                          DataType,
+    _Out_writes_bytes_(Length) PVOID    Buffer,
+    _In_ ULONG                          Offset,
+    _In_range_(!=, 0) ULONG             Length
     )
 {
-    PBUS_INTERFACE_STANDARD BusInterface;
+    PBUS_INTERFACE_STANDARD             BusInterface;
 
     BusInterface = Fdo->LowerBusInterface;
     ASSERT(BusInterface != NULL);
 
+#pragma prefast(suppress:6001) // imprecise GetBusData annotations
     return BusInterface->GetBusData(BusInterface->Context,
                                     DataType,
                                     Buffer,
@@ -863,6 +864,8 @@ FdoDelegateIrpCompletion(
     UNREFERENCED_PARAMETER(DeviceObject);
     UNREFERENCED_PARAMETER(Irp);
 
+    ASSERT(Event != NULL);
+
     KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
 
     return STATUS_MORE_PROCESSING_REQUIRED;
@@ -949,6 +952,8 @@ FdoForwardIrpSynchronouslyCompletion(
     UNREFERENCED_PARAMETER(DeviceObject);
     UNREFERENCED_PARAMETER(Irp);
 
+    ASSERT(Event != NULL);
+
     KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
 
     return STATUS_MORE_PROCESSING_REQUIRED;
@@ -4721,8 +4726,8 @@ static IO_WORKITEM_ROUTINE FdoSetDevcePowerUpWorker;
 _Use_decl_annotations_
 static VOID
 FdoSetDevcePowerUpWorker(
-    _In_ PDEVICE_OBJECT DeviceObject,
-    _In_opt_ PVOID      Context
+    PDEVICE_OBJECT      DeviceObject,
+    PVOID               Context
     )
 {
     PXENBUS_FDO         Fdo = (PXENBUS_FDO) Context;
@@ -4730,6 +4735,8 @@ FdoSetDevcePowerUpWorker(
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
+    ASSERT(Fdo != NULL);
+
     Irp = InterlockedExchangePointer(&Fdo->DevicePowerIrp, NULL);
     ASSERT(Irp != NULL);
 
@@ -4755,6 +4762,8 @@ FdoSetDevicePowerUpComplete(
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
+    ASSERT(Fdo != NULL);
+
     StackLocation = IoGetCurrentIrpStackLocation(Irp);
     DeviceState = StackLocation->Parameters.Power.State.DeviceState;
 
@@ -4806,6 +4815,8 @@ FdoSetDevicePowerDownWorker(
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
+    ASSERT(Fdo != NULL);
+
     Irp = InterlockedExchangePointer(&Fdo->DevicePowerIrp, NULL);
     ASSERT(Irp != NULL);
 
@@ -4915,6 +4926,8 @@ FdoRequestDevicePowerUpComplete(
     UNREFERENCED_PARAMETER(PowerState);
     UNREFERENCED_PARAMETER(IoStatus);
 
+    ASSERT(Irp != NULL);
+
     IoCompleteRequest(Irp, IO_NO_INCREMENT);
 }
 
@@ -4936,6 +4949,8 @@ FdoSetSystemPowerUpWorker(
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
+    ASSERT(Fdo != NULL);
+
     Irp = InterlockedExchangePointer(&Fdo->SystemPowerIrp, NULL);
     ASSERT(Irp != NULL);
 
@@ -4988,9 +5003,14 @@ FdoSetSystemPowerUpComplete(
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
+    ASSERT(Fdo != NULL);
+
     StackLocation = IoGetCurrentIrpStackLocation(Irp);
     SystemState = StackLocation->Parameters.Power.State.SystemState;
 
+    ASSERT(SystemState >= PowerSystemUnspecified &&
+           SystemState < PowerSystemMaximum);
+
     if (SystemState < PowerSystemHibernate &&
         __FdoGetSystemPowerState(Fdo) >= PowerSystemHibernate) {
 
@@ -5061,6 +5081,8 @@ FdoSetSystemPowerDownWorker(
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
+    ASSERT(Fdo != NULL);
+
     Irp = InterlockedExchangePointer(&Fdo->SystemPowerIrp, NULL);
     ASSERT(Irp != NULL);
 
@@ -5088,17 +5110,24 @@ FdoRequestDevicePowerDownComplete(
     )
 {
     PIRP                    Irp = (PIRP) Context;
-    PIO_STACK_LOCATION      StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    PDEVICE_OBJECT          UpperDeviceObject = StackLocation->DeviceObject;
-    PXENBUS_DX              Dx = (PXENBUS_DX)UpperDeviceObject->DeviceExtension;
-    PXENBUS_FDO             Fdo = Dx->Fdo;
-    SYSTEM_POWER_STATE      SystemState = StackLocation->Parameters.Power.State.SystemState;
+    PIO_STACK_LOCATION      StackLocation;
+    PDEVICE_OBJECT          UpperDeviceObject;
+    PXENBUS_DX              Dx;
+    PXENBUS_FDO             Fdo;
+    SYSTEM_POWER_STATE      SystemState;
     NTSTATUS                status = IoStatus->Status;
 
     UNREFERENCED_PARAMETER(DeviceObject);
     UNREFERENCED_PARAMETER(MinorFunction);
     UNREFERENCED_PARAMETER(PowerState);
 
+    ASSERT(Irp != NULL);
+    StackLocation = IoGetCurrentIrpStackLocation(Irp);
+    UpperDeviceObject = StackLocation->DeviceObject;
+    Dx = (PXENBUS_DX)UpperDeviceObject->DeviceExtension;
+    Fdo = Dx->Fdo;
+    SystemState = StackLocation->Parameters.Power.State.SystemState;
+
     if (!NT_SUCCESS(status))
         goto fail1;
 
@@ -5232,6 +5261,8 @@ FdoRequestQuerySystemPowerUpComplete(
     UNREFERENCED_PARAMETER(MinorFunction);
     UNREFERENCED_PARAMETER(PowerState);
 
+    ASSERT(Irp != NULL);
+
     if (!NT_SUCCESS(IoStatus->Status))
         Irp->IoStatus.Status = IoStatus->Status;
     IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -5255,6 +5286,8 @@ FdoQuerySystemPowerUpComplete(
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
+    ASSERT(Fdo != NULL);
+
     StackLocation = IoGetCurrentIrpStackLocation(Irp);
     SystemState = StackLocation->Parameters.Power.State.SystemState;
     PowerState.DeviceState = Fdo->LowerDeviceCapabilities.DeviceState[SystemState];
@@ -5299,23 +5332,29 @@ static REQUEST_POWER_COMPLETE FdoRequestQuerySystemPowerDownComplete;
 _Use_decl_annotations_
 static VOID
 FdoRequestQuerySystemPowerDownComplete(
-    _In_ PDEVICE_OBJECT     DeviceObject,
-    _In_ UCHAR              MinorFunction,
-    _In_ POWER_STATE        PowerState,
-    _In_opt_ PVOID          Context,
-    _In_ PIO_STATUS_BLOCK   IoStatus
+    PDEVICE_OBJECT          DeviceObject,
+    UCHAR                   MinorFunction,
+    POWER_STATE             PowerState,
+    PVOID                   Context,
+    PIO_STATUS_BLOCK        IoStatus
     )
 {
     PIRP                    Irp = (PIRP) Context;
-    PIO_STACK_LOCATION      StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    PDEVICE_OBJECT          UpperDeviceObject = StackLocation->DeviceObject;
-    PXENBUS_DX              Dx = (PXENBUS_DX)UpperDeviceObject->DeviceExtension;
-    PXENBUS_FDO             Fdo = Dx->Fdo;
+    PIO_STACK_LOCATION      StackLocation;
+    PDEVICE_OBJECT          UpperDeviceObject;
+    PXENBUS_DX              Dx;
+    PXENBUS_FDO             Fdo;
 
     UNREFERENCED_PARAMETER(DeviceObject);
     UNREFERENCED_PARAMETER(MinorFunction);
     UNREFERENCED_PARAMETER(PowerState);
 
+    ASSERT(Irp != NULL);
+    StackLocation = IoGetCurrentIrpStackLocation(Irp);
+    UpperDeviceObject = StackLocation->DeviceObject;
+    Dx = (PXENBUS_DX)UpperDeviceObject->DeviceExtension;
+    Fdo = Dx->Fdo;
+
     if (!NT_SUCCESS(IoStatus->Status))
         goto fail1;
 
diff --git a/src/xenbus/fdo.h b/src/xenbus/fdo.h
index e506787..e104d99 100644
--- a/src/xenbus/fdo.h
+++ b/src/xenbus/fdo.h
@@ -100,26 +100,26 @@ FdoTranslateBusAddress(
     _In_ PXENBUS_FDO        Fdo,
     _In_ PHYSICAL_ADDRESS   BusAddress,
     _In_ ULONG              Length,
-    _Inout_ PULONG          AddressSpace,
+    _Out_ PULONG            AddressSpace,
     _Out_ PPHYSICAL_ADDRESS TranslatedAddress
     );
 
 extern ULONG
 FdoSetBusData(
-    _In_ PXENBUS_FDO    Fdo,
-    _In_ ULONG          DataType,
-    _In_ PVOID          Buffer,
-    _In_ ULONG          Offset,
-    _In_ ULONG          Length
+    _In_ PXENBUS_FDO                Fdo,
+    _In_ ULONG                      DataType,
+    _In_reads_bytes_(Length) PVOID  Buffer,
+    _In_ ULONG                      Offset,
+    _In_range_(!=, 0) ULONG         Length
     );
 
 extern ULONG
 FdoGetBusData(
-    _In_ PXENBUS_FDO    Fdo,
-    _In_ ULONG          DataType,
-    _In_ PVOID          Buffer,
-    _In_ ULONG          Offset,
-    _In_ ULONG          Length
+    _In_ PXENBUS_FDO                    Fdo,
+    _In_ ULONG                          DataType,
+    _Out_writes_bytes_(Length) PVOID    Buffer,
+    _In_ ULONG                          Offset,
+    _In_range_(!=, 0) ULONG             Length
     );
 
 extern PSTR
diff --git a/src/xenbus/pdo.c b/src/xenbus/pdo.c
index df07973..ec2fb5e 100644
--- a/src/xenbus/pdo.c
+++ b/src/xenbus/pdo.c
@@ -518,7 +518,7 @@ PdoTranslateBusAddress(
     _In_ PXENBUS_PDO        Pdo,
     _In_ PHYSICAL_ADDRESS   BusAddress,
     _In_ ULONG              Length,
-    _Inout_ PULONG          AddressSpace,
+    _Out_ PULONG            AddressSpace,
     _Out_ PPHYSICAL_ADDRESS TranslatedAddress
     )
 {
@@ -1713,6 +1713,8 @@ PdoSetDevicePowerWorker(
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
+    ASSERT(Pdo != NULL);
+
     Irp = InterlockedExchangePointer(&Pdo->DevicePowerIrp, NULL);
     ASSERT(Irp != NULL);
 
@@ -1803,6 +1805,8 @@ PdoSetSystemPowerWorker(
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
+    ASSERT(Pdo != NULL);
+
     Irp = InterlockedExchangePointer(&Pdo->SystemPowerIrp, NULL);
     ASSERT(Irp != NULL);
 
diff --git a/src/xenbus/pdo.h b/src/xenbus/pdo.h
index af59955..d930919 100644
--- a/src/xenbus/pdo.h
+++ b/src/xenbus/pdo.h
@@ -87,7 +87,7 @@ PdoTranslateBusAddress(
     _In_ PXENBUS_PDO        Pdo,
     _In_ PHYSICAL_ADDRESS   BusAddress,
     _In_ ULONG              Length,
-    _Inout_ PULONG          AddressSpace,
+    _Out_ PULONG            AddressSpace,
     _Out_ PPHYSICAL_ADDRESS TranslatedAddress
     );
 
diff --git a/src/xenbus/shared_info.c b/src/xenbus/shared_info.c
index 84056b7..e85f4c1 100644
--- a/src/xenbus/shared_info.c
+++ b/src/xenbus/shared_info.c
@@ -205,7 +205,7 @@ SharedInfoEvtchnPoll(
     _In_ PINTERFACE                 Interface,
     _In_ ULONG                      Index,
     _In_ XENBUS_SHARED_INFO_EVENT   Event,
-    _In_opt_ PVOID                  Argument
+    _In_ PVOID                      Argument
     )
 {
     PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
diff --git a/src/xenbus/store.c b/src/xenbus/store.c
index 9bdd590..688e22f 100644
--- a/src/xenbus/store.c
+++ b/src/xenbus/store.c
@@ -186,6 +186,7 @@ StorePrepareRequest(
     va_list                             Arguments;
     NTSTATUS                            status;
 
+#pragma prefast(suppress:6001) // for ASSERT on Request only
     ASSERT(IsZeroMemory(Request, sizeof (XENBUS_STORE_REQUEST)));
 
     if (Transaction != NULL) {
diff --git a/src/xenfilt/fdo.c b/src/xenfilt/fdo.c
index de70c6d..594da4a 100644
--- a/src/xenfilt/fdo.c
+++ b/src/xenfilt/fdo.c
@@ -1091,6 +1091,8 @@ FdoSetDevicePowerUpComplete(
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
+    ASSERT(Fdo != NULL);
+
     StackLocation = IoGetCurrentIrpStackLocation(Irp);
     PowerState = StackLocation->Parameters.Power.State;
 
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:20 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:20 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025007.1400760 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCc-00087e-NA; Wed, 25 Jun 2025 14:34:18 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025007.1400760; Wed, 25 Jun 2025 14:34:18 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCc-00087N-JC; Wed, 25 Jun 2025 14:34:18 +0000
Received: by outflank-mailman (input) for mailman id 1025007;
 Wed, 25 Jun 2025 14:34:18 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=KZc6=ZI=bounce.vates.tech=bounce-md_30504962.685c08e5.v1-d46994f3460b4a62a9a3cf33aa1c049f@srs-se1.protection.inumbo.net>)
 id 1uURCb-000871-Vq
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:17 +0000
Received: from mail134-21.atl141.mandrillapp.com
 (mail134-21.atl141.mandrillapp.com [198.2.134.21])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 77b9027d-51d1-11f0-b894-0df219b8e170;
 Wed, 25 Jun 2025 16:34:15 +0200 (CEST)
Received: from pmta10.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail134-21.atl141.mandrillapp.com (Mailchimp) with ESMTP id
 4bS48560HXz1XLP5K
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:13 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 d46994f3460b4a62a9a3cf33aa1c049f; Wed, 25 Jun 2025 14:34:13 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 77b9027d-51d1-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862053; x=1751132053;
	bh=2rE34LTkyiqDCA1gvdHmA/AYeIiMA+1wjUjnKhixDZQ=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=1J8XOI/lQ6dSHUR9PHA6FYJiWlO1ZWhbZYDkRhYlqXo8pEMQkHZYBlW5kXVO4tw+j
	 VMupfZzfHBfmjUfsESvI4OnjoSQvAT6hRAZUCg8no7Y5deKyF00P4YATz/Uqw7Gdf5
	 EamlA1L9wdc001ztrKnhg9vdHgez/bBiIGwg/I0HxBYQgB+7BpIwPwXvS1NCXHDIRT
	 J5n0Jw5EcvEyXmAc2fELZ01rMByWvY7uqcAv7Y/PhUkhpG/EFE+QYkUQ3V7AmBD7Xx
	 PqB6ShDW/f7w9sl1BTS3NB7lcVh9A5Fg0AbXh0WyBylKdbyJ0ytDLk6ZoXc8Q2+myY
	 P/I1I1SnRCv8w==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862053; x=1751122553; i=ngoc-tu.dinh@vates.tech;
	bh=2rE34LTkyiqDCA1gvdHmA/AYeIiMA+1wjUjnKhixDZQ=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=ZIgwf6pNa3AVdZVqal62AaONi+uaxB9rvrfkyDuuZZsfFcd8BNYL8yfD2TqaNr1Su
	 otsCq4spUri8pF+BUQN348G2K27SFdUfbjK0EY3/qJoIutm3JwMV7h8jOEo/YDEv2B
	 JJ0HAMArfRY9oZniiHtmmk0XkyDL0FfOv5yiGU7xu+xfsJdCWyjIDDeZk83Mvgv++F
	 5Vv3ttDlrqPYVTRNGsuKDmFZGYjKBDyf6ee+bAnKIse5HoW0zZG3yJnFbk9CTfMvob
	 SiFGHgyTJaawY/ZO6V7IOpbMFlLTkIelYbq5IqhnR491cFen4L3/FNuXIuUh7zE+A7
	 5zbzaZG5Iw5aw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2005/13]=20Suppress=20uninitialized=20*Interface=20warning=20in=20FdoQueryInterface?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862053151
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-6-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
References: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.d46994f3460b4a62a9a3cf33aa1c049f?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:13 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenbus/fdo.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index 4d3282d..c610231 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -5611,6 +5611,9 @@ FdoQueryInterface(
     if (Irp == NULL)
         goto fail1;
 
+    // suppress "uninitialized *Interface" warning when IoCallDriver succeeds
+    RtlZeroMemory(Interface, sizeof (*Interface));
+
     StackLocation = IoGetNextIrpStackLocation(Irp);
     StackLocation->MinorFunction = IRP_MN_QUERY_INTERFACE;
 
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:20 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:20 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025008.1400763 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCe-0008Ao-OM; Wed, 25 Jun 2025 14:34:20 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025008.1400763; Wed, 25 Jun 2025 14:34:20 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCe-0008Aa-L1; Wed, 25 Jun 2025 14:34:20 +0000
Received: by outflank-mailman (input) for mailman id 1025008;
 Wed, 25 Jun 2025 14:34:19 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4HsZ=ZI=bounce.vates.tech=bounce-md_30504962.685c08e5.v1-5bd89cfb0f5f473ab607f6f720df03c6@srs-se1.protection.inumbo.net>)
 id 1uURCc-000871-Vx
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:19 +0000
Received: from mail180-2.suw31.mandrillapp.com
 (mail180-2.suw31.mandrillapp.com [198.2.180.2])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 776dcf35-51d1-11f0-b894-0df219b8e170;
 Wed, 25 Jun 2025 16:34:14 +0200 (CEST)
Received: from pmta11.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail180-2.suw31.mandrillapp.com (Mailchimp) with ESMTP id 4bS4853n0YzS62RvJ
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:13 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 5bd89cfb0f5f473ab607f6f720df03c6; Wed, 25 Jun 2025 14:34:13 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 776dcf35-51d1-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862053; x=1751132053;
	bh=IBLhr1nLj37QbjmcEEaweirhK7oA9rzZO0IEk5DttLo=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=bY8vOGf4Y53IUiBmIKxUZbf2wdwuXZve4hiKWBMVdiKBExSEFHzYuSVLiA/K+wz9s
	 R7LWNzptV2uwMs1mNvMbCpgBmpe8yEK0spM0R3eiQ9ky6aJHySSutKLtXIloWiRbGI
	 tPLfaRnMBNbae/do4KWfEuJzJ5b8bV9sTApmyTjMgmfnk5TnKdZHpCOfJDJsg2q2W/
	 XBGTqNtj/dP5lbWajC/kto+4OtELp383PtrJu8fom4i38juIO1tUh2zfM3tQGFullU
	 imSHfnZKPYm/vK8hirP37HjE072nL1j3MGhv33hfft5ILgB1xRv50pk6T/LlDi1eKW
	 ik0T+Jvi3jGPg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862053; x=1751122553; i=ngoc-tu.dinh@vates.tech;
	bh=IBLhr1nLj37QbjmcEEaweirhK7oA9rzZO0IEk5DttLo=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=cEcQ2ZmoRhw3l4DJkzwPc50CfQqLr/+EBXURklAIcyDgKQTCwVCOpsQapztcuOZ5m
	 MPyKz1USbgvSZuyCZt0XFN/85yAfmtQOPs9A6s4usTE1puJxaJGAtUTADJImcKSsKa
	 Qsoxor75+/bBVD3qcEWN1GozSjxAAqYLCwNHj3UdlfMoq1bbol+S95Fqz1DRSHtQgb
	 gLf8bDmH4fV6ZhSPr7UV8pRodds9XbG0WpOyA91zcGFfy+cSxUrCyePXC79xzGjsKl
	 0kaq0Q0xuu45JOJ2HcB9p8CY8H6d0WP8KqiNIRyfz7iaji/PT6jcL+I4fS8uB6Fgx8
	 ++oLWNuFLfCFA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2002/13]=20Switch=20from=20char=20pointers=20to=20null-terminated=20string=20types?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862052412
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-3-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
References: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.5bd89cfb0f5f473ab607f6f720df03c6?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:13 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

CHAR*/WCHAR* are currently used as string pointers in many places. These
can be safely replaced with PSTR/PWSTR (and their const equivalents) as
they only differ by annotations.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 include/cache_interface.h     |   4 +-
 include/console_interface.h   |   4 +-
 include/debug_interface.h     |   4 +-
 include/emulated_interface.h  |   4 +-
 include/gnttab_interface.h    |   4 +-
 include/range_set_interface.h |   2 +-
 include/store_interface.h     |  32 +++++------
 include/unplug_interface.h    |   2 +-
 include/xen.h                 |  42 +++++++-------
 src/common/assert.h           |  12 ++--
 src/common/dbg_print.h        |  16 +++---
 src/common/names.h            |  36 ++++++------
 src/common/registry.c         |  60 +++++++++----------
 src/common/registry.h         |  22 +++----
 src/common/util.h             |  24 ++++----
 src/monitor/monitor.c         |  92 ++++++++++++++---------------
 src/xen/acpi.c                |   2 +-
 src/xen/acpi.h                |   2 +-
 src/xen/bug_check.c           |  26 ++++-----
 src/xen/config.c              |  42 +++++++-------
 src/xen/driver.c              |  12 ++--
 src/xen/driver.h              |   2 +-
 src/xen/filters.c             |   8 +--
 src/xen/log.c                 |  32 +++++------
 src/xen/module.c              |  26 ++++-----
 src/xen/process.c             |   4 +-
 src/xen/process.h             |   2 +-
 src/xen/system.c              |   8 +--
 src/xen/unplug.c              |  14 ++---
 src/xen/xen_version.c         |   2 +-
 src/xenbus/balloon.c          |   4 +-
 src/xenbus/cache.c            |   4 +-
 src/xenbus/console.c          |  10 ++--
 src/xenbus/debug.c            |   8 +--
 src/xenbus/evtchn.c           |   2 +-
 src/xenbus/fdo.c              |  60 +++++++++----------
 src/xenbus/fdo.h              |   4 +-
 src/xenbus/gnttab.c           |   4 +-
 src/xenbus/pdo.c              |  18 +++---
 src/xenbus/pdo.h              |   4 +-
 src/xenbus/range_set.c        |   2 +-
 src/xenbus/store.c            | 105 +++++++++++++++++-----------------
 src/xenbus/suspend.c          |   6 +-
 src/xenbus/unplug.c           |   4 +-
 src/xenfilt/driver.c          |  38 ++++++------
 src/xenfilt/driver.h          |  14 ++---
 src/xenfilt/emulated.c        |  26 ++++-----
 src/xenfilt/emulated.h        |   6 +-
 src/xenfilt/fdo.c             |   6 +-
 src/xenfilt/fdo.h             |   2 +-
 src/xenfilt/pdo.c             |  26 ++++-----
 src/xenfilt/pdo.h             |   2 +-
 52 files changed, 449 insertions(+), 448 deletions(-)

diff --git a/include/cache_interface.h b/include/cache_interface.h
index dcf0222..a43e9cc 100644
--- a/include/cache_interface.h
+++ b/include/cache_interface.h
@@ -127,7 +127,7 @@ typedef VOID
 typedef NTSTATUS
 (*XENBUS_CACHE_CREATE_V1)(
     _In_ PINTERFACE                 Interface,
-    _In_ const CHAR                 *Name,
+    _In_ PCSTR                      Name,
     _In_ ULONG                      Size,
     _In_ ULONG                      Reservation,
     _In_ XENBUS_CACHE_CTOR          Ctor,
@@ -159,7 +159,7 @@ typedef NTSTATUS
 typedef NTSTATUS
 (*XENBUS_CACHE_CREATE)(
     _In_ PINTERFACE                 Interface,
-    _In_ const CHAR                 *Name,
+    _In_ PCSTR                      Name,
     _In_ ULONG                      Size,
     _In_ ULONG                      Reservation,
     _In_ ULONG                      Cap,
diff --git a/include/console_interface.h b/include/console_interface.h
index 9235862..0d5a2da 100644
--- a/include/console_interface.h
+++ b/include/console_interface.h
@@ -90,7 +90,7 @@ typedef BOOLEAN
 typedef ULONG
 (*XENBUS_CONSOLE_READ)(
     _In_ PINTERFACE Interface,
-    _In_ PCHAR      Data,
+    _In_ PSTR       Data,
     _In_ ULONG      Length
     );
 
@@ -118,7 +118,7 @@ typedef BOOLEAN
 typedef ULONG
 (*XENBUS_CONSOLE_WRITE)(
     _In_ PINTERFACE Interface,
-    _In_ PCHAR      Data,
+    _In_ PSTR       Data,
     _In_ ULONG      Length
     );
 
diff --git a/include/debug_interface.h b/include/debug_interface.h
index 77f40ba..05fcc3e 100644
--- a/include/debug_interface.h
+++ b/include/debug_interface.h
@@ -93,7 +93,7 @@ typedef VOID
 typedef NTSTATUS
 (*XENBUS_DEBUG_REGISTER)(
     _In_ PINTERFACE                 Interface,
-    _In_ PCHAR                      Prefix,
+    _In_ PSTR                       Prefix,
     _In_ XENBUS_DEBUG_FUNCTION      Function,
     _In_opt_ PVOID                  Argument,
     _Out_ PXENBUS_DEBUG_CALLBACK    *Callback
@@ -112,7 +112,7 @@ typedef NTSTATUS
 typedef VOID
 (*XENBUS_DEBUG_PRINTF)(
     _In_ PINTERFACE             Interface,
-    _In_ const CHAR             *Format,
+    _In_ PCSTR                  Format,
     ...
     );
 
diff --git a/include/emulated_interface.h b/include/emulated_interface.h
index 7920c44..ead9c14 100644
--- a/include/emulated_interface.h
+++ b/include/emulated_interface.h
@@ -75,8 +75,8 @@ typedef VOID
 typedef BOOLEAN
 (*XENFILT_EMULATED_IS_DEVICE_PRESENT)(
     _In_ PVOID      Context,
-    _In_ PCHAR      DeviceID,
-    _In_opt_ PCHAR  InstanceID
+    _In_ PSTR       DeviceID,
+    _In_opt_ PSTR   InstanceID
     );
 
 typedef BOOLEAN
diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h
index 1bc9c4e..6574e97 100644
--- a/include/gnttab_interface.h
+++ b/include/gnttab_interface.h
@@ -76,7 +76,7 @@ typedef VOID
 typedef NTSTATUS
 (*XENBUS_GNTTAB_CREATE_CACHE_V1)(
     _In_ PINTERFACE                 Interface,
-    _In_ const CHAR                 *Name,
+    _In_ PCSTR                      Name,
     _In_ ULONG                      Reservation,
     _In_ XENBUS_CACHE_ACQUIRE_LOCK  AcquireLock,
     _In_ XENBUS_CACHE_RELEASE_LOCK  ReleaseLock,
@@ -99,7 +99,7 @@ typedef NTSTATUS
 typedef NTSTATUS
 (*XENBUS_GNTTAB_CREATE_CACHE)(
     _In_ PINTERFACE                 Interface,
-    _In_ const CHAR                 *Name,
+    _In_ PCSTR                      Name,
     _In_ ULONG                      Reservation,
     _In_ ULONG                      Cap,
     _In_ XENBUS_CACHE_ACQUIRE_LOCK  AcquireLock,
diff --git a/include/range_set_interface.h b/include/range_set_interface.h
index 7b18eb9..dc19a45 100644
--- a/include/range_set_interface.h
+++ b/include/range_set_interface.h
@@ -77,7 +77,7 @@ typedef VOID
 typedef NTSTATUS
 (*XENBUS_RANGE_SET_CREATE)(
     _In_ PINTERFACE         Interface,
-    _In_ const CHAR                 *Name,
+    _In_ PCSTR              Name,
     _Out_ PXENBUS_RANGE_SET *RangeSet
     );
 
diff --git a/include/store_interface.h b/include/store_interface.h
index 4521ba7..dbc383d 100644
--- a/include/store_interface.h
+++ b/include/store_interface.h
@@ -97,7 +97,7 @@ typedef VOID
 typedef VOID
 (*XENBUS_STORE_FREE)(
     _In_ PINTERFACE Interface,
-    _In_ PCHAR      Buffer
+    _In_ PSTR       Buffer
     );
 
 /*! \typedef XENBUS_STORE_READ
@@ -118,9 +118,9 @@ typedef NTSTATUS
 (*XENBUS_STORE_READ)(
     _In_ PINTERFACE                     Interface,
     _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
-    _In_opt_ PCHAR                      Prefix,
-    _In_ PCHAR                          Node,
-    _Out_ PCHAR                         *Buffer
+    _In_opt_ PSTR                       Prefix,
+    _In_ PSTR                           Node,
+    _Outptr_result_z_ PSTR              *Buffer
     );
 
 /*! \typedef XENBUS_STORE_PRINTF
@@ -141,9 +141,9 @@ typedef NTSTATUS
 (*XENBUS_STORE_PRINTF)(
     _In_ PINTERFACE                     Interface,
     _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
-    _In_opt_ PCHAR                      Prefix,
-    _In_ PCHAR                          Node,
-    _In_ const CHAR                     *Format,
+    _In_opt_ PSTR                       Prefix,
+    _In_ PSTR                           Node,
+    _In_ PCSTR                          Format,
     ...
     );
 
@@ -161,8 +161,8 @@ typedef NTSTATUS
 (*XENBUS_STORE_REMOVE)(
     _In_ PINTERFACE                     Interface,
     _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
-    _In_opt_ PCHAR                      Prefix,
-    _In_ PCHAR                          Node
+    _In_opt_ PSTR                       Prefix,
+    _In_ PSTR                           Node
     );
 
 /*! \typedef XENBUS_STORE_DIRECTORY
@@ -183,9 +183,9 @@ typedef NTSTATUS
 (*XENBUS_STORE_DIRECTORY)(
     _In_ PINTERFACE                     Interface,
     _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
-    _In_opt_ PCHAR                      Prefix,
-    _In_ PCHAR                          Node,
-    _Out_ PCHAR                         *Buffer
+    _In_opt_ PSTR                       Prefix,
+    _In_ PSTR                           Node,
+    _Outptr_result_z_ PSTR              *Buffer
     );
 
 /*! \typedef XENBUS_STORE_TRANSACTION_START
@@ -232,8 +232,8 @@ typedef NTSTATUS
 typedef NTSTATUS
 (*XENBUS_STORE_WATCH_ADD)(
     _In_ PINTERFACE             Interface,
-    _In_opt_ PCHAR              Prefix,
-    _In_ PCHAR                  Node,
+    _In_opt_ PSTR               Prefix,
+    _In_ PSTR                   Node,
     _In_ PKEVENT                Event,
     _Out_ PXENBUS_STORE_WATCH   *Watch
     );
@@ -281,8 +281,8 @@ typedef NTSTATUS
 (*XENBUS_STORE_PERMISSIONS_SET)(
     _In_ PINTERFACE                     Interface,
     _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
-    _In_opt_ PCHAR                      Prefix,
-    _In_ PCHAR                          Node,
+    _In_opt_ PSTR                       Prefix,
+    _In_ PSTR                           Node,
     _In_ PXENBUS_STORE_PERMISSION       Permissions,
     _In_ ULONG                          NumberPermissions
     );
diff --git a/include/unplug_interface.h b/include/unplug_interface.h
index 7b030e7..249a873 100644
--- a/include/unplug_interface.h
+++ b/include/unplug_interface.h
@@ -118,7 +118,7 @@ typedef BOOLEAN
 typedef VOID
 (*XENBUS_UNPLUG_REBOOT)(
     _In_ PINTERFACE                 Interface,
-    _In_ PCHAR                      Module
+    _In_ PSTR                       Module
     );
 
 // {73db6517-3d06-4937-989f-199b7501e229}
diff --git a/include/xen.h b/include/xen.h
index 1ba109c..ce78f86 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -69,7 +69,7 @@
 XEN_API
 NTSTATUS
 XenTouch(
-    _In_ const CHAR *Name,
+    _In_ PCSTR      Name,
     _In_ ULONG      MajorVersion,
     _In_ ULONG      MinorVersion,
     _In_ ULONG      MicroVersion,
@@ -338,7 +338,7 @@ _Check_return_
 XEN_API
 NTSTATUS
 XenVersionExtra(
-    _Out_writes_(XEN_EXTRAVERSION_LEN) PCHAR    Extra
+    _Out_writes_z_(XEN_EXTRAVERSION_LEN) PSTR   Extra
     );
 
 // MODULE
@@ -346,9 +346,9 @@ XenVersionExtra(
 XEN_API
 VOID
 ModuleLookup(
-    _In_ ULONG_PTR      Address,
-    _Out_ PCHAR         *Name,
-    _Out_ PULONG_PTR    Offset
+    _In_ ULONG_PTR          Address,
+    _Outptr_result_z_ PSTR  *Name,
+    _Out_ PULONG_PTR        Offset
     );
 
 // UNPLUG
@@ -399,7 +399,7 @@ VOID
 LogCchVPrintf(
     _In_ LOG_LEVEL  Level,
     _In_ ULONG      Count,
-    _In_ const CHAR *Format,
+    _In_ PCSTR      Format,
     _In_ va_list    Arguments
     );
 
@@ -407,7 +407,7 @@ XEN_API
 VOID
 LogVPrintf(
     _In_ LOG_LEVEL  Level,
-    _In_ const CHAR *Format,
+    _In_ PCSTR      Format,
     _In_ va_list    Arguments
     );
 
@@ -416,7 +416,7 @@ VOID
 LogCchPrintf(
     _In_ LOG_LEVEL  Level,
     _In_ ULONG      Count,
-    _In_ const CHAR *Format,
+    _In_ PCSTR      Format,
     ...
     );
 
@@ -424,7 +424,7 @@ XEN_API
 VOID
 LogPrintf(
     _In_ LOG_LEVEL  Level,
-    _In_ const CHAR *Format,
+    _In_ PCSTR      Format,
     ...
     );
 
@@ -438,7 +438,7 @@ XEN_API
 NTSTATUS
 LogReadLogLevel(
     _In_ HANDLE         Key,
-    _In_ PCHAR          Name,
+    _In_ PSTR           Name,
     _Out_ PLOG_LEVEL    LogLevel
     );
 
@@ -448,7 +448,7 @@ XEN_API
 NTSTATUS
 LogAddDisposition(
     _In_ LOG_LEVEL          Mask,
-    _In_ VOID               (*Function)(PVOID, PCHAR, ULONG),
+    _In_ VOID               (*Function)(PVOID, PSTR, ULONG),
     _In_opt_ PVOID          Argument,
     _Out_ PLOG_DISPOSITION  *Disposition
     );
@@ -545,24 +545,24 @@ FiltersUninstall(
 XEN_API
 NTSTATUS
 ConfigGetActive(
-    _In_ const CHAR *Key,
-    _Out_ PCHAR     *Value
+    _In_ PCSTR              Key,
+    _Outptr_result_z_ PSTR  *Value
     );
 
 XEN_API
 NTSTATUS
 ConfigSetActive(
-    _In_ PCHAR  DeviceID,
-    _In_ PCHAR  InstanceID,
-    _In_ PCHAR  LocationInformation
+    _In_ PSTR   DeviceID,
+    _In_ PSTR   InstanceID,
+    _In_ PSTR   LocationInformation
     );
 
 XEN_API
 NTSTATUS
 ConfigUpdateActive(
-    _In_ PCHAR  DeviceID,
-    _In_ PCHAR  InstanceID,
-    _In_ PCHAR  LocationInformation
+    _In_ PSTR   DeviceID,
+    _In_ PSTR   InstanceID,
+    _In_ PSTR   LocationInformation
     );
 
 XEN_API
@@ -575,13 +575,13 @@ XEN_API
 NTSTATUS
 ConfigRequestReboot(
     _In_ HANDLE     ParametersKey,
-    _In_ PCHAR      Module
+    _In_ PSTR       Module
     );
 
 XEN_API
 NTSTATUS
 ConfigQuerySystemStartOption(
-    _In_ PCHAR          Key,
+    _In_ PSTR           Key,
     _Out_ PANSI_STRING  *Option
     );
 
diff --git a/src/common/assert.h b/src/common/assert.h
index 6c6ee28..1c1104d 100644
--- a/src/common/assert.h
+++ b/src/common/assert.h
@@ -58,8 +58,8 @@ __Bug(
 
 #define BUG(_TEXT)                                              \
         do {                                                    \
-            const CHAR  *_Text = (_TEXT);                       \
-            const CHAR  *_File = __FILE__;                      \
+            PCSTR       _Text = (_TEXT);                       \
+            PCSTR       _File = __FILE__;                      \
             ULONG       _Line = __LINE__;                       \
                                                                 \
             Error("BUG: " _TEXT "\n");                          \
@@ -154,8 +154,8 @@ __Bug(
 
 static __inline BOOLEAN
 _IsZeroMemory(
-    _In_ const PCHAR    Caller,
-    _In_ const PCHAR    Name,
+    _In_ const PSTR     Caller,
+    _In_ const PSTR     Name,
     _In_ PVOID          Buffer,
     _In_ ULONG          Length
     )
@@ -178,8 +178,8 @@ _IsZeroMemory(
 
 static __inline BOOLEAN
 _IsZeroMemory(
-    _In_ const PCHAR    Caller,
-    _In_ const PCHAR    Name,
+    _In_ const PSTR     Caller,
+    _In_ const PSTR     Name,
     _In_ PVOID          Buffer,
     _In_ ULONG          Length
     )
diff --git a/src/common/dbg_print.h b/src/common/dbg_print.h
index 372fd7b..a35f51d 100644
--- a/src/common/dbg_print.h
+++ b/src/common/dbg_print.h
@@ -44,8 +44,8 @@
 
 static __inline VOID
 __Error(
-    _In_ const CHAR *Prefix,
-    _In_ const CHAR *Format,
+    _In_ PCSTR      Prefix,
+    _In_ PCSTR      Format,
     ...
     )
 {
@@ -67,8 +67,8 @@ __Error(
 
 static __inline VOID
 __Warning(
-    _In_ const CHAR *Prefix,
-    _In_ const CHAR *Format,
+    _In_ PCSTR      Prefix,
+    _In_ PCSTR      Format,
     ...
     )
 {
@@ -91,8 +91,8 @@ __Warning(
 #if DBG
 static __inline VOID
 __Trace(
-    _In_ const CHAR *Prefix,
-    _In_ const CHAR *Format,
+    _In_ PCSTR      Prefix,
+    _In_ PCSTR      Format,
     ...
     )
 {
@@ -117,8 +117,8 @@ __Trace(
 
 static __inline VOID
 __Info(
-    _In_ const CHAR *Prefix,
-    _In_ const CHAR *Format,
+    _In_ PCSTR      Prefix,
+    _In_ PCSTR      Format,
     ...
     )
 {
diff --git a/src/common/names.h b/src/common/names.h
index a7af965..912fd4d 100644
--- a/src/common/names.h
+++ b/src/common/names.h
@@ -36,7 +36,7 @@
 #include <ntddk.h>
 #include <xen.h>
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 PowerStateTypeName(
     _In_ POWER_STATE_TYPE   Type
     )
@@ -56,7 +56,7 @@ PowerStateTypeName(
 #undef  _POWER_ACTION_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 SystemPowerStateName(
     _In_ SYSTEM_POWER_STATE State
     )
@@ -82,7 +82,7 @@ SystemPowerStateName(
 #undef  _POWER_SYSTEM_STATE_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 DevicePowerStateName(
     _In_ DEVICE_POWER_STATE State
     )
@@ -106,7 +106,7 @@ DevicePowerStateName(
 #undef  _POWER_DEVICE_STATE_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 PowerActionName(
     _In_ POWER_ACTION   Type
     )
@@ -132,7 +132,7 @@ PowerActionName(
 #undef  _POWER_ACTION_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 PowerMinorFunctionName(
     _In_ ULONG  MinorFunction
     )
@@ -154,7 +154,7 @@ PowerMinorFunctionName(
 #undef  _POWER_MINOR_FUNCTION_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 PnpMinorFunctionName(
     _In_ ULONG  Function
     )
@@ -197,7 +197,7 @@ PnpMinorFunctionName(
 #undef  _PNP_MINOR_FUNCTION_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 ResourceDescriptorTypeName(
     _In_ UCHAR  Type
     )
@@ -226,7 +226,7 @@ ResourceDescriptorTypeName(
 #undef  _RESOURCE_DESCRIPTOR_TYPE_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 ResourceDescriptorShareDispositionName(
     _In_ UCHAR  Disposition
     )
@@ -249,7 +249,7 @@ ResourceDescriptorShareDispositionName(
 #undef  _RESOURCE_DESCRIPTOR_SHARE_DISPOSITION_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 IrqDevicePolicyName(
     _In_ IRQ_DEVICE_POLICY  Policy
     )
@@ -274,7 +274,7 @@ IrqDevicePolicyName(
 #undef  _IRQ_DEVICE_POLICY_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 IrqPriorityName(
     _In_ IRQ_PRIORITY   Priority
     )
@@ -297,7 +297,7 @@ IrqPriorityName(
 #undef  _IRQ_PRIORITY_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 InterruptModeName(
     _In_ KINTERRUPT_MODE    Mode
     )
@@ -318,7 +318,7 @@ InterruptModeName(
 #undef  _INTERRUPT_MODE_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 DeviceUsageNotificationTypeName(
     _In_ DEVICE_USAGE_NOTIFICATION_TYPE Type
     )
@@ -340,7 +340,7 @@ DeviceUsageNotificationTypeName(
 #undef  _DEVICE_USAGE_TYPE_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 InterfaceTypeName(
     _In_ INTERFACE_TYPE Type
     )
@@ -378,7 +378,7 @@ InterfaceTypeName(
 #undef  _INTERFACE_TYPE_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 DmaWidthName(
     _In_ DMA_WIDTH  Width
     )
@@ -402,7 +402,7 @@ DmaWidthName(
 #undef  _DMA_WIDTH_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 DmaSpeedName(
     _In_ DMA_SPEED  Speed
     )
@@ -427,7 +427,7 @@ DmaSpeedName(
 #undef  _DMA_SPEED_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 BusQueryIdTypeName(
     _In_ BUS_QUERY_ID_TYPE  Type
     )
@@ -452,7 +452,7 @@ BusQueryIdTypeName(
 #undef  _BUS_QUERY_ID_TYPE_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 ProcessorChangeName(
     _In_ KE_PROCESSOR_CHANGE_NOTIFY_STATE   Change
     )
@@ -474,7 +474,7 @@ ProcessorChangeName(
 #undef _PROCESSOR_CHANGE_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 VirqName(
     _In_ ULONG  Type
     )
diff --git a/src/common/registry.c b/src/common/registry.c
index 6a8c73e..51a98bb 100644
--- a/src/common/registry.c
+++ b/src/common/registry.c
@@ -188,15 +188,15 @@ fail1:
 
 static NTSTATUS
 RegistryOpenRoot(
-    _In_ PWCHAR         Path,
-    _Out_ PHANDLE       Parent,
-    _Out_ PWCHAR        *ChildPath
+    _In_ PWSTR              Path,
+    _Out_ PHANDLE           Parent,
+    _Outptr_result_z_ PWSTR *ChildPath
     )
 {
-    const WCHAR         Prefix[] = L"\\Registry\\Machine\\";
-    ULONG               Length;
-    UNICODE_STRING      Unicode;
-    NTSTATUS            status;
+    PCWSTR                  Prefix = L"\\Registry\\Machine\\";
+    ULONG                   Length;
+    UNICODE_STRING          Unicode;
+    NTSTATUS                status;
 
     Length = (ULONG)wcslen(Prefix);
 
@@ -227,11 +227,11 @@ RegistryCreateKey(
     _Out_ PHANDLE           Key
     )
 {
-    PWCHAR              Buffer;
+    PWSTR               Buffer;
     HANDLE              Root;
-    PWCHAR              ChildPath;
-    PWCHAR              ChildName;
-    PWCHAR              Context;
+    PWSTR               ChildPath;
+    PWSTR               ChildName;
+    PWSTR               Context;
     HANDLE              Child;
     NTSTATUS            status;
 
@@ -368,7 +368,7 @@ RegistryOpenHardwareKey(
     HANDLE                  SubKey;
     ULONG                   Length;
     PKEY_NAME_INFORMATION   Info;
-    PWCHAR                  Cursor;
+    PWSTR                   Cursor;
     UNICODE_STRING          Unicode;
     NTSTATUS                status;
 
@@ -438,7 +438,7 @@ fail1:
 NTSTATUS
 RegistryOpenSubKey(
     _In_opt_ PHANDLE    Key,
-    _In_ PCHAR          Name,
+    _In_ PSTR           Name,
     _In_ ACCESS_MASK    DesiredAccess,
     _Out_ PHANDLE       SubKey
     )
@@ -471,7 +471,7 @@ fail1:
 NTSTATUS
 RegistryCreateSubKey(
     _In_opt_ HANDLE     Key,
-    _In_ PCHAR          Name,
+    _In_ PSTR           Name,
     _In_ ULONG          Options,
     _Out_ PHANDLE       SubKey
     )
@@ -504,7 +504,7 @@ fail1:
 NTSTATUS
 RegistryDeleteSubKey(
     _In_ PHANDLE        Key,
-    _In_ PCHAR          Name
+    _In_ PSTR           Name
     )
 {
     ANSI_STRING         Ansi;
@@ -756,7 +756,7 @@ fail1:
 NTSTATUS
 RegistryDeleteValue(
     _In_ PHANDLE        Key,
-    _In_ PCHAR          Name
+    _In_ PSTR           Name
     )
 {
     ANSI_STRING         Ansi;
@@ -787,7 +787,7 @@ fail1:
 NTSTATUS
 RegistryQueryDwordValue(
     _In_ HANDLE                     Key,
-    _In_ PCHAR                      Name,
+    _In_ PSTR                       Name,
     _Out_ PULONG                    Value
     )
 {
@@ -857,7 +857,7 @@ fail1:
 NTSTATUS
 RegistryUpdateDwordValue(
     _In_ HANDLE                     Key,
-    _In_ PCHAR                      Name,
+    _In_ PSTR                       Name,
     _In_ ULONG                      Value
     )
 {
@@ -912,7 +912,7 @@ fail1:
 
 static PANSI_STRING
 RegistrySzToAnsi(
-    _In_ PWCHAR     Buffer
+    _In_ PWSTR      Buffer
     )
 {
     PANSI_STRING    Ansi;
@@ -951,7 +951,7 @@ fail1:
 
 static PANSI_STRING
 RegistryMultiSzToAnsi(
-    _In_ PWCHAR     Buffer
+    _In_ PWSTR      Buffer
     )
 {
     PANSI_STRING    Ansi;
@@ -1014,7 +1014,7 @@ fail1:
 NTSTATUS
 RegistryQuerySzValue(
     _In_ HANDLE                     Key,
-    _In_ PCHAR                      Name,
+    _In_ PSTR                       Name,
     _Out_opt_ PULONG                Type,
     _Out_ PANSI_STRING              *Array
     )
@@ -1060,12 +1060,12 @@ RegistryQuerySzValue(
     switch (Value->Type) {
     case REG_SZ:
         status = STATUS_NO_MEMORY;
-        *Array = RegistrySzToAnsi((PWCHAR)Value->Data);
+        *Array = RegistrySzToAnsi((PWSTR)Value->Data);
         break;
 
     case REG_MULTI_SZ:
         status = STATUS_NO_MEMORY;
-        *Array = RegistryMultiSzToAnsi((PWCHAR)Value->Data);
+        *Array = RegistryMultiSzToAnsi((PWSTR)Value->Data);
         break;
 
     default:
@@ -1101,7 +1101,7 @@ fail1:
 NTSTATUS
 RegistryQueryBinaryValue(
     _In_ HANDLE                     Key,
-    _In_ PCHAR                      Name,
+    _In_ PSTR                       Name,
     _Out_ PVOID                     *Buffer,
     _Out_ PULONG                    Length
     )
@@ -1186,7 +1186,7 @@ fail1:
 NTSTATUS
 RegistryUpdateBinaryValue(
     _In_ HANDLE                     Key,
-    _In_ PCHAR                      Name,
+    _In_ PSTR                       Name,
     _In_ PVOID                      Buffer,
     _In_ ULONG                      Length
     )
@@ -1276,7 +1276,7 @@ RegistryQueryKeyName(
         goto fail3;
 
     Value->Name[Value->NameLength / sizeof (WCHAR)] = L'\0';
-    *Array = RegistrySzToAnsi((PWCHAR)Value->Name);
+    *Array = RegistrySzToAnsi((PWSTR)Value->Name);
 
     status = STATUS_NO_MEMORY;
     if (*Array == NULL)
@@ -1297,7 +1297,7 @@ fail1:
 
 NTSTATUS
 RegistryQuerySystemStartOption(
-    _In_ PCHAR                      Prefix,
+    _In_ PSTR                       Prefix,
     _Out_ PANSI_STRING              *Value
     )
 {
@@ -1305,8 +1305,8 @@ RegistryQuerySystemStartOption(
     HANDLE                          Key;
     PANSI_STRING                    Ansi;
     ULONG                           Length;
-    PCHAR                           Option;
-    PCHAR                           Context;
+    PSTR                            Option;
+    PSTR                            Context;
     NTSTATUS                        status;
 
     RtlInitUnicodeString(&Unicode, L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control");
@@ -1468,7 +1468,7 @@ fail1:
 NTSTATUS
 RegistryUpdateSzValue(
     _In_ HANDLE                     Key,
-    _In_ PCHAR                      Name,
+    _In_ PSTR                       Name,
     _In_ ULONG                      Type,
     _In_ PANSI_STRING               Array
     )
diff --git a/src/common/registry.h b/src/common/registry.h
index dd4e035..a65081f 100644
--- a/src/common/registry.h
+++ b/src/common/registry.h
@@ -96,7 +96,7 @@ RegistryOpenHardwareKey(
 extern NTSTATUS
 RegistryOpenSubKey(
     _In_opt_ HANDLE     Key,
-    _In_ PCHAR          Name,
+    _In_ PSTR           Name,
     _In_ ACCESS_MASK    DesiredAccess,
     _Out_ PHANDLE       SubKey
     );
@@ -104,7 +104,7 @@ RegistryOpenSubKey(
 extern NTSTATUS
 RegistryCreateSubKey(
     _In_opt_ HANDLE Key,
-    _In_ PCHAR      Name,
+    _In_ PSTR       Name,
     _In_ ULONG      Options,
     _Out_ PHANDLE   SubKey
     );
@@ -112,7 +112,7 @@ RegistryCreateSubKey(
 extern NTSTATUS
 RegistryDeleteSubKey(
     _In_ HANDLE     Key,
-    _In_ PCHAR      Name
+    _In_ PSTR       Name
     );
 
 extern NTSTATUS
@@ -132,27 +132,27 @@ RegistryEnumerateValues(
 extern NTSTATUS
 RegistryDeleteValue(
     _In_ HANDLE     Key,
-    _In_ PCHAR      Name
+    _In_ PSTR       Name
     );
 
 extern NTSTATUS
 RegistryQueryDwordValue(
     _In_ HANDLE         Key,
-    _In_ PCHAR          Name,
+    _In_ PSTR           Name,
     _Out_ PULONG        Value
     );
 
 extern NTSTATUS
 RegistryUpdateDwordValue(
     _In_ HANDLE         Key,
-    _In_ PCHAR          Name,
+    _In_ PSTR           Name,
     _In_ ULONG          Value
     );
 
 extern NTSTATUS
 RegistryQuerySzValue(
     _In_ HANDLE         Key,
-    _In_ PCHAR          Name,
+    _In_ PSTR           Name,
     _Out_opt_ PULONG    Type,
     _Out_ PANSI_STRING  *Array
     );
@@ -160,7 +160,7 @@ RegistryQuerySzValue(
 extern NTSTATUS
 RegistryQueryBinaryValue(
     _In_ HANDLE         Key,
-    _In_ PCHAR          Name,
+    _In_ PSTR           Name,
     _Out_ PVOID         *Buffer,
     _Out_ PULONG        Length
     );
@@ -168,7 +168,7 @@ RegistryQueryBinaryValue(
 extern NTSTATUS
 RegistryUpdateBinaryValue(
     _In_ HANDLE         Key,
-    _In_ PCHAR          Name,
+    _In_ PSTR           Name,
     _In_ PVOID          Buffer,
     _In_ ULONG          Length
     );
@@ -181,7 +181,7 @@ RegistryQueryKeyName(
 
 extern NTSTATUS
 RegistryQuerySystemStartOption(
-    _In_ PCHAR          Name,
+    _In_ PSTR           Name,
     _Out_ PANSI_STRING  *Option
     );
 
@@ -198,7 +198,7 @@ RegistryFreeBinaryValue(
 extern NTSTATUS
 RegistryUpdateSzValue(
     _In_ HANDLE         Key,
-    _In_ PCHAR          Name,
+    _In_ PSTR           Name,
     _In_ ULONG          Type,
     _In_ PANSI_STRING   Array
     );
diff --git a/src/common/util.h b/src/common/util.h
index a658adb..9398daa 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -274,15 +274,15 @@ __FreePages(
 
 #define __FreePage(_Mdl)    __FreePages(_Mdl)
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __strtok_r(
-    _In_opt_ PCHAR  Buffer,
-    _In_ PCHAR      Delimiter,
-    _Inout_ PCHAR   *Context
+    _In_opt_ PSTR   Buffer,
+    _In_ PSTR       Delimiter,
+    _Inout_ PSTR    *Context
     )
 {
-    PCHAR           Token;
-    PCHAR           End;
+    PSTR            Token;
+    PSTR            End;
 
     if (Buffer != NULL)
         *Context = Buffer;
@@ -312,15 +312,15 @@ __strtok_r(
     return Token;
 }
 
-static FORCEINLINE PWCHAR
+static FORCEINLINE PWSTR
 __wcstok_r(
-    _In_opt_ PWCHAR Buffer,
-    _In_ PWCHAR     Delimiter,
-    _Inout_ PWCHAR  *Context
+    _In_opt_ PWSTR  Buffer,
+    _In_ PWSTR      Delimiter,
+    _Inout_ PWSTR   *Context
     )
 {
-    PWCHAR          Token;
-    PWCHAR          End;
+    PWSTR           Token;
+    PWSTR           End;
 
     if (Buffer != NULL)
         *Context = Buffer;
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 532436d..f6e39f8 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -61,18 +61,18 @@ typedef struct _MONITOR_CONTEXT {
     HANDLE                  RequestEvent;
     HANDLE                  Timer;
     HKEY                    RequestKey;
-    PTCHAR                  Title;
-    PTCHAR                  Text;
-    PTCHAR                  Question;
+    PTSTR                   Title;
+    PTSTR                   Text;
+    PTSTR                   Question;
     BOOL                    RebootPrompted;
-    PTCHAR                  RebootRequestedBy;
+    PTSTR                   RebootRequestedBy;
     HANDLE                  ResponseEvent;
     DWORD                   Response;
 } MONITOR_CONTEXT, *PMONITOR_CONTEXT;
 
 typedef struct _REBOOT_PROMPT {
-    PTCHAR                  Title;
-    PTCHAR                  Text;
+    PTSTR                   Title;
+    PTSTR                   Text;
     HANDLE                  ResponseEvent;
     PDWORD                  PResponse;
 } REBOOT_PROMPT, *PREBOOT_PROMPT;
@@ -93,7 +93,7 @@ MONITOR_CONTEXT MonitorContext;
 static VOID
 #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
 __Log(
-    _In_ const CHAR     *Format,
+    _In_ PCSTR          Format,
     ...
     )
 {
@@ -146,12 +146,12 @@ __Log(
 #define Log(_Format, ...) \
         __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
 
-static PTCHAR
+static PTSTR
 GetErrorMessage(
     _In_  HRESULT   Error
     )
 {
-    PTCHAR          Message;
+    PTSTR           Message;
     ULONG           Index;
 
     if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
@@ -175,7 +175,7 @@ GetErrorMessage(
     return Message;
 }
 
-static const CHAR *
+static PCSTR
 ServiceStateName(
     _In_ DWORD  State
     )
@@ -241,7 +241,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
@@ -285,7 +285,7 @@ MonitorCtrlHandlerEx(
     return ERROR_CALL_NOT_IMPLEMENTED;
 }
 
-static const CHAR *
+static PCSTR
 WTSStateName(
     _In_ DWORD  State
     )
@@ -316,7 +316,7 @@ WTSStateName(
 
 static VOID
 DoReboot(
-    _In_ PTCHAR Message,
+    _In_ PTSTR  Message,
     _In_ DWORD  Timeout
     )
 {
@@ -365,9 +365,9 @@ GetPromptTimeout(
     return Value;
 }
 
-static PTCHAR
+static PTSTR
 GetDisplayName(
-    _In_ PTCHAR         DriverName
+    _In_ PTSTR          DriverName
     )
 {
     HRESULT             Result;
@@ -376,7 +376,7 @@ GetDisplayName(
     DWORD               MaxValueLength;
     DWORD               Type;
     DWORD               DisplayNameLength;
-    PTCHAR              DisplayName;
+    PTSTR               DisplayName;
     HRESULT             Error;
 
     Result = StringCbPrintf(ServiceKeyName,
@@ -458,7 +458,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
@@ -521,7 +521,7 @@ DoPromptForReboot(
 
     for (Index = 0; Index < Count; Index++) {
         DWORD                   SessionId = SessionInfo[Index].SessionId;
-        PTCHAR                  Name = SessionInfo[Index].pWinStationName;
+        PTSTR                   Name = SessionInfo[Index].pWinStationName;
         WTS_CONNECTSTATE_CLASS  State = SessionInfo[Index].State;
         DWORD                   Response;
 
@@ -570,14 +570,14 @@ fail1:
 
 static VOID
 PromptForReboot(
-    _In_ PTCHAR         DriverName
+    _In_ PTSTR          DriverName
     )
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
     HRESULT             Result;
     PREBOOT_PROMPT      Prompt;
-    PTCHAR              DisplayName;
-    PTCHAR              Description;
+    PTSTR               DisplayName;
+    PTSTR               Description;
     HANDLE              PromptThread;
     DWORD               TextLength;
     DWORD               Error;
@@ -670,7 +670,7 @@ fail2:
 
 fail1:
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
@@ -681,7 +681,7 @@ fail1:
 
 static VOID
 TryAutoReboot(
-    _In_ PTCHAR         DriverName
+    _In_ PTSTR          DriverName
     )
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
@@ -692,9 +692,9 @@ TryAutoReboot(
     DWORD               RebootCount;
     DWORD               Length;
     DWORD               Timeout;
-    PTCHAR              DisplayName;
-    PTCHAR              Description;
-    PTCHAR              Text;
+    PTSTR               DisplayName;
+    PTSTR               Description;
+    PTSTR               Text;
     DWORD               TextLength;
     ULONG               PowerInfo;
     NTSTATUS            Status;
@@ -847,7 +847,7 @@ fail2:
 
 fail1:
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
@@ -865,7 +865,7 @@ CheckRequestSubKeys(
     DWORD               SubKeys;
     DWORD               MaxSubKeyLength;
     DWORD               SubKeyLength;
-    PTCHAR              SubKeyName;
+    PTSTR               SubKeyName;
     DWORD               Index;
     HKEY                SubKey;
     HRESULT             Error;
@@ -976,7 +976,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1012,7 +1012,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1077,7 +1077,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1089,14 +1089,14 @@ fail1:
 _Success_(return)
 static BOOL
 GetRequestKeyName(
-    _Out_ PTCHAR        *RequestKeyName
+    _Outptr_result_z_ PTSTR     *RequestKeyName
     )
 {
-    PMONITOR_CONTEXT    Context = &MonitorContext;
-    DWORD               MaxValueLength;
-    DWORD               RequestKeyNameLength;
-    DWORD               Type;
-    HRESULT             Error;
+    PMONITOR_CONTEXT            Context = &MonitorContext;
+    DWORD                       MaxValueLength;
+    DWORD                       RequestKeyNameLength;
+    DWORD                       Type;
+    HRESULT                     Error;
 
     Error = RegQueryInfoKey(Context->ParametersKey,
                             NULL,
@@ -1156,7 +1156,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1300,7 +1300,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1311,7 +1311,7 @@ fail1:
 
 static BOOL
 RemoveStartOverride(
-    _In_ PTCHAR         DriverName
+    _In_ PTSTR          DriverName
     )
 {
     TCHAR               KeyName[MAX_PATH];
@@ -1360,7 +1360,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1376,7 +1376,7 @@ MonitorMain(
     )
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
-    PTCHAR              RequestKeyName;
+    PTSTR               RequestKeyName;
     BOOL                Success;
     HRESULT             Error;
     LARGE_INTEGER       DueTime;
@@ -1601,7 +1601,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1666,7 +1666,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1738,7 +1738,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1775,7 +1775,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         Log("fail1 (%s)", Message);
         LocalFree(Message);
diff --git a/src/xen/acpi.c b/src/xen/acpi.c
index a73e822..c5399f0 100644
--- a/src/xen/acpi.c
+++ b/src/xen/acpi.c
@@ -212,7 +212,7 @@ fail1:
 
 NTSTATUS
 AcpiGetTable(
-    _In_ const CHAR     *Signature,
+    _In_ PCSTR          Signature,
     _Out_opt_ PVOID     Buffer,
     _Inout_ PULONG      Length
     )
diff --git a/src/xen/acpi.h b/src/xen/acpi.h
index f6a9f99..2de9765 100644
--- a/src/xen/acpi.h
+++ b/src/xen/acpi.h
@@ -95,7 +95,7 @@ AcpiInitialize(
 
 extern NTSTATUS
 AcpiGetTable(
-    _In_ const CHAR *Signature,
+    _In_ PCSTR      Signature,
     _Out_opt_ PVOID Buffer,
     _Inout_ PULONG  Length
     );
diff --git a/src/xen/bug_check.c b/src/xen/bug_check.c
index 85f9f70..24bedfb 100644
--- a/src/xen/bug_check.c
+++ b/src/xen/bug_check.c
@@ -213,7 +213,7 @@ BugCheckStackDump(
             ULONG       EIP;
             ULONG       Parameter[PARAMETER_COUNT] = {0};
             ULONG       Index;
-            PCHAR       Name;
+            PSTR        Name;
             ULONG       Offset;
 
             NextEBP = *(PULONG)EBP;
@@ -515,7 +515,7 @@ BugCheckStackDump(
             ULONG64             RSP;
             ULONG64             Parameter[PARAMETER_COUNT] = {0};
             ULONG               Index;
-            PCHAR               Name;
+            PSTR                Name;
             ULONG64             Offset;
 
             if (Context->Rip == 0)
@@ -619,7 +619,7 @@ BugCheckIrqlNotLessOrEqual(
         KIRQL       Irql = (KIRQL)Parameter2;
         ULONG_PTR   Access = Parameter3;
         PVOID       Address = (PVOID)Parameter4;
-        PCHAR       Name;
+        PSTR        Name;
         ULONG_PTR   Offset;
 
         LogPrintf(LOG_LEVEL_CRITICAL,
@@ -670,7 +670,7 @@ BugCheckDriverIrqlNotLessOrEqual(
         KIRQL       Irql = (KIRQL)Parameter2;
         ULONG_PTR   Access = Parameter3;
         PVOID       Address = (PVOID)Parameter4;
-        PCHAR       Name;
+        PSTR        Name;
         ULONG_PTR   Offset;
 
         LogPrintf(LOG_LEVEL_CRITICAL,
@@ -743,7 +743,7 @@ BugCheckSystemThreadExceptionNotHandled(
         PVOID               Address = (PVOID)Parameter2;
         PEXCEPTION_RECORD   Exception = (PEXCEPTION_RECORD)Parameter3;
         PCONTEXT            Context = (PCONTEXT)Parameter4;
-        PCHAR               Name;
+        PSTR                Name;
         ULONG_PTR           Offset;
 
         ModuleLookup((ULONG_PTR)Address, &Name, &Offset);
@@ -783,7 +783,7 @@ BugCheckKernelModeExceptionNotHandled(
         CONTEXT     Context;
         ULONG       Code = (ULONG)Parameter1;
         PVOID       Address = (PVOID)Parameter2;
-        PCHAR       Name;
+        PSTR        Name;
         ULONG_PTR	Offset;
 
         UNREFERENCED_PARAMETER(Parameter3);
@@ -829,8 +829,8 @@ BugCheckCriticalObjectTermination(
     __try {
         ULONG       Type = (ULONG)Parameter1;
         PVOID	    Object = (PVOID)Parameter2;
-        PCHAR	    Name = (PCHAR)Parameter3;
-        PCHAR       Reason = (PCHAR)Parameter4;
+        PSTR 	    Name = (PSTR)Parameter3;
+        PSTR        Reason = (PSTR)Parameter4;
         CONTEXT     Context;
 
         LogPrintf(LOG_LEVEL_CRITICAL,
@@ -933,7 +933,7 @@ BugCheckDriverPowerStateFailure(
                       __MODULE__);
 
             for (Index = 0; Index <= Irp->StackCount; Index++) {
-                PCHAR       Name;
+                PSTR        Name;
                 ULONG_PTR   Offset;
 
                 LogPrintf(LOG_LEVEL_CRITICAL,
@@ -993,8 +993,8 @@ BugCheckAssertionFailure(
     )
 {
     __try {
-        PCHAR       Text = (PCHAR)Parameter1;
-        PCHAR       File = (PCHAR)Parameter2;
+        PSTR        Text = (PSTR)Parameter1;
+        PSTR        File = (PSTR)Parameter2;
         ULONG       Line = (ULONG)Parameter3;
         CONTEXT     Context;
 
@@ -1041,7 +1041,7 @@ BugCheckBugEFCriticalProcessDied(
         switch (Code) {
         case 0x0: {
             PEPROCESS   EProcess = (PEPROCESS)Parameter1;
-            PCHAR       Name = ProcessGetImageFileName(EProcess);
+            PSTR        Name = ProcessGetImageFileName(EProcess);
 
             if (Name == NULL)
                 Name = "(unknown)";
@@ -1079,7 +1079,7 @@ BugCheckBugEFCriticalProcessDied(
 
 struct _BUG_CODE_ENTRY {
     ULONG       Code;
-    const CHAR  *Name;
+    PCSTR       Name;
     VOID        (*Handler)(ULONG_PTR, ULONG_PTR, ULONG_PTR, ULONG_PTR);
 };
 
diff --git a/src/xen/config.c b/src/xen/config.c
index 45d66c6..c170d3a 100644
--- a/src/xen/config.c
+++ b/src/xen/config.c
@@ -56,15 +56,15 @@
 XEN_API
 NTSTATUS
 ConfigGetActive(
-    _In_ const CHAR *Key,
-    _Out_ PCHAR     *Value
+    _In_ PCSTR              Key,
+    _Outptr_result_z_ PSTR  *Value
     )
 {
-    HANDLE          ActiveKey;
-    CHAR            Name[MAXNAMELEN];
-    PANSI_STRING    Ansi;
-    ULONG           Length;
-    NTSTATUS        status;
+    HANDLE                  ActiveKey;
+    CHAR                    Name[MAXNAMELEN];
+    PANSI_STRING            Ansi;
+    ULONG                   Length;
+    NTSTATUS                status;
 
     Trace("====>\n");
 
@@ -126,13 +126,13 @@ fail1:
 
 static FORCEINLINE BOOLEAN
 __ConfigIsDeviceLegacy(
-    _In_ PCHAR  DeviceID
+    _In_ PSTR   DeviceID
     )
 {
     UNREFERENCED_PARAMETER(DeviceID);
 
 #ifdef VENDOR_DEVICE_ID_STR
-    const CHAR  *VendorDeviceID = "PCI\\VEN_5853&DEV_" VENDOR_DEVICE_ID_STR;
+    PCSTR       VendorDeviceID = "PCI\\VEN_5853&DEV_" VENDOR_DEVICE_ID_STR;
 
     return _strnicmp(DeviceID, VendorDeviceID, strlen(VendorDeviceID)) != 0;
 #endif
@@ -152,7 +152,7 @@ __ConfigIsVendorDevicePresent(
     HANDLE      DeviceKey;
     BOOLEAN     Found;
     NTSTATUS    status;
-    const CHAR  *VendorDeviceID = "PCI\\VEN_5853&DEV_" VENDOR_DEVICE_ID_STR "&SUBSYS_C0005853&REV_01";
+    PCSTR       VendorDeviceID = "PCI\\VEN_5853&DEV_" VENDOR_DEVICE_ID_STR "&SUBSYS_C0005853&REV_01";
 
     status = RegistryOpenSubKey(NULL,
                                 ENUM_PATH,
@@ -164,7 +164,7 @@ __ConfigIsVendorDevicePresent(
     Found = FALSE;
 
     status = RegistryOpenSubKey(EnumKey,
-                                (PCHAR)VendorDeviceID,
+                                (PSTR)VendorDeviceID,
                                 KEY_READ,
                                 &DeviceKey);
     if (!NT_SUCCESS(status))
@@ -188,9 +188,9 @@ fail1:
 XEN_API
 NTSTATUS
 ConfigSetActive(
-    _In_ PCHAR  DeviceID,
-    _In_ PCHAR  InstanceID,
-    _In_ PCHAR  LocationInformation
+    _In_ PSTR   DeviceID,
+    _In_ PSTR   InstanceID,
+    _In_ PSTR   LocationInformation
     )
 {
     HANDLE      ActiveKey;
@@ -273,15 +273,15 @@ fail1:
 XEN_API
 NTSTATUS
 ConfigUpdateActive(
-    _In_ PCHAR  DeviceID,
-    _In_ PCHAR  InstanceID,
-    _In_ PCHAR  LocationInformation
+    _In_ PSTR   DeviceID,
+    _In_ PSTR   InstanceID,
+    _In_ PSTR   LocationInformation
     )
 {
     HANDLE      ActiveKey;
     ANSI_STRING Ansi[2];
-    PCHAR       ActiveInstanceID;
-    PCHAR       ActiveLocationInformation;
+    PSTR        ActiveInstanceID;
+    PSTR        ActiveLocationInformation;
     NTSTATUS    status;
 
     Trace("====>\n");
@@ -411,7 +411,7 @@ XEN_API
 NTSTATUS
 ConfigRequestReboot(
     _In_ HANDLE     ParametersKey,
-    _In_ PCHAR      Module
+    _In_ PSTR       Module
     )
 {
     PANSI_STRING    Ansi;
@@ -489,7 +489,7 @@ fail1:
 XEN_API
 NTSTATUS
 ConfigQuerySystemStartOption(
-    _In_ PCHAR          Key,
+    _In_ PSTR           Key,
     _Out_ PANSI_STRING  *Option
     )
 {
diff --git a/src/xen/driver.c b/src/xen/driver.c
index 107dc65..48fe169 100644
--- a/src/xen/driver.c
+++ b/src/xen/driver.c
@@ -164,7 +164,7 @@ __DriverGetMemoryKey(
 
 static FORCEINLINE NTSTATUS
 __DriverSetPfnArray(
-    _In_ PCHAR      Name,
+    _In_ PSTR       Name,
     _In_ ULONG      Count,
     _In_ PFN_NUMBER PfnArray[]
     )
@@ -224,7 +224,7 @@ fail1:
 
 static FORCEINLINE NTSTATUS
 __DriverAllocatePfnArray(
-    _In_ PCHAR          Name,
+    _In_ PSTR           Name,
     _In_ ULONG          Count,
     _Out_ PFN_NUMBER    PfnArray[]
     )
@@ -289,7 +289,7 @@ fail1:
 
 static FORCEINLINE NTSTATUS
 __DriverGetPfnArray(
-    _In_ PCHAR                      Name,
+    _In_ PSTR                       Name,
     _In_ ULONG                      Count,
     _Out_writes_(Count) PFN_NUMBER  PfnArray[]
     )
@@ -341,7 +341,7 @@ fail1:
 
 PMDL
 DriverGetNamedPages(
-    _In_ PCHAR  Name,
+    _In_ PSTR   Name,
     _In_ ULONG  Count
     )
 {
@@ -425,7 +425,7 @@ DriverPutNamedPages(
 XEN_API
 NTSTATUS
 XenTouch(
-    _In_ const CHAR *Name,
+    _In_ PCSTR      Name,
     _In_ ULONG      MajorVersion,
     _In_ ULONG      MinorVersion,
     _In_ ULONG      MicroVersion,
@@ -480,7 +480,7 @@ fail1:
 static VOID
 DriverOutputBuffer(
     _In_ PVOID  Argument,
-    _In_ PCHAR  Buffer,
+    _In_ PSTR   Buffer,
     _In_ ULONG  Length
     )
 {
diff --git a/src/xen/driver.h b/src/xen/driver.h
index 6806886..21df779 100644
--- a/src/xen/driver.h
+++ b/src/xen/driver.h
@@ -45,7 +45,7 @@ DriverGetUnplugKey(
 
 extern PMDL
 DriverGetNamedPages(
-    _In_ PCHAR  Name,
+    _In_ PSTR   Name,
     _In_ ULONG  Count
     );
 
diff --git a/src/xen/filters.c b/src/xen/filters.c
index b643404..46324ea 100644
--- a/src/xen/filters.c
+++ b/src/xen/filters.c
@@ -67,9 +67,9 @@ __FiltersFree(
 
 static NTSTATUS
 FiltersInstallClass(
-    _In_ const CHAR *ClassName,
+    _In_ PCSTR      ClassName,
     _In_ const GUID *ClassGuid,
-    _In_ const CHAR *DriverName
+    _In_ PCSTR      DriverName
     )
 {
     HANDLE          ClassKey;
@@ -196,9 +196,9 @@ fail1:
 
 static NTSTATUS
 FiltersUninstallClass(
-    _In_ const CHAR *ClassName,
+    _In_ PCSTR      ClassName,
     _In_ const GUID *ClassGuid,
-    _In_ const CHAR *DriverName
+    _In_ PCSTR      DriverName
     )
 {
     HANDLE          ClassKey;
diff --git a/src/xen/log.c b/src/xen/log.c
index c81c834..5687801 100644
--- a/src/xen/log.c
+++ b/src/xen/log.c
@@ -52,7 +52,7 @@ typedef struct _LOG_SLOT {
 
 struct _LOG_DISPOSITION {
     LOG_LEVEL   Mask;
-    VOID        (*Function)(PVOID, PCHAR, ULONG);
+    VOID        (*Function)(PVOID, PSTR, ULONG);
     PVOID       Argument;
 };
 
@@ -121,9 +121,9 @@ __LogPut(
     Slot->Buffer[Slot->Offset++] = Character;
 }
 
-static PCHAR
+static PSTR
 LogFormatNumber(
-    _In_ PCHAR      Buffer,
+    _In_ PSTR       Buffer,
     _In_ ULONGLONG  Value,
     _In_ UCHAR      Base,
     _In_ BOOLEAN    UpperCase
@@ -185,7 +185,7 @@ static VOID
 LogWriteSlot(
     _In_ PLOG_SLOT  Slot,
     _In_ LONG       Count,
-    _In_ const CHAR *Format,
+    _In_ PCSTR      Format,
     _In_ va_list    Arguments
     )
 {
@@ -298,7 +298,7 @@ LogWriteSlot(
         }
         case 's': {
             if (Wide) {
-                PWCHAR  Value = va_arg(Arguments, PWCHAR);
+                PWSTR   Value = va_arg(Arguments, PWSTR);
                 ULONG   Length;
                 ULONG   Index;
 
@@ -324,7 +324,7 @@ LogWriteSlot(
                     }
                 }
             } else {
-                PCHAR   Value = va_arg(Arguments, PCHAR);
+                PSTR    Value = va_arg(Arguments, PSTR);
                 ULONG   Length;
                 ULONG   Index;
 
@@ -356,7 +356,7 @@ LogWriteSlot(
         case 'Z': {
             if (Wide) {
                 PUNICODE_STRING Value = va_arg(Arguments, PUNICODE_STRING);
-                PWCHAR          Buffer;
+                PWSTR           Buffer;
                 ULONG           Length;
                 ULONG           Index;
 
@@ -386,7 +386,7 @@ LogWriteSlot(
                 }
             } else {
                 PANSI_STRING Value = va_arg(Arguments, PANSI_STRING);
-                PCHAR        Buffer;
+                PSTR         Buffer;
                 ULONG        Length;
                 ULONG        Index;
 
@@ -434,7 +434,7 @@ VOID
 LogCchVPrintf(
     _In_ LOG_LEVEL  Level,
     _In_ ULONG      Count,
-    _In_ const CHAR *Format,
+    _In_ PCSTR      Format,
     _In_ va_list    Arguments
     )
 {
@@ -464,7 +464,7 @@ XEN_API
 VOID
 LogVPrintf(
     _In_ LOG_LEVEL  Level,
-    _In_ const CHAR *Format,
+    _In_ PCSTR      Format,
     _In_ va_list    Arguments
     )
 {
@@ -476,7 +476,7 @@ VOID
 LogCchPrintf(
     _In_ LOG_LEVEL  Level,
     _In_ ULONG      Count,
-    _In_ const CHAR *Format,
+    _In_ PCSTR      Format,
     ...
     )
 {
@@ -491,7 +491,7 @@ XEN_API
 VOID
 LogPrintf(
     _In_ LOG_LEVEL  Level,
-    _In_ const CHAR *Format,
+    _In_ PCSTR      Format,
     ...
     )
 {
@@ -603,7 +603,7 @@ LogTeardown(
 NTSTATUS
 LogAddDisposition(
     _In_ LOG_LEVEL          Mask,
-    _In_ VOID               (*Function)(PVOID, PCHAR, ULONG),
+    _In_ VOID               (*Function)(PVOID, PSTR, ULONG),
     _In_opt_ PVOID          Argument,
     _Out_ PLOG_DISPOSITION  *Disposition
     )
@@ -682,7 +682,7 @@ __LogDbgPrintCallbackEnable(
 {
     CHAR            Key[] = "XEN:DBG_PRINT=";
     PANSI_STRING    Option;
-    PCHAR           Value;
+    PSTR            Value;
     BOOLEAN         Enable;
     NTSTATUS        status;
 
@@ -721,7 +721,7 @@ LogResume(
 }
 
 typedef struct _XEN_LOG_LEVEL_NAME {
-    const CHAR      *Name;
+    PCSTR           Name;
     LOG_LEVEL       LogLevel;
 } XEN_LOG_LEVEL_NAME, *PXEN_LOG_LEVEL_NAME;
 
@@ -737,7 +737,7 @@ XEN_API
 NTSTATUS
 LogReadLogLevel(
     _In_ HANDLE         Key,
-    _In_ PCHAR          Name,
+    _In_ PSTR           Name,
     _Out_ PLOG_LEVEL    LogLevel
     )
 {
diff --git a/src/xen/module.c b/src/xen/module.c
index 6c804bc..35a16f4 100644
--- a/src/xen/module.c
+++ b/src/xen/module.c
@@ -115,7 +115,7 @@ ModuleSearchBackwards(
 static NTSTATUS
 ModuleAdd(
     _In_ PMODULE_CONTEXT    Context,
-    _In_ PCHAR              Name,
+    _In_ PSTR               Name,
     _In_ ULONG_PTR          Start,
     _In_ ULONG_PTR          Size
     )
@@ -274,8 +274,8 @@ ModuleLoad(
 {
     PMODULE_CONTEXT     Context = &ModuleContext;
     ANSI_STRING         Ansi;
-    PCHAR               Buffer;
-    PCHAR               Name;
+    PSTR                Buffer;
+    PSTR                Name;
     NTSTATUS            status;
 
     UNREFERENCED_PARAMETER(ProcessId);
@@ -297,7 +297,7 @@ ModuleLoad(
 
     RtlCopyMemory(Buffer, Ansi.Buffer, Ansi.Length);
 
-    Name = strrchr((const CHAR *)Buffer, '\\');
+    Name = strrchr((PCSTR)Buffer, '\\');
     Name = (Name == NULL) ? Buffer : (Name + 1);
 
     status = ModuleAdd(Context,
@@ -330,14 +330,14 @@ fail1:
 XEN_API
 VOID
 ModuleLookup(
-    _In_ ULONG_PTR  Address,
-    _Out_ PCHAR     *Name,
-    _Out_ PULONG_PTR Offset
+    _In_ ULONG_PTR          Address,
+    _Outptr_result_z_ PSTR  *Name,
+    _Out_ PULONG_PTR        Offset
     )
 {
-    PMODULE_CONTEXT Context = &ModuleContext;
-    PLIST_ENTRY     ListEntry;
-    KIRQL           Irql;
+    PMODULE_CONTEXT         Context = &ModuleContext;
+    PLIST_ENTRY             ListEntry;
+    KIRQL                   Irql;
 
     *Name = NULL;
     *Offset = 0;
@@ -448,10 +448,10 @@ again:
     Context->Cursor = &Context->List;
 
     for (Index = 0; Index < Count; Index++) {
-        PCHAR   Name;
+        PSTR    Name;
 
-        Name = strrchr((const CHAR *)QueryInfo[Index].FullPathName, '\\');
-        Name = (Name == NULL) ? (PCHAR)QueryInfo[Index].FullPathName : (Name + 1);
+        Name = strrchr((PCSTR)QueryInfo[Index].FullPathName, '\\');
+        Name = (Name == NULL) ? (PSTR)QueryInfo[Index].FullPathName : (Name + 1);
 
         status = ModuleAdd(Context,
                            Name,
diff --git a/src/xen/process.c b/src/xen/process.c
index 8e83188..503c832 100644
--- a/src/xen/process.c
+++ b/src/xen/process.c
@@ -40,7 +40,7 @@
 #include "dbg_print.h"
 #include "assert.h"
 
-typedef PCHAR (*GET_PROCESS_IMAGE_NAME)(PEPROCESS Process);
+typedef PSTR (*GET_PROCESS_IMAGE_NAME)(PEPROCESS Process);
 
 typedef struct _PROCESS_CONTEXT {
     LONG                    References;
@@ -77,7 +77,7 @@ ProcessNotify(
     KeLowerIrql(Irql);
 }
 
-PCHAR
+PSTR
 ProcessGetImageFileName(
     _In_ PEPROCESS  Process
     )
diff --git a/src/xen/process.h b/src/xen/process.h
index 9ae2ec9..880acd4 100644
--- a/src/xen/process.h
+++ b/src/xen/process.h
@@ -44,7 +44,7 @@ ProcessTeardown(
     VOID
     );
 
-extern PCHAR
+extern PSTR
 ProcessGetImageFileName(
     _In_ PEPROCESS  Process
     );
diff --git a/src/xen/system.c b/src/xen/system.c
index b813326..6618b67 100644
--- a/src/xen/system.c
+++ b/src/xen/system.c
@@ -99,7 +99,7 @@ __SystemFree(
     __FreePoolWithTag(Buffer, XEN_SYSTEM_TAG);
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 __PlatformIdName(
     _In_ ULONG  PlatformId
     )
@@ -120,7 +120,7 @@ __PlatformIdName(
 #undef  PLATFORM_ID_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 __SuiteName(
     _In_ ULONG SuiteBit
     )
@@ -153,7 +153,7 @@ __SuiteName(
 #undef  SUITE_NAME
 }
 
-static FORCEINLINE const CHAR *
+static FORCEINLINE PCSTR
 __ProductTypeName(
     _In_ UCHAR  ProductType
     )
@@ -1071,7 +1071,7 @@ fail1:
 
 static NTSTATUS
 SystemRegisterCallback(
-    _In_ PWCHAR             Name,
+    _In_ PWSTR              Name,
     _In_ PCALLBACK_FUNCTION Function,
     _In_opt_ PVOID          Argument,
     _Out_ PVOID             *Handle
diff --git a/src/xen/unplug.c b/src/xen/unplug.c
index bdf5843..dbd9a2e 100644
--- a/src/xen/unplug.c
+++ b/src/xen/unplug.c
@@ -50,7 +50,7 @@
 #define UNPLUG_TAG  'LPNU'
 
 typedef struct _UNPLUG_DATA {
-    PCHAR       Name;
+    PSTR        Name;
     BOOLEAN     Found;
 } UNPLUG_DATA, *PUNPLUG_DATA;
 
@@ -88,7 +88,7 @@ UnplugSetBootEmulated(
     PUNPLUG_CONTEXT Context = &UnplugContext;
     CHAR            Key[] = "XEN:BOOT_EMULATED=";
     PANSI_STRING    Option;
-    PCHAR           Value;
+    PSTR            Value;
     NTSTATUS        status;
 
     status = RegistryQuerySystemStartOption(Key, &Option);
@@ -210,7 +210,7 @@ UnplugCheckEnumKeyCallback(
 
 static NTSTATUS
 UnplugCheckEnumKey(
-    _In_ PCHAR          EnumName,
+    _In_ PSTR           EnumName,
     _Out_ PULONG        Value
     )
 {
@@ -266,8 +266,8 @@ UnplugSetRequest(
 {
     PUNPLUG_CONTEXT     Context = &UnplugContext;
     HANDLE              UnplugKey;
-    PCHAR               ValueName;
-    PCHAR               EnumName;
+    PSTR                ValueName;
+    PSTR                EnumName;
     ULONG               Value;
     KIRQL               Irql;
     NTSTATUS            status;
@@ -321,7 +321,7 @@ UnplugIncrementValue(
     )
 {
     HANDLE              UnplugKey;
-    PCHAR               ValueName;
+    PSTR                ValueName;
     ULONG               Value;
     NTSTATUS            status;
 
@@ -372,7 +372,7 @@ UnplugDecrementValue(
     )
 {
     HANDLE              UnplugKey;
-    PCHAR               ValueName;
+    PSTR                ValueName;
     LONG                Value;
     NTSTATUS            status;
 
diff --git a/src/xen/xen_version.c b/src/xen/xen_version.c
index 4cff07f..0043752 100644
--- a/src/xen/xen_version.c
+++ b/src/xen/xen_version.c
@@ -81,7 +81,7 @@ _Check_return_
 XEN_API
 NTSTATUS
 XenVersionExtra(
-    _Out_writes_(XEN_EXTRAVERSION_LEN) PCHAR    Extra
+    _Out_writes_z_(XEN_EXTRAVERSION_LEN) PSTR   Extra
     )
 {
     xen_extraversion_t                          op;
diff --git a/src/xenbus/balloon.c b/src/xenbus/balloon.c
index 98c2f79..7afd387 100644
--- a/src/xenbus/balloon.c
+++ b/src/xenbus/balloon.c
@@ -750,7 +750,7 @@ BalloonGetFISTEntries(
     _In_ PXENBUS_BALLOON_CONTEXT    Context
     )
 {
-    PCHAR                           Buffer;
+    PSTR                            Buffer;
     NTSTATUS                        status;
 
     status = XENBUS_STORE(Read,
@@ -792,7 +792,7 @@ BalloonGetFISTEntries(
         Warning("deflation disallowed\n");
 }
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __BalloonStatus(
     _In_ NTSTATUS   status
     )
diff --git a/src/xenbus/cache.c b/src/xenbus/cache.c
index 1af0ea8..24fc029 100644
--- a/src/xenbus/cache.c
+++ b/src/xenbus/cache.c
@@ -824,7 +824,7 @@ __CacheFlushMagazines(
 static NTSTATUS
 CacheCreate(
     _In_ PINTERFACE         Interface,
-    _In_ const CHAR         *Name,
+    _In_ PCSTR              Name,
     _In_ ULONG              Size,
     _In_ ULONG              Reservation,
     _In_ ULONG              Cap,
@@ -946,7 +946,7 @@ fail1:
 static NTSTATUS
 CacheCreateVersion1(
     _In_ PINTERFACE         Interface,
-    _In_ const CHAR         *Name,
+    _In_ PCSTR              Name,
     _In_ ULONG              Size,
     _In_ ULONG              Reservation,
     _In_ NTSTATUS           (*Ctor)(PVOID, PVOID),
diff --git a/src/xenbus/console.c b/src/xenbus/console.c
index 1c2af75..24f9d27 100644
--- a/src/xenbus/console.c
+++ b/src/xenbus/console.c
@@ -118,7 +118,7 @@ ConsoleOutAvailable(
 static ULONG
 ConsoleCopyToOut(
     _In_ PXENBUS_CONSOLE_CONTEXT    Context,
-    _In_ PCHAR                      Data,
+    _In_ PSTR                       Data,
     _In_ ULONG                      Length
     )
 {
@@ -193,7 +193,7 @@ ConsoleInAvailable(
 static ULONG
 ConsoleCopyFromIn(
     _In_ PXENBUS_CONSOLE_CONTEXT    Context,
-    _In_ PCHAR                      Data,
+    _In_ PSTR                       Data,
     _In_ ULONG                      Length
     )
 {
@@ -486,7 +486,7 @@ ConsoleDebugCallback(
              ListEntry != &(Context->WakeupList);
              ListEntry = ListEntry->Flink) {
             PXENBUS_CONSOLE_WAKEUP  Wakeup;
-            PCHAR                   Name;
+            PSTR                    Name;
             ULONG_PTR               Offset;
 
             Wakeup = CONTAINING_RECORD(ListEntry,
@@ -530,7 +530,7 @@ ConsoleCanRead(
 static ULONG
 ConsoleRead(
     _In_ PINTERFACE         Interface,
-    _In_ PCHAR              Data,
+    _In_ PSTR               Data,
     _In_ ULONG              Length
     )
 {
@@ -579,7 +579,7 @@ ConsoleCanWrite(
 static ULONG
 ConsoleWrite(
     _In_ PINTERFACE         Interface,
-    _In_ PCHAR              Data,
+    _In_ PSTR               Data,
     _In_ ULONG              Length
     )
 {
diff --git a/src/xenbus/debug.c b/src/xenbus/debug.c
index 2440afc..a0bb27d 100644
--- a/src/xenbus/debug.c
+++ b/src/xenbus/debug.c
@@ -59,7 +59,7 @@ struct _XENBUS_DEBUG_CONTEXT {
     LONG                        References;
     KBUGCHECK_CALLBACK_RECORD   CallbackRecord;
     LIST_ENTRY                  CallbackList;
-    const CHAR                  *CallbackPrefix;
+    PCSTR                       CallbackPrefix;
     HIGH_LOCK                   CallbackLock;
 };
 
@@ -92,7 +92,7 @@ RtlCaptureStackBackTrace(
 static NTSTATUS
 DebugRegister(
     _In_ PINTERFACE                     Interface,
-    _In_ PCHAR                          Prefix,
+    _In_ PSTR                           Prefix,
     _In_ XENBUS_DEBUG_FUNCTION          Function,
     _In_opt_ PVOID                      Argument,
     _Out_opt_ PXENBUS_DEBUG_CALLBACK    *Callback
@@ -132,7 +132,7 @@ fail1:
 static VOID
 DebugPrintf(
     _In_ PINTERFACE             Interface,
-    _In_ const CHAR             *Format,
+    _In_ PCSTR                  Format,
     ...
     )
 {
@@ -175,7 +175,7 @@ DebugCallback(
     _In_ BOOLEAN                Crashing
     )
 {
-    PCHAR                       Name;
+    PSTR                        Name;
     ULONG_PTR                   Offset;
 
     ModuleLookup((ULONG_PTR)Callback->Function, &Name, &Offset);
diff --git a/src/xenbus/evtchn.c b/src/xenbus/evtchn.c
index bb071d4..8927938 100644
--- a/src/xenbus/evtchn.c
+++ b/src/xenbus/evtchn.c
@@ -1465,7 +1465,7 @@ EvtchnDebugCallback(
              ListEntry != &Context->List;
              ListEntry = ListEntry->Flink) {
             PXENBUS_EVTCHN_CHANNEL  Channel;
-            PCHAR                   Name;
+            PSTR                    Name;
             ULONG_PTR               Offset;
 
             Channel = CONTAINING_RECORD(ListEntry, XENBUS_EVTCHN_CHANNEL, ListEntry);
diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index d2a8869..c673ae0 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -521,7 +521,7 @@ fail1:
     return status;
 }
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __FdoGetVendorName(
     _In_ PXENBUS_FDO    Fdo
     )
@@ -529,7 +529,7 @@ __FdoGetVendorName(
     return Fdo->VendorName;
 }
 
-PCHAR
+PSTR
 FdoGetVendorName(
     _In_ PXENBUS_FDO    Fdo
     )
@@ -552,7 +552,7 @@ __FdoSetName(
     ASSERT(NT_SUCCESS(status));
 }
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __FdoGetName(
     _In_ PXENBUS_FDO    Fdo
     )
@@ -562,7 +562,7 @@ __FdoGetName(
     return Dx->Name;
 }
 
-PCHAR
+PSTR
 FdoGetName(
     _In_ PXENBUS_FDO    Fdo
     )
@@ -575,14 +575,14 @@ static NTSTATUS
 FdoQueryId(
     _In_ PXENBUS_FDO        Fdo,
     _In_ BUS_QUERY_ID_TYPE  Type,
-    _Out_ PCHAR             *Id
+    _Outptr_result_z_ PSTR  *Id
     )
 {
     KEVENT                  Event;
     IO_STATUS_BLOCK         StatusBlock;
     PIRP                    Irp;
     PIO_STACK_LOCATION      StackLocation;
-    PWCHAR                  Buffer;
+    PWSTR                   Buffer;
     ULONG                   Length;
     NTSTATUS                status;
 
@@ -623,7 +623,7 @@ FdoQueryId(
     if (!NT_SUCCESS(status))
         goto fail2;
 
-    Buffer = (PWCHAR)StatusBlock.Information;
+    Buffer = (PWSTR)StatusBlock.Information;
     Length = (ULONG)(wcslen(Buffer) + 1) * sizeof (CHAR);
 
     *Id = __AllocatePoolWithTag(PagedPool, Length, 'SUB');
@@ -658,14 +658,14 @@ static NTSTATUS
 FdoQueryDeviceText(
     _In_ PXENBUS_FDO        Fdo,
     _In_ DEVICE_TEXT_TYPE   Type,
-    _Out_ PCHAR             *Text
+    _Outptr_result_z_ PSTR  *Text
     )
 {
     KEVENT                  Event;
     IO_STATUS_BLOCK         StatusBlock;
     PIRP                    Irp;
     PIO_STACK_LOCATION      StackLocation;
-    PWCHAR                  Buffer;
+    PWSTR                   Buffer;
     ULONG                   Length;
     NTSTATUS                status;
 
@@ -706,7 +706,7 @@ FdoQueryDeviceText(
     if (!NT_SUCCESS(status))
         goto fail2;
 
-    Buffer = (PWCHAR)StatusBlock.Information;
+    Buffer = (PWSTR)StatusBlock.Information;
     Length = (ULONG)(wcslen(Buffer) + 1) * sizeof (CHAR);
 
     *Text = __AllocatePoolWithTag(PagedPool, Length, 'SUB');
@@ -741,10 +741,10 @@ FdoSetActive(
     _In_ PXENBUS_FDO    Fdo
     )
 {
-    PCHAR               DeviceID;
-    PCHAR               InstanceID;
-    PCHAR               ActiveDeviceID;
-    PCHAR               LocationInformation;
+    PSTR                DeviceID;
+    PSTR                InstanceID;
+    PSTR                ActiveDeviceID;
+    PSTR                LocationInformation;
     NTSTATUS            status;
 
     status = FdoQueryId(Fdo,
@@ -1110,7 +1110,7 @@ FdoEnumerate(
         PXENBUS_PDO     Pdo = Dx->Pdo;
 
         if (!PdoIsMissing(Pdo) && PdoGetDevicePnpState(Pdo) != Deleted) {
-            PCHAR           Name;
+            PSTR            Name;
             BOOLEAN         Missing;
 
             Name = PdoGetName(Pdo);
@@ -1171,7 +1171,7 @@ done:
 
 static PANSI_STRING
 FdoMultiSzToUpcaseAnsi(
-    _In_ PCHAR      Buffer
+    _In_ PSTR       Buffer
     )
 {
     PANSI_STRING    Ansi;
@@ -1355,7 +1355,7 @@ FdoScan(
     ParametersKey = DriverGetParametersKey();
 
     for (;;) {
-        PCHAR                   Buffer;
+        PSTR                    Buffer;
         PANSI_STRING            StoreClasses;
         PANSI_STRING            SyntheticClasses;
         PANSI_STRING            SupportedClasses;
@@ -1529,7 +1529,7 @@ FdoSuspend(
     Event = ThreadGetEvent(Self);
 
     for (;;) {
-        PCHAR       Buffer;
+        PSTR        Buffer;
         BOOLEAN     Suspend;
         NTSTATUS    status;
 
@@ -1679,7 +1679,7 @@ FdoBalloon(
     Active = FALSE;
 
     for (;;) {
-        PCHAR                   Buffer;
+        PSTR                    Buffer;
         ULONGLONG               Target;
         ULONGLONG               Size;
 
@@ -2442,13 +2442,13 @@ FdoDestroyInterrupt(
 static FORCEINLINE BOOLEAN
 __FdoMatchDistribution(
     _In_ PXENBUS_FDO    Fdo,
-    _In_ PCHAR          Buffer
+    _In_ PSTR           Buffer
     )
 {
-    PCHAR               Vendor;
-    PCHAR               Product;
-    PCHAR               Context;
-    const CHAR          *Text;
+    PSTR                Vendor;
+    PSTR                Product;
+    PSTR                Context;
+    PCSTR               Text;
     BOOLEAN             Match;
     ULONG               Index;
     NTSTATUS            status;
@@ -2504,7 +2504,7 @@ FdoClearDistribution(
     _In_ PXENBUS_FDO    Fdo
     )
 {
-    PCHAR               Buffer;
+    PSTR                Buffer;
     PANSI_STRING        Distributions;
     ULONG               Index;
     NTSTATUS            status;
@@ -2570,14 +2570,14 @@ FdoSetDistribution(
     ULONG               Index;
     CHAR                Distribution[MAXNAMELEN];
     CHAR                Vendor[MAXNAMELEN];
-    const CHAR          *Product;
+    PCSTR               Product;
     NTSTATUS            status;
 
     Trace("====>\n");
 
     Index = 0;
     while (Index <= MAXIMUM_INDEX) {
-        PCHAR   Buffer;
+        PSTR    Buffer;
 
         status = RtlStringCbPrintfA(Distribution,
                                     MAXNAMELEN,
@@ -2663,13 +2663,13 @@ CHAR FdoOutBuffer[FDO_OUT_BUFFER_SIZE];
 static VOID
 FdoOutputBuffer(
     _In_ PVOID  Argument,
-    _In_ PCHAR  Buffer,
+    _In_ PSTR   Buffer,
     _In_ ULONG  Length
     )
 {
     PXENBUS_FDO Fdo = Argument;
     ULONG       Index;
-    PCHAR       Cursor;
+    PSTR        Cursor;
 
     Cursor = FdoOutBuffer;
     for (Index = 0; Index < Length; Index++) {
@@ -5632,7 +5632,7 @@ FdoBalloonInitialize(
 {
     CHAR                Key[] = "XEN:BALLOON=";
     PANSI_STRING        Option;
-    PCHAR               Value;
+    PSTR                Value;
     BOOLEAN             Enabled;
     NTSTATUS            status;
 
diff --git a/src/xenbus/fdo.h b/src/xenbus/fdo.h
index ae4b86d..e506787 100644
--- a/src/xenbus/fdo.h
+++ b/src/xenbus/fdo.h
@@ -122,12 +122,12 @@ FdoGetBusData(
     _In_ ULONG          Length
     );
 
-extern PCHAR
+extern PSTR
 FdoGetVendorName(
     _In_ PXENBUS_FDO    Fdo
     );
 
-extern PCHAR
+extern PSTR
 FdoGetName(
     _In_ PXENBUS_FDO    Fdo
     );
diff --git a/src/xenbus/gnttab.c b/src/xenbus/gnttab.c
index 550b8e0..1ee0cd1 100644
--- a/src/xenbus/gnttab.c
+++ b/src/xenbus/gnttab.c
@@ -367,7 +367,7 @@ GnttabReleaseLock(
 static NTSTATUS
 GnttabCreateCache(
     _In_ PINTERFACE             Interface,
-    _In_ const CHAR             *Name,
+    _In_ PCSTR                  Name,
     _In_ ULONG                  Reservation,
     _In_ ULONG                  Cap,
     _In_ VOID                   (*AcquireLock)(PVOID),
@@ -446,7 +446,7 @@ fail1:
 static NTSTATUS
 GnttabCreateCacheVersion1(
     _In_ PINTERFACE             Interface,
-    _In_ const CHAR             *Name,
+    _In_ PCSTR                  Name,
     _In_ ULONG                  Reservation,
     _In_ VOID                   (*AcquireLock)(PVOID),
     _In_ VOID                   (*ReleaseLock)(PVOID),
diff --git a/src/xenbus/pdo.c b/src/xenbus/pdo.c
index a504652..df07973 100644
--- a/src/xenbus/pdo.c
+++ b/src/xenbus/pdo.c
@@ -65,7 +65,7 @@ struct _XENBUS_PDO {
 
     PXENBUS_FDO                 Fdo;
     BOOLEAN                     Missing;
-    const CHAR                  *Reason;
+    PCSTR                       Reason;
 
     BOOLEAN                     Removable;
     BOOLEAN                     Ejectable;
@@ -191,7 +191,7 @@ __PdoGetSystemPowerState(
 static FORCEINLINE VOID
 __PdoSetMissing(
     _In_ PXENBUS_PDO    Pdo,
-    _In_ const CHAR     *Reason
+    _In_ PCSTR          Reason
     )
 {
     Pdo->Reason = Reason;
@@ -201,7 +201,7 @@ __PdoSetMissing(
 VOID
 PdoSetMissing(
     _In_ PXENBUS_PDO    Pdo,
-    _In_ const CHAR     *Reason
+    _In_ PCSTR          Reason
     )
 {
     __PdoSetMissing(Pdo, Reason);
@@ -239,7 +239,7 @@ __PdoSetName(
     ASSERT(NT_SUCCESS(status));
 }
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __PdoGetName(
     _In_ PXENBUS_PDO    Pdo
     )
@@ -249,7 +249,7 @@ __PdoGetName(
     return Dx->Name;
 }
 
-PCHAR
+PSTR
 PdoGetName(
     _In_ PXENBUS_PDO    Pdo
     )
@@ -491,7 +491,7 @@ PdoGetDeviceObject(
     return __PdoGetDeviceObject(Pdo);
 }
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __PdoGetVendorName(
     _In_ PXENBUS_PDO    Pdo
     )
@@ -1038,7 +1038,7 @@ DEFINE_PDO_QUERY_INTERFACE(Console)
 
 struct _INTERFACE_ENTRY {
     const GUID  *Guid;
-    const CHAR  *Name;
+    PCSTR       Name;
     NTSTATUS    (*Query)(PXENBUS_PDO, PIRP);
 };
 
@@ -1250,7 +1250,7 @@ PdoQueryDeviceText(
     )
 {
     PIO_STACK_LOCATION  StackLocation;
-    PWCHAR              Buffer;
+    PWSTR               Buffer;
     UNICODE_STRING      Text;
     NTSTATUS            status;
 
@@ -1361,7 +1361,7 @@ PdoQueryId(
     )
 {
     PIO_STACK_LOCATION  StackLocation;
-    PWCHAR              Buffer;
+    PWSTR               Buffer;
     UNICODE_STRING      Id;
     ULONG               Type;
     NTSTATUS            status;
diff --git a/src/xenbus/pdo.h b/src/xenbus/pdo.h
index 1de01f8..af59955 100644
--- a/src/xenbus/pdo.h
+++ b/src/xenbus/pdo.h
@@ -57,10 +57,10 @@ PdoIsMissing(
 extern VOID
 PdoSetMissing(
     _In_ PXENBUS_PDO    Pdo,
-    _In_ const CHAR     *Reason
+    _In_ PCSTR          Reason
     );
 
-extern PCHAR
+extern PSTR
 PdoGetName(
     _In_ PXENBUS_PDO    Pdo
     );
diff --git a/src/xenbus/range_set.c b/src/xenbus/range_set.c
index 13df2e5..354b3ca 100644
--- a/src/xenbus/range_set.c
+++ b/src/xenbus/range_set.c
@@ -568,7 +568,7 @@ fail1:
 NTSTATUS
 RangeSetCreate(
     _In_ PINTERFACE             Interface,
-    _In_ const CHAR             *Name,
+    _In_ PCSTR                  Name,
     _Out_ PXENBUS_RANGE_SET     *RangeSet
     )
 {
diff --git a/src/xenbus/store.c b/src/xenbus/store.c
index 0a0ee94..9bdd590 100644
--- a/src/xenbus/store.c
+++ b/src/xenbus/store.c
@@ -68,7 +68,7 @@ struct _XENBUS_STORE_WATCH {
     ULONG       Magic;
     PVOID       Caller;
     USHORT      Id;
-    PCHAR       Path;
+    PSTR        Path;
     PKEVENT     Event;
     BOOLEAN     Active; // Must be tested at >= DISPATCH_LEVEL
 };
@@ -82,7 +82,7 @@ typedef enum _XENBUS_STORE_REQUEST_STATE {
 } XENBUS_STORE_REQUEST_STATE, *PXENBUS_STORE_REQUEST_STATE;
 
 typedef struct _XENBUS_STORE_SEGMENT {
-    PCHAR   Data;
+    PSTR    Data;
     ULONG   Offset;
     ULONG   Length;
 } XENBUS_STORE_SEGMENT, *PXENBUS_STORE_SEGMENT;
@@ -206,17 +206,17 @@ StorePrepareRequest(
     Request->Count = 0;
     Segment = &Request->Segment[Request->Count++];
 
-    Segment->Data = (PCHAR)&Request->Header;
+    Segment->Data = (PSTR)&Request->Header;
     Segment->Offset = 0;
     Segment->Length = sizeof (struct xsd_sockmsg);
 
     va_start(Arguments, Type);
     status = STATUS_UNSUCCESSFUL;
     for (;;) {
-        PCHAR   Data;
+        PSTR    Data;
         ULONG   Length;
 
-        Data = va_arg(Arguments, PCHAR);
+        Data = va_arg(Arguments, PSTR);
         Length = va_arg(Arguments, ULONG);
 
         if (Data == NULL) {
@@ -255,7 +255,7 @@ fail1:
 static ULONG
 StoreCopyToRing(
     _In_ PXENBUS_STORE_CONTEXT          Context,
-    _In_ PCHAR                          Data,
+    _In_ PSTR                           Data,
     _In_ ULONG                          Length
     )
 {
@@ -372,7 +372,7 @@ StoreSendRequests(
 static ULONG
 StoreCopyFromRing(
     _In_ PXENBUS_STORE_CONTEXT          Context,
-    _In_ PCHAR                          Data,
+    _In_ PSTR                           Data,
     _In_ ULONG                          Length
     )
 {
@@ -609,14 +609,14 @@ StoreNextWatchId(
 
 static NTSTATUS
 StoreParseWatchEvent(
-    _In_ PCHAR      Data,
-    _In_ ULONG      Length,
-    _Out_ PCHAR     *Path,
-    _Out_ PVOID     *Caller,
-    _Out_ PUSHORT   Id
+    _In_ PSTR               Data,
+    _In_ ULONG              Length,
+    _Outptr_result_z_ PSTR  *Path,
+    _Outptr_ PVOID          *Caller,
+    _Out_ PUSHORT           Id
     )
 {
-    PCHAR           End;
+    PSTR            End;
 
     *Path = Data;
     while (*Data != '\0' && Length != 0) {
@@ -682,7 +682,7 @@ StoreProcessWatchEvent(
     )
 {
     PXENBUS_STORE_RESPONSE      Response;
-    PCHAR                       Path;
+    PSTR                        Path;
     PVOID                       Caller;
     USHORT                      Id;
     PXENBUS_STORE_WATCH         Watch;
@@ -705,7 +705,7 @@ StoreProcessWatchEvent(
     Watch = StoreFindWatch(Context, Id);
 
     if (Watch == NULL) {
-        PCHAR       Name;
+        PSTR        Name;
         ULONG_PTR   Offset;
 
         ModuleLookup((ULONG_PTR)Caller, &Name, &Offset);
@@ -742,7 +742,7 @@ StoreResetResponse(
 
     Segment = &Response->Segment[XENBUS_STORE_RESPONSE_HEADER_SEGMENT];
 
-    Segment->Data = (PCHAR)&Response->Header;
+    Segment->Data = (PSTR)&Response->Header;
     Segment->Offset = 0;
     Segment->Length = sizeof (struct xsd_sockmsg);
 }
@@ -759,8 +759,8 @@ StoreCopyResponse(
     *Response = Context->Response;
 
     Segment = &Response->Segment[XENBUS_STORE_RESPONSE_HEADER_SEGMENT];
-    ASSERT3P(Segment->Data, ==, (PCHAR)&Context->Response.Header);
-    Segment->Data = (PCHAR)&Response->Header;
+    ASSERT3P(Segment->Data, ==, (PSTR)&Context->Response.Header);
+    Segment->Data = (PSTR)&Response->Header;
 
     Segment = &Response->Segment[XENBUS_STORE_RESPONSE_PAYLOAD_SEGMENT];
     if (Segment->Length != 0) {
@@ -987,7 +987,7 @@ StoreCheckResponse(
     status = STATUS_SUCCESS;
 
     if (Response->Header.type == XS_ERROR) {
-        PCHAR   Error;
+        PSTR    Error;
         ULONG   Length;
         ULONG   Index;
 
@@ -1024,7 +1024,7 @@ StoreCopyPayload(
     _In_ PVOID                  Caller
     )
 {
-    PCHAR                       Data;
+    PSTR                        Data;
     ULONG                       Length;
     PXENBUS_STORE_BUFFER        Buffer;
     KIRQL                       Irql;
@@ -1079,7 +1079,7 @@ StoreFreePayload(
 static VOID
 StoreFree(
     _In_ PINTERFACE         Interface,
-    _In_ PCHAR              Value
+    _In_ PSTR               Value
     )
 {
     PXENBUS_STORE_CONTEXT   Context = Interface->Context;
@@ -1102,9 +1102,9 @@ static NTSTATUS
 StoreRead(
     _In_ PINTERFACE                     Interface,
     _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
-    _In_opt_ PCHAR                      Prefix,
-    _In_ PCHAR                          Node,
-    _Out_ PCHAR                         *Value
+    _In_opt_ PSTR                       Prefix,
+    _In_ PSTR                           Node,
+    _Outptr_result_z_ PSTR              *Value
     )
 {
     PXENBUS_STORE_CONTEXT               Context = Interface->Context;
@@ -1184,9 +1184,9 @@ static NTSTATUS
 StoreWrite(
     _In_ PXENBUS_STORE_CONTEXT          Context,
     _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
-    _In_opt_ PCHAR                      Prefix,
-    _In_ PCHAR                          Node,
-    _In_ PCHAR                          Value
+    _In_opt_ PSTR                       Prefix,
+    _In_ PSTR                           Node,
+    _In_ PSTR                           Value
     )
 {
     XENBUS_STORE_REQUEST                Request;
@@ -1254,14 +1254,14 @@ static NTSTATUS
 StoreVPrintf(
     _In_ PINTERFACE                     Interface,
     _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
-    _In_opt_ PCHAR                      Prefix,
-    _In_ PCHAR                          Node,
-    _In_ const CHAR                     *Format,
+    _In_opt_ PSTR                       Prefix,
+    _In_ PSTR                           Node,
+    _In_ PCSTR                          Format,
     _In_ va_list                        Arguments
     )
 {
     PXENBUS_STORE_CONTEXT               Context = Interface->Context;
-    PCHAR                               Buffer;
+    PSTR                                Buffer;
     ULONG                               Length;
     NTSTATUS                            status;
 
@@ -1316,9 +1316,9 @@ static NTSTATUS
 StorePrintf(
     _In_ PINTERFACE                     Interface,
     _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
-    _In_opt_ PCHAR                      Prefix,
-    _In_ PCHAR                          Node,
-    _In_ const CHAR                     *Format,
+    _In_opt_ PSTR                       Prefix,
+    _In_ PSTR                           Node,
+    _In_ PCSTR                          Format,
     ...
     )
 {
@@ -1341,8 +1341,8 @@ static NTSTATUS
 StoreRemove(
     _In_ PINTERFACE                     Interface,
     _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
-    _In_opt_ PCHAR                      Prefix,
-    _In_ PCHAR                          Node
+    _In_opt_ PSTR                       Prefix,
+    _In_ PSTR                           Node
     )
 {
     PXENBUS_STORE_CONTEXT               Context = Interface->Context;
@@ -1409,9 +1409,9 @@ static NTSTATUS
 StoreDirectory(
     _In_ PINTERFACE                     Interface,
     _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
-    _In_opt_ PCHAR                      Prefix,
-    _In_ PCHAR                          Node,
-    _Out_ PCHAR                         *Value
+    _In_opt_ PSTR                       Prefix,
+    _In_ PSTR                           Node,
+    _Outptr_result_z_ PSTR              *Value
     )
 {
     PXENBUS_STORE_CONTEXT               Context = Interface->Context;
@@ -1656,15 +1656,15 @@ fail1:
 static NTSTATUS
 StoreWatchAdd(
     _In_ PINTERFACE             Interface,
-    _In_opt_ PCHAR              Prefix,
-    _In_ PCHAR                  Node,
+    _In_opt_ PSTR               Prefix,
+    _In_ PSTR                   Node,
     _In_ PKEVENT                Event,
     _Out_ PXENBUS_STORE_WATCH   *Watch
     )
 {
     PXENBUS_STORE_CONTEXT       Context = Interface->Context;
     ULONG                       Length;
-    PCHAR                       Path;
+    PSTR                        Path;
     CHAR                        Token[TOKEN_LENGTH];
     XENBUS_STORE_REQUEST        Request;
     PXENBUS_STORE_RESPONSE      Response;
@@ -1791,7 +1791,7 @@ StoreWatchRemove(
     )
 {
     PXENBUS_STORE_CONTEXT       Context = Interface->Context;
-    PCHAR                       Path;
+    PSTR                        Path;
     CHAR                        Token[TOKEN_LENGTH];
     XENBUS_STORE_REQUEST        Request;
     PXENBUS_STORE_RESPONSE      Response;
@@ -1978,7 +1978,8 @@ StoreWatchdog(
 static NTSTATUS
 StorePermissionToString(
     _In_ PXENBUS_STORE_PERMISSION   Permission,
-    _Out_ PCHAR                     Buffer,
+    _Out_writes_to_(BufferSize, *UsedSize)
+    PSTR                            Buffer,
     _In_ ULONG                      BufferSize,
     _Out_ PULONG                    UsedSize
     )
@@ -2037,8 +2038,8 @@ static NTSTATUS
 StorePermissionsSet(
     _In_ PINTERFACE                     Interface,
     _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
-    _In_opt_ PCHAR                      Prefix,
-    _In_ PCHAR                          Node,
+    _In_opt_ PSTR                       Prefix,
+    _In_ PSTR                           Node,
     _In_ PXENBUS_STORE_PERMISSION       Permissions,
     _In_ ULONG                          NumberPermissions
     )
@@ -2051,9 +2052,9 @@ StorePermissionsSet(
     ULONG                               Index;
     ULONG                               Length;
     ULONG                               Used;
-    PCHAR                               Path;
-    PCHAR                               PermissionString;
-    PCHAR                               Segment;
+    PSTR                                Path;
+    PSTR                                PermissionString;
+    PSTR                                Segment;
 
     PermissionString = __StoreAllocate(XENSTORE_PAYLOAD_MAX);
 
@@ -2378,7 +2379,7 @@ StoreDebugCallback(
              ListEntry != &(Context->BufferList);
              ListEntry = ListEntry->Flink) {
             PXENBUS_STORE_BUFFER    Buffer;
-            PCHAR                   Name;
+            PSTR                    Name;
             ULONG_PTR               Offset;
 
             Buffer = CONTAINING_RECORD(ListEntry, XENBUS_STORE_BUFFER, ListEntry);
@@ -2413,7 +2414,7 @@ StoreDebugCallback(
              ListEntry != &(Context->WatchList);
              ListEntry = ListEntry->Flink) {
             PXENBUS_STORE_WATCH Watch;
-            PCHAR               Name;
+            PSTR                Name;
             ULONG_PTR           Offset;
 
             Watch = CONTAINING_RECORD(ListEntry, XENBUS_STORE_WATCH, ListEntry);
@@ -2452,7 +2453,7 @@ StoreDebugCallback(
              ListEntry != &(Context->TransactionList);
              ListEntry = ListEntry->Flink) {
             PXENBUS_STORE_TRANSACTION   Transaction;
-            PCHAR                       Name;
+            PSTR                        Name;
             ULONG_PTR                   Offset;
 
             Transaction = CONTAINING_RECORD(ListEntry, XENBUS_STORE_TRANSACTION, ListEntry);
diff --git a/src/xenbus/suspend.c b/src/xenbus/suspend.c
index ab403bf..55c00a2 100644
--- a/src/xenbus/suspend.c
+++ b/src/xenbus/suspend.c
@@ -143,7 +143,7 @@ SuspendDeregister(
 
 static FORCEINLINE VOID
 __SuspendLogTimers(
-    _In_ const CHAR *Prefix
+    _In_ PCSTR      Prefix
     )
 {
     LARGE_INTEGER   SystemTime;
@@ -331,7 +331,7 @@ SuspendDebugCallback(
          ListEntry != &Context->EarlyList;
          ListEntry = ListEntry->Flink) {
         PXENBUS_SUSPEND_CALLBACK    Callback;
-        PCHAR                       Name;
+        PSTR                        Name;
         ULONG_PTR                   Offset;
 
         Callback = CONTAINING_RECORD(ListEntry, XENBUS_SUSPEND_CALLBACK, ListEntry);
@@ -358,7 +358,7 @@ SuspendDebugCallback(
          ListEntry != &Context->LateList;
          ListEntry = ListEntry->Flink) {
         PXENBUS_SUSPEND_CALLBACK    Callback;
-        PCHAR                       Name;
+        PSTR                        Name;
         ULONG_PTR                   Offset;
 
         Callback = CONTAINING_RECORD(ListEntry, XENBUS_SUSPEND_CALLBACK, ListEntry);
diff --git a/src/xenbus/unplug.c b/src/xenbus/unplug.c
index a21df30..21cc122 100644
--- a/src/xenbus/unplug.c
+++ b/src/xenbus/unplug.c
@@ -154,7 +154,7 @@ UnplugBootEmulated(
     PXENBUS_UNPLUG_CONTEXT          Context = Interface->Context;
     CHAR                            KeyName[] = "XEN:BOOT_EMULATED=";
     PANSI_STRING                    Option;
-    PCHAR                           Value;
+    PSTR                            Value;
     NTSTATUS                        status;
     BOOLEAN                         BootEmulated;
 
@@ -187,7 +187,7 @@ _IRQL_requires_(PASSIVE_LEVEL)
 static VOID
 UnplugReboot(
     _In_ PINTERFACE                 Interface,
-    _In_ PCHAR                      Module
+    _In_ PSTR                       Module
     )
 {
     PXENBUS_UNPLUG_CONTEXT          Context = Interface->Context;
diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
index fd1ed22..16e4deb 100644
--- a/src/xenfilt/driver.c
+++ b/src/xenfilt/driver.c
@@ -206,15 +206,15 @@ DriverRemoveFunctionDeviceObject(
 
 static FORCEINLINE NTSTATUS
 __DriverGetActive(
-    _In_ const CHAR *Key,
-    _Out_ PCHAR     *Value
+    _In_ PCSTR              Key,
+    _Outptr_result_z_ PSTR  *Value
     )
 {
-    HANDLE          ParametersKey;
-    CHAR            Name[MAXNAMELEN];
-    PANSI_STRING    Ansi;
-    ULONG           Length;
-    NTSTATUS        status;
+    HANDLE                  ParametersKey;
+    CHAR                    Name[MAXNAMELEN];
+    PANSI_STRING            Ansi;
+    ULONG                   Length;
+    NTSTATUS                status;
 
     Trace("====>\n");
 
@@ -272,8 +272,8 @@ fail1:
 
 NTSTATUS
 DriverGetActive(
-    _In_ const CHAR *Key,
-    _Out_ PCHAR     *Value
+    _In_ PCSTR              Key,
+    _Outptr_result_z_ PSTR  *Value
     )
 {
     return __DriverGetActive(Key, Value);
@@ -284,7 +284,7 @@ DriverIsActivePresent(
     VOID
     )
 {
-    PCHAR       ActiveDeviceID;
+    PSTR        ActiveDeviceID;
     BOOLEAN     Present;
     NTSTATUS    status;
 
@@ -453,13 +453,13 @@ NTSTATUS
 DriverQueryId(
     _In_ PDEVICE_OBJECT     DeviceObject,
     _In_ BUS_QUERY_ID_TYPE  Type,
-    _Out_ PCHAR             *Id
+    _Outptr_result_z_ PSTR  *Id
     )
 {
     PIRP                    Irp;
     KEVENT                  Event;
     PIO_STACK_LOCATION      StackLocation;
-    PWCHAR                  Buffer;
+    PWSTR                   Buffer;
     NTSTATUS                status;
 
     ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
@@ -524,7 +524,7 @@ DriverQueryId(
     if (!NT_SUCCESS(status))
         goto fail3;
 
-    Buffer = (PWCHAR)Irp->IoStatus.Information;
+    Buffer = (PWSTR)Irp->IoStatus.Information;
 
     switch (Type) {
     case BusQueryDeviceID:
@@ -617,13 +617,13 @@ NTSTATUS
 DriverQueryDeviceText(
     _In_ PDEVICE_OBJECT     DeviceObject,
     _In_ DEVICE_TEXT_TYPE   Type,
-    _Out_ PCHAR             *Text
+    _Outptr_result_z_ PSTR  *Text
     )
 {
     PIRP                    Irp;
     KEVENT                  Event;
     PIO_STACK_LOCATION      StackLocation;
-    PWCHAR                  Buffer;
+    PWSTR                   Buffer;
     ULONG                   Length;
     NTSTATUS                status;
 
@@ -673,7 +673,7 @@ DriverQueryDeviceText(
     if (!NT_SUCCESS(status))
         goto fail2;
 
-    Buffer = (PWCHAR)Irp->IoStatus.Information;
+    Buffer = (PWSTR)Irp->IoStatus.Information;
     Length = (ULONG)(wcslen(Buffer) + 1) * sizeof (CHAR);
 
     *Text = __AllocatePoolWithTag(PagedPool, Length, 'TLIF');
@@ -703,7 +703,7 @@ fail1:
     return status;
 }
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __EmulatedTypeName(
     _In_ XENFILT_EMULATED_OBJECT_TYPE   Type
     )
@@ -718,7 +718,7 @@ __EmulatedTypeName(
 
 static XENFILT_EMULATED_OBJECT_TYPE
 DriverGetEmulatedType(
-    _In_ PCHAR                      Id
+    _In_ PSTR                       Id
     )
 {
     HANDLE                          ParametersKey;
@@ -780,7 +780,7 @@ DriverAddDevice(
     _In_ PDEVICE_OBJECT             PhysicalDeviceObject
     )
 {
-    PCHAR                           Id;
+    PSTR                            Id;
     XENFILT_EMULATED_OBJECT_TYPE    Type;
     NTSTATUS                        status;
 
diff --git a/src/xenfilt/driver.h b/src/xenfilt/driver.h
index ab36936..9c703c1 100644
--- a/src/xenfilt/driver.h
+++ b/src/xenfilt/driver.h
@@ -50,8 +50,8 @@ DriverReleaseMutex(
 
 extern NTSTATUS
 DriverGetActive(
-    _In_ const CHAR *Key,
-    _Out_ PCHAR     *Value
+    _In_ PCSTR              Key,
+    _Outptr_result_z_ PSTR  *Value
     );
 
 typedef enum _XENFILT_FILTER_STATE {
@@ -74,14 +74,14 @@ extern NTSTATUS
 DriverQueryId(
     _In_ PDEVICE_OBJECT     PhysicalDeviceObject,
     _In_ BUS_QUERY_ID_TYPE  Type,
-    _Out_ PCHAR             *Id
+    _Outptr_result_z_ PSTR  *Id
     );
 
 extern NTSTATUS
 DriverQueryDeviceText(
     _In_ PDEVICE_OBJECT     LowerDeviceObject,
     _In_ DEVICE_TEXT_TYPE   Type,
-    _Out_ PCHAR             *Text
+    _Outptr_result_z_ PSTR  *Text
     );
 
 #include "emulated.h"
@@ -120,9 +120,9 @@ typedef struct _XENFILT_DX {
     SYSTEM_POWER_STATE  SystemPowerState;
     DEVICE_POWER_STATE  DevicePowerState;
 
-    PCHAR               DeviceID;
-    PCHAR               InstanceID;
-    PCHAR               LocationInformation;
+    PSTR                DeviceID;
+    PSTR                InstanceID;
+    PSTR                LocationInformation;
 
     IO_REMOVE_LOCK      RemoveLock;
 
diff --git a/src/xenfilt/emulated.c b/src/xenfilt/emulated.c
index 76bb3c0..f5e1cc4 100644
--- a/src/xenfilt/emulated.c
+++ b/src/xenfilt/emulated.c
@@ -93,13 +93,13 @@ static NTSTATUS
 EmulatedSetObjectDeviceData(
     _In_ PXENFILT_EMULATED_OBJECT       EmulatedObject,
     _In_ XENFILT_EMULATED_OBJECT_TYPE   Type,
-    _In_ PCHAR                          DeviceID,
-    _In_ PCHAR                          InstanceID,
-    _In_opt_ PCHAR                      CompatibleIDs
+    _In_ PSTR                           DeviceID,
+    _In_ PSTR                           InstanceID,
+    _In_opt_ PSTR                       CompatibleIDs
     )
 {
     ULONG                               Index;
-    PCHAR                               LastMatch;
+    PSTR                                LastMatch;
     NTSTATUS                            status;
 
     status = STATUS_INVALID_PARAMETER;
@@ -154,12 +154,12 @@ static NTSTATUS
 EmulatedSetObjectDiskData(
     _In_ PXENFILT_EMULATED_OBJECT       EmulatedObject,
     _In_ XENFILT_EMULATED_OBJECT_TYPE   Type,
-    _In_ PCHAR                          DeviceID,
-    _In_ PCHAR                          InstanceID,
-    _In_opt_ PCHAR                      CompatibleIDs
+    _In_ PSTR                           DeviceID,
+    _In_ PSTR                           InstanceID,
+    _In_opt_ PSTR                       CompatibleIDs
     )
 {
-    PCHAR                               End;
+    PSTR                                End;
     ULONG                               Controller;
     ULONG                               Target;
     ULONG                               Lun;
@@ -223,9 +223,9 @@ fail1:
 NTSTATUS
 EmulatedAddObject(
     _In_ PXENFILT_EMULATED_CONTEXT      Context,
-    _In_ PCHAR                          DeviceID,
-    _In_ PCHAR                          InstanceID,
-    _In_opt_ PCHAR                      CompatibleIDs,
+    _In_ PSTR                           DeviceID,
+    _In_ PSTR                           InstanceID,
+    _In_opt_ PSTR                       CompatibleIDs,
     _In_ XENFILT_EMULATED_OBJECT_TYPE   Type,
     _Out_ PXENFILT_EMULATED_OBJECT      *EmulatedObject
     )
@@ -305,8 +305,8 @@ EmulatedRemoveObject(
 static BOOLEAN
 EmulatedIsDevicePresent(
     _In_ PINTERFACE             Interface,
-    _In_ PCHAR                  DeviceID,
-    _In_opt_ PCHAR              InstanceID
+    _In_ PSTR                   DeviceID,
+    _In_opt_ PSTR               InstanceID
     )
 {
     PXENFILT_EMULATED_CONTEXT   Context = Interface->Context;
diff --git a/src/xenfilt/emulated.h b/src/xenfilt/emulated.h
index 5cb6ece..686d542 100644
--- a/src/xenfilt/emulated.h
+++ b/src/xenfilt/emulated.h
@@ -68,9 +68,9 @@ EmulatedTeardown(
 extern NTSTATUS
 EmulatedAddObject(
     _In_ PXENFILT_EMULATED_CONTEXT      Context,
-    _In_ PCHAR                          DeviceID,
-    _In_ PCHAR                          InstanceID,
-    _In_opt_ PCHAR                      CompatibleIDs,
+    _In_ PSTR                           DeviceID,
+    _In_ PSTR                           InstanceID,
+    _In_opt_ PSTR                       CompatibleIDs,
     _In_ XENFILT_EMULATED_OBJECT_TYPE   Type,
     _Out_ PXENFILT_EMULATED_OBJECT      *EmulatedObject
     );
diff --git a/src/xenfilt/fdo.c b/src/xenfilt/fdo.c
index 94578f6..de70c6d 100644
--- a/src/xenfilt/fdo.c
+++ b/src/xenfilt/fdo.c
@@ -221,7 +221,7 @@ __FdoSetDeviceID(
 
 }
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __FdoGetDeviceID(
     _In_ PXENFILT_FDO   Fdo
     )
@@ -254,7 +254,7 @@ __FdoSetInstanceID(
                          &Dx->InstanceID);
 }
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __FdoGetInstanceID(
     _In_ PXENFILT_FDO   Fdo
     )
@@ -290,7 +290,7 @@ __FdoSetName(
     ASSERT(NT_SUCCESS(status));
 }
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __FdoGetName(
     _In_ PXENFILT_FDO   Fdo
     )
diff --git a/src/xenfilt/fdo.h b/src/xenfilt/fdo.h
index bd1d347..907ec4b 100644
--- a/src/xenfilt/fdo.h
+++ b/src/xenfilt/fdo.h
@@ -52,7 +52,7 @@ FdoDestroy(
     _In_ PXENFILT_FDO   Fdo
     );
 
-extern PCHAR
+extern PSTR
 FdoGetPrefix(
     _In_ PXENFILT_FDO   Fdo
     );
diff --git a/src/xenfilt/pdo.c b/src/xenfilt/pdo.c
index 9c6ba99..4f40c4f 100644
--- a/src/xenfilt/pdo.c
+++ b/src/xenfilt/pdo.c
@@ -59,7 +59,7 @@ struct _XENFILT_PDO {
 
     PXENFILT_FDO                    Fdo;
     BOOLEAN                         Missing;
-    const CHAR                      *Reason;
+    PCSTR                           Reason;
 
     XENFILT_EMULATED_OBJECT_TYPE    Type;
     PXENFILT_EMULATED_OBJECT        EmulatedObject;
@@ -189,7 +189,7 @@ PdoGetPhysicalDeviceObject(
 static FORCEINLINE VOID
 __PdoSetMissing(
     _In_ PXENFILT_PDO   Pdo,
-    _In_ const CHAR     *Reason
+    _In_ PCSTR          Reason
     )
 {
     Pdo->Reason = Reason;
@@ -199,7 +199,7 @@ __PdoSetMissing(
 VOID
 PdoSetMissing(
     _In_ PXENFILT_PDO   Pdo,
-    _In_ const CHAR     *Reason
+    _In_ PCSTR          Reason
     )
 {
     __PdoSetMissing(Pdo, Reason);
@@ -253,10 +253,10 @@ PdoSetDeviceInformation(
     )
 {
     PXENFILT_DX         Dx = Pdo->Dx;
-    PCHAR               DeviceID;
-    PCHAR               ActiveDeviceID;
-    PCHAR               InstanceID;
-    PCHAR               LocationInformation;
+    PSTR                DeviceID;
+    PSTR                ActiveDeviceID;
+    PSTR                InstanceID;
+    PSTR                LocationInformation;
     NTSTATUS            status;
 
     status = DriverQueryId(Pdo->LowerDeviceObject,
@@ -350,7 +350,7 @@ PdoClearDeviceInformation(
     Pdo->Active = FALSE;
 }
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __PdoGetDeviceID(
     _In_ PXENFILT_PDO   Pdo
     )
@@ -361,7 +361,7 @@ __PdoGetDeviceID(
     return Dx->DeviceID;
 }
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __PdoGetInstanceID(
     _In_ PXENFILT_PDO   Pdo
     )
@@ -380,7 +380,7 @@ __PdoGetType(
     return Pdo->Type;
 }
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __PdoGetLocationInformation(
     _In_ PXENFILT_PDO   Pdo
     )
@@ -413,7 +413,7 @@ __PdoSetName(
     ASSERT(NT_SUCCESS(status));
 }
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __PdoGetName(
     _In_ PXENFILT_PDO   Pdo
     )
@@ -814,7 +814,7 @@ DEFINE_PDO_QUERY_INTERFACE(Emulated)
 
 struct _INTERFACE_ENTRY {
     const GUID  *Guid;
-    const CHAR  *Name;
+    PCSTR       Name;
     NTSTATUS    (*Query)(PXENFILT_PDO, PIRP);
 };
 
@@ -1630,7 +1630,7 @@ PdoCreate(
     PDEVICE_OBJECT                      FilterDeviceObject;
     PXENFILT_DX                         Dx;
     PXENFILT_PDO                        Pdo;
-    PCHAR                               CompatibleIDs;
+    PSTR                                CompatibleIDs;
     NTSTATUS                            status;
 
     ASSERT(Type != XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN);
diff --git a/src/xenfilt/pdo.h b/src/xenfilt/pdo.h
index fbce164..85bc07f 100644
--- a/src/xenfilt/pdo.h
+++ b/src/xenfilt/pdo.h
@@ -65,7 +65,7 @@ PdoIsMissing(
 extern VOID
 PdoSetMissing(
     _In_ PXENFILT_PDO   Pdo,
-    _In_ const CHAR     *Reason
+    _In_ PCSTR          Reason
     );
 
 extern BOOLEAN
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:20 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:20 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025009.1400767 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCe-0008BH-RT; Wed, 25 Jun 2025 14:34:20 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025009.1400767; Wed, 25 Jun 2025 14:34:20 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCe-0008B4-Mx; Wed, 25 Jun 2025 14:34:20 +0000
Received: by outflank-mailman (input) for mailman id 1025009;
 Wed, 25 Jun 2025 14:34:20 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=2nB/=ZI=bounce.vates.tech=bounce-md_30504962.685c08e2.v1-f740664650d14cb1a7aedb90ddc27e15@srs-se1.protection.inumbo.net>)
 id 1uURCd-000871-W4
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:19 +0000
Received: from mail134-21.atl141.mandrillapp.com
 (mail134-21.atl141.mandrillapp.com [198.2.134.21])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 760f63d6-51d1-11f0-b894-0df219b8e170;
 Wed, 25 Jun 2025 16:34:12 +0200 (CEST)
Received: from pmta10.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail134-21.atl141.mandrillapp.com (Mailchimp) with ESMTP id
 4bS4826yWdz1XLP4w
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:10 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 f740664650d14cb1a7aedb90ddc27e15; Wed, 25 Jun 2025 14:34:10 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 760f63d6-51d1-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862051; x=1751132051;
	bh=aHfkAHJf/N24fGkS7hOB7HWP3DgE5p2OuE1t7m0r/1w=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=aMu2YKXiKpuSVIozfNtdJiK9PCMlNUoVv5tq1C7/NhTN7zA+y/NP4KbSOoGSEoDG/
	 v8vGfOBCFQK5G9vRFDm49xBwV4tC5d2FWuvyo0naBt5x6/KDvC3HRZ29Uf2o9nx5DC
	 duHBeock2CoCAUWLcOZXBf9wDgttnrnkwcgJRhWFYH0/dq0osdcV+TA6SikGkXEcNC
	 SUCK0axw23KqDVUb+C1g2r3O36263iDCLhr0J3NN28H+/FfL5nPT6adDldvSdhveiO
	 ihHcJnaaYaIPe+KoRh7S+bA8M/1bTb/YKPodUAm278kkWf7njklMoFEgjlz9j2+xgO
	 ME5ZOMZFx/uPw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862051; x=1751122551; i=ngoc-tu.dinh@vates.tech;
	bh=aHfkAHJf/N24fGkS7hOB7HWP3DgE5p2OuE1t7m0r/1w=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=SjYn3ZidA9ZptcnONa1nb4by9vyY9dkPU90Egk+yLyFuZ3duN7p5FwDPinGBCE/es
	 gXy+E9+0KZeKnnUf68gegTxIswoBzdW1ywpWsG43aTezjr2cJLUjGx8lg5o/4w9IXZ
	 5DG0/XNpf1wden0JA0O3dOH0dNtVGMO7Fu59W8d8h5XW3Dk62ybJa4zyS0WqS/M/Ak
	 DnBAblcPx1SEHaF5DU33v8pQgdD92mDjxfkxE/Zlwinih4pkp44K72VXfNRDSdterT
	 Yj7WwsshJx3lRU1c7/JGn0jDgyCR6ULD29QKSQGFjwTwOSd8n+rfuNQuWBKMfJliDL
	 PmsibBu4LfYmQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2000/13]=20Use=20SAL=202.0=20annotations?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862050183
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.f740664650d14cb1a7aedb90ddc27e15?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:10 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

WinPV drivers use old annotations (IN/OUT) that are not checked by the compiler.

This patch series aims to move all Xenbus annotations to SAL 2.0 to increase the
number of checks the compiler can do.

Only Xenbus is converted for now.

The series is split into 3 parts:

Part 1: Conversion and correction of existing annotations; use of string types
to explicitly signify null-terminated pointers
* Replace old annotations with SAL2 equivalents
* Switch from char pointers to null-terminated string types
* Refine function annotations
* Set _Outptr_ on output pointers

Part 2: Suppress new warnings
* Suppress uninitialized *Interface warning in FdoQueryInterface
* registry: Suppress unannotated DriverEntry warning
* registry: Suppress uninitialized memory warnings

Part 3: Various fixes discovered via SAL annotations. These patches can be taken
as-is separately from the above.
* Fix missing return types
* monitor: Fix GetRequestKeyName allocation check
* Check ParametersKey for null in FdoScan
* Check for IoAttachDeviceToDeviceStack failure in FdoCreate
* sync: Save/restore IRQL when disabling interrupts
* Explicitly check HvmGetParam result via BUG_ON

Tu Dinh (13):
  Replace old annotations with SAL2 equivalents
  Switch from char pointers to null-terminated string types
  Refine function annotations
  Set _Outptr_ on output pointers
  Suppress uninitialized *Interface warning in FdoQueryInterface
  registry: Suppress unannotated DriverEntry warning
  registry: Suppress uninitialized memory warnings
  Fix missing return types
  monitor: Fix GetRequestKeyName allocation check
  Check ParametersKey for null in FdoScan
  Check for IoAttachDeviceToDeviceStack failure in FdoCreate
  sync: Save/restore IRQL when disabling interrupts
  Explicitly check HvmGetParam result via BUG_ON

 include/balloon_interface.h     |   68 +-
 include/cache_interface.h       |  130 ++--
 include/console_interface.h     |   30 +-
 include/debug_interface.h       |   88 +--
 include/emulated_interface.h    |   78 +--
 include/evtchn_interface.h      |  136 ++--
 include/gnttab_interface.h      |  148 ++---
 include/range_set_interface.h   |  100 +--
 include/shared_info_interface.h |  106 +--
 include/store_interface.h       |  156 ++---
 include/suspend_interface.h     |   80 +--
 include/unplug_interface.h      |   72 +-
 include/xen.h                   |  330 +++++-----
 src/common/assert.h             |   80 +--
 src/common/dbg_print.h          |   62 +-
 src/common/high.h               |   63 +-
 src/common/mutex.h              |   60 +-
 src/common/names.h              |  118 ++--
 src/common/registry.c           |  269 ++++----
 src/common/registry.h           |  186 +++---
 src/common/util.h               |   73 +-
 src/monitor/monitor.c           |  125 ++--
 src/xen/acpi.c                  |   60 +-
 src/xen/acpi.h                  |   52 +-
 src/xen/bug_check.c             |  175 ++---
 src/xen/config.c                |   46 +-
 src/xen/driver.c                |  138 ++--
 src/xen/driver.h                |    6 +-
 src/xen/event_channel.c         |  116 ++--
 src/xen/filters.c               |   16 +-
 src/xen/grant_table.c           |   90 +--
 src/xen/hvm.c                   |   80 +--
 src/xen/log.c                   |  164 ++---
 src/xen/memory.c                |   78 +--
 src/xen/module.c                |  102 +--
 src/xen/process.c               |   60 +-
 src/xen/process.h               |   50 +-
 src/xen/sched.c                 |   64 +-
 src/xen/system.c                |  125 ++--
 src/xen/unplug.c                |   42 +-
 src/xen/vcpu.c                  |   20 +-
 src/xen/xen_version.c           |   66 +-
 src/xenbus/balloon.c            |  216 +++---
 src/xenbus/balloon.h            |   62 +-
 src/xenbus/bus.c                |  146 ++--
 src/xenbus/bus.h                |   52 +-
 src/xenbus/cache.c              |  220 +++----
 src/xenbus/cache.h              |   62 +-
 src/xenbus/console.c            |  140 ++--
 src/xenbus/console.h            |   16 +-
 src/xenbus/debug.c              |  140 ++--
 src/xenbus/debug.h              |   62 +-
 src/xenbus/dma.c                |  521 +++++++--------
 src/xenbus/dma.h                |   54 +-
 src/xenbus/driver.c             |   97 +--
 src/xenbus/driver.h             |   50 +-
 src/xenbus/evtchn.c             |  244 +++----
 src/xenbus/evtchn.h             |   64 +-
 src/xenbus/evtchn_2l.c          |   96 +--
 src/xenbus/evtchn_2l.h          |   56 +-
 src/xenbus/evtchn_abi.h         |   86 +--
 src/xenbus/evtchn_fifo.c        |  174 ++---
 src/xenbus/evtchn_fifo.h        |   56 +-
 src/xenbus/fdo.c                | 1099 ++++++++++++++++---------------
 src/xenbus/fdo.h                |  180 ++---
 src/xenbus/gnttab.c             |  214 +++---
 src/xenbus/gnttab.h             |   62 +-
 src/xenbus/hash_table.c         |  100 +--
 src/xenbus/hash_table.h         |   68 +-
 src/xenbus/pdo.c                |  392 +++++------
 src/xenbus/pdo.h                |  116 ++--
 src/xenbus/range_set.c          |  162 ++---
 src/xenbus/range_set.h          |   62 +-
 src/xenbus/shared_info.c        |  152 ++---
 src/xenbus/shared_info.h        |   62 +-
 src/xenbus/store.c              |  506 +++++++-------
 src/xenbus/store.h              |   62 +-
 src/xenbus/suspend.c            |  118 ++--
 src/xenbus/suspend.h            |   62 +-
 src/xenbus/sync.c               |  146 ++--
 src/xenbus/sync.h               |   78 +--
 src/xenbus/thread.c             |   74 +--
 src/xenbus/thread.h             |   64 +-
 src/xenbus/unplug.c             |   54 +-
 src/xenbus/unplug.h             |   16 +-
 src/xenfilt/driver.c            |  134 ++--
 src/xenfilt/driver.h            |   72 +-
 src/xenfilt/emulated.c          |  132 ++--
 src/xenfilt/emulated.h          |   74 +--
 src/xenfilt/fdo.c               |  286 ++++----
 src/xenfilt/fdo.h               |   78 +--
 src/xenfilt/pdo.c               |  313 ++++-----
 src/xenfilt/pdo.h               |   80 +--
 src/xenfilt/thread.c            |   78 +--
 src/xenfilt/thread.h            |   64 +-
 95 files changed, 5994 insertions(+), 5888 deletions(-)

-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:22 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025010.1400771 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCf-0008F3-SW; Wed, 25 Jun 2025 14:34:21 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025010.1400771; Wed, 25 Jun 2025 14:34:21 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCf-0008Es-PY; Wed, 25 Jun 2025 14:34:21 +0000
Received: by outflank-mailman (input) for mailman id 1025010;
 Wed, 25 Jun 2025 14:34:20 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=e7cG=ZI=bounce.vates.tech=bounce-md_30504962.685c08e5.v1-e9932c816d5a4d3c992d12dd76846bce@srs-se1.protection.inumbo.net>)
 id 1uURCe-0008AM-2T
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:20 +0000
Received: from mail180-2.suw31.mandrillapp.com
 (mail180-2.suw31.mandrillapp.com [198.2.180.2])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 7912b03f-51d1-11f0-a30f-13f23c93f187;
 Wed, 25 Jun 2025 16:34:17 +0200 (CEST)
Received: from pmta11.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail180-2.suw31.mandrillapp.com (Mailchimp) with ESMTP id 4bS48541btzS62RvN
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:13 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 e9932c816d5a4d3c992d12dd76846bce; Wed, 25 Jun 2025 14:34:13 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7912b03f-51d1-11f0-a30f-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862053; x=1751132053;
	bh=B0t62+zHC1wqN5E/pIi3vEVSZfQ6rV4HDZdrNW9vK1w=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=ESR2LScQWeCMjilnbAffBeWjvWfLX+wi0dizNcU5ygOMHk9NEpqlqjukmyZBc4yH5
	 7vGlL2UsgoNkgAwoVC+i14jgP/X4/t3YsAirdcgfbmgGRt7+zYYZOFspHQNH9vz61M
	 RAr28jQbktPSGfhtoN7LTlplDuIqoqKct3wdEEMkJzQKTyuUXKCiEidIdfT1PLqhdh
	 eqiyndzjvjU5onip/DBRQCnPicE7QhEmIFrBIBkYpDtYThrdRJI7LKZA8NdurUDGbH
	 aOJOCR2D2LrfYiD06a7lFpuugDXLtU534eSIYPXmCe5GIxXQL9rQjD3AomroRMyifr
	 nZx2evI0xFnZQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862053; x=1751122553; i=ngoc-tu.dinh@vates.tech;
	bh=B0t62+zHC1wqN5E/pIi3vEVSZfQ6rV4HDZdrNW9vK1w=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=Gc03cpsdKNZRTLLjFKYOS6PFEP0f9HgVFFkoqm2hKv6/0jSuESVYbYlR8MqlQDkyB
	 q/hAVZWAiLhld0miPP5mptihIZ+uR5oLj0r5iWKA3YHTvrxCnwPtURj4OR2jncB2tF
	 MIbe7CvH+FhEK016Eb8Ymf8dXrsS+l1NqIEtF4z/8B3rf9Jf4gQyDdFmc4LWLWBfJn
	 NvN0AItxyKradpxU3oJfMctBoPMYU6IX22ewC9VSqjI4PVcrwV3Yudz1sV2oTfJBG3
	 4JU7bOHbMPFzjlEZJPcaOky9OveJy9zrwpEBXxVRAMdXwpsgJnrltxXkgjc3qqZN1U
	 JC3UF1qCm4/ng==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2004/13]=20Set=20=5FOutptr=5F=20on=20output=20pointers?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862052917
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-5-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
References: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.e9932c816d5a4d3c992d12dd76846bce?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:13 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

For double pointers, the annotation checks that the pointed-to result is
valid.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 include/cache_interface.h     |  4 +--
 include/console_interface.h   |  2 +-
 include/debug_interface.h     |  2 +-
 include/gnttab_interface.h    |  6 ++--
 include/range_set_interface.h |  6 ++--
 include/store_interface.h     | 14 ++++----
 include/suspend_interface.h   |  2 +-
 include/xen.h                 | 12 +++----
 src/common/registry.c         |  8 ++---
 src/common/registry.h         | 16 +++++-----
 src/xen/config.c              |  4 +--
 src/xen/log.c                 | 16 +++++-----
 src/xen/system.c              |  2 +-
 src/xenbus/balloon.c          |  8 ++---
 src/xenbus/balloon.h          |  4 +--
 src/xenbus/cache.c            | 10 +++---
 src/xenbus/cache.h            |  4 +--
 src/xenbus/console.c          |  8 ++---
 src/xenbus/console.h          |  4 +--
 src/xenbus/debug.c            |  8 ++---
 src/xenbus/debug.h            |  4 +--
 src/xenbus/evtchn.c           |  2 +-
 src/xenbus/evtchn.h           |  2 +-
 src/xenbus/evtchn_2l.c        |  2 +-
 src/xenbus/evtchn_2l.h        |  2 +-
 src/xenbus/evtchn_fifo.c      |  4 +--
 src/xenbus/evtchn_fifo.h      |  2 +-
 src/xenbus/fdo.c              | 16 +++++-----
 src/xenbus/gnttab.c           | 60 +++++++++++++++++------------------
 src/xenbus/gnttab.h           |  2 +-
 src/xenbus/hash_table.c       |  2 +-
 src/xenbus/hash_table.h       |  2 +-
 src/xenbus/range_set.c        |  8 ++---
 src/xenbus/range_set.h        |  4 +--
 src/xenbus/shared_info.c      |  6 ++--
 src/xenbus/shared_info.h      |  4 +--
 src/xenbus/store.c            | 50 ++++++++++++++---------------
 src/xenbus/store.h            |  4 +--
 src/xenbus/suspend.c          |  8 ++---
 src/xenbus/suspend.h          |  4 +--
 src/xenbus/thread.c           |  2 +-
 src/xenbus/thread.h           |  2 +-
 src/xenbus/unplug.c           |  2 +-
 src/xenbus/unplug.h           |  2 +-
 src/xenfilt/emulated.c        |  6 ++--
 src/xenfilt/emulated.h        |  4 +--
 src/xenfilt/thread.c          |  2 +-
 src/xenfilt/thread.h          |  2 +-
 48 files changed, 175 insertions(+), 175 deletions(-)

diff --git a/include/cache_interface.h b/include/cache_interface.h
index a43e9cc..e5f4ce9 100644
--- a/include/cache_interface.h
+++ b/include/cache_interface.h
@@ -135,7 +135,7 @@ typedef NTSTATUS
     _In_ XENBUS_CACHE_ACQUIRE_LOCK  AcquireLock,
     _In_ XENBUS_CACHE_RELEASE_LOCK  ReleaseLock,
     _In_opt_ PVOID                  Argument,
-    _Out_ PXENBUS_CACHE             *Cache
+    _Outptr_ PXENBUS_CACHE          *Cache
     );
 
 /*! \typedef XENBUS_CACHE_CREATE
@@ -168,7 +168,7 @@ typedef NTSTATUS
     _In_ XENBUS_CACHE_ACQUIRE_LOCK  AcquireLock,
     _In_ XENBUS_CACHE_RELEASE_LOCK  ReleaseLock,
     _In_opt_ PVOID                  Argument,
-    _Out_ PXENBUS_CACHE             *Cache
+    _Outptr_ PXENBUS_CACHE          *Cache
     );
 
 /*! \typedef XENBUS_CACHE_GET
diff --git a/include/console_interface.h b/include/console_interface.h
index 0d5a2da..7ed7790 100644
--- a/include/console_interface.h
+++ b/include/console_interface.h
@@ -134,7 +134,7 @@ typedef NTSTATUS
 (*XENBUS_CONSOLE_WAKEUP_ADD)(
     _In_ PINTERFACE                 Interface,
     _In_ PKEVENT                    Event,
-    _Out_ PXENBUS_CONSOLE_WAKEUP    *Wakeup
+    _Outptr_ PXENBUS_CONSOLE_WAKEUP *Wakeup
     );
 
 /*! \typedef XENBUS_CONSOLE_WAKEUP_REMOVE
diff --git a/include/debug_interface.h b/include/debug_interface.h
index 05fcc3e..251902c 100644
--- a/include/debug_interface.h
+++ b/include/debug_interface.h
@@ -96,7 +96,7 @@ typedef NTSTATUS
     _In_ PSTR                       Prefix,
     _In_ XENBUS_DEBUG_FUNCTION      Function,
     _In_opt_ PVOID                  Argument,
-    _Out_ PXENBUS_DEBUG_CALLBACK    *Callback
+    _Outptr_ PXENBUS_DEBUG_CALLBACK *Callback
     );
 
 /*! \typedef XENBUS_DEBUG_PRINTF
diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h
index 6574e97..92a95a7 100644
--- a/include/gnttab_interface.h
+++ b/include/gnttab_interface.h
@@ -81,7 +81,7 @@ typedef NTSTATUS
     _In_ XENBUS_CACHE_ACQUIRE_LOCK  AcquireLock,
     _In_ XENBUS_CACHE_RELEASE_LOCK  ReleaseLock,
     _In_opt_ PVOID                  Argument,
-    _Out_ PXENBUS_GNTTAB_CACHE      *Cache
+    _Outptr_ PXENBUS_GNTTAB_CACHE   *Cache
     );
 
 /*! \typedef XENBUS_GNTTAB_CREATE_CACHE
@@ -105,7 +105,7 @@ typedef NTSTATUS
     _In_ XENBUS_CACHE_ACQUIRE_LOCK  AcquireLock,
     _In_ XENBUS_CACHE_RELEASE_LOCK  ReleaseLock,
     _In_opt_ PVOID                  Argument,
-    _Out_ PXENBUS_GNTTAB_CACHE      *Cache
+    _Outptr_ PXENBUS_GNTTAB_CACHE   *Cache
     );
 
 /*! \typedef XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS
@@ -129,7 +129,7 @@ typedef NTSTATUS
     _In_ USHORT                     Domain,
     _In_ PFN_NUMBER                 Pfn,
     _In_ BOOLEAN                    ReadOnly,
-    _Out_ PXENBUS_GNTTAB_ENTRY      *Entry
+    _Outptr_ PXENBUS_GNTTAB_ENTRY   *Entry
     );
 
 /*! \typedef XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS
diff --git a/include/range_set_interface.h b/include/range_set_interface.h
index dc19a45..cebe42e 100644
--- a/include/range_set_interface.h
+++ b/include/range_set_interface.h
@@ -76,9 +76,9 @@ typedef VOID
 */
 typedef NTSTATUS
 (*XENBUS_RANGE_SET_CREATE)(
-    _In_ PINTERFACE         Interface,
-    _In_ PCSTR              Name,
-    _Out_ PXENBUS_RANGE_SET *RangeSet
+    _In_ PINTERFACE             Interface,
+    _In_ PCSTR                  Name,
+    _Outptr_ PXENBUS_RANGE_SET  *RangeSet
     );
 
 /*! \typedef XENBUS_RANGE_SET_PUT
diff --git a/include/store_interface.h b/include/store_interface.h
index dbc383d..208be0e 100644
--- a/include/store_interface.h
+++ b/include/store_interface.h
@@ -196,8 +196,8 @@ typedef NTSTATUS
 */
 typedef NTSTATUS
 (*XENBUS_STORE_TRANSACTION_START)(
-    _In_ PINTERFACE                 Interface,
-    _Out_ PXENBUS_STORE_TRANSACTION *Transaction
+    _In_ PINTERFACE                     Interface,
+    _Outptr_ PXENBUS_STORE_TRANSACTION  *Transaction
     );
 
 /*! \typedef XENBUS_STORE_TRANSACTION_END
@@ -231,11 +231,11 @@ typedef NTSTATUS
 */
 typedef NTSTATUS
 (*XENBUS_STORE_WATCH_ADD)(
-    _In_ PINTERFACE             Interface,
-    _In_opt_ PSTR               Prefix,
-    _In_ PSTR                   Node,
-    _In_ PKEVENT                Event,
-    _Out_ PXENBUS_STORE_WATCH   *Watch
+    _In_ PINTERFACE                 Interface,
+    _In_opt_ PSTR                   Prefix,
+    _In_ PSTR                       Node,
+    _In_ PKEVENT                    Event,
+    _Outptr_ PXENBUS_STORE_WATCH    *Watch
     );
 
 /*! \typedef XENBUS_STORE_WATCH_REMOVE
diff --git a/include/suspend_interface.h b/include/suspend_interface.h
index 1444373..a20f616 100644
--- a/include/suspend_interface.h
+++ b/include/suspend_interface.h
@@ -105,7 +105,7 @@ typedef NTSTATUS
     _In_ XENBUS_SUSPEND_CALLBACK_TYPE   Type,
     _In_ XENBUS_SUSPEND_FUNCTION        Function,
     _In_opt_ PVOID                      Argument,
-    _Out_ PXENBUS_SUSPEND_CALLBACK      *Callback
+    _Outptr_ PXENBUS_SUSPEND_CALLBACK   *Callback
     );
 
 /*! \typedef XENBUS_SUSPEND_DEREGISTER
diff --git a/include/xen.h b/include/xen.h
index ce78f86..7f46990 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -447,10 +447,10 @@ typedef struct _LOG_DISPOSITION LOG_DISPOSITION, *PLOG_DISPOSITION;
 XEN_API
 NTSTATUS
 LogAddDisposition(
-    _In_ LOG_LEVEL          Mask,
-    _In_ VOID               (*Function)(PVOID, PSTR, ULONG),
-    _In_opt_ PVOID          Argument,
-    _Out_ PLOG_DISPOSITION  *Disposition
+    _In_ LOG_LEVEL              Mask,
+    _In_ VOID                   (*Function)(PVOID, PSTR, ULONG),
+    _In_opt_ PVOID              Argument,
+    _Outptr_ PLOG_DISPOSITION   *Disposition
     );
 
 XEN_API
@@ -581,8 +581,8 @@ ConfigRequestReboot(
 XEN_API
 NTSTATUS
 ConfigQuerySystemStartOption(
-    _In_ PSTR           Key,
-    _Out_ PANSI_STRING  *Option
+    _In_ PSTR               Key,
+    _Outptr_ PANSI_STRING   *Option
     );
 
 #endif  // _XEN_H
diff --git a/src/common/registry.c b/src/common/registry.c
index 51a98bb..61dae0e 100644
--- a/src/common/registry.c
+++ b/src/common/registry.c
@@ -1016,7 +1016,7 @@ RegistryQuerySzValue(
     _In_ HANDLE                     Key,
     _In_ PSTR                       Name,
     _Out_opt_ PULONG                Type,
-    _Out_ PANSI_STRING              *Array
+    _Outptr_ PANSI_STRING           *Array
     )
 {
     ANSI_STRING                     Ansi;
@@ -1102,7 +1102,7 @@ NTSTATUS
 RegistryQueryBinaryValue(
     _In_ HANDLE                     Key,
     _In_ PSTR                       Name,
-    _Out_ PVOID                     *Buffer,
+    _Outptr_ PVOID                  *Buffer,
     _Out_ PULONG                    Length
     )
 {
@@ -1243,7 +1243,7 @@ fail1:
 NTSTATUS
 RegistryQueryKeyName(
     _In_ HANDLE             Key,
-    _Out_ PANSI_STRING      *Array
+    _Outptr_ PANSI_STRING   *Array
     )
 {
     PKEY_NAME_INFORMATION   Value;
@@ -1298,7 +1298,7 @@ fail1:
 NTSTATUS
 RegistryQuerySystemStartOption(
     _In_ PSTR                       Prefix,
-    _Out_ PANSI_STRING              *Value
+    _Outptr_ PANSI_STRING           *Value
     )
 {
     UNICODE_STRING                  Unicode;
diff --git a/src/common/registry.h b/src/common/registry.h
index a65081f..e70a6ed 100644
--- a/src/common/registry.h
+++ b/src/common/registry.h
@@ -151,17 +151,17 @@ RegistryUpdateDwordValue(
 
 extern NTSTATUS
 RegistryQuerySzValue(
-    _In_ HANDLE         Key,
-    _In_ PSTR           Name,
-    _Out_opt_ PULONG    Type,
-    _Out_ PANSI_STRING  *Array
+    _In_ HANDLE             Key,
+    _In_ PSTR               Name,
+    _Out_opt_ PULONG        Type,
+    _Outptr_ PANSI_STRING   *Array
     );
 
 extern NTSTATUS
 RegistryQueryBinaryValue(
     _In_ HANDLE         Key,
     _In_ PSTR           Name,
-    _Out_ PVOID         *Buffer,
+    _Outptr_ PVOID      *Buffer,
     _Out_ PULONG        Length
     );
 
@@ -176,13 +176,13 @@ RegistryUpdateBinaryValue(
 extern NTSTATUS
 RegistryQueryKeyName(
     _In_ HANDLE             Key,
-    _Out_ PANSI_STRING      *Array
+    _Outptr_ PANSI_STRING   *Array
     );
 
 extern NTSTATUS
 RegistryQuerySystemStartOption(
-    _In_ PSTR           Name,
-    _Out_ PANSI_STRING  *Option
+    _In_ PSTR               Name,
+    _Outptr_ PANSI_STRING   *Option
     );
 
 extern VOID
diff --git a/src/xen/config.c b/src/xen/config.c
index c170d3a..a74f95b 100644
--- a/src/xen/config.c
+++ b/src/xen/config.c
@@ -489,8 +489,8 @@ fail1:
 XEN_API
 NTSTATUS
 ConfigQuerySystemStartOption(
-    _In_ PSTR           Key,
-    _Out_ PANSI_STRING  *Option
+    _In_ PSTR               Key,
+    _Outptr_ PANSI_STRING   *Option
     )
 {
     return RegistryQuerySystemStartOption(Key, Option);
diff --git a/src/xen/log.c b/src/xen/log.c
index 5687801..7bf8cdb 100644
--- a/src/xen/log.c
+++ b/src/xen/log.c
@@ -602,16 +602,16 @@ LogTeardown(
 
 NTSTATUS
 LogAddDisposition(
-    _In_ LOG_LEVEL          Mask,
-    _In_ VOID               (*Function)(PVOID, PSTR, ULONG),
-    _In_opt_ PVOID          Argument,
-    _Out_ PLOG_DISPOSITION  *Disposition
+    _In_ LOG_LEVEL              Mask,
+    _In_ VOID                   (*Function)(PVOID, PSTR, ULONG),
+    _In_opt_ PVOID              Argument,
+    _Outptr_ PLOG_DISPOSITION   *Disposition
     )
 {
-    PLOG_CONTEXT            Context = &LogContext;
-    KIRQL                   Irql;
-    ULONG                   Index;
-    NTSTATUS                status;
+    PLOG_CONTEXT                Context = &LogContext;
+    KIRQL                       Irql;
+    ULONG                       Index;
+    NTSTATUS                    status;
 
     *Disposition = NULL;
     if (Mask == LOG_LEVEL_NONE)
diff --git a/src/xen/system.c b/src/xen/system.c
index 6618b67..48f9af0 100644
--- a/src/xen/system.c
+++ b/src/xen/system.c
@@ -1074,7 +1074,7 @@ SystemRegisterCallback(
     _In_ PWSTR              Name,
     _In_ PCALLBACK_FUNCTION Function,
     _In_opt_ PVOID          Argument,
-    _Out_ PVOID             *Handle
+    _Outptr_ PVOID          *Handle
     )
 {
     UNICODE_STRING          Unicode;
diff --git a/src/xenbus/balloon.c b/src/xenbus/balloon.c
index 544628a..4affef5 100644
--- a/src/xenbus/balloon.c
+++ b/src/xenbus/balloon.c
@@ -960,12 +960,12 @@ static struct _XENBUS_BALLOON_INTERFACE_V1 BalloonInterfaceVersion1 = {
 
 NTSTATUS
 BalloonInitialize(
-    _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_BALLOON_CONTEXT   *Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Outptr_ PXENBUS_BALLOON_CONTEXT    *Context
     )
 {
-    UNICODE_STRING                  Unicode;
-    NTSTATUS                        status;
+    UNICODE_STRING                      Unicode;
+    NTSTATUS                            status;
 
     Trace("====>\n");
 
diff --git a/src/xenbus/balloon.h b/src/xenbus/balloon.h
index 8a45d3c..0269d88 100644
--- a/src/xenbus/balloon.h
+++ b/src/xenbus/balloon.h
@@ -43,8 +43,8 @@ typedef struct _XENBUS_BALLOON_CONTEXT  XENBUS_BALLOON_CONTEXT, *PXENBUS_BALLOON
 
 extern NTSTATUS
 BalloonInitialize(
-    _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_BALLOON_CONTEXT   *Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Outptr_ PXENBUS_BALLOON_CONTEXT    *Context
     );
 
 extern NTSTATUS
diff --git a/src/xenbus/cache.c b/src/xenbus/cache.c
index 24fc029..d60ae29 100644
--- a/src/xenbus/cache.c
+++ b/src/xenbus/cache.c
@@ -833,7 +833,7 @@ CacheCreate(
     _In_ VOID               (*AcquireLock)(PVOID),
     _In_ VOID               (*ReleaseLock)(PVOID),
     _In_ PVOID              Argument,
-    _Out_ PXENBUS_CACHE     *Cache
+    _Outptr_ PXENBUS_CACHE  *Cache
     )
 {
     PXENBUS_CACHE_CONTEXT   Context = Interface->Context;
@@ -954,7 +954,7 @@ CacheCreateVersion1(
     _In_ VOID               (*AcquireLock)(PVOID),
     _In_ VOID               (*ReleaseLock)(PVOID),
     _In_ PVOID              Argument,
-    _Out_ PXENBUS_CACHE     *Cache
+    _Outptr_ PXENBUS_CACHE  *Cache
     )
 {
     return CacheCreate(Interface,
@@ -1232,11 +1232,11 @@ static struct _XENBUS_CACHE_INTERFACE_V2 CacheInterfaceVersion2 = {
 
 NTSTATUS
 CacheInitialize(
-    _In_ PXENBUS_FDO            Fdo,
-    _Out_ PXENBUS_CACHE_CONTEXT *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Outptr_ PXENBUS_CACHE_CONTEXT  *Context
     )
 {
-    NTSTATUS                    status;
+    NTSTATUS                        status;
 
     Trace("====>\n");
 
diff --git a/src/xenbus/cache.h b/src/xenbus/cache.h
index 8714bc7..0d7feb1 100644
--- a/src/xenbus/cache.h
+++ b/src/xenbus/cache.h
@@ -43,8 +43,8 @@ typedef struct _XENBUS_CACHE_CONTEXT  XENBUS_CACHE_CONTEXT, *PXENBUS_CACHE_CONTE
 
 extern NTSTATUS
 CacheInitialize(
-    _In_ PXENBUS_FDO            Fdo,
-    _Out_ PXENBUS_CACHE_CONTEXT *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Outptr_ PXENBUS_CACHE_CONTEXT  *Context
     );
 
 extern NTSTATUS
diff --git a/src/xenbus/console.c b/src/xenbus/console.c
index 24f9d27..80e8b69 100644
--- a/src/xenbus/console.c
+++ b/src/xenbus/console.c
@@ -621,7 +621,7 @@ static NTSTATUS
 ConsoleWakeupAdd(
     _In_ PINTERFACE                 Interface,
     _In_ PKEVENT                    Event,
-    _Out_ PXENBUS_CONSOLE_WAKEUP    *Wakeup
+    _Outptr_ PXENBUS_CONSOLE_WAKEUP *Wakeup
     )
 {
     PXENBUS_CONSOLE_CONTEXT         Context = Interface->Context;
@@ -868,11 +868,11 @@ static struct _XENBUS_CONSOLE_INTERFACE_V1 ConsoleInterfaceVersion1 = {
 
 NTSTATUS
 ConsoleInitialize(
-    _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_CONSOLE_CONTEXT   *Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Outptr_ PXENBUS_CONSOLE_CONTEXT    *Context
     )
 {
-    NTSTATUS                        status;
+    NTSTATUS                            status;
 
     Trace("====>\n");
 
diff --git a/src/xenbus/console.h b/src/xenbus/console.h
index f4fb3d5..1a4dabe 100644
--- a/src/xenbus/console.h
+++ b/src/xenbus/console.h
@@ -43,8 +43,8 @@ typedef struct _XENBUS_CONSOLE_CONTEXT  XENBUS_CONSOLE_CONTEXT, *PXENBUS_CONSOLE
 
 extern NTSTATUS
 ConsoleInitialize(
-    _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_CONSOLE_CONTEXT   *Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Outptr_ PXENBUS_CONSOLE_CONTEXT    *Context
     );
 
 extern NTSTATUS
diff --git a/src/xenbus/debug.c b/src/xenbus/debug.c
index 7fc1430..ca09759 100644
--- a/src/xenbus/debug.c
+++ b/src/xenbus/debug.c
@@ -95,7 +95,7 @@ DebugRegister(
     _In_ PSTR                       Prefix,
     _In_ XENBUS_DEBUG_FUNCTION      Function,
     _In_opt_ PVOID                  Argument,
-    _Out_ PXENBUS_DEBUG_CALLBACK    *Callback
+    _Outptr_ PXENBUS_DEBUG_CALLBACK *Callback
     )
 {
     PXENBUS_DEBUG_CONTEXT           Context = Interface->Context;
@@ -361,11 +361,11 @@ static struct _XENBUS_DEBUG_INTERFACE_V1 DebugInterfaceVersion1 = {
 
 NTSTATUS
 DebugInitialize(
-    _In_ PXENBUS_FDO            Fdo,
-    _Out_ PXENBUS_DEBUG_CONTEXT *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Outptr_ PXENBUS_DEBUG_CONTEXT  *Context
     )
 {
-    NTSTATUS                    status;
+    NTSTATUS                        status;
 
     Trace("====>\n");
 
diff --git a/src/xenbus/debug.h b/src/xenbus/debug.h
index 18230e5..6b706d2 100644
--- a/src/xenbus/debug.h
+++ b/src/xenbus/debug.h
@@ -43,8 +43,8 @@ typedef struct _XENBUS_DEBUG_CONTEXT  XENBUS_DEBUG_CONTEXT, *PXENBUS_DEBUG_CONTE
 
 extern NTSTATUS
 DebugInitialize(
-    _In_ PXENBUS_FDO            Fdo,
-    _Out_ PXENBUS_DEBUG_CONTEXT *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Outptr_ PXENBUS_DEBUG_CONTEXT  *Context
     );
 
 extern NTSTATUS
diff --git a/src/xenbus/evtchn.c b/src/xenbus/evtchn.c
index 4344bae..7d6d69e 100644
--- a/src/xenbus/evtchn.c
+++ b/src/xenbus/evtchn.c
@@ -1892,7 +1892,7 @@ static struct _XENBUS_EVTCHN_INTERFACE_V9 EvtchnInterfaceVersion9 = {
 NTSTATUS
 EvtchnInitialize(
     _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_EVTCHN_CONTEXT    *Context
+    _Outptr_ PXENBUS_EVTCHN_CONTEXT *Context
     )
 {
     HANDLE                          ParametersKey;
diff --git a/src/xenbus/evtchn.h b/src/xenbus/evtchn.h
index d3ddd89..c429a8f 100644
--- a/src/xenbus/evtchn.h
+++ b/src/xenbus/evtchn.h
@@ -44,7 +44,7 @@ typedef struct _XENBUS_EVTCHN_CONTEXT  XENBUS_EVTCHN_CONTEXT, *PXENBUS_EVTCHN_CO
 extern NTSTATUS
 EvtchnInitialize(
     _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_EVTCHN_CONTEXT    *Context
+    _Outptr_ PXENBUS_EVTCHN_CONTEXT *Context
     );
 
 extern NTSTATUS
diff --git a/src/xenbus/evtchn_2l.c b/src/xenbus/evtchn_2l.c
index b2abead..21b48f0 100644
--- a/src/xenbus/evtchn_2l.c
+++ b/src/xenbus/evtchn_2l.c
@@ -242,7 +242,7 @@ static XENBUS_EVTCHN_ABI EvtchnAbiTwoLevel = {
 NTSTATUS
 EvtchnTwoLevelInitialize(
     _In_ PXENBUS_FDO                    Fdo,
-    _Out_ PXENBUS_EVTCHN_ABI_CONTEXT    *_Context
+    _Outptr_ PXENBUS_EVTCHN_ABI_CONTEXT *_Context
     )
 {
     PXENBUS_EVTCHN_TWO_LEVEL_CONTEXT    Context;
diff --git a/src/xenbus/evtchn_2l.h b/src/xenbus/evtchn_2l.h
index 41ed65c..f122fce 100644
--- a/src/xenbus/evtchn_2l.h
+++ b/src/xenbus/evtchn_2l.h
@@ -42,7 +42,7 @@
 extern NTSTATUS
 EvtchnTwoLevelInitialize(
     _In_ PXENBUS_FDO                    Fdo,
-    _Out_ PXENBUS_EVTCHN_ABI_CONTEXT    *Context
+    _Outptr_ PXENBUS_EVTCHN_ABI_CONTEXT *Context
     );
 
 extern VOID
diff --git a/src/xenbus/evtchn_fifo.c b/src/xenbus/evtchn_fifo.c
index 0f4b44e..1137dea 100644
--- a/src/xenbus/evtchn_fifo.c
+++ b/src/xenbus/evtchn_fifo.c
@@ -638,10 +638,10 @@ static XENBUS_EVTCHN_ABI EvtchnAbiFifo = {
 NTSTATUS
 EvtchnFifoInitialize(
     _In_ PXENBUS_FDO                    Fdo,
-    _Out_ PXENBUS_EVTCHN_ABI_CONTEXT    *_Context
+    _Outptr_ PXENBUS_EVTCHN_ABI_CONTEXT *_Context
     )
 {
-    PXENBUS_EVTCHN_FIFO_CONTEXT    Context;
+    PXENBUS_EVTCHN_FIFO_CONTEXT         Context;
     NTSTATUS                            status;
 
     Trace("====>\n");
diff --git a/src/xenbus/evtchn_fifo.h b/src/xenbus/evtchn_fifo.h
index c8a8fdf..28e43c1 100644
--- a/src/xenbus/evtchn_fifo.h
+++ b/src/xenbus/evtchn_fifo.h
@@ -42,7 +42,7 @@
 extern NTSTATUS
 EvtchnFifoInitialize(
     _In_ PXENBUS_FDO                    Fdo,
-    _Out_ PXENBUS_EVTCHN_ABI_CONTEXT    *Context
+    _Outptr_ PXENBUS_EVTCHN_ABI_CONTEXT *Context
     );
 
 extern VOID
diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index 89595ed..4d3282d 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -2158,7 +2158,7 @@ FdoConnectInterrupt(
     _In_ PXENBUS_FDO                        Fdo,
     _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR    Raw,
     _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR    Translated,
-    _Out_ PXENBUS_INTERRUPT                 *Interrupt
+    _Outptr_ PXENBUS_INTERRUPT              *Interrupt
     )
 {
     IO_CONNECT_INTERRUPT_PARAMETERS         Connect;
@@ -2803,15 +2803,15 @@ __FdoVirqDestroy(
 
 static FORCEINLINE NTSTATUS
 __FdoVirqCreate(
-    _In_ PXENBUS_FDO    Fdo,
-    _In_ ULONG          Type,
-    _In_ ULONG          Cpu,
-    _Out_ PXENBUS_VIRQ  *Virq
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ ULONG              Type,
+    _In_ ULONG              Cpu,
+    _Outptr_ PXENBUS_VIRQ   *Virq
     )
 {
-    PROCESSOR_NUMBER    ProcNumber;
-    unsigned int        vcpu_id;
-    NTSTATUS            status;
+    PROCESSOR_NUMBER        ProcNumber;
+    unsigned int            vcpu_id;
+    NTSTATUS                status;
 
     *Virq = __FdoAllocate(sizeof (XENBUS_VIRQ));
 
diff --git a/src/xenbus/gnttab.c b/src/xenbus/gnttab.c
index 1ee0cd1..693e9b3 100644
--- a/src/xenbus/gnttab.c
+++ b/src/xenbus/gnttab.c
@@ -366,19 +366,19 @@ GnttabReleaseLock(
 
 static NTSTATUS
 GnttabCreateCache(
-    _In_ PINTERFACE             Interface,
-    _In_ PCSTR                  Name,
-    _In_ ULONG                  Reservation,
-    _In_ ULONG                  Cap,
-    _In_ VOID                   (*AcquireLock)(PVOID),
-    _In_ VOID                   (*ReleaseLock)(PVOID),
-    _In_ PVOID                  Argument,
-    _Out_ PXENBUS_GNTTAB_CACHE  *Cache
+    _In_ PINTERFACE                 Interface,
+    _In_ PCSTR                      Name,
+    _In_ ULONG                      Reservation,
+    _In_ ULONG                      Cap,
+    _In_ VOID                       (*AcquireLock)(PVOID),
+    _In_ VOID                       (*ReleaseLock)(PVOID),
+    _In_ PVOID                      Argument,
+    _Outptr_ PXENBUS_GNTTAB_CACHE   *Cache
     )
 {
-    PXENBUS_GNTTAB_CONTEXT      Context = Interface->Context;
-    KIRQL                       Irql;
-    NTSTATUS                    status;
+    PXENBUS_GNTTAB_CONTEXT          Context = Interface->Context;
+    KIRQL                           Irql;
+    NTSTATUS                        status;
 
     *Cache = __GnttabAllocate(sizeof (XENBUS_GNTTAB_CACHE));
 
@@ -445,13 +445,13 @@ fail1:
 
 static NTSTATUS
 GnttabCreateCacheVersion1(
-    _In_ PINTERFACE             Interface,
-    _In_ PCSTR                  Name,
-    _In_ ULONG                  Reservation,
-    _In_ VOID                   (*AcquireLock)(PVOID),
-    _In_ VOID                   (*ReleaseLock)(PVOID),
-    _In_ PVOID                  Argument,
-    _Out_ PXENBUS_GNTTAB_CACHE  *Cache
+    _In_ PINTERFACE                 Interface,
+    _In_ PCSTR                      Name,
+    _In_ ULONG                      Reservation,
+    _In_ VOID                       (*AcquireLock)(PVOID),
+    _In_ VOID                       (*ReleaseLock)(PVOID),
+    _In_ PVOID                      Argument,
+    _Outptr_ PXENBUS_GNTTAB_CACHE   *Cache
     )
 {
     return GnttabCreateCache(Interface,
@@ -498,19 +498,19 @@ GnttabDestroyCache(
 
 static NTSTATUS
 GnttabPermitForeignAccess(
-    _In_ PINTERFACE             Interface,
-    _In_ PXENBUS_GNTTAB_CACHE   Cache,
-    _In_ BOOLEAN                Locked,
-    _In_ USHORT                 Domain,
-    _In_ PFN_NUMBER             Pfn,
-    _In_ BOOLEAN                ReadOnly,
-    _Out_ PXENBUS_GNTTAB_ENTRY  *Entry
+    _In_ PINTERFACE                 Interface,
+    _In_ PXENBUS_GNTTAB_CACHE       Cache,
+    _In_ BOOLEAN                    Locked,
+    _In_ USHORT                     Domain,
+    _In_ PFN_NUMBER                 Pfn,
+    _In_ BOOLEAN                    ReadOnly,
+    _Outptr_ PXENBUS_GNTTAB_ENTRY   *Entry
     )
 {
-    PXENBUS_GNTTAB_CONTEXT      Context = Interface->Context;
-    PXENBUS_GNTTAB_FRAME        Frame;
-    ULONG                       Index;
-    NTSTATUS                    status;
+    PXENBUS_GNTTAB_CONTEXT          Context = Interface->Context;
+    PXENBUS_GNTTAB_FRAME            Frame;
+    ULONG                           Index;
+    NTSTATUS                        status;
 
     *Entry = XENBUS_CACHE(Get,
                           &Context->CacheInterface,
@@ -1082,7 +1082,7 @@ static struct _XENBUS_GNTTAB_INTERFACE_V4   GnttabInterfaceVersion4 = {
 NTSTATUS
 GnttabInitialize(
     _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_GNTTAB_CONTEXT    *Context
+    _Outptr_ PXENBUS_GNTTAB_CONTEXT *Context
     )
 {
     NTSTATUS                        status;
diff --git a/src/xenbus/gnttab.h b/src/xenbus/gnttab.h
index ecd41f7..9a69a2e 100644
--- a/src/xenbus/gnttab.h
+++ b/src/xenbus/gnttab.h
@@ -44,7 +44,7 @@ typedef struct _XENBUS_GNTTAB_CONTEXT  XENBUS_GNTTAB_CONTEXT, *PXENBUS_GNTTAB_CO
 extern NTSTATUS
 GnttabInitialize(
     _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_GNTTAB_CONTEXT    *Context
+    _Outptr_ PXENBUS_GNTTAB_CONTEXT *Context
     );
 
 extern NTSTATUS
diff --git a/src/xenbus/hash_table.c b/src/xenbus/hash_table.c
index 061db08..538ba2c 100644
--- a/src/xenbus/hash_table.c
+++ b/src/xenbus/hash_table.c
@@ -383,7 +383,7 @@ HashTableDpc(
 
 NTSTATUS
 HashTableCreate(
-    _Out_ PXENBUS_HASH_TABLE    *Table
+    _Outptr_ PXENBUS_HASH_TABLE *Table
     )
 {
     ULONG                       Index;
diff --git a/src/xenbus/hash_table.h b/src/xenbus/hash_table.h
index 033b7c1..80d4801 100644
--- a/src/xenbus/hash_table.h
+++ b/src/xenbus/hash_table.h
@@ -59,7 +59,7 @@ HashTableLookup(
 
 extern NTSTATUS
 HashTableCreate(
-    _Out_ PXENBUS_HASH_TABLE    *Table
+    _Outptr_ PXENBUS_HASH_TABLE *Table
     );
 
 extern VOID
diff --git a/src/xenbus/range_set.c b/src/xenbus/range_set.c
index 354b3ca..76d04c4 100644
--- a/src/xenbus/range_set.c
+++ b/src/xenbus/range_set.c
@@ -569,7 +569,7 @@ NTSTATUS
 RangeSetCreate(
     _In_ PINTERFACE             Interface,
     _In_ PCSTR                  Name,
-    _Out_ PXENBUS_RANGE_SET     *RangeSet
+    _Outptr_ PXENBUS_RANGE_SET  *RangeSet
     )
 {
     PXENBUS_RANGE_SET_CONTEXT   Context = Interface->Context;
@@ -822,11 +822,11 @@ static struct _XENBUS_RANGE_SET_INTERFACE_V1 RangeSetInterfaceVersion1 = {
 
 NTSTATUS
 RangeSetInitialize(
-    _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_RANGE_SET_CONTEXT *Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Outptr_ PXENBUS_RANGE_SET_CONTEXT  *Context
     )
 {
-    NTSTATUS                        status;
+    NTSTATUS                            status;
 
     Trace("====>\n");
 
diff --git a/src/xenbus/range_set.h b/src/xenbus/range_set.h
index 678afd7..63cd98e 100644
--- a/src/xenbus/range_set.h
+++ b/src/xenbus/range_set.h
@@ -43,8 +43,8 @@ typedef struct _XENBUS_RANGE_SET_CONTEXT  XENBUS_RANGE_SET_CONTEXT, *PXENBUS_RAN
 
 extern NTSTATUS
 RangeSetInitialize(
-    _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_RANGE_SET_CONTEXT *Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Outptr_ PXENBUS_RANGE_SET_CONTEXT  *Context
     );
 
 extern NTSTATUS
diff --git a/src/xenbus/shared_info.c b/src/xenbus/shared_info.c
index e85f4c1..06e0aec 100644
--- a/src/xenbus/shared_info.c
+++ b/src/xenbus/shared_info.c
@@ -844,11 +844,11 @@ static struct _XENBUS_SHARED_INFO_INTERFACE_V4 SharedInfoInterfaceVersion4 = {
 
 NTSTATUS
 SharedInfoInitialize(
-    _In_ PXENBUS_FDO                    Fdo,
-    _Out_ PXENBUS_SHARED_INFO_CONTEXT   *Context
+    _In_ PXENBUS_FDO                        Fdo,
+    _Outptr_ PXENBUS_SHARED_INFO_CONTEXT    *Context
     )
 {
-    NTSTATUS                            status;
+    NTSTATUS                                status;
 
     Trace("====>\n");
 
diff --git a/src/xenbus/shared_info.h b/src/xenbus/shared_info.h
index af4221c..8023c6f 100644
--- a/src/xenbus/shared_info.h
+++ b/src/xenbus/shared_info.h
@@ -43,8 +43,8 @@ typedef struct _XENBUS_SHARED_INFO_CONTEXT  XENBUS_SHARED_INFO_CONTEXT, *PXENBUS
 
 extern NTSTATUS
 SharedInfoInitialize(
-    _In_ PXENBUS_FDO                    Fdo,
-    _Out_ PXENBUS_SHARED_INFO_CONTEXT   *Context
+    _In_ PXENBUS_FDO                        Fdo,
+    _Outptr_ PXENBUS_SHARED_INFO_CONTEXT    *Context
     );
 
 extern NTSTATUS
diff --git a/src/xenbus/store.c b/src/xenbus/store.c
index 688e22f..0685feb 100644
--- a/src/xenbus/store.c
+++ b/src/xenbus/store.c
@@ -1497,15 +1497,15 @@ fail1:
 
 static NTSTATUS
 StoreTransactionStart(
-    _In_ PINTERFACE                 Interface,
-    _Out_ PXENBUS_STORE_TRANSACTION *Transaction
+    _In_ PINTERFACE                     Interface,
+    _Outptr_ PXENBUS_STORE_TRANSACTION  *Transaction
     )
 {
-    PXENBUS_STORE_CONTEXT           Context = Interface->Context;
-    XENBUS_STORE_REQUEST            Request;
-    PXENBUS_STORE_RESPONSE          Response;
-    KIRQL                           Irql;
-    NTSTATUS                        status;
+    PXENBUS_STORE_CONTEXT               Context = Interface->Context;
+    XENBUS_STORE_REQUEST                Request;
+    PXENBUS_STORE_RESPONSE              Response;
+    KIRQL                               Irql;
+    NTSTATUS                            status;
 
     *Transaction = __StoreAllocate(sizeof (XENBUS_STORE_TRANSACTION));
 
@@ -1656,21 +1656,21 @@ fail1:
 
 static NTSTATUS
 StoreWatchAdd(
-    _In_ PINTERFACE             Interface,
-    _In_opt_ PSTR               Prefix,
-    _In_ PSTR                   Node,
-    _In_ PKEVENT                Event,
-    _Out_ PXENBUS_STORE_WATCH   *Watch
+    _In_ PINTERFACE                 Interface,
+    _In_opt_ PSTR                   Prefix,
+    _In_ PSTR                       Node,
+    _In_ PKEVENT                    Event,
+    _Outptr_ PXENBUS_STORE_WATCH    *Watch
     )
 {
-    PXENBUS_STORE_CONTEXT       Context = Interface->Context;
-    ULONG                       Length;
-    PSTR                        Path;
-    CHAR                        Token[TOKEN_LENGTH];
-    XENBUS_STORE_REQUEST        Request;
-    PXENBUS_STORE_RESPONSE      Response;
-    KIRQL                       Irql;
-    NTSTATUS                    status;
+    PXENBUS_STORE_CONTEXT           Context = Interface->Context;
+    ULONG                           Length;
+    PSTR                            Path;
+    CHAR                            Token[TOKEN_LENGTH];
+    XENBUS_STORE_REQUEST            Request;
+    PXENBUS_STORE_RESPONSE          Response;
+    KIRQL                           Irql;
+    NTSTATUS                        status;
 
     *Watch = __StoreAllocate(sizeof (XENBUS_STORE_WATCH));
 
@@ -2706,13 +2706,13 @@ static struct _XENBUS_STORE_INTERFACE_V2 StoreInterfaceVersion2 = {
 
 NTSTATUS
 StoreInitialize(
-    _In_ PXENBUS_FDO            Fdo,
-    _Out_ PXENBUS_STORE_CONTEXT *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Outptr_ PXENBUS_STORE_CONTEXT  *Context
     )
 {
-    LARGE_INTEGER               Now;
-    ULONG                       Seed;
-    NTSTATUS                    status;
+    LARGE_INTEGER                   Now;
+    ULONG                           Seed;
+    NTSTATUS                        status;
 
     Trace("====>\n");
 
diff --git a/src/xenbus/store.h b/src/xenbus/store.h
index 7f75d1e..6348df5 100644
--- a/src/xenbus/store.h
+++ b/src/xenbus/store.h
@@ -43,8 +43,8 @@ typedef struct _XENBUS_STORE_CONTEXT  XENBUS_STORE_CONTEXT, *PXENBUS_STORE_CONTE
 
 extern NTSTATUS
 StoreInitialize(
-    _In_ PXENBUS_FDO            Fdo,
-    _Out_ PXENBUS_STORE_CONTEXT *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Outptr_ PXENBUS_STORE_CONTEXT  *Context
     );
 
 extern NTSTATUS
diff --git a/src/xenbus/suspend.c b/src/xenbus/suspend.c
index 55c00a2..510973b 100644
--- a/src/xenbus/suspend.c
+++ b/src/xenbus/suspend.c
@@ -83,7 +83,7 @@ SuspendRegister(
     _In_ XENBUS_SUSPEND_CALLBACK_TYPE   Type,
     _In_ VOID                           (*Function)(PVOID),
     _In_opt_ PVOID                      Argument,
-    _Out_ PXENBUS_SUSPEND_CALLBACK      *Callback
+    _Outptr_ PXENBUS_SUSPEND_CALLBACK   *Callback
     )
 {
     PXENBUS_SUSPEND_CONTEXT             Context = Interface->Context;
@@ -479,11 +479,11 @@ static struct _XENBUS_SUSPEND_INTERFACE_V1 SuspendInterfaceVersion1 = {
 
 NTSTATUS
 SuspendInitialize(
-    _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_SUSPEND_CONTEXT   *Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Outptr_ PXENBUS_SUSPEND_CONTEXT    *Context
     )
 {
-    NTSTATUS                        status;
+    NTSTATUS                            status;
 
     Trace("====>\n");
 
diff --git a/src/xenbus/suspend.h b/src/xenbus/suspend.h
index 4cfd107..0deb54d 100644
--- a/src/xenbus/suspend.h
+++ b/src/xenbus/suspend.h
@@ -43,8 +43,8 @@ typedef struct _XENBUS_SUSPEND_CONTEXT  XENBUS_SUSPEND_CONTEXT, *PXENBUS_SUSPEND
 
 extern NTSTATUS
 SuspendInitialize(
-    _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_SUSPEND_CONTEXT   *Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Outptr_ PXENBUS_SUSPEND_CONTEXT    *Context
     );
 
 extern NTSTATUS
diff --git a/src/xenbus/thread.c b/src/xenbus/thread.c
index 91b4057..2a3c190 100644
--- a/src/xenbus/thread.c
+++ b/src/xenbus/thread.c
@@ -121,7 +121,7 @@ NTSTATUS
 ThreadCreate(
     _In_ XENBUS_THREAD_FUNCTION Function,
     _In_ PVOID                  Context,
-    _Out_ PXENBUS_THREAD        *Thread
+    _Outptr_ PXENBUS_THREAD     *Thread
     )
 {
     HANDLE                      Handle;
diff --git a/src/xenbus/thread.h b/src/xenbus/thread.h
index 9e24f65..28d6f9d 100644
--- a/src/xenbus/thread.h
+++ b/src/xenbus/thread.h
@@ -44,7 +44,7 @@ extern NTSTATUS
 ThreadCreate(
     _In_ XENBUS_THREAD_FUNCTION Function,
     _In_ PVOID                  Context,
-    _Out_ PXENBUS_THREAD        *Thread
+    _Outptr_ PXENBUS_THREAD     *Thread
     );
 
 extern PKEVENT
diff --git a/src/xenbus/unplug.c b/src/xenbus/unplug.c
index 21cc122..ca58c31 100644
--- a/src/xenbus/unplug.c
+++ b/src/xenbus/unplug.c
@@ -271,7 +271,7 @@ static struct _XENBUS_UNPLUG_INTERFACE_V3 UnplugInterfaceVersion3 = {
 NTSTATUS
 UnplugInitialize(
     _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_UNPLUG_CONTEXT    *Context
+    _Outptr_ PXENBUS_UNPLUG_CONTEXT *Context
     )
 {
     NTSTATUS                        status;
diff --git a/src/xenbus/unplug.h b/src/xenbus/unplug.h
index 1cc6251..9af1e36 100644
--- a/src/xenbus/unplug.h
+++ b/src/xenbus/unplug.h
@@ -44,7 +44,7 @@ typedef struct _XENBUS_UNPLUG_CONTEXT  XENBUS_UNPLUG_CONTEXT, *PXENBUS_UNPLUG_CO
 extern NTSTATUS
 UnplugInitialize(
     _In_ PXENBUS_FDO                Fdo,
-    _Out_ PXENBUS_UNPLUG_CONTEXT    *Context
+    _Outptr_ PXENBUS_UNPLUG_CONTEXT *Context
     );
 
 extern NTSTATUS
diff --git a/src/xenfilt/emulated.c b/src/xenfilt/emulated.c
index f5e1cc4..9065364 100644
--- a/src/xenfilt/emulated.c
+++ b/src/xenfilt/emulated.c
@@ -227,7 +227,7 @@ EmulatedAddObject(
     _In_ PSTR                           InstanceID,
     _In_opt_ PSTR                       CompatibleIDs,
     _In_ XENFILT_EMULATED_OBJECT_TYPE   Type,
-    _Out_ PXENFILT_EMULATED_OBJECT      *EmulatedObject
+    _Outptr_ PXENFILT_EMULATED_OBJECT   *EmulatedObject
     )
 {
     KIRQL                               Irql;
@@ -468,10 +468,10 @@ static struct _XENFILT_EMULATED_INTERFACE_V2 EmulatedInterfaceVersion2 = {
 
 NTSTATUS
 EmulatedInitialize(
-    _Out_ PXENFILT_EMULATED_CONTEXT *Context
+    _Outptr_ PXENFILT_EMULATED_CONTEXT  *Context
     )
 {
-    NTSTATUS                        status;
+    NTSTATUS                            status;
 
     Trace("====>\n");
 
diff --git a/src/xenfilt/emulated.h b/src/xenfilt/emulated.h
index 686d542..9b02268 100644
--- a/src/xenfilt/emulated.h
+++ b/src/xenfilt/emulated.h
@@ -49,7 +49,7 @@ typedef struct _XENFILT_EMULATED_OBJECT XENFILT_EMULATED_OBJECT, *PXENFILT_EMULA
 
 extern NTSTATUS
 EmulatedInitialize(
-    _Out_ PXENFILT_EMULATED_CONTEXT *Context
+    _Outptr_ PXENFILT_EMULATED_CONTEXT  *Context
     );
 
 extern NTSTATUS
@@ -72,7 +72,7 @@ EmulatedAddObject(
     _In_ PSTR                           InstanceID,
     _In_opt_ PSTR                       CompatibleIDs,
     _In_ XENFILT_EMULATED_OBJECT_TYPE   Type,
-    _Out_ PXENFILT_EMULATED_OBJECT      *EmulatedObject
+    _Outptr_ PXENFILT_EMULATED_OBJECT   *EmulatedObject
     );
 
 extern VOID
diff --git a/src/xenfilt/thread.c b/src/xenfilt/thread.c
index 34bac05..3f3b008 100644
--- a/src/xenfilt/thread.c
+++ b/src/xenfilt/thread.c
@@ -121,7 +121,7 @@ NTSTATUS
 ThreadCreate(
     _In_ XENFILT_THREAD_FUNCTION    Function,
     _In_ PVOID                      Context,
-    _Out_ PXENFILT_THREAD           *Thread
+    _Outptr_ PXENFILT_THREAD        *Thread
     )
 {
     HANDLE                          Handle;
diff --git a/src/xenfilt/thread.h b/src/xenfilt/thread.h
index 2d6d784..9cc35a0 100644
--- a/src/xenfilt/thread.h
+++ b/src/xenfilt/thread.h
@@ -44,7 +44,7 @@ extern NTSTATUS
 ThreadCreate(
     _In_ XENFILT_THREAD_FUNCTION    Function,
     _In_ PVOID                      Context,
-    _Out_ PXENFILT_THREAD           *Thread
+    _Outptr_ PXENFILT_THREAD        *Thread
     );
 
 extern PKEVENT
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:22 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025012.1400778 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCg-0008G3-5h; Wed, 25 Jun 2025 14:34:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025012.1400778; Wed, 25 Jun 2025 14:34:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCf-0008FS-TY; Wed, 25 Jun 2025 14:34:21 +0000
Received: by outflank-mailman (input) for mailman id 1025012;
 Wed, 25 Jun 2025 14:34:21 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=uSjP=ZI=bounce.vates.tech=bounce-md_30504962.685c08e6.v1-a89337d4479341ef99d6ef5d9b3a32b1@srs-se1.protection.inumbo.net>)
 id 1uURCe-000871-W7
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:20 +0000
Received: from mail134-21.atl141.mandrillapp.com
 (mail134-21.atl141.mandrillapp.com [198.2.134.21])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 796db2d6-51d1-11f0-b894-0df219b8e170;
 Wed, 25 Jun 2025 16:34:18 +0200 (CEST)
Received: from pmta10.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail134-21.atl141.mandrillapp.com (Mailchimp) with ESMTP id
 4bS4866xgmz1XLP5F
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:14 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 a89337d4479341ef99d6ef5d9b3a32b1; Wed, 25 Jun 2025 14:34:14 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 796db2d6-51d1-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862055; x=1751132055;
	bh=Jy3A7IgvJKFJ26nhMkKrlSwgam3vA6NuY7IhuVGB0wo=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=t4aXTYMtQM2aOK71x24yWfc6pdJaE8+HaSvVq9md7jCzXlHSF3YqAzKTT0RHjI8Q9
	 pmWoqIKsDgkQhn8hcdJIIfnsNVfP0eXlp6cgv8cx92hlRqV5ydxqKZh0GrKSc6ZApx
	 VmI+dztBoZUVcUeVjOdF2y/sSyCD2KkyYJrYImjay14bOWsCuMssrou6YSojWVnOfS
	 DyejfBDJ0WHzoDPs7oHCHnoca3FZ/p5b/SqolsGfU7IBRP1+OKre3A4OXRh+TpKOAU
	 aReQY4fEpQARY/peRstcPtnm6IeMl4SHQXzZBjUOm7WjKpwP75vSydCtXWq1/VRWTV
	 kxIjeZ/MXBVVA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862055; x=1751122555; i=ngoc-tu.dinh@vates.tech;
	bh=Jy3A7IgvJKFJ26nhMkKrlSwgam3vA6NuY7IhuVGB0wo=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=CEwFwwrvdlpH1x2C90+9vQtK4YUnM94XC9JFowS6wZ+EH4do3TD763QP4KITrZKdu
	 ap+C9GIwnp/zWchN+YmbRwBTNh5D6kCGLrHShXQubO8wU6m4cFhCToUn3m4l/JJOPs
	 Idbcv2dCDym1VTnXroMqR665rRCiYAlFpJD/8A+B33FdsQd5fTusAQWiqKmFAaJlvq
	 BkKTbMiZTt7rMSgxrY6dF7cOCVR2+rB4Am+MZUgoXZsGaGyUZlb25udD5WFogq8r/i
	 n8+2dmiVUHXuGj15wwyb/hUX/9R5uqoRHV2i0w7weNHeACropxrHArSVNaO8gTybkU
	 XOWDy5BBmn1SQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2010/13]=20Check=20ParametersKey=20for=20null=20in=20FdoScan?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862054176
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-11-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
References: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.a89337d4479341ef99d6ef5d9b3a32b1?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:14 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

DriverGetParametersKey may return null.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenbus/fdo.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index c610231..c876eb6 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -1402,12 +1402,16 @@ FdoScan(
             StoreClasses = NULL;
         }
 
-        status = RegistryQuerySzValue(ParametersKey,
-                                      "SyntheticClasses",
-                                      NULL,
-                                      &SyntheticClasses);
-        if (!NT_SUCCESS(status))
+        if (ParametersKey != NULL) {
+            status = RegistryQuerySzValue(ParametersKey,
+                                          "SyntheticClasses",
+                                          NULL,
+                                          &SyntheticClasses);
+            if (!NT_SUCCESS(status))
+                SyntheticClasses = NULL;
+        } else {
             SyntheticClasses = NULL;
+        }
 
         Classes = FdoCombineAnsi(StoreClasses, SyntheticClasses);
 
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:22 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025011.1400782 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCg-0008FW-6E; Wed, 25 Jun 2025 14:34:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025011.1400782; Wed, 25 Jun 2025 14:34:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCf-0008F8-Rh; Wed, 25 Jun 2025 14:34:21 +0000
Received: by outflank-mailman (input) for mailman id 1025011;
 Wed, 25 Jun 2025 14:34:20 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=syrj=ZI=bounce.vates.tech=bounce-md_30504962.685c08e5.v1-98b9b7ecd61e482d8f397728b8cd6f62@srs-se1.protection.inumbo.net>)
 id 1uURCe-0008AM-OI
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:20 +0000
Received: from mail180-2.suw31.mandrillapp.com
 (mail180-2.suw31.mandrillapp.com [198.2.180.2])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 7a6482c6-51d1-11f0-a30f-13f23c93f187;
 Wed, 25 Jun 2025 16:34:19 +0200 (CEST)
Received: from pmta11.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail180-2.suw31.mandrillapp.com (Mailchimp) with ESMTP id 4bS485743BzS62RWV
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:13 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 98b9b7ecd61e482d8f397728b8cd6f62; Wed, 25 Jun 2025 14:34:13 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7a6482c6-51d1-11f0-a30f-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862054; x=1751132054;
	bh=kl2CWTtFMLN6gw5oLsuhnD1O7m2hLncp33JPdTr5zMs=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=ZqvOQfMrF2/F9m2b1xxUtxS1VvtRlm7njr84+nnLATKXG9oKgJeOA4eYJ9ka+Xhlt
	 4u2umxCKVWSUtOmbuvp1MHd17imxgj2U8FGR3s8Flt6ahO75jHpn3j3mUc2paolhMn
	 B9edxmNY8dcvgaJkPFH160vXlVzDQwibNMLJFW7g4BfAoQ/wyLvVNiCHomGBpLexBU
	 /ETjk1Kz3W6Cz1vdnlaYy/vaiUyhfuN+ASmJ+xMZ4dTJRUghC7fFnZf1dv7MGVsGj+
	 GdP+EoUVm3a4XJnkbI+Q5eKwN9ib+UeoNTkNaKhYkdvvzHOweftBKrHJN1sRgifaRU
	 vDtbYqt7qOkMw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862054; x=1751122554; i=ngoc-tu.dinh@vates.tech;
	bh=kl2CWTtFMLN6gw5oLsuhnD1O7m2hLncp33JPdTr5zMs=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=eVEfAVgmmURxYw0U5GC6ZbtWLe0zjMmhJPK2N4/LtiAcWXWbrKrUyCjM/mRyHMV4e
	 osABhUSqJlS9Dk64W1/Jm1lWeaEPsk8BGxhz8IX+hfmPJJ2rW6BnyR+69K3dt2SdDq
	 61x8Ut/cGkeJp35Sxn/LzYneCJR6DGulTE/RSl1OJj5vDUvXZne9fuWWn8bWsv8lMy
	 cC5Rb5uCNQUpx883l2ZMvJdmdWnXd+OFsPc2DWLpC4Je7GYux/+nWFZh0XK4dujQ+h
	 PtI7VqOHGHJW9dhmL//t60TWVpiRB3+bMw+PS1caWWDvKvyY8GbYLju65JvZI/1pFw
	 HYN1aUpNyeWAw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2006/13]=20registry:=20Suppress=20unannotated=20DriverEntry=20warning?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862053373
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-7-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
References: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.98b9b7ecd61e482d8f397728b8cd6f62?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:13 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

RegistryInitialize is not a DriverEntry.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/common/registry.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/common/registry.c b/src/common/registry.c
index 61dae0e..73581a3 100644
--- a/src/common/registry.c
+++ b/src/common/registry.c
@@ -62,6 +62,7 @@ __RegistryFree(
 }
 
 NTSTATUS
+#pragma prefast(suppress:28101) // unannotated DriverEntry function
 RegistryInitialize(
     _In_opt_ PDRIVER_OBJECT DriverObject,
     _In_ PUNICODE_STRING    Path
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:23 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025013.1400783 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCh-0008LK-3K; Wed, 25 Jun 2025 14:34:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025013.1400783; Wed, 25 Jun 2025 14:34:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCh-0008LC-00; Wed, 25 Jun 2025 14:34:23 +0000
Received: by outflank-mailman (input) for mailman id 1025013;
 Wed, 25 Jun 2025 14:34:21 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=xuTE=ZI=bounce.vates.tech=bounce-md_30504962.685c08e6.v1-2a6bbc80fddd4eb18fae370fa930db27@srs-se1.protection.inumbo.net>)
 id 1uURCf-0008AM-OR
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:21 +0000
Received: from mail180-2.suw31.mandrillapp.com
 (mail180-2.suw31.mandrillapp.com [198.2.180.2])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 7ab3641c-51d1-11f0-a30f-13f23c93f187;
 Wed, 25 Jun 2025 16:34:19 +0200 (CEST)
Received: from pmta11.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail180-2.suw31.mandrillapp.com (Mailchimp) with ESMTP id 4bS4861K42zS62RW1
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:14 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 2a6bbc80fddd4eb18fae370fa930db27; Wed, 25 Jun 2025 14:34:14 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7ab3641c-51d1-11f0-a30f-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862054; x=1751132054;
	bh=eP+QVHeR8Z0i4/qBYmVgqk00I+6PcH1uZc+3D/t8Apc=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=GG7PphszcEiG8vPu5GzeUEj6U0z7GvY8HrD6djSQnAwKdC3PXYzanqtPWARMHc2AJ
	 y1nYBKKlbGytNqoxNL06OWvFBMRKzfd4LKwvMXLNcwrkRp2Owgg9t/9C4Hs5SxVL7Q
	 TWxJQNVJ3UT8vOgXEwat20/JVVmLYBFcHpO1Yygqfoqp9tHjugThUc0IOENJMqUxnj
	 CUddvr7wVcUlI7Be88yqEVe2iSYTwrP+zSm59hXL6JQgmmIMeBs4R3yfrMd9IC1YhH
	 8Q4JdRRxKvIs8IhC8Z+mSLrhbnsuCIAqy1YfMclZfhk/jINuvHLoP5ldZ81Zj18YEI
	 EC7CKk+dEyyvA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862054; x=1751122554; i=ngoc-tu.dinh@vates.tech;
	bh=eP+QVHeR8Z0i4/qBYmVgqk00I+6PcH1uZc+3D/t8Apc=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=v7Du65gkYk8/BgSVPiNIzsN+pECPWZN5oAbSyBm3VOsjj+SWZ2rtOx6c3BixCPXep
	 vKTAG6dxZgB+dcMH/2g+bPAx9laKWrYJ333PRERd2oH1e09bOVDDmH8jfNTtR0ENVm
	 dAE3oplVJJefUE5X5mVMbm6zZ+VRu68kxvGj6+7dY9RaffEDJMcaaAXHEVLeOMBwuk
	 DXUk1Vdh7gD3URA6AutLTnGid0mmEARV+b7L0BK0PGKH+iP8umbJhUyIe1I3fDwAJU
	 sBUS9xJCKZEvUvMgxjRiNsUJNvbek+ONlomok4PLr0XXyTZ9LL3zR1nMbZV4BXZSnE
	 wIrjTV10q7YMw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2007/13]=20registry:=20Suppress=20uninitialized=20memory=20warnings?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862053571
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-8-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
References: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.2a6bbc80fddd4eb18fae370fa930db27?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:14 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

The registry functions will fail if the initial ZwQueryKey unexpectedly
succeeds.

While this may not happen in practice, do so to avoid having to suppress
compiler warnings.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/common/registry.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/common/registry.c b/src/common/registry.c
index 73581a3..7965233 100644
--- a/src/common/registry.c
+++ b/src/common/registry.c
@@ -386,11 +386,11 @@ RegistryOpenHardwareKey(
                         NULL,
                         0,
                         &Length);
-    if (status != STATUS_BUFFER_OVERFLOW &&
+    if (!NT_SUCCESS(status) &&
+        status != STATUS_BUFFER_OVERFLOW &&
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail2;
 
-#pragma prefast(suppress:6102)
     Info = __RegistryAllocate(Length + sizeof (WCHAR));
 
     status = STATUS_NO_MEMORY;
@@ -565,7 +565,6 @@ RegistryEnumerateSubKeys(
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail1;
 
-#pragma prefast(suppress:6102)
     Full = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -669,7 +668,6 @@ RegistryEnumerateValues(
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail1;
 
-#pragma prefast(suppress:6102)
     Full = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -810,11 +808,11 @@ RegistryQueryDwordValue(
                              NULL,
                              0,
                              &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
+    if (!NT_SUCCESS(status) &&
+        status != STATUS_BUFFER_OVERFLOW &&
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail2;
 
-#pragma prefast(suppress:6102)
     Partial = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -1038,11 +1036,11 @@ RegistryQuerySzValue(
                              NULL,
                              0,
                              &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
+    if (!NT_SUCCESS(status) &&
+        status != STATUS_BUFFER_OVERFLOW &&
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail2;
 
-#pragma prefast(suppress:6102)
     Value = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -1125,11 +1123,11 @@ RegistryQueryBinaryValue(
                              NULL,
                              0,
                              &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
+    if (!NT_SUCCESS(status) &&
+        status != STATUS_BUFFER_OVERFLOW &&
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail2;
 
-#pragma prefast(suppress:6102)
     Partial = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -1256,12 +1254,12 @@ RegistryQueryKeyName(
                         NULL,
                         0,
                         &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
+    if (!NT_SUCCESS(status) &&
+        status != STATUS_BUFFER_OVERFLOW &&
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail1;
 
     // Name information is not intrinsically NULL terminated
-#pragma prefast(suppress:6102)
     Value = __RegistryAllocate(Size + sizeof (WCHAR));
 
     status = STATUS_NO_MEMORY;
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:24 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025014.1400788 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCi-0008PJ-4V; Wed, 25 Jun 2025 14:34:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025014.1400788; Wed, 25 Jun 2025 14:34:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCi-0008Oy-1Q; Wed, 25 Jun 2025 14:34:24 +0000
Received: by outflank-mailman (input) for mailman id 1025014;
 Wed, 25 Jun 2025 14:34:22 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=mUwF=ZI=bounce.vates.tech=bounce-md_30504962.685c08e6.v1-86ecd9e7670f470ea3223320474b7665@srs-se1.protection.inumbo.net>)
 id 1uURCg-0008AM-Ol
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:22 +0000
Received: from mail134-21.atl141.mandrillapp.com
 (mail134-21.atl141.mandrillapp.com [198.2.134.21])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 7926768d-51d1-11f0-a30f-13f23c93f187;
 Wed, 25 Jun 2025 16:34:18 +0200 (CEST)
Received: from pmta10.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail134-21.atl141.mandrillapp.com (Mailchimp) with ESMTP id
 4bS4863K2Xz1XLP5N
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:14 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 86ecd9e7670f470ea3223320474b7665; Wed, 25 Jun 2025 14:34:14 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7926768d-51d1-11f0-a30f-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862054; x=1751132054;
	bh=j3okVXKirj90Kd19zQj8IvMJ2Bvze16zr4cirlrM1iI=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=nUPxlSmONPVW3p9WvwjHFW6OtOH0wGlaCnrnEkFqfAmhDaCJbneRCVtksDZEg0NeY
	 V4Gkt1KmuciMTXVavTbPGW5HuMGd29phkPs4ap+SDEvInoxpZO5i8ujrUXylRVdkpy
	 CpUwM8YfShLH6suRytQQQlhGNxPMFDNpVTO5HEiMzdBFd/Z75mcy9PNuYMaGnE2zol
	 ayZswe/hr7xCXTjFrjgMVkzpukP+WKMTpWfBJotKvfsFoIDvSvYcAzsxBOFzLPKQMZ
	 t3w/II+SjvjVmrsiXoOEubFYYmqSmL1wLlq9rX9p0rePtE98czGOiKzFe6TFWWKqz0
	 3tckzZeCh5iUA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862054; x=1751122554; i=ngoc-tu.dinh@vates.tech;
	bh=j3okVXKirj90Kd19zQj8IvMJ2Bvze16zr4cirlrM1iI=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=RZxTacd0lpjVsveIHoYVRQCZg5xvigmnQR8QBNUr4Wlk4a8i1qfi4KKWSUUs7GyZI
	 rEFwJoQKUsbItIDH/K8XYQJ8RVp6F2iVg/NumQyCUQEPBI7E8kFVYSs68F5WHBm7bn
	 TeuijkpBfnPHKScfbv00E3pydTuMtQWxPqrWYX+c0zgfaOxbqFe6y8qzbQqQ1kCPj6
	 maoSRCd6FoHWF7qzS3HYN/NqkRMGFkxIDQuhZ6J1QvWWlDgnmcUaTiNgqFk7OShyex
	 NFjdP8tl7jx3c/+ZWYbah+89u8VNTcw5MFhLF8C/Gdx7bLj5zJvE2howC+vx9xVGr9
	 gj94XAoVMuosw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2008/13]=20Fix=20missing=20return=20types?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862053761
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-9-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
References: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.86ecd9e7670f470ea3223320474b7665?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:14 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

StoreGetAddress and ConsoleGetAddress should return NTSTATUS.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenbus/console.c | 2 +-
 src/xenbus/store.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/xenbus/console.c b/src/xenbus/console.c
index 80e8b69..2d747cb 100644
--- a/src/xenbus/console.c
+++ b/src/xenbus/console.c
@@ -381,7 +381,7 @@ fail1:
     return status;
 }
 
-static
+static NTSTATUS
 ConsoleGetAddress(
     _In_ PXENBUS_CONSOLE_CONTEXT    Context,
     _Out_ PPHYSICAL_ADDRESS         Address
diff --git a/src/xenbus/store.c b/src/xenbus/store.c
index 0685feb..b0f2332 100644
--- a/src/xenbus/store.c
+++ b/src/xenbus/store.c
@@ -2235,7 +2235,7 @@ StoreEnable(
         Context->Dpcs++;
 }
 
-static
+static NTSTATUS
 StoreGetAddress(
     _In_ PXENBUS_STORE_CONTEXT  Context,
     _Out_ PPHYSICAL_ADDRESS     Address
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:25 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025015.1400792 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCj-0008SR-8f; Wed, 25 Jun 2025 14:34:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025015.1400792; Wed, 25 Jun 2025 14:34:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCj-0008SI-46; Wed, 25 Jun 2025 14:34:25 +0000
Received: by outflank-mailman (input) for mailman id 1025015;
 Wed, 25 Jun 2025 14:34:23 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=OGaF=ZI=bounce.vates.tech=bounce-md_30504962.685c08e5.v1-e5f937f658a64da0a9e364ed695d2e6e@srs-se1.protection.inumbo.net>)
 id 1uURCf-000871-W8
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:23 +0000
Received: from mail180-2.suw31.mandrillapp.com
 (mail180-2.suw31.mandrillapp.com [198.2.180.2])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 79b51c90-51d1-11f0-b894-0df219b8e170;
 Wed, 25 Jun 2025 16:34:18 +0200 (CEST)
Received: from pmta11.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail180-2.suw31.mandrillapp.com (Mailchimp) with ESMTP id 4bS4856YrwzS62RW5
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:13 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 e5f937f658a64da0a9e364ed695d2e6e; Wed, 25 Jun 2025 14:34:13 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 79b51c90-51d1-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862054; x=1751132054;
	bh=t8O9+EATpQ2W1Jxh9KniGQj3e7OF2YvFl6Peq+S+wC8=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=TUY0zdeZ/RjLUQ/UDVn71RpdWubmgTcI02c5zc9oj6X51Xlo2j1rxdzRPkMqErvz6
	 TT87Cphey3mmBobpPbGv86pSh3EDalO1nEdi83HTvp7nyf4O1LfR1tIzfyE+SfDFav
	 nw7nL/NfTeSV0JbyX1uAZSvxlekZ+rnfEWHrJvc25M2Y8HYGDbpJYLJBcCQEguYpbl
	 5I1zY03JdN78RbLHgBGMVmzcBhQHljv6RYE31SxmfydGUnV9mwJ17btf3UhtDjZJR8
	 k1KEr8QjKfkTtoSPfOChky0FgesFtg/GrQfNs/VGAdFSdXZ2S/AdjqRvNxOpSKRf3F
	 3NQknSo7Sx1wA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862054; x=1751122554; i=ngoc-tu.dinh@vates.tech;
	bh=t8O9+EATpQ2W1Jxh9KniGQj3e7OF2YvFl6Peq+S+wC8=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=IZOVsZddG00CzfVRsrND7IDQuhhiZYJXaTfyWEzZRp8tZ3VCiACW4YC/Ea4Lsu82V
	 Ae2S91+Ar2cv+p5/ozVsJOhwxv4gPUhFTAcpoE2vbGd+IeeTe5lr57D1WfavZO4btM
	 ERfVKCwr9FEwWx9sidAeecYJ5x3XmIojOZ+tp6nrSrD1rOWW66aB9F26sUh4CQV9OM
	 7LP3KnTlaPn6rzIYdPQwZUo5J5QdJ5+LB5NXly8ldC5y2bcubR3cCl7G+Xxw6HCypv
	 /eK2jD+Cob55MTvrqEPZzEH2E2PLx9VgUVQkheqyhgVBjdZYaurUiEQjoO5p3yQnf3
	 odvLeJGEsJjig==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2001/13]=20Replace=20old=20annotations=20with=20SAL2=20equivalents?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862051744
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-2-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
References: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.e5f937f658a64da0a9e364ed695d2e6e?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:13 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

* Do a mechanical search-and-replace, where IN and OUT are replaced with
  _In_ and _Out_ respectively
* Parameters annotated with OPTIONAL use the _opt_ equivalents
* Replace __drv IRQL annotations with the _IRQL_ ones
* Existing functions with function class declarations are converted to
  a predeclaration and _Use_decl_annotations_ to check for mismatch

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 include/balloon_interface.h     |  68 +--
 include/cache_interface.h       | 130 ++---
 include/console_interface.h     |  30 +-
 include/debug_interface.h       |  88 ++--
 include/emulated_interface.h    |  78 +--
 include/evtchn_interface.h      | 136 ++---
 include/gnttab_interface.h      | 148 +++---
 include/range_set_interface.h   | 100 ++--
 include/shared_info_interface.h | 106 ++--
 include/store_interface.h       | 156 +++---
 include/suspend_interface.h     |  80 +--
 include/unplug_interface.h      |  72 +--
 include/xen.h                   | 330 ++++++------
 src/common/assert.h             |  72 +--
 src/common/dbg_print.h          |  62 +--
 src/common/high.h               |  63 ++-
 src/common/mutex.h              |  60 +--
 src/common/names.h              |  82 +--
 src/common/registry.c           | 218 ++++----
 src/common/registry.h           | 186 +++----
 src/common/util.h               |  54 +-
 src/monitor/monitor.c           |  43 +-
 src/xen/acpi.c                  |  60 +--
 src/xen/acpi.h                  |  52 +-
 src/xen/bug_check.c             | 149 +++---
 src/xen/config.c                |  26 +-
 src/xen/driver.c                | 120 ++---
 src/xen/driver.h                |   6 +-
 src/xen/event_channel.c         | 116 ++---
 src/xen/filters.c               |  16 +-
 src/xen/grant_table.c           |  90 ++--
 src/xen/hvm.c                   |  80 +--
 src/xen/log.c                   | 140 ++---
 src/xen/memory.c                |  78 +--
 src/xen/module.c                |  84 +--
 src/xen/process.c               |  56 +-
 src/xen/process.h               |  48 +-
 src/xen/sched.c                 |  64 +--
 src/xen/system.c                | 119 ++---
 src/xen/unplug.c                |  30 +-
 src/xen/vcpu.c                  |  20 +-
 src/xen/xen_version.c           |  66 +--
 src/xenbus/balloon.c            | 214 ++++----
 src/xenbus/balloon.h            |  62 +--
 src/xenbus/bus.c                | 138 ++---
 src/xenbus/bus.h                |  52 +-
 src/xenbus/cache.c              | 218 ++++----
 src/xenbus/cache.h              |  62 +--
 src/xenbus/console.c            | 136 ++---
 src/xenbus/console.h            |  16 +-
 src/xenbus/debug.c              | 134 ++---
 src/xenbus/debug.h              |  62 +--
 src/xenbus/dma.c                | 521 +++++++++----------
 src/xenbus/dma.h                |  54 +-
 src/xenbus/driver.c             |  97 ++--
 src/xenbus/driver.h             |  50 +-
 src/xenbus/evtchn.c             | 244 ++++-----
 src/xenbus/evtchn.h             |  64 +--
 src/xenbus/evtchn_2l.c          |  96 ++--
 src/xenbus/evtchn_2l.h          |  56 +-
 src/xenbus/evtchn_abi.h         |  86 ++--
 src/xenbus/evtchn_fifo.c        | 172 +++----
 src/xenbus/evtchn_fifo.h        |  56 +-
 src/xenbus/fdo.c                | 886 ++++++++++++++++----------------
 src/xenbus/fdo.h                | 176 +++----
 src/xenbus/gnttab.c             | 200 +++----
 src/xenbus/gnttab.h             |  62 +--
 src/xenbus/hash_table.c         | 100 ++--
 src/xenbus/hash_table.h         |  68 +--
 src/xenbus/pdo.c                | 374 +++++++-------
 src/xenbus/pdo.h                | 114 ++--
 src/xenbus/range_set.c          | 160 +++---
 src/xenbus/range_set.h          |  62 +--
 src/xenbus/shared_info.c        | 152 +++---
 src/xenbus/shared_info.h        |  62 +--
 src/xenbus/store.c              | 436 ++++++++--------
 src/xenbus/store.h              |  62 +--
 src/xenbus/suspend.c            | 108 ++--
 src/xenbus/suspend.h            |  62 +--
 src/xenbus/sync.c               |  98 ++--
 src/xenbus/sync.h               |  74 +--
 src/xenbus/thread.c             |  74 +--
 src/xenbus/thread.h             |  64 +--
 src/xenbus/unplug.c             |  52 +-
 src/xenbus/unplug.h             |  16 +-
 src/xenfilt/driver.c            | 110 ++--
 src/xenfilt/driver.h            |  66 +--
 src/xenfilt/emulated.c          | 126 ++---
 src/xenfilt/emulated.h          |  74 +--
 src/xenfilt/fdo.c               | 278 +++++-----
 src/xenfilt/fdo.h               |  76 +--
 src/xenfilt/pdo.c               | 293 +++++------
 src/xenfilt/pdo.h               |  80 +--
 src/xenfilt/thread.c            |  78 +--
 src/xenfilt/thread.h            |  64 +--
 95 files changed, 5555 insertions(+), 5524 deletions(-)

diff --git a/include/balloon_interface.h b/include/balloon_interface.h
index b9a64c6..ad2c20d 100644
--- a/include/balloon_interface.h
+++ b/include/balloon_interface.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -46,20 +46,20 @@
     \brief Acquire a reference to the BALLOON interface
 
     \param Interface The interface header
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_BALLOON_ACQUIRE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_BALLOON_RELEASE
     \brief Release a reference to the BALLOON interface
 
     \param Interface The interface header
-*/  
+*/
 typedef VOID
 (*XENBUS_BALLOON_RELEASE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_BALLOON_ADJUST
@@ -67,31 +67,31 @@ typedef VOID
 
     \param Interface The interface header
     \param Size The target size of the balloon in pages
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_BALLOON_ADJUST)(
-    IN  PINTERFACE  Interface,
-    IN  ULONGLONG   Size
+    _In_ PINTERFACE Interface,
+    _In_ ULONGLONG  Size
     );
 
 /*! \typedef XENBUS_BALLOON_GET_SIZE
     \brief Return the current size of the balloon in pages
 
     \param Interface The interface header
-*/  
+*/
 typedef ULONGLONG
 (*XENBUS_BALLOON_GET_SIZE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 // {D92AA810-BECB-4BD5-A3DA-BD03C135A297}
-DEFINE_GUID(GUID_XENBUS_BALLOON_INTERFACE, 
+DEFINE_GUID(GUID_XENBUS_BALLOON_INTERFACE,
 0xd92aa810, 0xbecb, 0x4bd5, 0xa3, 0xda, 0xbd, 0x3, 0xc1, 0x35, 0xa2, 0x97);
 
 /*! \struct _XENBUS_BALLOON_INTERFACE_V1
     \brief BALLOON interface version 1
     \ingroup interfaces
-*/  
+*/
 struct _XENBUS_BALLOON_INTERFACE_V1 {
     INTERFACE                   Interface;
     XENBUS_BALLOON_ACQUIRE      BalloonAcquire;
diff --git a/include/cache_interface.h b/include/cache_interface.h
index 97fa315..dcf0222 100644
--- a/include/cache_interface.h
+++ b/include/cache_interface.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -51,20 +51,20 @@ typedef struct _XENBUS_CACHE    XENBUS_CACHE, *PXENBUS_CACHE;
     \brief Acquire a reference to the CACHE interface
 
     \param Interface The interface header
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_CACHE_ACQUIRE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_CACHE_RELEASE
     \brief Release a reference to the CACHE interface
 
     \param Interface The interface header
-*/  
+*/
 typedef VOID
 (*XENBUS_CACHE_RELEASE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_CACHE_CTOR
@@ -79,8 +79,8 @@ typedef VOID
 */
 typedef NTSTATUS
 (*XENBUS_CACHE_CTOR)(
-    IN  PVOID   Argument,
-    IN  PVOID   Object
+    _In_ PVOID  Argument,
+    _In_ PVOID  Object
     );
 
 /*! \typedef XENBUS_CACHE_DTOR
@@ -94,8 +94,8 @@ typedef NTSTATUS
 */
 typedef VOID
 (*XENBUS_CACHE_DTOR)(
-    IN  PVOID   Argument,
-    IN  PVOID   Object
+    _In_ PVOID  Argument,
+    _In_ PVOID  Object
     );
 
 /*! \typedef XENBUS_CACHE_ACQUIRE_LOCK
@@ -108,7 +108,7 @@ typedef VOID
 */
 typedef VOID
 (*XENBUS_CACHE_ACQUIRE_LOCK)(
-    IN  PVOID   Argument
+    _In_ PVOID  Argument
     );
 
 /*! \typedef XENBUS_CACHE_RELEASE_LOCK
@@ -121,21 +121,21 @@ typedef VOID
 */
 typedef VOID
 (*XENBUS_CACHE_RELEASE_LOCK)(
-    IN  PVOID   Argument
+    _In_ PVOID  Argument
     );
 
 typedef NTSTATUS
 (*XENBUS_CACHE_CREATE_V1)(
-    IN  PINTERFACE                  Interface,
-    IN  const CHAR                  *Name,
-    IN  ULONG                       Size,
-    IN  ULONG                       Reservation,
-    IN  XENBUS_CACHE_CTOR           Ctor,
-    IN  XENBUS_CACHE_DTOR           Dtor,
-    IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
-    IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
-    IN  PVOID                       Argument OPTIONAL,
-    OUT PXENBUS_CACHE               *Cache
+    _In_ PINTERFACE                 Interface,
+    _In_ const CHAR                 *Name,
+    _In_ ULONG                      Size,
+    _In_ ULONG                      Reservation,
+    _In_ XENBUS_CACHE_CTOR          Ctor,
+    _In_ XENBUS_CACHE_DTOR          Dtor,
+    _In_ XENBUS_CACHE_ACQUIRE_LOCK  AcquireLock,
+    _In_ XENBUS_CACHE_RELEASE_LOCK  ReleaseLock,
+    _In_opt_ PVOID                  Argument,
+    _Out_ PXENBUS_CACHE             *Cache
     );
 
 /*! \typedef XENBUS_CACHE_CREATE
@@ -155,20 +155,20 @@ typedef NTSTATUS
 
     If a non-zero \a Reservation is specified then this method will fail
     unless that number of objects can be immediately created.
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_CACHE_CREATE)(
-    IN  PINTERFACE                  Interface,
-    IN  const CHAR                  *Name,
-    IN  ULONG                       Size,
-    IN  ULONG                       Reservation,
-    IN  ULONG                       Cap,
-    IN  XENBUS_CACHE_CTOR           Ctor,
-    IN  XENBUS_CACHE_DTOR           Dtor,
-    IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
-    IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
-    IN  PVOID                       Argument OPTIONAL,
-    OUT PXENBUS_CACHE               *Cache
+    _In_ PINTERFACE                 Interface,
+    _In_ const CHAR                 *Name,
+    _In_ ULONG                      Size,
+    _In_ ULONG                      Reservation,
+    _In_ ULONG                      Cap,
+    _In_ XENBUS_CACHE_CTOR          Ctor,
+    _In_ XENBUS_CACHE_DTOR          Dtor,
+    _In_ XENBUS_CACHE_ACQUIRE_LOCK  AcquireLock,
+    _In_ XENBUS_CACHE_RELEASE_LOCK  ReleaseLock,
+    _In_opt_ PVOID                  Argument,
+    _Out_ PXENBUS_CACHE             *Cache
     );
 
 /*! \typedef XENBUS_CACHE_GET
@@ -181,9 +181,9 @@ typedef NTSTATUS
 */
 typedef PVOID
 (*XENBUS_CACHE_GET)(
-    IN  PINTERFACE      Interface,
-    IN  PXENBUS_CACHE   Cache,
-    IN  BOOLEAN         Locked
+    _In_ PINTERFACE     Interface,
+    _In_ PXENBUS_CACHE  Cache,
+    _In_ BOOLEAN        Locked
     );
 
 /*! \typedef XENBUS_CACHE_PUT
@@ -196,10 +196,10 @@ typedef PVOID
 */
 typedef VOID
 (*XENBUS_CACHE_PUT)(
-    IN  PINTERFACE      Interface,
-    IN  PXENBUS_CACHE   Cache,
-    IN  PVOID           Object,
-    IN  BOOLEAN         Locked
+    _In_ PINTERFACE     Interface,
+    _In_ PXENBUS_CACHE  Cache,
+    _In_ PVOID          Object,
+    _In_ BOOLEAN        Locked
     );
 
 /*! \typedef XENBUS_CACHE_DESTROY
@@ -212,12 +212,12 @@ typedef VOID
 */
 typedef VOID
 (*XENBUS_CACHE_DESTROY)(
-    IN  PINTERFACE      Interface,
-    IN  PXENBUS_CACHE   Cache
+    _In_ PINTERFACE     Interface,
+    _In_ PXENBUS_CACHE  Cache
     );
 
 // {A98DFD78-416A-4949-92A5-E084F2F4B44E}
-DEFINE_GUID(GUID_XENBUS_CACHE_INTERFACE, 
+DEFINE_GUID(GUID_XENBUS_CACHE_INTERFACE,
 0xa98dfd78, 0x416a, 0x4949, 0x92, 0xa5, 0xe0, 0x84, 0xf2, 0xf4, 0xb4, 0x4e);
 
 /*! \struct _XENBUS_CACHE_INTERFACE_V1
diff --git a/include/console_interface.h b/include/console_interface.h
index 6b4ba7a..9235862 100644
--- a/include/console_interface.h
+++ b/include/console_interface.h
@@ -53,7 +53,7 @@ typedef struct _XENBUS_CONSOLE_WAKEUP   XENBUS_CONSOLE_WAKEUP, *PXENBUS_CONSOLE_
 */
 typedef NTSTATUS
 (*XENBUS_CONSOLE_ACQUIRE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_CONSOLE_RELEASE
@@ -63,7 +63,7 @@ typedef NTSTATUS
 */
 typedef VOID
 (*XENBUS_CONSOLE_RELEASE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_CONSOLE_CAN_READ
@@ -75,7 +75,7 @@ typedef VOID
 */
 typedef BOOLEAN
 (*XENBUS_CONSOLE_CAN_READ)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_CONSOLE_READ
@@ -89,9 +89,9 @@ typedef BOOLEAN
 */
 typedef ULONG
 (*XENBUS_CONSOLE_READ)(
-    IN  PINTERFACE  Interface,
-    IN  PCHAR       Data,
-    IN  ULONG       Length
+    _In_ PINTERFACE Interface,
+    _In_ PCHAR      Data,
+    _In_ ULONG      Length
     );
 
 /*! \typedef XENBUS_CONSOLE_CAN_WRITE
@@ -103,7 +103,7 @@ typedef ULONG
 */
 typedef BOOLEAN
 (*XENBUS_CONSOLE_CAN_WRITE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_CONSOLE_WRITE
@@ -117,9 +117,9 @@ typedef BOOLEAN
 */
 typedef ULONG
 (*XENBUS_CONSOLE_WRITE)(
-    IN  PINTERFACE  Interface,
-    IN  PCHAR       Data,
-    IN  ULONG       Length
+    _In_ PINTERFACE Interface,
+    _In_ PCHAR      Data,
+    _In_ ULONG      Length
     );
 
 /*! \typedef XENBUS_CONSOLE_WAKEUP_ADD
@@ -132,9 +132,9 @@ typedef ULONG
 */
 typedef NTSTATUS
 (*XENBUS_CONSOLE_WAKEUP_ADD)(
-    IN  PINTERFACE          	Interface,
-    IN  PKEVENT             	Event,
-    OUT PXENBUS_CONSOLE_WAKEUP	*Wakeup
+    _In_ PINTERFACE                 Interface,
+    _In_ PKEVENT                    Event,
+    _Out_ PXENBUS_CONSOLE_WAKEUP    *Wakeup
     );
 
 /*! \typedef XENBUS_CONSOLE_WAKEUP_REMOVE
@@ -145,8 +145,8 @@ typedef NTSTATUS
 */
 typedef VOID
 (*XENBUS_CONSOLE_WAKEUP_REMOVE)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_CONSOLE_WAKEUP  Wakeup
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_CONSOLE_WAKEUP Wakeup
     );
 
 // {04c4f738-034a-4268-bd20-a92ac90d4f82}
diff --git a/include/debug_interface.h b/include/debug_interface.h
index 79729c7..77f40ba 100644
--- a/include/debug_interface.h
+++ b/include/debug_interface.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -50,20 +50,20 @@ typedef struct _XENBUS_DEBUG_CALLBACK   XENBUS_DEBUG_CALLBACK, *PXENBUS_DEBUG_CA
     \brief Acquire a reference to the DEBUG interface
 
     \param Interface The interface header
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_DEBUG_ACQUIRE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_DEBUG_RELEASE
     \brief Release a reference to the DEBUG interface
 
     \param Interface The interface header
-*/  
+*/
 typedef VOID
 (*XENBUS_DEBUG_RELEASE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_DEBUG_FUNCTION
@@ -74,11 +74,11 @@ typedef VOID
     part of pre-crash logging
 
     Debug callback functions are always invoked with IRQL == HIGH_LEVEL
-*/  
+*/
 typedef VOID
 (*XENBUS_DEBUG_FUNCTION)(
-    IN  PVOID   Argument,
-    IN  BOOLEAN Crashing
+    _In_ PVOID      Argument,
+    _In_ BOOLEAN    Crashing
     );
 
 /*! \typedef XENBUS_DEBUG_REGISTER
@@ -89,14 +89,14 @@ typedef VOID
     \param Function The callback function
     \param Argument An optional context argument passed to the callback
     \param Callback A pointer to a callback handle to be initialized
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_DEBUG_REGISTER)(
-    IN  PINTERFACE              Interface,
-    IN  PCHAR                   Prefix,
-    IN  XENBUS_DEBUG_FUNCTION   Function,
-    IN  PVOID                   Argument OPTIONAL,
-    OUT PXENBUS_DEBUG_CALLBACK  *Callback
+    _In_ PINTERFACE                 Interface,
+    _In_ PCHAR                      Prefix,
+    _In_ XENBUS_DEBUG_FUNCTION      Function,
+    _In_opt_ PVOID                  Argument,
+    _Out_ PXENBUS_DEBUG_CALLBACK    *Callback
     );
 
 /*! \typedef XENBUS_DEBUG_PRINTF
@@ -108,11 +108,11 @@ typedef NTSTATUS
 
     This method must only be invoked from the context of a debug
     callback
-*/  
+*/
 typedef VOID
 (*XENBUS_DEBUG_PRINTF)(
-    IN  PINTERFACE              Interface,
-    IN  const CHAR              *Format,
+    _In_ PINTERFACE             Interface,
+    _In_ const CHAR             *Format,
     ...
     );
 
@@ -124,8 +124,8 @@ typedef VOID
 */
 typedef VOID
 (*XENBUS_DEBUG_DEREGISTER)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_DEBUG_CALLBACK  Callback
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_DEBUG_CALLBACK Callback
     );
 
 /*! \typedef XENBUS_DEBUG_TRIGGER
@@ -137,12 +137,12 @@ typedef VOID
 */
 typedef VOID
 (*XENBUS_DEBUG_TRIGGER)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_DEBUG_CALLBACK  Callback OPTIONAL
+    _In_ PINTERFACE                 Interface,
+    _In_opt_ PXENBUS_DEBUG_CALLBACK Callback
     );
 
 // {0DF600AE-6B20-4227-BF94-03DA9A26A114}
-DEFINE_GUID(GUID_XENBUS_DEBUG_INTERFACE, 
+DEFINE_GUID(GUID_XENBUS_DEBUG_INTERFACE,
 0xdf600ae, 0x6b20, 0x4227, 0xbf, 0x94, 0x3, 0xda, 0x9a, 0x26, 0xa1, 0x14);
 
 /*! \struct _XENBUS_DEBUG_INTERFACE_V1
diff --git a/include/emulated_interface.h b/include/emulated_interface.h
index ad5975d..7920c44 100644
--- a/include/emulated_interface.h
+++ b/include/emulated_interface.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -46,20 +46,20 @@
     \brief Acquire a reference to the EMULATED interface
 
     \param Interface The interface header
-*/  
+*/
 typedef NTSTATUS
 (*XENFILT_EMULATED_ACQUIRE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENFILT_EMULATED_RELEASE
     \brief Release a reference to the EMULATED interface
 
     \param Interface The interface header
-*/  
+*/
 typedef VOID
 (*XENFILT_EMULATED_RELEASE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENFILT_EMULATED_IS_DEVICE_PRESENT
@@ -71,20 +71,20 @@ typedef VOID
            NULL to match any device instance
     \return TRUE if the specified device is present in the system or
     FALSE if it is not
-*/  
+*/
 typedef BOOLEAN
 (*XENFILT_EMULATED_IS_DEVICE_PRESENT)(
-    IN  PVOID   Context,
-    IN  PCHAR   DeviceID,
-    IN  PCHAR   InstanceID OPTIONAL
+    _In_ PVOID      Context,
+    _In_ PCHAR      DeviceID,
+    _In_opt_ PCHAR  InstanceID
     );
 
 typedef BOOLEAN
 (*XENFILT_EMULATED_IS_DISK_PRESENT_V1)(
-    IN  PVOID   Context,
-    IN  ULONG   Controller,
-    IN  ULONG   Target,
-    IN  ULONG   Lun
+    _In_ PVOID  Context,
+    _In_ ULONG  Controller,
+    _In_ ULONG  Target,
+    _In_ ULONG  Lun
     );
 /*! \typedef XENFILT_EMULATED_IS_DISK_PRESENT
     \brief Determine whether a given emulated disk is present in the VM
@@ -94,15 +94,15 @@ typedef BOOLEAN
                  emulated device is aliasing
     \return TRUE if an emulated disk aliasing the specified paravirtual
     disk index is present in the system or FALSE if not
-*/  
+*/
 typedef BOOLEAN
 (*XENFILT_EMULATED_IS_DISK_PRESENT)(
-    IN  PVOID   Context,
-    IN  ULONG   Index
+    _In_ PVOID  Context,
+    _In_ ULONG  Index
     );
 
 // {959027A1-FCCE-4E78-BCF4-637384F499C5}
-DEFINE_GUID(GUID_XENFILT_EMULATED_INTERFACE, 
+DEFINE_GUID(GUID_XENFILT_EMULATED_INTERFACE,
 0x959027a1, 0xfcce, 0x4e78, 0xbc, 0xf4, 0x63, 0x73, 0x84, 0xf4, 0x99, 0xc5);
 
 /*! \struct _XENFILT_EMULATED_INTERFACE_V1
diff --git a/include/evtchn_interface.h b/include/evtchn_interface.h
index ef67487..5c46f97 100644
--- a/include/evtchn_interface.h
+++ b/include/evtchn_interface.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -54,27 +54,27 @@ typedef enum _XENBUS_EVTCHN_TYPE {
 
 /*! \typedef XENBUS_EVTCHN_CHANNEL
     \brief Event channel handle
-*/  
+*/
 typedef struct _XENBUS_EVTCHN_CHANNEL XENBUS_EVTCHN_CHANNEL, *PXENBUS_EVTCHN_CHANNEL;
 
 /*! \typedef XENBUS_EVTCHN_ACQUIRE
     \brief Acquire a reference to the EVTCHN interface
 
     \param Interface The interface header
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_EVTCHN_ACQUIRE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_EVTCHN_RELEASE
     \brief Release a reference to the EVTCHN interface
 
     \param Interface The interface header
-*/  
+*/
 typedef VOID
 (*XENBUS_EVTCHN_RELEASE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_EVTCHN_OPEN
@@ -105,13 +105,13 @@ typedef VOID
     \param Number The relative number of the CPU that should handle the VIRQ
 
     \return Event channel handle
-*/  
+*/
 typedef PXENBUS_EVTCHN_CHANNEL
 (*XENBUS_EVTCHN_OPEN)(
-    IN  PINTERFACE          Interface,
-    IN  XENBUS_EVTCHN_TYPE  Type,
-    IN  PKSERVICE_ROUTINE   Function,
-    IN  PVOID               Argument OPTIONAL,
+    _In_ PINTERFACE         Interface,
+    _In_ XENBUS_EVTCHN_TYPE Type,
+    _In_ PKSERVICE_ROUTINE  Function,
+    _In_opt_ PVOID          Argument,
     ...
     );
 
@@ -125,17 +125,17 @@ typedef PXENBUS_EVTCHN_CHANNEL
 */
 typedef NTSTATUS
 (*XENBUS_EVTCHN_BIND)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  USHORT                  Group,
-    IN  UCHAR                   Number
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ USHORT                 Group,
+    _In_ UCHAR                  Number
     );
 
 typedef VOID
 (*XENBUS_EVTCHN_UNMASK_V4)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  BOOLEAN                 InCallback
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ BOOLEAN                InCallback
     );
 
 /*! \typedef XENBUS_EVTCHN_UNMASK
@@ -148,16 +148,16 @@ typedef VOID
 */
 typedef BOOLEAN
 (*XENBUS_EVTCHN_UNMASK)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  BOOLEAN                 InCallback,
-    IN  BOOLEAN                 Force
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ BOOLEAN                InCallback,
+    _In_ BOOLEAN                Force
     );
 
 typedef VOID
 (*XENBUS_EVTCHN_SEND_V1)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel
     );
 
 /*! \typedef XENBUS_EVTCHN_SEND
@@ -168,11 +168,11 @@ typedef VOID
 
     \param Interface The interface header
     \param Channel The channel handle
-*/  
+*/
 typedef VOID
 (*XENBUS_EVTCHN_SEND)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel
     );
 
 /*! \typedef XENBUS_EVTCHN_TRIGGER
@@ -180,11 +180,11 @@ typedef VOID
 
     \param Interface The interface header
     \param Channel The channel handle
-*/  
+*/
 typedef VOID
 (*XENBUS_EVTCHN_TRIGGER)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel
     );
 
 /*! \typedef XENBUS_EVTCHN_GET_COUNT
@@ -196,15 +196,15 @@ typedef VOID
 */
 typedef ULONG
 (*XENBUS_EVTCHN_GET_COUNT)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel
     );
 
 typedef NTSTATUS
 (*XENBUS_EVTCHN_WAIT_V5)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  PLARGE_INTEGER          Timeout OPTIONAL
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_opt_ PLARGE_INTEGER     Timeout
     );
 
 /*! \typedef XENBUS_EVTCHN_WAIT
@@ -217,10 +217,10 @@ typedef NTSTATUS
 */
 typedef NTSTATUS
 (*XENBUS_EVTCHN_WAIT)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  ULONG                   Count,
-    IN  PLARGE_INTEGER          Timeout OPTIONAL
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ ULONG                  Count,
+    _In_opt_ PLARGE_INTEGER     Timeout
     );
 
 /*! \typedef XENBUS_EVTCHN_GET_PORT
@@ -229,11 +229,11 @@ typedef NTSTATUS
     \param Interface The interface header
     \param Channel The channel handle
     \return The port number
-*/  
+*/
 typedef ULONG
 (*XENBUS_EVTCHN_GET_PORT)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel
     );
 
 /*! \typedef XENBUS_EVTCHN_CLOSE
@@ -241,15 +241,15 @@ typedef ULONG
 
     \param Interface The interface header
     \param Channel The channel handle
-*/  
+*/
 typedef VOID
 (*XENBUS_EVTCHN_CLOSE)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel
     );
 
 // {BE2440AC-1098-4150-AF4D-452FADCEF923}
-DEFINE_GUID(GUID_XENBUS_EVTCHN_INTERFACE, 
+DEFINE_GUID(GUID_XENBUS_EVTCHN_INTERFACE,
 0xbe2440ac, 0x1098, 0x4150, 0xaf, 0x4d, 0x45, 0x2f, 0xad, 0xce, 0xf9, 0x23);
 
 /*! \struct _XENBUS_EVTCHN_INTERFACE_V5
diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h
index 4fc8f1f..1bc9c4e 100644
--- a/include/gnttab_interface.h
+++ b/include/gnttab_interface.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -57,31 +57,31 @@ typedef struct _XENBUS_GNTTAB_CACHE XENBUS_GNTTAB_CACHE, *PXENBUS_GNTTAB_CACHE;
     \brief Acquire a reference to the GNTTAB interface
 
     \param Interface The interface header
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_GNTTAB_ACQUIRE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_GNTTAB_RELEASE
     \brief Release a reference to the GNTTAB interface
 
     \param Interface The interface header
-*/  
+*/
 typedef VOID
 (*XENBUS_GNTTAB_RELEASE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 typedef NTSTATUS
 (*XENBUS_GNTTAB_CREATE_CACHE_V1)(
-    IN  PINTERFACE                  Interface,
-    IN  const CHAR                  *Name,
-    IN  ULONG                       Reservation,
-    IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
-    IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
-    IN  PVOID                       Argument OPTIONAL,
-    OUT PXENBUS_GNTTAB_CACHE        *Cache
+    _In_ PINTERFACE                 Interface,
+    _In_ const CHAR                 *Name,
+    _In_ ULONG                      Reservation,
+    _In_ XENBUS_CACHE_ACQUIRE_LOCK  AcquireLock,
+    _In_ XENBUS_CACHE_RELEASE_LOCK  ReleaseLock,
+    _In_opt_ PVOID                  Argument,
+    _Out_ PXENBUS_GNTTAB_CACHE      *Cache
     );
 
 /*! \typedef XENBUS_GNTTAB_CREATE_CACHE
@@ -95,17 +95,17 @@ typedef NTSTATUS
     \param ReleaseLock A callback invoked to release the spinlock
     \param Argument An optional context argument passed to the callbacks
     \param Cache A pointer to a grant table cache handle to be initialized
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_GNTTAB_CREATE_CACHE)(
-    IN  PINTERFACE                  Interface,
-    IN  const CHAR                  *Name,
-    IN  ULONG                       Reservation,
-    IN  ULONG                       Cap,
-    IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
-    IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
-    IN  PVOID                       Argument OPTIONAL,
-    OUT PXENBUS_GNTTAB_CACHE        *Cache
+    _In_ PINTERFACE                 Interface,
+    _In_ const CHAR                 *Name,
+    _In_ ULONG                      Reservation,
+    _In_ ULONG                      Cap,
+    _In_ XENBUS_CACHE_ACQUIRE_LOCK  AcquireLock,
+    _In_ XENBUS_CACHE_RELEASE_LOCK  ReleaseLock,
+    _In_opt_ PVOID                  Argument,
+    _Out_ PXENBUS_GNTTAB_CACHE      *Cache
     );
 
 /*! \typedef XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS
@@ -123,13 +123,13 @@ typedef NTSTATUS
 */
 typedef NTSTATUS
 (*XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS)(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_GNTTAB_CACHE        Cache,
-    IN  BOOLEAN                     Locked,
-    IN  USHORT                      Domain,
-    IN  PFN_NUMBER                  Pfn,
-    IN  BOOLEAN                     ReadOnly,
-    OUT PXENBUS_GNTTAB_ENTRY        *Entry
+    _In_ PINTERFACE                 Interface,
+    _In_ PXENBUS_GNTTAB_CACHE       Cache,
+    _In_ BOOLEAN                    Locked,
+    _In_ USHORT                     Domain,
+    _In_ PFN_NUMBER                 Pfn,
+    _In_ BOOLEAN                    ReadOnly,
+    _Out_ PXENBUS_GNTTAB_ENTRY      *Entry
     );
 
 /*! \typedef XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS
@@ -143,10 +143,10 @@ typedef NTSTATUS
 */
 typedef NTSTATUS
 (*XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS)(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_GNTTAB_CACHE        Cache,
-    IN  BOOLEAN                     Locked,
-    IN  PXENBUS_GNTTAB_ENTRY        Entry
+    _In_ PINTERFACE                 Interface,
+    _In_ PXENBUS_GNTTAB_CACHE       Cache,
+    _In_ BOOLEAN                    Locked,
+    _In_ PXENBUS_GNTTAB_ENTRY       Entry
     );
 
 /*! \typedef XENBUS_GNTTAB_GET_REFERENCE
@@ -155,11 +155,11 @@ typedef NTSTATUS
     \param Interface The interface header
     \param Entry The grant table entry handle
     \return The reference number
-*/  
+*/
 typedef ULONG
 (*XENBUS_GNTTAB_GET_REFERENCE)(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_GNTTAB_ENTRY        Entry
+    _In_ PINTERFACE                 Interface,
+    _In_ PXENBUS_GNTTAB_ENTRY       Entry
     );
 
 /*! \typedef XENBUS_GNTTAB_QUERY_REFERENCE
@@ -172,10 +172,10 @@ typedef ULONG
 */
 typedef NTSTATUS
 (*XENBUS_GNTTAB_QUERY_REFERENCE)(
-    IN  PINTERFACE  Interface,
-    IN  ULONG       Reference,
-    OUT PPFN_NUMBER Pfn OPTIONAL,
-    OUT PBOOLEAN    ReadOnly OPTIONAL
+    _In_ PINTERFACE         Interface,
+    _In_ ULONG              Reference,
+    _Out_opt_ PPFN_NUMBER   Pfn,
+    _Out_opt_ PBOOLEAN      ReadOnly
     );
 
 #define XENBUS_GNTTAB_CONSOLE_REFERENCE 0
@@ -189,12 +189,12 @@ typedef NTSTATUS
     \param Cache The grant table cache handle
 
     All grant table entries must have been revoked prior to destruction
-    of the cache 
-*/  
+    of the cache
+*/
 typedef VOID
 (*XENBUS_GNTTAB_DESTROY_CACHE)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_GNTTAB_CACHE    Cache
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_GNTTAB_CACHE   Cache
     );
 
 /*! \typedef XENBUS_GNTTAB_MAP_FOREIGN_PAGES
@@ -210,12 +210,12 @@ typedef VOID
 
 typedef NTSTATUS
 (*XENBUS_GNTTAB_MAP_FOREIGN_PAGES)(
-    IN  PINTERFACE              Interface,
-    IN  USHORT                  Domain,
-    IN  ULONG                   NumberPages,
-    IN  PULONG                  References,
-    IN  BOOLEAN                 ReadOnly,
-    OUT PHYSICAL_ADDRESS        *Address
+    _In_ PINTERFACE             Interface,
+    _In_ USHORT                 Domain,
+    _In_ ULONG                  NumberPages,
+    _In_ PULONG                 References,
+    _In_ BOOLEAN                ReadOnly,
+    _Out_ PHYSICAL_ADDRESS      *Address
     );
 
 /*! \typedef XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES
@@ -226,12 +226,12 @@ typedef NTSTATUS
 */
 typedef NTSTATUS
 (*XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES)(
-    IN  PINTERFACE              Interface,
-    IN  PHYSICAL_ADDRESS        Address
+    _In_ PINTERFACE             Interface,
+    _In_ PHYSICAL_ADDRESS       Address
     );
 
 // {763679C5-E5C2-4A6D-8B88-6BB02EC42D8E}
-DEFINE_GUID(GUID_XENBUS_GNTTAB_INTERFACE, 
+DEFINE_GUID(GUID_XENBUS_GNTTAB_INTERFACE,
 0x763679c5, 0xe5c2, 0x4a6d, 0x8b, 0x88, 0x6b, 0xb0, 0x2e, 0xc4, 0x2d, 0x8e);
 
 /*! \struct _XENBUS_GNTTAB_INTERFACE_V2
diff --git a/include/range_set_interface.h b/include/range_set_interface.h
index c45a161..7b18eb9 100644
--- a/include/range_set_interface.h
+++ b/include/range_set_interface.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -51,20 +51,20 @@ typedef struct _XENBUS_RANGE_SET    XENBUS_RANGE_SET, *PXENBUS_RANGE_SET;
     \brief Acquire a reference to the RANGE_SET interface
 
     \param Interface The interface header
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_RANGE_SET_ACQUIRE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_RANGE_SET_RELEASE
     \brief Release a reference to the RANGE_SET interface
 
     \param Interface The interface header
-*/  
+*/
 typedef VOID
 (*XENBUS_RANGE_SET_RELEASE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_RANGE_SET_CREATE
@@ -73,12 +73,12 @@ typedef VOID
     \param Interface The interface header
     \param Name A name for the ramge-set which will be used in debug output
     \param RangeSet A pointer to a range-set handle to be initialized
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_RANGE_SET_CREATE)(
-    IN  PINTERFACE          Interface,
-    IN  const CHAR          *Name,
-    OUT PXENBUS_RANGE_SET   *RangeSet
+    _In_ PINTERFACE         Interface,
+    _In_ const CHAR                 *Name,
+    _Out_ PXENBUS_RANGE_SET *RangeSet
     );
 
 /*! \typedef XENBUS_RANGE_SET_PUT
@@ -88,13 +88,13 @@ typedef NTSTATUS
     \param RangeSet The range-set handle
     \param Start The base of the range
     \param Count The number of items of the range
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_RANGE_SET_PUT)(
-    IN  PINTERFACE          Interface,
-    IN  PXENBUS_RANGE_SET   RangeSet,
-    IN  LONGLONG            Start,
-    IN  ULONGLONG           Count
+    _In_ PINTERFACE         Interface,
+    _In_ PXENBUS_RANGE_SET  RangeSet,
+    _In_ LONGLONG           Start,
+    _In_ ULONGLONG          Count
     );
 
 /*! \typedef XENBUS_RANGE_SET_POP
@@ -105,13 +105,13 @@ typedef NTSTATUS
     \param Count The number of items required
     \param Start A pointer to a value which will be set to the base of
     a suitable range
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_RANGE_SET_POP)(
-    IN  PINTERFACE          Interface,
-    IN  PXENBUS_RANGE_SET   RangeSet,
-    IN  ULONGLONG           Count,
-    OUT PLONGLONG           Start
+    _In_ PINTERFACE         Interface,
+    _In_ PXENBUS_RANGE_SET  RangeSet,
+    _In_ ULONGLONG          Count,
+    _Out_ PLONGLONG         Start
     );
 
 /*! \typedef XENBUS_RANGE_SET_GET
@@ -121,13 +121,13 @@ typedef NTSTATUS
     \param RangeSet The range-set handle
     \param Start The base of the range
     \param Count The number of items in the range
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_RANGE_SET_GET)(
-    IN  PINTERFACE          Interface,
-    IN  PXENBUS_RANGE_SET   RangeSet,
-    IN  LONGLONG            Start,
-    IN  ULONGLONG           Count
+    _In_ PINTERFACE         Interface,
+    _In_ PXENBUS_RANGE_SET  RangeSet,
+    _In_ LONGLONG           Start,
+    _In_ ULONGLONG          Count
     );
 
 /*! \typedef XENBUS_RANGE_SET_DESTROY
@@ -137,15 +137,15 @@ typedef NTSTATUS
     \param RangeSet The range-set handle
 
     The range-set must be empty when it is destroyed
-*/  
+*/
 typedef VOID
 (*XENBUS_RANGE_SET_DESTROY)(
-    IN  PINTERFACE          Interface,
-    IN  PXENBUS_RANGE_SET   RangeSet
+    _In_ PINTERFACE         Interface,
+    _In_ PXENBUS_RANGE_SET  RangeSet
     );
 
 // {EE7E78A2-6847-48C5-B123-BB012F0EABF4}
-DEFINE_GUID(GUID_XENBUS_RANGE_SET_INTERFACE, 
+DEFINE_GUID(GUID_XENBUS_RANGE_SET_INTERFACE,
 0xee7e78a2, 0x6847, 0x48c5, 0xb1, 0x23, 0xbb, 0x1, 0x2f, 0xe, 0xab, 0xf4);
 
 /*! \struct _XENBUS_RANGE_SET_INTERFACE_V1
diff --git a/include/shared_info_interface.h b/include/shared_info_interface.h
index 7aaf4f5..5fdedfd 100644
--- a/include/shared_info_interface.h
+++ b/include/shared_info_interface.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -45,20 +45,20 @@
     \brief Acquire a reference to the SHARED_INFO interface
 
     \param Interface The interface header
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_SHARED_INFO_ACQUIRE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_SHARED_INFO_RELEASE
     \brief Release a reference to the SHARED_INFO interface
 
     \param Interface The interface header
-*/  
+*/
 typedef VOID
 (*XENBUS_SHARED_INFO_RELEASE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_SHARED_INFO_UPCALL_SUPPORTED
@@ -66,8 +66,8 @@ typedef VOID
 */
 typedef BOOLEAN
 (*XENBUS_SHARED_INFO_UPCALL_SUPPORTED)(
-    IN  PINTERFACE  Interface,
-    IN  ULONG       Index
+    _In_ PINTERFACE Interface,
+    _In_ ULONG      Index
     );
 
 /*! \typedef XENBUS_SHARED_INFO_UPCALL_PENDING
@@ -75,57 +75,57 @@ typedef BOOLEAN
 */
 typedef BOOLEAN
 (*XENBUS_SHARED_INFO_UPCALL_PENDING)(
-    IN  PINTERFACE  Interface,
-    IN  ULONG       Index
+    _In_ PINTERFACE Interface,
+    _In_ ULONG      Index
     );
 
 typedef BOOLEAN
 (*XENBUS_SHARED_INFO_EVENT)(
-    IN  PVOID   Argument,
-    IN  ULONG   Port
+    _In_ PVOID  Argument,
+    _In_ ULONG  Port
     );
 
 /*! \typedef XENBUS_SHARED_INFO_EVTCHN_POLL
     \brief Private method for EVTCHN inerface
-*/  
+*/
 typedef BOOLEAN
 (*XENBUS_SHARED_INFO_EVTCHN_POLL)(
-    IN  PINTERFACE                  Interface,
-    IN  ULONG                       Index,
-    IN  XENBUS_SHARED_INFO_EVENT    Event,
-    IN  PVOID                       Argument
+    _In_ PINTERFACE                 Interface,
+    _In_ ULONG                      Index,
+    _In_ XENBUS_SHARED_INFO_EVENT   Event,
+    _In_ PVOID                      Argument
     );
 
 /*! \typedef XENBUS_SHARED_INFO_EVTCHN_ACK
     \brief Private method for EVTCHN inerface
-*/  
+*/
 typedef VOID
 (*XENBUS_SHARED_INFO_EVTCHN_ACK)(
-    IN  PINTERFACE  Interface,
-    IN  ULONG       Port
+    _In_ PINTERFACE Interface,
+    _In_ ULONG      Port
     );
 
 /*! \typedef XENBUS_SHARED_INFO_EVTCHN_MASK
     \brief Private method for EVTCHN inerface
-*/  
+*/
 typedef VOID
 (*XENBUS_SHARED_INFO_EVTCHN_MASK)(
-    IN  PINTERFACE  Interface,
-    IN  ULONG       Port
+    _In_ PINTERFACE Interface,
+    _In_ ULONG      Port
     );
 
 /*! \typedef XENBUS_SHARED_INFO_EVTCHN_UNMASK
     \brief Private method for EVTCHN inerface
-*/  
+*/
 typedef BOOLEAN
 (*XENBUS_SHARED_INFO_EVTCHN_UNMASK)(
-    IN  PINTERFACE  Interface,
-    IN  ULONG       Port
+    _In_ PINTERFACE Interface,
+    _In_ ULONG      Port
     );
 
 typedef LARGE_INTEGER
 (*XENBUS_SHARED_INFO_GET_TIME_V2)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_SHARED_INFO_GET_TIME
@@ -134,16 +134,16 @@ typedef LARGE_INTEGER
     \param Interface The interface header
     \param Time The wallclock time
     \param Local Set, on return, if the wallclock is in local time
-*/  
+*/
 typedef VOID
 (*XENBUS_SHARED_INFO_GET_TIME)(
-    IN  PINTERFACE      Interface,
-    OUT PLARGE_INTEGER  Time,
-    OUT PBOOLEAN        Local
+    _In_ PINTERFACE         Interface,
+    _Out_ PLARGE_INTEGER    Time,
+    _Out_ PBOOLEAN          Local
     );
 
 // {7E73C34F-1640-4649-A8F3-263BC930A004}
-DEFINE_GUID(GUID_XENBUS_SHARED_INFO_INTERFACE, 
+DEFINE_GUID(GUID_XENBUS_SHARED_INFO_INTERFACE,
 0x7e73c34f, 0x1640, 0x4649, 0xa8, 0xf3, 0x26, 0x3b, 0xc9, 0x30, 0xa0, 0x4);
 
 /*! \struct _XENBUS_SHARED_INFO_INTERFACE_V2
diff --git a/include/store_interface.h b/include/store_interface.h
index ca883bd..4521ba7 100644
--- a/include/store_interface.h
+++ b/include/store_interface.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -72,20 +72,20 @@ typedef struct _XENBUS_STORE_PERMISSION {
     \brief Acquire a reference to the STORE interface
 
     \param Interface The interface header
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_STORE_ACQUIRE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_STORE_RELEASE
     \brief Release a reference to the STORE interface
 
     \param Interface The interface header
-*/  
+*/
 typedef VOID
 (*XENBUS_STORE_RELEASE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_STORE_FREE
@@ -93,11 +93,11 @@ typedef VOID
 
     \param Interface The interface header
     \param Buffer Pointer to the memory buffer
-*/  
+*/
 typedef VOID
 (*XENBUS_STORE_FREE)(
-    IN  PINTERFACE  Interface,
-    IN  PCHAR       Buffer
+    _In_ PINTERFACE Interface,
+    _In_ PCHAR      Buffer
     );
 
 /*! \typedef XENBUS_STORE_READ
@@ -113,14 +113,14 @@ typedef VOID
     buffer containing the value read
 
     The \a Buffer should be freed using \a XENBUS_STORE_FREE
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_STORE_READ)(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction OPTIONAL,
-    IN  PCHAR                       Prefix OPTIONAL,
-    IN  PCHAR                       Node,
-    OUT PCHAR                       *Buffer
+    _In_ PINTERFACE                     Interface,
+    _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_opt_ PCHAR                      Prefix,
+    _In_ PCHAR                          Node,
+    _Out_ PCHAR                         *Buffer
     );
 
 /*! \typedef XENBUS_STORE_PRINTF
@@ -136,14 +136,14 @@ typedef NTSTATUS
     \param ... Additional parameters required by \a Format
 
     If the \a Node does not exist then it is created
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_STORE_PRINTF)(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction OPTIONAL,
-    IN  PCHAR                       Prefix OPTIONAL,
-    IN  PCHAR                       Node,
-    IN  const CHAR                  *Format,
+    _In_ PINTERFACE                     Interface,
+    _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_opt_ PCHAR                      Prefix,
+    _In_ PCHAR                          Node,
+    _In_ const CHAR                     *Format,
     ...
     );
 
@@ -156,13 +156,13 @@ typedef NTSTATUS
     \param Prefix An optional prefix for the \a Node
     \param Node The concatenation of the \a Prefix and this value specifies
     the XenStore key to remove
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_STORE_REMOVE)(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction OPTIONAL,
-    IN  PCHAR                       Prefix OPTIONAL,
-    IN  PCHAR                       Node
+    _In_ PINTERFACE                     Interface,
+    _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_opt_ PCHAR                      Prefix,
+    _In_ PCHAR                          Node
     );
 
 /*! \typedef XENBUS_STORE_DIRECTORY
@@ -178,14 +178,14 @@ typedef NTSTATUS
     buffer containing a NUL separated list of key names
 
     The \a Buffer should be freed using \a XENBUS_STORE_FREE
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_STORE_DIRECTORY)(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction OPTIONAL,
-    IN  PCHAR                       Prefix OPTIONAL,
-    IN  PCHAR                       Node,
-    OUT PCHAR                       *Buffer
+    _In_ PINTERFACE                     Interface,
+    _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_opt_ PCHAR                      Prefix,
+    _In_ PCHAR                          Node,
+    _Out_ PCHAR                         *Buffer
     );
 
 /*! \typedef XENBUS_STORE_TRANSACTION_START
@@ -193,11 +193,11 @@ typedef NTSTATUS
 
     \param Interface The interface header
     \param Transaction Pointer to a transaction handle to be initialized
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_STORE_TRANSACTION_START)(
-    IN  PINTERFACE                  Interface,
-    OUT PXENBUS_STORE_TRANSACTION   *Transaction
+    _In_ PINTERFACE                 Interface,
+    _Out_ PXENBUS_STORE_TRANSACTION *Transaction
     );
 
 /*! \typedef XENBUS_STORE_TRANSACTION_END
@@ -210,12 +210,12 @@ typedef NTSTATUS
 
     If \a Commit is TRUE and the transaction to found to clash then
     STATUS_RETRY will be returned
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_STORE_TRANSACTION_END)(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction,
-    IN  BOOLEAN                     Commit
+    _In_ PINTERFACE                 Interface,
+    _In_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_ BOOLEAN                    Commit
     );
 
 /*! \typedef XENBUS_STORE_WATCH_ADD
@@ -228,14 +228,14 @@ typedef NTSTATUS
     \param Event A pointer to an event object to be signalled when the
     watch fires
     \param Watch A pointer to a watch handle to be initialized
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_STORE_WATCH_ADD)(
-    IN  PINTERFACE          Interface,
-    IN  PCHAR               Prefix OPTIONAL,
-    IN  PCHAR               Node,
-    IN  PKEVENT             Event,
-    OUT PXENBUS_STORE_WATCH *Watch
+    _In_ PINTERFACE             Interface,
+    _In_opt_ PCHAR              Prefix,
+    _In_ PCHAR                  Node,
+    _In_ PKEVENT                Event,
+    _Out_ PXENBUS_STORE_WATCH   *Watch
     );
 
 /*! \typedef XENBUS_STORE_WATCH_REMOVE
@@ -243,11 +243,11 @@ typedef NTSTATUS
 
     \param Interface The interface header
     \param Watch The watch handle
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_STORE_WATCH_REMOVE)(
-    IN  PINTERFACE          Interface,
-    IN  PXENBUS_STORE_WATCH Watch
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_STORE_WATCH    Watch
     );
 
 /*! \typedef XENBUS_STORE_POLL
@@ -259,10 +259,10 @@ typedef NTSTATUS
     activity then this will block the normal STORE interface DPC so this
     method must be regularly invoked during the spin loop to check for
     XenStore activity
-*/  
+*/
 typedef VOID
 (*XENBUS_STORE_POLL)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_STORE_PERMISSIONS_SET
@@ -279,16 +279,16 @@ typedef VOID
 */
 typedef NTSTATUS
 (*XENBUS_STORE_PERMISSIONS_SET)(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction OPTIONAL,
-    IN  PCHAR                       Prefix OPTIONAL,
-    IN  PCHAR                       Node,
-    IN  PXENBUS_STORE_PERMISSION    Permissions,
-    IN  ULONG                       NumberPermissions
+    _In_ PINTERFACE                     Interface,
+    _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_opt_ PCHAR                      Prefix,
+    _In_ PCHAR                          Node,
+    _In_ PXENBUS_STORE_PERMISSION       Permissions,
+    _In_ ULONG                          NumberPermissions
     );
 
 // {86824C3B-D34E-4753-B281-2F1E3AD214D7}
-DEFINE_GUID(GUID_XENBUS_STORE_INTERFACE, 
+DEFINE_GUID(GUID_XENBUS_STORE_INTERFACE,
 0x86824c3b, 0xd34e, 0x4753, 0xb2, 0x81, 0x2f, 0x1e, 0x3a, 0xd2, 0x14, 0xd7);
 
 /*! \struct _XENBUS_STORE_INTERFACE_V2
diff --git a/include/suspend_interface.h b/include/suspend_interface.h
index 4176dc3..1444373 100644
--- a/include/suspend_interface.h
+++ b/include/suspend_interface.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -52,27 +52,27 @@ typedef enum _XENBUS_SUSPEND_CALLBACK_TYPE {
 
 /*! \typedef XENBUS_SUSPEND_CALLBACK
     \brief Suspend callback handle
-*/  
+*/
 typedef struct _XENBUS_SUSPEND_CALLBACK   XENBUS_SUSPEND_CALLBACK, *PXENBUS_SUSPEND_CALLBACK;
 
 /*! \typedef XENBUS_SUSPEND_ACQUIRE
     \brief Acquire a reference to the SUSPEND interface
 
     \param Interface The interface header
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_SUSPEND_ACQUIRE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_SUSPEND_RELEASE
     \brief Release a reference to the SUSPEND interface
 
     \param Interface The interface header
-*/  
+*/
 typedef VOID
 (*XENBUS_SUSPEND_RELEASE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_SUSPEND_FUNCTION
@@ -84,10 +84,10 @@ typedef VOID
     vCPUs corralled at the same IRQL as the callback. \a Early callback
     functions are always invoked with IRQL == HIGH_LEVEL and \a Late callback
     functions are always invoked with IRQL == DISPATCH_LEVEL
-*/  
+*/
 typedef VOID
 (*XENBUS_SUSPEND_FUNCTION)(
-    IN  PVOID   Argument
+    _In_ PVOID  Argument
     );
 
 /*! \typedef XENBUS_SUSPEND_REGISTER
@@ -98,14 +98,14 @@ typedef VOID
     \param Function The callback function
     \param Argument An optional context argument passed to the callback
     \param Callback A pointer to a callback handle to be initialized
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_SUSPEND_REGISTER)(
-    IN  PINTERFACE                      Interface,
-    IN  XENBUS_SUSPEND_CALLBACK_TYPE    Type,
-    IN  XENBUS_SUSPEND_FUNCTION         Function,
-    IN  PVOID                           Argument OPTIONAL,
-    OUT PXENBUS_SUSPEND_CALLBACK        *Callback
+    _In_ PINTERFACE                     Interface,
+    _In_ XENBUS_SUSPEND_CALLBACK_TYPE   Type,
+    _In_ XENBUS_SUSPEND_FUNCTION        Function,
+    _In_opt_ PVOID                      Argument,
+    _Out_ PXENBUS_SUSPEND_CALLBACK      *Callback
     );
 
 /*! \typedef XENBUS_SUSPEND_DEREGISTER
@@ -116,8 +116,8 @@ typedef NTSTATUS
 */
 typedef VOID
 (*XENBUS_SUSPEND_DEREGISTER)(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_SUSPEND_CALLBACK    Callback
+    _In_ PINTERFACE                 Interface,
+    _In_ PXENBUS_SUSPEND_CALLBACK   Callback
     );
 
 /*! \typedef XENBUS_SUSPEND_TRIGGER
@@ -129,7 +129,7 @@ typedef VOID
 */
 typedef NTSTATUS
 (*XENBUS_SUSPEND_TRIGGER)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_SUSPEND_GET_COUNT
@@ -140,7 +140,7 @@ typedef NTSTATUS
 */
 typedef ULONG
 (*XENBUS_SUSPEND_GET_COUNT)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 // {0554F2AF-B510-4C71-AC03-1C503E394238}
diff --git a/include/unplug_interface.h b/include/unplug_interface.h
index dad3afc..7b030e7 100644
--- a/include/unplug_interface.h
+++ b/include/unplug_interface.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -45,20 +45,20 @@
     \brief Acquire a reference to the UNPLUG interface
 
     \param Interface The interface header
-*/  
+*/
 typedef NTSTATUS
 (*XENBUS_UNPLUG_ACQUIRE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \typedef XENBUS_UNPLUG_RELEASE
     \brief Release a reference to the UNPLUG interface
 
     \param Interface The interface header
-*/  
+*/
 typedef VOID
 (*XENBUS_UNPLUG_RELEASE)(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     );
 
 /*! \enum _XENBUS_UNPLUG_DEVICE_TYPE
@@ -77,12 +77,12 @@ typedef enum _XENBUS_UNPLUG_DEVICE_TYPE {
     \param Type The type of device
     \param Make Set to TRUE if the request is being made, FALSE if it is
            being revoked.
-*/  
+*/
 typedef VOID
 (*XENBUS_UNPLUG_REQUEST)(
-    IN  PINTERFACE                  Interface,
-    IN  XENBUS_UNPLUG_DEVICE_TYPE   Type,
-    IN  BOOLEAN                     Make
+    _In_ PINTERFACE                 Interface,
+    _In_ XENBUS_UNPLUG_DEVICE_TYPE  Type,
+    _In_ BOOLEAN                    Make
     );
 
 /*! \typedef XENBUS_UNPLUG_IS_REQUESTED
@@ -95,8 +95,8 @@ typedef VOID
 */
 typedef BOOLEAN
 (*XENBUS_UNPLUG_IS_REQUESTED)(
-    IN  PINTERFACE                  Interface,
-    IN  XENBUS_UNPLUG_DEVICE_TYPE   Type
+    _In_ PINTERFACE                 Interface,
+    _In_ XENBUS_UNPLUG_DEVICE_TYPE  Type
     );
 
 /*! \typedef XENBUS_UNPLUG_BOOT_EMULATED
@@ -106,7 +106,7 @@ typedef BOOLEAN
 */
 typedef BOOLEAN
 (*XENBUS_UNPLUG_BOOT_EMULATED)(
-    IN  PINTERFACE                  Interface
+    _In_ PINTERFACE                 Interface
     );
 
 /*! \typedef XENBUS_UNPLUG_REBOOT
@@ -117,8 +117,8 @@ typedef BOOLEAN
 */
 typedef VOID
 (*XENBUS_UNPLUG_REBOOT)(
-    IN  PINTERFACE                  Interface,
-    IN  PCHAR                       Module
+    _In_ PINTERFACE                 Interface,
+    _In_ PCHAR                      Module
     );
 
 // {73db6517-3d06-4937-989f-199b7501e229}
diff --git a/include/xen.h b/include/xen.h
index a874ed1..1ba109c 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -69,11 +69,11 @@
 XEN_API
 NTSTATUS
 XenTouch(
-    IN  const CHAR  *Name,
-    IN  ULONG       MajorVersion,
-    IN  ULONG       MinorVersion,
-    IN  ULONG       MicroVersion,
-    IN  ULONG       BuildNumber
+    _In_ const CHAR *Name,
+    _In_ ULONG      MajorVersion,
+    _In_ ULONG      MinorVersion,
+    _In_ ULONG      MicroVersion,
+    _In_ ULONG      BuildNumber
     );
 
 // HYPERCALL
@@ -86,229 +86,229 @@ HypercallPopulate(
 
 // HVM
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 HvmSetParam(
-    IN  ULONG       Parameter,
-    IN  ULONGLONG   Value
+    _In_ ULONG      Parameter,
+    _In_ ULONGLONG  Value
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 HvmGetParam(
-    IN  ULONG       Parameter,
-    OUT PULONGLONG  Value
+    _In_ ULONG          Parameter,
+    _Out_ PULONGLONG    Value
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 HvmPagetableDying(
-    IN  PHYSICAL_ADDRESS    Address
+    _In_ PHYSICAL_ADDRESS   Address
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 HvmSetEvtchnUpcallVector(
-    IN  unsigned int    vcpu_id,
-    IN  UCHAR           Vector
+    _In_ unsigned int   vcpu_id,
+    _In_ UCHAR          Vector
     );
 
 // MEMORY
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 MemoryAddToPhysmap(
-    IN  PFN_NUMBER  Pfn,
-    IN  ULONG       Space,
-    IN  ULONG_PTR   Offset
+    _In_ PFN_NUMBER Pfn,
+    _In_ ULONG      Space,
+    _In_ ULONG_PTR  Offset
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 MemoryRemoveFromPhysmap(
-    IN  PFN_NUMBER  Pfn
+    _In_ PFN_NUMBER Pfn
     );
 
 #define PAGE_ORDER_4K   0
 #define PAGE_ORDER_2M   9
 
-__checkReturn
+_Check_return_
 XEN_API
 ULONG
 MemoryDecreaseReservation(
-    IN  ULONG       Order,
-    IN  ULONG       Count,
-    IN  PPFN_NUMBER PfnArray
+    _In_ ULONG          Order,
+    _In_ ULONG          Count,
+    _In_ PPFN_NUMBER    PfnArray
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 ULONG
 MemoryPopulatePhysmap(
-    IN  ULONG       Order,
-    IN  ULONG       Count,
-    IN  PPFN_NUMBER PfnArray
+    _In_ ULONG          Order,
+    _In_ ULONG          Count,
+    _In_ PPFN_NUMBER    PfnArray
     );
 
 // EVENT CHANNEL
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelSend(
-    IN  ULONG   Port
+    _In_ ULONG  Port
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelAllocateUnbound(
-    IN  USHORT  Domain,
-    OUT ULONG   *Port
+    _In_ USHORT Domain,
+    _Out_ ULONG *Port
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelBindInterDomain(
-    IN  USHORT  RemoteDomain,
-    IN  ULONG   RemotePort,
-    OUT ULONG   *LocalPort
+    _In_ USHORT RemoteDomain,
+    _In_ ULONG  RemotePort,
+    _Out_ ULONG *LocalPort
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelBindVirq(
-    IN  ULONG           Virq,
-    IN  unsigned int    vcpu_id,
-    OUT ULONG           *LocalPort
+    _In_ ULONG          Virq,
+    _In_ unsigned int   vcpu_id,
+    _Out_ ULONG         *LocalPort
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelQueryInterDomain(
-    IN  ULONG   LocalPort,
-    OUT USHORT  *RemoteDomain,
-    OUT ULONG   *RemotePort
+    _In_ ULONG      LocalPort,
+    _Out_ USHORT    *RemoteDomain,
+    _Out_ ULONG     *RemotePort
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelClose(
-    IN  ULONG   LocalPort
+    _In_ ULONG  LocalPort
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelExpandArray(
-    IN  PFN_NUMBER  Pfn
+    _In_ PFN_NUMBER Pfn
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelInitControl(
-    IN  PFN_NUMBER      Pfn,
-    IN  unsigned int    vcpu_id
+    _In_ PFN_NUMBER     Pfn,
+    _In_ unsigned int   vcpu_id
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelReset(
     VOID
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelBindVirtualCpu(
-    IN  ULONG           LocalPort,
-    IN  unsigned int    vcpu_id
+    _In_ ULONG          LocalPort,
+    _In_ unsigned int   vcpu_id
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelUnmask(
-    IN  ULONG   LocalPort
+    _In_ ULONG  LocalPort
     );
 
 // GRANT TABLE
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 GrantTableSetVersion(
-    IN  uint32_t    Version
+    _In_ uint32_t   Version
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 GrantTableGetVersion(
-    OUT uint32_t    *Version
+    _Out_ uint32_t  *Version
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 GrantTableCopy(
-    IN  struct gnttab_copy  op[],
-    IN  ULONG               Count
+    _In_ struct gnttab_copy op[],
+    _In_ ULONG              Count
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 GrantTableMapForeignPage(
-    IN  USHORT              Domain,
-    IN  ULONG               GrantRef,
-    IN  PHYSICAL_ADDRESS    Address,
-    IN  BOOLEAN             ReadOnly,
-    OUT ULONG               *Handle
+    _In_ USHORT             Domain,
+    _In_ ULONG              GrantRef,
+    _In_ PHYSICAL_ADDRESS   Address,
+    _In_ BOOLEAN            ReadOnly,
+    _Out_ ULONG             *Handle
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 GrantTableUnmapForeignPage(
-    IN  ULONG               Handle,
-    IN  PHYSICAL_ADDRESS    Address
+    _In_ ULONG              Handle,
+    _In_ PHYSICAL_ADDRESS   Address
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 GrantTableQuerySize(
-    OUT uint32_t    *Current OPTIONAL,
-    OUT uint32_t    *Maximum OPTIONAL
+    _Out_opt_ uint32_t      *Current,
+    _Out_opt_ uint32_t      *Maximum
     );
 
 // SCHED
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 SchedShutdownCode(
-    ULONG   Reason
+    _In_ ULONG  Reason
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 SchedShutdown(
-    ULONG   Reason
+    _In_ ULONG  Reason
     );
 
 XEN_API
@@ -320,25 +320,25 @@ SchedYield(
 XEN_API
 NTSTATUS
 SchedWatchdog(
-    IN OUT  PULONG  Id,
-    IN      ULONG   Seconds
+    _Inout_ PULONG  Id,
+    _In_ ULONG      Seconds
     );
 
 // XEN VERSION
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 XenVersion(
-    OUT PULONG  Major,
-    OUT PULONG  Minor
+    _Out_ PULONG    Major,
+    _Out_ PULONG    Minor
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 XenVersionExtra(
-    OUT PCHAR   Extra
+    _Out_writes_(XEN_EXTRAVERSION_LEN) PCHAR    Extra
     );
 
 // MODULE
@@ -346,9 +346,9 @@ XenVersionExtra(
 XEN_API
 VOID
 ModuleLookup(
-    IN  ULONG_PTR   Address,
-    OUT PCHAR       *Name,
-    OUT PULONG_PTR  Offset
+    _In_ ULONG_PTR      Address,
+    _Out_ PCHAR         *Name,
+    _Out_ PULONG_PTR    Offset
     );
 
 // UNPLUG
@@ -368,19 +368,19 @@ UnplugDevices(
 XEN_API
 NTSTATUS
 UnplugIncrementValue(
-    IN  UNPLUG_TYPE Type
+    _In_ UNPLUG_TYPE    Type
     );
 
 XEN_API
 NTSTATUS
 UnplugDecrementValue(
-    IN  UNPLUG_TYPE Type
+    _In_ UNPLUG_TYPE    Type
     );
 
 XEN_API
 BOOLEAN
 UnplugGetRequest(
-    IN  UNPLUG_TYPE Type
+    _In_ UNPLUG_TYPE    Type
     );
 
 // LOG
@@ -397,34 +397,34 @@ typedef enum _LOG_LEVEL {
 XEN_API
 VOID
 LogCchVPrintf(
-    IN  LOG_LEVEL   Level,
-    IN  ULONG       Count,
-    IN  const CHAR  *Format,
-    IN  va_list     Arguments
+    _In_ LOG_LEVEL  Level,
+    _In_ ULONG      Count,
+    _In_ const CHAR *Format,
+    _In_ va_list    Arguments
     );
 
 XEN_API
 VOID
 LogVPrintf(
-    IN  LOG_LEVEL   Level,
-    IN  const CHAR  *Format,
-    IN  va_list     Arguments
+    _In_ LOG_LEVEL  Level,
+    _In_ const CHAR *Format,
+    _In_ va_list    Arguments
     );
 
 XEN_API
 VOID
 LogCchPrintf(
-    IN  LOG_LEVEL   Level,
-    IN  ULONG       Count,
-    IN  const CHAR  *Format,
+    _In_ LOG_LEVEL  Level,
+    _In_ ULONG      Count,
+    _In_ const CHAR *Format,
     ...
     );
 
 XEN_API
 VOID
 LogPrintf(
-    IN  LOG_LEVEL   Level,
-    IN  const CHAR  *Format,
+    _In_ LOG_LEVEL  Level,
+    _In_ const CHAR *Format,
     ...
     );
 
@@ -437,9 +437,9 @@ LogResume(
 XEN_API
 NTSTATUS
 LogReadLogLevel(
-    IN  HANDLE      Key,
-    IN  PCHAR       Name,
-    OUT PLOG_LEVEL  LogLevel
+    _In_ HANDLE         Key,
+    _In_ PCHAR          Name,
+    _Out_ PLOG_LEVEL    LogLevel
     );
 
 typedef struct _LOG_DISPOSITION LOG_DISPOSITION, *PLOG_DISPOSITION;
@@ -447,16 +447,16 @@ typedef struct _LOG_DISPOSITION LOG_DISPOSITION, *PLOG_DISPOSITION;
 XEN_API
 NTSTATUS
 LogAddDisposition(
-    IN  LOG_LEVEL           Mask,
-    IN  VOID                (*Function)(PVOID, PCHAR, ULONG),
-    IN  PVOID               Argument OPTIONAL,
-    OUT PLOG_DISPOSITION    *Disposition
+    _In_ LOG_LEVEL          Mask,
+    _In_ VOID               (*Function)(PVOID, PCHAR, ULONG),
+    _In_opt_ PVOID          Argument,
+    _Out_ PLOG_DISPOSITION  *Disposition
     );
 
 XEN_API
 VOID
 LogRemoveDisposition(
-    IN  PLOG_DISPOSITION    Disposition
+    _In_ PLOG_DISPOSITION   Disposition
     );
 
 
@@ -465,22 +465,22 @@ LogRemoveDisposition(
 XEN_API
 NTSTATUS
 SystemProcessorVcpuId(
-    IN  ULONG           Cpu,
-    OUT unsigned int    *vcpu_id
+    _In_ ULONG          Cpu,
+    _Out_ unsigned int  *vcpu_id
     );
 
 XEN_API
 NTSTATUS
 SystemProcessorVcpuInfo(
-    IN  ULONG       Cpu,
-    OUT vcpu_info_t **Vcpu
+    _In_ ULONG          Cpu,
+    _Out_ vcpu_info_t   **Vcpu
     );
 
 XEN_API
 NTSTATUS
 SystemProcessorRegisterVcpuInfo(
-    IN  ULONG   Cpu,
-    IN  BOOLEAN Force
+    _In_ ULONG      Cpu,
+    _In_ BOOLEAN    Force
     );
 
 XEN_API
@@ -498,7 +498,7 @@ SystemRealTimeIsUniversal(
 XEN_API
 NTSTATUS
 SystemSetWatchdog(
-    IN  ULONG       Seconds
+    _In_ ULONG      Seconds
     );
 
 XEN_API
@@ -509,21 +509,21 @@ SystemStopWatchdog(
 
 // VCPU
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 VcpuSetPeriodicTimer(
-    IN  unsigned int    vcpu_id,
-    IN  PLARGE_INTEGER  Period
+    _In_ unsigned int       vcpu_id,
+    _In_opt_ PLARGE_INTEGER Period
     );
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 VcpuRegisterVcpuInfo(
-    IN  unsigned int                vcpu_id,
-    IN  PFN_NUMBER                  Pfn,
-    IN  ULONG                       Offset
+    _In_ unsigned int               vcpu_id,
+    _In_ PFN_NUMBER                 Pfn,
+    _In_ ULONG                      Offset
     );
 
 // FILTERS
@@ -545,24 +545,24 @@ FiltersUninstall(
 XEN_API
 NTSTATUS
 ConfigGetActive(
-    IN  const CHAR  *Key,
-    OUT PCHAR       *Value
+    _In_ const CHAR *Key,
+    _Out_ PCHAR     *Value
     );
 
 XEN_API
 NTSTATUS
 ConfigSetActive(
-    IN  PCHAR   DeviceID,
-    IN  PCHAR   InstanceID,
-    IN  PCHAR   LocationInformation
+    _In_ PCHAR  DeviceID,
+    _In_ PCHAR  InstanceID,
+    _In_ PCHAR  LocationInformation
     );
 
 XEN_API
 NTSTATUS
 ConfigUpdateActive(
-    IN  PCHAR   DeviceID,
-    IN  PCHAR   InstanceID,
-    IN  PCHAR   LocationInformation
+    _In_ PCHAR  DeviceID,
+    _In_ PCHAR  InstanceID,
+    _In_ PCHAR  LocationInformation
     );
 
 XEN_API
@@ -574,15 +574,15 @@ ConfigClearActive(
 XEN_API
 NTSTATUS
 ConfigRequestReboot(
-    IN  HANDLE      ParametersKey,
-    IN  PCHAR       Module
+    _In_ HANDLE     ParametersKey,
+    _In_ PCHAR      Module
     );
 
 XEN_API
 NTSTATUS
 ConfigQuerySystemStartOption(
-    IN  PCHAR           Key,
-    OUT PANSI_STRING    *Option
+    _In_ PCHAR          Key,
+    _Out_ PANSI_STRING  *Option
     );
 
 #endif  // _XEN_H
diff --git a/src/common/assert.h b/src/common/assert.h
index 0d43ea9..6c6ee28 100644
--- a/src/common/assert.h
+++ b/src/common/assert.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -39,11 +39,11 @@
 
 static FORCEINLINE VOID
 __Bug(
-    IN  ULONG       Code,
-    IN  ULONG_PTR   Parameter1,
-    IN  ULONG_PTR   Parameter2,
-    IN  ULONG_PTR   Parameter3,
-    IN  ULONG_PTR   Parameter4
+    _In_ ULONG      Code,
+    _In_ ULONG_PTR  Parameter1,
+    _In_ ULONG_PTR  Parameter2,
+    _In_ ULONG_PTR  Parameter3,
+    _In_ ULONG_PTR  Parameter4
     )
 {
 #pragma prefast(suppress:28159)
@@ -154,10 +154,10 @@ __Bug(
 
 static __inline BOOLEAN
 _IsZeroMemory(
-    IN  const PCHAR Caller,
-    IN  const PCHAR Name,
-    IN  PVOID       Buffer,
-    IN  ULONG       Length
+    _In_ const PCHAR    Caller,
+    _In_ const PCHAR    Name,
+    _In_ PVOID          Buffer,
+    _In_ ULONG          Length
     )
 {
     ULONG           Offset;
@@ -178,10 +178,10 @@ _IsZeroMemory(
 
 static __inline BOOLEAN
 _IsZeroMemory(
-    IN  const PCHAR Caller,
-    IN  const PCHAR Name,
-    IN  PVOID       Buffer,
-    IN  ULONG       Length
+    _In_ const PCHAR    Caller,
+    _In_ const PCHAR    Name,
+    _In_ PVOID          Buffer,
+    _In_ ULONG          Length
     )
 {
     UNREFERENCED_PARAMETER(Caller);
diff --git a/src/common/dbg_print.h b/src/common/dbg_print.h
index a0bd727..372fd7b 100644
--- a/src/common/dbg_print.h
+++ b/src/common/dbg_print.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -44,8 +44,8 @@
 
 static __inline VOID
 __Error(
-    IN  const CHAR  *Prefix,
-    IN  const CHAR  *Format,
+    _In_ const CHAR *Prefix,
+    _In_ const CHAR *Format,
     ...
     )
 {
@@ -67,8 +67,8 @@ __Error(
 
 static __inline VOID
 __Warning(
-    IN  const CHAR  *Prefix,
-    IN  const CHAR  *Format,
+    _In_ const CHAR *Prefix,
+    _In_ const CHAR *Format,
     ...
     )
 {
@@ -91,8 +91,8 @@ __Warning(
 #if DBG
 static __inline VOID
 __Trace(
-    IN  const CHAR  *Prefix,
-    IN  const CHAR  *Format,
+    _In_ const CHAR *Prefix,
+    _In_ const CHAR *Format,
     ...
     )
 {
@@ -117,8 +117,8 @@ __Trace(
 
 static __inline VOID
 __Info(
-    IN  const CHAR  *Prefix,
-    IN  const CHAR  *Format,
+    _In_ const CHAR *Prefix,
+    _In_ const CHAR *Format,
     ...
     )
 {
diff --git a/src/common/high.h b/src/common/high.h
index 40cf0f5..4e21f5b 100644
--- a/src/common/high.h
+++ b/src/common/high.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -42,12 +42,12 @@ typedef LONG    HIGH_LOCK, *PHIGH_LOCK;
 #define LOCK_MAGIC  0xFEEDFACE
 
 static FORCEINLINE
-__drv_maxIRQL(HIGH_LEVEL)
-__drv_raisesIRQL(HIGH_LEVEL)
-__drv_savesIRQL
+_IRQL_requires_max_(HIGH_LEVEL)
+_IRQL_raises_(HIGH_LEVEL)
+_IRQL_saves_
 KIRQL
 __AcquireHighLock(
-    IN  PHIGH_LOCK  Lock
+    _In_ PHIGH_LOCK Lock
     )
 {
     KIRQL           Irql;
@@ -68,12 +68,11 @@ __AcquireHighLock(
         } while (FALSE)
 
 static FORCEINLINE
-__drv_maxIRQL(HIGH_LEVEL)
-__drv_requiresIRQL(HIGH_LEVEL)
+_IRQL_requires_(HIGH_LEVEL)
 VOID
 ReleaseHighLock(
-    IN  PHIGH_LOCK                  Lock,
-    IN  __drv_restoresIRQL KIRQL    Irql
+    _In_ PHIGH_LOCK                 Lock,
+    _In_  _IRQL_restores_ KIRQL     Irql
     )
 {
     KeMemoryBarrier();
@@ -85,7 +84,7 @@ ReleaseHighLock(
 static FORCEINLINE
 VOID
 InitializeHighLock(
-    IN  PHIGH_LOCK  Lock
+    _In_ PHIGH_LOCK Lock
     )
 {
     RtlZeroMemory(&Lock, sizeof (HIGH_LOCK));
diff --git a/src/common/mutex.h b/src/common/mutex.h
index 4f13236..bdacddb 100644
--- a/src/common/mutex.h
+++ b/src/common/mutex.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -44,7 +44,7 @@ typedef struct _MUTEX {
 
 static FORCEINLINE VOID
 InitializeMutex(
-    IN  PMUTEX  Mutex
+    _In_ PMUTEX Mutex
     )
 {
     RtlZeroMemory(Mutex, sizeof (MUTEX));
@@ -53,9 +53,9 @@ InitializeMutex(
 }
 
 static FORCEINLINE BOOLEAN
-__drv_maxIRQL(PASSIVE_LEVEL)
+_IRQL_requires_max_(PASSIVE_LEVEL)
 TryAcquireMutex(
-    IN  PMUTEX      Mutex
+    _In_ PMUTEX     Mutex
     )
 {
     LARGE_INTEGER   Timeout;
@@ -80,9 +80,9 @@ TryAcquireMutex(
 }
 
 static FORCEINLINE VOID
-__drv_maxIRQL(PASSIVE_LEVEL)
+_IRQL_requires_max_(PASSIVE_LEVEL)
 AcquireMutex(
-    IN  PMUTEX  Mutex
+    _In_ PMUTEX Mutex
     )
 {
     NTSTATUS    status;
@@ -100,9 +100,9 @@ AcquireMutex(
 }
 
 static FORCEINLINE VOID
-__drv_maxIRQL(PASSIVE_LEVEL)
+_IRQL_requires_max_(PASSIVE_LEVEL)
 ReleaseMutex(
-    IN  PMUTEX  Mutex
+    _In_ PMUTEX Mutex
     )
 {
     ASSERT3P(Mutex->Owner, ==, KeGetCurrentThread());
diff --git a/src/common/names.h b/src/common/names.h
index 9bdfb1c..a7af965 100644
--- a/src/common/names.h
+++ b/src/common/names.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -38,7 +38,7 @@
 
 static FORCEINLINE const CHAR *
 PowerStateTypeName(
-    IN  POWER_STATE_TYPE    Type
+    _In_ POWER_STATE_TYPE   Type
     )
 {
 #define _POWER_TYPE_NAME(_Type) \
@@ -58,7 +58,7 @@ PowerStateTypeName(
 
 static FORCEINLINE const CHAR *
 SystemPowerStateName(
-    IN  SYSTEM_POWER_STATE State
+    _In_ SYSTEM_POWER_STATE State
     )
 {
 #define _POWER_SYSTEM_STATE_NAME(_State)    \
@@ -84,7 +84,7 @@ SystemPowerStateName(
 
 static FORCEINLINE const CHAR *
 DevicePowerStateName(
-    IN  DEVICE_POWER_STATE State
+    _In_ DEVICE_POWER_STATE State
     )
 {
 #define _POWER_DEVICE_STATE_NAME(_State)    \
@@ -108,7 +108,7 @@ DevicePowerStateName(
 
 static FORCEINLINE const CHAR *
 PowerActionName(
-    IN  POWER_ACTION    Type
+    _In_ POWER_ACTION   Type
     )
 {
 #define _POWER_ACTION_NAME(_Type)   \
@@ -134,7 +134,7 @@ PowerActionName(
 
 static FORCEINLINE const CHAR *
 PowerMinorFunctionName(
-    IN  ULONG   MinorFunction
+    _In_ ULONG  MinorFunction
     )
 {
 #define _POWER_MINOR_FUNCTION_NAME(_Function)   \
@@ -156,7 +156,7 @@ PowerMinorFunctionName(
 
 static FORCEINLINE const CHAR *
 PnpMinorFunctionName(
-    IN  ULONG   Function
+    _In_ ULONG  Function
     )
 {
 #define _PNP_MINOR_FUNCTION_NAME(_Function) \
@@ -199,7 +199,7 @@ PnpMinorFunctionName(
 
 static FORCEINLINE const CHAR *
 ResourceDescriptorTypeName(
-    IN  UCHAR   Type
+    _In_ UCHAR  Type
     )
 {
 #define _RESOURCE_DESCRIPTOR_TYPE_NAME(_Type)   \
@@ -228,7 +228,7 @@ ResourceDescriptorTypeName(
 
 static FORCEINLINE const CHAR *
 ResourceDescriptorShareDispositionName(
-    IN  UCHAR   Disposition
+    _In_ UCHAR  Disposition
     )
 {
 #define _RESOURCE_DESCRIPTOR_SHARE_DISPOSITION_NAME(_Disposition)  \
@@ -251,7 +251,7 @@ ResourceDescriptorShareDispositionName(
 
 static FORCEINLINE const CHAR *
 IrqDevicePolicyName(
-    IN  IRQ_DEVICE_POLICY   Policy
+    _In_ IRQ_DEVICE_POLICY  Policy
     )
 {
 #define _IRQ_DEVICE_POLICY_NAME(_Policy)    \
@@ -276,7 +276,7 @@ IrqDevicePolicyName(
 
 static FORCEINLINE const CHAR *
 IrqPriorityName(
-    IN  IRQ_PRIORITY    Priority
+    _In_ IRQ_PRIORITY   Priority
     )
 {
 #define _IRQ_PRIORITY_NAME(_Priority)   \
@@ -299,7 +299,7 @@ IrqPriorityName(
 
 static FORCEINLINE const CHAR *
 InterruptModeName(
-    IN  KINTERRUPT_MODE Mode
+    _In_ KINTERRUPT_MODE    Mode
     )
 {
 #define _INTERRUPT_MODE_NAME(_Mode) \
@@ -320,7 +320,7 @@ InterruptModeName(
 
 static FORCEINLINE const CHAR *
 DeviceUsageNotificationTypeName(
-    IN  DEVICE_USAGE_NOTIFICATION_TYPE  Type
+    _In_ DEVICE_USAGE_NOTIFICATION_TYPE Type
     )
 {
 #define _DEVICE_USAGE_TYPE_NAME(_Type)  \
@@ -342,7 +342,7 @@ DeviceUsageNotificationTypeName(
 
 static FORCEINLINE const CHAR *
 InterfaceTypeName(
-    IN  INTERFACE_TYPE  Type
+    _In_ INTERFACE_TYPE Type
     )
 {
 #define _INTERFACE_TYPE_NAME(_Type) \
@@ -380,7 +380,7 @@ InterfaceTypeName(
 
 static FORCEINLINE const CHAR *
 DmaWidthName(
-    IN  DMA_WIDTH   Width
+    _In_ DMA_WIDTH  Width
     )
 {
 #define _DMA_WIDTH_NAME(_Width) \
@@ -404,7 +404,7 @@ DmaWidthName(
 
 static FORCEINLINE const CHAR *
 DmaSpeedName(
-    IN  DMA_SPEED   Speed
+    _In_ DMA_SPEED  Speed
     )
 {
 #define _DMA_SPEED_NAME(_Speed) \
@@ -429,7 +429,7 @@ DmaSpeedName(
 
 static FORCEINLINE const CHAR *
 BusQueryIdTypeName(
-    IN  BUS_QUERY_ID_TYPE   Type
+    _In_ BUS_QUERY_ID_TYPE  Type
     )
 {
 #define _BUS_QUERY_ID_TYPE_NAME(_Type)  \
@@ -454,7 +454,7 @@ BusQueryIdTypeName(
 
 static FORCEINLINE const CHAR *
 ProcessorChangeName(
-    IN  KE_PROCESSOR_CHANGE_NOTIFY_STATE    Change
+    _In_ KE_PROCESSOR_CHANGE_NOTIFY_STATE   Change
     )
 {
 #define _PROCESSOR_CHANGE_NAME(_Change) \
@@ -476,7 +476,7 @@ ProcessorChangeName(
 
 static FORCEINLINE const CHAR *
 VirqName(
-    IN  ULONG   Type
+    _In_ ULONG  Type
     )
 {
 #define _VIRQ_NAME(_Type) \
diff --git a/src/common/registry.c b/src/common/registry.c
index fc68941..6a8c73e 100644
--- a/src/common/registry.c
+++ b/src/common/registry.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -47,7 +47,7 @@ static IOOPENDRIVERREGISTRYKEY __IoOpenDriverRegistryKey;
 
 static FORCEINLINE PVOID
 __RegistryAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, REGISTRY_TAG);
@@ -55,7 +55,7 @@ __RegistryAllocate(
 
 static FORCEINLINE VOID
 __RegistryFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, REGISTRY_TAG);
@@ -63,8 +63,8 @@ __RegistryFree(
 
 NTSTATUS
 RegistryInitialize(
-    IN  PDRIVER_OBJECT  DriverObject,
-    IN  PUNICODE_STRING Path
+    _In_opt_ PDRIVER_OBJECT DriverObject,
+    _In_ PUNICODE_STRING    Path
     )
 {
     UNICODE_STRING      Unicode;
@@ -111,8 +111,8 @@ RegistryTeardown(
 
 NTSTATUS
 RegistryOpenParametersKey(
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
+    _In_ ACCESS_MASK    DesiredAccess,
+    _Out_ PHANDLE       Key
     )
 {
     HANDLE              ServiceKey;
@@ -159,10 +159,10 @@ fail1:
 
 NTSTATUS
 RegistryOpenKey(
-    IN  HANDLE          Parent,
-    IN  PUNICODE_STRING Path,
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
+    _In_opt_ HANDLE         Parent,
+    _In_ PUNICODE_STRING    Path,
+    _In_ ACCESS_MASK        DesiredAccess,
+    _Out_ PHANDLE           Key
     )
 {
     OBJECT_ATTRIBUTES   Attributes;
@@ -188,9 +188,9 @@ fail1:
 
 static NTSTATUS
 RegistryOpenRoot(
-    IN  PWCHAR          Path,
-    OUT PHANDLE         Parent,
-    OUT PWCHAR          *ChildPath
+    _In_ PWCHAR         Path,
+    _Out_ PHANDLE       Parent,
+    _Out_ PWCHAR        *ChildPath
     )
 {
     const WCHAR         Prefix[] = L"\\Registry\\Machine\\";
@@ -221,10 +221,10 @@ fail1:
 
 NTSTATUS
 RegistryCreateKey(
-    IN  HANDLE          Parent,
-    IN  PUNICODE_STRING Path,
-    IN  ULONG           Options,
-    OUT PHANDLE         Key
+    _In_opt_ HANDLE         Parent,
+    _In_ PUNICODE_STRING    Path,
+    _In_ ULONG              Options,
+    _Out_ PHANDLE           Key
     )
 {
     PWCHAR              Buffer;
@@ -321,8 +321,8 @@ fail1:
 
 NTSTATUS
 RegistryOpenServiceKey(
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
+    _In_ ACCESS_MASK    DesiredAccess,
+    _Out_ PHANDLE       Key
     )
 {
     return RegistryOpenKey(NULL, &RegistryPath, DesiredAccess, Key);
@@ -330,7 +330,7 @@ RegistryOpenServiceKey(
 
 NTSTATUS
 RegistryCreateServiceKey(
-    OUT PHANDLE         Key
+    _Out_ PHANDLE       Key
     )
 {
     return RegistryCreateKey(NULL, &RegistryPath, REG_OPTION_NON_VOLATILE, Key);
@@ -338,9 +338,9 @@ RegistryCreateServiceKey(
 
 NTSTATUS
 RegistryOpenSoftwareKey(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
+    _In_ PDEVICE_OBJECT DeviceObject,
+    _In_ ACCESS_MASK    DesiredAccess,
+    _Out_ PHANDLE       Key
     )
 {
     NTSTATUS            status;
@@ -360,9 +360,9 @@ fail1:
 
 NTSTATUS
 RegistryOpenHardwareKey(
-    IN  PDEVICE_OBJECT      DeviceObject,
-    IN  ACCESS_MASK         DesiredAccess,
-    OUT PHANDLE             Key
+    _In_ PDEVICE_OBJECT     DeviceObject,
+    _In_ ACCESS_MASK        DesiredAccess,
+    _Out_ PHANDLE           Key
     )
 {
     HANDLE                  SubKey;
@@ -410,7 +410,7 @@ RegistryOpenHardwareKey(
     ASSERT(Cursor != NULL);
 
     *Cursor = L'\0';
-    
+
     RtlInitUnicodeString(&Unicode, Info->Name);
 
     status = RegistryOpenKey(NULL, &Unicode, DesiredAccess, Key);
@@ -437,10 +437,10 @@ fail1:
 
 NTSTATUS
 RegistryOpenSubKey(
-    IN  PHANDLE         Key,
-    IN  PCHAR           Name,
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         SubKey
+    _In_opt_ PHANDLE    Key,
+    _In_ PCHAR          Name,
+    _In_ ACCESS_MASK    DesiredAccess,
+    _Out_ PHANDLE       SubKey
     )
 {
     ANSI_STRING         Ansi;
@@ -470,10 +470,10 @@ fail1:
 
 NTSTATUS
 RegistryCreateSubKey(
-    IN  PHANDLE         Key,
-    IN  PCHAR           Name,
-    IN  ULONG           Options,
-    OUT PHANDLE         SubKey
+    _In_opt_ HANDLE     Key,
+    _In_ PCHAR          Name,
+    _In_ ULONG          Options,
+    _Out_ PHANDLE       SubKey
     )
 {
     ANSI_STRING         Ansi;
@@ -503,8 +503,8 @@ fail1:
 
 NTSTATUS
 RegistryDeleteSubKey(
-    IN  PHANDLE         Key,
-    IN  PCHAR           Name
+    _In_ PHANDLE        Key,
+    _In_ PCHAR          Name
     )
 {
     ANSI_STRING         Ansi;
@@ -544,9 +544,9 @@ fail1:
 
 NTSTATUS
 RegistryEnumerateSubKeys(
-    IN  HANDLE              Key,
-    IN  NTSTATUS            (*Callback)(PVOID, HANDLE, PANSI_STRING),
-    IN  PVOID               Context
+    _In_ HANDLE             Key,
+    _In_ NTSTATUS           (*Callback)(PVOID, HANDLE, PANSI_STRING),
+    _In_ PVOID              Context
     )
 {
     ULONG                   Size;
@@ -615,7 +615,7 @@ RegistryEnumerateSubKeys(
         status = RtlUnicodeStringToAnsiString(&Ansi, &Unicode, FALSE);
         ASSERT(NT_SUCCESS(status));
 
-        Ansi.Length = (USHORT)(strlen(Ansi.Buffer) * sizeof (CHAR));        
+        Ansi.Length = (USHORT)(strlen(Ansi.Buffer) * sizeof (CHAR));
 
         status = Callback(Context, Key, &Ansi);
 
@@ -640,7 +640,7 @@ fail5:
 fail4:
 fail3:
     __RegistryFree(Full);
-    
+
 fail2:
 fail1:
     return status;
@@ -648,9 +648,9 @@ fail1:
 
 NTSTATUS
 RegistryEnumerateValues(
-    IN  HANDLE                      Key,
-    IN  NTSTATUS                    (*Callback)(PVOID, HANDLE, PANSI_STRING, ULONG),
-    IN  PVOID                       Context
+    _In_ HANDLE                     Key,
+    _In_ NTSTATUS                   (*Callback)(PVOID, HANDLE, PANSI_STRING, ULONG),
+    _In_ PVOID                      Context
     )
 {
     ULONG                           Size;
@@ -722,7 +722,7 @@ RegistryEnumerateValues(
             goto fail7;
         }
 
-        Ansi.Length = (USHORT)(strlen(Ansi.Buffer) * sizeof (CHAR));        
+        Ansi.Length = (USHORT)(strlen(Ansi.Buffer) * sizeof (CHAR));
 
         status = Callback(Context, Key, &Ansi, Basic->Type);
 
@@ -747,7 +747,7 @@ fail5:
 fail4:
 fail3:
     __RegistryFree(Full);
-    
+
 fail2:
 fail1:
     return status;
@@ -755,8 +755,8 @@ fail1:
 
 NTSTATUS
 RegistryDeleteValue(
-    IN  PHANDLE         Key,
-    IN  PCHAR           Name
+    _In_ PHANDLE        Key,
+    _In_ PCHAR          Name
     )
 {
     ANSI_STRING         Ansi;
@@ -786,9 +786,9 @@ fail1:
 
 NTSTATUS
 RegistryQueryDwordValue(
-    IN  HANDLE                      Key,
-    IN  PCHAR                       Name,
-    OUT PULONG                      Value
+    _In_ HANDLE                     Key,
+    _In_ PCHAR                      Name,
+    _Out_ PULONG                    Value
     )
 {
     ANSI_STRING                     Ansi;
@@ -802,7 +802,7 @@ RegistryQueryDwordValue(
     status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
     if (!NT_SUCCESS(status))
         goto fail1;
-        
+
     status = ZwQueryValueKey(Key,
                              &Unicode,
                              KeyValuePartialInformation,
@@ -834,7 +834,7 @@ RegistryQueryDwordValue(
         Partial->DataLength != sizeof (ULONG))
         goto fail5;
 
-    *Value = *(PULONG)Partial->Data;            
+    *Value = *(PULONG)Partial->Data;
 
     __RegistryFree(Partial);
 
@@ -856,9 +856,9 @@ fail1:
 
 NTSTATUS
 RegistryUpdateDwordValue(
-    IN  HANDLE                      Key,
-    IN  PCHAR                       Name,
-    IN  ULONG                       Value
+    _In_ HANDLE                     Key,
+    _In_ PCHAR                      Name,
+    _In_ ULONG                      Value
     )
 {
     ANSI_STRING                     Ansi;
@@ -871,7 +871,7 @@ RegistryUpdateDwordValue(
     status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
     if (!NT_SUCCESS(status))
         goto fail1;
-        
+
     Partial = __RegistryAllocate(FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data) +
                                  sizeof (ULONG));
 
@@ -882,7 +882,7 @@ RegistryUpdateDwordValue(
     Partial->TitleIndex = 0;
     Partial->Type = REG_DWORD;
     Partial->DataLength = sizeof (ULONG);
-    *(PULONG)Partial->Data = Value;            
+    *(PULONG)Partial->Data = Value;
 
     status = ZwSetValueKey(Key,
                            &Unicode,
@@ -912,7 +912,7 @@ fail1:
 
 static PANSI_STRING
 RegistrySzToAnsi(
-    IN  PWCHAR      Buffer
+    _In_ PWCHAR     Buffer
     )
 {
     PANSI_STRING    Ansi;
@@ -951,7 +951,7 @@ fail1:
 
 static PANSI_STRING
 RegistryMultiSzToAnsi(
-    IN  PWCHAR      Buffer
+    _In_ PWCHAR     Buffer
     )
 {
     PANSI_STRING    Ansi;
@@ -1013,10 +1013,10 @@ fail1:
 
 NTSTATUS
 RegistryQuerySzValue(
-    IN  HANDLE                      Key,
-    IN  PCHAR                       Name,
-    OUT PULONG                      Type OPTIONAL,
-    OUT PANSI_STRING                *Array
+    _In_ HANDLE                     Key,
+    _In_ PCHAR                      Name,
+    _Out_opt_ PULONG                Type,
+    _Out_ PANSI_STRING              *Array
     )
 {
     ANSI_STRING                     Ansi;
@@ -1030,7 +1030,7 @@ RegistryQuerySzValue(
     status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
     if (!NT_SUCCESS(status))
         goto fail1;
-        
+
     status = ZwQueryValueKey(Key,
                              &Unicode,
                              KeyValuePartialInformation,
@@ -1100,10 +1100,10 @@ fail1:
 
 NTSTATUS
 RegistryQueryBinaryValue(
-    IN  HANDLE                      Key,
-    IN  PCHAR                       Name,
-    OUT PVOID                       *Buffer,
-    OUT PULONG                      Length
+    _In_ HANDLE                     Key,
+    _In_ PCHAR                      Name,
+    _Out_ PVOID                     *Buffer,
+    _Out_ PULONG                    Length
     )
 {
     ANSI_STRING                     Ansi;
@@ -1185,10 +1185,10 @@ fail1:
 
 NTSTATUS
 RegistryUpdateBinaryValue(
-    IN  HANDLE                      Key,
-    IN  PCHAR                       Name,
-    IN  PVOID                       Buffer,
-    IN  ULONG                       Length
+    _In_ HANDLE                     Key,
+    _In_ PCHAR                      Name,
+    _In_ PVOID                      Buffer,
+    _In_ ULONG                      Length
     )
 {
     ANSI_STRING                     Ansi;
@@ -1242,8 +1242,8 @@ fail1:
 
 NTSTATUS
 RegistryQueryKeyName(
-    IN  HANDLE              Key,
-    OUT PANSI_STRING        *Array
+    _In_ HANDLE             Key,
+    _Out_ PANSI_STRING      *Array
     )
 {
     PKEY_NAME_INFORMATION   Value;
@@ -1297,8 +1297,8 @@ fail1:
 
 NTSTATUS
 RegistryQuerySystemStartOption(
-    IN  PCHAR                       Prefix,
-    OUT PANSI_STRING                *Value
+    _In_ PCHAR                      Prefix,
+    _Out_ PANSI_STRING              *Value
     )
 {
     UNICODE_STRING                  Unicode;
@@ -1310,7 +1310,7 @@ RegistryQuerySystemStartOption(
     NTSTATUS                        status;
 
     RtlInitUnicodeString(&Unicode, L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control");
-    
+
     status = RegistryOpenKey(NULL, &Unicode, KEY_READ, &Key);
     if (!NT_SUCCESS(status))
         goto fail1;
@@ -1467,10 +1467,10 @@ fail1:
 
 NTSTATUS
 RegistryUpdateSzValue(
-    IN  HANDLE                      Key,
-    IN  PCHAR                       Name,
-    IN  ULONG                       Type,
-    IN  PANSI_STRING                Array
+    _In_ HANDLE                     Key,
+    _In_ PCHAR                      Name,
+    _In_ ULONG                      Type,
+    _In_ PANSI_STRING               Array
     )
 {
     ANSI_STRING                     Ansi;
@@ -1531,7 +1531,7 @@ fail1:
 
 VOID
 RegistryFreeSzValue(
-    IN  PANSI_STRING    Array
+    _In_ PANSI_STRING   Array
     )
 {
     ULONG               Index;
@@ -1547,7 +1547,7 @@ RegistryFreeSzValue(
 
 VOID
 RegistryFreeBinaryValue(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __RegistryFree(Buffer);
@@ -1555,7 +1555,7 @@ RegistryFreeBinaryValue(
 
 VOID
 RegistryCloseKey(
-    IN  HANDLE  Key
+    _In_ HANDLE Key
     )
 {
     ZwClose(Key);
diff --git a/src/common/registry.h b/src/common/registry.h
index efa96ea..dd4e035 100644
--- a/src/common/registry.h
+++ b/src/common/registry.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -37,8 +37,8 @@
 
 extern NTSTATUS
 RegistryInitialize(
-    IN  PDRIVER_OBJECT  DrvObj,
-    IN  PUNICODE_STRING Path
+    _In_opt_ PDRIVER_OBJECT DrvObj,
+    _In_ PUNICODE_STRING    Path
     );
 
 extern VOID
@@ -48,164 +48,164 @@ RegistryTeardown(
 
 extern NTSTATUS
 RegistryOpenParametersKey(
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
+    _In_ ACCESS_MASK    DesiredAccess,
+    _Out_ PHANDLE       Key
     );
 
 extern NTSTATUS
 RegistryOpenKey(
-    IN  HANDLE          Parent,
-    IN  PUNICODE_STRING Path,
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
+    _In_opt_ HANDLE         Parent,
+    _In_ PUNICODE_STRING    Path,
+    _In_ ACCESS_MASK        DesiredAccess,
+    _Out_ PHANDLE           Key
     );
 
 extern NTSTATUS
 RegistryCreateKey(
-    IN  HANDLE          Parent,
-    IN  PUNICODE_STRING Path,
-    IN  ULONG           Options,
-    OUT PHANDLE         Key
+    _In_opt_ HANDLE         Parent,
+    _In_ PUNICODE_STRING    Path,
+    _In_ ULONG              Options,
+    _Out_ PHANDLE           Key
     );
 
 extern NTSTATUS
 RegistryOpenServiceKey(
-    IN  ACCESS_MASK DesiredAccess,
-    OUT PHANDLE     Key
+    _In_ ACCESS_MASK    DesiredAccess,
+    _Out_ PHANDLE       Key
     );
 
 extern NTSTATUS
 RegistryCreateServiceKey(
-    OUT PHANDLE     Key
+    _Out_ PHANDLE   Key
     );
 
 extern NTSTATUS
 RegistryOpenSoftwareKey(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
+    _In_ PDEVICE_OBJECT DeviceObject,
+    _In_ ACCESS_MASK    DesiredAccess,
+    _Out_ PHANDLE       Key
     );
 
 extern NTSTATUS
 RegistryOpenHardwareKey(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
+    _In_ PDEVICE_OBJECT DeviceObject,
+    _In_ ACCESS_MASK    DesiredAccess,
+    _Out_ PHANDLE       Key
     );
 
 extern NTSTATUS
 RegistryOpenSubKey(
-    IN  HANDLE      Key,
-    IN  PCHAR       Name,
-    IN  ACCESS_MASK DesiredAccess,
-    OUT PHANDLE     SubKey
+    _In_opt_ HANDLE     Key,
+    _In_ PCHAR          Name,
+    _In_ ACCESS_MASK    DesiredAccess,
+    _Out_ PHANDLE       SubKey
     );
 
 extern NTSTATUS
 RegistryCreateSubKey(
-    IN  HANDLE      Key,
-    IN  PCHAR       Name,
-    IN  ULONG       Options,
-    OUT PHANDLE     SubKey
+    _In_opt_ HANDLE Key,
+    _In_ PCHAR      Name,
+    _In_ ULONG      Options,
+    _Out_ PHANDLE   SubKey
     );
 
 extern NTSTATUS
 RegistryDeleteSubKey(
-    IN  HANDLE      Key,
-    IN  PCHAR       Name
+    _In_ HANDLE     Key,
+    _In_ PCHAR      Name
     );
 
 extern NTSTATUS
 RegistryEnumerateSubKeys(
-    IN  HANDLE      Key,
-    IN  NTSTATUS    (*Callback)(PVOID, HANDLE, PANSI_STRING),
-    IN  PVOID       Context
+    _In_ HANDLE     Key,
+    _In_ NTSTATUS   (*Callback)(PVOID, HANDLE, PANSI_STRING),
+    _In_ PVOID      Context
     );
 
 extern NTSTATUS
 RegistryEnumerateValues(
-    IN  HANDLE      Key,
-    IN  NTSTATUS    (*Callback)(PVOID, HANDLE, PANSI_STRING, ULONG),
-    IN  PVOID       Context
+    _In_ HANDLE     Key,
+    _In_ NTSTATUS   (*Callback)(PVOID, HANDLE, PANSI_STRING, ULONG),
+    _In_ PVOID      Context
     );
 
 extern NTSTATUS
 RegistryDeleteValue(
-    IN  HANDLE      Key,
-    IN  PCHAR       Name
+    _In_ HANDLE     Key,
+    _In_ PCHAR      Name
     );
 
 extern NTSTATUS
 RegistryQueryDwordValue(
-    IN  HANDLE          Key,
-    IN  PCHAR           Name,
-    OUT PULONG          Value
+    _In_ HANDLE         Key,
+    _In_ PCHAR          Name,
+    _Out_ PULONG        Value
     );
-    
+
 extern NTSTATUS
 RegistryUpdateDwordValue(
-    IN  HANDLE          Key,
-    IN  PCHAR           Name,
-    IN  ULONG           Value
+    _In_ HANDLE         Key,
+    _In_ PCHAR          Name,
+    _In_ ULONG          Value
     );
-    
+
 extern NTSTATUS
 RegistryQuerySzValue(
-    IN  HANDLE          Key,
-    IN  PCHAR           Name,
-    OUT PULONG          Type OPTIONAL,
-    OUT PANSI_STRING    *Array
+    _In_ HANDLE         Key,
+    _In_ PCHAR          Name,
+    _Out_opt_ PULONG    Type,
+    _Out_ PANSI_STRING  *Array
     );
 
 extern NTSTATUS
 RegistryQueryBinaryValue(
-    IN  HANDLE          Key,
-    IN  PCHAR           Name,
-    OUT PVOID           *Buffer,
-    OUT PULONG          Length
+    _In_ HANDLE         Key,
+    _In_ PCHAR          Name,
+    _Out_ PVOID         *Buffer,
+    _Out_ PULONG        Length
     );
 
 extern NTSTATUS
 RegistryUpdateBinaryValue(
-    IN  HANDLE          Key,
-    IN  PCHAR           Name,
-    IN  PVOID           Buffer,
-    IN  ULONG           Length
+    _In_ HANDLE         Key,
+    _In_ PCHAR          Name,
+    _In_ PVOID          Buffer,
+    _In_ ULONG          Length
     );
 
 extern NTSTATUS
 RegistryQueryKeyName(
-    IN  HANDLE              Key,
-    OUT PANSI_STRING        *Array
+    _In_ HANDLE             Key,
+    _Out_ PANSI_STRING      *Array
     );
 
 extern NTSTATUS
 RegistryQuerySystemStartOption(
-    IN  PCHAR           Name,
-    OUT PANSI_STRING    *Option
+    _In_ PCHAR          Name,
+    _Out_ PANSI_STRING  *Option
     );
 
 extern VOID
 RegistryFreeSzValue(
-    IN  PANSI_STRING    Array
+    _In_ PANSI_STRING   Array
     );
 
 extern VOID
 RegistryFreeBinaryValue(
-    IN  PVOID           Buffer
+    _In_ PVOID          Buffer
     );
 
 extern NTSTATUS
 RegistryUpdateSzValue(
-    IN  HANDLE          Key,
-    IN  PCHAR           Name,
-    IN  ULONG           Type,
-    IN  PANSI_STRING    Array
+    _In_ HANDLE         Key,
+    _In_ PCHAR          Name,
+    _In_ ULONG          Type,
+    _In_ PANSI_STRING   Array
     );
 
 extern VOID
 RegistryCloseKey(
-    IN  HANDLE  Key
+    _In_ HANDLE Key
     );
 
 #endif  // _COMMON_REGISTRY_H
diff --git a/src/common/util.h b/src/common/util.h
index b020e5b..a658adb 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -43,7 +43,7 @@
 
 static FORCEINLINE LONG
 __ffs(
-    IN  unsigned long long  mask
+    _In_ unsigned long long mask
     )
 {
     unsigned char           *array = (unsigned char *)&mask;
@@ -82,11 +82,11 @@ __ffs(
 
 static FORCEINLINE VOID
 __CpuId(
-    IN  ULONG   Leaf,
-    OUT PULONG  EAX OPTIONAL,
-    OUT PULONG  EBX OPTIONAL,
-    OUT PULONG  ECX OPTIONAL,
-    OUT PULONG  EDX OPTIONAL
+    _In_ ULONG          Leaf,
+    _Out_opt_ PULONG    EAX,
+    _Out_opt_ PULONG    EBX,
+    _Out_opt_ PULONG    ECX,
+    _Out_opt_ PULONG    EDX
     )
 {
     int         Value[4] = {0};
@@ -108,8 +108,8 @@ __CpuId(
 
 static FORCEINLINE LONG
 __InterlockedAdd(
-    IN  LONG    *Value,
-    IN  LONG    Delta
+    _In_ LONG   *Value,
+    _In_ LONG   Delta
     )
 {
     LONG        New;
@@ -125,8 +125,8 @@ __InterlockedAdd(
 
 static FORCEINLINE LONG
 __InterlockedSubtract(
-    IN  LONG    *Value,
-    IN  LONG    Delta
+    _In_ LONG   *Value,
+    _In_ LONG   Delta
     )
 {
     LONG        New;
@@ -140,12 +140,12 @@ __InterlockedSubtract(
     return New;
 }
 
-__checkReturn
+_Check_return_
 static FORCEINLINE PVOID
 __AllocatePoolWithTag(
-    IN  POOL_TYPE   PoolType,
-    IN  SIZE_T      NumberOfBytes,
-    IN  ULONG       Tag
+    _In_ POOL_TYPE  PoolType,
+    _In_ SIZE_T     NumberOfBytes,
+    _In_ ULONG      Tag
     )
 {
     PUCHAR          Buffer;
@@ -171,8 +171,8 @@ __AllocatePoolWithTag(
 
 static FORCEINLINE VOID
 __FreePoolWithTag(
-    IN  PVOID   Buffer,
-    IN  ULONG   Tag
+    _In_ PVOID  Buffer,
+    _In_ ULONG  Tag
     )
 {
     ExFreePoolWithTag(Buffer, Tag);
@@ -180,8 +180,8 @@ __FreePoolWithTag(
 
 static FORCEINLINE PMDL
 __AllocatePages(
-    IN  ULONG           Count,
-    IN  BOOLEAN         Contiguous
+    _In_ ULONG          Count,
+    _In_ BOOLEAN        Contiguous
     )
 {
     PHYSICAL_ADDRESS    LowAddress;
@@ -258,7 +258,7 @@ fail1:
 
 static FORCEINLINE VOID
 __FreePages(
-    IN	PMDL	Mdl
+    _In_ PMDL   Mdl
     )
 {
     PUCHAR	MdlMappedSystemVa;
@@ -276,9 +276,9 @@ __FreePages(
 
 static FORCEINLINE PCHAR
 __strtok_r(
-    IN      PCHAR   Buffer,
-    IN      PCHAR   Delimiter,
-    IN OUT  PCHAR   *Context
+    _In_opt_ PCHAR  Buffer,
+    _In_ PCHAR      Delimiter,
+    _Inout_ PCHAR   *Context
     )
 {
     PCHAR           Token;
@@ -314,9 +314,9 @@ __strtok_r(
 
 static FORCEINLINE PWCHAR
 __wcstok_r(
-    IN      PWCHAR  Buffer,
-    IN      PWCHAR  Delimiter,
-    IN OUT  PWCHAR  *Context
+    _In_opt_ PWCHAR Buffer,
+    _In_ PWCHAR     Delimiter,
+    _Inout_ PWCHAR  *Context
     )
 {
     PWCHAR          Token;
@@ -352,7 +352,7 @@ __wcstok_r(
 
 static FORCEINLINE CHAR
 __toupper(
-    IN  CHAR    Character
+    _In_ CHAR   Character
     )
 {
     if (Character < 'a' || Character > 'z')
@@ -363,7 +363,7 @@ __toupper(
 
 static FORCEINLINE CHAR
 __tolower(
-    IN  CHAR    Character
+    _In_ CHAR   Character
     )
 {
     if (Character < 'A' || Character > 'Z')
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index dd5fc13..532436d 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -93,8 +93,8 @@ MONITOR_CONTEXT MonitorContext;
 static VOID
 #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
 __Log(
-    IN  const CHAR      *Format,
-    IN  ...
+    _In_ const CHAR     *Format,
+    ...
     )
 {
 #if DBG
@@ -148,11 +148,11 @@ __Log(
 
 static PTCHAR
 GetErrorMessage(
-    IN  HRESULT Error
+    _In_  HRESULT   Error
     )
 {
-    PTCHAR      Message;
-    ULONG       Index;
+    PTCHAR          Message;
+    ULONG           Index;
 
     if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
                        FORMAT_MESSAGE_FROM_SYSTEM |
@@ -177,7 +177,7 @@ GetErrorMessage(
 
 static const CHAR *
 ServiceStateName(
-    IN  DWORD   State
+    _In_ DWORD  State
     )
 {
 #define _STATE_NAME(_State) \
@@ -200,9 +200,9 @@ ServiceStateName(
 
 static VOID
 ReportStatus(
-    IN  DWORD           CurrentState,
-    IN  DWORD           Win32ExitCode,
-    IN  DWORD           WaitHint)
+    _In_ DWORD          CurrentState,
+    _In_ DWORD          Win32ExitCode,
+    _In_ DWORD          WaitHint)
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
     static DWORD        CheckPoint = 1;
@@ -250,10 +250,10 @@ fail1:
 
 DWORD WINAPI
 MonitorCtrlHandlerEx(
-    IN  DWORD           Ctrl,
-    IN  DWORD           EventType,
-    IN  LPVOID          EventData,
-    IN  LPVOID          Argument
+    _In_ DWORD          Ctrl,
+    _In_ DWORD          EventType,
+    _In_ LPVOID         EventData,
+    _In_ LPVOID         Argument
     )
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
@@ -287,7 +287,7 @@ MonitorCtrlHandlerEx(
 
 static const CHAR *
 WTSStateName(
-    IN  DWORD   State
+    _In_ DWORD  State
     )
 {
 #define _STATE_NAME(_State) \
@@ -316,8 +316,8 @@ WTSStateName(
 
 static VOID
 DoReboot(
-    IN PTCHAR   Message,
-    IN DWORD    Timeout
+    _In_ PTCHAR Message,
+    _In_ DWORD  Timeout
     )
 {
     Log("waiting for pending install events...");
@@ -367,7 +367,7 @@ GetPromptTimeout(
 
 static PTCHAR
 GetDisplayName(
-    IN PTCHAR           DriverName
+    _In_ PTCHAR         DriverName
     )
 {
     HRESULT             Result;
@@ -570,7 +570,7 @@ fail1:
 
 static VOID
 PromptForReboot(
-    IN PTCHAR           DriverName
+    _In_ PTCHAR         DriverName
     )
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
@@ -681,7 +681,7 @@ fail1:
 
 static VOID
 TryAutoReboot(
-    IN PTCHAR           DriverName
+    _In_ PTCHAR         DriverName
     )
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
@@ -1086,9 +1086,10 @@ fail1:
     return FALSE;
 }
 
+_Success_(return)
 static BOOL
 GetRequestKeyName(
-    OUT PTCHAR          *RequestKeyName
+    _Out_ PTCHAR        *RequestKeyName
     )
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
@@ -1310,7 +1311,7 @@ fail1:
 
 static BOOL
 RemoveStartOverride(
-    IN PTCHAR           DriverName
+    _In_ PTCHAR         DriverName
     )
 {
     TCHAR               KeyName[MAX_PATH];
diff --git a/src/xen/acpi.c b/src/xen/acpi.c
index 418f8ae..a73e822 100644
--- a/src/xen/acpi.c
+++ b/src/xen/acpi.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -46,7 +46,7 @@ static PACPI_XSDT   AcpiXsdt;
 
 static FORCEINLINE PVOID
 __AcpiAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_ACPI_TAG);
@@ -54,7 +54,7 @@ __AcpiAllocate(
 
 static FORCEINLINE VOID
 __AcpiFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_ACPI_TAG);
@@ -62,8 +62,8 @@ __AcpiFree(
 
 static BOOLEAN
 AcpiVerifyChecksum(
-    IN  PVOID   Table,
-    IN  ULONG   Length
+    _In_ PVOID  Table,
+    _In_ ULONG  Length
     )
 {
     UCHAR       Sum;
@@ -212,9 +212,9 @@ fail1:
 
 NTSTATUS
 AcpiGetTable(
-    IN      const CHAR  *Signature,
-    OUT     PVOID       Buffer OPTIONAL,
-    IN OUT  PULONG      Length
+    _In_ const CHAR     *Signature,
+    _Out_opt_ PVOID     Buffer,
+    _Inout_ PULONG      Length
     )
 {
     ULONG               Count;
diff --git a/src/xen/acpi.h b/src/xen/acpi.h
index f188905..f6a9f99 100644
--- a/src/xen/acpi.h
+++ b/src/xen/acpi.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -95,9 +95,9 @@ AcpiInitialize(
 
 extern NTSTATUS
 AcpiGetTable(
-    IN      const CHAR  *Signature,
-    OUT     PVOID       Buffer OPTIONAL,
-    IN OUT  PULONG      Length
+    _In_ const CHAR *Signature,
+    _Out_opt_ PVOID Buffer,
+    _Inout_ PULONG  Length
     );
 
 extern VOID
diff --git a/src/xen/bug_check.c b/src/xen/bug_check.c
index 41b5f73..85f9f70 100644
--- a/src/xen/bug_check.c
+++ b/src/xen/bug_check.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -61,7 +61,7 @@ BugCheckTeardown(
 
 static VOID
 BugCheckDumpExceptionRecord(
-    IN  PEXCEPTION_RECORD   Exception
+    _In_ PEXCEPTION_RECORD  Exception
     )
 {
     __try {
@@ -108,7 +108,7 @@ BugCheckDumpExceptionRecord(
 #if defined(__i386__)
 static VOID
 BugCheckDumpContext(
-    IN  PCONTEXT    Context
+    _In_ PCONTEXT   Context
     )
 {
     __try {
@@ -190,7 +190,7 @@ BugCheckDumpContext(
 
 static VOID
 BugCheckStackDump(
-    IN  PCONTEXT    Context
+    _In_ PCONTEXT   Context
     )
 {
 #define PARAMETER_COUNT     3
@@ -269,7 +269,7 @@ BugCheckStackDump(
 #elif defined(__x86_64__)
 static VOID
 BugCheckDumpContext(
-    IN  PCONTEXT    Context
+    _In_ PCONTEXT   Context
     )
 {
     __try {
@@ -493,7 +493,7 @@ RtlVirtualUnwind(
 
 static VOID
 BugCheckStackDump(
-    IN  PCONTEXT    Context
+    _In_ PCONTEXT   Context
     )
 {
 #define PARAMETER_COUNT     4
@@ -506,7 +506,7 @@ BugCheckStackDump(
 
         LogPrintf(LOG_LEVEL_CRITICAL,
                   "%s|BUGCHECK: STACK:\n",
-                  __MODULE__);	
+                  __MODULE__);
 
         for (Iteration = 0; Iteration < MAXIMUM_ITERATIONS; Iteration++) {
             PRUNTIME_FUNCTION   FunctionEntry;
@@ -607,10 +607,10 @@ RtlCaptureContext(
 
 static VOID
 BugCheckIrqlNotLessOrEqual(
-    IN  ULONG_PTR   Parameter1,
-    IN  ULONG_PTR   Parameter2,
-    IN  ULONG_PTR   Parameter3,
-    IN  ULONG_PTR   Parameter4
+    _In_ ULONG_PTR  Parameter1,
+    _In_ ULONG_PTR  Parameter2,
+    _In_ ULONG_PTR  Parameter3,
+    _In_ ULONG_PTR  Parameter4
     )
 {
     __try {
@@ -658,10 +658,10 @@ BugCheckIrqlNotLessOrEqual(
 
 static VOID
 BugCheckDriverIrqlNotLessOrEqual(
-    IN  ULONG_PTR   Parameter1,
-    IN  ULONG_PTR   Parameter2,
-    IN  ULONG_PTR   Parameter3,
-    IN  ULONG_PTR   Parameter4
+    _In_ ULONG_PTR  Parameter1,
+    _In_ ULONG_PTR  Parameter2,
+    _In_ ULONG_PTR  Parameter3,
+    _In_ ULONG_PTR  Parameter4
     )
 {
     __try {
@@ -709,10 +709,10 @@ BugCheckDriverIrqlNotLessOrEqual(
 
 static VOID
 BugCheckSystemServiceException(
-    IN  ULONG_PTR   Parameter1,
-    IN  ULONG_PTR   Parameter2,
-    IN  ULONG_PTR   Parameter3,
-    IN  ULONG_PTR   Parameter4
+    _In_ ULONG_PTR  Parameter1,
+    _In_ ULONG_PTR  Parameter2,
+    _In_ ULONG_PTR  Parameter3,
+    _In_ ULONG_PTR  Parameter4
     )
 {
     __try {
@@ -732,10 +732,10 @@ BugCheckSystemServiceException(
 
 static VOID
 BugCheckSystemThreadExceptionNotHandled(
-    IN  ULONG_PTR   Parameter1,
-    IN  ULONG_PTR   Parameter2,
-    IN  ULONG_PTR   Parameter3,
-    IN  ULONG_PTR   Parameter4
+    _In_ ULONG_PTR  Parameter1,
+    _In_ ULONG_PTR  Parameter2,
+    _In_ ULONG_PTR  Parameter3,
+    _In_ ULONG_PTR  Parameter4
     )
 {
     __try {
@@ -773,10 +773,10 @@ BugCheckSystemThreadExceptionNotHandled(
 
 static VOID
 BugCheckKernelModeExceptionNotHandled(
-    IN  ULONG_PTR   Parameter1,
-    IN  ULONG_PTR   Parameter2,
-    IN  ULONG_PTR   Parameter3,
-    IN  ULONG_PTR   Parameter4
+    _In_ ULONG_PTR  Parameter1,
+    _In_ ULONG_PTR  Parameter2,
+    _In_ ULONG_PTR  Parameter3,
+    _In_ ULONG_PTR  Parameter4
     )
 {
     __try {
@@ -820,10 +820,10 @@ BugCheckKernelModeExceptionNotHandled(
 
 static VOID
 BugCheckCriticalObjectTermination(
-    IN  ULONG_PTR   Parameter1,
-    IN  ULONG_PTR   Parameter2,
-    IN  ULONG_PTR   Parameter3,
-    IN  ULONG_PTR   Parameter4
+    _In_ ULONG_PTR  Parameter1,
+    _In_ ULONG_PTR  Parameter2,
+    _In_ ULONG_PTR  Parameter3,
+    _In_ ULONG_PTR  Parameter4
     )
 {
     __try {
@@ -859,10 +859,10 @@ BugCheckCriticalObjectTermination(
 
 static VOID
 BugCheckInaccessibleBootDevice(
-    IN  ULONG_PTR   Parameter1,
-    IN  ULONG_PTR   Parameter2,
-    IN  ULONG_PTR   Parameter3,
-    IN  ULONG_PTR   Parameter4
+    _In_ ULONG_PTR  Parameter1,
+    _In_ ULONG_PTR  Parameter2,
+    _In_ ULONG_PTR  Parameter3,
+    _In_ ULONG_PTR  Parameter4
     )
 {
     __try {
@@ -887,10 +887,10 @@ BugCheckInaccessibleBootDevice(
 
 static VOID
 BugCheckDriverPowerStateFailure(
-    IN  ULONG_PTR       Parameter1,
-    IN  ULONG_PTR       Parameter2,
-    IN  ULONG_PTR       Parameter3,
-    IN  ULONG_PTR       Parameter4
+    _In_ ULONG_PTR      Parameter1,
+    _In_ ULONG_PTR      Parameter2,
+    _In_ ULONG_PTR      Parameter3,
+    _In_ ULONG_PTR      Parameter4
     )
 {
     __try {
@@ -930,7 +930,7 @@ BugCheckDriverPowerStateFailure(
 
             LogPrintf(LOG_LEVEL_CRITICAL,
                       "%s|BUGCHECK: IRP STACK:\n",
-                      __MODULE__);	
+                      __MODULE__);
 
             for (Index = 0; Index <= Irp->StackCount; Index++) {
                 PCHAR       Name;
@@ -972,7 +972,7 @@ BugCheckDriverPowerStateFailure(
                           StackLocation->Context);
 
                 StackLocation++;
-            } 
+            }
 
             break;
         }
@@ -986,10 +986,10 @@ BugCheckDriverPowerStateFailure(
 
 static VOID
 BugCheckAssertionFailure(
-    IN  ULONG_PTR   Parameter1,
-    IN  ULONG_PTR   Parameter2,
-    IN  ULONG_PTR   Parameter3,
-    IN  ULONG_PTR   Parameter4
+    _In_ ULONG_PTR  Parameter1,
+    _In_ ULONG_PTR  Parameter2,
+    _In_ ULONG_PTR  Parameter3,
+    _In_ ULONG_PTR  Parameter4
     )
 {
     __try {
@@ -1025,10 +1025,10 @@ BugCheckAssertionFailure(
 /// <param name="Parameter4">reserved.</param>
 static VOID
 BugCheckBugEFCriticalProcessDied(
-    IN  ULONG_PTR   Parameter1,
-    IN  ULONG_PTR   Parameter2,
-    IN  ULONG_PTR   Parameter3,
-    IN  ULONG_PTR   Parameter4
+    _In_ ULONG_PTR  Parameter1,
+    _In_ ULONG_PTR  Parameter2,
+    _In_ ULONG_PTR  Parameter3,
+    _In_ ULONG_PTR  Parameter4
     )
 {
     __try {
@@ -1121,10 +1121,11 @@ BugCheckDefaultHandler(
 
 KBUGCHECK_CALLBACK_ROUTINE BugCheckBugCheckCallback;
 
-VOID                     
+_Use_decl_annotations_
+VOID
 BugCheckBugCheckCallback(
-    IN  PVOID               Argument,
-    IN  ULONG               Length
+    _In_ PVOID              Argument,
+    _In_ ULONG              Length
     )
 {
     extern PULONG_PTR       KiBugCheckData;
diff --git a/src/xen/config.c b/src/xen/config.c
index e600732..45d66c6 100644
--- a/src/xen/config.c
+++ b/src/xen/config.c
@@ -56,8 +56,8 @@
 XEN_API
 NTSTATUS
 ConfigGetActive(
-    IN  const CHAR  *Key,
-    OUT PCHAR       *Value
+    _In_ const CHAR *Key,
+    _Out_ PCHAR     *Value
     )
 {
     HANDLE          ActiveKey;
@@ -126,7 +126,7 @@ fail1:
 
 static FORCEINLINE BOOLEAN
 __ConfigIsDeviceLegacy(
-    IN  PCHAR   DeviceID
+    _In_ PCHAR  DeviceID
     )
 {
     UNREFERENCED_PARAMETER(DeviceID);
@@ -188,9 +188,9 @@ fail1:
 XEN_API
 NTSTATUS
 ConfigSetActive(
-    IN  PCHAR   DeviceID,
-    IN  PCHAR   InstanceID,
-    IN  PCHAR   LocationInformation
+    _In_ PCHAR  DeviceID,
+    _In_ PCHAR  InstanceID,
+    _In_ PCHAR  LocationInformation
     )
 {
     HANDLE      ActiveKey;
@@ -273,9 +273,9 @@ fail1:
 XEN_API
 NTSTATUS
 ConfigUpdateActive(
-    IN  PCHAR   DeviceID,
-    IN  PCHAR   InstanceID,
-    IN  PCHAR   LocationInformation
+    _In_ PCHAR  DeviceID,
+    _In_ PCHAR  InstanceID,
+    _In_ PCHAR  LocationInformation
     )
 {
     HANDLE      ActiveKey;
@@ -410,8 +410,8 @@ fail1:
 XEN_API
 NTSTATUS
 ConfigRequestReboot(
-    IN  HANDLE      ParametersKey,
-    IN  PCHAR       Module
+    _In_ HANDLE     ParametersKey,
+    _In_ PCHAR      Module
     )
 {
     PANSI_STRING    Ansi;
@@ -489,8 +489,8 @@ fail1:
 XEN_API
 NTSTATUS
 ConfigQuerySystemStartOption(
-    IN  PCHAR           Key,
-    OUT PANSI_STRING    *Option
+    _In_ PCHAR          Key,
+    _Out_ PANSI_STRING  *Option
     )
 {
     return RegistryQuerySystemStartOption(Key, Option);
diff --git a/src/xen/driver.c b/src/xen/driver.c
index e04a772..107dc65 100644
--- a/src/xen/driver.c
+++ b/src/xen/driver.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -74,7 +74,7 @@ extern PULONG   InitSafeBootMode;
 
 static FORCEINLINE PVOID
 __DriverAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XEN_DRIVER_TAG);
@@ -82,7 +82,7 @@ __DriverAllocate(
 
 static FORCEINLINE VOID
 __DriverFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XEN_DRIVER_TAG);
@@ -98,7 +98,7 @@ __DriverSafeMode(
 
 static FORCEINLINE VOID
 __DriverSetParametersKey(
-    IN  HANDLE  Key
+    _In_opt_ HANDLE Key
     )
 {
     Driver.ParametersKey = Key;
@@ -122,7 +122,7 @@ DriverGetParametersKey(
 
 static FORCEINLINE VOID
 __DriverSetUnplugKey(
-    IN  HANDLE  Key
+    _In_opt_ HANDLE Key
     )
 {
     Driver.UnplugKey = Key;
@@ -146,7 +146,7 @@ DriverGetUnplugKey(
 
 static FORCEINLINE VOID
 __DriverSetMemoryKey(
-    IN  HANDLE  Key
+    _In_opt_ HANDLE Key
     )
 {
     Driver.MemoryKey = Key;
@@ -164,9 +164,9 @@ __DriverGetMemoryKey(
 
 static FORCEINLINE NTSTATUS
 __DriverSetPfnArray(
-    IN  PCHAR       Name,
-    IN  ULONG       Count,
-    IN  PFN_NUMBER  PfnArray[]
+    _In_ PCHAR      Name,
+    _In_ ULONG      Count,
+    _In_ PFN_NUMBER PfnArray[]
     )
 {
     HANDLE          Key = __DriverGetMemoryKey();
@@ -224,9 +224,9 @@ fail1:
 
 static FORCEINLINE NTSTATUS
 __DriverAllocatePfnArray(
-    IN  PCHAR           Name,
-    IN  ULONG           Count,
-    OUT PFN_NUMBER      PfnArray[]
+    _In_ PCHAR          Name,
+    _In_ ULONG          Count,
+    _Out_ PFN_NUMBER    PfnArray[]
     )
 {
     PHYSICAL_ADDRESS    LowAddress;
@@ -289,14 +289,14 @@ fail1:
 
 static FORCEINLINE NTSTATUS
 __DriverGetPfnArray(
-    IN  PCHAR       Name,
-    IN  ULONG       Count,
-    OUT PFN_NUMBER  PfnArray[]
+    _In_ PCHAR                      Name,
+    _In_ ULONG                      Count,
+    _Out_writes_(Count) PFN_NUMBER  PfnArray[]
     )
 {
-    HANDLE          Key = __DriverGetMemoryKey();
-    ULONG           Index;
-    NTSTATUS        status;
+    HANDLE                          Key = __DriverGetMemoryKey();
+    ULONG                           Index;
+    NTSTATUS                        status;
 
     for (Index = 0; Index < Count; Index++) {
         CHAR    ValueName[MAXNAMELEN];
@@ -341,8 +341,8 @@ fail1:
 
 PMDL
 DriverGetNamedPages(
-    IN  PCHAR   Name,
-    IN  ULONG   Count
+    _In_ PCHAR  Name,
+    _In_ ULONG  Count
     )
 {
     ULONG       Size;
@@ -407,7 +407,7 @@ fail1:
 
 VOID
 DriverPutNamedPages(
-    IN  PMDL    Mdl
+    _In_ PMDL   Mdl
     )
 {
     PUCHAR	    MdlMappedSystemVa;
@@ -425,11 +425,11 @@ DriverPutNamedPages(
 XEN_API
 NTSTATUS
 XenTouch(
-    IN  const CHAR  *Name,
-    IN  ULONG       MajorVersion,
-    IN  ULONG       MinorVersion,
-    IN  ULONG       MicroVersion,
-    IN  ULONG       BuildNumber
+    _In_ const CHAR *Name,
+    _In_ ULONG      MajorVersion,
+    _In_ ULONG      MinorVersion,
+    _In_ ULONG      MicroVersion,
+    _In_ ULONG      BuildNumber
    )
 {
     static ULONG    Reference;
@@ -479,9 +479,9 @@ fail1:
 
 static VOID
 DriverOutputBuffer(
-    IN  PVOID   Argument,
-    IN  PCHAR   Buffer,
-    IN  ULONG   Length
+    _In_ PVOID  Argument,
+    _In_ PCHAR  Buffer,
+    _In_ ULONG  Length
     )
 {
     ULONG_PTR   Port = (ULONG_PTR)Argument;
@@ -494,15 +494,15 @@ DriverOutputBuffer(
 
 NTSTATUS
 DllInitialize(
-    IN  PUNICODE_STRING RegistryPath
+    _In_ PUNICODE_STRING    RegistryPath
     )
 {
-    HANDLE              ServiceKey;
-    HANDLE              ParametersKey;
-    HANDLE              UnplugKey;
-    HANDLE              MemoryKey;
-    LOG_LEVEL           LogLevel;
-    NTSTATUS            status;
+    HANDLE                  ServiceKey;
+    HANDLE                  ParametersKey;
+    HANDLE                  UnplugKey;
+    HANDLE                  MemoryKey;
+    LOG_LEVEL               LogLevel;
+    NTSTATUS                status;
 
     ExInitializeDriverRuntime(DrvRtPoolNxOptIn);
     WdmlibProcgrpInitialize();
@@ -762,8 +762,8 @@ DRIVER_INITIALIZE   DriverEntry;
 
 NTSTATUS
 DriverEntry(
-    IN  PDRIVER_OBJECT  DriverObject,
-    IN  PUNICODE_STRING RegistryPath
+    _In_ PDRIVER_OBJECT     DriverObject,
+    _In_ PUNICODE_STRING    RegistryPath
     )
 {
     UNREFERENCED_PARAMETER(DriverObject);
diff --git a/src/xen/driver.h b/src/xen/driver.h
index 210b561..6806886 100644
--- a/src/xen/driver.h
+++ b/src/xen/driver.h
@@ -45,13 +45,13 @@ DriverGetUnplugKey(
 
 extern PMDL
 DriverGetNamedPages(
-    IN  PCHAR   Name,
-    IN  ULONG   Count
+    _In_ PCHAR  Name,
+    _In_ ULONG  Count
     );
 
 extern VOID
 DriverPutNamedPages(
-    IN  PMDL    Mdl
+    _In_ PMDL   Mdl
     );
 
 #endif  // _XEN_DRIVER_H
diff --git a/src/xen/event_channel.c b/src/xen/event_channel.c
index 2344169..1e91882 100644
--- a/src/xen/event_channel.c
+++ b/src/xen/event_channel.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -41,18 +41,18 @@
 
 static LONG_PTR
 EventChannelOp(
-    IN  ULONG   Command,
-    IN  PVOID   Argument
+    _In_ ULONG  Command,
+    _In_ PVOID  Argument
     )
 {
     return HYPERCALL(LONG_PTR, event_channel_op, 2, Command, Argument);
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelSend(
-    IN  ULONG           LocalPort
+    _In_ ULONG          LocalPort
     )
 {
     struct evtchn_send  op;
@@ -76,12 +76,12 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelAllocateUnbound(
-    IN  USHORT                  Domain,
-    OUT ULONG                   *LocalPort
+    _In_ USHORT                 Domain,
+    _Out_ ULONG                 *LocalPort
     )
 {
     struct evtchn_alloc_unbound op;
@@ -99,7 +99,7 @@ EventChannelAllocateUnbound(
     }
 
     *LocalPort = op.port;
-    
+
     return STATUS_SUCCESS;
 
 fail1:
@@ -108,13 +108,13 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelBindInterDomain(
-    IN  USHORT                      RemoteDomain,
-    IN  ULONG                       RemotePort,
-    OUT ULONG                       *LocalPort
+    _In_ USHORT                     RemoteDomain,
+    _In_ ULONG                      RemotePort,
+    _Out_ ULONG                     *LocalPort
     )
 {
     struct evtchn_bind_interdomain  op;
@@ -132,7 +132,7 @@ EventChannelBindInterDomain(
     }
 
     *LocalPort = op.local_port;
-    
+
     return STATUS_SUCCESS;
 
 fail1:
@@ -141,13 +141,13 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelBindVirq(
-    IN  ULONG               Virq,
-    IN  unsigned int        vcpu_id,
-    OUT ULONG               *LocalPort
+    _In_ ULONG              Virq,
+    _In_ unsigned int       vcpu_id,
+    _Out_ ULONG             *LocalPort
     )
 {
     struct evtchn_bind_virq op;
@@ -165,7 +165,7 @@ EventChannelBindVirq(
     }
 
     *LocalPort = op.port;
-    
+
     return STATUS_SUCCESS;
 
 fail1:
@@ -174,13 +174,13 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelQueryInterDomain(
-    IN  ULONG               LocalPort,
-    OUT USHORT              *RemoteDomain,
-    OUT ULONG               *RemotePort
+    _In_ ULONG              LocalPort,
+    _Out_ USHORT            *RemoteDomain,
+    _Out_ ULONG             *RemotePort
     )
 {
     struct evtchn_status    op;
@@ -215,11 +215,11 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelClose(
-    IN  ULONG           LocalPort
+    _In_ ULONG          LocalPort
     )
 {
     struct evtchn_close op;
@@ -243,11 +243,11 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelExpandArray(
-    IN  PFN_NUMBER              Pfn
+    _In_ PFN_NUMBER             Pfn
     )
 {
     struct evtchn_expand_array  op;
@@ -271,12 +271,12 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelInitControl(
-    IN  PFN_NUMBER              Pfn,
-    IN  unsigned int            vcpu_id
+    _In_ PFN_NUMBER             Pfn,
+    _In_ unsigned int           vcpu_id
     )
 {
     struct evtchn_init_control  op;
@@ -302,7 +302,7 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelReset(
@@ -330,12 +330,12 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelBindVirtualCpu(
-    IN  ULONG               LocalPort,
-    IN  unsigned int        vcpu_id
+    _In_ ULONG              LocalPort,
+    _In_ unsigned int       vcpu_id
     )
 {
     struct evtchn_bind_vcpu op;
@@ -360,11 +360,11 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 EventChannelUnmask(
-    IN  ULONG               LocalPort
+    _In_ ULONG              LocalPort
     )
 {
     struct evtchn_unmask    op;
diff --git a/src/xen/filters.c b/src/xen/filters.c
index 36a266f..b643404 100644
--- a/src/xen/filters.c
+++ b/src/xen/filters.c
@@ -49,7 +49,7 @@
 
 static FORCEINLINE PVOID
 __FiltersAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_FILTERS_TAG);
@@ -57,7 +57,7 @@ __FiltersAllocate(
 
 static FORCEINLINE VOID
 __FiltersFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_FILTERS_TAG);
@@ -67,9 +67,9 @@ __FiltersFree(
 
 static NTSTATUS
 FiltersInstallClass(
-    IN  const CHAR  *ClassName,
-    IN  const GUID  *ClassGuid,
-    IN  const CHAR  *DriverName
+    _In_ const CHAR *ClassName,
+    _In_ const GUID *ClassGuid,
+    _In_ const CHAR *DriverName
     )
 {
     HANDLE          ClassKey;
@@ -196,9 +196,9 @@ fail1:
 
 static NTSTATUS
 FiltersUninstallClass(
-    IN  const CHAR  *ClassName,
-    IN  const GUID  *ClassGuid,
-    IN  const CHAR  *DriverName
+    _In_ const CHAR *ClassName,
+    _In_ const GUID *ClassGuid,
+    _In_ const CHAR *DriverName
     )
 {
     HANDLE          ClassKey;
diff --git a/src/xen/grant_table.c b/src/xen/grant_table.c
index 65c7d13..96a5a26 100644
--- a/src/xen/grant_table.c
+++ b/src/xen/grant_table.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -73,19 +73,19 @@
 
 static LONG_PTR
 GrantTableOp(
-    IN  ULONG   Command,
-    IN  PVOID   Argument,
-    IN  ULONG   Count
+    _In_ ULONG  Command,
+    _In_ PVOID  Argument,
+    _In_ ULONG  Count
     )
 {
     return HYPERCALL(LONG_PTR, grant_table_op, 3, Command, Argument, Count);
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 GrantTableSetVersion(
-    IN  uint32_t                Version
+    _In_ uint32_t               Version
     )
 {
     struct gnttab_set_version   op;
@@ -109,11 +109,11 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 GrantTableGetVersion(
-    OUT uint32_t                *Version
+    _Out_ uint32_t              *Version
     )
 {
     struct gnttab_get_version   op;
@@ -139,12 +139,12 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 GrantTableCopy(
-    IN  struct gnttab_copy  op[],
-    IN  ULONG               Count
+    _In_ struct gnttab_copy op[],
+    _In_ ULONG              Count
     )
 {
     LONG_PTR                rc;
@@ -165,15 +165,15 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 GrantTableMapForeignPage(
-    IN  USHORT                  Domain,
-    IN  ULONG                   GrantRef,
-    IN  PHYSICAL_ADDRESS        Address,
-    IN  BOOLEAN                 ReadOnly,
-    OUT ULONG                   *Handle
+    _In_ USHORT                 Domain,
+    _In_ ULONG                  GrantRef,
+    _In_ PHYSICAL_ADDRESS       Address,
+    _In_ BOOLEAN                ReadOnly,
+    _Out_ ULONG                 *Handle
     )
 {
     struct gnttab_map_grant_ref op;
@@ -220,12 +220,12 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 GrantTableUnmapForeignPage(
-    IN  ULONG                     Handle,
-    IN  PHYSICAL_ADDRESS          Address
+    _In_ ULONG                    Handle,
+    _In_ PHYSICAL_ADDRESS         Address
     )
 {
     struct gnttab_unmap_grant_ref op;
@@ -264,12 +264,12 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 GrantTableQuerySize(
-    OUT uint32_t                *Current OPTIONAL,
-    OUT uint32_t                *Maximum OPTIONAL
+    _Out_opt_ uint32_t          *Current,
+    _Out_opt_ uint32_t          *Maximum
     )
 {
     struct gnttab_query_size    op;
diff --git a/src/xen/hvm.c b/src/xen/hvm.c
index 9887681..6dea2ab 100644
--- a/src/xen/hvm.c
+++ b/src/xen/hvm.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -41,19 +41,19 @@
 
 static LONG_PTR
 HvmOp(
-    IN  ULONG   Command,
-    IN  PVOID   Argument
+    _In_ ULONG  Command,
+    _In_ PVOID  Argument
     )
 {
     return HYPERCALL(LONG_PTR, hvm_op, 2, Command, Argument);
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 HvmSetParam(
-    IN  ULONG               Parameter,
-    IN  ULONGLONG           Value
+    _In_ ULONG              Parameter,
+    _In_ ULONGLONG          Value
     )
 {
     struct xen_hvm_param    op;
@@ -65,7 +65,7 @@ HvmSetParam(
     op.value = Value;
 
     rc = HvmOp(HVMOP_set_param, &op);
-    
+
     if (rc < 0) {
         ERRNO_TO_STATUS(-rc, status);
         goto fail1;
@@ -78,13 +78,13 @@ fail1:
 
     return status;
 }
-    
-__checkReturn
+
+_Check_return_
 XEN_API
 NTSTATUS
 HvmGetParam(
-    IN  ULONG               Parameter,
-    OUT PULONGLONG          Value
+    _In_ ULONG              Parameter,
+    _Out_ PULONGLONG        Value
     )
 {
     struct xen_hvm_param    op;
@@ -96,7 +96,7 @@ HvmGetParam(
     op.value = 0xFEEDFACE;
 
     rc = HvmOp(HVMOP_get_param, &op);
-    
+
     if (rc < 0) {
         ERRNO_TO_STATUS(-rc, status);
         goto fail1;
@@ -113,11 +113,11 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 HvmPagetableDying(
-    IN  PHYSICAL_ADDRESS            Address
+    _In_ PHYSICAL_ADDRESS           Address
     )
 {
     struct xen_hvm_pagetable_dying  op;
@@ -128,7 +128,7 @@ HvmPagetableDying(
     op.gpa = Address.QuadPart;
 
     rc = HvmOp(HVMOP_pagetable_dying, &op);
-    
+
     if (rc < 0) {
         ERRNO_TO_STATUS(-rc, status);
         goto fail1;
@@ -140,12 +140,12 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 HvmSetEvtchnUpcallVector(
-    IN  unsigned int                    vcpu_id,
-    IN  UCHAR                           Vector
+    _In_ unsigned int                   vcpu_id,
+    _In_ UCHAR                          Vector
     )
 {
     struct xen_hvm_evtchn_upcall_vector op;
diff --git a/src/xen/log.c b/src/xen/log.c
index 20c9a4a..c81c834 100644
--- a/src/xen/log.c
+++ b/src/xen/log.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -73,8 +73,8 @@ static LOG_CONTEXT  LogContext;
 
 static FORCEINLINE VOID
 __LogFlushSlot(
-    IN  PLOG_CONTEXT    Context,
-    IN  PLOG_SLOT       Slot
+    _In_ PLOG_CONTEXT   Context,
+    _In_ PLOG_SLOT      Slot
     )
 {
     ULONG               Index;
@@ -94,7 +94,7 @@ __LogFlushSlot(
 
 static VOID
 LogFlush(
-    IN  PLOG_CONTEXT    Context
+    _In_ PLOG_CONTEXT   Context
     )
 {
     ULONG               Index;
@@ -111,8 +111,8 @@ LogFlush(
 
 static FORCEINLINE VOID
 __LogPut(
-    IN  PLOG_SLOT   Slot,
-    IN  CHAR        Character
+    _In_ PLOG_SLOT  Slot,
+    _In_ CHAR       Character
     )
 {
     if (Slot->Offset >= LOG_BUFFER_SIZE)
@@ -123,10 +123,10 @@ __LogPut(
 
 static PCHAR
 LogFormatNumber(
-    IN  PCHAR       Buffer,
-    IN  ULONGLONG   Value,
-    IN  UCHAR       Base,
-    IN  BOOLEAN     UpperCase
+    _In_ PCHAR      Buffer,
+    _In_ ULONGLONG  Value,
+    _In_ UCHAR      Base,
+    _In_ BOOLEAN    UpperCase
     )
 {
     ULONGLONG       Next = Value / Base;
@@ -183,10 +183,10 @@ LogFormatNumber(
 
 static VOID
 LogWriteSlot(
-    IN  PLOG_SLOT   Slot,
-    IN  LONG        Count,
-    IN  const CHAR  *Format,
-    IN  va_list     Arguments
+    _In_ PLOG_SLOT  Slot,
+    _In_ LONG       Count,
+    _In_ const CHAR *Format,
+    _In_ va_list    Arguments
     )
 {
     CHAR            Character;
@@ -197,7 +197,7 @@ LogWriteSlot(
         BOOLEAN Wide = FALSE;
         BOOLEAN ZeroPrefix = FALSE;
         BOOLEAN OppositeJustification = FALSE;
-        
+
         if (Character != '%') {
             __LogPut(Slot, Character);
             goto loop;
@@ -249,7 +249,7 @@ LogWriteSlot(
                 Value = va_arg(Arguments, WCHAR);
 
                 __LogPut(Slot, (CHAR)Value);
-            } else { 
+            } else {
                 CHAR    Value;
 
                 Value = va_arg(Arguments, CHAR);
@@ -432,10 +432,10 @@ loop:
 XEN_API
 VOID
 LogCchVPrintf(
-    IN  LOG_LEVEL   Level,
-    IN  ULONG       Count,
-    IN  const CHAR  *Format,
-    IN  va_list     Arguments
+    _In_ LOG_LEVEL  Level,
+    _In_ ULONG      Count,
+    _In_ const CHAR *Format,
+    _In_ va_list    Arguments
     )
 {
     PLOG_CONTEXT    Context = &LogContext;
@@ -463,9 +463,9 @@ LogCchVPrintf(
 XEN_API
 VOID
 LogVPrintf(
-    IN  LOG_LEVEL   Level,
-    IN  const CHAR  *Format,
-    IN  va_list     Arguments
+    _In_ LOG_LEVEL  Level,
+    _In_ const CHAR *Format,
+    _In_ va_list    Arguments
     )
 {
     LogCchVPrintf(Level, LOG_BUFFER_SIZE, Format, Arguments);
@@ -474,9 +474,9 @@ LogVPrintf(
 XEN_API
 VOID
 LogCchPrintf(
-    IN  LOG_LEVEL   Level,
-    IN  ULONG       Count,
-    IN  const CHAR  *Format,
+    _In_ LOG_LEVEL  Level,
+    _In_ ULONG      Count,
+    _In_ const CHAR *Format,
     ...
     )
 {
@@ -490,8 +490,8 @@ LogCchPrintf(
 XEN_API
 VOID
 LogPrintf(
-    IN  LOG_LEVEL   Level,
-    IN  const CHAR  *Format,
+    _In_ LOG_LEVEL  Level,
+    _In_ const CHAR *Format,
     ...
     )
 {
@@ -517,10 +517,10 @@ _IRQL_requires_(DISPATCH_LEVEL)
 _IRQL_requires_same_
 VOID
 LogDpc(
-    IN  PKDPC       Dpc,
-    IN  PVOID       _Context,
-    IN  PVOID       Argument1,
-    IN  PVOID       Argument2
+    _In_ PKDPC      Dpc,
+    _In_ PVOID      _Context,
+    _In_ PVOID      Argument1,
+    _In_ PVOID      Argument2
     )
 {
     PLOG_CONTEXT    Context = &LogContext;
@@ -538,9 +538,9 @@ LogDpc(
 
 static VOID
 LogDebugPrint(
-    IN  PANSI_STRING    Ansi,
-    IN  ULONG           ComponentId,
-    IN  ULONG           Level
+    _In_ PANSI_STRING   Ansi,
+    _In_ ULONG          ComponentId,
+    _In_ ULONG          Level
     )
 {
     PLOG_CONTEXT        Context = &LogContext;
@@ -588,7 +588,7 @@ LogTeardown(
     PLOG_CONTEXT    Context = &LogContext;
 
     if (Context->Enabled) {
-        (VOID) DbgSetDebugPrintCallback(LogDebugPrint, FALSE); 
+        (VOID) DbgSetDebugPrintCallback(LogDebugPrint, FALSE);
         Context->Enabled = FALSE;
     }
 
@@ -602,10 +602,10 @@ LogTeardown(
 
 NTSTATUS
 LogAddDisposition(
-    IN  LOG_LEVEL           Mask,
-    IN  VOID                (*Function)(PVOID, PCHAR, ULONG),
-    IN  PVOID               Argument OPTIONAL,
-    OUT PLOG_DISPOSITION    *Disposition
+    _In_ LOG_LEVEL          Mask,
+    _In_ VOID               (*Function)(PVOID, PCHAR, ULONG),
+    _In_opt_ PVOID          Argument,
+    _Out_ PLOG_DISPOSITION  *Disposition
     )
 {
     PLOG_CONTEXT            Context = &LogContext;
@@ -653,7 +653,7 @@ fail1:
 
 extern VOID
 LogRemoveDisposition(
-    IN  PLOG_DISPOSITION    Disposition
+    _In_ PLOG_DISPOSITION   Disposition
     )
 {
     PLOG_CONTEXT            Context = &LogContext;
@@ -736,15 +736,15 @@ static const XEN_LOG_LEVEL_NAME XenLogLevelNames[] = {
 XEN_API
 NTSTATUS
 LogReadLogLevel(
-    IN  HANDLE      Key,
-    IN  PCHAR       Name,
-    OUT PLOG_LEVEL  LogLevel
+    _In_ HANDLE         Key,
+    _In_ PCHAR          Name,
+    _Out_ PLOG_LEVEL    LogLevel
     )
 {
-    PANSI_STRING    Values;
-    ULONG           Type;
-    ULONG           Index;
-    NTSTATUS        status;
+    PANSI_STRING        Values;
+    ULONG               Type;
+    ULONG               Index;
+    NTSTATUS            status;
 
     status = RegistryQuerySzValue(Key,
                                   Name,
diff --git a/src/xen/memory.c b/src/xen/memory.c
index bc12140..6a3a3d0 100644
--- a/src/xen/memory.c
+++ b/src/xen/memory.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -41,20 +41,20 @@
 
 static FORCEINLINE LONG_PTR
 MemoryOp(
-    IN  ULONG   Command,
-    IN  PVOID   Argument
+    _In_ ULONG  Command,
+    _In_ PVOID  Argument
     )
 {
     return HYPERCALL(LONG_PTR, memory_op, 2, Command, Argument);
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 MemoryAddToPhysmap(
-    IN  PFN_NUMBER              Pfn,
-    IN  ULONG                   Space,
-    IN  ULONG_PTR               Offset
+    _In_ PFN_NUMBER             Pfn,
+    _In_ ULONG                  Space,
+    _In_ ULONG_PTR              Offset
     )
 {
     struct xen_add_to_physmap   op;
@@ -81,11 +81,11 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 MemoryRemoveFromPhysmap(
-    IN  PFN_NUMBER                  Pfn
+    _In_ PFN_NUMBER                 Pfn
     )
 {
     struct xen_remove_from_physmap  op;
@@ -110,13 +110,13 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 ULONG
 MemoryDecreaseReservation(
-    IN  ULONG                       Order,
-    IN  ULONG                       Count,
-    IN  PPFN_NUMBER                 PfnArray
+    _In_ ULONG                      Order,
+    _In_ ULONG                      Count,
+    _In_ PPFN_NUMBER                PfnArray
     )
 {
     struct xen_memory_reservation   op;
@@ -133,13 +133,13 @@ MemoryDecreaseReservation(
     return (ULONG)rc;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 ULONG
 MemoryPopulatePhysmap(
-    IN  ULONG                       Order,
-    IN  ULONG                       Count,
-    IN  PPFN_NUMBER                 PfnArray
+    _In_ ULONG                      Order,
+    _In_ ULONG                      Count,
+    _In_ PPFN_NUMBER                PfnArray
     )
 {
     struct xen_memory_reservation   op;
diff --git a/src/xen/module.c b/src/xen/module.c
index 1f0212f..6c804bc 100644
--- a/src/xen/module.c
+++ b/src/xen/module.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -62,7 +62,7 @@ static MODULE_CONTEXT   ModuleContext;
 
 static FORCEINLINE PVOID
 __ModuleAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, MODULE_TAG);
@@ -70,7 +70,7 @@ __ModuleAllocate(
 
 static FORCEINLINE VOID
 __ModuleFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, MODULE_TAG);
@@ -78,8 +78,8 @@ __ModuleFree(
 
 static VOID
 ModuleSearchForwards(
-    IN  PMODULE_CONTEXT Context,
-    IN  ULONG_PTR       Address
+    _In_ PMODULE_CONTEXT    Context,
+    _In_ ULONG_PTR          Address
     )
 {
     while (Context->Cursor != &Context->List) {
@@ -96,8 +96,8 @@ ModuleSearchForwards(
 
 static VOID
 ModuleSearchBackwards(
-    IN  PMODULE_CONTEXT Context,
-    IN  ULONG_PTR       Address
+    _In_ PMODULE_CONTEXT    Context,
+    _In_ ULONG_PTR          Address
     )
 {
     while (Context->Cursor != &Context->List) {
@@ -114,10 +114,10 @@ ModuleSearchBackwards(
 
 static NTSTATUS
 ModuleAdd(
-    IN  PMODULE_CONTEXT Context,
-    IN  PCHAR           Name,
-    IN  ULONG_PTR       Start,
-    IN  ULONG_PTR       Size
+    _In_ PMODULE_CONTEXT    Context,
+    _In_ PCHAR              Name,
+    _In_ ULONG_PTR          Start,
+    _In_ ULONG_PTR          Size
     )
 {
 #define INSERT_AFTER(_Cursor, _New)             \
@@ -221,7 +221,7 @@ again:
         }
     } else {
         PLIST_ENTRY Cursor;
-        
+
         Cursor = (Context->Cursor->Flink != &Context->List) ?
                  Context->Cursor->Flink :
                  Context->Cursor->Blink;
@@ -264,12 +264,12 @@ fail1:
 #undef  INSERT_BEFORE
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static VOID
 ModuleLoad(
-    IN  PUNICODE_STRING FullImageName,
-    IN  HANDLE          ProcessId,
-    IN  PIMAGE_INFO     ImageInfo
+    _In_ PUNICODE_STRING    FullImageName,
+    _In_ HANDLE             ProcessId,
+    _In_ PIMAGE_INFO        ImageInfo
     )
 {
     PMODULE_CONTEXT     Context = &ModuleContext;
@@ -330,9 +330,9 @@ fail1:
 XEN_API
 VOID
 ModuleLookup(
-    IN  ULONG_PTR   Address,
-    OUT PCHAR       *Name,
-    OUT PULONG_PTR  Offset
+    _In_ ULONG_PTR  Address,
+    _Out_ PCHAR     *Name,
+    _Out_ PULONG_PTR Offset
     )
 {
     PMODULE_CONTEXT Context = &ModuleContext;
@@ -507,7 +507,7 @@ fail1:
 
     (VOID) InterlockedDecrement(&Context->References);
 
-    ASSERT(IsZeroMemory(Context, sizeof (MODULE_CONTEXT)));    
+    ASSERT(IsZeroMemory(Context, sizeof (MODULE_CONTEXT)));
 
     return status;
 }
diff --git a/src/xen/process.c b/src/xen/process.c
index 2ba6599..8e83188 100644
--- a/src/xen/process.c
+++ b/src/xen/process.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -51,9 +51,9 @@ static PROCESS_CONTEXT  ProcessContext;
 
 static VOID
 ProcessNotify(
-    IN  HANDLE                      ParentId,
-    IN  HANDLE                      ProcessId,
-    IN  BOOLEAN                     Create
+    _In_ HANDLE                     ParentId,
+    _In_ HANDLE                     ProcessId,
+    _In_ BOOLEAN                    Create
     )
 {
     KIRQL                           Irql;
@@ -71,7 +71,7 @@ ProcessNotify(
 
     KeRaiseIrql(DISPATCH_LEVEL, &Irql);
 
-    Address.QuadPart = __readcr3();   
+    Address.QuadPart = __readcr3();
     (VOID)HvmPagetableDying(Address);
 
     KeLowerIrql(Irql);
@@ -79,7 +79,7 @@ ProcessNotify(
 
 PCHAR
 ProcessGetImageFileName(
-    IN  PEPROCESS   Process
+    _In_ PEPROCESS  Process
     )
 {
     PPROCESS_CONTEXT    Context = &ProcessContext;
diff --git a/src/xen/process.h b/src/xen/process.h
index d25c8f0..9ae2ec9 100644
--- a/src/xen/process.h
+++ b/src/xen/process.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -46,7 +46,7 @@ ProcessTeardown(
 
 extern PCHAR
 ProcessGetImageFileName(
-    IN  PEPROCESS   Process
+    _In_ PEPROCESS  Process
     );
 
 #endif  // _XEN_PROCESS_H
diff --git a/src/xen/sched.c b/src/xen/sched.c
index a6e2a27..a9cac58 100644
--- a/src/xen/sched.c
+++ b/src/xen/sched.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -41,18 +41,18 @@
 
 static LONG_PTR
 SchedOp(
-    IN  ULONG   Command,
-    IN  PVOID   Argument
+    _In_ ULONG      Command,
+    _In_opt_ PVOID  Argument
     )
 {
     return HYPERCALL(LONG_PTR, sched_op, 2, Command, Argument);
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 SchedShutdownCode(
-    IN  ULONG               Reason
+    _In_ ULONG              Reason
     )
 {
     struct sched_shutdown   op;
@@ -62,7 +62,7 @@ SchedShutdownCode(
     op.reason = Reason;
 
     rc = SchedOp(SCHEDOP_shutdown_code, &op);
-    
+
     if (rc < 0) {
         ERRNO_TO_STATUS(-rc, status);
         goto fail1;
@@ -76,11 +76,11 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 SchedShutdown(
-    IN  ULONG               Reason
+    _In_ ULONG              Reason
     )
 {
     struct sched_shutdown   op;
@@ -124,8 +124,8 @@ SchedYield(
 XEN_API
 NTSTATUS
 SchedWatchdog(
-    IN OUT  PULONG          Id,
-    IN      ULONG           Seconds
+    _Inout_ PULONG          Id,
+    _In_ ULONG              Seconds
     )
 {
     struct sched_watchdog   op;
diff --git a/src/xen/system.c b/src/xen/system.c
index 844deea..b813326 100644
--- a/src/xen/system.c
+++ b/src/xen/system.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -85,7 +85,7 @@ static SYSTEM_CONTEXT   SystemContext;
 
 static FORCEINLINE PVOID
 __SystemAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XEN_SYSTEM_TAG);
@@ -93,7 +93,7 @@ __SystemAllocate(
 
 static FORCEINLINE VOID
 __SystemFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XEN_SYSTEM_TAG);
@@ -101,7 +101,7 @@ __SystemFree(
 
 static FORCEINLINE const CHAR *
 __PlatformIdName(
-    IN  ULONG   PlatformId
+    _In_ ULONG  PlatformId
     )
 {
 #define PLATFORM_ID_NAME(_PlatformId)       \
@@ -122,7 +122,7 @@ __PlatformIdName(
 
 static FORCEINLINE const CHAR *
 __SuiteName(
-    IN  ULONG  SuiteBit
+    _In_ ULONG SuiteBit
     )
 {
 #define SUITE_NAME(_Suite)          \
@@ -155,7 +155,7 @@ __SuiteName(
 
 static FORCEINLINE const CHAR *
 __ProductTypeName(
-    IN  UCHAR   ProductType
+    _In_ UCHAR  ProductType
     )
 {
 #define PRODUCT_TYPE_NAME(_ProductType) \
@@ -174,7 +174,7 @@ __ProductTypeName(
 #undef  PRODUCT_TYPE_NAME
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static NTSTATUS
 SystemGetVersionInformation(
     VOID
@@ -207,7 +207,7 @@ SystemGetVersionInformation(
          __PlatformIdName(VersionInformation.dwPlatformId));
 #else
 #error 'Unrecognised architecture'
-#endif    
+#endif
 
     if (VersionInformation.wServicePackMajor != 0 ||
         VersionInformation.wServicePackMinor != 0)
@@ -326,7 +326,7 @@ fail1:
 
 static UCHAR
 SystemApicIDToProcessorID(
-    IN  UCHAR   ApicID
+    _In_ UCHAR  ApicID
     )
 {
     PSYSTEM_CONTEXT Context = &SystemContext;
@@ -357,7 +357,7 @@ SystemApicIDToProcessorID(
 
 static VOID
 SystemViridianInformation(
-    IN  ULONG   Count
+    _In_ ULONG  Count
     )
 {
     ULONG       EAX;
@@ -573,7 +573,7 @@ done:
 
 static VOID
 SystemProcessorInitialize(
-    IN  ULONG           Cpu
+    _In_ ULONG          Cpu
     )
 {
     PSYSTEM_CONTEXT     Context = &SystemContext;
@@ -617,7 +617,7 @@ SystemProcessorInitialize(
 
 static VOID
 SystemProcessorTeardown(
-    IN  ULONG           Cpu
+    _In_ ULONG          Cpu
     )
 {
     PSYSTEM_CONTEXT     Context = &SystemContext;
@@ -633,8 +633,8 @@ SystemProcessorTeardown(
 XEN_API
 NTSTATUS
 SystemProcessorVcpuId(
-    IN  ULONG           Cpu,
-    OUT unsigned int    *vcpu_id
+    _In_ ULONG          Cpu,
+    _Out_ unsigned int  *vcpu_id
     )
 {
     PSYSTEM_CONTEXT     Context = &SystemContext;
@@ -660,8 +660,8 @@ fail1:
 XEN_API
 NTSTATUS
 SystemProcessorVcpuInfo(
-    IN  ULONG           Cpu,
-    OUT vcpu_info_t     **Vcpu
+    _In_ ULONG          Cpu,
+    _Out_ vcpu_info_t   **Vcpu
     )
 {
     PSYSTEM_CONTEXT     Context = &SystemContext;
@@ -693,8 +693,8 @@ fail1:
 XEN_API
 NTSTATUS
 SystemProcessorRegisterVcpuInfo(
-    IN  ULONG           Cpu,
-    IN  BOOLEAN         Force
+    _In_ ULONG          Cpu,
+    _In_ BOOLEAN        Force
     )
 {
     PSYSTEM_CONTEXT     Context = &SystemContext;
@@ -773,7 +773,7 @@ fail1:
 
 static VOID
 SystemProcessorDeregisterVcpuInfo(
-    IN  ULONG           Cpu
+    _In_ ULONG          Cpu
     )
 {
     PSYSTEM_CONTEXT     Context = &SystemContext;
@@ -794,10 +794,10 @@ _IRQL_requires_(DISPATCH_LEVEL)
 _IRQL_requires_same_
 VOID
 SystemProcessorDpc(
-    IN  PKDPC           Dpc,
-    IN  PVOID           _Context,
-    IN  PVOID           Argument1,
-    IN  PVOID           Argument2
+    _In_ PKDPC          Dpc,
+    _In_ PVOID          _Context,
+    _In_ PVOID          Argument1,
+    _In_ PVOID          Argument2
     )
 {
     PSYSTEM_CONTEXT     Context = &SystemContext;
@@ -843,9 +843,9 @@ static
 _Function_class_(PROCESSOR_CALLBACK_FUNCTION)
 VOID
 SystemProcessorChangeCallback(
-    IN      PVOID                               Argument,
-    IN      PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT Change,
-    IN OUT  PNTSTATUS                           Status
+    _In_ PVOID                                  Argument,
+    _In_ PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT    Change,
+    _Inout_ PNTSTATUS                           Status
     )
 {
     PSYSTEM_CONTEXT                             Context = &SystemContext;
@@ -1033,7 +1033,7 @@ SystemGetStartOptions(
     NTSTATUS        status;
 
     RtlInitUnicodeString(&Unicode, L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control");
-    
+
     status = RegistryOpenKey(NULL, &Unicode, KEY_READ, &Key);
     if (!NT_SUCCESS(status))
         goto fail1;
@@ -1071,17 +1071,17 @@ fail1:
 
 static NTSTATUS
 SystemRegisterCallback(
-    IN  PWCHAR              Name,
-    IN  PCALLBACK_FUNCTION  Function,
-    IN  PVOID               Argument,
-    OUT PVOID               *Handle
+    _In_ PWCHAR             Name,
+    _In_ PCALLBACK_FUNCTION Function,
+    _In_opt_ PVOID          Argument,
+    _Out_ PVOID             *Handle
     )
 {
     UNICODE_STRING          Unicode;
     OBJECT_ATTRIBUTES       Attributes;
     PCALLBACK_OBJECT        Object;
     NTSTATUS                status;
-    
+
     RtlInitUnicodeString(&Unicode, Name);
 
     InitializeObjectAttributes(&Attributes,
@@ -1122,7 +1122,7 @@ fail1:
 
 static VOID
 SystemDeregisterCallback(
-    IN  PVOID   Handle
+    _In_ PVOID  Handle
     )
 {
     ExUnregisterCallback(Handle);
@@ -1130,11 +1130,12 @@ SystemDeregisterCallback(
 
 CALLBACK_FUNCTION   SystemPowerStateCallback;
 
+_Use_decl_annotations_
 VOID
 SystemPowerStateCallback(
-    IN  PVOID   _Context,
-    IN  PVOID   Argument1,
-    IN  PVOID   Argument2
+    PVOID       _Context,
+    PVOID       Argument1,
+    PVOID       Argument2
     )
 {
     ULONG_PTR   Type = (ULONG_PTR)Argument1;
@@ -1401,7 +1402,7 @@ SystemRealTimeIsUniversal(
 XEN_API
 NTSTATUS
 SystemSetWatchdog(
-    IN  ULONG       Seconds
+    _In_ ULONG      Seconds
     )
 {
     PSYSTEM_CONTEXT Context = &SystemContext;
diff --git a/src/xen/unplug.c b/src/xen/unplug.c
index 3121005..bdf5843 100644
--- a/src/xen/unplug.c
+++ b/src/xen/unplug.c
@@ -66,7 +66,7 @@ static UNPLUG_CONTEXT   UnplugContext;
 
 static FORCEINLINE PVOID
 __UnplugAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, UNPLUG_TAG);
@@ -74,7 +74,7 @@ __UnplugAllocate(
 
 static FORCEINLINE VOID
 __UnplugFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, UNPLUG_TAG);
@@ -107,7 +107,7 @@ UnplugSetBootEmulated(
 
 static VOID
 UnplugDeviceType(
-    IN  UNPLUG_TYPE Type
+    _In_ UNPLUG_TYPE    Type
     )
 {
     PUNPLUG_CONTEXT Context = &UnplugContext;
@@ -193,9 +193,9 @@ fail1:
 
 static NTSTATUS
 UnplugCheckEnumKeyCallback(
-    IN  PVOID           Context,
-    IN  HANDLE          Key,
-    IN  PANSI_STRING    Name
+    _In_ PVOID          Context,
+    _In_ HANDLE         Key,
+    _In_ PANSI_STRING   Name
     )
 {
     PUNPLUG_DATA        Data = Context;
@@ -210,8 +210,8 @@ UnplugCheckEnumKeyCallback(
 
 static NTSTATUS
 UnplugCheckEnumKey(
-    IN  PCHAR           EnumName,
-    OUT PULONG          Value
+    _In_ PCHAR          EnumName,
+    _Out_ PULONG        Value
     )
 {
     UNICODE_STRING      Unicode;
@@ -261,7 +261,7 @@ fail1:
 
 static VOID
 UnplugSetRequest(
-    IN  UNPLUG_TYPE     Type
+    _In_ UNPLUG_TYPE    Type
     )
 {
     PUNPLUG_CONTEXT     Context = &UnplugContext;
@@ -317,7 +317,7 @@ done:
 XEN_API
 NTSTATUS
 UnplugIncrementValue(
-    IN  UNPLUG_TYPE     Type
+    _In_ UNPLUG_TYPE    Type
     )
 {
     HANDLE              UnplugKey;
@@ -368,7 +368,7 @@ fail1:
 XEN_API
 NTSTATUS
 UnplugDecrementValue(
-    IN  UNPLUG_TYPE     Type
+    _In_ UNPLUG_TYPE    Type
     )
 {
     HANDLE              UnplugKey;
@@ -427,12 +427,12 @@ fail1:
 XEN_API
 BOOLEAN
 UnplugGetRequest(
-    IN  UNPLUG_TYPE Type
+    _In_ UNPLUG_TYPE    Type
     )
 {
-    PUNPLUG_CONTEXT Context = &UnplugContext;
-    KIRQL           Irql;
-    BOOLEAN         Request;
+    PUNPLUG_CONTEXT     Context = &UnplugContext;
+    KIRQL               Irql;
+    BOOLEAN             Request;
 
     AcquireHighLock(&Context->Lock, &Irql);
     Request = Context->Request[Type];
diff --git a/src/xen/vcpu.c b/src/xen/vcpu.c
index 552b3b3..12ec8a4 100644
--- a/src/xen/vcpu.c
+++ b/src/xen/vcpu.c
@@ -39,20 +39,20 @@
 
 static LONG_PTR
 VcpuOp(
-    IN  ULONG           Command,
-    IN  unsigned int    vcpu_id,
-    IN  PVOID           Argument
+    _In_ ULONG          Command,
+    _In_ unsigned int   vcpu_id,
+    _In_opt_ PVOID      Argument
     )
 {
     return HYPERCALL(LONG_PTR, vcpu_op, 3, Command, vcpu_id, Argument);
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 VcpuSetPeriodicTimer(
-    IN  unsigned int                vcpu_id,
-    IN  PLARGE_INTEGER              Period
+    _In_ unsigned int               vcpu_id,
+    _In_opt_ PLARGE_INTEGER         Period
     )
 {
     LONG_PTR                        rc;
@@ -81,13 +81,13 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 VcpuRegisterVcpuInfo(
-    IN  unsigned int                vcpu_id,
-    IN  PFN_NUMBER                  Pfn,
-    IN  ULONG                       Offset
+    _In_ unsigned int               vcpu_id,
+    _In_ PFN_NUMBER                 Pfn,
+    _In_ ULONG                      Offset
     )
 {
     struct vcpu_register_vcpu_info  op;
diff --git a/src/xen/xen_version.c b/src/xen/xen_version.c
index 3fa20b7..4cff07f 100644
--- a/src/xen/xen_version.c
+++ b/src/xen/xen_version.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -41,19 +41,19 @@
 
 static FORCEINLINE LONG_PTR
 XenVersionOp(
-    IN  ULONG   Command,
-    IN  PVOID   Argument
+    _In_ ULONG      Command,
+    _In_opt_ PVOID  Argument
     )
 {
     return HYPERCALL(LONG_PTR, xen_version, 2, Command, Argument);
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 XenVersion(
-    OUT PULONG  Major,
-    OUT PULONG  Minor
+    _Out_ PULONG    Major,
+    _Out_ PULONG    Minor
     )
 {
     LONG_PTR                    rc;
@@ -77,16 +77,16 @@ fail1:
     return status;
 }
 
-__checkReturn
+_Check_return_
 XEN_API
 NTSTATUS
 XenVersionExtra(
-    OUT PCHAR           Extra
+    _Out_writes_(XEN_EXTRAVERSION_LEN) PCHAR    Extra
     )
 {
-    xen_extraversion_t  op;
-    LONG_PTR            rc;
-    NTSTATUS            status;
+    xen_extraversion_t                          op;
+    LONG_PTR                                    rc;
+    NTSTATUS                                    status;
 
     RtlZeroMemory(&op, sizeof (op));
 
diff --git a/src/xenbus/balloon.c b/src/xenbus/balloon.c
index 0e2ef05..98c2f79 100644
--- a/src/xenbus/balloon.c
+++ b/src/xenbus/balloon.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -70,7 +70,7 @@ struct _XENBUS_BALLOON_CONTEXT {
 
 static FORCEINLINE PVOID
 __BalloonAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_BALLOON_TAG);
@@ -78,7 +78,7 @@ __BalloonAllocate(
 
 static FORCEINLINE VOID
 __BalloonFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_BALLOON_TAG);
@@ -94,13 +94,13 @@ __BalloonFree(
 
 static VOID
 BalloonHeapPushDown(
-    IN  PPFN_NUMBER Heap,
-    IN  ULONG       Start,
-    IN  ULONG       Count
+    _In_ PPFN_NUMBER    Heap,
+    _In_ ULONG          Start,
+    _In_ ULONG          Count
     )
 {
-    ULONG           LeftChild;
-    ULONG           RightChild;
+    ULONG               LeftChild;
+    ULONG               RightChild;
 
 again:
     LeftChild = Start * 2 + 1;
@@ -160,11 +160,11 @@ again:
 // Turn an array of PFNs into a max heap (largest node at root)
 static VOID
 BalloonCreateHeap(
-    IN  PPFN_NUMBER PfnArray,
-    IN  ULONG       Count
+    _In_ PPFN_NUMBER    PfnArray,
+    _In_ ULONG          Count
     )
 {
-    LONG            Index = (LONG)Count;
+    LONG                Index = (LONG)Count;
 
     while (--Index >= 0)
         BalloonHeapPushDown(PfnArray, (ULONG)Index, Count);
@@ -172,13 +172,13 @@ BalloonCreateHeap(
 
 static VOID
 BalloonSort(
-    IN  PXENBUS_BALLOON_CONTEXT Context,
-    IN  ULONG                   Count
+    _In_ PXENBUS_BALLOON_CONTEXT    Context,
+    _In_ ULONG                      Count
     )
 {
-    PPFN_NUMBER                 PfnArray;
-    ULONG                       Unsorted;
-    ULONG                       Index;
+    PPFN_NUMBER                     PfnArray;
+    ULONG                           Unsorted;
+    ULONG                           Index;
 
     PfnArray = Context->PfnArray;
 
@@ -194,10 +194,10 @@ BalloonSort(
         ASSERT3U(PfnArray[Index], <, PfnArray[Index + 1]);
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static PMDL
 BalloonAllocatePagesForMdl(
-    IN  ULONG       Count
+    _In_ ULONG      Count
     )
 {
     LARGE_INTEGER   LowAddress;
@@ -212,7 +212,7 @@ BalloonAllocatePagesForMdl(
     HighAddress.QuadPart = ~0ull;
     SkipBytes.QuadPart = 0ull;
     TotalBytes = (SIZE_T)Count << PAGE_SHIFT;
-    
+
     Mdl = MmAllocatePagesForMdlEx(LowAddress,
                                   HighAddress,
                                   SkipBytes,
@@ -236,8 +236,8 @@ done:
 
 static VOID
 BalloonFreePagesFromMdl(
-    IN  PMDL        Mdl,
-    IN  BOOLEAN     Check
+    _In_ PMDL       Mdl,
+    _In_ BOOLEAN    Check
     )
 {
     volatile UCHAR  *Mapping;
@@ -251,7 +251,7 @@ BalloonFreePagesFromMdl(
 
     // Sanity check:
     //
-    // Make sure that things written to the page really do stick. 
+    // Make sure that things written to the page really do stick.
     // If the page is still ballooned out at the hypervisor level
     // then writes will be discarded and reads will give back
     // all 1s.
@@ -321,9 +321,9 @@ done:
 
 static ULONG
 BalloonAllocatePfnArray(
-    IN      PXENBUS_BALLOON_CONTEXT Context,
-    IN      ULONG                   Requested,
-    IN OUT  PBOOLEAN                Slow
+    _In_ PXENBUS_BALLOON_CONTEXT    Context,
+    _In_ ULONG                      Requested,
+    _Inout_ PBOOLEAN                Slow
     )
 {
     LARGE_INTEGER                   Start;
@@ -371,15 +371,15 @@ done:
 
 static ULONG
 BalloonPopulatePhysmap(
-    IN  ULONG       Requested,
-    IN  PPFN_NUMBER PfnArray
+    _In_ ULONG          Requested,
+    _In_ PPFN_NUMBER    PfnArray
     )
 {
-    LARGE_INTEGER   Start;
-    LARGE_INTEGER   End;
-    ULONGLONG       TimeDelta;
-    ULONGLONG       Rate;
-    ULONG           Count;
+    LARGE_INTEGER       Start;
+    LARGE_INTEGER       End;
+    ULONGLONG           TimeDelta;
+    ULONGLONG           Rate;
+    ULONG               Count;
 
     ASSERT(Requested != 0);
 
@@ -398,8 +398,8 @@ BalloonPopulatePhysmap(
 
 static ULONG
 BalloonPopulatePfnArray(
-    IN      PXENBUS_BALLOON_CONTEXT Context,
-    IN      ULONG                   Requested
+    _In_ PXENBUS_BALLOON_CONTEXT    Context,
+    _In_ ULONG                      Requested
     )
 {
     LARGE_INTEGER                   Start;
@@ -458,15 +458,15 @@ BalloonPopulatePfnArray(
 
 static ULONG
 BalloonDecreaseReservation(
-    IN  ULONG       Requested,
-    IN  PPFN_NUMBER PfnArray
+    _In_ ULONG          Requested,
+    _In_ PPFN_NUMBER    PfnArray
     )
 {
-    LARGE_INTEGER   Start;
-    LARGE_INTEGER   End;
-    ULONGLONG       TimeDelta;
-    ULONGLONG       Rate;
-    ULONG           Count;
+    LARGE_INTEGER       Start;
+    LARGE_INTEGER       End;
+    ULONGLONG           TimeDelta;
+    ULONGLONG           Rate;
+    ULONG               Count;
 
     ASSERT(Requested != 0);
 
@@ -485,8 +485,8 @@ BalloonDecreaseReservation(
 
 static ULONG
 BalloonReleasePfnArray(
-    IN      PXENBUS_BALLOON_CONTEXT Context,
-    IN      ULONG                   Requested
+    _In_ PXENBUS_BALLOON_CONTEXT    Context,
+    _In_ ULONG                      Requested
     )
 {
     LARGE_INTEGER                   Start;
@@ -549,9 +549,9 @@ done:
 
 static ULONG
 BalloonFreePfnArray(
-    IN      PXENBUS_BALLOON_CONTEXT Context,
-    IN      ULONG                   Requested,
-    IN      BOOLEAN                 Check
+    _In_ PXENBUS_BALLOON_CONTEXT    Context,
+    _In_ ULONG                      Requested,
+    _In_ BOOLEAN                    Check
     )
 {
     LARGE_INTEGER                   Start;
@@ -612,11 +612,11 @@ done:
 
 static BOOLEAN
 BalloonLowMemory(
-    IN  PXENBUS_BALLOON_CONTEXT Context
+    _In_ PXENBUS_BALLOON_CONTEXT    Context
     )
 {
-    LARGE_INTEGER               Timeout;
-    NTSTATUS                    status;
+    LARGE_INTEGER                   Timeout;
+    NTSTATUS                        status;
 
     Timeout.QuadPart = 0;
 
@@ -631,15 +631,15 @@ BalloonLowMemory(
 
 static NTSTATUS
 BalloonDeflate(
-    IN  PXENBUS_BALLOON_CONTEXT Context,
-    IN  ULONGLONG               Requested
+    _In_ PXENBUS_BALLOON_CONTEXT    Context,
+    _In_ ULONGLONG                  Requested
     )
 {
-    LARGE_INTEGER               Start;
-    LARGE_INTEGER               End;
-    ULONGLONG                   Count;
-    ULONGLONG                   TimeDelta;
-    NTSTATUS                    status;
+    LARGE_INTEGER                   Start;
+    LARGE_INTEGER                   End;
+    ULONGLONG                       Count;
+    ULONGLONG                       TimeDelta;
+    NTSTATUS                        status;
 
     status = STATUS_UNSUCCESSFUL;
     if (Context->FIST.Deflation)
@@ -680,15 +680,15 @@ done:
 
 static NTSTATUS
 BalloonInflate(
-    IN  PXENBUS_BALLOON_CONTEXT Context,
-    IN  ULONGLONG               Requested
+    _In_ PXENBUS_BALLOON_CONTEXT    Context,
+    _In_ ULONGLONG                  Requested
     )
 {
-    LARGE_INTEGER               Start;
-    LARGE_INTEGER               End;
-    ULONGLONG                   Count;
-    ULONGLONG                   TimeDelta;
-    NTSTATUS                    status;
+    LARGE_INTEGER                   Start;
+    LARGE_INTEGER                   End;
+    ULONGLONG                       Count;
+    ULONGLONG                       TimeDelta;
+    NTSTATUS                        status;
 
     status = STATUS_UNSUCCESSFUL;
     if (Context->FIST.Inflation)
@@ -747,11 +747,11 @@ done:
 
 static VOID
 BalloonGetFISTEntries(
-    IN  PXENBUS_BALLOON_CONTEXT Context
+    _In_ PXENBUS_BALLOON_CONTEXT    Context
     )
 {
-    PCHAR                       Buffer;
-    NTSTATUS                    status;
+    PCHAR                           Buffer;
+    NTSTATUS                        status;
 
     status = XENBUS_STORE(Read,
                           &Context->StoreInterface,
@@ -787,14 +787,14 @@ BalloonGetFISTEntries(
 
     if (Context->FIST.Inflation)
         Warning("inflation disallowed\n");
-        
+
     if (Context->FIST.Deflation)
         Warning("deflation disallowed\n");
 }
 
 static FORCEINLINE PCHAR
 __BalloonStatus(
-    IN  NTSTATUS    status
+    _In_ NTSTATUS   status
     )
 {
     switch (status) {
@@ -815,8 +815,8 @@ __BalloonStatus(
 
 NTSTATUS
 BalloonAdjust(
-    IN  PINTERFACE          Interface,
-    IN  ULONGLONG           Size
+    _In_ PINTERFACE         Interface,
+    _In_ ULONGLONG          Size
     )
 {
     PXENBUS_BALLOON_CONTEXT Context = Interface->Context;
@@ -846,7 +846,7 @@ BalloonAdjust(
 
 ULONGLONG
 BalloonGetSize(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_BALLOON_CONTEXT Context = Interface->Context;
@@ -856,7 +856,7 @@ BalloonGetSize(
 
 static NTSTATUS
 BalloonAcquire(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_BALLOON_CONTEXT Context = Interface->Context;
@@ -917,7 +917,7 @@ fail1:
 
 static VOID
 BalloonRelease(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_BALLOON_CONTEXT Context = Interface->Context;
@@ -957,15 +957,15 @@ static struct _XENBUS_BALLOON_INTERFACE_V1 BalloonInterfaceVersion1 = {
     BalloonAdjust,
     BalloonGetSize
 };
-                     
+
 NTSTATUS
 BalloonInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_BALLOON_CONTEXT *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_BALLOON_CONTEXT   *Context
     )
 {
-    UNICODE_STRING              Unicode;
-    NTSTATUS                    status;
+    UNICODE_STRING                  Unicode;
+    NTSTATUS                        status;
 
     Trace("====>\n");
 
@@ -1022,10 +1022,10 @@ fail1:
 
 NTSTATUS
 BalloonGetInterface(
-    IN      PXENBUS_BALLOON_CONTEXT Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_BALLOON_CONTEXT    Context,
+    _In_ ULONG                      Version,
+    _Inout_ PINTERFACE              Interface,
+    _In_ ULONG                      Size
     )
 {
     NTSTATUS                        status;
@@ -1056,11 +1056,11 @@ BalloonGetInterface(
     }
 
     return status;
-}   
+}
 
 ULONG
 BalloonGetReferences(
-    IN  PXENBUS_BALLOON_CONTEXT Context
+    _In_ PXENBUS_BALLOON_CONTEXT    Context
     )
 {
     return Context->References;
@@ -1068,7 +1068,7 @@ BalloonGetReferences(
 
 VOID
 BalloonTeardown(
-    IN  PXENBUS_BALLOON_CONTEXT Context
+    _In_ PXENBUS_BALLOON_CONTEXT    Context
     )
 {
     Trace("====>\n");
diff --git a/src/xenbus/balloon.h b/src/xenbus/balloon.h
index fd20b47..8a45d3c 100644
--- a/src/xenbus/balloon.h
+++ b/src/xenbus/balloon.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -43,26 +43,26 @@ typedef struct _XENBUS_BALLOON_CONTEXT  XENBUS_BALLOON_CONTEXT, *PXENBUS_BALLOON
 
 extern NTSTATUS
 BalloonInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_BALLOON_CONTEXT *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_BALLOON_CONTEXT   *Context
     );
 
 extern NTSTATUS
 BalloonGetInterface(
-    IN      PXENBUS_BALLOON_CONTEXT Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_BALLOON_CONTEXT    Context,
+    _In_ ULONG                      Version,
+    _Inout_ PINTERFACE              Interface,
+    _In_ ULONG                      Size
     );
 
 extern ULONG
 BalloonGetReferences(
-    IN  PXENBUS_BALLOON_CONTEXT Context
+    _In_ PXENBUS_BALLOON_CONTEXT    Context
     );
 
 extern VOID
 BalloonTeardown(
-    IN  PXENBUS_BALLOON_CONTEXT Context
+    _In_ PXENBUS_BALLOON_CONTEXT    Context
     );
 
 #endif  // _XENBUS_BALLOON_H
diff --git a/src/xenbus/bus.c b/src/xenbus/bus.c
index 2f20a39..c97759c 100644
--- a/src/xenbus/bus.c
+++ b/src/xenbus/bus.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -54,7 +54,7 @@ typedef struct _XENBUS_BUS_CONTEXT {
 
 static FORCEINLINE PVOID
 __BusAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, BUS_TAG);
@@ -62,7 +62,7 @@ __BusAllocate(
 
 static FORCEINLINE VOID
 __BusFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, BUS_TAG);
@@ -70,7 +70,7 @@ __BusFree(
 
 static VOID
 BusReference(
-    IN  PVOID           _Context
+    _In_ PVOID          _Context
     )
 {
     PXENBUS_BUS_CONTEXT Context = _Context;
@@ -80,7 +80,7 @@ BusReference(
 
 static VOID
 BusDereference(
-    IN  PVOID           _Context
+    _In_ PVOID          _Context
     )
 {
     PXENBUS_BUS_CONTEXT Context = _Context;
@@ -89,15 +89,16 @@ BusDereference(
     InterlockedDecrement(&Context->References);
 }
 
-static
-__drv_functionClass(TRANSLATE_BUS_ADDRESS)
-BOOLEAN
+static TRANSLATE_BUS_ADDRESS BusTranslateAddress;
+
+_Use_decl_annotations_
+static BOOLEAN
 BusTranslateAddress(
-    IN      PVOID               _Context,
-    IN      PHYSICAL_ADDRESS    BusAddress,
-    IN      ULONG               Length,
-    IN OUT  PULONG              AddressSpace,
-    OUT     PPHYSICAL_ADDRESS   TranslatedAddress
+    PVOID                       _Context,
+    PHYSICAL_ADDRESS            BusAddress,
+    ULONG                       Length,
+    PULONG                      AddressSpace,
+    PPHYSICAL_ADDRESS           TranslatedAddress
     )
 {
     PXENBUS_BUS_CONTEXT         Context = _Context;
@@ -109,17 +110,18 @@ BusTranslateAddress(
                                   TranslatedAddress);
 }
 
-static
-__drv_functionClass(GET_DMA_ADAPTER)
-PDMA_ADAPTER
+static GET_DMA_ADAPTER BusGetDmaAdapter;
+
+_Use_decl_annotations_
+static PDMA_ADAPTER
 BusGetDmaAdapter(
-    IN  PVOID               _Context,
-    IN  PDEVICE_DESCRIPTION DeviceDescriptor,
-    OUT PULONG              NumberOfMapRegisters
+    PVOID                       _Context,
+    PDEVICE_DESCRIPTION         DeviceDescriptor,
+    PULONG                      NumberOfMapRegisters
     )
 {
-    PXENBUS_BUS_CONTEXT     Context = _Context;
-    XENBUS_DMA_ADAPTER_TYPE Type;
+    PXENBUS_BUS_CONTEXT         Context = _Context;
+    XENBUS_DMA_ADAPTER_TYPE     Type;
 
     if (Context->InterceptDmaAdapter != 0) {
         RTL_OSVERSIONINFOEXW    VersionInformation;
@@ -138,22 +140,23 @@ BusGetDmaAdapter(
     } else {
         Type = XENBUS_DMA_ADAPTER_NO_INTERCEPT;
     }
-    
+
     return DmaGetAdapter(Context->Pdo,
                          Type,
                          DeviceDescriptor,
                          NumberOfMapRegisters);
 }
 
-static
-__drv_functionClass(GET_SET_DEVICE_DATA)
-ULONG
+static GET_SET_DEVICE_DATA BusSetData;
+
+_Use_decl_annotations_
+static ULONG
 BusSetData(
-    IN  PVOID           _Context,
-    IN  ULONG           DataType,
-    IN  PVOID           Buffer,
-    IN  ULONG           Offset,
-    IN  ULONG           Length
+    PVOID               _Context,
+    ULONG               DataType,
+    PVOID               Buffer,
+    ULONG               Offset,
+    ULONG               Length
     )
 {
     PXENBUS_BUS_CONTEXT Context = _Context;
@@ -165,15 +168,16 @@ BusSetData(
                          Length);
 }
 
-static
-__drv_functionClass(GET_SET_DEVICE_DATA)
-ULONG
+static GET_SET_DEVICE_DATA BusGetData;
+
+_Use_decl_annotations_
+static ULONG
 BusGetData(
-    IN  PVOID           _Context,
-    IN  ULONG           DataType,
-    IN  PVOID           Buffer,
-    IN  ULONG           Offset,
-    IN  ULONG           Length
+    PVOID               _Context,
+    ULONG               DataType,
+    PVOID               Buffer,
+    ULONG               Offset,
+    ULONG               Length
     )
 {
     PXENBUS_BUS_CONTEXT Context = _Context;
@@ -187,14 +191,14 @@ BusGetData(
 
 NTSTATUS
 BusInitialize(
-    IN  PXENBUS_PDO             Pdo,
-    OUT PBUS_INTERFACE_STANDARD Interface
+    _In_ PXENBUS_PDO                Pdo,
+    _Out_ PBUS_INTERFACE_STANDARD   Interface
     )
 {
-    PXENBUS_BUS_CONTEXT         Context;
-    HANDLE                      ParametersKey;
-    ULONG                       InterceptDmaAdapter;
-    NTSTATUS                    status;
+    PXENBUS_BUS_CONTEXT             Context;
+    HANDLE                          ParametersKey;
+    ULONG                           InterceptDmaAdapter;
+    NTSTATUS                        status;
 
     Trace("====>\n");
 
@@ -238,7 +242,7 @@ fail1:
 
 VOID
 BusTeardown(
-    IN OUT  PBUS_INTERFACE_STANDARD Interface
+    _Inout_ PBUS_INTERFACE_STANDARD Interface
     )
 {
     PXENBUS_BUS_CONTEXT             Context = Interface->Context;
diff --git a/src/xenbus/bus.h b/src/xenbus/bus.h
index 9671bfa..caec040 100644
--- a/src/xenbus/bus.h
+++ b/src/xenbus/bus.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -40,13 +40,13 @@
 
 extern NTSTATUS
 BusInitialize(
-    IN  PXENBUS_PDO             Pdo,
-    OUT PBUS_INTERFACE_STANDARD Interface
+    _In_ PXENBUS_PDO                Pdo,
+    _Out_ PBUS_INTERFACE_STANDARD   Interface
     );
 
 extern VOID
 BusTeardown(
-    IN OUT  PBUS_INTERFACE_STANDARD Interface
+    _Inout_ PBUS_INTERFACE_STANDARD Interface
     );
 
 #endif  // _XENBUS_BUS_H
diff --git a/src/xenbus/cache.c b/src/xenbus/cache.c
index b67c5dd..1af0ea8 100644
--- a/src/xenbus/cache.c
+++ b/src/xenbus/cache.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -110,7 +110,7 @@ struct _XENBUS_CACHE_CONTEXT {
 
 static FORCEINLINE PVOID
 __CacheAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, CACHE_TAG);
@@ -118,45 +118,45 @@ __CacheAllocate(
 
 static FORCEINLINE VOID
 __CacheFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, CACHE_TAG);
 }
 
 static FORCEINLINE VOID
-__drv_requiresIRQL(DISPATCH_LEVEL)
+_IRQL_requires_(DISPATCH_LEVEL)
 __CacheAcquireLock(
-    IN  PXENBUS_CACHE   Cache
+    _In_ PXENBUS_CACHE  Cache
     )
 {
     Cache->AcquireLock(Cache->Argument);
 }
 
 static FORCEINLINE VOID
-__drv_requiresIRQL(DISPATCH_LEVEL)
+_IRQL_requires_(DISPATCH_LEVEL)
 __CacheReleaseLock(
-    IN  PXENBUS_CACHE   Cache
+    _In_ PXENBUS_CACHE  Cache
     )
 {
     Cache->ReleaseLock(Cache->Argument);
 }
 
 static FORCEINLINE NTSTATUS
-__drv_requiresIRQL(DISPATCH_LEVEL)
+_IRQL_requires_(DISPATCH_LEVEL)
 __CacheCtor(
-    IN  PXENBUS_CACHE   Cache,
-    IN  PVOID           Object
+    _In_ PXENBUS_CACHE  Cache,
+    _In_ PVOID          Object
     )
 {
     return Cache->Ctor(Cache->Argument, Object);
 }
 
 static FORCEINLINE VOID
-__drv_requiresIRQL(DISPATCH_LEVEL)
+_IRQL_requires_(DISPATCH_LEVEL)
 __CacheDtor(
-    IN  PXENBUS_CACHE   Cache,
-    IN  PVOID           Object
+    _In_ PXENBUS_CACHE  Cache,
+    _In_ PVOID          Object
     )
 {
     Cache->Dtor(Cache->Argument, Object);
@@ -164,7 +164,7 @@ __CacheDtor(
 
 static PVOID
 CacheGetObjectFromMagazine(
-    IN  PXENBUS_CACHE_MAGAZINE  Magazine
+    _In_ PXENBUS_CACHE_MAGAZINE Magazine
     )
 {
     ULONG                       Index;
@@ -185,8 +185,8 @@ CacheGetObjectFromMagazine(
 
 static NTSTATUS
 CachePutObjectToMagazine(
-    IN  PXENBUS_CACHE_MAGAZINE  Magazine,
-    IN  PVOID                   Object
+    _In_ PXENBUS_CACHE_MAGAZINE Magazine,
+    _In_ PVOID                  Object
     )
 {
     ULONG                       Index;
@@ -203,7 +203,7 @@ CachePutObjectToMagazine(
 
 static PXENBUS_CACHE_MASK
 CacheMaskCreate(
-    IN  ULONG           Size
+    _In_ ULONG          Size
     )
 {
     ULONG               NumberOfBytes;
@@ -226,7 +226,7 @@ fail1:
 
 static VOID
 CacheMaskDestroy(
-    IN  PXENBUS_CACHE_MASK  Mask
+    _In_ PXENBUS_CACHE_MASK Mask
     )
 {
     ASSERT(Mask->Count == 0);
@@ -235,8 +235,8 @@ CacheMaskDestroy(
 
 static FORCEINLINE VOID
 __CacheMaskSet(
-    IN  PXENBUS_CACHE_MASK  Mask,
-    IN  ULONG               Bit
+    _In_ PXENBUS_CACHE_MASK Mask,
+    _In_ ULONG              Bit
     )
 {
     ULONG                   Index = Bit / BITS_PER_ULONG;
@@ -252,8 +252,8 @@ __CacheMaskSet(
 
 static FORCEINLINE BOOLEAN
 __CacheMaskTest(
-    IN  PXENBUS_CACHE_MASK  Mask,
-    IN  ULONG               Bit
+    _In_ PXENBUS_CACHE_MASK Mask,
+    _In_ ULONG              Bit
     )
 {
     ULONG                   Index = Bit / BITS_PER_ULONG;
@@ -266,8 +266,8 @@ __CacheMaskTest(
 
 static FORCEINLINE VOID
 __CacheMaskClear(
-    IN  PXENBUS_CACHE_MASK  Mask,
-    IN  ULONG               Bit
+    _In_ PXENBUS_CACHE_MASK Mask,
+    _In_ ULONG              Bit
     )
 {
     ULONG                   Index = Bit / BITS_PER_ULONG;
@@ -283,7 +283,7 @@ __CacheMaskClear(
 
 static ULONG
 CacheMaskSize(
-    IN  PXENBUS_CACHE_MASK  Mask
+    _In_ PXENBUS_CACHE_MASK Mask
     )
 {
     return Mask->Size;
@@ -291,7 +291,7 @@ CacheMaskSize(
 
 static ULONG
 CacheMaskCount(
-    IN  PXENBUS_CACHE_MASK  Mask
+    _In_ PXENBUS_CACHE_MASK Mask
     )
 {
     return Mask->Count;
@@ -299,8 +299,8 @@ CacheMaskCount(
 
 static VOID
 CacheInsertSlab(
-    IN  PXENBUS_CACHE       Cache,
-    IN  PXENBUS_CACHE_SLAB  New
+    _In_ PXENBUS_CACHE      Cache,
+    _In_ PXENBUS_CACHE_SLAB New
     )
 {
 #define INSERT_BEFORE(_ListEntry, _New)             \
@@ -353,7 +353,7 @@ done:
 #if DBG
 static VOID
 CacheAudit(
-    IN  PXENBUS_CACHE   Cache
+    _In_ PXENBUS_CACHE  Cache
     )
 {
     ULONG               Count = ULONG_MAX;
@@ -396,7 +396,7 @@ CacheAudit(
 // Must be called with lock held
 static NTSTATUS
 CacheCreateSlab(
-    IN  PXENBUS_CACHE   Cache
+    _In_ PXENBUS_CACHE  Cache
     )
 {
     PXENBUS_CACHE_SLAB  Slab;
@@ -468,8 +468,8 @@ fail1:
 // Must be called with lock held
 static VOID
 CacheDestroySlab(
-    IN  PXENBUS_CACHE       Cache,
-    IN  PXENBUS_CACHE_SLAB  Slab
+    _In_ PXENBUS_CACHE      Cache,
+    _In_ PXENBUS_CACHE_SLAB Slab
     )
 {
     LONG                    Index;
@@ -511,7 +511,7 @@ CacheDestroySlab(
 // Must be called with lock held
 static PVOID
 CacheGetObjectFromSlab(
-    IN  PXENBUS_CACHE_SLAB  Slab
+    _In_ PXENBUS_CACHE_SLAB Slab
     )
 {
     PXENBUS_CACHE           Cache;
@@ -570,8 +570,8 @@ fail1:
 // Must be called with lock held
 static VOID
 CachePutObjectToSlab(
-    IN  PXENBUS_CACHE_SLAB  Slab,
-    IN  PVOID               Object
+    _In_ PXENBUS_CACHE_SLAB Slab,
+    _In_ PVOID              Object
     )
 {
     PXENBUS_CACHE           Cache;
@@ -587,9 +587,9 @@ CachePutObjectToSlab(
 
 static PVOID
 CacheGet(
-    IN  PINTERFACE          Interface,
-    IN  PXENBUS_CACHE       Cache,
-    IN  BOOLEAN             Locked
+    _In_ PINTERFACE         Interface,
+    _In_ PXENBUS_CACHE      Cache,
+    _In_ BOOLEAN            Locked
     )
 {
     KIRQL                   Irql;
@@ -664,10 +664,10 @@ done:
 
 static VOID
 CachePut(
-    IN  PINTERFACE          Interface,
-    IN  PXENBUS_CACHE       Cache,
-    IN  PVOID               Object,
-    IN  BOOLEAN             Locked
+    _In_ PINTERFACE         Interface,
+    _In_ PXENBUS_CACHE      Cache,
+    _In_ PVOID              Object,
+    _In_ BOOLEAN            Locked
     )
 {
     KIRQL                   Irql;
@@ -722,8 +722,8 @@ done:
 
 static NTSTATUS
 CacheFill(
-    IN  PXENBUS_CACHE   Cache,
-    IN  ULONG           Count
+    _In_ PXENBUS_CACHE  Cache,
+    _In_ ULONG          Count
     )
 {
     KIRQL               Irql;
@@ -749,8 +749,8 @@ CacheFill(
 
 static VOID
 CacheSpill(
-    IN  PXENBUS_CACHE   Cache,
-    IN  ULONG           Count
+    _In_ PXENBUS_CACHE  Cache,
+    _In_ ULONG          Count
     )
 {
     KIRQL               Irql;
@@ -794,7 +794,7 @@ done:
 
 static FORCEINLINE VOID
 __CacheFlushMagazines(
-    IN  PXENBUS_CACHE   Cache
+    _In_ PXENBUS_CACHE  Cache
     )
 {
     KIRQL               Irql;
@@ -823,17 +823,17 @@ __CacheFlushMagazines(
 
 static NTSTATUS
 CacheCreate(
-    IN  PINTERFACE          Interface,
-    IN  const CHAR          *Name,
-    IN  ULONG               Size,
-    IN  ULONG               Reservation,
-    IN  ULONG               Cap,
-    IN  NTSTATUS            (*Ctor)(PVOID, PVOID),
-    IN  VOID                (*Dtor)(PVOID, PVOID),
-    IN  VOID                (*AcquireLock)(PVOID),
-    IN  VOID                (*ReleaseLock)(PVOID),
-    IN  PVOID               Argument,
-    OUT PXENBUS_CACHE       *Cache
+    _In_ PINTERFACE         Interface,
+    _In_ const CHAR         *Name,
+    _In_ ULONG              Size,
+    _In_ ULONG              Reservation,
+    _In_ ULONG              Cap,
+    _In_ NTSTATUS           (*Ctor)(PVOID, PVOID),
+    _In_ VOID               (*Dtor)(PVOID, PVOID),
+    _In_ VOID               (*AcquireLock)(PVOID),
+    _In_ VOID               (*ReleaseLock)(PVOID),
+    _In_ PVOID              Argument,
+    _Out_ PXENBUS_CACHE     *Cache
     )
 {
     PXENBUS_CACHE_CONTEXT   Context = Interface->Context;
@@ -933,28 +933,28 @@ fail2:
     Error("fail2\n");
 
     RtlZeroMemory((*Cache)->Name, sizeof ((*Cache)->Name));
-    
+
     ASSERT(IsZeroMemory(*Cache, sizeof (XENBUS_CACHE)));
     __CacheFree(*Cache);
 
 fail1:
     Error("fail1 (%08x)\n", status);
 
-    return status;    
+    return status;
 }
 
 static NTSTATUS
 CacheCreateVersion1(
-    IN  PINTERFACE          Interface,
-    IN  const CHAR          *Name,
-    IN  ULONG               Size,
-    IN  ULONG               Reservation,
-    IN  NTSTATUS            (*Ctor)(PVOID, PVOID),
-    IN  VOID                (*Dtor)(PVOID, PVOID),
-    IN  VOID                (*AcquireLock)(PVOID),
-    IN  VOID                (*ReleaseLock)(PVOID),
-    IN  PVOID               Argument,
-    OUT PXENBUS_CACHE       *Cache
+    _In_ PINTERFACE         Interface,
+    _In_ const CHAR         *Name,
+    _In_ ULONG              Size,
+    _In_ ULONG              Reservation,
+    _In_ NTSTATUS           (*Ctor)(PVOID, PVOID),
+    _In_ VOID               (*Dtor)(PVOID, PVOID),
+    _In_ VOID               (*AcquireLock)(PVOID),
+    _In_ VOID               (*ReleaseLock)(PVOID),
+    _In_ PVOID              Argument,
+    _Out_ PXENBUS_CACHE     *Cache
     )
 {
     return CacheCreate(Interface,
@@ -972,8 +972,8 @@ CacheCreateVersion1(
 
 static VOID
 CacheDestroy(
-    IN  PINTERFACE          Interface,
-    IN  PXENBUS_CACHE       Cache
+    _In_ PINTERFACE         Interface,
+    _In_ PXENBUS_CACHE      Cache
     )
 {
     PXENBUS_CACHE_CONTEXT   Context = Interface->Context;
@@ -1027,8 +1027,8 @@ CacheDestroy(
 
 static VOID
 CacheDebugCallback(
-    IN  PVOID               Argument,
-    IN  BOOLEAN             Crashing
+    _In_ PVOID              Argument,
+    _In_ BOOLEAN            Crashing
     )
 {
     PXENBUS_CACHE_CONTEXT   Context = Argument;
@@ -1072,8 +1072,8 @@ CacheDebugCallback(
 
 static NTSTATUS
 CacheMonitor(
-    IN  PXENBUS_THREAD      Self,
-    IN  PVOID               _Context
+    _In_ PXENBUS_THREAD     Self,
+    _In_ PVOID              _Context
     )
 {
     PXENBUS_CACHE_CONTEXT   Context = _Context;
@@ -1181,7 +1181,7 @@ fail1:
 
 VOID
 CacheRelease(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_CACHE_CONTEXT   Context = Interface->Context;
@@ -1229,11 +1229,11 @@ static struct _XENBUS_CACHE_INTERFACE_V2 CacheInterfaceVersion2 = {
     CachePut,
     CacheDestroy
 };
-                     
+
 NTSTATUS
 CacheInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_CACHE_CONTEXT   *Context
+    _In_ PXENBUS_FDO            Fdo,
+    _Out_ PXENBUS_CACHE_CONTEXT *Context
     )
 {
     NTSTATUS                    status;
@@ -1283,10 +1283,10 @@ fail1:
 
 NTSTATUS
 CacheGetInterface(
-    IN      PXENBUS_CACHE_CONTEXT   Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_CACHE_CONTEXT      Context,
+    _In_ ULONG                      Version,
+    _Inout_ PINTERFACE              Interface,
+    _In_ ULONG                      Size
     )
 {
     NTSTATUS                        status;
@@ -1334,11 +1334,11 @@ CacheGetInterface(
     }
 
     return status;
-}   
+}
 
 ULONG
 CacheGetReferences(
-    IN  PXENBUS_CACHE_CONTEXT   Context
+    _In_ PXENBUS_CACHE_CONTEXT  Context
     )
 {
     return Context->References;
@@ -1346,7 +1346,7 @@ CacheGetReferences(
 
 VOID
 CacheTeardown(
-    IN  PXENBUS_CACHE_CONTEXT   Context
+    _In_ PXENBUS_CACHE_CONTEXT  Context
     )
 {
     Trace("====>\n");
diff --git a/src/xenbus/cache.h b/src/xenbus/cache.h
index 2dc3821..8714bc7 100644
--- a/src/xenbus/cache.h
+++ b/src/xenbus/cache.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -43,26 +43,26 @@ typedef struct _XENBUS_CACHE_CONTEXT  XENBUS_CACHE_CONTEXT, *PXENBUS_CACHE_CONTE
 
 extern NTSTATUS
 CacheInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_CACHE_CONTEXT   *Context
+    _In_ PXENBUS_FDO            Fdo,
+    _Out_ PXENBUS_CACHE_CONTEXT *Context
     );
 
 extern NTSTATUS
 CacheGetInterface(
-    IN      PXENBUS_CACHE_CONTEXT   Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_CACHE_CONTEXT  Context,
+    _In_ ULONG                  Version,
+    _Inout_ PINTERFACE          Interface,
+    _In_ ULONG                  Size
     );
 
 extern ULONG
 CacheGetReferences(
-    IN  PXENBUS_CACHE_CONTEXT   Context
+    _In_ PXENBUS_CACHE_CONTEXT  Context
     );
 
 extern VOID
 CacheTeardown(
-    IN  PXENBUS_CACHE_CONTEXT   Context
+    _In_ PXENBUS_CACHE_CONTEXT  Context
     );
 
 #endif  // _XENBUS_CACHE_H
diff --git a/src/xenbus/console.c b/src/xenbus/console.c
index b94b00b..1c2af75 100644
--- a/src/xenbus/console.c
+++ b/src/xenbus/console.c
@@ -80,7 +80,7 @@ C_ASSERT(sizeof (struct xencons_interface) <= PAGE_SIZE);
 
 static FORCEINLINE PVOID
 __ConsoleAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_CONSOLE_TAG);
@@ -88,7 +88,7 @@ __ConsoleAllocate(
 
 static FORCEINLINE VOID
 __ConsoleFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_CONSOLE_TAG);
@@ -96,7 +96,7 @@ __ConsoleFree(
 
 static ULONG
 ConsoleOutAvailable(
-    IN  PXENBUS_CONSOLE_CONTEXT Context
+    _In_ PXENBUS_CONSOLE_CONTEXT    Context
     )
 {
     struct xencons_interface    *Shared;
@@ -117,15 +117,15 @@ ConsoleOutAvailable(
 
 static ULONG
 ConsoleCopyToOut(
-    IN  PXENBUS_CONSOLE_CONTEXT Context,
-    IN  PCHAR                   Data,
-    IN  ULONG                   Length
+    _In_ PXENBUS_CONSOLE_CONTEXT    Context,
+    _In_ PCHAR                      Data,
+    _In_ ULONG                      Length
     )
 {
-    struct xencons_interface    *Shared;
-    XENCONS_RING_IDX            cons;
-    XENCONS_RING_IDX            prod;
-    ULONG                       Offset;
+    struct xencons_interface        *Shared;
+    XENCONS_RING_IDX                cons;
+    XENCONS_RING_IDX                prod;
+    ULONG                           Offset;
 
     Shared = Context->Shared;
 
@@ -171,12 +171,12 @@ ConsoleCopyToOut(
 
 static ULONG
 ConsoleInAvailable(
-    IN  PXENBUS_CONSOLE_CONTEXT Context
+    _In_ PXENBUS_CONSOLE_CONTEXT    Context
     )
 {
-    struct xencons_interface    *Shared;
-    XENCONS_RING_IDX            cons;
-    XENCONS_RING_IDX            prod;
+    struct xencons_interface        *Shared;
+    XENCONS_RING_IDX                cons;
+    XENCONS_RING_IDX                prod;
 
     Shared = Context->Shared;
 
@@ -192,15 +192,15 @@ ConsoleInAvailable(
 
 static ULONG
 ConsoleCopyFromIn(
-    IN  PXENBUS_CONSOLE_CONTEXT Context,
-    IN  PCHAR                   Data,
-    IN  ULONG                   Length
+    _In_ PXENBUS_CONSOLE_CONTEXT    Context,
+    _In_ PCHAR                      Data,
+    _In_ ULONG                      Length
     )
 {
-    struct xencons_interface    *Shared;
-    XENCONS_RING_IDX            cons;
-    XENCONS_RING_IDX            prod;
-    ULONG                       Offset;
+    struct xencons_interface        *Shared;
+    XENCONS_RING_IDX                cons;
+    XENCONS_RING_IDX                prod;
+    ULONG                           Offset;
 
     Shared = Context->Shared;
 
@@ -246,10 +246,10 @@ ConsoleCopyFromIn(
 
 static VOID
 ConsolePoll(
-    IN  PXENBUS_CONSOLE_CONTEXT Context
+    _In_ PXENBUS_CONSOLE_CONTEXT    Context
     )
 {
-    PLIST_ENTRY                 ListEntry;
+    PLIST_ENTRY                     ListEntry;
 
     for (ListEntry = Context->WakeupList.Flink;
          ListEntry != &Context->WakeupList;
@@ -272,10 +272,10 @@ _IRQL_requires_(DISPATCH_LEVEL)
 _IRQL_requires_same_
 VOID
 ConsoleDpc(
-    IN  PKDPC               Dpc,
-    IN  PVOID               _Context,
-    IN  PVOID               Argument1,
-    IN  PVOID               Argument2
+    _In_ PKDPC              Dpc,
+    _In_ PVOID              _Context,
+    _In_ PVOID              Argument1,
+    _In_ PVOID              Argument2
     )
 {
     PXENBUS_CONSOLE_CONTEXT Context = _Context;
@@ -298,8 +298,8 @@ _IRQL_requires_(HIGH_LEVEL)
 _IRQL_requires_same_
 BOOLEAN
 ConsoleEvtchnCallback(
-    IN  PKINTERRUPT         InterruptObject,
-    IN  PVOID               Argument
+    _In_ PKINTERRUPT        InterruptObject,
+    _In_ PVOID              Argument
     )
 {
     PXENBUS_CONSOLE_CONTEXT Context = Argument;
@@ -318,7 +318,7 @@ ConsoleEvtchnCallback(
 
 static VOID
 ConsoleDisable(
-    IN PXENBUS_CONSOLE_CONTEXT  Context
+    _In_ PXENBUS_CONSOLE_CONTEXT    Context
     )
 {
     LogPrintf(LOG_LEVEL_INFO,
@@ -334,12 +334,12 @@ ConsoleDisable(
 
 static NTSTATUS
 ConsoleEnable(
-    IN PXENBUS_CONSOLE_CONTEXT  Context
+    _In_ PXENBUS_CONSOLE_CONTEXT    Context
     )
 {
-    ULONGLONG                   Value;
-    ULONG                       Port;
-    NTSTATUS                    status;
+    ULONGLONG                       Value;
+    ULONG                           Port;
+    NTSTATUS                        status;
 
     /* In some Xen deployments the tool-stack may not set up the console */
     status = HvmGetParam(HVM_PARAM_CONSOLE_EVTCHN, &Value);
@@ -383,12 +383,12 @@ fail1:
 
 static
 ConsoleGetAddress(
-    IN  PXENBUS_CONSOLE_CONTEXT Context,
-    OUT PPHYSICAL_ADDRESS       Address
+    _In_ PXENBUS_CONSOLE_CONTEXT    Context,
+    _Out_ PPHYSICAL_ADDRESS         Address
     )
 {
-    PFN_NUMBER                  Pfn;
-    NTSTATUS                    status;
+    PFN_NUMBER                      Pfn;
+    NTSTATUS                        status;
 
     status = XENBUS_GNTTAB(QueryReference,
                            &Context->GnttabInterface,
@@ -415,7 +415,7 @@ fail1:
 
 static VOID
 ConsoleSuspendCallbackLate(
-    IN  PVOID                   Argument
+    _In_ PVOID                  Argument
     )
 {
     PXENBUS_CONSOLE_CONTEXT     Context = Argument;
@@ -439,8 +439,8 @@ ConsoleSuspendCallbackLate(
 
 static VOID
 ConsoleDebugCallback(
-    IN  PVOID               Argument,
-    IN  BOOLEAN             Crashing
+    _In_ PVOID              Argument,
+    _In_ BOOLEAN            Crashing
     )
 {
     PXENBUS_CONSOLE_CONTEXT Context = Argument;
@@ -513,7 +513,7 @@ ConsoleDebugCallback(
 
 static BOOLEAN
 ConsoleCanRead(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_CONSOLE_CONTEXT Context = Interface->Context;
@@ -529,9 +529,9 @@ ConsoleCanRead(
 
 static ULONG
 ConsoleRead(
-    IN  PINTERFACE          Interface,
-    IN  PCHAR               Data,
-    IN  ULONG               Length
+    _In_ PINTERFACE         Interface,
+    _In_ PCHAR              Data,
+    _In_ ULONG              Length
     )
 {
     PXENBUS_CONSOLE_CONTEXT Context = Interface->Context;
@@ -562,7 +562,7 @@ done:
 
 static BOOLEAN
 ConsoleCanWrite(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_CONSOLE_CONTEXT Context = Interface->Context;
@@ -578,9 +578,9 @@ ConsoleCanWrite(
 
 static ULONG
 ConsoleWrite(
-    IN  PINTERFACE          Interface,
-    IN  PCHAR               Data,
-    IN  ULONG               Length
+    _In_ PINTERFACE         Interface,
+    _In_ PCHAR              Data,
+    _In_ ULONG              Length
     )
 {
     PXENBUS_CONSOLE_CONTEXT Context = Interface->Context;
@@ -619,14 +619,14 @@ RtlCaptureStackBackTrace(
 
 static NTSTATUS
 ConsoleWakeupAdd(
-    IN  PINTERFACE          	Interface,
-    IN  PKEVENT             	Event,
-    OUT PXENBUS_CONSOLE_WAKEUP	*Wakeup
+    _In_ PINTERFACE                 Interface,
+    _In_ PKEVENT                    Event,
+    _Out_ PXENBUS_CONSOLE_WAKEUP    *Wakeup
     )
 {
-    PXENBUS_CONSOLE_CONTEXT     Context = Interface->Context;
-    KIRQL                       Irql;
-    NTSTATUS                    status;
+    PXENBUS_CONSOLE_CONTEXT         Context = Interface->Context;
+    KIRQL                           Irql;
+    NTSTATUS                        status;
 
     *Wakeup = __ConsoleAllocate(sizeof (XENBUS_CONSOLE_WAKEUP));
 
@@ -653,8 +653,8 @@ fail1:
 
 static VOID
 ConsoleWakeupRemove(
-    IN  PINTERFACE          	Interface,
-    IN  PXENBUS_CONSOLE_WAKEUP	Wakeup
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_CONSOLE_WAKEUP Wakeup
     )
 {
     PXENBUS_CONSOLE_CONTEXT     Context = Interface->Context;
@@ -677,7 +677,7 @@ ConsoleWakeupRemove(
 
 static NTSTATUS
 ConsoleAcquire(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_CONSOLE_CONTEXT Context = Interface->Context;
@@ -807,7 +807,7 @@ fail1:
 
 static VOID
 ConsoleRelease(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_CONSOLE_CONTEXT Context = Interface->Context;
@@ -868,11 +868,11 @@ static struct _XENBUS_CONSOLE_INTERFACE_V1 ConsoleInterfaceVersion1 = {
 
 NTSTATUS
 ConsoleInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_CONSOLE_CONTEXT *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_CONSOLE_CONTEXT   *Context
     )
 {
-    NTSTATUS                    status;
+    NTSTATUS                        status;
 
     Trace("====>\n");
 
@@ -931,10 +931,10 @@ fail1:
 
 NTSTATUS
 ConsoleGetInterface(
-    IN      PXENBUS_CONSOLE_CONTEXT   Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_CONSOLE_CONTEXT    Context,
+    _In_ ULONG                      Version,
+    _Inout_ PINTERFACE              Interface,
+    _In_ ULONG                      Size
     )
 {
     NTSTATUS                        status;
@@ -969,7 +969,7 @@ ConsoleGetInterface(
 
 ULONG
 ConsoleGetReferences(
-    IN  PXENBUS_CONSOLE_CONTEXT   Context
+    _In_ PXENBUS_CONSOLE_CONTEXT  Context
     )
 {
     return Context->References;
@@ -977,7 +977,7 @@ ConsoleGetReferences(
 
 VOID
 ConsoleTeardown(
-    IN  PXENBUS_CONSOLE_CONTEXT   Context
+    _In_ PXENBUS_CONSOLE_CONTEXT  Context
     )
 {
     Trace("====>\n");
diff --git a/src/xenbus/console.h b/src/xenbus/console.h
index 8c8f0ad..f4fb3d5 100644
--- a/src/xenbus/console.h
+++ b/src/xenbus/console.h
@@ -43,26 +43,26 @@ typedef struct _XENBUS_CONSOLE_CONTEXT  XENBUS_CONSOLE_CONTEXT, *PXENBUS_CONSOLE
 
 extern NTSTATUS
 ConsoleInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_CONSOLE_CONTEXT *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_CONSOLE_CONTEXT   *Context
     );
 
 extern NTSTATUS
 ConsoleGetInterface(
-    IN      PXENBUS_CONSOLE_CONTEXT Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_CONSOLE_CONTEXT    Context,
+    _In_ ULONG                      Version,
+    _Inout_ PINTERFACE              Interface,
+    _In_ ULONG                      Size
     );
 
 extern ULONG
 ConsoleGetReferences(
-    IN  PXENBUS_CONSOLE_CONTEXT Context
+    _In_ PXENBUS_CONSOLE_CONTEXT    Context
     );
 
 extern VOID
 ConsoleTeardown(
-    IN  PXENBUS_CONSOLE_CONTEXT Context
+    _In_ PXENBUS_CONSOLE_CONTEXT    Context
     );
 
 #endif  // _XENBUS_CONSOLE_H
diff --git a/src/xenbus/debug.c b/src/xenbus/debug.c
index 937547f..2440afc 100644
--- a/src/xenbus/debug.c
+++ b/src/xenbus/debug.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -67,7 +67,7 @@ struct _XENBUS_DEBUG_CONTEXT {
 
 static FORCEINLINE PVOID
 __DebugAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_DEBUG_TAG);
@@ -75,7 +75,7 @@ __DebugAllocate(
 
 static FORCEINLINE VOID
 __DebugFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_DEBUG_TAG);
@@ -91,17 +91,17 @@ RtlCaptureStackBackTrace(
 
 static NTSTATUS
 DebugRegister(
-    IN  PINTERFACE              Interface,
-    IN  PCHAR                   Prefix,
-    IN  XENBUS_DEBUG_FUNCTION   Function,
-    IN  PVOID                   Argument OPTIONAL,
-    OUT PXENBUS_DEBUG_CALLBACK  *Callback
+    _In_ PINTERFACE                     Interface,
+    _In_ PCHAR                          Prefix,
+    _In_ XENBUS_DEBUG_FUNCTION          Function,
+    _In_opt_ PVOID                      Argument,
+    _Out_opt_ PXENBUS_DEBUG_CALLBACK    *Callback
     )
 {
-    PXENBUS_DEBUG_CONTEXT       Context = Interface->Context;
-    ULONG                       Length;
-    KIRQL                       Irql;
-    NTSTATUS                    status;
+    PXENBUS_DEBUG_CONTEXT               Context = Interface->Context;
+    ULONG                               Length;
+    KIRQL                               Irql;
+    NTSTATUS                            status;
 
     *Callback = __DebugAllocate(sizeof (XENBUS_DEBUG_CALLBACK));
 
@@ -109,7 +109,7 @@ DebugRegister(
     if (*Callback == NULL)
         goto fail1;
 
-    (VOID) RtlCaptureStackBackTrace(1, 1, &(*Callback)->Caller, NULL);    
+    (VOID) RtlCaptureStackBackTrace(1, 1, &(*Callback)->Caller, NULL);
 
     Length = (ULONG)__min(strlen(Prefix), MAXIMUM_PREFIX_LENGTH - 1);
     RtlCopyMemory((*Callback)->Prefix, Prefix, Length);
@@ -131,8 +131,8 @@ fail1:
 
 static VOID
 DebugPrintf(
-    IN  PINTERFACE              Interface,
-    IN  const CHAR              *Format,
+    _In_ PINTERFACE             Interface,
+    _In_ const CHAR             *Format,
     ...
     )
 {
@@ -154,8 +154,8 @@ DebugPrintf(
 
 static VOID
 DebugDeregister(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_DEBUG_CALLBACK  Callback
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_DEBUG_CALLBACK Callback
     )
 {
     PXENBUS_DEBUG_CONTEXT       Context = Interface->Context;
@@ -170,9 +170,9 @@ DebugDeregister(
 
 static VOID
 DebugCallback(
-    IN  PXENBUS_DEBUG_CONTEXT   Context,
-    IN  PXENBUS_DEBUG_CALLBACK  Callback,
-    IN  BOOLEAN                 Crashing
+    _In_ PXENBUS_DEBUG_CONTEXT  Context,
+    _In_ PXENBUS_DEBUG_CALLBACK Callback,
+    _In_ BOOLEAN                Crashing
     )
 {
     PCHAR                       Name;
@@ -216,9 +216,9 @@ DebugCallback(
 
 static VOID
 DebugTriggerLocked(
-    IN  PXENBUS_DEBUG_CONTEXT   Context,
-    IN  PXENBUS_DEBUG_CALLBACK  Callback OPTIONAL,
-    IN  BOOLEAN                 Crashing
+    _In_ PXENBUS_DEBUG_CONTEXT      Context,
+    _In_opt_ PXENBUS_DEBUG_CALLBACK Callback,
+    _In_ BOOLEAN                    Crashing
     )
 {
     if (Callback == NULL) {
@@ -238,15 +238,15 @@ DebugTriggerLocked(
         DebugCallback(Context, Callback, Crashing);
     }
 }
-    
+
 static VOID
 DebugTrigger(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_DEBUG_CALLBACK  Callback OPTIONAL
+    _In_ PINTERFACE                 Interface,
+    _In_opt_ PXENBUS_DEBUG_CALLBACK Callback
     )
 {
-    PXENBUS_DEBUG_CONTEXT       Context = Interface->Context;
-    KIRQL                       Irql;
+    PXENBUS_DEBUG_CONTEXT           Context = Interface->Context;
+    KIRQL                           Irql;
 
     Trace("====>\n");
 
@@ -257,13 +257,13 @@ DebugTrigger(
     Trace("<====\n");
 }
 
-static 
+static
 _Function_class_(KBUGCHECK_CALLBACK_ROUTINE)
 _IRQL_requires_same_
-VOID                     
+VOID
 DebugBugCheckCallback(
-    IN  PVOID               Argument,
-    IN  ULONG               Length
+    _In_ PVOID              Argument,
+    _In_ ULONG              Length
     )
 {
     PXENBUS_DEBUG_CONTEXT   Context = Argument;
@@ -319,7 +319,7 @@ fail1:
 
 static VOID
 DebugRelease(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_DEBUG_CONTEXT   Context = Interface->Context;
@@ -358,11 +358,11 @@ static struct _XENBUS_DEBUG_INTERFACE_V1 DebugInterfaceVersion1 = {
     DebugTrigger,
     DebugDeregister
 };
-                     
+
 NTSTATUS
 DebugInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_DEBUG_CONTEXT   *Context
+    _In_ PXENBUS_FDO            Fdo,
+    _Out_ PXENBUS_DEBUG_CONTEXT *Context
     )
 {
     NTSTATUS                    status;
@@ -392,16 +392,16 @@ fail1:
 
 NTSTATUS
 DebugGetInterface(
-    IN      PXENBUS_DEBUG_CONTEXT   Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_DEBUG_CONTEXT  Context,
+    _In_ ULONG                  Version,
+    _Inout_ PINTERFACE          Interface,
+    _In_ ULONG                  Size
     )
 {
-    NTSTATUS                        status;
+    NTSTATUS                    status;
 
     ASSERT(Context != NULL);
-        
+
     switch (Version) {
     case 1: {
         struct _XENBUS_DEBUG_INTERFACE_V1   *DebugInterface;
@@ -426,11 +426,11 @@ DebugGetInterface(
     }
 
     return status;
-}   
+}
 
 ULONG
 DebugGetReferences(
-    IN  PXENBUS_DEBUG_CONTEXT   Context
+    _In_ PXENBUS_DEBUG_CONTEXT  Context
     )
 {
     return Context->References;
@@ -438,7 +438,7 @@ DebugGetReferences(
 
 VOID
 DebugTeardown(
-    IN  PXENBUS_DEBUG_CONTEXT   Context
+    _In_ PXENBUS_DEBUG_CONTEXT  Context
     )
 {
     Trace("====>\n");
diff --git a/src/xenbus/debug.h b/src/xenbus/debug.h
index f5a1fda..18230e5 100644
--- a/src/xenbus/debug.h
+++ b/src/xenbus/debug.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -43,26 +43,26 @@ typedef struct _XENBUS_DEBUG_CONTEXT  XENBUS_DEBUG_CONTEXT, *PXENBUS_DEBUG_CONTE
 
 extern NTSTATUS
 DebugInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_DEBUG_CONTEXT   *Context
+    _In_ PXENBUS_FDO            Fdo,
+    _Out_ PXENBUS_DEBUG_CONTEXT *Context
     );
 
 extern NTSTATUS
 DebugGetInterface(
-    IN      PXENBUS_DEBUG_CONTEXT   Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_DEBUG_CONTEXT  Context,
+    _In_ ULONG                  Version,
+    _Inout_ PINTERFACE          Interface,
+    _In_ ULONG                  Size
     );
 
 extern ULONG
 DebugGetReferences(
-    IN  PXENBUS_DEBUG_CONTEXT   Context
+    _In_ PXENBUS_DEBUG_CONTEXT  Context
     );
 
 extern VOID
 DebugTeardown(
-    IN  PXENBUS_DEBUG_CONTEXT   Context
+    _In_ PXENBUS_DEBUG_CONTEXT  Context
     );
 
 #endif  // _XENBUS_DEBUG_H
diff --git a/src/xenbus/dma.c b/src/xenbus/dma.c
index a166dbb..206143e 100644
--- a/src/xenbus/dma.c
+++ b/src/xenbus/dma.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -198,7 +198,7 @@ struct _XENBUS_DMA_LIST_CONTROL {
 
 static FORCEINLINE PVOID
 __DmaAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, DMA_TAG);
@@ -206,7 +206,7 @@ __DmaAllocate(
 
 static FORCEINLINE VOID
 __DmaFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, DMA_TAG);
@@ -214,7 +214,7 @@ __DmaFree(
 
 static VOID
 DmaDumpDeviceDescription(
-    IN  PDEVICE_DESCRIPTION DeviceDescription
+    _In_ PDEVICE_DESCRIPTION    DeviceDescription
     )
 {
     Trace("Version = %u\n", DeviceDescription->Version);
@@ -263,7 +263,7 @@ fail1:
 
 static VOID
 DmaDestroyContext(
-    IN  PXENBUS_DMA_CONTEXT Context
+    _In_ PXENBUS_DMA_CONTEXT    Context
     )
 {
     Info("%p\n", Context);
@@ -289,11 +289,11 @@ static PXENBUS_DMA_CONTEXT  DmaContext[NR_CONTEXT_BUCKETS];
 #pragma warning(suppress: 28167) // changes the IRQL and does not restore the IRQL before it exits
 static KIRQL
 DmaAcquireLock(
-    IN  PKSPIN_LOCK         Lock
+    _In_ PKSPIN_LOCK        Lock
     )
 {
     KIRQL       Irql;
-    
+
     Irql = KeGetCurrentIrql();
     if (Irql > DISPATCH_LEVEL)
         return Irql;
@@ -305,8 +305,8 @@ DmaAcquireLock(
 #pragma warning(suppress: 28167) // changes the IRQL and does not restore the IRQL before it exits
 static VOID
 DmaReleaseLock(
-    IN  PKSPIN_LOCK         Lock,
-    IN  KIRQL               Irql
+    _In_ PKSPIN_LOCK        Lock,
+    _In_ KIRQL              Irql
     )
 {
     if (Irql > DISPATCH_LEVEL)
@@ -318,12 +318,12 @@ DmaReleaseLock(
 
 static VOID
 DmaAddContext(
-    IN  PVOID               Key,
-    IN  PXENBUS_DMA_CONTEXT Context
+    _In_ PVOID                  Key,
+    _In_ PXENBUS_DMA_CONTEXT    Context
     )
 {
-    KIRQL                   Irql;
-    ULONG_PTR               Bucket;
+    KIRQL                       Irql;
+    ULONG_PTR                   Bucket;
 
     Context->Key = Key;
 
@@ -336,13 +336,13 @@ DmaAddContext(
 
 static VOID
 DmaRemoveContext(
-    IN  PXENBUS_DMA_CONTEXT Context
+    _In_ PXENBUS_DMA_CONTEXT    Context
     )
 {
-    PVOID                   Key;
-    KIRQL                   Irql;
-    ULONG_PTR               Bucket;
-    PXENBUS_DMA_CONTEXT     *Entry;
+    PVOID                       Key;
+    KIRQL                       Irql;
+    ULONG_PTR                   Bucket;
+    PXENBUS_DMA_CONTEXT         *Entry;
 
     ASSERT(Context != NULL);
     Key = Context->Key;
@@ -365,7 +365,7 @@ DmaRemoveContext(
 
 static PXENBUS_DMA_CONTEXT
 DmaFindContext(
-    IN  PVOID           Key
+    _In_ PVOID          Key
     )
 {
     KIRQL               Irql;
@@ -387,7 +387,7 @@ DmaFindContext(
 
 static VOID
 DmaPutAdapter(
-    IN  PDMA_ADAPTER    Adapter
+    _In_ PDMA_ADAPTER   Adapter
     )
 {
     PXENBUS_DMA_CONTEXT Context;
@@ -404,10 +404,10 @@ DmaPutAdapter(
 
 static PVOID
 DmaAllocateCommonBuffer(
-    IN  PDMA_ADAPTER        Adapter,
-    IN  ULONG               Length,
-    OUT PPHYSICAL_ADDRESS   LogicalAddress,
-    IN  BOOLEAN             CacheEnabled
+    _In_ PDMA_ADAPTER       Adapter,
+    _In_ ULONG              Length,
+    _Out_ PPHYSICAL_ADDRESS LogicalAddress,
+    _In_ BOOLEAN            CacheEnabled
     )
 {
     PXENBUS_DMA_CONTEXT     Context;
@@ -429,11 +429,11 @@ DmaAllocateCommonBuffer(
 
 static VOID
 DmaFreeCommonBuffer(
-    IN  PDMA_ADAPTER        Adapter,
-    IN  ULONG               Length,
-    IN  PHYSICAL_ADDRESS    LogicalAddress,
-    IN  PVOID               VirtualAddress,
-    IN  BOOLEAN             CacheEnabled
+    _In_ PDMA_ADAPTER       Adapter,
+    _In_ ULONG              Length,
+    _In_ PHYSICAL_ADDRESS   LogicalAddress,
+    _In_ PVOID              VirtualAddress,
+    _In_ BOOLEAN            CacheEnabled
     )
 {
     PXENBUS_DMA_CONTEXT     Context;
@@ -453,16 +453,16 @@ DmaFreeCommonBuffer(
 
 static PXENBUS_DMA_CONTROL
 DmaAddControl(
-    IN  PXENBUS_DMA_CONTEXT Context,
-    IN  PDEVICE_OBJECT      DeviceObject,
-    IN  PVOID               TransferContext OPTIONAL,
-    IN  PDRIVER_CONTROL     Function,
-    IN  PVOID               Argument
+    _In_ PXENBUS_DMA_CONTEXT    Context,
+    _In_ PDEVICE_OBJECT         DeviceObject,
+    _In_opt_ PVOID              TransferContext,
+    _In_opt_ PDRIVER_CONTROL    Function,
+    _In_opt_ PVOID              Argument
     )
 {
-    PXENBUS_DMA_CONTROL     Control;
-    KIRQL                   Irql;
-    NTSTATUS                status;
+    PXENBUS_DMA_CONTROL         Control;
+    KIRQL                       Irql;
+    NTSTATUS                    status;
 
     ASSERT3U(KeGetCurrentIrql(), <=, DISPATCH_LEVEL);
     Control = __DmaAllocate(sizeof (XENBUS_DMA_CONTROL));
@@ -491,11 +491,11 @@ fail1:
 
 static VOID
 DmaRemoveControl(
-    IN  PXENBUS_DMA_CONTROL Control
+    _In_ PXENBUS_DMA_CONTROL    Control
     )
 {
-    PXENBUS_DMA_CONTEXT     Context = Control->Context;
-    KIRQL                   Irql;
+    PXENBUS_DMA_CONTEXT         Context = Control->Context;
+    KIRQL                       Irql;
 
     ASSERT3U(KeGetCurrentIrql(), <=, DISPATCH_LEVEL);
     KeAcquireSpinLock(&Context->Lock, &Irql);
@@ -509,10 +509,10 @@ DRIVER_CONTROL DmaAdapterControl;
 
 IO_ALLOCATION_ACTION
 DmaAdapterControl(
-    IN  PDEVICE_OBJECT      DeviceObject,
-    IN  PIRP                Irp,
-    IN  PVOID               MapRegisterBase,
-    IN  PVOID               _Context
+    PDEVICE_OBJECT          DeviceObject,
+    PIRP                    Irp,
+    PVOID                   MapRegisterBase,
+    PVOID                   _Context
     )
 {
     PXENBUS_DMA_CONTROL     Control = _Context;
@@ -537,17 +537,17 @@ DmaAdapterControl(
 
 static NTSTATUS
 DmaAllocateAdapterChannel(
-    IN  PDMA_ADAPTER    Adapter,
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  ULONG           NumberOfMapRegisters,
-    IN  PDRIVER_CONTROL Function,
-    IN  PVOID           Argument
+    _In_ PDMA_ADAPTER       Adapter,
+    _In_ PDEVICE_OBJECT     DeviceObject,
+    _In_ ULONG              NumberOfMapRegisters,
+    _In_ PDRIVER_CONTROL    Function,
+    _In_ PVOID              Argument
     )
 {
-    PXENBUS_DMA_CONTEXT Context;
-    PXENBUS_DMA_CONTROL Control;
-    PDMA_OPERATIONS     Operations;
-    NTSTATUS            status;
+    PXENBUS_DMA_CONTEXT     Context;
+    PXENBUS_DMA_CONTROL     Control;
+    PDMA_OPERATIONS         Operations;
+    NTSTATUS                status;
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
@@ -566,10 +566,10 @@ DmaAllocateAdapterChannel(
     }
 
     Control = DmaAddControl(Context,
-                              DeviceObject,
-                              NULL,
-                              Function,
-                              Argument);
+                            DeviceObject,
+                            NULL,
+                            Function,
+                            Argument);
 
     status = STATUS_NO_MEMORY;
     if (Control == NULL)
@@ -595,20 +595,20 @@ fail1:
 
 static NTSTATUS
 DmaAllocateAdapterChannelEx(
-    IN  PDMA_ADAPTER    Adapter,
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PVOID           TransferContext,
-    IN  ULONG           NumberOfMapRegisters,
-    IN  ULONG           Flags,
-    IN  PDRIVER_CONTROL Function OPTIONAL,
-    IN  PVOID           Argument OPTIONAL,
-    OUT PVOID           *MapRegisterBase OPTIONAL
+    _In_ PDMA_ADAPTER           Adapter,
+    _In_ PDEVICE_OBJECT         DeviceObject,
+    _In_ PVOID                  TransferContext,
+    _In_ ULONG                  NumberOfMapRegisters,
+    _In_ ULONG                  Flags,
+    _In_opt_ PDRIVER_CONTROL    Function,
+    _In_opt_ PVOID              Argument,
+    _Out_opt_ PVOID             *MapRegisterBase
     )
 {
-    PXENBUS_DMA_CONTEXT Context;
-    PXENBUS_DMA_CONTROL Control;
-    PDMA_OPERATIONS     Operations;
-    NTSTATUS            status;
+    PXENBUS_DMA_CONTEXT         Context;
+    PXENBUS_DMA_CONTROL         Control;
+    PDMA_OPERATIONS             Operations;
+    NTSTATUS                    status;
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
@@ -631,10 +631,10 @@ DmaAllocateAdapterChannelEx(
     }
 
     Control = DmaAddControl(Context,
-                              DeviceObject,
-                              TransferContext,
-                              Function,
-                              Argument);
+                            DeviceObject,
+                            TransferContext,
+                            Function,
+                            Argument);
 
     status = STATUS_NO_MEMORY;
     if (Control == NULL)
@@ -663,12 +663,12 @@ fail1:
 
 static BOOLEAN
 DmaFlushAdapterBuffers(
-    IN  PDMA_ADAPTER    Adapter,
-    IN  PMDL            Mdl,
-    IN  PVOID           MapRegisterBase,
-    IN  PVOID           CurrentVa,
-    IN  ULONG           Length,
-    IN  BOOLEAN         WriteToDevice
+    _In_ PDMA_ADAPTER   Adapter,
+    _In_ PMDL           Mdl,
+    _In_ PVOID          MapRegisterBase,
+    _In_ PVOID          CurrentVa,
+    _In_ ULONG          Length,
+    _In_ BOOLEAN        WriteToDevice
     )
 {
     PXENBUS_DMA_CONTEXT Context;
@@ -690,7 +690,7 @@ DmaFlushAdapterBuffers(
 
 static VOID
 DmaFreeAdapterChannel(
-    IN  PDMA_ADAPTER    Adapter
+    _In_ PDMA_ADAPTER   Adapter
     )
 {
     PXENBUS_DMA_CONTEXT Context;
@@ -706,9 +706,9 @@ DmaFreeAdapterChannel(
 
 static VOID
 DmaFreeMapRegisters(
-    IN  PDMA_ADAPTER    Adapter,
-    IN  PVOID           MapRegisterBase,
-    IN  ULONG           NumberOfMapRegisters
+    _In_ PDMA_ADAPTER   Adapter,
+    _In_ PVOID          MapRegisterBase,
+    _In_ ULONG          NumberOfMapRegisters
     )
 {
     PXENBUS_DMA_CONTEXT Context;
@@ -731,17 +731,17 @@ DmaFreeMapRegisters(
 
 static PHYSICAL_ADDRESS
 DmaMapTransfer(
-    IN      PDMA_ADAPTER    Adapter,
-    IN      PMDL            Mdl,
-    IN      PVOID           MapRegisterBase,
-    IN      PVOID           CurrentVa,
-    IN OUT  PULONG          Length,
-    IN      BOOLEAN         WriteToDevice
+    _In_ PDMA_ADAPTER   Adapter,
+    _In_ PMDL           Mdl,
+    _In_ PVOID          MapRegisterBase,
+    _In_ PVOID          CurrentVa,
+    _Inout_ PULONG      Length,
+    _In_ BOOLEAN        WriteToDevice
     )
 {
-    PXENBUS_DMA_CONTEXT     Context;
-    PDMA_OPERATIONS         Operations;
-    PHYSICAL_ADDRESS        LogicalAddress;
+    PXENBUS_DMA_CONTEXT Context;
+    PDMA_OPERATIONS     Operations;
+    PHYSICAL_ADDRESS    LogicalAddress;
 
     Context = DmaFindContext(Adapter);
 
@@ -752,13 +752,13 @@ DmaMapTransfer(
                                              CurrentVa,
                                              Length,
                                              WriteToDevice);
-    
+
     return LogicalAddress;
 }
 
 static ULONG
 DmaGetAlignment(
-    IN  PDMA_ADAPTER    Adapter
+    _In_ PDMA_ADAPTER   Adapter
     )
 {
     PXENBUS_DMA_CONTEXT Context;
@@ -777,7 +777,7 @@ DmaGetAlignment(
 
 static ULONG
 DmaReadCounter(
-    IN  PDMA_ADAPTER    Adapter
+    _In_ PDMA_ADAPTER   Adapter
     )
 {
     PXENBUS_DMA_CONTEXT Context;
@@ -788,22 +788,22 @@ DmaReadCounter(
 
     Operations = Context->LowerOperations;
     Counter = Operations->ReadDmaCounter(Context->LowerAdapter);
-    
+
     return Counter;
 }
 
 static PXENBUS_DMA_LIST_CONTROL
 DmaAddListControl(
-    IN  PXENBUS_DMA_CONTEXT     Context,
-    IN  PDEVICE_OBJECT          DeviceObject,
-    IN  PVOID                   TransferContext OPTIONAL,
-    IN  PDRIVER_LIST_CONTROL    Function,
-    IN  PVOID                   Argument
+    _In_ PXENBUS_DMA_CONTEXT        Context,
+    _In_ PDEVICE_OBJECT             DeviceObject,
+    _In_opt_ PVOID                  TransferContext,
+    _In_opt_ PDRIVER_LIST_CONTROL   Function,
+    _In_opt_ PVOID                  Argument
     )
 {
-    PXENBUS_DMA_LIST_CONTROL    ListControl;
-    KIRQL                       Irql;
-    NTSTATUS                    status;
+    PXENBUS_DMA_LIST_CONTROL        ListControl;
+    KIRQL                           Irql;
+    NTSTATUS                        status;
 
     ASSERT3U(KeGetCurrentIrql(), <=, DISPATCH_LEVEL);
     ListControl = __DmaAllocate(sizeof (XENBUS_DMA_LIST_CONTROL));
@@ -832,7 +832,7 @@ fail1:
 
 static VOID
 DmaRemoveListControl(
-    IN  PXENBUS_DMA_LIST_CONTROL    ListControl
+    _In_ PXENBUS_DMA_LIST_CONTROL   ListControl
     )
 {
     PXENBUS_DMA_CONTEXT             Context = ListControl->Context;
@@ -850,10 +850,10 @@ DRIVER_LIST_CONTROL DmaAdapterListControl;
 
 VOID
 DmaAdapterListControl(
-    IN  PDEVICE_OBJECT          DeviceObject,
-    IN  PIRP                    Irp,
-    IN  PSCATTER_GATHER_LIST    ScatterGather,
-    IN  PVOID                   _Context
+    _In_ PDEVICE_OBJECT         DeviceObject,
+    _In_ PIRP                   Irp,
+    _In_ PSCATTER_GATHER_LIST   ScatterGather,
+    _In_ PVOID                  _Context
     )
 {
     PXENBUS_DMA_LIST_CONTROL    ListControl = _Context;
@@ -871,14 +871,14 @@ DmaAdapterListControl(
 
 static NTSTATUS
 DmaGetScatterGatherList(
-    IN  PDMA_ADAPTER            Adapter,
-    IN  PDEVICE_OBJECT          DeviceObject,
-    IN  PMDL                    Mdl,
-    IN  PVOID                   CurrentVa,
-    IN  ULONG                   Length,
-    IN  PDRIVER_LIST_CONTROL    Function,
-    IN  PVOID                   Argument,
-    IN  BOOLEAN                 WriteToDevice
+    _In_ PDMA_ADAPTER           Adapter,
+    _In_ PDEVICE_OBJECT         DeviceObject,
+    _In_ PMDL                   Mdl,
+    _In_ PVOID                  CurrentVa,
+    _In_ ULONG                  Length,
+    _In_ PDRIVER_LIST_CONTROL   Function,
+    _In_ PVOID                  Argument,
+    _In_ BOOLEAN                WriteToDevice
     )
 {
     PXENBUS_DMA_CONTEXT         Context;
@@ -937,25 +937,25 @@ fail1:
 
 static NTSTATUS
 DmaGetScatterGatherListEx(
-    IN  PDMA_ADAPTER            Adapter,
-    IN  PDEVICE_OBJECT          DeviceObject,
-    IN  PVOID                   TransferContext,
-    IN  PMDL                    Mdl,
-    IN  ULONGLONG               Offset,
-    IN  ULONG                   Length,
-    IN  ULONG                   Flags,
-    IN  PDRIVER_LIST_CONTROL    Function,
-    IN  PVOID                   Argument OPTIONAL,
-    IN  BOOLEAN                 WriteToDevice,
-    IN  PDMA_COMPLETION_ROUTINE CompletionRoutine OPTIONAL,
-    IN  PVOID                   CompletionContext OPTIONAL,
-    OUT PSCATTER_GATHER_LIST    *ScatterGatherList OPTIONAL
+    _In_ PDMA_ADAPTER                   Adapter,
+    _In_ PDEVICE_OBJECT                 DeviceObject,
+    _In_ PVOID                          TransferContext,
+    _In_ PMDL                           Mdl,
+    _In_ ULONGLONG                      Offset,
+    _In_ ULONG                          Length,
+    _In_ ULONG                          Flags,
+    _In_ PDRIVER_LIST_CONTROL           Function,
+    _In_opt_ PVOID                      Argument,
+    _In_ BOOLEAN                        WriteToDevice,
+    _In_opt_ PDMA_COMPLETION_ROUTINE    CompletionRoutine,
+    _In_opt_ PVOID                      CompletionContext,
+    _Out_opt_ PSCATTER_GATHER_LIST      *ScatterGatherList
     )
 {
-    PXENBUS_DMA_CONTEXT         Context;
-    PXENBUS_DMA_LIST_CONTROL    ListControl;
-    PDMA_OPERATIONS             Operations;
-    NTSTATUS                    status;
+    PXENBUS_DMA_CONTEXT                 Context;
+    PXENBUS_DMA_LIST_CONTROL            ListControl;
+    PDMA_OPERATIONS                     Operations;
+    NTSTATUS                            status;
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
@@ -1017,12 +1017,12 @@ fail1:
 
 static NTSTATUS
 DmaCalculateScatterGatherList(
-    IN  PDMA_ADAPTER    Adapter,
-    IN  PMDL            Mdl OPTIONAL,
-    IN  PVOID           CurrentVa,
-    IN  ULONG           Length,
-    OUT PULONG          ScatterGatherListSize,
-    OUT PULONG          NumberOfMapRegisters OPTIONAL
+    _In_ PDMA_ADAPTER   Adapter,
+    _In_opt_ PMDL       Mdl,
+    _In_ PVOID          CurrentVa,
+    _In_ ULONG          Length,
+    _Out_ PULONG        ScatterGatherListSize,
+    _Out_opt_ PULONG    NumberOfMapRegisters
     )
 {
     PXENBUS_DMA_CONTEXT Context;
@@ -1033,6 +1033,7 @@ DmaCalculateScatterGatherList(
     ASSERT3U(Context->Version, >=, 2);
 
     Operations = Context->LowerOperations;
+#pragma prefast(suppress:6387) // bad CalculateScatterGatherList signature
     status = Operations->CalculateScatterGatherList(Context->LowerAdapter,
                                                     Mdl,
                                                     CurrentVa,
@@ -1045,16 +1046,16 @@ DmaCalculateScatterGatherList(
 
 static NTSTATUS
 DmaBuildScatterGatherList(
-    IN  PDMA_ADAPTER            Adapter,
-    IN  PDEVICE_OBJECT          DeviceObject,
-    IN  PMDL                    Mdl,
-    IN  PVOID                   CurrentVa,
-    IN  ULONG                   Length,
-    IN  PDRIVER_LIST_CONTROL    Function,
-    IN  PVOID                   Argument,
-    IN  BOOLEAN                 WriteToDevice,
-    IN  PVOID                   ScatterGatherBuffer,
-    IN  ULONG                   ScatterGatherBufferLength
+    _In_ PDMA_ADAPTER           Adapter,
+    _In_ PDEVICE_OBJECT         DeviceObject,
+    _In_ PMDL                   Mdl,
+    _In_ PVOID                  CurrentVa,
+    _In_ ULONG                  Length,
+    _In_ PDRIVER_LIST_CONTROL   Function,
+    _In_ PVOID                  Argument,
+    _In_ BOOLEAN                WriteToDevice,
+    _In_ PVOID                  ScatterGatherBuffer,
+    _In_ ULONG                  ScatterGatherBufferLength
     )
 {
     PXENBUS_DMA_CONTEXT         Context;
@@ -1119,27 +1120,27 @@ fail1:
 
 static NTSTATUS
 DmaBuildScatterGatherListEx(
-    IN  PDMA_ADAPTER            Adapter,
-    IN  PDEVICE_OBJECT          DeviceObject,
-    IN  PVOID                   TransferContext,
-    IN  PMDL                    Mdl,
-    IN  ULONGLONG               Offset,
-    IN  ULONG                   Length,
-    IN  ULONG                   Flags,
-    IN  PDRIVER_LIST_CONTROL    Function OPTIONAL,
-    IN  PVOID                   Argument OPTIONAL,
-    IN  BOOLEAN                 WriteToDevice,
-    IN  PVOID                   ScatterGatherBuffer,
-    IN  ULONG                   ScatterGatherBufferLength,
-    IN  PDMA_COMPLETION_ROUTINE CompletionRoutine OPTIONAL,
-    IN  PVOID                   CompletionContext OPTIONAL,
-    OUT PSCATTER_GATHER_LIST    *ScatterGatherList OPTIONAL
+    _In_ PDMA_ADAPTER                   Adapter,
+    _In_ PDEVICE_OBJECT                 DeviceObject,
+    _In_ PVOID                          TransferContext,
+    _In_ PMDL                           Mdl,
+    _In_ ULONGLONG                      Offset,
+    _In_ ULONG                          Length,
+    _In_ ULONG                          Flags,
+    _In_opt_ PDRIVER_LIST_CONTROL       Function,
+    _In_opt_ PVOID                      Argument,
+    _In_ BOOLEAN                        WriteToDevice,
+    _In_ PVOID                          ScatterGatherBuffer,
+    _In_ ULONG                          ScatterGatherBufferLength,
+    _In_opt_ PDMA_COMPLETION_ROUTINE    CompletionRoutine,
+    _In_opt_ PVOID                      CompletionContext,
+    _Out_opt_ PSCATTER_GATHER_LIST      *ScatterGatherList
     )
 {
-    PXENBUS_DMA_CONTEXT         Context;
-    PXENBUS_DMA_LIST_CONTROL    ListControl;
-    PDMA_OPERATIONS             Operations;
-    NTSTATUS                    status;
+    PXENBUS_DMA_CONTEXT                 Context;
+    PXENBUS_DMA_LIST_CONTROL            ListControl;
+    PDMA_OPERATIONS                     Operations;
+    NTSTATUS                            status;
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
@@ -1207,9 +1208,9 @@ fail1:
 
 static VOID
 DmaPutScatterGatherList(
-    IN  PDMA_ADAPTER            Adapter,
-    IN  PSCATTER_GATHER_LIST    ScatterGather,
-    IN  BOOLEAN                 WriteToDevice
+    _In_ PDMA_ADAPTER           Adapter,
+    _In_ PSCATTER_GATHER_LIST   ScatterGather,
+    _In_ BOOLEAN                WriteToDevice
     )
 
 {
@@ -1217,7 +1218,7 @@ DmaPutScatterGatherList(
     PDMA_OPERATIONS             Operations;
 
     ASSERT3U(KeGetCurrentIrql(), >=, DISPATCH_LEVEL);
- 
+
     Context = DmaFindContext(Adapter);
 
     Operations = Context->LowerOperations;
@@ -1228,10 +1229,10 @@ DmaPutScatterGatherList(
 
 static NTSTATUS
 DmaBuildMdlFromScatterGatherList(
-    IN  PDMA_ADAPTER            Adapter,
-    IN  PSCATTER_GATHER_LIST    ScatterGather,
-    IN  PMDL                    OriginalMdl,
-    IN  PMDL                    *TargetMdl
+    _In_ PDMA_ADAPTER           Adapter,
+    _In_ PSCATTER_GATHER_LIST   ScatterGather,
+    _In_ PMDL                   OriginalMdl,
+    _In_ PMDL                   *TargetMdl
     )
 {
     PXENBUS_DMA_CONTEXT         Context;
@@ -1245,16 +1246,16 @@ DmaBuildMdlFromScatterGatherList(
     status = Operations->BuildMdlFromScatterGatherList(Context->LowerAdapter,
                                                        ScatterGather,
                                                        OriginalMdl,
-                                                       TargetMdl);  
+                                                       TargetMdl);
 
     return status;
 }
 
 static BOOLEAN
 DmaCancelAdapterChannel(
-    IN  PDMA_ADAPTER    Adapter,
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PVOID           TransferContext
+    _In_ PDMA_ADAPTER   Adapter,
+    _In_ PDEVICE_OBJECT DeviceObject,
+    _In_ PVOID          TransferContext
     )
 {
     PXENBUS_DMA_CONTEXT Context;
@@ -1310,8 +1311,8 @@ DmaCancelAdapterChannel(
 
 static NTSTATUS
 DmaGetAdapterInfo(
-    IN      PDMA_ADAPTER        Adapter,
-    IN OUT  PDMA_ADAPTER_INFO   AdapterInfo
+    _In_ PDMA_ADAPTER           Adapter,
+    _Inout_ PDMA_ADAPTER_INFO   AdapterInfo
     )
 {
     PXENBUS_DMA_CONTEXT         Context;
@@ -1330,12 +1331,12 @@ DmaGetAdapterInfo(
 
 static NTSTATUS
 DmaGetTransferInfo(
-    IN  PDMA_ADAPTER            Adapter,
-    IN  PMDL                    Mdl,
-    IN  ULONGLONG               Offset,
-    IN  ULONG                   Length,
-    IN  BOOLEAN                 WriteOnly,
-    IN OUT  PDMA_TRANSFER_INFO  TransferInfo
+    _In_ PDMA_ADAPTER           Adapter,
+    _In_ PMDL                   Mdl,
+    _In_ ULONGLONG              Offset,
+    _In_ ULONG                  Length,
+    _In_ BOOLEAN                WriteOnly,
+    _Inout_ PDMA_TRANSFER_INFO  TransferInfo
     )
 {
     PXENBUS_DMA_CONTEXT         Context;
@@ -1358,8 +1359,8 @@ DmaGetTransferInfo(
 
 static NTSTATUS
 DmaInitializeTransferContext(
-    IN  PDMA_ADAPTER    Adapter,
-    OUT PVOID           TransferContext
+    _In_ PDMA_ADAPTER   Adapter,
+    _Out_ PVOID         TransferContext
     )
 {
     PXENBUS_DMA_CONTEXT Context;
@@ -1378,17 +1379,17 @@ DmaInitializeTransferContext(
 
 static PVOID
 DmaAllocateCommonBufferEx(
-    IN  PDMA_ADAPTER        Adapter,
-    IN  PPHYSICAL_ADDRESS   MaximumAddress OPTIONAL,
-    IN  ULONG               Length,
-    OUT PPHYSICAL_ADDRESS   LogicalAddress,
-    IN  BOOLEAN             CacheEnabled,
-    IN  NODE_REQUIREMENT    PreferredNode
+    _In_ PDMA_ADAPTER           Adapter,
+    _In_opt_ PPHYSICAL_ADDRESS  MaximumAddress,
+    _In_ ULONG                  Length,
+    _Out_ PPHYSICAL_ADDRESS     LogicalAddress,
+    _In_ BOOLEAN                CacheEnabled,
+    _In_ NODE_REQUIREMENT       PreferredNode
     )
 {
-    PXENBUS_DMA_CONTEXT     Context;
-    PDMA_OPERATIONS         Operations;
-    PVOID                   Buffer;
+    PXENBUS_DMA_CONTEXT         Context;
+    PDMA_OPERATIONS             Operations;
+    PVOID                       Buffer;
 
     ASSERTIRQL(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
 
@@ -1408,9 +1409,9 @@ DmaAllocateCommonBufferEx(
 
 static NTSTATUS
 DmaConfigureAdapterChannel(
-    IN  PDMA_ADAPTER    Adapter,
-    IN  ULONG           FunctionNumber,
-    IN  PVOID           Argument
+    _In_ PDMA_ADAPTER   Adapter,
+    _In_ ULONG          FunctionNumber,
+    _In_ PVOID          Argument
     )
 {
     PXENBUS_DMA_CONTEXT Context;
@@ -1430,22 +1431,22 @@ DmaConfigureAdapterChannel(
 
 static NTSTATUS
 DmaMapTransferEx(
-    IN      PDMA_ADAPTER            Adapter,
-    IN      PMDL                    Mdl,
-    IN      PVOID                   MapRegisterBase,
-    IN      ULONGLONG               Offset,
-    IN      ULONG                   DeviceOffset,
-    IN OUT  PULONG                  Length,
-    IN      BOOLEAN                 WriteToDevice,
-    OUT     PSCATTER_GATHER_LIST    ScatterGatherBuffer OPTIONAL,
-    IN      ULONG                   ScatterGatherBufferLength,
-    IN      PDMA_COMPLETION_ROUTINE CompletionRoutine OPTIONAL,
-    IN      PVOID                   CompletionContext OPTIONAL
+    _In_ PDMA_ADAPTER                   Adapter,
+    _In_ PMDL                           Mdl,
+    _In_ PVOID                          MapRegisterBase,
+    _In_ ULONGLONG                      Offset,
+    _In_ ULONG                          DeviceOffset,
+    _Inout_ PULONG                      Length,
+    _In_ BOOLEAN                        WriteToDevice,
+    _Out_opt_ PSCATTER_GATHER_LIST      ScatterGatherBuffer,
+    _In_ ULONG                          ScatterGatherBufferLength,
+    _In_opt_ PDMA_COMPLETION_ROUTINE    CompletionRoutine,
+    _In_opt_ PVOID                      CompletionContext
     )
 {
-    PXENBUS_DMA_CONTEXT             Context;
-    PDMA_OPERATIONS                 Operations;
-    NTSTATUS                        status;
+    PXENBUS_DMA_CONTEXT                 Context;
+    PDMA_OPERATIONS                     Operations;
+    NTSTATUS                            status;
 
     Context = DmaFindContext(Adapter);
     ASSERT3U(Context->Version, >=, 3);
@@ -1468,12 +1469,12 @@ DmaMapTransferEx(
 
 static NTSTATUS
 DmaFlushAdapterBuffersEx(
-    IN  PDMA_ADAPTER    Adapter,
-    IN  PMDL            Mdl,
-    IN  PVOID           MapRegisterBase,
-    IN  ULONGLONG       Offset,
-    IN  ULONG           Length,
-    IN  BOOLEAN         WriteToDevice
+    _In_ PDMA_ADAPTER   Adapter,
+    _In_ PMDL           Mdl,
+    _In_ PVOID          MapRegisterBase,
+    _In_ ULONGLONG      Offset,
+    _In_ ULONG          Length,
+    _In_ BOOLEAN        WriteToDevice
     )
 {
     PXENBUS_DMA_CONTEXT Context;
@@ -1496,8 +1497,8 @@ DmaFlushAdapterBuffersEx(
 
 static VOID
 DmaFreeAdapterObject(
-    IN  PDMA_ADAPTER            Adapter,
-    IN  IO_ALLOCATION_ACTION    AllocationAction
+    _In_ PDMA_ADAPTER           Adapter,
+    _In_ IO_ALLOCATION_ACTION   AllocationAction
     )
 {
     PXENBUS_DMA_CONTEXT         Context;
@@ -1531,8 +1532,8 @@ DmaFreeAdapterObject(
 
 static NTSTATUS
 DmaCancelMappedTransfer(
-    IN  PDMA_ADAPTER    Adapter,
-    IN  PVOID           TransferContext
+    _In_ PDMA_ADAPTER   Adapter,
+    _In_ PVOID          TransferContext
     )
 {
     PXENBUS_DMA_CONTEXT Context;
@@ -1593,17 +1594,17 @@ static DMA_OPERATIONS   DmaOperations = {
 
 PDMA_ADAPTER
 DmaGetAdapter(
-    IN  PXENBUS_PDO             Pdo,
-    IN  XENBUS_DMA_ADAPTER_TYPE Type,
-    IN  PDEVICE_DESCRIPTION     DeviceDescription,
-    OUT PULONG                  NumberOfMapRegisters
+    _In_ PXENBUS_PDO                Pdo,
+    _In_ XENBUS_DMA_ADAPTER_TYPE    Type,
+    _In_ PDEVICE_DESCRIPTION        DeviceDescription,
+    _Out_ PULONG                    NumberOfMapRegisters
     )
 {
-    PDMA_ADAPTER                LowerAdapter;
-    PDEVICE_OBJECT              LowerDeviceObject;
-    PXENBUS_DMA_CONTEXT         Context;
-    PDMA_ADAPTER                Adapter;
-    NTSTATUS                    status;
+    PDMA_ADAPTER                    LowerAdapter;
+    PDEVICE_OBJECT                  LowerDeviceObject;
+    PXENBUS_DMA_CONTEXT             Context;
+    PDMA_ADAPTER                    Adapter;
+    NTSTATUS                        status;
 
     DmaDumpDeviceDescription(DeviceDescription);
 
@@ -1635,7 +1636,7 @@ DmaGetAdapter(
         goto fail2;
 
     Context->LowerAdapter = LowerAdapter;
-    Context->LowerOperations = LowerAdapter->DmaOperations; 
+    Context->LowerOperations = LowerAdapter->DmaOperations;
     Context->LowerDeviceObject = LowerDeviceObject;
 
     switch (Context->LowerOperations->Size) {
@@ -1661,7 +1662,7 @@ DmaGetAdapter(
 
     // Copy in the requisite number of operations
     RtlCopyMemory(&Context->Operations,
-                  &DmaOperations, 
+                  &DmaOperations,
                   Context->LowerOperations->Size);
     Context->Operations.Size = Context->LowerOperations->Size;
 
diff --git a/src/xenbus/dma.h b/src/xenbus/dma.h
index 6953385..49fd40d 100644
--- a/src/xenbus/dma.h
+++ b/src/xenbus/dma.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -46,10 +46,10 @@ typedef enum {
 
 PDMA_ADAPTER
 DmaGetAdapter(
-    IN  PXENBUS_PDO             Pdo,
-    IN  XENBUS_DMA_ADAPTER_TYPE Type,
-    IN  PDEVICE_DESCRIPTION     DeviceDescriptor,
-    OUT PULONG                  NumberOfMapRegisters
+    _In_ PXENBUS_PDO                Pdo,
+    _In_ XENBUS_DMA_ADAPTER_TYPE    Type,
+    _In_ PDEVICE_DESCRIPTION        DeviceDescriptor,
+    _Out_ PULONG                    NumberOfMapRegisters
     );
 
 #endif  // _XENBUS_DMA_H
diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c
index 4aae2cc..8ae662d 100644
--- a/src/xenbus/driver.c
+++ b/src/xenbus/driver.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -63,7 +63,7 @@ static XENBUS_DRIVER    Driver;
 
 static FORCEINLINE PVOID
 __DriverAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_DRIVER_TAG);
@@ -71,7 +71,7 @@ __DriverAllocate(
 
 static FORCEINLINE VOID
 __DriverFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_DRIVER_TAG);
@@ -79,7 +79,7 @@ __DriverFree(
 
 static FORCEINLINE VOID
 __DriverSetDriverObject(
-    IN  PDRIVER_OBJECT  DriverObject
+    _In_opt_ PDRIVER_OBJECT DriverObject
     )
 {
     Driver.DriverObject = DriverObject;
@@ -103,7 +103,7 @@ DriverGetDriverObject(
 
 static FORCEINLINE VOID
 __DriverSetParametersKey(
-    IN  HANDLE  Key
+    _In_opt_ HANDLE Key
     )
 {
     Driver.ParametersKey = Key;
@@ -127,7 +127,7 @@ DriverGetParametersKey(
 
 static FORCEINLINE VOID
 __DriverSetConsoleLogLevel(
-    IN  LOG_LEVEL   LogLevel
+    _In_ LOG_LEVEL  LogLevel
     )
 {
     Driver.ConsoleLogLevel = LogLevel;
@@ -183,12 +183,12 @@ DriverReleaseMutex(
 
 VOID
 DriverAddFunctionDeviceObject(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    PDEVICE_OBJECT  DeviceObject;
-    PXENBUS_DX      Dx;
-    ULONG           References;
+    PDEVICE_OBJECT      DeviceObject;
+    PXENBUS_DX          Dx;
+    ULONG               References;
 
     DeviceObject = FdoGetDeviceObject(Fdo);
     Dx = (PXENBUS_DX)DeviceObject->DeviceExtension;
@@ -203,12 +203,12 @@ DriverAddFunctionDeviceObject(
 
 VOID
 DriverRemoveFunctionDeviceObject(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    PDEVICE_OBJECT  DeviceObject;
-    PXENBUS_DX      Dx;
-    ULONG           References;
+    PDEVICE_OBJECT      DeviceObject;
+    PXENBUS_DX          Dx;
+    ULONG               References;
 
     DeviceObject = FdoGetDeviceObject(Fdo);
     Dx = (PXENBUS_DX)DeviceObject->DeviceExtension;
@@ -226,7 +226,7 @@ DRIVER_UNLOAD       DriverUnload;
 
 VOID
 DriverUnload(
-    IN  PDRIVER_OBJECT  DriverObject
+    _In_ PDRIVER_OBJECT DriverObject
     )
 {
     HANDLE              ParametersKey;
@@ -272,8 +272,8 @@ DRIVER_ADD_DEVICE   DriverAddDevice;
 NTSTATUS
 #pragma prefast(suppress:28152) // Does not clear DO_DEVICE_INITIALIZING
 DriverAddDevice(
-    IN  PDRIVER_OBJECT  DriverObject,
-    IN  PDEVICE_OBJECT  DeviceObject
+    _In_ PDRIVER_OBJECT DriverObject,
+    _In_ PDEVICE_OBJECT DeviceObject
     )
 {
     NTSTATUS            status;
@@ -302,10 +302,11 @@ fail1:
 
 DRIVER_DISPATCH DriverDispatch;
 
-NTSTATUS 
+_Use_decl_annotations_
+NTSTATUS
 DriverDispatch(
-    IN PDEVICE_OBJECT   DeviceObject,
-    IN PIRP             Irp
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp
     )
 {
     PXENBUS_DX          Dx;
@@ -361,14 +362,14 @@ DRIVER_INITIALIZE   DriverEntry;
 
 NTSTATUS
 DriverEntry(
-    IN  PDRIVER_OBJECT  DriverObject,
-    IN  PUNICODE_STRING RegistryPath
+    _In_ PDRIVER_OBJECT     DriverObject,
+    _In_ PUNICODE_STRING    RegistryPath
     )
 {
-    HANDLE              ParametersKey;
-    ULONG               Index;
-    LOG_LEVEL           LogLevel;
-    NTSTATUS            status;
+    HANDLE                  ParametersKey;
+    ULONG                   Index;
+    LOG_LEVEL               LogLevel;
+    NTSTATUS                status;
 
     ASSERT3P(__DriverGetDriverObject(), ==, NULL);
 
diff --git a/src/xenbus/driver.h b/src/xenbus/driver.h
index 99290e0..5f43379 100644
--- a/src/xenbus/driver.h
+++ b/src/xenbus/driver.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -70,12 +70,12 @@ typedef struct _XENBUS_PDO      XENBUS_PDO, *PXENBUS_PDO;
 
 extern VOID
 DriverAddFunctionDeviceObject(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 extern VOID
 DriverRemoveFunctionDeviceObject(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 #pragma warning(push)
diff --git a/src/xenbus/evtchn.c b/src/xenbus/evtchn.c
index 123f4a3..bb071d4 100644
--- a/src/xenbus/evtchn.c
+++ b/src/xenbus/evtchn.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -127,7 +127,7 @@ struct _XENBUS_EVTCHN_CONTEXT {
 
 static FORCEINLINE PVOID
 __EvtchnAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_EVTCHN_TAG);
@@ -135,7 +135,7 @@ __EvtchnAllocate(
 
 static FORCEINLINE VOID
 __EvtchnFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_EVTCHN_TAG);
@@ -143,10 +143,10 @@ __EvtchnFree(
 
 static NTSTATUS
 EvtchnOpenFixed(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  ULONG                   Count,
-    IN  va_list                 Arguments
+    _In_ PXENBUS_EVTCHN_CONTEXT Context,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ ULONG                  Count,
+    _In_ va_list                Arguments
     )
 {
     ULONG                       LocalPort;
@@ -166,10 +166,10 @@ EvtchnOpenFixed(
 
 static NTSTATUS
 EvtchnOpenUnbound(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  ULONG                   Count,
-    IN  va_list                 Arguments
+    _In_ PXENBUS_EVTCHN_CONTEXT Context,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ ULONG                  Count,
+    _In_ va_list                Arguments
     )
 {
     USHORT                      RemoteDomain;
@@ -202,10 +202,10 @@ fail1:
 
 static NTSTATUS
 EvtchnOpenInterDomain(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  ULONG                   Count,
-    IN  va_list                 Arguments
+    _In_ PXENBUS_EVTCHN_CONTEXT Context,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ ULONG                  Count,
+    _In_ va_list                Arguments
     )
 {
     USHORT                      RemoteDomain;
@@ -243,10 +243,10 @@ fail1:
 
 static NTSTATUS
 EvtchnOpenVirq(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  ULONG                   Count,
-    IN  va_list                 Arguments
+    _In_ PXENBUS_EVTCHN_CONTEXT Context,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ ULONG                  Count,
+    _In_ va_list                Arguments
     )
 {
     ULONG                       Index;
@@ -320,10 +320,10 @@ RtlCaptureStackBackTrace(
 
 static PXENBUS_EVTCHN_CHANNEL
 EvtchnOpen(
-    IN  PINTERFACE          Interface,
-    IN  XENBUS_EVTCHN_TYPE  Type,
-    IN  PKSERVICE_ROUTINE   Callback,
-    IN  PVOID               Argument OPTIONAL,
+    _In_ PINTERFACE         Interface,
+    _In_ XENBUS_EVTCHN_TYPE Type,
+    _In_ PKSERVICE_ROUTINE  Callback,
+    _In_opt_ PVOID          Argument,
     ...
     )
 {
@@ -344,7 +344,7 @@ EvtchnOpen(
 
     Channel->Magic = XENBUS_EVTCHN_CHANNEL_MAGIC;
 
-    (VOID) RtlCaptureStackBackTrace(1, 1, &Channel->Caller, NULL);    
+    (VOID) RtlCaptureStackBackTrace(1, 1, &Channel->Caller, NULL);
 
     Channel->Type = Type;
     Channel->Callback = Callback;
@@ -449,9 +449,9 @@ fail1:
 
 static VOID
 EvtchnReap(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  BOOLEAN                 Close
+    _In_ PXENBUS_EVTCHN_CONTEXT Context,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ BOOLEAN                Close
     )
 {
     ULONG                       LocalPort = Channel->LocalPort;
@@ -493,8 +493,8 @@ EvtchnReap(
 
 static BOOLEAN
 EvtchnPollCallback(
-    IN  PVOID                   Argument,
-    IN  ULONG                   LocalPort
+    _In_ PVOID                  Argument,
+    _In_ ULONG                  LocalPort
     )
 {
     PXENBUS_EVTCHN_PROCESSOR    Processor = Argument;
@@ -527,9 +527,9 @@ done:
 
 static BOOLEAN
 EvtchnPoll(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context,
-    IN  ULONG                   Cpu,
-    IN  PLIST_ENTRY             List
+    _In_ PXENBUS_EVTCHN_CONTEXT Context,
+    _In_ ULONG                  Cpu,
+    _In_opt_ PLIST_ENTRY        List
     )
 {
     PXENBUS_EVTCHN_PROCESSOR    Processor;
@@ -609,8 +609,8 @@ EvtchnPoll(
 
 static VOID
 EvtchnFlush(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context,
-    IN  ULONG                   Cpu
+    _In_ PXENBUS_EVTCHN_CONTEXT Context,
+    _In_ ULONG                  Cpu
     )
 {
     PXENBUS_EVTCHN_PROCESSOR    Processor;
@@ -663,10 +663,10 @@ _IRQL_requires_(DISPATCH_LEVEL)
 _IRQL_requires_same_
 VOID
 EvtchnDpc(
-    IN  PKDPC                   Dpc,
-    IN  PVOID                   _Context,
-    IN  PVOID                   Argument1,
-    IN  PVOID                   Argument2
+    _In_ PKDPC                  Dpc,
+    _In_ PVOID                  _Context,
+    _In_ PVOID                  Argument1,
+    _In_ PVOID                  Argument2
     )
 {
     PXENBUS_EVTCHN_PROCESSOR    Processor = _Context;
@@ -690,8 +690,8 @@ done:
 
 static VOID
 EvtchnTrigger(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel
     )
 {
     PXENBUS_EVTCHN_CONTEXT      Context = Interface->Context;
@@ -733,10 +733,10 @@ EvtchnTrigger(
 
 static NTSTATUS
 EvtchnBind(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  USHORT                  Group,
-    IN  UCHAR                   Number
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ USHORT                 Group,
+    _In_ UCHAR                  Number
     )
 {
     PXENBUS_EVTCHN_CONTEXT      Context = Interface->Context;
@@ -806,10 +806,10 @@ fail1:
 
 static BOOLEAN
 EvtchnUnmask(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  BOOLEAN                 InUpcall,
-    IN  BOOLEAN                 Force
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ BOOLEAN                InUpcall,
+    _In_ BOOLEAN                Force
     )
 {
     PXENBUS_EVTCHN_CONTEXT      Context = Interface->Context;
@@ -888,9 +888,9 @@ done:
 
 static VOID
 EvtchnUnmaskVersion4(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  BOOLEAN                 InUpcall
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ BOOLEAN                InUpcall
     )
 {
     EvtchnUnmask(Interface, Channel, InUpcall, TRUE);
@@ -898,8 +898,8 @@ EvtchnUnmaskVersion4(
 
 static VOID
 EvtchnSend(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel
     )
 {
     UNREFERENCED_PARAMETER(Interface);
@@ -914,8 +914,8 @@ EvtchnSend(
 
 static VOID
 EvtchnSendVersion1(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel
     )
 {
     KIRQL                       Irql;
@@ -927,8 +927,8 @@ EvtchnSendVersion1(
 
 static VOID
 EvtchnClose(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel
     )
 {
     PXENBUS_EVTCHN_CONTEXT      Context = Interface->Context;
@@ -979,8 +979,8 @@ done:
 
 static ULONG
 EvtchnGetPort(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel
     )
 {
     UNREFERENCED_PARAMETER(Interface);
@@ -993,8 +993,8 @@ EvtchnGetPort(
 
 static ULONG
 EvtchnGetCount(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel
     )
 {
     UNREFERENCED_PARAMETER(Interface);
@@ -1006,10 +1006,10 @@ EvtchnGetCount(
 
 static NTSTATUS
 EvtchnWait(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  ULONG                   Count,
-    IN  PLARGE_INTEGER          Timeout
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ ULONG                  Count,
+    _In_ PLARGE_INTEGER         Timeout
     )
 {
     KIRQL                       Irql;
@@ -1069,9 +1069,9 @@ EvtchnWait(
 
 static NTSTATUS
 EvtchnWaitVersion5(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  PLARGE_INTEGER          Timeout
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_EVTCHN_CHANNEL Channel,
+    _In_ PLARGE_INTEGER         Timeout
     )
 {
     ULONG                       Count;
@@ -1084,13 +1084,13 @@ EvtchnWaitVersion5(
                       Timeout);
 }
 
-static
-_Function_class_(KSERVICE_ROUTINE)
-__drv_requiresIRQL(HIGH_LEVEL)
-BOOLEAN
+static KSERVICE_ROUTINE EvtchnInterruptCallback;
+
+_Use_decl_annotations_
+static BOOLEAN
 EvtchnInterruptCallback(
-    IN  PKINTERRUPT             InterruptObject,
-    IN  PVOID                   Argument
+    PKINTERRUPT                 InterruptObject,
+    PVOID                       Argument
     )
 {
     PXENBUS_EVTCHN_PROCESSOR    Processor = Argument;
@@ -1223,7 +1223,7 @@ EvtchnReset(
 
 static NTSTATUS
 EvtchnAbiAcquire(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context
+    _In_ PXENBUS_EVTCHN_CONTEXT Context
     )
 {
     NTSTATUS                    status;
@@ -1263,7 +1263,7 @@ fail1:
 
 static VOID
 EvtchnAbiRelease(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context
+    _In_ PXENBUS_EVTCHN_CONTEXT Context
     )
 {
     XENBUS_EVTCHN_ABI(Release, &Context->EvtchnAbi);
@@ -1273,8 +1273,8 @@ EvtchnAbiRelease(
 
 static BOOLEAN
 EvtchnIsProcessorEnabled(
-    IN  PXENBUS_EVTCHN_CONTEXT      Context,
-    IN  ULONG                       Cpu
+    _In_ PXENBUS_EVTCHN_CONTEXT     Context,
+    _In_ ULONG                      Cpu
     )
 {
     if (!XENBUS_SHARED_INFO(UpcallSupported,
@@ -1289,7 +1289,7 @@ EvtchnIsProcessorEnabled(
 
 static VOID
 EvtchnInterruptEnable(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context
+    _In_ PXENBUS_EVTCHN_CONTEXT Context
     )
 {
     ULONG                       Cpu;
@@ -1362,7 +1362,7 @@ line:
 
 static VOID
 EvtchnInterruptDisable(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context
+    _In_ PXENBUS_EVTCHN_CONTEXT Context
     )
 {
     ULONG                       Cpu;
@@ -1398,7 +1398,7 @@ EvtchnInterruptDisable(
 
 static VOID
 EvtchnSuspendCallbackEarly(
-    IN  PVOID               Argument
+    _In_ PVOID              Argument
     )
 {
     PXENBUS_EVTCHN_CONTEXT  Context = Argument;
@@ -1429,7 +1429,7 @@ EvtchnSuspendCallbackEarly(
 
 static VOID
 EvtchnSuspendCallbackLate(
-    IN  PVOID               Argument
+    _In_ PVOID              Argument
     )
 {
     PXENBUS_EVTCHN_CONTEXT  Context = Argument;
@@ -1446,8 +1446,8 @@ EvtchnSuspendCallbackLate(
 
 static VOID
 EvtchnDebugCallback(
-    IN  PVOID               Argument,
-    IN  BOOLEAN             Crashing
+    _In_ PVOID              Argument,
+    _In_ BOOLEAN            Crashing
     )
 {
     PXENBUS_EVTCHN_CONTEXT  Context = Argument;
@@ -1536,7 +1536,7 @@ EvtchnDebugCallback(
 
 static NTSTATUS
 EvtchnAcquire(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_EVTCHN_CONTEXT  Context = Interface->Context;
@@ -1736,7 +1736,7 @@ fail1:
 
 VOID
 EvtchnRelease(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_EVTCHN_CONTEXT  Context = Interface->Context;
@@ -1891,14 +1891,14 @@ static struct _XENBUS_EVTCHN_INTERFACE_V9 EvtchnInterfaceVersion9 = {
 
 NTSTATUS
 EvtchnInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_EVTCHN_CONTEXT  *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_EVTCHN_CONTEXT    *Context
     )
 {
-    HANDLE                      ParametersKey;
-    ULONG                       UseEvtchnFifoAbi;
-    ULONG                       UseEvtchnUpcall;
-    NTSTATUS                    status;
+    HANDLE                          ParametersKey;
+    ULONG                           UseEvtchnFifoAbi;
+    ULONG                           UseEvtchnUpcall;
+    NTSTATUS                        status;
 
     Trace("====>\n");
 
@@ -1995,13 +1995,13 @@ fail1:
 
 NTSTATUS
 EvtchnGetInterface(
-    IN      PXENBUS_EVTCHN_CONTEXT  Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_EVTCHN_CONTEXT Context,
+    _In_ ULONG                  Version,
+    _Inout_ PINTERFACE          Interface,
+    _In_ ULONG                  Size
     )
 {
-    NTSTATUS                        status;
+    NTSTATUS                    status;
 
     ASSERT(Context != NULL);
 
@@ -2097,11 +2097,11 @@ EvtchnGetInterface(
     }
 
     return status;
-}   
+}
 
 ULONG
 EvtchnGetReferences(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context
+    _In_ PXENBUS_EVTCHN_CONTEXT Context
     )
 {
     return Context->References;
@@ -2109,7 +2109,7 @@ EvtchnGetReferences(
 
 VOID
 EvtchnTeardown(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context
+    _In_ PXENBUS_EVTCHN_CONTEXT Context
     )
 {
     Trace("====>\n");
diff --git a/src/xenbus/evtchn.h b/src/xenbus/evtchn.h
index 3a85d45..d3ddd89 100644
--- a/src/xenbus/evtchn.h
+++ b/src/xenbus/evtchn.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -43,26 +43,26 @@ typedef struct _XENBUS_EVTCHN_CONTEXT  XENBUS_EVTCHN_CONTEXT, *PXENBUS_EVTCHN_CO
 
 extern NTSTATUS
 EvtchnInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_EVTCHN_CONTEXT  *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_EVTCHN_CONTEXT    *Context
     );
 
 extern NTSTATUS
 EvtchnGetInterface(
-    IN      PXENBUS_EVTCHN_CONTEXT  Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_EVTCHN_CONTEXT Context,
+    _In_ ULONG                  Version,
+    _Inout_ PINTERFACE          Interface,
+    _In_ ULONG                  Size
     );
 
 extern ULONG
 EvtchnGetReferences(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context
+    _In_ PXENBUS_EVTCHN_CONTEXT Context
     );
 
 extern VOID
 EvtchnTeardown(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context
+    _In_ PXENBUS_EVTCHN_CONTEXT Context
     );
 
 VOID
@@ -72,7 +72,7 @@ EvtchnReset(
 
 extern BOOLEAN
 EvtchnInterrupt(
-    IN  PXENBUS_EVTCHN_CONTEXT  Context
+    _In_ PXENBUS_EVTCHN_CONTEXT Context
     );
 
 #endif  // _XENBUS_EVTCHN_H
diff --git a/src/xenbus/evtchn_2l.c b/src/xenbus/evtchn_2l.c
index 6585f73..b2abead 100644
--- a/src/xenbus/evtchn_2l.c
+++ b/src/xenbus/evtchn_2l.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -52,7 +52,7 @@ typedef struct _XENBUS_EVTCHN_TWO_LEVEL_CONTEXT {
 
 static FORCEINLINE PVOID
 __EvtchnTwoLevelAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_EVTCHN_TWO_LEVEL_TAG);
@@ -60,7 +60,7 @@ __EvtchnTwoLevelAllocate(
 
 static FORCEINLINE VOID
 __EvtchnTwoLevelFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_EVTCHN_TWO_LEVEL_TAG);
@@ -68,8 +68,8 @@ __EvtchnTwoLevelFree(
 
 static BOOLEAN
 EvtchnTwoLevelIsProcessorEnabled(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  _Context,
-    IN  ULONG                       Index
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT _Context,
+    _In_ ULONG                      Index
     )
 {
     unsigned int                    vcpu_id;
@@ -85,10 +85,10 @@ EvtchnTwoLevelIsProcessorEnabled(
 
 static BOOLEAN
 EvtchnTwoLevelPoll(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT      _Context,
-    IN  ULONG                           Index,
-    IN  XENBUS_EVTCHN_ABI_EVENT         Event,
-    IN  PVOID                           Argument
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT     _Context,
+    _In_ ULONG                          Index,
+    _In_ XENBUS_EVTCHN_ABI_EVENT        Event,
+    _In_ PVOID                          Argument
     )
 {
     PXENBUS_EVTCHN_TWO_LEVEL_CONTEXT    Context = (PVOID)_Context;
@@ -102,8 +102,8 @@ EvtchnTwoLevelPoll(
 
 static NTSTATUS
 EvtchnTwoLevelPortEnable(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT      _Context,
-    IN  ULONG                           Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT     _Context,
+    _In_ ULONG                          Port
     )
 {
     UNREFERENCED_PARAMETER(_Context);
@@ -114,8 +114,8 @@ EvtchnTwoLevelPortEnable(
 
 static VOID
 EvtchnTwoLevelPortDisable(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT      _Context,
-    IN  ULONG                           Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT     _Context,
+    _In_ ULONG                          Port
     )
 {
     PXENBUS_EVTCHN_TWO_LEVEL_CONTEXT    Context = (PVOID)_Context;
@@ -127,8 +127,8 @@ EvtchnTwoLevelPortDisable(
 
 static VOID
 EvtchnTwoLevelPortAck(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT      _Context,
-    IN  ULONG                           Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT     _Context,
+    _In_ ULONG                          Port
     )
 {
     PXENBUS_EVTCHN_TWO_LEVEL_CONTEXT    Context = (PVOID)_Context;
@@ -140,8 +140,8 @@ EvtchnTwoLevelPortAck(
 
 static VOID
 EvtchnTwoLevelPortMask(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT      _Context,
-    IN  ULONG                           Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT     _Context,
+    _In_ ULONG                          Port
     )
 {
     PXENBUS_EVTCHN_TWO_LEVEL_CONTEXT    Context = (PVOID)_Context;
@@ -153,8 +153,8 @@ EvtchnTwoLevelPortMask(
 
 static BOOLEAN
 EvtchnTwoLevelPortUnmask(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT      _Context,
-    IN  ULONG                           Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT     _Context,
+    _In_ ULONG                          Port
     )
 {
     PXENBUS_EVTCHN_TWO_LEVEL_CONTEXT    Context = (PVOID)_Context;
@@ -166,7 +166,7 @@ EvtchnTwoLevelPortUnmask(
 
 static NTSTATUS
 EvtchnTwoLevelAcquire(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT      _Context
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT     _Context
     )
 {
     PXENBUS_EVTCHN_TWO_LEVEL_CONTEXT    Context = (PVOID)_Context;
@@ -205,7 +205,7 @@ fail1:
 
 VOID
 EvtchnTwoLevelRelease(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT      _Context
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT     _Context
     )
 {
     PXENBUS_EVTCHN_TWO_LEVEL_CONTEXT    Context = (PVOID)_Context;
@@ -241,8 +241,8 @@ static XENBUS_EVTCHN_ABI EvtchnAbiTwoLevel = {
 
 NTSTATUS
 EvtchnTwoLevelInitialize(
-    IN  PXENBUS_FDO                     Fdo,
-    OUT PXENBUS_EVTCHN_ABI_CONTEXT      *_Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Out_ PXENBUS_EVTCHN_ABI_CONTEXT    *_Context
     )
 {
     PXENBUS_EVTCHN_TWO_LEVEL_CONTEXT    Context;
@@ -281,8 +281,8 @@ fail1:
 
 VOID
 EvtchnTwoLevelGetAbi(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT      _Context,
-    OUT PXENBUS_EVTCHN_ABI              Abi)
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT     _Context,
+    _Out_ PXENBUS_EVTCHN_ABI            Abi)
 {
     *Abi = EvtchnAbiTwoLevel;
 
@@ -291,7 +291,7 @@ EvtchnTwoLevelGetAbi(
 
 VOID
 EvtchnTwoLevelTeardown(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT      _Context
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT     _Context
     )
 {
     PXENBUS_EVTCHN_TWO_LEVEL_CONTEXT    Context = (PVOID)_Context;
diff --git a/src/xenbus/evtchn_2l.h b/src/xenbus/evtchn_2l.h
index 9974385..41ed65c 100644
--- a/src/xenbus/evtchn_2l.h
+++ b/src/xenbus/evtchn_2l.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -41,19 +41,19 @@
 
 extern NTSTATUS
 EvtchnTwoLevelInitialize(
-    IN  PXENBUS_FDO                 Fdo,
-    OUT PXENBUS_EVTCHN_ABI_CONTEXT  *Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Out_ PXENBUS_EVTCHN_ABI_CONTEXT    *Context
     );
 
 extern VOID
 EvtchnTwoLevelGetAbi(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  Context,
-    OUT PXENBUS_EVTCHN_ABI          Abi
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT Context,
+    _Out_ PXENBUS_EVTCHN_ABI        Abi
     );
 
 extern VOID
 EvtchnTwoLevelTeardown(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  Context
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT Context
     );
 
 #endif  // _XENBUS_EVTCHN_H
diff --git a/src/xenbus/evtchn_abi.h b/src/xenbus/evtchn_abi.h
index 85480df..a1bc06b 100644
--- a/src/xenbus/evtchn_abi.h
+++ b/src/xenbus/evtchn_abi.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRAN4TIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRAN4TIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -40,62 +40,62 @@ typedef PVOID *PXENBUS_EVTCHN_ABI_CONTEXT;
 
 typedef NTSTATUS
 (*XENBUS_EVTCHN_ABI_ACQUIRE)(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  Context
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT Context
     );
 
 typedef VOID
 (*XENBUS_EVTCHN_ABI_RELEASE)(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  Context
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT Context
     );
 
 typedef BOOLEAN
 (*XENBUS_EVTCHN_ABI_IS_PROCESSOR_ENABLED)(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  Context,
-    IN  ULONG                       Index
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT Context,
+    _In_ ULONG                      Index
     );
 
 typedef BOOLEAN
 (*XENBUS_EVTCHN_ABI_EVENT)(
-    IN  PVOID   Argument,
-    IN  ULONG   Port
+    _In_ PVOID  Argument,
+    _In_ ULONG  Port
     );
 
 typedef BOOLEAN
 (*XENBUS_EVTCHN_ABI_POLL)(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  Context,
-    IN  ULONG                       Index,
-    IN  XENBUS_EVTCHN_ABI_EVENT     Event,
-    IN  PVOID                       Argument
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT Context,
+    _In_ ULONG                      Index,
+    _In_ XENBUS_EVTCHN_ABI_EVENT    Event,
+    _In_ PVOID                      Argument
     );
 
 typedef NTSTATUS
 (*XENBUS_EVTCHN_ABI_PORT_ENABLE)(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  Context,
-    IN  ULONG                       Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT Context,
+    _In_ ULONG                      Port
     );
 
 typedef VOID
 (*XENBUS_EVTCHN_ABI_PORT_DISABLE)(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  Context,
-    IN  ULONG                       Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT Context,
+    _In_ ULONG                      Port
     );
 
 typedef VOID
 (*XENBUS_EVTCHN_ABI_PORT_ACK)(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  Context,
-    IN  ULONG                       Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT Context,
+    _In_ ULONG                      Port
     );
 
 typedef VOID
 (*XENBUS_EVTCHN_ABI_PORT_MASK)(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  Context,
-    IN  ULONG                       Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT Context,
+    _In_ ULONG                      Port
     );
 
 typedef BOOLEAN
 (*XENBUS_EVTCHN_ABI_PORT_UNMASK)(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  Context,
-    IN  ULONG                       Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT Context,
+    _In_ ULONG                      Port
     );
 
 typedef struct _XENBUS_EVTCHN_ABI {
diff --git a/src/xenbus/evtchn_fifo.c b/src/xenbus/evtchn_fifo.c
index a9e8591..0f4b44e 100644
--- a/src/xenbus/evtchn_fifo.c
+++ b/src/xenbus/evtchn_fifo.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -58,7 +58,7 @@ typedef struct _XENBUS_EVTCHN_FIFO_CONTEXT {
 
 static FORCEINLINE PVOID
 __EvtchnFifoAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_EVTCHN_FIFO_TAG);
@@ -66,7 +66,7 @@ __EvtchnFifoAllocate(
 
 static FORCEINLINE VOID
 __EvtchnFifoFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_EVTCHN_FIFO_TAG);
@@ -74,13 +74,13 @@ __EvtchnFifoFree(
 
 static event_word_t *
 EvtchnFifoEventWord(
-    IN  PXENBUS_EVTCHN_FIFO_CONTEXT Context,
-    IN  ULONG                       Port
+    _In_ PXENBUS_EVTCHN_FIFO_CONTEXT    Context,
+    _In_ ULONG                          Port
     )
 {
-    ULONG                           Index;
-    PMDL                            Mdl;
-    event_word_t                    *EventWord;
+    ULONG                               Index;
+    PMDL                                Mdl;
+    event_word_t                        *EventWord;
 
     Index = Port / EVENT_WORDS_PER_PAGE;
     ASSERT3U(Index, <, Context->EventPageCount);
@@ -98,8 +98,8 @@ EvtchnFifoEventWord(
 
 static FORCEINLINE BOOLEAN
 __EvtchnFifoTestFlag(
-    IN  event_word_t    *EventWord,
-    IN  ULONG           Flag
+    _In_ event_word_t   *EventWord,
+    _In_ ULONG          Flag
     )
 {
     KeMemoryBarrier();
@@ -108,8 +108,8 @@ __EvtchnFifoTestFlag(
 
 static FORCEINLINE BOOLEAN
 __EvtchnFifoTestAndSetFlag(
-    IN  event_word_t    *EventWord,
-    IN  ULONG           Flag
+    _In_ event_word_t   *EventWord,
+    _In_ ULONG          Flag
     )
 {
     return (InterlockedBitTestAndSet((LONG *)EventWord, Flag) != 0) ? TRUE : FALSE;
@@ -117,8 +117,8 @@ __EvtchnFifoTestAndSetFlag(
 
 static FORCEINLINE BOOLEAN
 __EvtchnFifoTestAndClearFlag(
-    IN  event_word_t    *EventWord,
-    IN  ULONG           Flag
+    _In_ event_word_t   *EventWord,
+    _In_ ULONG          Flag
     )
 {
     return (InterlockedBitTestAndReset((LONG *)EventWord, Flag) != 0) ? TRUE : FALSE;
@@ -126,8 +126,8 @@ __EvtchnFifoTestAndClearFlag(
 
 static FORCEINLINE VOID
 __EvtchnFifoSetFlag(
-    IN  event_word_t    *EventWord,
-    IN  ULONG           Flag
+    _In_ event_word_t   *EventWord,
+    _In_ ULONG          Flag
     )
 {
     (VOID) InterlockedBitTestAndSet((LONG *)EventWord, Flag);
@@ -135,8 +135,8 @@ __EvtchnFifoSetFlag(
 
 static FORCEINLINE VOID
 __EvtchnFifoClearFlag(
-    IN  event_word_t    *EventWord,
-    IN  ULONG           Flag
+    _In_ event_word_t   *EventWord,
+    _In_ ULONG          Flag
     )
 {
     (VOID) InterlockedBitTestAndReset((LONG *)EventWord, Flag);
@@ -144,7 +144,7 @@ __EvtchnFifoClearFlag(
 
 static FORCEINLINE ULONG
 __EvtchnFifoUnlink(
-    IN  event_word_t    *EventWord
+    _In_ event_word_t   *EventWord
     )
 {
     LONG                Old;
@@ -162,17 +162,17 @@ __EvtchnFifoUnlink(
 
 static NTSTATUS
 EvtchnFifoExpand(
-    IN  PXENBUS_EVTCHN_FIFO_CONTEXT Context,
-    IN  ULONG                       Port
+    _In_ PXENBUS_EVTCHN_FIFO_CONTEXT    Context,
+    _In_ ULONG                          Port
     )
 {
-    LONG                            Index;
-    ULONG                           EventPageCount;
-    PMDL                            *EventPageMdl;
-    PMDL                            Mdl;
-    ULONG                           Start;
-    ULONG                           End;
-    NTSTATUS                        status;
+    LONG                                Index;
+    ULONG                               EventPageCount;
+    PMDL                                *EventPageMdl;
+    PMDL                                Mdl;
+    ULONG                               Start;
+    ULONG                               End;
+    NTSTATUS                            status;
 
     Index = Port / EVENT_WORDS_PER_PAGE;
     ASSERT3U(Index, >=, (LONG)Context->EventPageCount);
@@ -259,10 +259,10 @@ fail1:
 
 static VOID
 EvtchnFifoContract(
-    IN  PXENBUS_EVTCHN_FIFO_CONTEXT Context
+    _In_ PXENBUS_EVTCHN_FIFO_CONTEXT    Context
     )
 {
-    LONG                            Index;
+    LONG                                Index;
 
     Index = Context->EventPageCount;
     while (--Index >= 0) {
@@ -282,14 +282,14 @@ EvtchnFifoContract(
 
 static BOOLEAN
 EvtchnFifoIsProcessorEnabled(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  _Context,
-    IN  ULONG                       Index
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT _Context,
+    _In_ ULONG                      Index
     )
 {
     PXENBUS_EVTCHN_FIFO_CONTEXT     Context = (PVOID)_Context;
     unsigned int                    vcpu_id;
     NTSTATUS                        status;
-    
+
     status = SystemProcessorVcpuId(Index, &vcpu_id);
     if (!NT_SUCCESS(status))
         return FALSE;
@@ -299,18 +299,18 @@ EvtchnFifoIsProcessorEnabled(
 
 static BOOLEAN
 EvtchnFifoPollPriority(
-    IN  PXENBUS_EVTCHN_FIFO_CONTEXT Context,
-    IN  unsigned int                vcpu_id,
-    IN  ULONG                       Priority,
-    IN  PULONG                      Ready,
-    IN  XENBUS_EVTCHN_ABI_EVENT     Event,
-    IN  PVOID                       Argument
+    _In_ PXENBUS_EVTCHN_FIFO_CONTEXT    Context,
+    _In_ unsigned int                   vcpu_id,
+    _In_ ULONG                          Priority,
+    _In_ PULONG                         Ready,
+    _In_ XENBUS_EVTCHN_ABI_EVENT        Event,
+    _In_ PVOID                          Argument
     )
 {
-    ULONG                           Head;
-    ULONG                           Port;
-    event_word_t                    *EventWord;
-    BOOLEAN                         DoneSomething;
+    ULONG                               Head;
+    ULONG                               Port;
+    event_word_t                        *EventWord;
+    BOOLEAN                             DoneSomething;
 
     Head = Context->Head[vcpu_id][Priority];
 
@@ -348,10 +348,10 @@ EvtchnFifoPollPriority(
 
 static BOOLEAN
 EvtchnFifoPoll(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  _Context,
-    IN  ULONG                       Index,
-    IN  XENBUS_EVTCHN_ABI_EVENT     Event,
-    IN  PVOID                       Argument
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT _Context,
+    _In_ ULONG                      Index,
+    _In_ XENBUS_EVTCHN_ABI_EVENT    Event,
+    _In_ PVOID                      Argument
     )
 {
     PXENBUS_EVTCHN_FIFO_CONTEXT     Context = (PVOID)_Context;
@@ -394,8 +394,8 @@ done:
 
 static NTSTATUS
 EvtchnFifoPortEnable(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  _Context,
-    IN  ULONG                       Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT _Context,
+    _In_ ULONG                      Port
     )
 {
     PXENBUS_EVTCHN_FIFO_CONTEXT     Context = (PVOID)_Context;
@@ -425,8 +425,8 @@ fail1:
 
 static VOID
 EvtchnFifoPortAck(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  _Context,
-    IN  ULONG                       Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT _Context,
+    _In_ ULONG                      Port
     )
 {
     PXENBUS_EVTCHN_FIFO_CONTEXT     Context = (PVOID)_Context;
@@ -438,8 +438,8 @@ EvtchnFifoPortAck(
 
 static VOID
 EvtchnFifoPortMask(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  _Context,
-    IN  ULONG                       Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT _Context,
+    _In_ ULONG                      Port
     )
 {
     PXENBUS_EVTCHN_FIFO_CONTEXT     Context = (PVOID)_Context;
@@ -451,8 +451,8 @@ EvtchnFifoPortMask(
 
 static BOOLEAN
 EvtchnFifoPortUnmask(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  _Context,
-    IN  ULONG                       Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT _Context,
+    _In_ ULONG                      Port
     )
 {
     PXENBUS_EVTCHN_FIFO_CONTEXT     Context = (PVOID)_Context;
@@ -474,8 +474,8 @@ EvtchnFifoPortUnmask(
 
 static VOID
 EvtchnFifoPortDisable(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  _Context,
-    IN  ULONG                       Port
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT _Context,
+    _In_ ULONG                      Port
     )
 {
     EvtchnFifoPortMask(_Context, Port);
@@ -483,7 +483,7 @@ EvtchnFifoPortDisable(
 
 static NTSTATUS
 EvtchnFifoAcquire(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  _Context
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT _Context
     )
 {
     PXENBUS_EVTCHN_FIFO_CONTEXT     Context = (PVOID)_Context;
@@ -585,7 +585,7 @@ fail1:
 
 VOID
 EvtchnFifoRelease(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  _Context
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT _Context
     )
 {
     PXENBUS_EVTCHN_FIFO_CONTEXT     Context = (PVOID)_Context;
@@ -637,8 +637,8 @@ static XENBUS_EVTCHN_ABI EvtchnAbiFifo = {
 
 NTSTATUS
 EvtchnFifoInitialize(
-    IN  PXENBUS_FDO                     Fdo,
-    OUT PXENBUS_EVTCHN_ABI_CONTEXT      *_Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Out_ PXENBUS_EVTCHN_ABI_CONTEXT    *_Context
     )
 {
     PXENBUS_EVTCHN_FIFO_CONTEXT    Context;
@@ -670,8 +670,8 @@ fail1:
 
 VOID
 EvtchnFifoGetAbi(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT      _Context,
-    OUT PXENBUS_EVTCHN_ABI              Abi)
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT     _Context,
+    _Out_ PXENBUS_EVTCHN_ABI            Abi)
 {
     *Abi = EvtchnAbiFifo;
 
@@ -680,7 +680,7 @@ EvtchnFifoGetAbi(
 
 VOID
 EvtchnFifoTeardown(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT      _Context
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT     _Context
     )
 {
     PXENBUS_EVTCHN_FIFO_CONTEXT    Context = (PVOID)_Context;
diff --git a/src/xenbus/evtchn_fifo.h b/src/xenbus/evtchn_fifo.h
index 03d3edf..c8a8fdf 100644
--- a/src/xenbus/evtchn_fifo.h
+++ b/src/xenbus/evtchn_fifo.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -41,19 +41,19 @@
 
 extern NTSTATUS
 EvtchnFifoInitialize(
-    IN  PXENBUS_FDO                 Fdo,
-    OUT PXENBUS_EVTCHN_ABI_CONTEXT  *Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Out_ PXENBUS_EVTCHN_ABI_CONTEXT    *Context
     );
 
 extern VOID
 EvtchnFifoGetAbi(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  Context,
-    OUT PXENBUS_EVTCHN_ABI          Abi
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT Context,
+    _Out_ PXENBUS_EVTCHN_ABI        Abi
     );
 
 extern VOID
 EvtchnFifoTeardown(
-    IN  PXENBUS_EVTCHN_ABI_CONTEXT  Context
+    _In_ PXENBUS_EVTCHN_ABI_CONTEXT Context
     );
 
 #endif  // _XENBUS_EVTCHN_FIFO_H
diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index 3a4a1a2..d2a8869 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source 1and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source 1and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the23 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the23
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -173,7 +173,7 @@ struct _XENBUS_FDO {
 
 static FORCEINLINE PVOID
 __FdoAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_FDO_TAG);
@@ -181,7 +181,7 @@ __FdoAllocate(
 
 static FORCEINLINE VOID
 __FdoFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_FDO_TAG);
@@ -189,8 +189,8 @@ __FdoFree(
 
 static FORCEINLINE VOID
 __FdoSetDevicePnpState(
-    IN  PXENBUS_FDO         Fdo,
-    IN  DEVICE_PNP_STATE    State
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ DEVICE_PNP_STATE   State
     )
 {
     PXENBUS_DX              Dx = Fdo->Dx;
@@ -204,8 +204,8 @@ __FdoSetDevicePnpState(
 
 static FORCEINLINE VOID
 __FdoRestoreDevicePnpState(
-    IN  PXENBUS_FDO         Fdo,
-    IN  DEVICE_PNP_STATE    State
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ DEVICE_PNP_STATE   State
     )
 {
     PXENBUS_DX              Dx = Fdo->Dx;
@@ -216,28 +216,28 @@ __FdoRestoreDevicePnpState(
 
 static FORCEINLINE DEVICE_PNP_STATE
 __FdoGetDevicePnpState(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    PXENBUS_DX      Dx = Fdo->Dx;
+    PXENBUS_DX          Dx = Fdo->Dx;
 
     return Dx->DevicePnpState;
 }
 
 static FORCEINLINE DEVICE_PNP_STATE
 __FdoGetPreviousDevicePnpState(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    PXENBUS_DX      Dx = Fdo->Dx;
+    PXENBUS_DX          Dx = Fdo->Dx;
 
     return Dx->PreviousDevicePnpState;
 }
 
 static FORCEINLINE VOID
 __FdoSetDevicePowerState(
-    IN  PXENBUS_FDO         Fdo,
-    IN  DEVICE_POWER_STATE  State
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ DEVICE_POWER_STATE State
     )
 {
     PXENBUS_DX              Dx = Fdo->Dx;
@@ -247,18 +247,18 @@ __FdoSetDevicePowerState(
 
 static FORCEINLINE DEVICE_POWER_STATE
 __FdoGetDevicePowerState(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    PXENBUS_DX      Dx = Fdo->Dx;
+    PXENBUS_DX          Dx = Fdo->Dx;
 
     return Dx->DevicePowerState;
 }
 
 static FORCEINLINE VOID
 __FdoSetSystemPowerState(
-    IN  PXENBUS_FDO         Fdo,
-    IN  SYSTEM_POWER_STATE  State
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ SYSTEM_POWER_STATE State
     )
 {
     PXENBUS_DX              Dx = Fdo->Dx;
@@ -268,27 +268,27 @@ __FdoSetSystemPowerState(
 
 static FORCEINLINE SYSTEM_POWER_STATE
 __FdoGetSystemPowerState(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    PXENBUS_DX      Dx = Fdo->Dx;
+    PXENBUS_DX          Dx = Fdo->Dx;
 
     return Dx->SystemPowerState;
 }
 
 static FORCEINLINE PDEVICE_OBJECT
 __FdoGetDeviceObject(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    PXENBUS_DX      Dx = Fdo->Dx;
+    PXENBUS_DX          Dx = Fdo->Dx;
 
     return Dx->DeviceObject;
 }
 
 PDEVICE_OBJECT
 FdoGetDeviceObject(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     return __FdoGetDeviceObject(Fdo);
@@ -296,7 +296,7 @@ FdoGetDeviceObject(
 
 static FORCEINLINE PDEVICE_OBJECT
 __FdoGetPhysicalDeviceObject(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     return Fdo->PhysicalDeviceObject;
@@ -304,16 +304,16 @@ __FdoGetPhysicalDeviceObject(
 
 PDEVICE_OBJECT
 FdoGetPhysicalDeviceObject(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     return __FdoGetPhysicalDeviceObject(Fdo);
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static NTSTATUS
 FdoAcquireLowerBusInterface(
-    IN  PXENBUS_FDO         Fdo
+    _In_ PXENBUS_FDO        Fdo
     )
 {
     PBUS_INTERFACE_STANDARD BusInterface;
@@ -396,7 +396,7 @@ fail1:
 
 static VOID
 FdoReleaseLowerBusInterface(
-    IN  PXENBUS_FDO         Fdo
+    _In_ PXENBUS_FDO        Fdo
     )
 {
     PBUS_INTERFACE_STANDARD BusInterface;
@@ -415,12 +415,12 @@ FdoReleaseLowerBusInterface(
 
 PDMA_ADAPTER
 FdoGetDmaAdapter(
-    IN  PXENBUS_FDO         Fdo,
-    IN  PDEVICE_DESCRIPTION DeviceDescriptor,
-    OUT PULONG              NumberOfMapRegisters
+    _In_ PXENBUS_FDO            Fdo,
+    _In_ PDEVICE_DESCRIPTION    DeviceDescriptor,
+    _Out_ PULONG                NumberOfMapRegisters
     )
 {
-    PBUS_INTERFACE_STANDARD BusInterface;
+    PBUS_INTERFACE_STANDARD     BusInterface;
 
     BusInterface = Fdo->LowerBusInterface;
     ASSERT(BusInterface != NULL);
@@ -432,14 +432,14 @@ FdoGetDmaAdapter(
 
 BOOLEAN
 FdoTranslateBusAddress(
-    IN      PXENBUS_FDO         Fdo,
-    IN      PHYSICAL_ADDRESS    BusAddress,
-    IN      ULONG               Length,
-    IN OUT  PULONG              AddressSpace,
-    OUT     PPHYSICAL_ADDRESS   TranslatedAddress
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ PHYSICAL_ADDRESS   BusAddress,
+    _In_ ULONG              Length,
+    _Inout_ PULONG          AddressSpace,
+    _Out_ PPHYSICAL_ADDRESS TranslatedAddress
     )
 {
-    PBUS_INTERFACE_STANDARD     BusInterface;
+    PBUS_INTERFACE_STANDARD BusInterface;
 
     BusInterface = Fdo->LowerBusInterface;
     ASSERT(BusInterface != NULL);
@@ -453,11 +453,11 @@ FdoTranslateBusAddress(
 
 ULONG
 FdoSetBusData(
-    IN  PXENBUS_FDO         Fdo,
-    IN  ULONG               DataType,
-    IN  PVOID               Buffer,
-    IN  ULONG               Offset,
-    IN  ULONG               Length
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ ULONG              DataType,
+    _In_ PVOID              Buffer,
+    _In_ ULONG              Offset,
+    _In_ ULONG              Length
     )
 {
     PBUS_INTERFACE_STANDARD BusInterface;
@@ -474,11 +474,11 @@ FdoSetBusData(
 
 ULONG
 FdoGetBusData(
-    IN  PXENBUS_FDO         Fdo,
-    IN  ULONG               DataType,
-    IN  PVOID               Buffer,
-    IN  ULONG               Offset,
-    IN  ULONG               Length
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ ULONG              DataType,
+    _In_ PVOID              Buffer,
+    _In_ ULONG              Offset,
+    _In_ ULONG              Length
     )
 {
     PBUS_INTERFACE_STANDARD BusInterface;
@@ -495,12 +495,12 @@ FdoGetBusData(
 
 static FORCEINLINE NTSTATUS
 __FdoSetVendorName(
-    IN  PXENBUS_FDO Fdo,
-    IN  USHORT      VendorID,
-    IN  USHORT      DeviceID
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ USHORT         VendorID,
+    _In_ USHORT         DeviceID
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     status = STATUS_NOT_SUPPORTED;
     if (VendorID != 'XS')
@@ -523,7 +523,7 @@ fail1:
 
 static FORCEINLINE PCHAR
 __FdoGetVendorName(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     return Fdo->VendorName;
@@ -531,7 +531,7 @@ __FdoGetVendorName(
 
 PCHAR
 FdoGetVendorName(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     return __FdoGetVendorName(Fdo);
@@ -539,11 +539,11 @@ FdoGetVendorName(
 
 static FORCEINLINE VOID
 __FdoSetName(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    PXENBUS_DX      Dx = Fdo->Dx;
-    NTSTATUS        status;
+    PXENBUS_DX          Dx = Fdo->Dx;
+    NTSTATUS            status;
 
     status = RtlStringCbPrintfA(Dx->Name,
                                 MAXNAMELEN,
@@ -554,7 +554,7 @@ __FdoSetName(
 
 static FORCEINLINE PCHAR
 __FdoGetName(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     PXENBUS_DX      Dx = Fdo->Dx;
@@ -564,18 +564,18 @@ __FdoGetName(
 
 PCHAR
 FdoGetName(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     return __FdoGetName(Fdo);
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static NTSTATUS
 FdoQueryId(
-    IN  PXENBUS_FDO         Fdo,
-    IN  BUS_QUERY_ID_TYPE   Type,
-    OUT PCHAR               *Id
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ BUS_QUERY_ID_TYPE  Type,
+    _Out_ PCHAR             *Id
     )
 {
     KEVENT                  Event;
@@ -653,12 +653,12 @@ fail1:
     return status;
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static NTSTATUS
 FdoQueryDeviceText(
-    IN  PXENBUS_FDO         Fdo,
-    IN  DEVICE_TEXT_TYPE    Type,
-    OUT PCHAR               *Text
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ DEVICE_TEXT_TYPE   Type,
+    _Out_ PCHAR             *Text
     )
 {
     KEVENT                  Event;
@@ -738,14 +738,14 @@ fail1:
 
 static NTSTATUS
 FdoSetActive(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    PCHAR           DeviceID;
-    PCHAR           InstanceID;
-    PCHAR           ActiveDeviceID;
-    PCHAR           LocationInformation;
-    NTSTATUS        status;
+    PCHAR               DeviceID;
+    PCHAR               InstanceID;
+    PCHAR               ActiveDeviceID;
+    PCHAR               LocationInformation;
+    NTSTATUS            status;
 
     status = FdoQueryId(Fdo,
                         BusQueryDeviceID,
@@ -803,7 +803,7 @@ fail1:
 
 static VOID
 FdoClearActive(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     (VOID) ConfigClearActive();
@@ -813,7 +813,7 @@ FdoClearActive(
 
 static FORCEINLINE BOOLEAN
 __FdoIsActive(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     return Fdo->Active;
@@ -822,7 +822,7 @@ __FdoIsActive(
 #define DEFINE_FDO_GET_CONTEXT(_Interface, _Type)               \
 static FORCEINLINE _Type                                        \
 __FdoGet ## _Interface ## Context(                              \
-    IN  PXENBUS_FDO Fdo                                         \
+    _In_ PXENBUS_FDO    Fdo                                     \
     )                                                           \
 {                                                               \
     return Fdo-> ## _Interface ## Context;                      \
@@ -830,7 +830,7 @@ __FdoGet ## _Interface ## Context(                              \
                                                                 \
 _Type                                                           \
 FdoGet ## _Interface ## Context(                                \
-    IN  PXENBUS_FDO Fdo                                         \
+    _In_ PXENBUS_FDO    Fdo                                     \
     )                                                           \
 {                                                               \
     return __FdoGet ## _Interface ## Context(Fdo);              \
@@ -848,13 +848,14 @@ DEFINE_FDO_GET_CONTEXT(Gnttab, PXENBUS_GNTTAB_CONTEXT)
 DEFINE_FDO_GET_CONTEXT(Unplug, PXENBUS_UNPLUG_CONTEXT)
 DEFINE_FDO_GET_CONTEXT(Balloon, PXENBUS_BALLOON_CONTEXT)
 
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
+static IO_COMPLETION_ROUTINE FdoDelegateIrpCompletion;
+
+_Use_decl_annotations_
 static NTSTATUS
 FdoDelegateIrpCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp,
+    PVOID               Context
     )
 {
     PKEVENT             Event = Context;
@@ -869,8 +870,8 @@ FdoDelegateIrpCompletion(
 
 NTSTATUS
 FdoDelegateIrp(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     PDEVICE_OBJECT      DeviceObject;
@@ -933,13 +934,14 @@ done:
     return status;
 }
 
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
+static IO_COMPLETION_ROUTINE FdoForwardIrpSynchronouslyCompletion;
+
+_Use_decl_annotations_
 static NTSTATUS
 FdoForwardIrpSynchronouslyCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp,
+    PVOID               Context
     )
 {
     PKEVENT             Event = Context;
@@ -954,12 +956,12 @@ FdoForwardIrpSynchronouslyCompletion(
 
 static NTSTATUS
 FdoForwardIrpSynchronously(
-    IN  PXENBUS_FDO Fdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
-    KEVENT          Event;
-    NTSTATUS        status;
+    KEVENT              Event;
+    NTSTATUS            status;
 
     ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
 
@@ -990,8 +992,8 @@ FdoForwardIrpSynchronously(
 
 VOID
 FdoAddPhysicalDeviceObject(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PXENBUS_PDO     Pdo
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     PDEVICE_OBJECT      DeviceObject;
@@ -1011,8 +1013,8 @@ FdoAddPhysicalDeviceObject(
 
 VOID
 FdoRemovePhysicalDeviceObject(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PXENBUS_PDO     Pdo
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     PDEVICE_OBJECT      DeviceObject;
@@ -1035,7 +1037,7 @@ FdoRemovePhysicalDeviceObject(
 
 static FORCEINLINE VOID
 __FdoAcquireMutex(
-    IN  PXENBUS_FDO     Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     AcquireMutex(&Fdo->Mutex);
@@ -1043,7 +1045,7 @@ __FdoAcquireMutex(
 
 VOID
 FdoAcquireMutex(
-    IN  PXENBUS_FDO     Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     __FdoAcquireMutex(Fdo);
@@ -1051,7 +1053,7 @@ FdoAcquireMutex(
 
 static FORCEINLINE VOID
 __FdoReleaseMutex(
-    IN  PXENBUS_FDO     Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     ReleaseMutex(&Fdo->Mutex);
@@ -1059,7 +1061,7 @@ __FdoReleaseMutex(
 
 VOID
 FdoReleaseMutex(
-    IN  PXENBUS_FDO     Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     __FdoReleaseMutex(Fdo);
@@ -1073,8 +1075,8 @@ FdoReleaseMutex(
 
 static BOOLEAN
 FdoEnumerate(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PANSI_STRING    Classes
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PANSI_STRING   Classes
     )
 {
     BOOLEAN             NeedInvalidate;
@@ -1169,7 +1171,7 @@ done:
 
 static PANSI_STRING
 FdoMultiSzToUpcaseAnsi(
-    IN  PCHAR       Buffer
+    _In_ PCHAR      Buffer
     )
 {
     PANSI_STRING    Ansi;
@@ -1234,37 +1236,37 @@ fail1:
 
 static VOID
 FdoFreeAnsi(
-    IN  PANSI_STRING    Ansi
+    _In_ PANSI_STRING   Ansi
     )
 {
     ULONG               Index;
 
     for (Index = 0; Ansi[Index].Buffer != NULL; Index++)
         __FdoFree(Ansi[Index].Buffer);
-        
+
     __FdoFree(Ansi);
 }
 
 static PANSI_STRING
 FdoCombineAnsi(
-    IN  PANSI_STRING    AnsiA,
-    IN  PANSI_STRING    AnsiB
+    _In_opt_ PANSI_STRING   AnsiA,
+    _In_opt_ PANSI_STRING   AnsiB
     )
 {
-    LONG                Count;
-    ULONG               Index;
-    PANSI_STRING        Ansi;
-    NTSTATUS            status;
+    LONG                    Count;
+    ULONG                   Index;
+    PANSI_STRING            Ansi;
+    NTSTATUS                status;
 
     Count = 0;
 
     for (Index = 0;
-         AnsiA != NULL && AnsiA[Index].Buffer != NULL; 
+         AnsiA != NULL && AnsiA[Index].Buffer != NULL;
          Index++)
         Count++;
 
     for (Index = 0;
-         AnsiB != NULL && AnsiB[Index].Buffer != NULL; 
+         AnsiB != NULL && AnsiB[Index].Buffer != NULL;
          Index++)
         Count++;
 
@@ -1277,7 +1279,7 @@ FdoCombineAnsi(
     Count = 0;
 
     for (Index = 0;
-         AnsiA != NULL && AnsiA[Index].Buffer != NULL; 
+         AnsiA != NULL && AnsiA[Index].Buffer != NULL;
          Index++) {
         USHORT  Length;
 
@@ -1297,7 +1299,7 @@ FdoCombineAnsi(
     }
 
     for (Index = 0;
-         AnsiB != NULL && AnsiB[Index].Buffer != NULL; 
+         AnsiB != NULL && AnsiB[Index].Buffer != NULL;
          Index++) {
         USHORT  Length;
 
@@ -1324,7 +1326,7 @@ fail3:
 fail2:
     Error("fail2\n");
 
-    while (--Count >= 0) 
+    while (--Count >= 0)
         __FdoFree(Ansi[Count].Buffer);
 
     __FdoFree(Ansi);
@@ -1337,8 +1339,8 @@ fail1:
 
 static NTSTATUS
 FdoScan(
-    IN  PXENBUS_THREAD  Self,
-    IN  PVOID           Context
+    _In_ PXENBUS_THREAD Self,
+    _In_ PVOID          Context
     )
 {
     PXENBUS_FDO         Fdo = Context;
@@ -1425,7 +1427,7 @@ FdoScan(
         }
 
         // NULL out anything in the Classes list that not in the
-        // SupportedClasses list    
+        // SupportedClasses list
         for (Index = 0; Classes[Index].Buffer != NULL; Index++) {
             PANSI_STRING    Class = &Classes[Index];
             ULONG           Entry;
@@ -1457,7 +1459,7 @@ FdoScan(
 
         if (NeedInvalidate) {
             NeedInvalidate = FALSE;
-            IoInvalidateDeviceRelations(__FdoGetPhysicalDeviceObject(Fdo), 
+            IoInvalidateDeviceRelations(__FdoGetPhysicalDeviceObject(Fdo),
                                         BusRelations);
         }
 
@@ -1473,7 +1475,7 @@ loop:
 
 static FORCEINLINE NTSTATUS
 __FdoSuspendSetActive(
-    IN  PXENBUS_FDO     Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     if (!TryAcquireMutex(&Fdo->BalloonSuspendMutex))
@@ -1489,7 +1491,7 @@ fail1:
 
 static FORCEINLINE VOID
 __FdoSuspendClearActive(
-    IN  PXENBUS_FDO     Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     ReleaseMutex(&Fdo->BalloonSuspendMutex);
@@ -1506,8 +1508,8 @@ __FdoSuspendClearActive(
 
 static NTSTATUS
 FdoSuspend(
-    IN  PXENBUS_THREAD  Self,
-    IN  PVOID           Context
+    _In_ PXENBUS_THREAD Self,
+    _In_ PVOID          Context
     )
 {
     PXENBUS_FDO         Fdo = Context;
@@ -1557,7 +1559,7 @@ FdoSuspend(
                               &Buffer);
         if (NT_SUCCESS(status)) {
             Suspend = (strcmp(Buffer, "suspend") == 0) ? TRUE : FALSE;
-                
+
             XENBUS_STORE(Free,
                          &Fdo->StoreInterface,
                          Buffer);
@@ -1604,7 +1606,7 @@ loop:
 
 static FORCEINLINE NTSTATUS
 __FdoBalloonSetActive(
-    IN  PXENBUS_FDO         Fdo
+    _In_ PXENBUS_FDO        Fdo
     )
 {
     if (!TryAcquireMutex(&Fdo->BalloonSuspendMutex))
@@ -1628,7 +1630,7 @@ fail1:
 
 static FORCEINLINE VOID
 __FdoBalloonClearActive(
-    IN  PXENBUS_FDO     Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     (VOID) XENBUS_STORE(Printf,
@@ -1654,8 +1656,8 @@ __FdoBalloonClearActive(
 
 static NTSTATUS
 FdoBalloon(
-    IN  PXENBUS_THREAD  Self,
-    IN  PVOID           Context
+    _In_ PXENBUS_THREAD Self,
+    _In_ PVOID          Context
     )
 {
     PXENBUS_FDO         Fdo = Context;
@@ -1691,7 +1693,7 @@ FdoBalloon(
                                      &Timeout :
                                      NULL);
         KeClearEvent(Event);
-        
+
         Trace("awake\n");
 
         if (ThreadIsAlerted(Self))
@@ -1819,8 +1821,8 @@ loop:
 
 static VOID
 FdoDumpIoResourceDescriptor(
-    IN  PXENBUS_FDO             Fdo,
-    IN  PIO_RESOURCE_DESCRIPTOR Descriptor
+    _In_ PXENBUS_FDO                Fdo,
+    _In_ PIO_RESOURCE_DESCRIPTOR    Descriptor
     )
 {
     Trace("%s: %s\n",
@@ -1868,8 +1870,8 @@ FdoDumpIoResourceDescriptor(
 
 static VOID
 FdoDumpIoResourceList(
-    IN  PXENBUS_FDO         Fdo,
-    IN  PIO_RESOURCE_LIST   List
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ PIO_RESOURCE_LIST  List
     )
 {
     ULONG                   Index;
@@ -1887,8 +1889,8 @@ FdoDumpIoResourceList(
 
 static NTSTATUS
 FdoFilterResourceRequirements(
-    IN  PXENBUS_FDO                 Fdo,
-    IN  PIRP                        Irp
+    _In_ PXENBUS_FDO                Fdo,
+    _In_ PIRP                       Irp
     )
 {
     PIO_RESOURCE_REQUIREMENTS_LIST  Old;
@@ -1991,9 +1993,9 @@ fail1:
 
 static VOID
 FdoDumpCmPartialResourceDescriptor(
-    IN  PXENBUS_FDO                     Fdo,
-    IN  BOOLEAN                         Translated,
-    IN  PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
+    _In_ PXENBUS_FDO                        Fdo,
+    _In_ BOOLEAN                            Translated,
+    _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR    Descriptor
     )
 {
     Trace("%s: %s: %s SharedDisposition=%s Flags=%04x\n",
@@ -2002,7 +2004,7 @@ FdoDumpCmPartialResourceDescriptor(
           ResourceDescriptorTypeName(Descriptor->Type),
           ResourceDescriptorShareDispositionName(Descriptor->ShareDisposition),
           Descriptor->Flags);
-    
+
     switch (Descriptor->Type) {
     case CmResourceTypeMemory:
         Trace("%s: %s: Start = %08x.%08x Length = %08x\n",
@@ -2043,9 +2045,9 @@ FdoDumpCmPartialResourceDescriptor(
 
 static VOID
 FdoDumpCmPartialResourceList(
-    IN  PXENBUS_FDO                 Fdo,
-    IN  BOOLEAN                     Translated,
-    IN  PCM_PARTIAL_RESOURCE_LIST   List
+    _In_ PXENBUS_FDO                Fdo,
+    _In_ BOOLEAN                    Translated,
+    _In_ PCM_PARTIAL_RESOURCE_LIST  List
     )
 {
     ULONG                           Index;
@@ -2071,9 +2073,9 @@ FdoDumpCmPartialResourceList(
 
 static VOID
 FdoDumpCmFullResourceDescriptor(
-    IN  PXENBUS_FDO                     Fdo,
-    IN  BOOLEAN                         Translated,
-    IN  PCM_FULL_RESOURCE_DESCRIPTOR    Descriptor
+    _In_ PXENBUS_FDO                    Fdo,
+    _In_ BOOLEAN                        Translated,
+    _In_ PCM_FULL_RESOURCE_DESCRIPTOR   Descriptor
     )
 {
     Trace("%s: %s: InterfaceType = %s BusNumber = %d\n",
@@ -2087,9 +2089,9 @@ FdoDumpCmFullResourceDescriptor(
 
 static VOID
 FdoDumpCmResourceList(
-    IN  PXENBUS_FDO         Fdo,
-    IN  BOOLEAN             Translated,
-    IN  PCM_RESOURCE_LIST   List
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ BOOLEAN            Translated,
+    _In_ PCM_RESOURCE_LIST  List
     )
 {
     FdoDumpCmFullResourceDescriptor(Fdo, Translated, &List->List[0]);
@@ -2100,8 +2102,8 @@ _IRQL_saves_
 _IRQL_raises_(HIGH_LEVEL)
 KIRQL
 FdoAcquireInterruptLock(
-    IN  PXENBUS_FDO         Fdo,
-    IN  PXENBUS_INTERRUPT   Interrupt
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ PXENBUS_INTERRUPT  Interrupt
     )
 {
     UNREFERENCED_PARAMETER(Fdo);
@@ -2112,9 +2114,9 @@ FdoAcquireInterruptLock(
 _IRQL_requires_(HIGH_LEVEL)
 VOID
 FdoReleaseInterruptLock(
-    IN  PXENBUS_FDO                 Fdo,
-    IN  PXENBUS_INTERRUPT           Interrupt,
-    IN  __drv_restoresIRQL KIRQL    Irql
+    _In_ PXENBUS_FDO                Fdo,
+    _In_ PXENBUS_INTERRUPT          Interrupt,
+    _In_ _IRQL_restores_ KIRQL      Irql
     )
 {
     UNREFERENCED_PARAMETER(Fdo);
@@ -2124,11 +2126,11 @@ FdoReleaseInterruptLock(
 
 static
 _Function_class_(KSERVICE_ROUTINE)
-__drv_requiresIRQL(HIGH_LEVEL)
+_IRQL_requires_(HIGH_LEVEL)
 BOOLEAN
 FdoInterruptCallback(
-    IN  PKINTERRUPT             InterruptObject,
-    IN  PVOID                   Context
+    _In_ PKINTERRUPT            InterruptObject,
+    _In_ PVOID                  Context
     )
 {
     PXENBUS_INTERRUPT           Interrupt = Context;
@@ -2148,16 +2150,16 @@ FdoInterruptCallback(
 
 static NTSTATUS
 FdoConnectInterrupt(
-    IN  PXENBUS_FDO                     Fdo,
-    IN  PCM_PARTIAL_RESOURCE_DESCRIPTOR Raw,
-    IN  PCM_PARTIAL_RESOURCE_DESCRIPTOR Translated,
-    OUT PXENBUS_INTERRUPT               *Interrupt
+    _In_ PXENBUS_FDO                        Fdo,
+    _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR    Raw,
+    _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR    Translated,
+    _Out_ PXENBUS_INTERRUPT                 *Interrupt
     )
 {
-    IO_CONNECT_INTERRUPT_PARAMETERS     Connect;
-    BOOLEAN                             Found;
-    ULONG                               Number;
-    NTSTATUS                            status;
+    IO_CONNECT_INTERRUPT_PARAMETERS         Connect;
+    BOOLEAN                                 Found;
+    ULONG                                   Number;
+    NTSTATUS                                status;
 
     Trace("====>\n");
 
@@ -2246,8 +2248,8 @@ fail1:
 
 static VOID
 FdoDisconnectInterrupt(
-    IN  PXENBUS_FDO                     Fdo,
-    IN  PXENBUS_INTERRUPT               Interrupt
+    _In_ PXENBUS_FDO                    Fdo,
+    _In_ PXENBUS_INTERRUPT              Interrupt
     )
 {
     IO_DISCONNECT_INTERRUPT_PARAMETERS  Disconnect;
@@ -2286,7 +2288,7 @@ FdoDisconnectInterrupt(
 
 static NTSTATUS
 FdoCreateInterrupt(
-    IN  PXENBUS_FDO     Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     ULONG               Index;
@@ -2334,12 +2336,12 @@ fail1:
 
 PXENBUS_INTERRUPT
 FdoAllocateInterrupt(
-    IN  PXENBUS_FDO         Fdo,
-    IN  KINTERRUPT_MODE     InterruptMode,
-    IN  USHORT              Group,
-    IN  UCHAR               Number,
-    IN  KSERVICE_ROUTINE    Callback,
-    IN  PVOID               Argument OPTIONAL
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ KINTERRUPT_MODE    InterruptMode,
+    _In_ USHORT             Group,
+    _In_ UCHAR              Number,
+    _In_ KSERVICE_ROUTINE   Callback,
+    _In_opt_ PVOID          Argument
     )
 {
     PLIST_ENTRY             ListEntry;
@@ -2374,8 +2376,8 @@ fail1:
 
 UCHAR
 FdoGetInterruptVector(
-    IN  PXENBUS_FDO         Fdo,
-    IN  PXENBUS_INTERRUPT   Interrupt
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ PXENBUS_INTERRUPT  Interrupt
     )
 {
     UNREFERENCED_PARAMETER(Fdo);
@@ -2385,8 +2387,8 @@ FdoGetInterruptVector(
 
 ULONG
 FdoGetInterruptLine(
-    IN  PXENBUS_FDO         Fdo,
-    IN  PXENBUS_INTERRUPT   Interrupt
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ PXENBUS_INTERRUPT  Interrupt
     )
 {
     UNREFERENCED_PARAMETER(Fdo);
@@ -2396,8 +2398,8 @@ FdoGetInterruptLine(
 
 VOID
 FdoFreeInterrupt(
-    IN  PXENBUS_FDO         Fdo,
-    IN  PXENBUS_INTERRUPT   Interrupt
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ PXENBUS_INTERRUPT  Interrupt
     )
 {
     KIRQL                   Irql;
@@ -2410,7 +2412,7 @@ FdoFreeInterrupt(
 
 static VOID
 FdoDestroyInterrupt(
-    IN  PXENBUS_FDO     Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     while (!IsListEmpty(&Fdo->InterruptList)) {
@@ -2439,17 +2441,17 @@ FdoDestroyInterrupt(
 
 static FORCEINLINE BOOLEAN
 __FdoMatchDistribution(
-    IN  PXENBUS_FDO Fdo,
-    IN  PCHAR       Buffer
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PCHAR          Buffer
     )
 {
-    PCHAR           Vendor;
-    PCHAR           Product;
-    PCHAR           Context;
-    const CHAR      *Text;
-    BOOLEAN         Match;
-    ULONG           Index;
-    NTSTATUS        status;
+    PCHAR               Vendor;
+    PCHAR               Product;
+    PCHAR               Context;
+    const CHAR          *Text;
+    BOOLEAN             Match;
+    ULONG               Index;
+    NTSTATUS            status;
 
     UNREFERENCED_PARAMETER(Fdo);
 
@@ -2499,13 +2501,13 @@ fail1:
 
 static VOID
 FdoClearDistribution(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    PCHAR           Buffer;
-    PANSI_STRING    Distributions;
-    ULONG           Index;
-    NTSTATUS        status;
+    PCHAR               Buffer;
+    PANSI_STRING        Distributions;
+    ULONG               Index;
+    NTSTATUS            status;
 
     Trace("====>\n");
 
@@ -2562,14 +2564,14 @@ done:
 
 static NTSTATUS
 FdoSetDistribution(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    ULONG           Index;
-    CHAR            Distribution[MAXNAMELEN];
-    CHAR            Vendor[MAXNAMELEN];
-    const CHAR      *Product;
-    NTSTATUS        status;
+    ULONG               Index;
+    CHAR                Distribution[MAXNAMELEN];
+    CHAR                Vendor[MAXNAMELEN];
+    const CHAR          *Product;
+    NTSTATUS            status;
 
     Trace("====>\n");
 
@@ -2660,9 +2662,9 @@ CHAR FdoOutBuffer[FDO_OUT_BUFFER_SIZE];
 
 static VOID
 FdoOutputBuffer(
-    IN  PVOID   Argument,
-    IN  PCHAR   Buffer,
-    IN  ULONG   Length
+    _In_ PVOID  Argument,
+    _In_ PCHAR  Buffer,
+    _In_ ULONG  Length
     )
 {
     PXENBUS_FDO Fdo = Argument;
@@ -2694,7 +2696,7 @@ FdoOutputBuffer(
 
 static FORCEINLINE BOOLEAN
 __FdoVirqPatWatchdog(
-    IN  PXENBUS_VIRQ    Virq
+    _In_ PXENBUS_VIRQ   Virq
     )
 {
     PXENBUS_FDO         Fdo = Virq->Fdo;
@@ -2731,18 +2733,17 @@ out:
     return Pat;
 }
 
-static
-_Function_class_(KSERVICE_ROUTINE)
-_IRQL_requires_(HIGH_LEVEL)
-_IRQL_requires_same_
-BOOLEAN
+static KSERVICE_ROUTINE FdoVirqCallback;
+
+_Use_decl_annotations_
+static BOOLEAN
 FdoVirqCallback(
-    IN  PKINTERRUPT InterruptObject,
-    IN  PVOID       Argument
+    PKINTERRUPT         InterruptObject,
+    PVOID               Argument
     )
 {
-    PXENBUS_VIRQ    Virq = Argument;
-    PXENBUS_FDO     Fdo;
+    PXENBUS_VIRQ        Virq = Argument;
+    PXENBUS_FDO         Fdo;
 
     UNREFERENCED_PARAMETER(InterruptObject);
 
@@ -2771,7 +2772,7 @@ FdoVirqCallback(
 
 static FORCEINLINE VOID
 __FdoVirqDestroy(
-    IN  PXENBUS_VIRQ    Virq
+    _In_ PXENBUS_VIRQ   Virq
     )
 {
     PXENBUS_FDO         Fdo = Virq->Fdo;
@@ -2797,10 +2798,10 @@ __FdoVirqDestroy(
 
 static FORCEINLINE NTSTATUS
 __FdoVirqCreate(
-    IN  PXENBUS_FDO     Fdo,
-    IN  ULONG           Type,
-    IN  ULONG           Cpu,
-    OUT PXENBUS_VIRQ    *Virq
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ ULONG          Type,
+    _In_ ULONG          Cpu,
+    _Out_ PXENBUS_VIRQ  *Virq
     )
 {
     PROCESSOR_NUMBER    ProcNumber;
@@ -2878,7 +2879,7 @@ fail1:
 
 static VOID
 FdoVirqTeardown(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     if (Fdo->Watchdog != 0)
@@ -2904,14 +2905,14 @@ FdoVirqTeardown(
 
 static NTSTATUS
 FdoVirqInitialize(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    PXENBUS_VIRQ    Virq;
-    ULONG           Count;
-    ULONG           Index;
-    ULONG           Timer;
-    NTSTATUS        status;
+    PXENBUS_VIRQ        Virq;
+    ULONG               Count;
+    ULONG               Index;
+    ULONG               Timer;
+    NTSTATUS            status;
 
     InitializeListHead(&Fdo->VirqList);
     InitializeHighLock(&Fdo->VirqLock);
@@ -2959,10 +2960,10 @@ fail1:
 
 static FORCEINLINE NTSTATUS
 __FdoD3ToD0(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     Trace("====>\n");
 
@@ -3071,7 +3072,7 @@ fail1:
 
 static FORCEINLINE VOID
 __FdoD0ToD3(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     Trace("====>\n");
@@ -3121,7 +3122,7 @@ __FdoD0ToD3(
 
 static VOID
 FdoSuspendCallbackLate(
-    IN  PVOID   Argument
+    _In_ PVOID  Argument
     )
 {
     PXENBUS_FDO Fdo = Argument;
@@ -3135,7 +3136,7 @@ FdoSuspendCallbackLate(
 
 static NTSTATUS
 FdoPciHoleCreate(
-    IN  PXENBUS_FDO                 Fdo
+    _In_ PXENBUS_FDO                Fdo
     )
 {
     PXENBUS_PCI_HOLE                Hole = &Fdo->PciHole;
@@ -3216,7 +3217,7 @@ fail1:
 
 static VOID
 FdoPciHoleDestroy(
-    IN  PXENBUS_FDO     Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     PXENBUS_PCI_HOLE    Hole = &Fdo->PciHole;
@@ -3245,8 +3246,8 @@ FdoPciHoleDestroy(
 
 static PMDL
 FdoPciHoleAllocate(
-    IN  PXENBUS_FDO         Fdo,
-    IN  ULONG               Count
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ ULONG              Count
     )
 {
     PXENBUS_PCI_HOLE        Hole = &Fdo->PciHole;
@@ -3309,8 +3310,8 @@ fail1:
 
 static VOID
 FdoPciHoleFree(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PMDL            Mdl
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PMDL           Mdl
     )
 {
     PXENBUS_PCI_HOLE    Hole = &Fdo->PciHole;
@@ -3350,8 +3351,8 @@ FdoPciHoleFree(
 
 static PMDL
 FdoMemoryHoleAllocate(
-    IN  PXENBUS_FDO     Fdo,
-    IN  ULONG           Count
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ ULONG          Count
     )
 {
     PMDL                Mdl;
@@ -3387,8 +3388,8 @@ fail1:
 
 static VOID
 FdoMemoryHoleFree(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PMDL            Mdl
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PMDL           Mdl
     )
 {
     ULONG               Count;
@@ -3407,8 +3408,8 @@ FdoMemoryHoleFree(
 
 PMDL
 FdoHoleAllocate(
-    IN  PXENBUS_FDO Fdo,
-    IN  ULONG       Count
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ ULONG      Count
     )
 {
     return (Fdo->UseMemoryHole != 0) ?
@@ -3418,8 +3419,8 @@ FdoHoleAllocate(
 
 VOID
 FdoHoleFree(
-    IN  PXENBUS_FDO Fdo,
-    IN  PMDL        Mdl
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PMDL       Mdl
     )
 {
     if (Fdo->UseMemoryHole != 0)
@@ -3431,11 +3432,11 @@ FdoHoleFree(
 
 static VOID
 FdoDebugCallback(
-    IN  PVOID   Argument,
-    IN  BOOLEAN Crashing
+    _In_ PVOID      Argument,
+    _In_ BOOLEAN    Crashing
     )
 {
-    PXENBUS_FDO Fdo = Argument;
+    PXENBUS_FDO     Fdo = Argument;
 
     UNREFERENCED_PARAMETER(Crashing);
 
@@ -3472,7 +3473,7 @@ FdoDebugCallback(
 // This function must not touch pageable code or data
 static NTSTATUS
 FdoD3ToD0(
-    IN  PXENBUS_FDO             Fdo
+    _In_ PXENBUS_FDO            Fdo
     )
 {
     POWER_STATE                 PowerState;
@@ -3643,12 +3644,12 @@ fail1:
 // This function must not touch pageable code or data
 static VOID
 FdoD0ToD3(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    POWER_STATE     PowerState;
-    PLIST_ENTRY     ListEntry;
-    KIRQL           Irql;
+    POWER_STATE         PowerState;
+    PLIST_ENTRY         ListEntry;
+    KIRQL               Irql;
 
     ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
     ASSERT3U(__FdoGetDevicePowerState(Fdo), ==, PowerDeviceD0);
@@ -3756,10 +3757,10 @@ not_active:
 // This function must not touch pageable code or data
 static VOID
 FdoS4ToS3(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    KIRQL           Irql;
+    KIRQL               Irql;
 
     Trace("====>\n");
 
@@ -3788,7 +3789,7 @@ not_active:
 // This function must not touch pageable code or data
 static VOID
 FdoS3ToS4(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     Trace("====>\n");
@@ -3815,8 +3816,8 @@ not_active:
 
 static VOID
 FdoFilterCmPartialResourceList(
-    IN  PXENBUS_FDO                 Fdo,
-    IN  PCM_PARTIAL_RESOURCE_LIST   List
+    _In_ PXENBUS_FDO                Fdo,
+    _In_ PCM_PARTIAL_RESOURCE_LIST  List
     )
 {
     ULONG                           Index;
@@ -3841,11 +3842,11 @@ FdoFilterCmPartialResourceList(
 #define BALLOON_WARN_TIMEOUT        10
 #define BALLOON_BUGCHECK_TIMEOUT    1200
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static NTSTATUS
 FdoStartDevice(
-    IN  PXENBUS_FDO                 Fdo,
-    IN  PIRP                        Irp
+    _In_ PXENBUS_FDO                Fdo,
+    _In_ PIRP                       Irp
     )
 {
     PIO_STACK_LOCATION              StackLocation;
@@ -3995,7 +3996,7 @@ fail8:
 
     if (!__FdoIsActive(Fdo))
         goto fail4;
-    
+
     if (Fdo->BalloonInterface.Interface.Context != NULL) {
         ThreadAlert(Fdo->BalloonThread);
         ThreadJoin(Fdo->BalloonThread);
@@ -4056,8 +4057,8 @@ fail1:
 
 static NTSTATUS
 FdoQueryStopDevice(
-    IN  PXENBUS_FDO Fdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP       Irp
     )
 {
     NTSTATUS        status;
@@ -4087,11 +4088,11 @@ fail1:
 
 static NTSTATUS
 FdoCancelStopDevice(
-    IN  PXENBUS_FDO Fdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     Irp->IoStatus.Status = STATUS_SUCCESS;
 
@@ -4105,11 +4106,11 @@ FdoCancelStopDevice(
 
 static NTSTATUS
 FdoStopDevice(
-    IN  PXENBUS_FDO Fdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     if (__FdoGetDevicePowerState(Fdo) == PowerDeviceD0)
         FdoD0ToD3(Fdo);
@@ -4159,11 +4160,11 @@ not_active:
 
 static NTSTATUS
 FdoQueryRemoveDevice(
-    IN  PXENBUS_FDO Fdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     status = STATUS_UNSUCCESSFUL;
     if (Fdo->BalloonInterface.Interface.Context != NULL &&
@@ -4190,11 +4191,11 @@ fail1:
 
 static NTSTATUS
 FdoCancelRemoveDevice(
-    IN  PXENBUS_FDO Fdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     __FdoRestoreDevicePnpState(Fdo, RemovePending);
 
@@ -4208,12 +4209,12 @@ FdoCancelRemoveDevice(
 
 static NTSTATUS
 FdoSurpriseRemoval(
-    IN  PXENBUS_FDO Fdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
-    PLIST_ENTRY     ListEntry;
-    NTSTATUS        status;
+    PLIST_ENTRY         ListEntry;
+    NTSTATUS            status;
 
     __FdoSetDevicePnpState(Fdo, SurpriseRemovePending);
 
@@ -4241,11 +4242,11 @@ FdoSurpriseRemoval(
     return status;
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static NTSTATUS
 FdoRemoveDevice(
-    IN  PXENBUS_FDO                     Fdo,
-    IN  PIRP                            Irp
+    _In_ PXENBUS_FDO                    Fdo,
+    _In_ PIRP                           Irp
     )
 {
     PLIST_ENTRY                         ListEntry;
@@ -4359,11 +4360,11 @@ done:
 
 #define SCAN_PAUSE  10
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static NTSTATUS
 FdoQueryDeviceRelations(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -4500,8 +4501,8 @@ fail1:
 
 static NTSTATUS
 FdoQueryCapabilities(
-    IN  PXENBUS_FDO         Fdo,
-    IN  PIRP                Irp
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ PIRP               Irp
     )
 {
     PIO_STACK_LOCATION      StackLocation;
@@ -4542,8 +4543,8 @@ fail1:
 
 static NTSTATUS
 FdoDeviceUsageNotification(
-    IN  PXENBUS_FDO                 Fdo,
-    IN  PIRP                        Irp
+    _In_ PXENBUS_FDO                Fdo,
+    _In_ PIRP                       Irp
     )
 {
     PIO_STACK_LOCATION              StackLocation;
@@ -4574,7 +4575,7 @@ FdoDeviceUsageNotification(
     if (!NT_SUCCESS(status))
         goto fail1;
 
-    NotDisableable = FALSE;    
+    NotDisableable = FALSE;
     for (Type = 0; Type <= DeviceUsageTypeDumpFile; Type++) {
         if (Fdo->Usage[Type] != 0) {
             NotDisableable = TRUE;
@@ -4586,7 +4587,7 @@ FdoDeviceUsageNotification(
 
     if (Fdo->NotDisableable != NotDisableable) {
         Fdo->NotDisableable = NotDisableable;
-    
+
         IoInvalidateDeviceState(__FdoGetPhysicalDeviceObject(Fdo));
     }
 
@@ -4602,8 +4603,8 @@ fail1:
 
 static NTSTATUS
 FdoQueryPnpDeviceState(
-    IN  PXENBUS_FDO                 Fdo,
-    IN  PIRP                        Irp
+    _In_ PXENBUS_FDO                Fdo,
+    _In_ PIRP                       Irp
     )
 {
     ULONG_PTR                       State;
@@ -4633,8 +4634,8 @@ done:
 
 static NTSTATUS
 FdoDispatchPnp(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -4645,8 +4646,8 @@ FdoDispatchPnp(
     MinorFunction = StackLocation->MinorFunction;
 
     Trace("====> (%02x:%s)\n",
-          MinorFunction, 
-          PnpMinorFunctionName(MinorFunction)); 
+          MinorFunction,
+          PnpMinorFunctionName(MinorFunction));
 
     switch (StackLocation->MinorFunction) {
     case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
@@ -4708,19 +4709,20 @@ FdoDispatchPnp(
     }
 
     Trace("<==== (%02x:%s)(%08x)\n",
-          MinorFunction, 
+          MinorFunction,
           PnpMinorFunctionName(MinorFunction),
-          status); 
+          status);
 
     return status;
 }
 
-__drv_functionClass(IO_WORKITEM_ROUTINE)
-__drv_sameIRQL
+static IO_WORKITEM_ROUTINE FdoSetDevcePowerUpWorker;
+
+_Use_decl_annotations_
 static VOID
 FdoSetDevcePowerUpWorker(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PVOID           Context
+    _In_ PDEVICE_OBJECT DeviceObject,
+    _In_opt_ PVOID      Context
     )
 {
     PXENBUS_FDO         Fdo = (PXENBUS_FDO) Context;
@@ -4737,13 +4739,14 @@ FdoSetDevcePowerUpWorker(
     IoCompleteRequest(Irp, IO_NO_INCREMENT);
 }
 
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
+static IO_COMPLETION_ROUTINE FdoSetDevicePowerUpComplete;
+
+_Use_decl_annotations_
 static NTSTATUS
 FdoSetDevicePowerUpComplete(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp,
+    PVOID               Context
     )
 {
     PXENBUS_FDO         Fdo = (PXENBUS_FDO) Context;
@@ -4773,8 +4776,8 @@ FdoSetDevicePowerUpComplete(
 
 static NTSTATUS
 FdoSetDevicePowerUp(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     IoMarkIrpPending(Irp);
@@ -4789,12 +4792,13 @@ FdoSetDevicePowerUp(
     return STATUS_PENDING;
 }
 
-__drv_functionClass(IO_WORKITEM_ROUTINE)
-__drv_sameIRQL
+static IO_WORKITEM_ROUTINE FdoSetDevicePowerDownWorker;
+
+_Use_decl_annotations_
 static VOID
 FdoSetDevicePowerDownWorker(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PVOID           Context
+    _In_ PDEVICE_OBJECT DeviceObject,
+    _In_opt_ PVOID      Context
     )
 {
     PXENBUS_FDO         Fdo = (PXENBUS_FDO)Context;
@@ -4813,8 +4817,8 @@ FdoSetDevicePowerDownWorker(
 
 static NTSTATUS
 FdoSetDevicePowerDown(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -4856,8 +4860,8 @@ done:
 
 static NTSTATUS
 FdoSetDevicePower(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -4870,7 +4874,7 @@ FdoSetDevicePower(
     PowerAction = StackLocation->Parameters.Power.ShutdownType;
 
     Trace("====> (%s:%s)\n",
-          DevicePowerStateName(DeviceState), 
+          DevicePowerStateName(DeviceState),
           PowerActionName(PowerAction));
 
     if (DeviceState == __FdoGetDevicePowerState(Fdo)) {
@@ -4886,21 +4890,22 @@ FdoSetDevicePower(
 
 done:
     Trace("<==== (%s:%s)(%08x)\n",
-          DevicePowerStateName(DeviceState), 
+          DevicePowerStateName(DeviceState),
           PowerActionName(PowerAction),
           status);
     return status;
 }
 
-__drv_functionClass(REQUEST_POWER_COMPLETE)
-__drv_sameIRQL
+static REQUEST_POWER_COMPLETE FdoRequestDevicePowerUpComplete;
+
+_Use_decl_annotations_
 static VOID
 FdoRequestDevicePowerUpComplete(
-    IN  PDEVICE_OBJECT      DeviceObject,
-    IN  UCHAR               MinorFunction,
-    IN  POWER_STATE         PowerState,
-    IN  PVOID               Context,
-    IN  PIO_STATUS_BLOCK    IoStatus
+    _In_ PDEVICE_OBJECT     DeviceObject,
+    _In_ UCHAR              MinorFunction,
+    _In_ POWER_STATE        PowerState,
+    _In_opt_ PVOID          Context,
+    _In_ PIO_STATUS_BLOCK   IoStatus
     )
 {
     PIRP                    Irp = (PIRP) Context;
@@ -4913,12 +4918,13 @@ FdoRequestDevicePowerUpComplete(
     IoCompleteRequest(Irp, IO_NO_INCREMENT);
 }
 
-__drv_functionClass(IO_WORKITEM_ROUTINE)
-__drv_sameIRQL
+static IO_WORKITEM_ROUTINE FdoSetSystemPowerUpWorker;
+
+_Use_decl_annotations_
 static VOID
 FdoSetSystemPowerUpWorker(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PVOID           Context
+    _In_ PDEVICE_OBJECT DeviceObject,
+    _In_opt_ PVOID      Context
     )
 {
     PXENBUS_FDO         Fdo = (PXENBUS_FDO)Context;
@@ -4964,13 +4970,14 @@ fail1:
     IoCompleteRequest(Irp, IO_NO_INCREMENT);
 }
 
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
+static IO_COMPLETION_ROUTINE FdoSetSystemPowerUpComplete;
+
+_Use_decl_annotations_
 static NTSTATUS
 FdoSetSystemPowerUpComplete(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp,
+    PVOID               Context
     )
 {
     PXENBUS_FDO         Fdo = (PXENBUS_FDO) Context;
@@ -5024,8 +5031,8 @@ fail1:
 
 static NTSTATUS
 FdoSetSystemPowerUp(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     IoCopyCurrentIrpStackLocationToNext(Irp);
@@ -5038,12 +5045,13 @@ FdoSetSystemPowerUp(
     return IoCallDriver(Fdo->LowerDeviceObject, Irp);
 }
 
-__drv_functionClass(IO_WORKITEM_ROUTINE)
-__drv_sameIRQL
+static IO_WORKITEM_ROUTINE FdoSetSystemPowerDownWorker;
+
+_Use_decl_annotations_
 static VOID
 FdoSetSystemPowerDownWorker(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PVOID           Context
+    _In_ PDEVICE_OBJECT DeviceObject,
+    _In_opt_ PVOID      Context
     )
 {
     PXENBUS_FDO         Fdo = (PXENBUS_FDO)Context;
@@ -5067,15 +5075,16 @@ FdoSetSystemPowerDownWorker(
     IoCallDriver(Fdo->LowerDeviceObject, Irp);
 }
 
-__drv_functionClass(REQUEST_POWER_COMPLETE)
-__drv_sameIRQL
+static REQUEST_POWER_COMPLETE FdoRequestDevicePowerDownComplete;
+
+_Use_decl_annotations_
 static VOID
 FdoRequestDevicePowerDownComplete(
-    IN  PDEVICE_OBJECT      DeviceObject,
-    IN  UCHAR               MinorFunction,
-    IN  POWER_STATE         PowerState,
-    IN  PVOID               Context,
-    IN  PIO_STATUS_BLOCK    IoStatus
+    _In_ PDEVICE_OBJECT     DeviceObject,
+    _In_ UCHAR              MinorFunction,
+    _In_ POWER_STATE        PowerState,
+    _In_opt_ PVOID          Context,
+    _In_ PIO_STATUS_BLOCK   IoStatus
     )
 {
     PIRP                    Irp = (PIRP) Context;
@@ -5124,8 +5133,8 @@ fail1:
 
 static NTSTATUS
 FdoSetSystemPowerDown(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -5166,8 +5175,8 @@ fail1:
 
 static NTSTATUS
 FdoSetSystemPower(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -5205,15 +5214,16 @@ done:
     return status;
 }
 
-__drv_functionClass(REQUEST_POWER_COMPLETE)
-__drv_sameIRQL
+static REQUEST_POWER_COMPLETE FdoRequestQuerySystemPowerUpComplete;
+
+_Use_decl_annotations_
 static VOID
 FdoRequestQuerySystemPowerUpComplete(
-    IN  PDEVICE_OBJECT      DeviceObject,
-    IN  UCHAR               MinorFunction,
-    IN  POWER_STATE         PowerState,
-    IN  PVOID               Context,
-    IN  PIO_STATUS_BLOCK    IoStatus
+    _In_ PDEVICE_OBJECT     DeviceObject,
+    _In_ UCHAR              MinorFunction,
+    _In_ POWER_STATE        PowerState,
+    _In_opt_ PVOID          Context,
+    _In_ PIO_STATUS_BLOCK   IoStatus
     )
 {
     PIRP                    Irp = (PIRP) Context;
@@ -5227,13 +5237,14 @@ FdoRequestQuerySystemPowerUpComplete(
     IoCompleteRequest(Irp, IO_NO_INCREMENT);
 }
 
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
+static IO_COMPLETION_ROUTINE FdoQuerySystemPowerUpComplete;
+
+_Use_decl_annotations_
 static NTSTATUS
 FdoQuerySystemPowerUpComplete(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp,
+    PVOID               Context
     )
 {
     PXENBUS_FDO         Fdo = (PXENBUS_FDO) Context;
@@ -5268,8 +5279,8 @@ fail1:
 
 static NTSTATUS
 FdoQuerySystemPowerUp(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     IoMarkIrpPending(Irp);
@@ -5283,15 +5294,16 @@ FdoQuerySystemPowerUp(
     return IoCallDriver(Fdo->LowerDeviceObject, Irp);
 }
 
-__drv_functionClass(REQUEST_POWER_COMPLETE)
-__drv_sameIRQL
+static REQUEST_POWER_COMPLETE FdoRequestQuerySystemPowerDownComplete;
+
+_Use_decl_annotations_
 static VOID
 FdoRequestQuerySystemPowerDownComplete(
-    IN  PDEVICE_OBJECT      DeviceObject,
-    IN  UCHAR               MinorFunction,
-    IN  POWER_STATE         PowerState,
-    IN  PVOID               Context,
-    IN  PIO_STATUS_BLOCK    IoStatus
+    _In_ PDEVICE_OBJECT     DeviceObject,
+    _In_ UCHAR              MinorFunction,
+    _In_ POWER_STATE        PowerState,
+    _In_opt_ PVOID          Context,
+    _In_ PIO_STATUS_BLOCK   IoStatus
     )
 {
     PIRP                    Irp = (PIRP) Context;
@@ -5320,8 +5332,8 @@ fail1:
 
 static NTSTATUS
 FdoQuerySystemPowerDown(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -5359,8 +5371,8 @@ fail1:
 
 static NTSTATUS
 FdoQuerySystemPower(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -5373,7 +5385,7 @@ FdoQuerySystemPower(
     PowerAction = StackLocation->Parameters.Power.ShutdownType;
 
     Trace("====> (%s:%s)\n",
-          SystemPowerStateName(SystemState), 
+          SystemPowerStateName(SystemState),
           PowerActionName(PowerAction));
 
     if (SystemState == __FdoGetSystemPowerState(Fdo)) {
@@ -5389,7 +5401,7 @@ FdoQuerySystemPower(
 
 done:
     Trace("<==== (%s:%s)(%08x)\n",
-          SystemPowerStateName(SystemState), 
+          SystemPowerStateName(SystemState),
           PowerActionName(PowerAction),
           status);
 
@@ -5398,8 +5410,8 @@ done:
 
 static NTSTATUS
 FdoDispatchDevicePower(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -5423,8 +5435,8 @@ FdoDispatchDevicePower(
 
 static NTSTATUS
 FdoDispatchSystemPower(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -5452,8 +5464,8 @@ FdoDispatchSystemPower(
 
 static NTSTATUS
 FdoDispatchPower(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -5486,11 +5498,11 @@ FdoDispatchPower(
 
 static NTSTATUS
 FdoDispatchDefault(
-    IN  PXENBUS_FDO Fdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     IoSkipCurrentIrpStackLocation(Irp);
     status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
@@ -5500,8 +5512,8 @@ FdoDispatchDefault(
 
 NTSTATUS
 FdoDispatch(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -5526,15 +5538,15 @@ FdoDispatch(
     return status;
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static NTSTATUS
 FdoQueryInterface(
-    IN  PXENBUS_FDO     Fdo,
-    IN  const GUID      *Guid,
-    IN  ULONG           Version,
-    OUT PINTERFACE      Interface,
-    IN  ULONG           Size,
-    IN  BOOLEAN         Optional
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ const GUID     *Guid,
+    _In_ ULONG          Version,
+    _Out_ PINTERFACE    Interface,
+    _In_ ULONG          Size,
+    _In_ BOOLEAN        Optional
     )
 {
     KEVENT              Event;
@@ -5567,7 +5579,7 @@ FdoQueryInterface(
     StackLocation->Parameters.QueryInterface.Size = (USHORT)Size;
     StackLocation->Parameters.QueryInterface.Version = (USHORT)Version;
     StackLocation->Parameters.QueryInterface.Interface = Interface;
-    
+
     Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
 
     status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
@@ -5615,14 +5627,14 @@ fail1:
 
 static NTSTATUS
 FdoBalloonInitialize(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    CHAR            Key[] = "XEN:BALLOON=";
-    PANSI_STRING    Option;
-    PCHAR           Value;
-    BOOLEAN         Enabled;
-    NTSTATUS        status;
+    CHAR                Key[] = "XEN:BALLOON=";
+    PANSI_STRING        Option;
+    PCHAR               Value;
+    BOOLEAN             Enabled;
+    NTSTATUS            status;
 
     Enabled = TRUE;
 
@@ -5647,7 +5659,7 @@ done:
 
 static VOID
 FdoBalloonTeardown(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
     if (Fdo->BalloonContext == NULL)
@@ -5659,13 +5671,13 @@ FdoBalloonTeardown(
 
 static VOID
 FdoSetWatchdog(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    CHAR            Key[] = "XEN:WATCHDOG=";
-    PANSI_STRING    Option;
-    ULONG           Value;
-    NTSTATUS        status;
+    CHAR                Key[] = "XEN:WATCHDOG=";
+    PANSI_STRING        Option;
+    ULONG               Value;
+    NTSTATUS            status;
 
     status = ConfigQuerySystemStartOption(Key, &Option);
     if (!NT_SUCCESS(status))
@@ -5690,7 +5702,7 @@ FdoSetWatchdog(
 
 NTSTATUS
 FdoCreate(
-    IN  PDEVICE_OBJECT          PhysicalDeviceObject
+    _In_ PDEVICE_OBJECT         PhysicalDeviceObject
     )
 {
     PDEVICE_OBJECT              FunctionDeviceObject;
@@ -6009,11 +6021,11 @@ fail1:
 
 VOID
 FdoDestroy(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     )
 {
-    PXENBUS_DX      Dx = Fdo->Dx;
-    PDEVICE_OBJECT  FunctionDeviceObject = Dx->DeviceObject;
+    PXENBUS_DX          Dx = Fdo->Dx;
+    PDEVICE_OBJECT      FunctionDeviceObject = Dx->DeviceObject;
 
     ASSERT(IsListEmpty(&Fdo->List));
     ASSERT3U(Fdo->References, ==, 0);
diff --git a/src/xenbus/fdo.h b/src/xenbus/fdo.h
index f2ec88c..ae4b86d 100644
--- a/src/xenbus/fdo.h
+++ b/src/xenbus/fdo.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -42,106 +42,106 @@ typedef struct _XENBUS_INTERRUPT XENBUS_INTERRUPT, *PXENBUS_INTERRUPT;
 
 extern NTSTATUS
 FdoCreate(
-    IN  PDEVICE_OBJECT  PhysicalDeviceObject
+    _In_ PDEVICE_OBJECT PhysicalDeviceObject
     );
 
 extern VOID
 FdoDestroy(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 extern NTSTATUS
 FdoDelegateIrp(
-    IN  PXENBUS_FDO Fdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     );
 
 extern VOID
 FdoAddPhysicalDeviceObject(
-    IN  PXENBUS_FDO Fdo,
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PXENBUS_PDO    Pdo
     );
 
 extern VOID
 FdoRemovePhysicalDeviceObject(
-    IN  PXENBUS_FDO Fdo,
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PXENBUS_PDO    Pdo
     );
 
 extern VOID
 FdoAcquireMutex(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 extern VOID
 FdoReleaseMutex(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 extern PDEVICE_OBJECT
 FdoGetDeviceObject(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 extern PDEVICE_OBJECT
 FdoGetPhysicalDeviceObject(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 extern PDMA_ADAPTER
 FdoGetDmaAdapter(
-    IN  PXENBUS_FDO         Fdo,
-    IN  PDEVICE_DESCRIPTION DeviceDescriptor,
-    OUT PULONG              NumberOfMapRegisters
+    _In_ PXENBUS_FDO            Fdo,
+    _In_ PDEVICE_DESCRIPTION    DeviceDescriptor,
+    _Out_ PULONG                NumberOfMapRegisters
     );
 
 extern BOOLEAN
 FdoTranslateBusAddress(
-    IN      PXENBUS_FDO         Fdo,
-    IN      PHYSICAL_ADDRESS    BusAddress,
-    IN      ULONG               Length,
-    IN OUT  PULONG              AddressSpace,
-    OUT     PPHYSICAL_ADDRESS   TranslatedAddress
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ PHYSICAL_ADDRESS   BusAddress,
+    _In_ ULONG              Length,
+    _Inout_ PULONG          AddressSpace,
+    _Out_ PPHYSICAL_ADDRESS TranslatedAddress
     );
 
 extern ULONG
 FdoSetBusData(
-    IN  PXENBUS_FDO     Fdo,
-    IN  ULONG           DataType,
-    IN  PVOID           Buffer,
-    IN  ULONG           Offset,
-    IN  ULONG           Length
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ ULONG          DataType,
+    _In_ PVOID          Buffer,
+    _In_ ULONG          Offset,
+    _In_ ULONG          Length
     );
 
 extern ULONG
 FdoGetBusData(
-    IN  PXENBUS_FDO     Fdo,
-    IN  ULONG           DataType,
-    IN  PVOID           Buffer,
-    IN  ULONG           Offset,
-    IN  ULONG           Length
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ ULONG          DataType,
+    _In_ PVOID          Buffer,
+    _In_ ULONG          Offset,
+    _In_ ULONG          Length
     );
 
 extern PCHAR
 FdoGetVendorName(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 extern PCHAR
 FdoGetName(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 extern PMDL
 FdoHoleAllocate(
-    IN  PXENBUS_FDO Fdo,
-    IN  ULONG       Count
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ ULONG          Count
     );
 
 extern VOID
 FdoHoleFree(
-    IN  PXENBUS_FDO Fdo,
-    IN  PMDL        Mdl
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PMDL           Mdl
     );
 
 // Disable erroneous SAL warnings around use of interrupt locks
@@ -154,121 +154,121 @@ _IRQL_saves_
 _IRQL_raises_(HIGH_LEVEL)
 KIRQL
 FdoAcquireInterruptLock(
-    IN  PXENBUS_FDO         Fdo,
-    IN  PXENBUS_INTERRUPT   Interrupt
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ PXENBUS_INTERRUPT  Interrupt
     );
 
 extern
 _IRQL_requires_(HIGH_LEVEL)
 VOID
 FdoReleaseInterruptLock(
-    IN  PXENBUS_FDO                 Fdo,
-    IN  PXENBUS_INTERRUPT           Interrupt,
-    IN  __drv_restoresIRQL KIRQL    Irql
+    _In_ PXENBUS_FDO            Fdo,
+    _In_ PXENBUS_INTERRUPT      Interrupt,
+    _In_ _IRQL_restores_ KIRQL  Irql
     );
 
 extern PXENBUS_INTERRUPT
 FdoAllocateInterrupt(
-    IN  PXENBUS_FDO         Fdo,
-    IN  KINTERRUPT_MODE     InterruptMode,
-    IN  USHORT              Group,
-    IN  UCHAR               Number,
-    IN  KSERVICE_ROUTINE    Callback,
-    IN  PVOID               Argument OPTIONAL
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ KINTERRUPT_MODE    InterruptMode,
+    _In_ USHORT             Group,
+    _In_ UCHAR              Number,
+    _In_ KSERVICE_ROUTINE   Callback,
+    _In_opt_ PVOID          Argument
     );
 
 extern UCHAR
 FdoGetInterruptVector(
-    IN  PXENBUS_FDO         Fdo,
-    IN  PXENBUS_INTERRUPT   Interrupt
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ PXENBUS_INTERRUPT  Interrupt
     );
 
 extern ULONG
 FdoGetInterruptLine(
-    IN  PXENBUS_FDO         Fdo,
-    IN  PXENBUS_INTERRUPT   Interrupt
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ PXENBUS_INTERRUPT  Interrupt
     );
 
 extern VOID
 FdoFreeInterrupt(
-    IN  PXENBUS_FDO         Fdo,
-    IN  PXENBUS_INTERRUPT   Interrupt
+    _In_ PXENBUS_FDO        Fdo,
+    _In_ PXENBUS_INTERRUPT  Interrupt
     );
 
 #include "suspend.h"
 
 extern PXENBUS_SUSPEND_CONTEXT
 FdoGetSuspendContext(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 #include "shared_info.h"
 
 extern PXENBUS_SHARED_INFO_CONTEXT
 FdoGetSharedInfoContext(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 #include "evtchn.h"
 
 extern PXENBUS_EVTCHN_CONTEXT
 FdoGetEvtchnContext(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 #include "debug.h"
 
 extern PXENBUS_DEBUG_CONTEXT
 FdoGetDebugContext(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 #include "store.h"
 
 extern PXENBUS_STORE_CONTEXT
 FdoGetStoreContext(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 #include "range_set.h"
 
 extern PXENBUS_RANGE_SET_CONTEXT
 FdoGetRangeSetContext(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 #include "cache.h"
 
 extern PXENBUS_CACHE_CONTEXT
 FdoGetCacheContext(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 #include "gnttab.h"
 
 extern PXENBUS_GNTTAB_CONTEXT
 FdoGetGnttabContext(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 #include "unplug.h"
 
 extern PXENBUS_UNPLUG_CONTEXT
 FdoGetUnplugContext(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 #include "console.h"
 
 extern PXENBUS_CONSOLE_CONTEXT
 FdoGetConsoleContext(
-    IN  PXENBUS_FDO Fdo
+    _In_ PXENBUS_FDO    Fdo
     );
 
 extern NTSTATUS
 FdoDispatch(
-    IN  PXENBUS_FDO Fdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PIRP           Irp
     );
 
 #endif  // _XENBUS_FDO_H
diff --git a/src/xenbus/gnttab.c b/src/xenbus/gnttab.c
index 57c36df..550b8e0 100644
--- a/src/xenbus/gnttab.c
+++ b/src/xenbus/gnttab.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -101,7 +101,7 @@ struct _XENBUS_GNTTAB_CONTEXT {
 
 static FORCEINLINE PVOID
 __GnttabAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_GNTTAB_TAG);
@@ -109,7 +109,7 @@ __GnttabAllocate(
 
 static FORCEINLINE VOID
 __GnttabFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_GNTTAB_TAG);
@@ -117,7 +117,7 @@ __GnttabFree(
 
 static NTSTATUS
 GnttabExpand(
-    IN  PXENBUS_GNTTAB_CONTEXT  Context
+    _In_ PXENBUS_GNTTAB_CONTEXT Context
     )
 {
     ULONG                       Index;
@@ -200,7 +200,7 @@ fail1:
 
 static VOID
 GnttabMap(
-    IN  PXENBUS_GNTTAB_CONTEXT  Context
+    _In_ PXENBUS_GNTTAB_CONTEXT Context
     )
 {
     LONG                        Index;
@@ -228,7 +228,7 @@ GnttabMap(
 
 static VOID
 GnttabUnmap(
-    IN  PXENBUS_GNTTAB_CONTEXT  Context
+    _In_ PXENBUS_GNTTAB_CONTEXT Context
     )
 {
     LONG                        Index;
@@ -249,7 +249,7 @@ GnttabUnmap(
 
 static VOID
 GnttabContract(
-    IN  PXENBUS_GNTTAB_CONTEXT  Context
+    _In_ PXENBUS_GNTTAB_CONTEXT Context
     )
 {
     LONG                        Index;
@@ -290,8 +290,8 @@ GnttabContract(
 
 static NTSTATUS
 GnttabEntryCtor(
-    IN  PVOID               Argument,
-    IN  PVOID               Object
+    _In_ PVOID              Argument,
+    _In_ PVOID              Object
     )
 {
     PXENBUS_GNTTAB_CACHE    Cache = Argument;
@@ -327,8 +327,8 @@ fail1:
 
 static VOID
 GnttabEntryDtor(
-    IN  PVOID               Argument,
-    IN  PVOID               Object
+    _In_ PVOID              Argument,
+    _In_ PVOID              Object
     )
 {
     PXENBUS_GNTTAB_CACHE    Cache = Argument;
@@ -346,7 +346,7 @@ GnttabEntryDtor(
 
 static VOID
 GnttabAcquireLock(
-    IN  PVOID               Argument
+    _In_ PVOID              Argument
     )
 {
     PXENBUS_GNTTAB_CACHE    Cache = Argument;
@@ -356,7 +356,7 @@ GnttabAcquireLock(
 
 static VOID
 GnttabReleaseLock(
-    IN  PVOID               Argument
+    _In_ PVOID              Argument
     )
 {
     PXENBUS_GNTTAB_CACHE    Cache = Argument;
@@ -366,14 +366,14 @@ GnttabReleaseLock(
 
 static NTSTATUS
 GnttabCreateCache(
-    IN  PINTERFACE              Interface,
-    IN  const CHAR              *Name,
-    IN  ULONG                   Reservation,
-    IN  ULONG                   Cap,
-    IN  VOID                    (*AcquireLock)(PVOID),
-    IN  VOID                    (*ReleaseLock)(PVOID),
-    IN  PVOID                   Argument,
-    OUT PXENBUS_GNTTAB_CACHE    *Cache
+    _In_ PINTERFACE             Interface,
+    _In_ const CHAR             *Name,
+    _In_ ULONG                  Reservation,
+    _In_ ULONG                  Cap,
+    _In_ VOID                   (*AcquireLock)(PVOID),
+    _In_ VOID                   (*ReleaseLock)(PVOID),
+    _In_ PVOID                  Argument,
+    _Out_ PXENBUS_GNTTAB_CACHE  *Cache
     )
 {
     PXENBUS_GNTTAB_CONTEXT      Context = Interface->Context;
@@ -428,7 +428,7 @@ fail3:
     (*Cache)->AcquireLock = NULL;
 
     RtlZeroMemory((*Cache)->Name, sizeof ((*Cache)->Name));
-    
+
 fail2:
     Error("fail2\n");
 
@@ -445,13 +445,13 @@ fail1:
 
 static NTSTATUS
 GnttabCreateCacheVersion1(
-    IN  PINTERFACE              Interface,
-    IN  const CHAR              *Name,
-    IN  ULONG                   Reservation,
-    IN  VOID                    (*AcquireLock)(PVOID),
-    IN  VOID                    (*ReleaseLock)(PVOID),
-    IN  PVOID                   Argument,
-    OUT PXENBUS_GNTTAB_CACHE    *Cache
+    _In_ PINTERFACE             Interface,
+    _In_ const CHAR             *Name,
+    _In_ ULONG                  Reservation,
+    _In_ VOID                   (*AcquireLock)(PVOID),
+    _In_ VOID                   (*ReleaseLock)(PVOID),
+    _In_ PVOID                  Argument,
+    _Out_ PXENBUS_GNTTAB_CACHE  *Cache
     )
 {
     return GnttabCreateCache(Interface,
@@ -466,8 +466,8 @@ GnttabCreateCacheVersion1(
 
 static VOID
 GnttabDestroyCache(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_GNTTAB_CACHE    Cache
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_GNTTAB_CACHE   Cache
     )
 {
     PXENBUS_GNTTAB_CONTEXT      Context = Interface->Context;
@@ -489,7 +489,7 @@ GnttabDestroyCache(
     Cache->AcquireLock = NULL;
 
     RtlZeroMemory(Cache->Name, sizeof (Cache->Name));
-    
+
     Cache->Context = NULL;
 
     ASSERT(IsZeroMemory(Cache, sizeof (XENBUS_GNTTAB_CACHE)));
@@ -497,14 +497,14 @@ GnttabDestroyCache(
 }
 
 static NTSTATUS
-GnttabPermitForeignAccess( 
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_GNTTAB_CACHE    Cache,
-    IN  BOOLEAN                 Locked,
-    IN  USHORT                  Domain,
-    IN  PFN_NUMBER              Pfn,
-    IN  BOOLEAN                 ReadOnly,
-    OUT PXENBUS_GNTTAB_ENTRY    *Entry
+GnttabPermitForeignAccess(
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_GNTTAB_CACHE   Cache,
+    _In_ BOOLEAN                Locked,
+    _In_ USHORT                 Domain,
+    _In_ PFN_NUMBER             Pfn,
+    _In_ BOOLEAN                ReadOnly,
+    _Out_ PXENBUS_GNTTAB_ENTRY  *Entry
     )
 {
     PXENBUS_GNTTAB_CONTEXT      Context = Interface->Context;
@@ -549,10 +549,10 @@ fail1:
 
 static NTSTATUS
 GnttabRevokeForeignAccess(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_GNTTAB_CACHE    Cache,
-    IN  BOOLEAN                 Locked,
-    IN  PXENBUS_GNTTAB_ENTRY    Entry
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_GNTTAB_CACHE   Cache,
+    _In_ BOOLEAN                Locked,
+    _In_ PXENBUS_GNTTAB_ENTRY   Entry
     )
 {
     PXENBUS_GNTTAB_CONTEXT      Context = Interface->Context;
@@ -610,8 +610,8 @@ fail1:
 
 static ULONG
 GnttabGetReference(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_GNTTAB_ENTRY    Entry
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_GNTTAB_ENTRY   Entry
     )
 {
     UNREFERENCED_PARAMETER(Interface);
@@ -623,10 +623,10 @@ GnttabGetReference(
 
 static NTSTATUS
 GnttabQueryReference(
-    IN  PINTERFACE          Interface,
-    IN	ULONG               Reference,
-    OUT PPFN_NUMBER         Pfn OPTIONAL,
-    OUT PBOOLEAN            ReadOnly OPTIONAL
+    _In_ PINTERFACE         Interface,
+    _In_ ULONG              Reference,
+    _Out_opt_ PPFN_NUMBER   Pfn,
+    _Out_opt_ PBOOLEAN      ReadOnly
     )
 {
     PXENBUS_GNTTAB_CONTEXT  Context = Interface->Context;
@@ -657,12 +657,12 @@ fail1:
 
 static NTSTATUS
 GnttabMapForeignPages(
-    IN  PINTERFACE              Interface,
-    IN  USHORT                  Domain,
-    IN  ULONG                   NumberPages,
-    IN  PULONG                  References,
-    IN  BOOLEAN                 ReadOnly,
-    OUT PHYSICAL_ADDRESS        *Address
+    _In_ PINTERFACE             Interface,
+    _In_ USHORT                 Domain,
+    _In_ ULONG                  NumberPages,
+    _In_ PULONG                 References,
+    _In_ BOOLEAN                ReadOnly,
+    _Out_ PHYSICAL_ADDRESS      *Address
     )
 {
     PXENBUS_GNTTAB_CONTEXT      Context = Interface->Context;
@@ -740,8 +740,8 @@ fail1:
 
 static NTSTATUS
 GnttabUnmapForeignPages(
-    IN  PINTERFACE              Interface,
-    IN  PHYSICAL_ADDRESS        Address
+    _In_ PINTERFACE             Interface,
+    _In_ PHYSICAL_ADDRESS       Address
     )
 {
     PXENBUS_GNTTAB_CONTEXT      Context = Interface->Context;
@@ -793,18 +793,18 @@ fail1:
 
 static VOID
 GnttabSuspendCallbackEarly(
-    IN  PVOID               Argument
+    _In_ PVOID              Argument
     )
 {
     PXENBUS_GNTTAB_CONTEXT  Context = Argument;
 
     GnttabMap(Context);
 }
-                     
+
 static VOID
 GnttabDebugCallback(
-    IN  PVOID               Argument,
-    IN  BOOLEAN             Crashing
+    _In_ PVOID              Argument,
+    _In_ BOOLEAN            Crashing
     )
 {
     PXENBUS_GNTTAB_CONTEXT  Context = Argument;
@@ -817,7 +817,7 @@ GnttabDebugCallback(
         PHYSICAL_ADDRESS        Address;
 
         Address.QuadPart = MmGetMdlPfnArray(Frame->Mdl)[0] << PAGE_SHIFT;
-    
+
         XENBUS_DEBUG(Printf,
                     &Context->DebugInterface,
                      "[%u] Address = %08x.%08x\n",
@@ -825,10 +825,10 @@ GnttabDebugCallback(
                      Address.LowPart);
     }
 }
-                     
+
 NTSTATUS
 GnttabAcquire(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_GNTTAB_CONTEXT  Context = Interface->Context;
@@ -872,7 +872,7 @@ GnttabAcquire(
     status = XENBUS_CACHE(Acquire, &Context->CacheInterface);
     if (!NT_SUCCESS(status))
         goto fail5;
-    
+
     status = XENBUS_SUSPEND(Acquire, &Context->SuspendInterface);
     if (!NT_SUCCESS(status))
         goto fail6;
@@ -983,7 +983,7 @@ fail1:
 
 VOID
 GnttabRelease(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_GNTTAB_CONTEXT  Context = Interface->Context;
@@ -1081,11 +1081,11 @@ static struct _XENBUS_GNTTAB_INTERFACE_V4   GnttabInterfaceVersion4 = {
 
 NTSTATUS
 GnttabInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_GNTTAB_CONTEXT  *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_GNTTAB_CONTEXT    *Context
     )
 {
-    NTSTATUS                    status;
+    NTSTATUS                        status;
 
     Trace("====>\n");
 
@@ -1147,13 +1147,13 @@ fail1:
 
 NTSTATUS
 GnttabGetInterface(
-    IN      PXENBUS_GNTTAB_CONTEXT  Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_GNTTAB_CONTEXT Context,
+    _In_ ULONG                  Version,
+    _Inout_ PINTERFACE          Interface,
+    _In_ ULONG                  Size
     )
 {
-    NTSTATUS                        status;
+    NTSTATUS                    status;
 
     ASSERT(Context != NULL);
 
@@ -1215,11 +1215,11 @@ GnttabGetInterface(
     }
 
     return status;
-}   
+}
 
 ULONG
 GnttabGetReferences(
-    IN  PXENBUS_GNTTAB_CONTEXT  Context
+    _In_ PXENBUS_GNTTAB_CONTEXT Context
     )
 {
     return Context->References;
@@ -1227,7 +1227,7 @@ GnttabGetReferences(
 
 VOID
 GnttabTeardown(
-    IN  PXENBUS_GNTTAB_CONTEXT  Context
+    _In_ PXENBUS_GNTTAB_CONTEXT Context
     )
 {
     Trace("====>\n");
diff --git a/src/xenbus/gnttab.h b/src/xenbus/gnttab.h
index df74e39..ecd41f7 100644
--- a/src/xenbus/gnttab.h
+++ b/src/xenbus/gnttab.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -43,26 +43,26 @@ typedef struct _XENBUS_GNTTAB_CONTEXT  XENBUS_GNTTAB_CONTEXT, *PXENBUS_GNTTAB_CO
 
 extern NTSTATUS
 GnttabInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_GNTTAB_CONTEXT  *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_GNTTAB_CONTEXT    *Context
     );
 
 extern NTSTATUS
 GnttabGetInterface(
-    IN      PXENBUS_GNTTAB_CONTEXT  Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_GNTTAB_CONTEXT Context,
+    _In_ ULONG                  Version,
+    _Inout_ PINTERFACE          Interface,
+    _In_ ULONG                  Size
     );
 
 extern ULONG
 GnttabGetReferences(
-    IN  PXENBUS_GNTTAB_CONTEXT  Context
+    _In_ PXENBUS_GNTTAB_CONTEXT Context
     );
 
 extern VOID
 GnttabTeardown(
-    IN  PXENBUS_GNTTAB_CONTEXT  Context
+    _In_ PXENBUS_GNTTAB_CONTEXT Context
     );
 
 #endif  // _XENBUS_GNTTAB_H
diff --git a/src/xenbus/hash_table.c b/src/xenbus/hash_table.c
index 66d5ddd..061db08 100644
--- a/src/xenbus/hash_table.c
+++ b/src/xenbus/hash_table.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -63,7 +63,7 @@ struct _XENBUS_HASH_TABLE {
 
 static FORCEINLINE PVOID
 __HashTableAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_HASH_TABLE_TAG);
@@ -71,7 +71,7 @@ __HashTableAllocate(
 
 static FORCEINLINE VOID
 __HashTableFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_HASH_TABLE_TAG);
@@ -79,7 +79,7 @@ __HashTableFree(
 
 static ULONG
 HashTableHash(
-    IN  ULONG_PTR   Key
+    _In_ ULONG_PTR  Key
     )
 {
     PUCHAR          Array = (PUCHAR)&Key;
@@ -111,8 +111,8 @@ _IRQL_saves_
 _IRQL_raises_(HIGH_LEVEL)
 KIRQL
 __HashTableBucketLock(
-    IN  PXENBUS_HASH_TABLE_BUCKET   Bucket,
-    IN  BOOLEAN                     Writer
+    _In_ PXENBUS_HASH_TABLE_BUCKET  Bucket,
+    _In_ BOOLEAN                    Writer
     )
 {
     KIRQL                           Irql;
@@ -135,7 +135,7 @@ __HashTableBucketLock(
         // There must be no existing writer
         Old = Readers << 1;
 
-        if (Writer) 
+        if (Writer)
             Writers++;
         else
             Readers++;
@@ -162,12 +162,12 @@ __HashTableBucketLock(
     } while (FALSE)
 
 static
-__drv_requiresIRQL(HIGH_LEVEL)
+_IRQL_requires_(HIGH_LEVEL)
 VOID
 HashTableBucketUnlock(
-    IN  PXENBUS_HASH_TABLE_BUCKET   Bucket,
-    IN  BOOLEAN                     Writer,
-    IN  __drv_restoresIRQL KIRQL    Irql
+    _In_ PXENBUS_HASH_TABLE_BUCKET  Bucket,
+    _In_ BOOLEAN                    Writer,
+    _In_ _IRQL_restores_ KIRQL      Irql
     )
 {
     for (;;) {
@@ -203,9 +203,9 @@ HashTableBucketUnlock(
 
 NTSTATUS
 HashTableAdd(
-    IN  PXENBUS_HASH_TABLE      Table,
-    IN  ULONG_PTR               Key,
-    IN  ULONG_PTR               Value
+    _In_ PXENBUS_HASH_TABLE     Table,
+    _In_ ULONG_PTR              Key,
+    _In_ ULONG_PTR              Value
     )
 {
     PXENBUS_HASH_TABLE_NODE     Node;
@@ -223,7 +223,7 @@ HashTableAdd(
     Node->Value = Value;
 
     Bucket = &Table->Bucket[HashTableHash(Key)];
-    
+
     HashTableBucketLock(Bucket, TRUE, &Irql);
     InsertTailList(&Bucket->List, &Node->ListEntry);
     HashTableBucketUnlock(Bucket, TRUE, Irql);
@@ -238,8 +238,8 @@ fail1:
 
 NTSTATUS
 HashTableRemove(
-    IN  PXENBUS_HASH_TABLE      Table,
-    IN  ULONG_PTR               Key
+    _In_ PXENBUS_HASH_TABLE     Table,
+    _In_ ULONG_PTR              Key
     )
 {
     PXENBUS_HASH_TABLE_BUCKET   Bucket;
@@ -251,7 +251,7 @@ HashTableRemove(
 
     Bucket = &Table->Bucket[HashTableHash(Key)];
     Hidden = &Table->Hidden;
-    
+
     HashTableBucketLock(Bucket, TRUE, &Irql);
 
     for (ListEntry = Bucket->List.Flink;
@@ -289,9 +289,9 @@ fail1:
 
 NTSTATUS
 HashTableLookup(
-    IN  PXENBUS_HASH_TABLE      Table,
-    IN  ULONG_PTR               Key,
-    OUT PULONG_PTR              Value
+    _In_ PXENBUS_HASH_TABLE     Table,
+    _In_ ULONG_PTR              Key,
+    _Out_ PULONG_PTR            Value
     )
 {
     PXENBUS_HASH_TABLE_BUCKET   Bucket;
@@ -301,7 +301,7 @@ HashTableLookup(
     NTSTATUS                    status;
 
     Bucket = &Table->Bucket[HashTableHash(Key)];
-    
+
     HashTableBucketLock(Bucket, FALSE, &Irql);
 
     for (ListEntry = Bucket->List.Flink;
@@ -339,10 +339,10 @@ _IRQL_requires_(DISPATCH_LEVEL)
 _IRQL_requires_same_
 VOID
 HashTableDpc(
-    IN  PKDPC                   Dpc,
-    IN  PVOID                   Context,
-    IN  PVOID                   Argument1,
-    IN  PVOID                   Argument2
+    _In_ PKDPC                  Dpc,
+    _In_ PVOID                  Context,
+    _In_ PVOID                  Argument1,
+    _In_ PVOID                  Argument2
     )
 {
     PXENBUS_HASH_TABLE          Table = Context;
@@ -383,7 +383,7 @@ HashTableDpc(
 
 NTSTATUS
 HashTableCreate(
-    OUT PXENBUS_HASH_TABLE      *Table
+    _Out_ PXENBUS_HASH_TABLE    *Table
     )
 {
     ULONG                       Index;
@@ -418,7 +418,7 @@ fail1:
 
 VOID
 HashTableDestroy(
-    IN  PXENBUS_HASH_TABLE      Table
+    _In_ PXENBUS_HASH_TABLE     Table
     )
 {
     ULONG                       Index;
diff --git a/src/xenbus/hash_table.h b/src/xenbus/hash_table.h
index ef1abe5..033b7c1 100644
--- a/src/xenbus/hash_table.h
+++ b/src/xenbus/hash_table.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -35,36 +35,36 @@
 
 #include <ntddk.h>
 
-typedef struct _XENBUS_HASH_TABLE XENBUS_HASH_TABLE, *PXENBUS_HASH_TABLE; 
+typedef struct _XENBUS_HASH_TABLE XENBUS_HASH_TABLE, *PXENBUS_HASH_TABLE;
 
 extern NTSTATUS
 HashTableAdd(
-    IN  PXENBUS_HASH_TABLE  Table,
-    IN  ULONG_PTR           Key,
-    IN  ULONG_PTR           Value
+    _In_ PXENBUS_HASH_TABLE Table,
+    _In_ ULONG_PTR          Key,
+    _In_ ULONG_PTR          Value
     );
 
 extern NTSTATUS
 HashTableRemove(
-    IN  PXENBUS_HASH_TABLE  Table,
-    IN  ULONG_PTR           Key
+    _In_ PXENBUS_HASH_TABLE Table,
+    _In_ ULONG_PTR          Key
     );
 
 extern NTSTATUS
 HashTableLookup(
-    IN  PXENBUS_HASH_TABLE  Table,
-    IN  ULONG_PTR           Key,
-    OUT PULONG_PTR          Value
+    _In_ PXENBUS_HASH_TABLE Table,
+    _In_ ULONG_PTR          Key,
+    _Out_ PULONG_PTR        Value
     );
 
 extern NTSTATUS
 HashTableCreate(
-    OUT PXENBUS_HASH_TABLE  *Table
+    _Out_ PXENBUS_HASH_TABLE    *Table
     );
 
 extern VOID
 HashTableDestroy(
-    IN  PXENBUS_HASH_TABLE  Table
+    _In_ PXENBUS_HASH_TABLE Table
     );
 
 #endif  // _XENBUS_HASH_TABLE_H
diff --git a/src/xenbus/pdo.c b/src/xenbus/pdo.c
index 9163923..a504652 100644
--- a/src/xenbus/pdo.c
+++ b/src/xenbus/pdo.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -78,7 +78,7 @@ struct _XENBUS_PDO {
 
 static FORCEINLINE PVOID
 __PdoAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, PDO_TAG);
@@ -86,7 +86,7 @@ __PdoAllocate(
 
 static FORCEINLINE VOID
 __PdoFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, PDO_TAG);
@@ -94,8 +94,8 @@ __PdoFree(
 
 static FORCEINLINE VOID
 __PdoSetDevicePnpState(
-    IN  PXENBUS_PDO         Pdo,
-    IN  DEVICE_PNP_STATE    State
+    _In_ PXENBUS_PDO        Pdo,
+    _In_ DEVICE_PNP_STATE   State
     )
 {
     PXENBUS_DX              Dx = Pdo->Dx;
@@ -109,8 +109,8 @@ __PdoSetDevicePnpState(
 
 VOID
 PdoSetDevicePnpState(
-    IN  PXENBUS_PDO         Pdo,
-    IN  DEVICE_PNP_STATE    State
+    _In_ PXENBUS_PDO        Pdo,
+    _In_ DEVICE_PNP_STATE   State
     )
 {
     __PdoSetDevicePnpState(Pdo, State);
@@ -118,8 +118,8 @@ PdoSetDevicePnpState(
 
 static FORCEINLINE VOID
 __PdoRestoreDevicePnpState(
-    IN  PXENBUS_PDO         Pdo,
-    IN  DEVICE_PNP_STATE    State
+    _In_ PXENBUS_PDO        Pdo,
+    _In_ DEVICE_PNP_STATE   State
     )
 {
     PXENBUS_DX              Dx = Pdo->Dx;
@@ -130,7 +130,7 @@ __PdoRestoreDevicePnpState(
 
 static FORCEINLINE DEVICE_PNP_STATE
 __PdoGetDevicePnpState(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     PXENBUS_DX      Dx = Pdo->Dx;
@@ -140,7 +140,7 @@ __PdoGetDevicePnpState(
 
 DEVICE_PNP_STATE
 PdoGetDevicePnpState(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     return __PdoGetDevicePnpState(Pdo);
@@ -148,8 +148,8 @@ PdoGetDevicePnpState(
 
 static FORCEINLINE VOID
 __PdoSetDevicePowerState(
-    IN  PXENBUS_PDO         Pdo,
-    IN  DEVICE_POWER_STATE  State
+    _In_ PXENBUS_PDO        Pdo,
+    _In_ DEVICE_POWER_STATE State
     )
 {
     PXENBUS_DX              Dx = Pdo->Dx;
@@ -159,18 +159,18 @@ __PdoSetDevicePowerState(
 
 static FORCEINLINE DEVICE_POWER_STATE
 __PdoGetDevicePowerState(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
-    PXENBUS_DX      Dx = Pdo->Dx;
+    PXENBUS_DX          Dx = Pdo->Dx;
 
     return Dx->DevicePowerState;
 }
 
 static FORCEINLINE VOID
 __PdoSetSystemPowerState(
-    IN  PXENBUS_PDO         Pdo,
-    IN  SYSTEM_POWER_STATE  State
+    _In_ PXENBUS_PDO        Pdo,
+    _In_ SYSTEM_POWER_STATE State
     )
 {
     PXENBUS_DX              Dx = Pdo->Dx;
@@ -180,18 +180,18 @@ __PdoSetSystemPowerState(
 
 static FORCEINLINE SYSTEM_POWER_STATE
 __PdoGetSystemPowerState(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
-    PXENBUS_DX      Dx = Pdo->Dx;
+    PXENBUS_DX          Dx = Pdo->Dx;
 
     return Dx->SystemPowerState;
 }
 
 static FORCEINLINE VOID
 __PdoSetMissing(
-    IN  PXENBUS_PDO Pdo,
-    IN  const CHAR  *Reason
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ const CHAR     *Reason
     )
 {
     Pdo->Reason = Reason;
@@ -200,8 +200,8 @@ __PdoSetMissing(
 
 VOID
 PdoSetMissing(
-    IN  PXENBUS_PDO Pdo,
-    IN  const CHAR  *Reason
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ const CHAR     *Reason
     )
 {
     __PdoSetMissing(Pdo, Reason);
@@ -209,7 +209,7 @@ PdoSetMissing(
 
 static FORCEINLINE BOOLEAN
 __PdoIsMissing(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     return Pdo->Missing;
@@ -217,7 +217,7 @@ __PdoIsMissing(
 
 BOOLEAN
 PdoIsMissing(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     return __PdoIsMissing(Pdo);
@@ -225,8 +225,8 @@ PdoIsMissing(
 
 static FORCEINLINE VOID
 __PdoSetName(
-    IN  PXENBUS_PDO     Pdo,
-    IN  PANSI_STRING    Name
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PANSI_STRING   Name
     )
 {
     PXENBUS_DX          Dx = Pdo->Dx;
@@ -241,17 +241,17 @@ __PdoSetName(
 
 static FORCEINLINE PCHAR
 __PdoGetName(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
-    PXENBUS_DX      Dx = Pdo->Dx;
+    PXENBUS_DX          Dx = Pdo->Dx;
 
     return Dx->Name;
 }
 
 PCHAR
 PdoGetName(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     return __PdoGetName(Pdo);
@@ -259,7 +259,7 @@ PdoGetName(
 
 static FORCEINLINE VOID
 __PdoSetRemovable(
-    IN  PXENBUS_PDO     Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     HANDLE              ParametersKey;
@@ -290,7 +290,7 @@ done:
 
 static FORCEINLINE BOOLEAN
 __PdoIsRemovable(
-    IN  PXENBUS_PDO     Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     return Pdo->Removable;
@@ -298,7 +298,7 @@ __PdoIsRemovable(
 
 static FORCEINLINE VOID
 __PdoSetEjectable(
-    IN  PXENBUS_PDO     Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     HANDLE              ParametersKey;
@@ -329,7 +329,7 @@ done:
 
 static FORCEINLINE BOOLEAN
 __PdoIsEjectable(
-    IN  PXENBUS_PDO     Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     return Pdo->Ejectable;
@@ -339,7 +339,7 @@ __PdoIsEjectable(
 
 static FORCEINLINE PXENBUS_FDO
 __PdoGetFdo(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     return Pdo->Fdo;
@@ -347,7 +347,7 @@ __PdoGetFdo(
 
 PXENBUS_FDO
 PdoGetFdo(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     return __PdoGetFdo(Pdo);
@@ -379,10 +379,10 @@ static XENBUS_PDO_REVISION PdoRevision[] = {
 
 static VOID
 PdoDumpRevisions(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
-    ULONG           Index;
+    ULONG               Index;
 
     UNREFERENCED_PARAMETER(Pdo);
 
@@ -475,17 +475,17 @@ PdoDumpRevisions(
 
 static FORCEINLINE PDEVICE_OBJECT
 __PdoGetDeviceObject(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
-    PXENBUS_DX      Dx = Pdo->Dx;
+    PXENBUS_DX          Dx = Pdo->Dx;
 
     return (Dx->DeviceObject);
 }
-    
+
 PDEVICE_OBJECT
 PdoGetDeviceObject(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     return __PdoGetDeviceObject(Pdo);
@@ -493,7 +493,7 @@ PdoGetDeviceObject(
 
 static FORCEINLINE PCHAR
 __PdoGetVendorName(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     return FdoGetVendorName(__PdoGetFdo(Pdo));
@@ -501,9 +501,9 @@ __PdoGetVendorName(
 
 PDMA_ADAPTER
 PdoGetDmaAdapter(
-    IN  PXENBUS_PDO         Pdo,
-    IN  PDEVICE_DESCRIPTION DeviceDescriptor,
-    OUT PULONG              NumberOfMapRegisters
+    _In_ PXENBUS_PDO            Pdo,
+    _In_ PDEVICE_DESCRIPTION    DeviceDescriptor,
+    _Out_ PULONG                NumberOfMapRegisters
     )
 {
     Trace("<===>\n");
@@ -515,11 +515,11 @@ PdoGetDmaAdapter(
 
 BOOLEAN
 PdoTranslateBusAddress(
-    IN      PXENBUS_PDO         Pdo,
-    IN      PHYSICAL_ADDRESS    BusAddress,
-    IN      ULONG               Length,
-    IN OUT  PULONG              AddressSpace,
-    OUT     PPHYSICAL_ADDRESS   TranslatedAddress
+    _In_ PXENBUS_PDO        Pdo,
+    _In_ PHYSICAL_ADDRESS   BusAddress,
+    _In_ ULONG              Length,
+    _Inout_ PULONG          AddressSpace,
+    _Out_ PPHYSICAL_ADDRESS TranslatedAddress
     )
 {
     Trace("<===>\n");
@@ -533,11 +533,11 @@ PdoTranslateBusAddress(
 
 ULONG
 PdoSetBusData(
-    IN  PXENBUS_PDO     Pdo,
-    IN  ULONG           DataType,
-    IN  PVOID           Buffer,
-    IN  ULONG           Offset,
-    IN  ULONG           Length
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ ULONG          DataType,
+    _In_ PVOID          Buffer,
+    _In_ ULONG          Offset,
+    _In_ ULONG          Length
     )
 {
     Trace("<===>\n");
@@ -551,11 +551,11 @@ PdoSetBusData(
 
 ULONG
 PdoGetBusData(
-    IN  PXENBUS_PDO     Pdo,
-    IN  ULONG           DataType,
-    IN  PVOID           Buffer,
-    IN  ULONG           Offset,
-    IN  ULONG           Length
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ ULONG          DataType,
+    _In_ PVOID          Buffer,
+    _In_ ULONG          Offset,
+    _In_ ULONG          Length
     )
 {
     Trace("<===>\n");
@@ -569,7 +569,7 @@ PdoGetBusData(
 
 static FORCEINLINE VOID
 __PdoD3ToD0(
-    IN  PXENBUS_PDO     Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     POWER_STATE         PowerState;
@@ -591,7 +591,7 @@ __PdoD3ToD0(
 
 static FORCEINLINE VOID
 __PdoD0ToD3(
-    IN  PXENBUS_PDO     Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     POWER_STATE         PowerState;
@@ -613,7 +613,7 @@ __PdoD0ToD3(
 
 static VOID
 PdoSuspendCallbackLate(
-    IN  PVOID   Argument
+    _In_ PVOID  Argument
     )
 {
     PXENBUS_PDO Pdo = Argument;
@@ -625,11 +625,11 @@ PdoSuspendCallbackLate(
 // This function must not touch pageable code or data
 static NTSTATUS
 PdoD3ToD0(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
-    KIRQL           Irql;
-    NTSTATUS        status;
+    KIRQL               Irql;
+    NTSTATUS            status;
 
     ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
 
@@ -672,10 +672,10 @@ fail1:
 // This function must not touch pageable code or data
 static VOID
 PdoD0ToD3(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
-    KIRQL           Irql;
+    KIRQL               Irql;
 
     ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
 
@@ -696,7 +696,7 @@ PdoD0ToD3(
 // This function must not touch pageable code or data
 static VOID
 PdoS4ToS3(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     Trace("(%s) ====>\n", __PdoGetName(Pdo));
@@ -712,7 +712,7 @@ PdoS4ToS3(
 // This function must not touch pageable code or data
 static VOID
 PdoS3ToS4(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     Trace("(%s) ====>\n", __PdoGetName(Pdo));
@@ -727,8 +727,8 @@ PdoS3ToS4(
 
 static NTSTATUS
 PdoStartDevice(
-    IN  PXENBUS_PDO     Pdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     NTSTATUS            status;
@@ -746,11 +746,11 @@ PdoStartDevice(
 
 static NTSTATUS
 PdoQueryStopDevice(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     __PdoSetDevicePnpState(Pdo, StopPending);
     status = STATUS_SUCCESS;
@@ -763,8 +763,8 @@ PdoQueryStopDevice(
 
 static NTSTATUS
 PdoCancelStopDevice(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP       Irp
     )
 {
     NTSTATUS        status;
@@ -780,11 +780,11 @@ PdoCancelStopDevice(
 
 static NTSTATUS
 PdoStopDevice(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     PdoD0ToD3(Pdo);
 
@@ -799,11 +799,11 @@ PdoStopDevice(
 
 static NTSTATUS
 PdoQueryRemoveDevice(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     __PdoSetDevicePnpState(Pdo, RemovePending);
     status = STATUS_SUCCESS;
@@ -816,11 +816,11 @@ PdoQueryRemoveDevice(
 
 static NTSTATUS
 PdoCancelRemoveDevice(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     __PdoRestoreDevicePnpState(Pdo, RemovePending);
     status = STATUS_SUCCESS;
@@ -833,11 +833,11 @@ PdoCancelRemoveDevice(
 
 static NTSTATUS
 PdoSurpriseRemoval(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     Warning("%s\n", __PdoGetName(Pdo));
 
@@ -852,13 +852,13 @@ PdoSurpriseRemoval(
 
 static NTSTATUS
 PdoRemoveDevice(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
-    PXENBUS_FDO     Fdo = __PdoGetFdo(Pdo);
-    BOOLEAN         NeedInvalidate;
-    NTSTATUS        status;
+    PXENBUS_FDO         Fdo = __PdoGetFdo(Pdo);
+    BOOLEAN             NeedInvalidate;
+    NTSTATUS            status;
 
     if (__PdoGetDevicePowerState(Pdo) != PowerDeviceD0)
         goto done;
@@ -899,8 +899,8 @@ done:
 
 static NTSTATUS
 PdoQueryDeviceRelations(
-    IN  PXENBUS_PDO     Pdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -936,8 +936,8 @@ done:
 
 static FORCEINLINE NTSTATUS
 __PdoDelegateIrp(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     return FdoDelegateIrp(__PdoGetFdo(Pdo), Irp);
@@ -945,8 +945,8 @@ __PdoDelegateIrp(
 
 static NTSTATUS
 PdoDelegateIrp(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     return __PdoDelegateIrp(Pdo, Irp);
@@ -954,8 +954,8 @@ PdoDelegateIrp(
 
 static NTSTATUS
 PdoQueryBusInterface(
-    IN  PXENBUS_PDO         Pdo,
-    IN  PIRP                Irp
+    _In_ PXENBUS_PDO        Pdo,
+    _In_ PIRP               Irp
     )
 {
     PIO_STACK_LOCATION      StackLocation;
@@ -964,7 +964,7 @@ PdoQueryBusInterface(
     PBUS_INTERFACE_STANDARD BusInterface;
     NTSTATUS                status;
 
-    status = Irp->IoStatus.Status;        
+    status = Irp->IoStatus.Status;
 
     StackLocation = IoGetCurrentIrpStackLocation(Irp);
     Size = StackLocation->Parameters.QueryInterface.Size;
@@ -974,7 +974,7 @@ PdoQueryBusInterface(
     if (Version != 1)
         goto done;
 
-    status = STATUS_BUFFER_TOO_SMALL;        
+    status = STATUS_BUFFER_TOO_SMALL;
     if (Size < sizeof (BUS_INTERFACE_STANDARD))
         goto done;
 
@@ -991,8 +991,8 @@ done:
 #define DEFINE_PDO_QUERY_INTERFACE(_Interface)                      \
 static NTSTATUS                                                     \
 PdoQuery ## _Interface ## Interface(                                \
-    IN  PXENBUS_PDO     Pdo,                                        \
-    IN  PIRP            Irp                                         \
+    _In_ PXENBUS_PDO    Pdo,                                        \
+    _In_ PIRP           Irp                                         \
     )                                                               \
 {                                                                   \
     PIO_STACK_LOCATION  StackLocation;                              \
@@ -1060,8 +1060,8 @@ static struct _INTERFACE_ENTRY PdoInterfaceTable[] = {
 
 static NTSTATUS
 PdoQueryInterface(
-    IN  PXENBUS_PDO         Pdo,
-    IN  PIRP                Irp
+    _In_ PXENBUS_PDO        Pdo,
+    _In_ PIRP               Irp
     )
 {
     PIO_STACK_LOCATION      StackLocation;
@@ -1099,8 +1099,8 @@ done:
 
 static NTSTATUS
 PdoQueryCapabilities(
-    IN  PXENBUS_PDO         Pdo,
-    IN  PIRP                Irp
+    _In_ PXENBUS_PDO        Pdo,
+    _In_ PIRP               Irp
     )
 {
     PIO_STACK_LOCATION      StackLocation;
@@ -1168,8 +1168,8 @@ done:
 
 static NTSTATUS
 PdoQueryResourceRequirements(
-    IN  PXENBUS_PDO                 Pdo,
-    IN  PIRP                        Irp
+    _In_ PXENBUS_PDO                Pdo,
+    _In_ PIRP                       Irp
     )
 {
     IO_RESOURCE_DESCRIPTOR          Memory;
@@ -1245,8 +1245,8 @@ fail1:
 
 static NTSTATUS
 PdoQueryDeviceText(
-    IN  PXENBUS_PDO     Pdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1326,8 +1326,8 @@ done:
 
 static NTSTATUS
 PdoReadConfig(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     UNREFERENCED_PARAMETER(Pdo);
@@ -1340,8 +1340,8 @@ PdoReadConfig(
 
 static NTSTATUS
 PdoWriteConfig(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     UNREFERENCED_PARAMETER(Pdo);
@@ -1356,8 +1356,8 @@ PdoWriteConfig(
 
 static NTSTATUS
 PdoQueryId(
-    IN  PXENBUS_PDO     Pdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1513,8 +1513,8 @@ done:
 
 static NTSTATUS
 PdoQueryBusInformation(
-    IN  PXENBUS_PDO         Pdo,
-    IN  PIRP                Irp
+    _In_ PXENBUS_PDO        Pdo,
+    _In_ PIRP               Irp
     )
 {
     PPNP_BUS_INFORMATION    Info;
@@ -1544,11 +1544,11 @@ done:
 
 static NTSTATUS
 PdoDeviceUsageNotification(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     status = __PdoDelegateIrp(Pdo, Irp);
 
@@ -1560,8 +1560,8 @@ PdoDeviceUsageNotification(
 
 static NTSTATUS
 PdoEject(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     PXENBUS_FDO     Fdo = __PdoGetFdo(Pdo);
@@ -1589,8 +1589,8 @@ PdoEject(
 
 static NTSTATUS
 PdoDispatchPnp(
-    IN  PXENBUS_PDO     Pdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1601,7 +1601,7 @@ PdoDispatchPnp(
     MinorFunction = StackLocation->MinorFunction;
 
     Trace("====> (%02x:%s)\n",
-          MinorFunction, 
+          MinorFunction,
           PnpMinorFunctionName(MinorFunction));
 
     switch (StackLocation->MinorFunction) {
@@ -1688,19 +1688,20 @@ PdoDispatchPnp(
     }
 
     Trace("<==== (%02x:%s)(%08x)\n",
-          MinorFunction, 
+          MinorFunction,
           PnpMinorFunctionName(MinorFunction),
           status);
 
     return status;
 }
 
-__drv_functionClass(IO_WORKITEM_ROUTINE)
-__drv_sameIRQL
+static IO_WORKITEM_ROUTINE PdoSetDevicePowerWorker;
+
+_Use_decl_annotations_
 static VOID
 PdoSetDevicePowerWorker(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PVOID           Context
+    _In_ PDEVICE_OBJECT DeviceObject,
+    _In_opt_ PVOID      Context
     )
 {
     PXENBUS_PDO         Pdo = (PXENBUS_PDO) Context;
@@ -1751,14 +1752,14 @@ done:
     IoCompleteRequest(Irp, IO_NO_INCREMENT);
 
     Trace("<==== (%s:%s)\n",
-          DevicePowerStateName(DeviceState), 
+          DevicePowerStateName(DeviceState),
           PowerActionName(PowerAction));
 }
 
 static NTSTATUS
 PdoSetDevicePower(
-    IN  PXENBUS_PDO     Pdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1785,12 +1786,13 @@ PdoSetDevicePower(
     return STATUS_PENDING;
 }
 
-__drv_functionClass(IO_WORKITEM_ROUTINE)
-__drv_sameIRQL
+static IO_WORKITEM_ROUTINE PdoSetSystemPowerWorker;
+
+_Use_decl_annotations_
 static VOID
 PdoSetSystemPowerWorker(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PVOID           Context
+    _In_ PDEVICE_OBJECT DeviceObject,
+    _In_opt_ PVOID      Context
     )
 {
     PXENBUS_PDO         Pdo = (PXENBUS_PDO) Context;
@@ -1839,14 +1841,14 @@ PdoSetSystemPowerWorker(
     IoCompleteRequest(Irp, IO_NO_INCREMENT);
 
     Trace("<==== (%s:%s)\n",
-          SystemPowerStateName(SystemState), 
+          SystemPowerStateName(SystemState),
           PowerActionName(PowerAction));
 }
 
 static NTSTATUS
 PdoSetSystemPower(
-    IN  PXENBUS_PDO     Pdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1875,15 +1877,15 @@ PdoSetSystemPower(
 
 static NTSTATUS
 PdoDispatchSetPower(
-    IN  PXENBUS_PDO     Pdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
     POWER_STATE_TYPE    PowerType;
     POWER_ACTION        PowerAction;
     NTSTATUS            status;
-    
+
     StackLocation = IoGetCurrentIrpStackLocation(Irp);
     PowerType = StackLocation->Parameters.Power.Type;
     PowerAction = StackLocation->Parameters.Power.ShutdownType;
@@ -1908,8 +1910,8 @@ PdoDispatchSetPower(
 
 static NTSTATUS
 PdoDispatchPower(
-    IN  PXENBUS_PDO     Pdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1936,11 +1938,11 @@ PdoDispatchPower(
 
 static NTSTATUS
 PdoDispatchDefault(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
-    NTSTATUS        status;
+    NTSTATUS            status;
 
     UNREFERENCED_PARAMETER(Pdo);
 
@@ -1952,8 +1954,8 @@ PdoDispatchDefault(
 
 NTSTATUS
 PdoDispatch(
-    IN  PXENBUS_PDO     Pdo,
-    IN  PIRP            Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1980,7 +1982,7 @@ PdoDispatch(
 
 VOID
 PdoResume(
-    IN  PXENBUS_PDO     Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     UNREFERENCED_PARAMETER(Pdo);
@@ -1990,7 +1992,7 @@ PdoResume(
 
 VOID
 PdoSuspend(
-    IN  PXENBUS_PDO     Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
     UNREFERENCED_PARAMETER(Pdo);
@@ -2000,8 +2002,8 @@ PdoSuspend(
 
 NTSTATUS
 PdoCreate(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PANSI_STRING    Name
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PANSI_STRING   Name
     )
 {
     PDEVICE_OBJECT      PhysicalDeviceObject;
@@ -2112,12 +2114,12 @@ fail1:
 
 VOID
 PdoDestroy(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     )
 {
-    PXENBUS_DX      Dx = Pdo->Dx;
-    PDEVICE_OBJECT  PhysicalDeviceObject = Dx->DeviceObject;
-    PXENBUS_FDO     Fdo = __PdoGetFdo(Pdo);
+    PXENBUS_DX          Dx = Pdo->Dx;
+    PDEVICE_OBJECT      PhysicalDeviceObject = Dx->DeviceObject;
+    PXENBUS_FDO         Fdo = __PdoGetFdo(Pdo);
 
     ASSERT3U(__PdoGetDevicePnpState(Pdo), ==, Deleted);
 
diff --git a/src/xenbus/pdo.h b/src/xenbus/pdo.h
index 22bd506..1de01f8 100644
--- a/src/xenbus/pdo.h
+++ b/src/xenbus/pdo.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -40,100 +40,100 @@
 
 extern VOID
 PdoSetDevicePnpState(
-    IN  PXENBUS_PDO         Pdo,
-    IN  DEVICE_PNP_STATE    State
+    _In_ PXENBUS_PDO        Pdo,
+    _In_ DEVICE_PNP_STATE   State
     );
 
 extern DEVICE_PNP_STATE
 PdoGetDevicePnpState(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     );
 
 extern BOOLEAN
 PdoIsMissing(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     );
 
 extern VOID
 PdoSetMissing(
-    IN  PXENBUS_PDO Pdo,
-    IN  const CHAR  *Reason
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ const CHAR     *Reason
     );
 
 extern PCHAR
 PdoGetName(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     );
 
 extern PDEVICE_OBJECT
 PdoGetDeviceObject(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     );
 
 extern PXENBUS_FDO
 PdoGetFdo(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     );
 
 extern PDMA_ADAPTER
 PdoGetDmaAdapter(
-    IN  PXENBUS_PDO         Pdo,
-    IN  PDEVICE_DESCRIPTION DeviceDescriptor,
-    OUT PULONG              NumberOfMapRegisters
+    _In_ PXENBUS_PDO            Pdo,
+    _In_ PDEVICE_DESCRIPTION    DeviceDescriptor,
+    _Out_ PULONG                NumberOfMapRegisters
     );
 
 extern BOOLEAN
 PdoTranslateBusAddress(
-    IN      PXENBUS_PDO         Pdo,
-    IN      PHYSICAL_ADDRESS    BusAddress,
-    IN      ULONG               Length,
-    IN OUT  PULONG              AddressSpace,
-    OUT     PPHYSICAL_ADDRESS   TranslatedAddress
+    _In_ PXENBUS_PDO        Pdo,
+    _In_ PHYSICAL_ADDRESS   BusAddress,
+    _In_ ULONG              Length,
+    _Inout_ PULONG          AddressSpace,
+    _Out_ PPHYSICAL_ADDRESS TranslatedAddress
     );
 
 extern ULONG
 PdoSetBusData(
-    IN  PXENBUS_PDO Pdo,
-    IN  ULONG       DataType,
-    IN  PVOID       Buffer,
-    IN  ULONG       Offset,
-    IN  ULONG       Length
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ ULONG      DataType,
+    _In_ PVOID      Buffer,
+    _In_ ULONG      Offset,
+    _In_ ULONG      Length
     );
 
 extern ULONG
 PdoGetBusData(
-    IN  PXENBUS_PDO Pdo,
-    IN  ULONG       DataType,
-    IN  PVOID       Buffer,
-    IN  ULONG       Offset,
-    IN  ULONG       Length
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ ULONG      DataType,
+    _In_ PVOID      Buffer,
+    _In_ ULONG      Offset,
+    _In_ ULONG      Length
     );
 
 extern NTSTATUS
 PdoCreate(
-    IN  PXENBUS_FDO     Fdo,
-    IN  PANSI_STRING    Name
+    _In_ PXENBUS_FDO    Fdo,
+    _In_ PANSI_STRING   Name
     );
 
 extern VOID
 PdoResume(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     );
 
 extern VOID
 PdoSuspend(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     );
 
 extern VOID
 PdoDestroy(
-    IN  PXENBUS_PDO Pdo
+    _In_ PXENBUS_PDO    Pdo
     );
 
 extern NTSTATUS
 PdoDispatch(
-    IN  PXENBUS_PDO Pdo,
-    IN  PIRP        Irp
+    _In_ PXENBUS_PDO    Pdo,
+    _In_ PIRP       Irp
     );
 
 #endif  // _XENBUS_PDO_H
diff --git a/src/xenbus/range_set.c b/src/xenbus/range_set.c
index 08af0db..13df2e5 100644
--- a/src/xenbus/range_set.c
+++ b/src/xenbus/range_set.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -71,7 +71,7 @@ struct _XENBUS_RANGE_SET_CONTEXT {
 
 static FORCEINLINE PVOID
 __RangeSetAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, RANGE_SET_TAG);
@@ -79,7 +79,7 @@ __RangeSetAllocate(
 
 static FORCEINLINE VOID
 __RangeSetFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, RANGE_SET_TAG);
@@ -87,7 +87,7 @@ __RangeSetFree(
 
 static FORCEINLINE BOOLEAN
 __RangeSetIsEmpty(
-    IN  PXENBUS_RANGE_SET   RangeSet
+    _In_ PXENBUS_RANGE_SET  RangeSet
     )
 {
     return IsListEmpty(&RangeSet->List);
@@ -95,8 +95,8 @@ __RangeSetIsEmpty(
 
 static VOID
 RangeSetRemove(
-    IN  PXENBUS_RANGE_SET   RangeSet,
-    IN  BOOLEAN             After
+    _In_ PXENBUS_RANGE_SET  RangeSet,
+    _In_ BOOLEAN            After
     )
 {
     PLIST_ENTRY             Cursor;
@@ -130,7 +130,7 @@ RangeSetRemove(
 
 static VOID
 RangeSetMergeBackwards(
-    IN  PXENBUS_RANGE_SET   RangeSet
+    _In_ PXENBUS_RANGE_SET  RangeSet
     )
 {
     PLIST_ENTRY             Cursor;
@@ -156,7 +156,7 @@ RangeSetMergeBackwards(
 
 static VOID
 RangeSetMergeForwards(
-    IN  PXENBUS_RANGE_SET   RangeSet
+    _In_ PXENBUS_RANGE_SET  RangeSet
     )
 {
     PLIST_ENTRY             Cursor;
@@ -182,10 +182,10 @@ RangeSetMergeForwards(
 
 static NTSTATUS
 RangeSetPop(
-    IN  PINTERFACE          Interface,
-    IN  PXENBUS_RANGE_SET   RangeSet,
-    IN  ULONGLONG           Count,
-    OUT PLONGLONG           Start
+    _In_ PINTERFACE         Interface,
+    _In_ PXENBUS_RANGE_SET  RangeSet,
+    _In_ ULONGLONG          Count,
+    _Out_ PLONGLONG         Start
     )
 {
     PLIST_ENTRY             Cursor;
@@ -252,10 +252,10 @@ fail1:
 
 static NTSTATUS
 RangeSetAdd(
-    IN  PXENBUS_RANGE_SET   RangeSet,
-    IN  LONGLONG            Start,
-    IN  LONGLONG            End,
-    IN  BOOLEAN             After
+    _In_ PXENBUS_RANGE_SET  RangeSet,
+    _In_ LONGLONG           Start,
+    _In_ LONGLONG           End,
+    _In_ BOOLEAN            After
     )
 {
 #define INSERT_AFTER(_Cursor, _New)             \
@@ -323,10 +323,10 @@ fail1:
 
 static NTSTATUS
 RangeSetGet(
-    IN  PINTERFACE          Interface,
-    IN  PXENBUS_RANGE_SET   RangeSet,
-    IN  LONGLONG            Start,
-    IN  ULONGLONG           Count
+    _In_ PINTERFACE         Interface,
+    _In_ PXENBUS_RANGE_SET  RangeSet,
+    _In_ LONGLONG           Start,
+    _In_ ULONGLONG          Count
     )
 {
     LONGLONG                End = Start + Count - 1;
@@ -417,14 +417,14 @@ fail2:
 fail1:
     Error("fail1 (%08x)\n", status);
 
-    return status;    
+    return status;
 }
 
 static NTSTATUS
 RangeSetAddAfter(
-    IN  PXENBUS_RANGE_SET   RangeSet,
-    IN  LONGLONG            Start,
-    IN  LONGLONG            End
+    _In_ PXENBUS_RANGE_SET  RangeSet,
+    _In_ LONGLONG           Start,
+    _In_ LONGLONG           End
     )
 {
     PLIST_ENTRY             Cursor;
@@ -450,7 +450,7 @@ RangeSetAddAfter(
     }
 
     RangeSet->Cursor = Cursor;
-    status = RangeSetAdd(RangeSet, Start, End, FALSE);    
+    status = RangeSetAdd(RangeSet, Start, End, FALSE);
     if (!NT_SUCCESS(status))
         goto fail1;
 
@@ -459,14 +459,14 @@ RangeSetAddAfter(
 fail1:
     Error("fail1 (%08x)\n", status);
 
-    return status;    
+    return status;
 }
 
 static NTSTATUS
 RangeSetAddBefore(
-    IN  PXENBUS_RANGE_SET   RangeSet,
-    IN  LONGLONG            Start,
-    IN  LONGLONG            End
+    _In_ PXENBUS_RANGE_SET  RangeSet,
+    _In_ LONGLONG           Start,
+    _In_ LONGLONG           End
     )
 {
     PLIST_ENTRY             Cursor;
@@ -492,7 +492,7 @@ RangeSetAddBefore(
     }
 
     RangeSet->Cursor = Cursor;
-    status = RangeSetAdd(RangeSet, Start, End, TRUE);    
+    status = RangeSetAdd(RangeSet, Start, End, TRUE);
     if (!NT_SUCCESS(status))
         goto fail1;
 
@@ -501,15 +501,15 @@ RangeSetAddBefore(
 fail1:
     Error("fail1 (%08x)\n", status);
 
-    return status;    
+    return status;
 }
 
 static NTSTATUS
 RangeSetPut(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_RANGE_SET       RangeSet,
-    IN  LONGLONG                Start,
-    IN  ULONGLONG               Count
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_RANGE_SET      RangeSet,
+    _In_ LONGLONG               Start,
+    _In_ ULONGLONG              Count
     )
 {
     LONGLONG                    End = Start + Count - 1;
@@ -567,9 +567,9 @@ fail1:
 
 NTSTATUS
 RangeSetCreate(
-    IN  PINTERFACE              Interface,
-    IN  const CHAR              *Name,
-    OUT PXENBUS_RANGE_SET       *RangeSet
+    _In_ PINTERFACE             Interface,
+    _In_ const CHAR             *Name,
+    _Out_ PXENBUS_RANGE_SET     *RangeSet
     )
 {
     PXENBUS_RANGE_SET_CONTEXT   Context = Interface->Context;
@@ -619,8 +619,8 @@ fail1:
 
 VOID
 RangeSetDestroy(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_RANGE_SET       RangeSet
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_RANGE_SET      RangeSet
     )
 {
     PXENBUS_RANGE_SET_CONTEXT   Context = Interface->Context;
@@ -638,7 +638,7 @@ RangeSetDestroy(
         __RangeSetFree(RangeSet->Spare);
         RangeSet->Spare = NULL;
     }
-        
+
     ASSERT(__RangeSetIsEmpty(RangeSet));
     RtlZeroMemory(&RangeSet->List, sizeof (LIST_ENTRY));
     RtlZeroMemory(&RangeSet->Lock, sizeof (KSPIN_LOCK));
@@ -655,8 +655,8 @@ RangeSetDestroy(
 
 static VOID
 RangeSetDump(
-    IN  PXENBUS_RANGE_SET_CONTEXT   Context,
-    IN  PXENBUS_RANGE_SET           RangeSet
+    _In_ PXENBUS_RANGE_SET_CONTEXT  Context,
+    _In_ PXENBUS_RANGE_SET          RangeSet
     )
 {
     XENBUS_DEBUG(Printf,
@@ -700,8 +700,8 @@ RangeSetDump(
 
 static VOID
 RangeSetDebugCallback(
-    IN  PVOID                   Argument,
-    IN  BOOLEAN                 Crashing
+    _In_ PVOID                  Argument,
+    _In_ BOOLEAN                Crashing
     )
 {
     PXENBUS_RANGE_SET_CONTEXT   Context = Argument;
@@ -729,7 +729,7 @@ RangeSetDebugCallback(
 
 static NTSTATUS
 RangeSetAcquire(
-    IN  PINTERFACE              Interface
+    _In_ PINTERFACE             Interface
     )
 {
     PXENBUS_RANGE_SET_CONTEXT   Context = Interface->Context;
@@ -780,7 +780,7 @@ fail1:
 
 static VOID
 RangeSetRelease(
-    IN  PINTERFACE              Interface
+    _In_ PINTERFACE             Interface
     )
 {
     PXENBUS_RANGE_SET_CONTEXT   Context = Interface->Context;
@@ -819,11 +819,11 @@ static struct _XENBUS_RANGE_SET_INTERFACE_V1 RangeSetInterfaceVersion1 = {
     RangeSetGet,
     RangeSetDestroy
 };
-                     
+
 NTSTATUS
 RangeSetInitialize(
-    IN  PXENBUS_FDO                 Fdo,
-    OUT PXENBUS_RANGE_SET_CONTEXT   *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_RANGE_SET_CONTEXT *Context
     )
 {
     NTSTATUS                        status;
@@ -860,13 +860,13 @@ fail1:
 
 NTSTATUS
 RangeSetGetInterface(
-    IN      PXENBUS_RANGE_SET_CONTEXT   Context,
-    IN      ULONG                       Version,
-    IN OUT  PINTERFACE                  Interface,
-    IN      ULONG                       Size
+    _In_ PXENBUS_RANGE_SET_CONTEXT  Context,
+    _In_ ULONG                      Version,
+    _Inout_ PINTERFACE              Interface,
+    _In_ ULONG                      Size
     )
 {
-    NTSTATUS                            status;
+    NTSTATUS                        status;
 
     ASSERT(Context != NULL);
 
@@ -894,11 +894,11 @@ RangeSetGetInterface(
     }
 
     return status;
-}   
+}
 
 ULONG
 RangeSetGetReferences(
-    IN  PXENBUS_RANGE_SET_CONTEXT   Context
+    _In_ PXENBUS_RANGE_SET_CONTEXT  Context
     )
 {
     return Context->References;
@@ -906,7 +906,7 @@ RangeSetGetReferences(
 
 VOID
 RangeSetTeardown(
-    IN  PXENBUS_RANGE_SET_CONTEXT   Context
+    _In_ PXENBUS_RANGE_SET_CONTEXT  Context
     )
 {
     Trace("====>\n");
diff --git a/src/xenbus/range_set.h b/src/xenbus/range_set.h
index cce7a2b..678afd7 100644
--- a/src/xenbus/range_set.h
+++ b/src/xenbus/range_set.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -43,26 +43,26 @@ typedef struct _XENBUS_RANGE_SET_CONTEXT  XENBUS_RANGE_SET_CONTEXT, *PXENBUS_RAN
 
 extern NTSTATUS
 RangeSetInitialize(
-    IN  PXENBUS_FDO                 Fdo,
-    OUT PXENBUS_RANGE_SET_CONTEXT   *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_RANGE_SET_CONTEXT *Context
     );
 
 extern NTSTATUS
 RangeSetGetInterface(
-    IN      PXENBUS_RANGE_SET_CONTEXT   Context,
-    IN      ULONG                       Version,
-    IN OUT  PINTERFACE                  Interface,
-    IN      ULONG                       Size
+    _In_ PXENBUS_RANGE_SET_CONTEXT  Context,
+    _In_ ULONG                      Version,
+    _Inout_ PINTERFACE              Interface,
+    _In_ ULONG                      Size
     );
 
 extern ULONG
 RangeSetGetReferences(
-    IN  PXENBUS_RANGE_SET_CONTEXT   Context
+    _In_ PXENBUS_RANGE_SET_CONTEXT  Context
     );
 
 extern VOID
 RangeSetTeardown(
-    IN  PXENBUS_RANGE_SET_CONTEXT   Context
+    _In_ PXENBUS_RANGE_SET_CONTEXT  Context
     );
 
 #endif  // _XENBUS_RANGE_SET_H
diff --git a/src/xenbus/shared_info.c b/src/xenbus/shared_info.c
index dc456eb..84056b7 100644
--- a/src/xenbus/shared_info.c
+++ b/src/xenbus/shared_info.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -67,7 +67,7 @@ struct _XENBUS_SHARED_INFO_CONTEXT {
 
 static FORCEINLINE PVOID
 __SharedInfoAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_SHARED_INFO_TAG);
@@ -75,7 +75,7 @@ __SharedInfoAllocate(
 
 static FORCEINLINE VOID
 __SharedInfoFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_SHARED_INFO_TAG);
@@ -83,8 +83,8 @@ __SharedInfoFree(
 
 static BOOLEAN
 SharedInfoSetBit(
-    IN  ULONG_PTR volatile  *Mask,
-    IN  ULONG               Bit
+    _In_ ULONG_PTR volatile *Mask,
+    _In_ ULONG              Bit
     )
 {
     ASSERT3U(Bit, <, sizeof (ULONG_PTR) * 8);
@@ -97,8 +97,8 @@ SharedInfoSetBit(
 
 static BOOLEAN
 SharedInfoClearBit(
-    IN  ULONG_PTR volatile  *Mask,
-    IN  ULONG               Bit
+    _In_ ULONG_PTR volatile *Mask,
+    _In_ ULONG              Bit
     )
 {
     ASSERT3U(Bit, <, sizeof (ULONG_PTR) * 8);
@@ -111,8 +111,8 @@ SharedInfoClearBit(
 
 static BOOLEAN
 SharedInfoClearBitUnlocked(
-    IN  ULONG_PTR   *Mask,
-    IN  ULONG       Bit
+    _In_ ULONG_PTR  *Mask,
+    _In_ ULONG      Bit
     )
 {
     ULONG_PTR       Old;
@@ -129,8 +129,8 @@ SharedInfoClearBitUnlocked(
 
 static BOOLEAN
 SharedInfoTestBit(
-    IN  ULONG_PTR   *Mask,
-    IN  ULONG       Bit
+    _In_ ULONG_PTR  *Mask,
+    _In_ ULONG      Bit
     )
 {
     ASSERT3U(Bit, <, sizeof (ULONG_PTR) * 8);
@@ -142,11 +142,11 @@ SharedInfoTestBit(
 
 static VOID
 SharedInfoEvtchnMaskAll(
-    IN  PXENBUS_SHARED_INFO_CONTEXT Context
+    _In_ PXENBUS_SHARED_INFO_CONTEXT    Context
     )
 {
-    shared_info_t                   *Shared;
-    ULONG                           Port;
+    shared_info_t                       *Shared;
+    ULONG                               Port;
 
     Shared = Context->Shared;
 
@@ -163,8 +163,8 @@ SharedInfoEvtchnMaskAll(
 
 static BOOLEAN
 SharedInfoUpcallSupported(
-    IN  PINTERFACE                  Interface,
-    IN  ULONG                       Index
+    _In_ PINTERFACE                 Interface,
+    _In_ ULONG                      Index
     )
 {
     PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
@@ -177,8 +177,8 @@ SharedInfoUpcallSupported(
 
 static BOOLEAN
 SharedInfoUpcallPending(
-    IN  PINTERFACE                  Interface,
-    IN  ULONG                       Index
+    _In_ PINTERFACE                 Interface,
+    _In_ ULONG                      Index
     )
 {
     PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
@@ -202,10 +202,10 @@ SharedInfoUpcallPending(
 
 static BOOLEAN
 SharedInfoEvtchnPoll(
-    IN  PINTERFACE                  Interface,
-    IN  ULONG                       Index,
-    IN  XENBUS_SHARED_INFO_EVENT    Event,
-    IN  PVOID                       Argument OPTIONAL
+    _In_ PINTERFACE                 Interface,
+    _In_ ULONG                      Index,
+    _In_ XENBUS_SHARED_INFO_EVENT   Event,
+    _In_opt_ PVOID                  Argument
     )
 {
     PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
@@ -277,8 +277,8 @@ done:
 
 static VOID
 SharedInfoEvtchnAck(
-    IN  PINTERFACE              Interface,
-    IN  ULONG                   Port
+    _In_ PINTERFACE             Interface,
+    _In_ ULONG                  Port
     )
 {
     PXENBUS_SHARED_INFO_CONTEXT Context = Interface->Context;
@@ -296,8 +296,8 @@ SharedInfoEvtchnAck(
 
 static VOID
 SharedInfoEvtchnMask(
-    IN  PINTERFACE              Interface,
-    IN  ULONG                   Port
+    _In_ PINTERFACE             Interface,
+    _In_ ULONG                  Port
     )
 {
     PXENBUS_SHARED_INFO_CONTEXT Context = Interface->Context;
@@ -315,8 +315,8 @@ SharedInfoEvtchnMask(
 
 static BOOLEAN
 SharedInfoEvtchnUnmask(
-    IN  PINTERFACE              Interface,
-    IN  ULONG                   Port
+    _In_ PINTERFACE             Interface,
+    _In_ ULONG                  Port
     )
 {
     PXENBUS_SHARED_INFO_CONTEXT Context = Interface->Context;
@@ -339,9 +339,9 @@ SharedInfoEvtchnUnmask(
 
 static VOID
 SharedInfoGetTime(
-    IN  PINTERFACE                  Interface,
-    OUT PLARGE_INTEGER              Time,
-    OUT PBOOLEAN                    Local
+    _In_ PINTERFACE                 Interface,
+    _Out_ PLARGE_INTEGER            Time,
+    _Out_opt_ PBOOLEAN              Local
     )
 {
 #define NS_PER_S 1000000000ull
@@ -444,7 +444,7 @@ SharedInfoGetTime(
 
 static LARGE_INTEGER
 SharedInfoGetTimeVersion2(
-    IN  PINTERFACE  Interface
+    _In_ PINTERFACE Interface
     )
 {
     LARGE_INTEGER   Time;
@@ -456,12 +456,12 @@ SharedInfoGetTimeVersion2(
 
 static VOID
 SharedInfoMap(
-    IN  PXENBUS_SHARED_INFO_CONTEXT Context
+    _In_ PXENBUS_SHARED_INFO_CONTEXT    Context
     )
 {
-    PFN_NUMBER                      Pfn;
-    PHYSICAL_ADDRESS                Address;
-    NTSTATUS                        status;
+    PFN_NUMBER                          Pfn;
+    PHYSICAL_ADDRESS                    Address;
+    NTSTATUS                            status;
 
     Pfn = MmGetMdlPfnArray(Context->Mdl)[0];
 
@@ -478,10 +478,10 @@ SharedInfoMap(
 
 static VOID
 SharedInfoUnmap(
-    IN  PXENBUS_SHARED_INFO_CONTEXT Context
+    _In_ PXENBUS_SHARED_INFO_CONTEXT    Context
     )
 {
-    PFN_NUMBER                      Pfn;
+    PFN_NUMBER                          Pfn;
 
     LogPrintf(LOG_LEVEL_INFO,
               "SHARED_INFO: UNMAP XENMAPSPACE_shared_info\n");
@@ -493,7 +493,7 @@ SharedInfoUnmap(
 
 static VOID
 SharedInfoSuspendCallbackEarly(
-    IN  PVOID                   Argument
+    _In_ PVOID                  Argument
     )
 {
     PXENBUS_SHARED_INFO_CONTEXT Context = Argument;
@@ -504,8 +504,8 @@ SharedInfoSuspendCallbackEarly(
 
 static VOID
 SharedInfoDebugCallback(
-    IN  PVOID                   Argument,
-    IN  BOOLEAN                 Crashing
+    _In_ PVOID                  Argument,
+    _In_ BOOLEAN                Crashing
     )
 {
     PXENBUS_SHARED_INFO_CONTEXT Context = Argument;
@@ -587,7 +587,7 @@ SharedInfoDebugCallback(
 
 static NTSTATUS
 SharedInfoAcquire(
-    IN  PINTERFACE                  Interface
+    _In_ PINTERFACE                 Interface
     )
 {
     PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
@@ -748,7 +748,7 @@ fail1:
 
 static VOID
 SharedInfoRelease (
-    IN  PINTERFACE                  Interface
+    _In_ PINTERFACE                 Interface
     )
 {
     PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
@@ -828,7 +828,7 @@ static struct _XENBUS_SHARED_INFO_INTERFACE_V3 SharedInfoInterfaceVersion3 = {
     SharedInfoEvtchnUnmask,
     SharedInfoGetTime
 };
-                     
+
 static struct _XENBUS_SHARED_INFO_INTERFACE_V4 SharedInfoInterfaceVersion4 = {
     { sizeof (struct _XENBUS_SHARED_INFO_INTERFACE_V4), 4, NULL, NULL, NULL },
     SharedInfoAcquire,
@@ -844,11 +844,11 @@ static struct _XENBUS_SHARED_INFO_INTERFACE_V4 SharedInfoInterfaceVersion4 = {
 
 NTSTATUS
 SharedInfoInitialize(
-    IN  PXENBUS_FDO                 Fdo,
-    OUT PXENBUS_SHARED_INFO_CONTEXT *Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Out_ PXENBUS_SHARED_INFO_CONTEXT   *Context
     )
 {
-    NTSTATUS                        status;
+    NTSTATUS                            status;
 
     Trace("====>\n");
 
@@ -888,10 +888,10 @@ fail1:
 
 NTSTATUS
 SharedInfoGetInterface(
-    IN      PXENBUS_SHARED_INFO_CONTEXT Context,
-    IN      ULONG                       Version,
-    IN OUT  PINTERFACE                  Interface,
-    IN      ULONG                       Size
+    _In_ PXENBUS_SHARED_INFO_CONTEXT    Context,
+    _In_ ULONG                          Version,
+    _Inout_ PINTERFACE                  Interface,
+    _In_ ULONG                          Size
     )
 {
     NTSTATUS                            status;
@@ -956,11 +956,11 @@ SharedInfoGetInterface(
     }
 
     return status;
-}   
+}
 
 ULONG
 SharedInfoGetReferences(
-    IN  PXENBUS_SHARED_INFO_CONTEXT Context
+    _In_ PXENBUS_SHARED_INFO_CONTEXT    Context
     )
 {
     return Context->References;
@@ -968,7 +968,7 @@ SharedInfoGetReferences(
 
 VOID
 SharedInfoTeardown(
-    IN  PXENBUS_SHARED_INFO_CONTEXT Context
+    _In_ PXENBUS_SHARED_INFO_CONTEXT    Context
     )
 {
     Trace("====>\n");
diff --git a/src/xenbus/shared_info.h b/src/xenbus/shared_info.h
index 9b88288..af4221c 100644
--- a/src/xenbus/shared_info.h
+++ b/src/xenbus/shared_info.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -43,26 +43,26 @@ typedef struct _XENBUS_SHARED_INFO_CONTEXT  XENBUS_SHARED_INFO_CONTEXT, *PXENBUS
 
 extern NTSTATUS
 SharedInfoInitialize(
-    IN  PXENBUS_FDO                 Fdo,
-    OUT PXENBUS_SHARED_INFO_CONTEXT *Context
+    _In_ PXENBUS_FDO                    Fdo,
+    _Out_ PXENBUS_SHARED_INFO_CONTEXT   *Context
     );
 
 extern NTSTATUS
 SharedInfoGetInterface(
-    IN      PXENBUS_SHARED_INFO_CONTEXT Context,
-    IN      ULONG                       Version,
-    IN OUT  PINTERFACE                  Interface,
-    IN      ULONG                       Size
+    _In_ PXENBUS_SHARED_INFO_CONTEXT    Context,
+    _In_ ULONG                          Version,
+    _Inout_ PINTERFACE                  Interface,
+    _In_ ULONG                          Size
     );
 
 extern ULONG
 SharedInfoGetReferences(
-    IN  PXENBUS_SHARED_INFO_CONTEXT Context
+    _In_ PXENBUS_SHARED_INFO_CONTEXT    Context
     );
 
 extern VOID
 SharedInfoTeardown(
-    IN  PXENBUS_SHARED_INFO_CONTEXT Context
+    _In_ PXENBUS_SHARED_INFO_CONTEXT    Context
     );
 
 #endif  // _XENBUS_SHARED_INFO_H
diff --git a/src/xenbus/store.c b/src/xenbus/store.c
index 02cdd17..0a0ee94 100644
--- a/src/xenbus/store.c
+++ b/src/xenbus/store.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -158,7 +158,7 @@ C_ASSERT(sizeof (struct xenstore_domain_interface) <= PAGE_SIZE);
 
 static FORCEINLINE PVOID
 __StoreAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_STORE_TAG);
@@ -166,7 +166,7 @@ __StoreAllocate(
 
 static FORCEINLINE VOID
 __StoreFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_STORE_TAG);
@@ -174,17 +174,17 @@ __StoreFree(
 
 static NTSTATUS
 StorePrepareRequest(
-    IN  PXENBUS_STORE_CONTEXT       Context,
-    OUT PXENBUS_STORE_REQUEST       Request,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction OPTIONAL,
-    IN  enum xsd_sockmsg_type       Type,
-    IN  ...
+    _In_ PXENBUS_STORE_CONTEXT          Context,
+    _Out_ PXENBUS_STORE_REQUEST         Request,
+    _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_ enum xsd_sockmsg_type          Type,
+    ...
     )
 {
-    ULONG                           Id;
-    PXENBUS_STORE_SEGMENT           Segment;
-    va_list                         Arguments;
-    NTSTATUS                        status;
+    ULONG                               Id;
+    PXENBUS_STORE_SEGMENT               Segment;
+    va_list                             Arguments;
+    NTSTATUS                            status;
 
     ASSERT(IsZeroMemory(Request, sizeof (XENBUS_STORE_REQUEST)));
 
@@ -218,7 +218,7 @@ StorePrepareRequest(
 
         Data = va_arg(Arguments, PCHAR);
         Length = va_arg(Arguments, ULONG);
-        
+
         if (Data == NULL) {
             ASSERT3U(Length, ==, 0);
             break;
@@ -254,9 +254,9 @@ fail1:
 
 static ULONG
 StoreCopyToRing(
-    IN  PXENBUS_STORE_CONTEXT           Context,
-    IN  PCHAR                           Data,
-    IN  ULONG                           Length
+    _In_ PXENBUS_STORE_CONTEXT          Context,
+    _In_ PCHAR                          Data,
+    _In_ ULONG                          Length
     )
 {
     struct xenstore_domain_interface    *Shared;
@@ -303,14 +303,14 @@ StoreCopyToRing(
 
     KeMemoryBarrier();
 
-    return Offset;    
+    return Offset;
 }
 
 static NTSTATUS
 StoreSendSegment(
-    IN      PXENBUS_STORE_CONTEXT   Context,
-    IN OUT  PXENBUS_STORE_SEGMENT   Segment,
-    IN OUT  PULONG                  Written
+    _In_ PXENBUS_STORE_CONTEXT      Context,
+    _Inout_ PXENBUS_STORE_SEGMENT   Segment,
+    _Inout_ PULONG                  Written
     )
 {
     ULONG                           Copied;
@@ -328,8 +328,8 @@ StoreSendSegment(
 
 static VOID
 StoreSendRequests(
-    IN      PXENBUS_STORE_CONTEXT   Context,
-    IN OUT  PULONG                  Written
+    _In_ PXENBUS_STORE_CONTEXT      Context,
+    _Inout_ PULONG                  Written
     )
 {
     if (IsListEmpty(&Context->SubmittedList))
@@ -371,9 +371,9 @@ StoreSendRequests(
 
 static ULONG
 StoreCopyFromRing(
-    IN  PXENBUS_STORE_CONTEXT           Context,
-    IN  PCHAR                           Data,
-    IN  ULONG                           Length
+    _In_ PXENBUS_STORE_CONTEXT          Context,
+    _In_ PCHAR                          Data,
+    _In_ ULONG                          Length
     )
 {
     struct xenstore_domain_interface    *Shared;
@@ -420,14 +420,14 @@ StoreCopyFromRing(
 
     KeMemoryBarrier();
 
-    return Offset;    
+    return Offset;
 }
 
 static NTSTATUS
 StoreReceiveSegment(
-    IN      PXENBUS_STORE_CONTEXT   Context,
-    IN OUT  PXENBUS_STORE_SEGMENT   Segment,
-    IN OUT  PULONG                  Read
+    _In_ PXENBUS_STORE_CONTEXT      Context,
+    _Inout_ PXENBUS_STORE_SEGMENT   Segment,
+    _Inout_ PULONG                  Read
     )
 {
     ULONG                           Copied;
@@ -445,7 +445,7 @@ StoreReceiveSegment(
 
 static BOOLEAN
 StoreIgnoreHeaderType(
-    IN  ULONG   Type
+    _In_ ULONG  Type
     )
 {
     switch (Type) {
@@ -495,13 +495,13 @@ StoreVerifyHeader(
         Valid = FALSE;
     }
 
-    return Valid;    
+    return Valid;
 }
 
 static NTSTATUS
 StoreReceiveResponse(
-    IN      PXENBUS_STORE_CONTEXT   Context,
-    IN OUT  PULONG                  Read
+    _In_ PXENBUS_STORE_CONTEXT      Context,
+    _Inout_ PULONG                  Read
     )
 {
     PXENBUS_STORE_RESPONSE          Response = &Context->Response;
@@ -530,13 +530,13 @@ payload:
                                  Read);
 
 done:
-    return status;    
+    return status;
 }
 
 static PXENBUS_STORE_REQUEST
 StoreFindRequest(
-    IN  PXENBUS_STORE_CONTEXT   Context,
-    IN  uint32_t                req_id
+    _In_ PXENBUS_STORE_CONTEXT  Context,
+    _In_ uint32_t               req_id
     )
 {
     PLIST_ENTRY                 ListEntry;
@@ -560,8 +560,8 @@ StoreFindRequest(
 
 static PXENBUS_STORE_WATCH
 StoreFindWatch(
-    IN  PXENBUS_STORE_CONTEXT   Context,
-    IN  USHORT                  Id
+    _In_ PXENBUS_STORE_CONTEXT  Context,
+    _In_ USHORT                 Id
     )
 {
     PLIST_ENTRY                 ListEntry;
@@ -585,7 +585,7 @@ StoreFindWatch(
 
 static USHORT
 StoreNextWatchId(
-    IN  PXENBUS_STORE_CONTEXT   Context
+    _In_ PXENBUS_STORE_CONTEXT  Context
     )
 {
     USHORT                      Id;
@@ -609,14 +609,14 @@ StoreNextWatchId(
 
 static NTSTATUS
 StoreParseWatchEvent(
-    IN  PCHAR   Data,
-    IN  ULONG   Length,
-    OUT PCHAR   *Path,
-    OUT PVOID   *Caller,
-    OUT PUSHORT Id
+    _In_ PCHAR      Data,
+    _In_ ULONG      Length,
+    _Out_ PCHAR     *Path,
+    _Out_ PVOID     *Caller,
+    _Out_ PUSHORT   Id
     )
 {
-    PCHAR       End;
+    PCHAR           End;
 
     *Path = Data;
     while (*Data != '\0' && Length != 0) {
@@ -678,7 +678,7 @@ fail1:
 
 static VOID
 StoreProcessWatchEvent(
-    IN  PXENBUS_STORE_CONTEXT   Context
+    _In_ PXENBUS_STORE_CONTEXT  Context
     )
 {
     PXENBUS_STORE_RESPONSE      Response;
@@ -730,7 +730,7 @@ StoreProcessWatchEvent(
 
 static VOID
 StoreResetResponse(
-    IN  PXENBUS_STORE_CONTEXT   Context
+    _In_ PXENBUS_STORE_CONTEXT  Context
     )
 {
     PXENBUS_STORE_RESPONSE      Response;
@@ -749,11 +749,11 @@ StoreResetResponse(
 
 static VOID
 StoreCopyResponse(
-    IN  PXENBUS_STORE_CONTEXT   Context,
-    OUT PXENBUS_STORE_RESPONSE  Response
+    _In_ PXENBUS_STORE_CONTEXT      Context,
+    _Out_ PXENBUS_STORE_RESPONSE    Response
     )
 {
-    PXENBUS_STORE_SEGMENT       Segment;
+    PXENBUS_STORE_SEGMENT           Segment;
 
     ASSERT(Response != NULL);
     *Response = Context->Response;
@@ -773,15 +773,15 @@ StoreCopyResponse(
 
 static VOID
 StoreFreeResponse(
-    IN  PXENBUS_STORE_RESPONSE  Response
+    _In_ PXENBUS_STORE_RESPONSE Response
     )
 {
-    __StoreFree(Response);    
+    __StoreFree(Response);
 }
 
 static VOID
 StoreProcessResponse(
-    IN  PXENBUS_STORE_CONTEXT   Context
+    _In_ PXENBUS_STORE_CONTEXT  Context
     )
 {
     PXENBUS_STORE_RESPONSE      Response;
@@ -822,7 +822,7 @@ StoreProcessResponse(
 
 static ULONG
 StorePollLocked(
-    IN  PXENBUS_STORE_CONTEXT   Context
+    _In_ PXENBUS_STORE_CONTEXT  Context
     )
 {
     ULONG                       Count;
@@ -865,7 +865,7 @@ StorePollLocked(
 
 static FORCEINLINE VOID
 __StorePoll(
-    IN  PXENBUS_STORE_CONTEXT   Context
+    _In_ PXENBUS_STORE_CONTEXT  Context
     )
 {
     KeAcquireSpinLockAtDpcLevel(&Context->Lock);
@@ -882,10 +882,10 @@ _IRQL_requires_(DISPATCH_LEVEL)
 _IRQL_requires_same_
 VOID
 StoreDpc(
-    IN  PKDPC               Dpc,
-    IN  PVOID               _Context,
-    IN  PVOID               Argument1,
-    IN  PVOID               Argument2
+    _In_ PKDPC              Dpc,
+    _In_ PVOID              _Context,
+    _In_ PVOID              Argument1,
+    _In_ PVOID              Argument2
     )
 {
     PXENBUS_STORE_CONTEXT   Context = _Context;
@@ -907,8 +907,8 @@ StoreDpc(
 
 static PXENBUS_STORE_RESPONSE
 StoreSubmitRequest(
-    IN  PXENBUS_STORE_CONTEXT   Context,
-    IN  PXENBUS_STORE_REQUEST   Request
+    _In_ PXENBUS_STORE_CONTEXT  Context,
+    _In_ PXENBUS_STORE_REQUEST  Request
     )
 {
     PXENBUS_STORE_RESPONSE      Response;
@@ -979,7 +979,7 @@ fail1:
 
 static NTSTATUS
 StoreCheckResponse(
-    IN  PXENBUS_STORE_RESPONSE  Response
+    _In_ PXENBUS_STORE_RESPONSE Response
     )
 {
     NTSTATUS                    status;
@@ -1003,7 +1003,7 @@ StoreCheckResponse(
              Index < sizeof (xsd_errors) / sizeof (xsd_errors[0]);
              Index++) {
             struct xsd_errors   *Entry = &xsd_errors[Index];
-            
+
             if (strncmp(Error, Entry->errstring, Length) == 0) {
                 ERRNO_TO_STATUS(Entry->errnum, status);
                 goto done;
@@ -1019,9 +1019,9 @@ done:
 
 static PXENBUS_STORE_BUFFER
 StoreCopyPayload(
-    IN  PXENBUS_STORE_CONTEXT   Context,
-    IN  PXENBUS_STORE_RESPONSE  Response,
-    IN  PVOID                   Caller
+    _In_ PXENBUS_STORE_CONTEXT  Context,
+    _In_ PXENBUS_STORE_RESPONSE Response,
+    _In_ PVOID                  Caller
     )
 {
     PCHAR                       Data;
@@ -1061,8 +1061,8 @@ fail1:
 
 static VOID
 StoreFreePayload(
-    IN  PXENBUS_STORE_CONTEXT   Context,
-    IN  PXENBUS_STORE_BUFFER    Buffer
+    _In_ PXENBUS_STORE_CONTEXT  Context,
+    _In_ PXENBUS_STORE_BUFFER   Buffer
     )
 {
     KIRQL                       Irql;
@@ -1078,8 +1078,8 @@ StoreFreePayload(
 
 static VOID
 StoreFree(
-    IN  PINTERFACE          Interface,
-    IN  PCHAR               Value
+    _In_ PINTERFACE         Interface,
+    _In_ PCHAR              Value
     )
 {
     PXENBUS_STORE_CONTEXT   Context = Interface->Context;
@@ -1100,22 +1100,22 @@ RtlCaptureStackBackTrace(
 
 static NTSTATUS
 StoreRead(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction OPTIONAL,
-    IN  PCHAR                       Prefix OPTIONAL,
-    IN  PCHAR                       Node,
-    OUT PCHAR                       *Value
+    _In_ PINTERFACE                     Interface,
+    _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_opt_ PCHAR                      Prefix,
+    _In_ PCHAR                          Node,
+    _Out_ PCHAR                         *Value
     )
 {
-    PXENBUS_STORE_CONTEXT           Context = Interface->Context;
-    PVOID                           Caller;
-    XENBUS_STORE_REQUEST            Request;
-    KIRQL                           Irql;
-    PXENBUS_STORE_RESPONSE          Response;
-    PXENBUS_STORE_BUFFER            Buffer;
-    NTSTATUS                        status;
+    PXENBUS_STORE_CONTEXT               Context = Interface->Context;
+    PVOID                               Caller;
+    XENBUS_STORE_REQUEST                Request;
+    KIRQL                               Irql;
+    PXENBUS_STORE_RESPONSE              Response;
+    PXENBUS_STORE_BUFFER                Buffer;
+    NTSTATUS                            status;
 
-    (VOID) RtlCaptureStackBackTrace(1, 1, &Caller, NULL);    
+    (VOID) RtlCaptureStackBackTrace(1, 1, &Caller, NULL);
 
     RtlZeroMemory(&Request, sizeof (XENBUS_STORE_REQUEST));
 
@@ -1182,17 +1182,17 @@ fail1:
 
 static NTSTATUS
 StoreWrite(
-    IN  PXENBUS_STORE_CONTEXT       Context,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction OPTIONAL,
-    IN  PCHAR                       Prefix OPTIONAL,
-    IN  PCHAR                       Node,
-    IN  PCHAR                       Value
+    _In_ PXENBUS_STORE_CONTEXT          Context,
+    _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_opt_ PCHAR                      Prefix,
+    _In_ PCHAR                          Node,
+    _In_ PCHAR                          Value
     )
 {
-    XENBUS_STORE_REQUEST            Request;
-    KIRQL                           Irql;
-    PXENBUS_STORE_RESPONSE          Response;
-    NTSTATUS                        status;
+    XENBUS_STORE_REQUEST                Request;
+    KIRQL                               Irql;
+    PXENBUS_STORE_RESPONSE              Response;
+    NTSTATUS                            status;
 
     RtlZeroMemory(&Request, sizeof (XENBUS_STORE_REQUEST));
 
@@ -1252,18 +1252,18 @@ fail1:
 
 static NTSTATUS
 StoreVPrintf(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction OPTIONAL,
-    IN  PCHAR                       Prefix OPTIONAL,
-    IN  PCHAR                       Node,
-    IN  const CHAR                  *Format,
-    IN  va_list                     Arguments
+    _In_ PINTERFACE                     Interface,
+    _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_opt_ PCHAR                      Prefix,
+    _In_ PCHAR                          Node,
+    _In_ const CHAR                     *Format,
+    _In_ va_list                        Arguments
     )
 {
-    PXENBUS_STORE_CONTEXT           Context = Interface->Context;
-    PCHAR                           Buffer;
-    ULONG                           Length;
-    NTSTATUS                        status;
+    PXENBUS_STORE_CONTEXT               Context = Interface->Context;
+    PCHAR                               Buffer;
+    ULONG                               Length;
+    NTSTATUS                            status;
 
     Length = 32;
     for (;;) {
@@ -1314,16 +1314,16 @@ fail1:
 
 static NTSTATUS
 StorePrintf(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction OPTIONAL,
-    IN  PCHAR                       Prefix OPTIONAL,
-    IN  PCHAR                       Node,
-    IN  const CHAR                  *Format,
+    _In_ PINTERFACE                     Interface,
+    _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_opt_ PCHAR                      Prefix,
+    _In_ PCHAR                          Node,
+    _In_ const CHAR                     *Format,
     ...
     )
 {
-    va_list                         Arguments;
-    NTSTATUS                        status;
+    va_list                             Arguments;
+    NTSTATUS                            status;
 
     va_start(Arguments, Format);
     status = StoreVPrintf(Interface,
@@ -1339,17 +1339,17 @@ StorePrintf(
 
 static NTSTATUS
 StoreRemove(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction OPTIONAL,
-    IN  PCHAR                       Prefix OPTIONAL,
-    IN  PCHAR                       Node
+    _In_ PINTERFACE                     Interface,
+    _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_opt_ PCHAR                      Prefix,
+    _In_ PCHAR                          Node
     )
 {
-    PXENBUS_STORE_CONTEXT           Context = Interface->Context;
-    XENBUS_STORE_REQUEST            Request;
-    KIRQL                           Irql;
-    PXENBUS_STORE_RESPONSE          Response;
-    NTSTATUS                        status;
+    PXENBUS_STORE_CONTEXT               Context = Interface->Context;
+    XENBUS_STORE_REQUEST                Request;
+    KIRQL                               Irql;
+    PXENBUS_STORE_RESPONSE              Response;
+    NTSTATUS                            status;
 
     RtlZeroMemory(&Request, sizeof (XENBUS_STORE_REQUEST));
 
@@ -1407,22 +1407,22 @@ fail1:
 
 static NTSTATUS
 StoreDirectory(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction OPTIONAL,
-    IN  PCHAR                       Prefix OPTIONAL,
-    IN  PCHAR                       Node,
-    OUT PCHAR                       *Value
+    _In_ PINTERFACE                     Interface,
+    _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_opt_ PCHAR                      Prefix,
+    _In_ PCHAR                          Node,
+    _Out_ PCHAR                         *Value
     )
 {
-    PXENBUS_STORE_CONTEXT           Context = Interface->Context;
-    PVOID                           Caller;
-    XENBUS_STORE_REQUEST            Request;
-    KIRQL                           Irql;
-    PXENBUS_STORE_RESPONSE          Response;
-    PXENBUS_STORE_BUFFER            Buffer;
-    NTSTATUS                        status;
+    PXENBUS_STORE_CONTEXT               Context = Interface->Context;
+    PVOID                               Caller;
+    XENBUS_STORE_REQUEST                Request;
+    KIRQL                               Irql;
+    PXENBUS_STORE_RESPONSE              Response;
+    PXENBUS_STORE_BUFFER                Buffer;
+    NTSTATUS                            status;
 
-    (VOID) RtlCaptureStackBackTrace(1, 1, &Caller, NULL);    
+    (VOID) RtlCaptureStackBackTrace(1, 1, &Caller, NULL);
 
     RtlZeroMemory(&Request, sizeof (XENBUS_STORE_REQUEST));
 
@@ -1496,8 +1496,8 @@ fail1:
 
 static NTSTATUS
 StoreTransactionStart(
-    IN  PINTERFACE                  Interface,
-    OUT PXENBUS_STORE_TRANSACTION   *Transaction
+    _In_ PINTERFACE                 Interface,
+    _Out_ PXENBUS_STORE_TRANSACTION *Transaction
     )
 {
     PXENBUS_STORE_CONTEXT           Context = Interface->Context;
@@ -1513,7 +1513,7 @@ StoreTransactionStart(
         goto fail1;
 
     (*Transaction)->Magic = STORE_TRANSACTION_MAGIC;
-    (VOID) RtlCaptureStackBackTrace(1, 1, &(*Transaction)->Caller, NULL);    
+    (VOID) RtlCaptureStackBackTrace(1, 1, &(*Transaction)->Caller, NULL);
 
     RtlZeroMemory(&Request, sizeof (XENBUS_STORE_REQUEST));
 
@@ -1578,9 +1578,9 @@ fail1:
 
 static NTSTATUS
 StoreTransactionEnd(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction,
-    IN  BOOLEAN                     Commit
+    _In_ PINTERFACE                 Interface,
+    _In_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_ BOOLEAN                    Commit
     )
 {
     PXENBUS_STORE_CONTEXT           Context = Interface->Context;
@@ -1655,11 +1655,11 @@ fail1:
 
 static NTSTATUS
 StoreWatchAdd(
-    IN  PINTERFACE              Interface,
-    IN  PCHAR                   Prefix OPTIONAL,
-    IN  PCHAR                   Node,
-    IN  PKEVENT                 Event,
-    OUT PXENBUS_STORE_WATCH     *Watch
+    _In_ PINTERFACE             Interface,
+    _In_opt_ PCHAR              Prefix,
+    _In_ PCHAR                  Node,
+    _In_ PKEVENT                Event,
+    _Out_ PXENBUS_STORE_WATCH   *Watch
     )
 {
     PXENBUS_STORE_CONTEXT       Context = Interface->Context;
@@ -1678,7 +1678,7 @@ StoreWatchAdd(
         goto fail1;
 
     (*Watch)->Magic = STORE_WATCH_MAGIC;
-    (VOID) RtlCaptureStackBackTrace(1, 1, &(*Watch)->Caller, NULL);    
+    (VOID) RtlCaptureStackBackTrace(1, 1, &(*Watch)->Caller, NULL);
 
     if (Prefix == NULL)
         Length = (ULONG)strlen(Node) + sizeof (CHAR);
@@ -1695,7 +1695,7 @@ StoreWatchAdd(
              RtlStringCbPrintfA(Path, Length, "%s", Node) :
              RtlStringCbPrintfA(Path, Length, "%s/%s", Prefix, Node);
     ASSERT(NT_SUCCESS(status));
-    
+
     (*Watch)->Path = Path;
     (*Watch)->Event = Event;
 
@@ -1723,7 +1723,7 @@ StoreWatchAdd(
                                  XS_WATCH,
                                  Path, strlen(Path),
                                  "", 1,
-                                 Token, strlen(Token), 
+                                 Token, strlen(Token),
                                  "", 1,
                                  NULL, 0);
 
@@ -1786,8 +1786,8 @@ fail1:
 
 static NTSTATUS
 StoreWatchRemove(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_STORE_WATCH     Watch
+    _In_ PINTERFACE             Interface,
+    _In_ PXENBUS_STORE_WATCH    Watch
     )
 {
     PXENBUS_STORE_CONTEXT       Context = Interface->Context;
@@ -1823,7 +1823,7 @@ StoreWatchRemove(
                                  XS_UNWATCH,
                                  Path, strlen(Path),
                                  "", 1,
-                                 Token, strlen(Token), 
+                                 Token, strlen(Token),
                                  "", 1,
                                  NULL, 0);
 
@@ -1882,7 +1882,7 @@ fail1:
 
 static VOID
 StorePoll(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     __StorePoll(Interface->Context);
@@ -1897,8 +1897,8 @@ StorePoll(
 
 static NTSTATUS
 StoreWatchdog(
-    IN  PXENBUS_THREAD                  Self,
-    IN  PVOID                           _Context
+    _In_ PXENBUS_THREAD                 Self,
+    _In_ PVOID                          _Context
     )
 {
     PXENBUS_STORE_CONTEXT               Context = _Context;
@@ -1977,10 +1977,10 @@ StoreWatchdog(
 
 static NTSTATUS
 StorePermissionToString(
-    IN  PXENBUS_STORE_PERMISSION    Permission,
-    OUT PCHAR                       Buffer,
-    IN  ULONG                       BufferSize,
-    OUT PULONG                      UsedSize
+    _In_ PXENBUS_STORE_PERMISSION   Permission,
+    _Out_ PCHAR                     Buffer,
+    _In_ ULONG                      BufferSize,
+    _Out_ PULONG                    UsedSize
     )
 {
     size_t                          Remaining;
@@ -2035,25 +2035,25 @@ fail1:
 
 static NTSTATUS
 StorePermissionsSet(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction OPTIONAL,
-    IN  PCHAR                       Prefix OPTIONAL,
-    IN  PCHAR                       Node,
-    IN  PXENBUS_STORE_PERMISSION    Permissions,
-    IN  ULONG                       NumberPermissions
+    _In_ PINTERFACE                     Interface,
+    _In_opt_ PXENBUS_STORE_TRANSACTION  Transaction,
+    _In_opt_ PCHAR                      Prefix,
+    _In_ PCHAR                          Node,
+    _In_ PXENBUS_STORE_PERMISSION       Permissions,
+    _In_ ULONG                          NumberPermissions
     )
 {
-    PXENBUS_STORE_CONTEXT           Context = Interface->Context;
-    XENBUS_STORE_REQUEST            Request;
-    KIRQL                           Irql;
-    PXENBUS_STORE_RESPONSE          Response;
-    NTSTATUS                        status;
-    ULONG                           Index;
-    ULONG                           Length;
-    ULONG                           Used;
-    PCHAR                           Path;
-    PCHAR                           PermissionString;
-    PCHAR                           Segment;
+    PXENBUS_STORE_CONTEXT               Context = Interface->Context;
+    XENBUS_STORE_REQUEST                Request;
+    KIRQL                               Irql;
+    PXENBUS_STORE_RESPONSE              Response;
+    NTSTATUS                            status;
+    ULONG                               Index;
+    ULONG                               Length;
+    ULONG                               Used;
+    PCHAR                               Path;
+    PCHAR                               PermissionString;
+    PCHAR                               Segment;
 
     PermissionString = __StoreAllocate(XENSTORE_PAYLOAD_MAX);
 
@@ -2159,11 +2159,11 @@ _IRQL_requires_(HIGH_LEVEL)
 _IRQL_requires_same_
 BOOLEAN
 StoreEvtchnCallback(
-    IN  PKINTERRUPT InterruptObject,
-    IN  PVOID       Argument
+    _In_ PKINTERRUPT        InterruptObject,
+    _In_ PVOID              Argument
     )
 {
-    PXENBUS_STORE_CONTEXT  Context = Argument;
+    PXENBUS_STORE_CONTEXT   Context = Argument;
 
     UNREFERENCED_PARAMETER(InterruptObject);
 
@@ -2179,7 +2179,7 @@ StoreEvtchnCallback(
 
 static VOID
 StoreDisable(
-    IN PXENBUS_STORE_CONTEXT    Context
+    _In_ PXENBUS_STORE_CONTEXT  Context
     )
 {
     LogPrintf(LOG_LEVEL_INFO,
@@ -2195,7 +2195,7 @@ StoreDisable(
 
 static VOID
 StoreEnable(
-    IN PXENBUS_STORE_CONTEXT    Context
+    _In_ PXENBUS_STORE_CONTEXT  Context
     )
 {
     ULONGLONG                   Value;
@@ -2235,8 +2235,8 @@ StoreEnable(
 
 static
 StoreGetAddress(
-    IN  PXENBUS_STORE_CONTEXT   Context,
-    OUT PPHYSICAL_ADDRESS       Address
+    _In_ PXENBUS_STORE_CONTEXT  Context,
+    _Out_ PPHYSICAL_ADDRESS     Address
     )
 {
     PFN_NUMBER                  Pfn;
@@ -2267,7 +2267,7 @@ fail1:
 
 static VOID
 StoreSuspendCallbackEarly(
-    IN  PVOID               Argument
+    _In_ PVOID              Argument
     )
 {
     PXENBUS_STORE_CONTEXT   Context = Argument;
@@ -2296,7 +2296,7 @@ StoreSuspendCallbackEarly(
 
 static VOID
 StoreSuspendCallbackLate(
-    IN  PVOID                           Argument
+    _In_ PVOID                          Argument
     )
 {
     PXENBUS_STORE_CONTEXT               Context = Argument;
@@ -2330,8 +2330,8 @@ StoreSuspendCallbackLate(
 
 static VOID
 StoreDebugCallback(
-    IN  PVOID               Argument,
-    IN  BOOLEAN             Crashing
+    _In_ PVOID              Argument,
+    _In_ BOOLEAN            Crashing
     )
 {
     PXENBUS_STORE_CONTEXT   Context = Argument;
@@ -2481,7 +2481,7 @@ StoreDebugCallback(
 
 static NTSTATUS
 StoreAcquire(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_STORE_CONTEXT   Context = Interface->Context;
@@ -2625,11 +2625,11 @@ fail1:
 
 static VOID
 StoreRelease(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_STORE_CONTEXT   Context = Interface->Context;
-    KIRQL                   Irql;    
+    KIRQL                   Irql;
 
     KeAcquireSpinLock(&Context->Lock, &Irql);
 
@@ -2704,8 +2704,8 @@ static struct _XENBUS_STORE_INTERFACE_V2 StoreInterfaceVersion2 = {
 
 NTSTATUS
 StoreInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_STORE_CONTEXT   *Context
+    _In_ PXENBUS_FDO            Fdo,
+    _Out_ PXENBUS_STORE_CONTEXT *Context
     )
 {
     LARGE_INTEGER               Now;
@@ -2819,13 +2819,13 @@ fail1:
 
 NTSTATUS
 StoreGetInterface(
-    IN      PXENBUS_STORE_CONTEXT   Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_STORE_CONTEXT  Context,
+    _In_ ULONG                  Version,
+    _Inout_ PINTERFACE          Interface,
+    _In_ ULONG                  Size
     )
 {
-    NTSTATUS                        status;
+    NTSTATUS                    status;
 
     ASSERT(Context != NULL);
 
@@ -2853,11 +2853,11 @@ StoreGetInterface(
     }
 
     return status;
-}   
+}
 
 ULONG
 StoreGetReferences(
-    IN  PXENBUS_STORE_CONTEXT   Context
+    _In_ PXENBUS_STORE_CONTEXT  Context
     )
 {
     return Context->References;
@@ -2865,7 +2865,7 @@ StoreGetReferences(
 
 VOID
 StoreTeardown(
-    IN  PXENBUS_STORE_CONTEXT   Context
+    _In_ PXENBUS_STORE_CONTEXT  Context
     )
 {
     Trace("====>\n");
diff --git a/src/xenbus/store.h b/src/xenbus/store.h
index bf7d692..7f75d1e 100644
--- a/src/xenbus/store.h
+++ b/src/xenbus/store.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -43,26 +43,26 @@ typedef struct _XENBUS_STORE_CONTEXT  XENBUS_STORE_CONTEXT, *PXENBUS_STORE_CONTE
 
 extern NTSTATUS
 StoreInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_STORE_CONTEXT   *Context
+    _In_ PXENBUS_FDO            Fdo,
+    _Out_ PXENBUS_STORE_CONTEXT *Context
     );
 
 extern NTSTATUS
 StoreGetInterface(
-    IN      PXENBUS_STORE_CONTEXT   Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_STORE_CONTEXT  Context,
+    _In_ ULONG                  Version,
+    _Inout_ PINTERFACE          Interface,
+    _In_ ULONG                  Size
     );
 
 extern ULONG
 StoreGetReferences(
-    IN  PXENBUS_STORE_CONTEXT   Context
+    _In_ PXENBUS_STORE_CONTEXT  Context
     );
 
 extern VOID
 StoreTeardown(
-    IN  PXENBUS_STORE_CONTEXT   Context
+    _In_ PXENBUS_STORE_CONTEXT  Context
     );
 
 #endif  // _XENBUS_STORE_H
diff --git a/src/xenbus/suspend.c b/src/xenbus/suspend.c
index ffae491..ab403bf 100644
--- a/src/xenbus/suspend.c
+++ b/src/xenbus/suspend.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -63,7 +63,7 @@ struct _XENBUS_SUSPEND_CONTEXT {
 
 static FORCEINLINE PVOID
 __SuspendAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_SUSPEND_TAG);
@@ -71,7 +71,7 @@ __SuspendAllocate(
 
 static FORCEINLINE VOID
 __SuspendFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_SUSPEND_TAG);
@@ -79,11 +79,11 @@ __SuspendFree(
 
 static NTSTATUS
 SuspendRegister(
-    IN  PINTERFACE                      Interface,
-    IN  XENBUS_SUSPEND_CALLBACK_TYPE    Type,
-    IN  VOID                            (*Function)(PVOID),
-    IN  PVOID                           Argument OPTIONAL,
-    OUT PXENBUS_SUSPEND_CALLBACK        *Callback
+    _In_ PINTERFACE                     Interface,
+    _In_ XENBUS_SUSPEND_CALLBACK_TYPE   Type,
+    _In_ VOID                           (*Function)(PVOID),
+    _In_opt_ PVOID                      Argument,
+    _Out_ PXENBUS_SUSPEND_CALLBACK      *Callback
     )
 {
     PXENBUS_SUSPEND_CONTEXT             Context = Interface->Context;
@@ -127,8 +127,8 @@ fail1:
 
 static VOID
 SuspendDeregister(
-    IN  PINTERFACE                  Interface,
-    IN  PXENBUS_SUSPEND_CALLBACK    Callback
+    _In_ PINTERFACE                 Interface,
+    _In_ PXENBUS_SUSPEND_CALLBACK   Callback
     )
 {
     PXENBUS_SUSPEND_CONTEXT         Context = Interface->Context;
@@ -143,7 +143,7 @@ SuspendDeregister(
 
 static FORCEINLINE VOID
 __SuspendLogTimers(
-    IN  const CHAR  *Prefix
+    _In_ const CHAR *Prefix
     )
 {
     LARGE_INTEGER   SystemTime;
@@ -183,8 +183,8 @@ __SuspendLogTimers(
 
 static VOID
 SuspendEarly(
-    IN  PVOID               Argument,
-    IN  ULONG               Cpu
+    _In_ PVOID              Argument,
+    _In_ ULONG              Cpu
     )
 {
     PXENBUS_SUSPEND_CONTEXT Context = Argument;
@@ -223,8 +223,8 @@ SuspendEarly(
 
 static VOID
 SuspendLate(
-    IN  PVOID               Argument,
-    IN  ULONG               Cpu
+    _In_ PVOID              Argument,
+    _In_ ULONG              Cpu
     )
 {
     PXENBUS_SUSPEND_CONTEXT Context = Argument;
@@ -253,7 +253,7 @@ SuspendLate(
 NTSTATUS
 #pragma prefast(suppress:28167) // Function changes IRQL
 SuspendTrigger(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_SUSPEND_CONTEXT Context = Interface->Context;
@@ -298,7 +298,7 @@ SuspendTrigger(
 
 static ULONG
 SuspendGetCount(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_SUSPEND_CONTEXT Context = Interface->Context;
@@ -313,8 +313,8 @@ SuspendGetCount(
 
 static VOID
 SuspendDebugCallback(
-    IN  PVOID               Argument,
-    IN  BOOLEAN             Crashing
+    _In_ PVOID              Argument,
+    _In_ BOOLEAN            Crashing
     )
 {
     PXENBUS_SUSPEND_CONTEXT Context = Argument;
@@ -384,7 +384,7 @@ SuspendDebugCallback(
 
 static NTSTATUS
 SuspendAcquire(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_SUSPEND_CONTEXT Context = Interface->Context;
@@ -435,7 +435,7 @@ fail1:
 
 static VOID
 SuspendRelease(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_SUSPEND_CONTEXT Context = Interface->Context;
@@ -476,14 +476,14 @@ static struct _XENBUS_SUSPEND_INTERFACE_V1 SuspendInterfaceVersion1 = {
     SuspendTrigger,
     SuspendGetCount
 };
-                     
+
 NTSTATUS
 SuspendInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_SUSPEND_CONTEXT *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_SUSPEND_CONTEXT   *Context
     )
 {
-    NTSTATUS                    status;
+    NTSTATUS                        status;
 
     Trace("====>\n");
 
@@ -517,10 +517,10 @@ fail1:
 
 NTSTATUS
 SuspendGetInterface(
-    IN      PXENBUS_SUSPEND_CONTEXT Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_SUSPEND_CONTEXT    Context,
+    _In_ ULONG                      Version,
+    _Inout_ PINTERFACE              Interface,
+    _In_ ULONG                      Size
     )
 {
     NTSTATUS                        status;
@@ -551,11 +551,11 @@ SuspendGetInterface(
     }
 
     return status;
-}   
+}
 
 ULONG
 SuspendGetReferences(
-    IN  PXENBUS_SUSPEND_CONTEXT Context
+    _In_ PXENBUS_SUSPEND_CONTEXT    Context
     )
 {
     return Context->References;
@@ -563,7 +563,7 @@ SuspendGetReferences(
 
 VOID
 SuspendTeardown(
-    IN  PXENBUS_SUSPEND_CONTEXT Context
+    _In_ PXENBUS_SUSPEND_CONTEXT    Context
     )
 {
     Trace("====>\n");
diff --git a/src/xenbus/suspend.h b/src/xenbus/suspend.h
index ced30e4..4cfd107 100644
--- a/src/xenbus/suspend.h
+++ b/src/xenbus/suspend.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -43,26 +43,26 @@ typedef struct _XENBUS_SUSPEND_CONTEXT  XENBUS_SUSPEND_CONTEXT, *PXENBUS_SUSPEND
 
 extern NTSTATUS
 SuspendInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_SUSPEND_CONTEXT *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_SUSPEND_CONTEXT   *Context
     );
 
 extern NTSTATUS
 SuspendGetInterface(
-    IN      PXENBUS_SUSPEND_CONTEXT Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_SUSPEND_CONTEXT    Context,
+    _In_ ULONG                      Version,
+    _Inout_ PINTERFACE              Interface,
+    _In_ ULONG                      Size
     );
 
 extern ULONG
 SuspendGetReferences(
-    IN  PXENBUS_SUSPEND_CONTEXT Context
+    _In_ PXENBUS_SUSPEND_CONTEXT    Context
     );
 
 extern VOID
 SuspendTeardown(
-    IN  PXENBUS_SUSPEND_CONTEXT Context
+    _In_ PXENBUS_SUSPEND_CONTEXT    Context
     );
 
 #endif  // _XENBUS_SUSPEND_H
diff --git a/src/xenbus/sync.c b/src/xenbus/sync.c
index 4296003..bf7ad0f 100644
--- a/src/xenbus/sync.c
+++ b/src/xenbus/sync.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -102,7 +102,7 @@ static LONG             SyncOwner = -1;
 
 static FORCEINLINE PVOID
 __SyncAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_SYNC_TAG);
@@ -110,7 +110,7 @@ __SyncAllocate(
 
 static FORCEINLINE VOID
 __SyncFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_SYNC_TAG);
@@ -118,7 +118,7 @@ __SyncFree(
 
 static FORCEINLINE VOID
 __SyncAcquire(
-    IN  LONG    Index
+    _In_ LONG   Index
     )
 {
     LONG        Old;
@@ -198,7 +198,7 @@ __SyncProcessorDisableInterrupts(
 
 static FORCEINLINE VOID
 __SyncProcessorRunEarly(
-    IN  ULONG       Index
+    _In_ ULONG      Index
     )
 {
     PSYNC_CONTEXT   Context = &SyncContext;
@@ -226,7 +226,7 @@ __SyncProcessorEnableInterrupts(
 
 static FORCEINLINE VOID
 __SyncProcessorRunLate(
-    IN  ULONG       Index
+    _In_ ULONG      Index
     )
 {
     PSYNC_CONTEXT   Context = &SyncContext;
@@ -257,10 +257,10 @@ __SyncWait(
 VOID
 #pragma prefast(suppress:28166) // Function does not restore IRQL
 SyncWorker(
-    IN  PKDPC           Dpc,
-    IN  PVOID           _Context,
-    IN  PVOID           Argument1,
-    IN  PVOID           Argument2
+    PKDPC               Dpc,
+    PVOID               _Context,
+    PVOID               Argument1,
+    PVOID               Argument2
     )
 {
     PSYNC_CONTEXT       Context = &SyncContext;
@@ -325,20 +325,20 @@ SyncWorker(
     InterlockedIncrement(&Context->CompletionCount);
 }
 
-__drv_maxIRQL(DISPATCH_LEVEL)
-__drv_raisesIRQL(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
+_IRQL_raises_(DISPATCH_LEVEL)
 VOID
 SyncCapture(
-    IN  PVOID           Argument OPTIONAL,
-    IN  SYNC_CALLBACK   Early OPTIONAL,
-    IN  SYNC_CALLBACK   Late OPTIONAL
+    _In_opt_ PVOID          Argument,
+    _In_opt_ SYNC_CALLBACK  Early,
+    _In_opt_ SYNC_CALLBACK  Late
     )
 {
-    PSYNC_CONTEXT       Context = &SyncContext;
-    LONG                Index;
-    PROCESSOR_NUMBER    ProcNumber;
-    USHORT              Group;
-    UCHAR               Number;
+    PSYNC_CONTEXT           Context = &SyncContext;
+    LONG                    Index;
+    PROCESSOR_NUMBER        ProcNumber;
+    USHORT                  Group;
+    UCHAR                   Number;
 
     ASSERT3U(KeGetCurrentIrql(), ==, DISPATCH_LEVEL);
 
@@ -387,8 +387,8 @@ SyncCapture(
     Trace("<==== (%u:%u)\n", Group, Number);
 }
 
-__drv_requiresIRQL(DISPATCH_LEVEL)
-__drv_setsIRQL(HIGH_LEVEL)
+_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_raises_(HIGH_LEVEL)
 VOID
 SyncDisableInterrupts(
     VOID
@@ -416,7 +416,7 @@ SyncDisableInterrupts(
     }
 }
 
-__drv_requiresIRQL(HIGH_LEVEL)
+_IRQL_requires_(HIGH_LEVEL)
 VOID
 SyncRunEarly(
     )
@@ -436,8 +436,8 @@ SyncRunEarly(
     __SyncWait();
 }
 
-__drv_requiresIRQL(HIGH_LEVEL)
-__drv_setsIRQL(DISPATCH_LEVEL)
+_IRQL_requires_(HIGH_LEVEL)
+_IRQL_raises_(DISPATCH_LEVEL)
 VOID
 SyncEnableInterrupts(
     )
@@ -459,7 +459,7 @@ SyncEnableInterrupts(
     Trace("<====\n");
 }
 
-__drv_requiresIRQL(DISPATCH_LEVEL)
+_IRQL_requires_(DISPATCH_LEVEL)
 VOID
 SyncRunLate(
     )
@@ -480,7 +480,7 @@ SyncRunLate(
 }
 
 
-__drv_requiresIRQL(DISPATCH_LEVEL)
+_IRQL_requires_(DISPATCH_LEVEL)
 VOID
 #pragma prefast(suppress:28167) // Function changes IRQL
 SyncRelease(
diff --git a/src/xenbus/sync.h b/src/xenbus/sync.h
index 7170946..9707548 100644
--- a/src/xenbus/sync.h
+++ b/src/xenbus/sync.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -37,52 +37,52 @@
 
 typedef VOID
 (*SYNC_CALLBACK)(
-    IN  PVOID   Arguement,
-    IN  ULONG   Cpu
+    _In_ PVOID  Arguement,
+    _In_ ULONG  Cpu
     );
 
 extern
-__drv_maxIRQL(DISPATCH_LEVEL)
-__drv_raisesIRQL(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
+_IRQL_raises_(DISPATCH_LEVEL)
 VOID
 SyncCapture(
-    IN  PVOID           Argument OPTIONAL,
-    IN  SYNC_CALLBACK   Early OPTIONAL,
-    IN  SYNC_CALLBACK   Late OPTIONAL
+    _In_opt_ PVOID          Argument,
+    _In_opt_ SYNC_CALLBACK  Early,
+    _In_opt_ SYNC_CALLBACK  Late
     );
 
 extern
-__drv_requiresIRQL(DISPATCH_LEVEL)
-__drv_setsIRQL(HIGH_LEVEL)
+_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_raises_(HIGH_LEVEL)
 VOID
 SyncDisableInterrupts(
     VOID
     );
 
 extern
-__drv_requiresIRQL(HIGH_LEVEL)
+_IRQL_requires_(HIGH_LEVEL)
 VOID
 SyncRunEarly(
     VOID
     );
 
 extern
-__drv_requiresIRQL(HIGH_LEVEL)
-__drv_setsIRQL(DISPATCH_LEVEL)
+_IRQL_requires_(HIGH_LEVEL)
+_IRQL_raises_(DISPATCH_LEVEL)
 VOID
 SyncEnableInterrupts(
     VOID
     );
 
 extern
-__drv_requiresIRQL(DISPATCH_LEVEL)
+_IRQL_requires_(DISPATCH_LEVEL)
 VOID
 SyncRunLate(
     VOID
     );
 
 extern
-__drv_requiresIRQL(DISPATCH_LEVEL)
+_IRQL_requires_(DISPATCH_LEVEL)
 VOID
 SyncRelease(
     VOID
diff --git a/src/xenbus/thread.c b/src/xenbus/thread.c
index 03f022d..91b4057 100644
--- a/src/xenbus/thread.c
+++ b/src/xenbus/thread.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -50,7 +50,7 @@ struct _XENBUS_THREAD {
 
 static FORCEINLINE PVOID
 __ThreadAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, THREAD_TAG);
@@ -58,7 +58,7 @@ __ThreadAllocate(
 
 static FORCEINLINE VOID
 __ThreadFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, THREAD_TAG);
@@ -66,7 +66,7 @@ __ThreadFree(
 
 static FORCEINLINE VOID
 __ThreadWake(
-    IN  PXENBUS_THREAD  Thread
+    _In_ PXENBUS_THREAD Thread
     )
 {
     KeSetEvent(&Thread->Event, IO_NO_INCREMENT, FALSE);
@@ -74,7 +74,7 @@ __ThreadWake(
 
 VOID
 ThreadWake(
-    IN  PXENBUS_THREAD  Thread
+    _In_ PXENBUS_THREAD Thread
     )
 {
     __ThreadWake(Thread);
@@ -82,7 +82,7 @@ ThreadWake(
 
 static FORCEINLINE VOID
 __ThreadAlert(
-    IN  PXENBUS_THREAD  Thread
+    _In_ PXENBUS_THREAD Thread
     )
 {
     Thread->Alerted = TRUE;
@@ -91,7 +91,7 @@ __ThreadAlert(
 
 VOID
 ThreadAlert(
-    IN  PXENBUS_THREAD  Thread
+    _In_ PXENBUS_THREAD Thread
     )
 {
     __ThreadAlert(Thread);
@@ -101,7 +101,7 @@ KSTART_ROUTINE  ThreadFunction;
 
 VOID
 ThreadFunction(
-    IN  PVOID       Argument
+    _In_ PVOID      Argument
     )
 {
     PXENBUS_THREAD  Self = Argument;
@@ -116,12 +116,12 @@ ThreadFunction(
     // NOT REACHED
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 NTSTATUS
 ThreadCreate(
-    IN  XENBUS_THREAD_FUNCTION  Function,
-    IN  PVOID                   Context,
-    OUT PXENBUS_THREAD          *Thread
+    _In_ XENBUS_THREAD_FUNCTION Function,
+    _In_ PVOID                  Context,
+    _Out_ PXENBUS_THREAD        *Thread
     )
 {
     HANDLE                      Handle;
@@ -189,7 +189,7 @@ fail1:
 
 PKEVENT
 ThreadGetEvent(
-    IN  PXENBUS_THREAD  Thread
+    _In_ PXENBUS_THREAD Thread
     )
 {
     return &Thread->Event;
@@ -197,7 +197,7 @@ ThreadGetEvent(
 
 BOOLEAN
 ThreadIsAlerted(
-    IN  PXENBUS_THREAD  Thread
+    _In_ PXENBUS_THREAD Thread
     )
 {
     return Thread->Alerted;
@@ -205,7 +205,7 @@ ThreadIsAlerted(
 
 VOID
 ThreadJoin(
-    IN  PXENBUS_THREAD  Thread
+    _In_ PXENBUS_THREAD Thread
     )
 {
     LONG                References;
diff --git a/src/xenbus/thread.h b/src/xenbus/thread.h
index 633b3dd..9e24f65 100644
--- a/src/xenbus/thread.h
+++ b/src/xenbus/thread.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -39,37 +39,37 @@ typedef struct _XENBUS_THREAD XENBUS_THREAD, *PXENBUS_THREAD;
 
 typedef NTSTATUS (*XENBUS_THREAD_FUNCTION)(PXENBUS_THREAD, PVOID);
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 extern NTSTATUS
 ThreadCreate(
-    IN  XENBUS_THREAD_FUNCTION  Function,
-    IN  PVOID                   Context,
-    OUT PXENBUS_THREAD          *Thread
+    _In_ XENBUS_THREAD_FUNCTION Function,
+    _In_ PVOID                  Context,
+    _Out_ PXENBUS_THREAD        *Thread
     );
 
 extern PKEVENT
 ThreadGetEvent(
-    IN  PXENBUS_THREAD  Self
+    _In_ PXENBUS_THREAD Self
     );
 
 extern BOOLEAN
 ThreadIsAlerted(
-    IN  PXENBUS_THREAD  Self
+    _In_ PXENBUS_THREAD Self
     );
 
 extern VOID
 ThreadWake(
-    IN  PXENBUS_THREAD  Thread
+    _In_ PXENBUS_THREAD Thread
     );
 
 extern VOID
 ThreadAlert(
-    IN  PXENBUS_THREAD  Thread
+    _In_ PXENBUS_THREAD Thread
     );
 
 extern VOID
 ThreadJoin(
-    IN  PXENBUS_THREAD  Thread
+    _In_ PXENBUS_THREAD Thread
     );
 
 #endif  // _XENBUS_THREAD_H
diff --git a/src/xenbus/unplug.c b/src/xenbus/unplug.c
index a3f9b71..a21df30 100644
--- a/src/xenbus/unplug.c
+++ b/src/xenbus/unplug.c
@@ -54,7 +54,7 @@ struct _XENBUS_UNPLUG_CONTEXT {
 
 static FORCEINLINE PVOID
 __UnplugAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENBUS_UNPLUG_TAG);
@@ -62,18 +62,18 @@ __UnplugAllocate(
 
 static FORCEINLINE VOID
 __UnplugFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENBUS_UNPLUG_TAG);
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static VOID
 UnplugRequest(
-    IN  PINTERFACE                  Interface,
-    IN  XENBUS_UNPLUG_DEVICE_TYPE   Type,
-    IN  BOOLEAN                     Make
+    _In_ PINTERFACE                 Interface,
+    _In_ XENBUS_UNPLUG_DEVICE_TYPE  Type,
+    _In_ BOOLEAN                    Make
     )
 {
     PXENBUS_UNPLUG_CONTEXT          Context = Interface->Context;
@@ -111,11 +111,11 @@ UnplugRequest(
     ReleaseMutex(&Context->Mutex);
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static BOOLEAN
 UnplugIsRequested(
-    IN  PINTERFACE                  Interface,
-    IN  XENBUS_UNPLUG_DEVICE_TYPE   Type
+    _In_ PINTERFACE                 Interface,
+    _In_ XENBUS_UNPLUG_DEVICE_TYPE  Type
     )
 {
     PXENBUS_UNPLUG_CONTEXT          Context = Interface->Context;
@@ -145,10 +145,10 @@ UnplugIsRequested(
     return Requested;
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static BOOLEAN
 UnplugBootEmulated(
-    IN  PINTERFACE                  Interface
+    _In_ PINTERFACE                 Interface
     )
 {
     PXENBUS_UNPLUG_CONTEXT          Context = Interface->Context;
@@ -183,11 +183,11 @@ done:
     return BootEmulated;
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 static VOID
 UnplugReboot(
-    IN  PINTERFACE                  Interface,
-    IN  PCHAR                       Module
+    _In_ PINTERFACE                 Interface,
+    _In_ PCHAR                      Module
     )
 {
     PXENBUS_UNPLUG_CONTEXT          Context = Interface->Context;
@@ -205,7 +205,7 @@ UnplugReboot(
 
 static NTSTATUS
 UnplugAcquire(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_UNPLUG_CONTEXT  Context = Interface->Context;
@@ -226,7 +226,7 @@ done:
 
 static VOID
 UnplugRelease(
-    IN  PINTERFACE          Interface
+    _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_UNPLUG_CONTEXT  Context = Interface->Context;
@@ -270,11 +270,11 @@ static struct _XENBUS_UNPLUG_INTERFACE_V3 UnplugInterfaceVersion3 = {
 
 NTSTATUS
 UnplugInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_UNPLUG_CONTEXT  *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_UNPLUG_CONTEXT    *Context
     )
 {
-    NTSTATUS                    status;
+    NTSTATUS                        status;
 
     UNREFERENCED_PARAMETER(Fdo);
 
@@ -301,13 +301,13 @@ fail1:
 
 NTSTATUS
 UnplugGetInterface(
-    IN      PXENBUS_UNPLUG_CONTEXT  Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_UNPLUG_CONTEXT Context,
+    _In_ ULONG                  Version,
+    _Inout_ PINTERFACE          Interface,
+    _In_ ULONG                  Size
     )
 {
-    NTSTATUS                        status;
+    NTSTATUS                    status;
 
     ASSERT(Context != NULL);
 
@@ -373,7 +373,7 @@ UnplugGetInterface(
 
 ULONG
 UnplugGetReferences(
-    IN  PXENBUS_UNPLUG_CONTEXT  Context
+    _In_ PXENBUS_UNPLUG_CONTEXT Context
     )
 {
     return Context->References;
@@ -381,7 +381,7 @@ UnplugGetReferences(
 
 VOID
 UnplugTeardown(
-    IN  PXENBUS_UNPLUG_CONTEXT  Context
+    _In_ PXENBUS_UNPLUG_CONTEXT Context
     )
 {
     Trace("====>\n");
diff --git a/src/xenbus/unplug.h b/src/xenbus/unplug.h
index c1417db..1cc6251 100644
--- a/src/xenbus/unplug.h
+++ b/src/xenbus/unplug.h
@@ -43,26 +43,26 @@ typedef struct _XENBUS_UNPLUG_CONTEXT  XENBUS_UNPLUG_CONTEXT, *PXENBUS_UNPLUG_CO
 
 extern NTSTATUS
 UnplugInitialize(
-    IN  PXENBUS_FDO             Fdo,
-    OUT PXENBUS_UNPLUG_CONTEXT  *Context
+    _In_ PXENBUS_FDO                Fdo,
+    _Out_ PXENBUS_UNPLUG_CONTEXT    *Context
     );
 
 extern NTSTATUS
 UnplugGetInterface(
-    IN      PXENBUS_UNPLUG_CONTEXT  Context,
-    IN      ULONG                   Version,
-    IN OUT  PINTERFACE              Interface,
-    IN      ULONG                   Size
+    _In_ PXENBUS_UNPLUG_CONTEXT Context,
+    _In_ ULONG                  Version,
+    _Inout_ PINTERFACE          Interface,
+    _In_ ULONG                  Size
     );
 
 extern ULONG
 UnplugGetReferences(
-    IN  PXENBUS_UNPLUG_CONTEXT   Context
+    _In_ PXENBUS_UNPLUG_CONTEXT Context
     );
 
 extern VOID
 UnplugTeardown(
-    IN  PXENBUS_UNPLUG_CONTEXT   Context
+    _In_ PXENBUS_UNPLUG_CONTEXT Context
     );
 
 #endif  // _XENBUS_UNPLUG_H
diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
index aee663a..fd1ed22 100644
--- a/src/xenfilt/driver.c
+++ b/src/xenfilt/driver.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -65,7 +65,7 @@ static XENFILT_DRIVER   Driver;
 
 static FORCEINLINE PVOID
 __DriverAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENFILT_DRIVER_TAG);
@@ -73,7 +73,7 @@ __DriverAllocate(
 
 static FORCEINLINE VOID
 __DriverFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENFILT_DRIVER_TAG);
@@ -91,7 +91,7 @@ __DriverSafeMode(
 
 static FORCEINLINE VOID
 __DriverSetDriverObject(
-    IN  PDRIVER_OBJECT  DriverObject
+    _In_opt_ PDRIVER_OBJECT DriverObject
     )
 {
     Driver.DriverObject = DriverObject;
@@ -115,7 +115,7 @@ DriverGetDriverObject(
 
 static FORCEINLINE VOID
 __DriverSetEmulatedContext(
-    IN  PXENFILT_EMULATED_CONTEXT   Context
+    _In_ PXENFILT_EMULATED_CONTEXT  Context
     )
 {
     Driver.EmulatedContext = Context;
@@ -171,7 +171,7 @@ DriverReleaseMutex(
 
 VOID
 DriverAddFunctionDeviceObject(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PDEVICE_OBJECT      DeviceObject;
@@ -187,7 +187,7 @@ DriverAddFunctionDeviceObject(
 
 VOID
 DriverRemoveFunctionDeviceObject(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PDEVICE_OBJECT      DeviceObject;
@@ -206,8 +206,8 @@ DriverRemoveFunctionDeviceObject(
 
 static FORCEINLINE NTSTATUS
 __DriverGetActive(
-    IN  const CHAR  *Key,
-    OUT PCHAR       *Value
+    _In_ const CHAR *Key,
+    _Out_ PCHAR     *Value
     )
 {
     HANDLE          ParametersKey;
@@ -272,8 +272,8 @@ fail1:
 
 NTSTATUS
 DriverGetActive(
-    IN  const CHAR  *Key,
-    OUT PCHAR       *Value
+    _In_ const CHAR *Key,
+    _Out_ PCHAR     *Value
     )
 {
     return __DriverGetActive(Key, Value);
@@ -391,7 +391,7 @@ DRIVER_UNLOAD   DriverUnload;
 
 VOID
 DriverUnload(
-    IN  PDRIVER_OBJECT  DriverObject
+    _In_ PDRIVER_OBJECT DriverObject
     )
 {
     ASSERT3P(DriverObject, ==, __DriverGetDriverObject());
@@ -429,13 +429,14 @@ DriverUnload(
     Trace("<====\n");
 }
 
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
+static IO_COMPLETION_ROUTINE DriverQueryCompletion;
+
+_Use_decl_annotations_
 static NTSTATUS
 DriverQueryCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp,
+    PVOID               Context
     )
 {
     PKEVENT             Event = Context;
@@ -450,9 +451,9 @@ DriverQueryCompletion(
 
 NTSTATUS
 DriverQueryId(
-    IN  PDEVICE_OBJECT      DeviceObject,
-    IN  BUS_QUERY_ID_TYPE   Type,
-    OUT PCHAR               *Id
+    _In_ PDEVICE_OBJECT     DeviceObject,
+    _In_ BUS_QUERY_ID_TYPE  Type,
+    _Out_ PCHAR             *Id
     )
 {
     PIRP                    Irp;
@@ -614,9 +615,9 @@ fail1:
 
 NTSTATUS
 DriverQueryDeviceText(
-    IN  PDEVICE_OBJECT      DeviceObject,
-    IN  DEVICE_TEXT_TYPE    Type,
-    OUT PCHAR               *Text
+    _In_ PDEVICE_OBJECT     DeviceObject,
+    _In_ DEVICE_TEXT_TYPE   Type,
+    _Out_ PCHAR             *Text
     )
 {
     PIRP                    Irp;
@@ -704,7 +705,7 @@ fail1:
 
 static FORCEINLINE PCHAR
 __EmulatedTypeName(
-    IN  XENFILT_EMULATED_OBJECT_TYPE    Type
+    _In_ XENFILT_EMULATED_OBJECT_TYPE   Type
     )
 {
     switch (Type) {
@@ -717,7 +718,7 @@ __EmulatedTypeName(
 
 static XENFILT_EMULATED_OBJECT_TYPE
 DriverGetEmulatedType(
-    IN  PCHAR                       Id
+    _In_ PCHAR                      Id
     )
 {
     HANDLE                          ParametersKey;
@@ -775,8 +776,8 @@ DRIVER_ADD_DEVICE   DriverAddDevice;
 NTSTATUS
 #pragma prefast(suppress:28152) // Does not clear DO_DEVICE_INITIALIZING
 DriverAddDevice(
-    IN  PDRIVER_OBJECT              DriverObject,
-    IN  PDEVICE_OBJECT              PhysicalDeviceObject
+    _In_ PDRIVER_OBJECT             DriverObject,
+    _In_ PDEVICE_OBJECT             PhysicalDeviceObject
     )
 {
     PCHAR                           Id;
@@ -823,10 +824,11 @@ done:
 
 DRIVER_DISPATCH DriverDispatch;
 
-NTSTATUS 
+_Use_decl_annotations_
+NTSTATUS
 DriverDispatch(
-    IN PDEVICE_OBJECT   DeviceObject,
-    IN PIRP             Irp
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp
     )
 {
     PXENFILT_DX         Dx;
@@ -882,8 +884,8 @@ DRIVER_INITIALIZE   DriverEntry;
 
 NTSTATUS
 DriverEntry(
-    IN  PDRIVER_OBJECT          DriverObject,
-    IN  PUNICODE_STRING         RegistryPath
+    _In_ PDRIVER_OBJECT         DriverObject,
+    _In_ PUNICODE_STRING        RegistryPath
     )
 {
     PXENFILT_EMULATED_CONTEXT   EmulatedContext;
diff --git a/src/xenfilt/driver.h b/src/xenfilt/driver.h
index e7bd468..ab36936 100644
--- a/src/xenfilt/driver.h
+++ b/src/xenfilt/driver.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -50,8 +50,8 @@ DriverReleaseMutex(
 
 extern NTSTATUS
 DriverGetActive(
-    IN  const CHAR  *Key,
-    OUT PCHAR       *Value
+    _In_ const CHAR *Key,
+    _Out_ PCHAR     *Value
     );
 
 typedef enum _XENFILT_FILTER_STATE {
@@ -72,16 +72,16 @@ DriverGetFilterState(
 
 extern NTSTATUS
 DriverQueryId(
-    IN  PDEVICE_OBJECT      PhysicalDeviceObject,
-    IN  BUS_QUERY_ID_TYPE   Type,
-    OUT PCHAR               *Id
+    _In_ PDEVICE_OBJECT     PhysicalDeviceObject,
+    _In_ BUS_QUERY_ID_TYPE  Type,
+    _Out_ PCHAR             *Id
     );
 
 extern NTSTATUS
 DriverQueryDeviceText(
-    IN  PDEVICE_OBJECT      LowerDeviceObject,
-    IN  DEVICE_TEXT_TYPE    Type,
-    OUT PCHAR               *Text
+    _In_ PDEVICE_OBJECT     LowerDeviceObject,
+    _In_ DEVICE_TEXT_TYPE   Type,
+    _Out_ PCHAR             *Text
     );
 
 #include "emulated.h"
@@ -99,12 +99,12 @@ typedef struct _XENFILT_PDO XENFILT_PDO, *PXENFILT_PDO;
 
 extern VOID
 DriverAddFunctionDeviceObject(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     );
 
 extern VOID
 DriverRemoveFunctionDeviceObject(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     );
 
 #pragma warning(push)
diff --git a/src/xenfilt/emulated.c b/src/xenfilt/emulated.c
index 177cde3..76bb3c0 100644
--- a/src/xenfilt/emulated.c
+++ b/src/xenfilt/emulated.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -75,7 +75,7 @@ struct _XENFILT_EMULATED_CONTEXT {
 
 static FORCEINLINE PVOID
 __EmulatedAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, XENFILT_EMULATED_TAG);
@@ -83,7 +83,7 @@ __EmulatedAllocate(
 
 static FORCEINLINE VOID
 __EmulatedFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, XENFILT_EMULATED_TAG);
@@ -91,11 +91,11 @@ __EmulatedFree(
 
 static NTSTATUS
 EmulatedSetObjectDeviceData(
-    IN  PXENFILT_EMULATED_OBJECT        EmulatedObject,
-    IN  XENFILT_EMULATED_OBJECT_TYPE    Type,
-    IN  PCHAR                           DeviceID,
-    IN  PCHAR                           InstanceID,
-    IN  PCHAR                           CompatibleIDs OPTIONAL
+    _In_ PXENFILT_EMULATED_OBJECT       EmulatedObject,
+    _In_ XENFILT_EMULATED_OBJECT_TYPE   Type,
+    _In_ PCHAR                          DeviceID,
+    _In_ PCHAR                          InstanceID,
+    _In_opt_ PCHAR                      CompatibleIDs
     )
 {
     ULONG                               Index;
@@ -152,11 +152,11 @@ fail1:
 
 static NTSTATUS
 EmulatedSetObjectDiskData(
-    IN  PXENFILT_EMULATED_OBJECT        EmulatedObject,
-    IN  XENFILT_EMULATED_OBJECT_TYPE    Type,
-    IN  PCHAR                           DeviceID,
-    IN  PCHAR                           InstanceID,
-    IN  PCHAR                           CompatibleIDs OPTIONAL
+    _In_ PXENFILT_EMULATED_OBJECT       EmulatedObject,
+    _In_ XENFILT_EMULATED_OBJECT_TYPE   Type,
+    _In_ PCHAR                          DeviceID,
+    _In_ PCHAR                          InstanceID,
+    _In_opt_ PCHAR                      CompatibleIDs
     )
 {
     PCHAR                               End;
@@ -222,12 +222,12 @@ fail1:
 
 NTSTATUS
 EmulatedAddObject(
-    IN  PXENFILT_EMULATED_CONTEXT       Context,
-    IN  PCHAR                           DeviceID,
-    IN  PCHAR                           InstanceID,
-    IN  PCHAR                           CompatibleIDs OPTIONAL,
-    IN  XENFILT_EMULATED_OBJECT_TYPE    Type,
-    OUT PXENFILT_EMULATED_OBJECT        *EmulatedObject
+    _In_ PXENFILT_EMULATED_CONTEXT      Context,
+    _In_ PCHAR                          DeviceID,
+    _In_ PCHAR                          InstanceID,
+    _In_opt_ PCHAR                      CompatibleIDs,
+    _In_ XENFILT_EMULATED_OBJECT_TYPE   Type,
+    _Out_ PXENFILT_EMULATED_OBJECT      *EmulatedObject
     )
 {
     KIRQL                               Irql;
@@ -289,8 +289,8 @@ fail1:
 
 VOID
 EmulatedRemoveObject(
-    IN  PXENFILT_EMULATED_CONTEXT   Context,
-    IN  PXENFILT_EMULATED_OBJECT    EmulatedObject
+    _In_ PXENFILT_EMULATED_CONTEXT  Context,
+    _In_ PXENFILT_EMULATED_OBJECT   EmulatedObject
     )
 {
     KIRQL                           Irql;
@@ -304,9 +304,9 @@ EmulatedRemoveObject(
 
 static BOOLEAN
 EmulatedIsDevicePresent(
-    IN  PINTERFACE              Interface,
-    IN  PCHAR                   DeviceID,
-    IN  PCHAR                   InstanceID OPTIONAL
+    _In_ PINTERFACE             Interface,
+    _In_ PCHAR                  DeviceID,
+    _In_opt_ PCHAR              InstanceID
     )
 {
     PXENFILT_EMULATED_CONTEXT   Context = Interface->Context;
@@ -347,8 +347,8 @@ EmulatedIsDevicePresent(
 
 static BOOLEAN
 EmulatedIsDiskPresent(
-    IN  PINTERFACE              Interface,
-    IN  ULONG                   Index
+    _In_ PINTERFACE             Interface,
+    _In_ ULONG                  Index
     )
 {
     PXENFILT_EMULATED_CONTEXT   Context = Interface->Context;
@@ -392,10 +392,10 @@ EmulatedIsDiskPresent(
 
 static BOOLEAN
 EmulatedIsDiskPresentVersion1(
-    IN  PINTERFACE              Interface,
-    IN  ULONG                   Controller,
-    IN  ULONG                   Target,
-    IN  ULONG                   Lun
+    _In_ PINTERFACE             Interface,
+    _In_ ULONG                  Controller,
+    _In_ ULONG                  Target,
+    _In_ ULONG                  Lun
     )
 {
     UNREFERENCED_PARAMETER(Controller);
@@ -412,7 +412,7 @@ EmulatedIsDiskPresentVersion1(
 
 NTSTATUS
 EmulatedAcquire(
-    IN  PINTERFACE              Interface
+    _In_ PINTERFACE             Interface
     )
 {
     PXENFILT_EMULATED_CONTEXT   Context = Interface->Context;
@@ -433,7 +433,7 @@ done:
 
 VOID
 EmulatedRelease(
-    IN  PINTERFACE              Interface
+    _In_ PINTERFACE             Interface
     )
 {
     PXENFILT_EMULATED_CONTEXT   Context = Interface->Context;
@@ -457,7 +457,7 @@ static struct _XENFILT_EMULATED_INTERFACE_V1 EmulatedInterfaceVersion1 = {
     EmulatedIsDevicePresent,
     EmulatedIsDiskPresentVersion1
 };
-                     
+
 static struct _XENFILT_EMULATED_INTERFACE_V2 EmulatedInterfaceVersion2 = {
     { sizeof (struct _XENFILT_EMULATED_INTERFACE_V2), 2, NULL, NULL, NULL },
     EmulatedAcquire,
@@ -468,7 +468,7 @@ static struct _XENFILT_EMULATED_INTERFACE_V2 EmulatedInterfaceVersion2 = {
 
 NTSTATUS
 EmulatedInitialize(
-    OUT PXENFILT_EMULATED_CONTEXT   *Context
+    _Out_ PXENFILT_EMULATED_CONTEXT *Context
     )
 {
     NTSTATUS                        status;
@@ -496,13 +496,13 @@ fail1:
 
 NTSTATUS
 EmulatedGetInterface(
-    IN      PXENFILT_EMULATED_CONTEXT   Context,
-    IN      ULONG                       Version,
-    IN OUT  PINTERFACE                  Interface,
-    IN      ULONG                       Size
+    _In_ PXENFILT_EMULATED_CONTEXT  Context,
+    _In_ ULONG                      Version,
+    _Inout_ PINTERFACE              Interface,
+    _In_ ULONG                      Size
     )
 {
-    NTSTATUS                            status;
+    NTSTATUS                        status;
 
     ASSERT(Context != NULL);
 
@@ -547,11 +547,11 @@ EmulatedGetInterface(
     }
 
     return status;
-}   
+}
 
 VOID
 EmulatedTeardown(
-    IN  PXENFILT_EMULATED_CONTEXT   Context
+    _In_ PXENFILT_EMULATED_CONTEXT  Context
     )
 {
     Trace("====>\n");
diff --git a/src/xenfilt/emulated.h b/src/xenfilt/emulated.h
index 0986ded..5cb6ece 100644
--- a/src/xenfilt/emulated.h
+++ b/src/xenfilt/emulated.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -49,36 +49,36 @@ typedef struct _XENFILT_EMULATED_OBJECT XENFILT_EMULATED_OBJECT, *PXENFILT_EMULA
 
 extern NTSTATUS
 EmulatedInitialize(
-    OUT PXENFILT_EMULATED_CONTEXT   *Context
+    _Out_ PXENFILT_EMULATED_CONTEXT *Context
     );
 
 extern NTSTATUS
 EmulatedGetInterface(
-    IN      PXENFILT_EMULATED_CONTEXT   Context,
-    IN      ULONG                       Version,
-    IN OUT  PINTERFACE                  Interface,
-    IN      ULONG                       Size
+    _In_ PXENFILT_EMULATED_CONTEXT  Context,
+    _In_ ULONG                      Version,
+    _Inout_ PINTERFACE              Interface,
+    _In_ ULONG                      Size
     );
 
 extern VOID
 EmulatedTeardown(
-    IN  PXENFILT_EMULATED_CONTEXT   Context
+    _In_ PXENFILT_EMULATED_CONTEXT  Context
     );
 
 extern NTSTATUS
 EmulatedAddObject(
-    IN  PXENFILT_EMULATED_CONTEXT       Context,
-    IN  PCHAR                           DeviceID,
-    IN  PCHAR                           InstanceID,
-    IN  PCHAR                           CompatibleIDs OPTIONAL,
-    IN  XENFILT_EMULATED_OBJECT_TYPE    Type,
-    OUT PXENFILT_EMULATED_OBJECT        *EmulatedObject
+    _In_ PXENFILT_EMULATED_CONTEXT      Context,
+    _In_ PCHAR                          DeviceID,
+    _In_ PCHAR                          InstanceID,
+    _In_opt_ PCHAR                      CompatibleIDs,
+    _In_ XENFILT_EMULATED_OBJECT_TYPE   Type,
+    _Out_ PXENFILT_EMULATED_OBJECT      *EmulatedObject
     );
 
 extern VOID
 EmulatedRemoveObject(
-    IN  PXENFILT_EMULATED_CONTEXT   Context,
-    IN  PXENFILT_EMULATED_OBJECT    EmulatedObject
+    _In_ PXENFILT_EMULATED_CONTEXT  Context,
+    _In_ PXENFILT_EMULATED_OBJECT   EmulatedObject
     );
 
 #endif  // _XENFILT_EMULATED_H
diff --git a/src/xenfilt/fdo.c b/src/xenfilt/fdo.c
index 08cf5a7..94578f6 100644
--- a/src/xenfilt/fdo.c
+++ b/src/xenfilt/fdo.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -71,7 +71,7 @@ struct _XENFILT_FDO {
 
 static FORCEINLINE PVOID
 __FdoAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, FDO_TAG);
@@ -79,7 +79,7 @@ __FdoAllocate(
 
 static FORCEINLINE VOID
 __FdoFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, FDO_TAG);
@@ -87,8 +87,8 @@ __FdoFree(
 
 static FORCEINLINE VOID
 __FdoSetDevicePnpState(
-    IN  PXENFILT_FDO        Fdo,
-    IN  DEVICE_PNP_STATE    State
+    _In_ PXENFILT_FDO       Fdo,
+    _In_ DEVICE_PNP_STATE   State
     )
 {
     PXENFILT_DX             Dx = Fdo->Dx;
@@ -102,8 +102,8 @@ __FdoSetDevicePnpState(
 
 static FORCEINLINE VOID
 __FdoRestoreDevicePnpState(
-    IN  PXENFILT_FDO        Fdo,
-    IN  DEVICE_PNP_STATE    State
+    _In_ PXENFILT_FDO       Fdo,
+    _In_ DEVICE_PNP_STATE   State
     )
 {
     PXENFILT_DX             Dx = Fdo->Dx;
@@ -114,7 +114,7 @@ __FdoRestoreDevicePnpState(
 
 static FORCEINLINE DEVICE_PNP_STATE
 __FdoGetDevicePnpState(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PXENFILT_DX         Dx = Fdo->Dx;
@@ -124,7 +124,7 @@ __FdoGetDevicePnpState(
 
 static FORCEINLINE DEVICE_PNP_STATE
 __FdoGetPreviousDevicePnpState(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PXENFILT_DX         Dx = Fdo->Dx;
@@ -134,8 +134,8 @@ __FdoGetPreviousDevicePnpState(
 
 static FORCEINLINE VOID
 __FdoSetDevicePowerState(
-    IN  PXENFILT_FDO        Fdo,
-    IN  DEVICE_POWER_STATE  State
+    _In_ PXENFILT_FDO       Fdo,
+    _In_ DEVICE_POWER_STATE State
     )
 {
     PXENFILT_DX             Dx = Fdo->Dx;
@@ -145,7 +145,7 @@ __FdoSetDevicePowerState(
 
 static FORCEINLINE DEVICE_POWER_STATE
 __FdoGetDevicePowerState(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PXENFILT_DX         Dx = Fdo->Dx;
@@ -155,8 +155,8 @@ __FdoGetDevicePowerState(
 
 static FORCEINLINE VOID
 __FdoSetSystemPowerState(
-    IN  PXENFILT_FDO        Fdo,
-    IN  SYSTEM_POWER_STATE  State
+    _In_ PXENFILT_FDO       Fdo,
+    _In_ SYSTEM_POWER_STATE State
     )
 {
     PXENFILT_DX              Dx = Fdo->Dx;
@@ -166,7 +166,7 @@ __FdoSetSystemPowerState(
 
 static FORCEINLINE SYSTEM_POWER_STATE
 __FdoGetSystemPowerState(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PXENFILT_DX         Dx = Fdo->Dx;
@@ -176,17 +176,17 @@ __FdoGetSystemPowerState(
 
 static FORCEINLINE PDEVICE_OBJECT
 __FdoGetDeviceObject(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PXENFILT_DX         Dx = Fdo->Dx;
 
     return Dx->DeviceObject;
 }
-    
+
 PDEVICE_OBJECT
 FdoGetDeviceObject(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     return __FdoGetDeviceObject(Fdo);
@@ -194,7 +194,7 @@ FdoGetDeviceObject(
 
 static FORCEINLINE PDEVICE_OBJECT
 __FdoGetPhysicalDeviceObject(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     return Fdo->PhysicalDeviceObject;
@@ -202,7 +202,7 @@ __FdoGetPhysicalDeviceObject(
 
 PDEVICE_OBJECT
 FdoGetPhysicalDeviceObject(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     return __FdoGetPhysicalDeviceObject(Fdo);
@@ -210,7 +210,7 @@ FdoGetPhysicalDeviceObject(
 
 static FORCEINLINE NTSTATUS
 __FdoSetDeviceID(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PXENFILT_DX         Dx = Fdo->Dx;
@@ -223,7 +223,7 @@ __FdoSetDeviceID(
 
 static FORCEINLINE PCHAR
 __FdoGetDeviceID(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PXENFILT_DX         Dx = Fdo->Dx;
@@ -233,7 +233,7 @@ __FdoGetDeviceID(
 
 static FORCEINLINE VOID
 __FdoClearDeviceID(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PXENFILT_DX         Dx = Fdo->Dx;
@@ -244,7 +244,7 @@ __FdoClearDeviceID(
 
 static FORCEINLINE NTSTATUS
 __FdoSetInstanceID(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PXENFILT_DX         Dx = Fdo->Dx;
@@ -256,7 +256,7 @@ __FdoSetInstanceID(
 
 static FORCEINLINE PCHAR
 __FdoGetInstanceID(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PXENFILT_DX         Dx = Fdo->Dx;
@@ -266,7 +266,7 @@ __FdoGetInstanceID(
 
 static FORCEINLINE VOID
 __FdoClearInstanceID(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PXENFILT_DX         Dx = Fdo->Dx;
@@ -277,7 +277,7 @@ __FdoClearInstanceID(
 
 static FORCEINLINE VOID
 __FdoSetName(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     NTSTATUS            status;
@@ -292,7 +292,7 @@ __FdoSetName(
 
 static FORCEINLINE PCHAR
 __FdoGetName(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     return Fdo->Name;
@@ -300,8 +300,8 @@ __FdoGetName(
 
 VOID
 FdoAddPhysicalDeviceObject(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     PDEVICE_OBJECT      DeviceObject;
@@ -320,8 +320,8 @@ FdoAddPhysicalDeviceObject(
 
 VOID
 FdoRemovePhysicalDeviceObject(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     PDEVICE_OBJECT      DeviceObject;
@@ -340,7 +340,7 @@ FdoRemovePhysicalDeviceObject(
 
 static FORCEINLINE VOID
 __FdoAcquireMutex(
-    IN  PXENFILT_FDO     Fdo
+    _In_ PXENFILT_FDO    Fdo
     )
 {
     AcquireMutex(&Fdo->Mutex);
@@ -348,7 +348,7 @@ __FdoAcquireMutex(
 
 VOID
 FdoAcquireMutex(
-    IN  PXENFILT_FDO     Fdo
+    _In_ PXENFILT_FDO    Fdo
     )
 {
     __FdoAcquireMutex(Fdo);
@@ -356,7 +356,7 @@ FdoAcquireMutex(
 
 static FORCEINLINE VOID
 __FdoReleaseMutex(
-    IN  PXENFILT_FDO     Fdo
+    _In_ PXENFILT_FDO    Fdo
     )
 {
     ReleaseMutex(&Fdo->Mutex);
@@ -364,7 +364,7 @@ __FdoReleaseMutex(
 
 VOID
 FdoReleaseMutex(
-    IN  PXENFILT_FDO     Fdo
+    _In_ PXENFILT_FDO    Fdo
     )
 {
     __FdoReleaseMutex(Fdo);
@@ -378,7 +378,7 @@ FdoReleaseMutex(
 
 static FORCEINLINE VOID
 __FdoSetEnumerated(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     Fdo->Enumerated = TRUE;
@@ -388,7 +388,7 @@ __FdoSetEnumerated(
 
 BOOLEAN
 FdoHasEnumerated(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     return Fdo->Enumerated;
@@ -396,8 +396,8 @@ FdoHasEnumerated(
 
 static VOID
 FdoEnumerate(
-    IN  PXENFILT_FDO        Fdo,
-    IN  PDEVICE_RELATIONS   Relations
+    _In_ PXENFILT_FDO       Fdo,
+    _In_ PDEVICE_RELATIONS  Relations
     )
 {
     PDEVICE_OBJECT          *PhysicalDeviceObject;
@@ -466,7 +466,7 @@ FdoEnumerate(
             ObDereferenceObject(PhysicalDeviceObject[Index]);
         }
     }
-    
+
     __FdoSetEnumerated(Fdo);
 
     __FdoFree(PhysicalDeviceObject);
@@ -476,13 +476,14 @@ fail1:
     Error("fail1 (%08x)\n", status);
 }
 
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
+static IO_COMPLETION_ROUTINE FdoForwardIrpSynchronouslyCompletion;
+
+_Use_decl_annotations_
 static NTSTATUS
 FdoForwardIrpSynchronouslyCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp,
+    PVOID               Context
     )
 {
     PKEVENT             Event = Context;
@@ -497,8 +498,8 @@ FdoForwardIrpSynchronouslyCompletion(
 
 static NTSTATUS
 FdoForwardIrpSynchronously(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     KEVENT              Event;
@@ -533,8 +534,8 @@ FdoForwardIrpSynchronously(
 
 static NTSTATUS
 FdoStartDevice(
-    IN  PXENFILT_FDO            Fdo,
-    IN  PIRP                    Irp
+    _In_ PXENFILT_FDO           Fdo,
+    _In_ PIRP                   Irp
     )
 {
     POWER_STATE                 PowerState;
@@ -579,8 +580,8 @@ fail1:
 
 static NTSTATUS
 FdoQueryStopDevice(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     NTSTATUS            status;
@@ -608,8 +609,8 @@ fail1:
 
 static NTSTATUS
 FdoCancelStopDevice(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     NTSTATUS            status;
@@ -638,8 +639,8 @@ fail1:
 
 static NTSTATUS
 FdoStopDevice(
-    IN  PXENFILT_FDO            Fdo,
-    IN  PIRP                    Irp
+    _In_ PXENFILT_FDO           Fdo,
+    _In_ PIRP                   Irp
     )
 {
     NTSTATUS                    status;
@@ -678,8 +679,8 @@ fail1:
 
 static NTSTATUS
 FdoQueryRemoveDevice(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     NTSTATUS            status;
@@ -707,8 +708,8 @@ fail1:
 
 static NTSTATUS
 FdoCancelRemoveDevice(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     NTSTATUS            status;
@@ -736,8 +737,8 @@ fail1:
 
 static NTSTATUS
 FdoSurpriseRemoval(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     NTSTATUS            status;
@@ -765,8 +766,8 @@ fail1:
 
 static NTSTATUS
 FdoRemoveDevice(
-    IN  PXENFILT_FDO            Fdo,
-    IN  PIRP                    Irp
+    _In_ PXENFILT_FDO           Fdo,
+    _In_ PIRP                   Irp
     )
 {
     PLIST_ENTRY                 ListEntry;
@@ -840,13 +841,14 @@ fail1:
     return status;
 }
 
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
+static IO_COMPLETION_ROUTINE FdoQueryDeviceRelationsCompletion;
+
+_Use_decl_annotations_
 static NTSTATUS
 FdoQueryDeviceRelationsCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp,
+    PVOID               Context
     )
 {
     PKEVENT             Event = Context;
@@ -861,8 +863,8 @@ FdoQueryDeviceRelationsCompletion(
 
 static NTSTATUS
 FdoQueryDeviceRelations(
-    IN  PXENFILT_FDO        Fdo,
-    IN  PIRP                Irp
+    _In_ PXENFILT_FDO       Fdo,
+    _In_ PIRP               Irp
     )
 {
     KEVENT                  Event;
@@ -1002,8 +1004,8 @@ fail1:
 
 static NTSTATUS
 FdoDispatchPnp(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1073,13 +1075,14 @@ fail1:
     return status;
 }
 
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
+static IO_COMPLETION_ROUTINE FdoSetDevicePowerUpComplete;
+
+_Use_decl_annotations_
 static NTSTATUS
 FdoSetDevicePowerUpComplete(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp,
+    PVOID               Context
     )
 {
     PXENFILT_FDO        Fdo = (PXENFILT_FDO)Context;
@@ -1112,8 +1115,8 @@ FdoSetDevicePowerUpComplete(
 
 static FORCEINLINE NTSTATUS
 __FdoSetDevicePowerUp(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     IoCopyCurrentIrpStackLocationToNext(Irp);
@@ -1129,8 +1132,8 @@ __FdoSetDevicePowerUp(
 
 static NTSTATUS
 __FdoSetDevicePowerDown(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1158,8 +1161,8 @@ __FdoSetDevicePowerDown(
 
 static NTSTATUS
 FdoSetDevicePower(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1173,7 +1176,7 @@ FdoSetDevicePower(
 
     Trace("%s: ====> (%s:%s)\n",
           __FdoGetName(Fdo),
-          DevicePowerStateName(DeviceState), 
+          DevicePowerStateName(DeviceState),
           PowerActionName(PowerAction));
 
     if (DeviceState == __FdoGetDevicePowerState(Fdo)) {
@@ -1190,7 +1193,7 @@ FdoSetDevicePower(
 done:
     Trace("%s: <==== (%s:%s)(%08x)\n",
           __FdoGetName(Fdo),
-          DevicePowerStateName(DeviceState), 
+          DevicePowerStateName(DeviceState),
           PowerActionName(PowerAction),
           status);
     return status;
@@ -1198,8 +1201,8 @@ done:
 
 static FORCEINLINE NTSTATUS
 __FdoDispatchDevicePower(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1223,13 +1226,14 @@ __FdoDispatchDevicePower(
     return status;
 }
 
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
+static IO_COMPLETION_ROUTINE FdoSetSystemPowerUpComplete;
+
+_Use_decl_annotations_
 static NTSTATUS
 FdoSetSystemPowerUpComplete(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp,
+    PVOID               Context
     )
 {
     PXENFILT_FDO        Fdo = (PXENFILT_FDO)Context;
@@ -1258,8 +1262,8 @@ FdoSetSystemPowerUpComplete(
 
 static FORCEINLINE NTSTATUS
 __FdoSetSystemPowerUp(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     IoCopyCurrentIrpStackLocationToNext(Irp);
@@ -1274,8 +1278,8 @@ __FdoSetSystemPowerUp(
 
 static FORCEINLINE NTSTATUS
 __FdoSetSystemPowerDown(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1299,8 +1303,8 @@ __FdoSetSystemPowerDown(
 
 static NTSTATUS
 FdoSetSystemPower(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1314,7 +1318,7 @@ FdoSetSystemPower(
 
     Trace("%s: ====> (%s:%s)\n",
           __FdoGetName(Fdo),
-          SystemPowerStateName(SystemState), 
+          SystemPowerStateName(SystemState),
           PowerActionName(PowerAction));
 
     if (SystemState == __FdoGetSystemPowerState(Fdo)) {
@@ -1331,7 +1335,7 @@ FdoSetSystemPower(
 done:
     Trace("%s: <==== (%s:%s)(%08x)\n",
           __FdoGetName(Fdo),
-          SystemPowerStateName(SystemState), 
+          SystemPowerStateName(SystemState),
           PowerActionName(PowerAction),
           status);
     return status;
@@ -1339,8 +1343,8 @@ done:
 
 static FORCEINLINE NTSTATUS
 __FdoDispatchSystemPower(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1366,8 +1370,8 @@ __FdoDispatchSystemPower(
 
 static NTSTATUS
 FdoDispatchPower(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1395,8 +1399,8 @@ FdoDispatchPower(
 
     Trace("%s: ====> (%02x:%s)\n",
           __FdoGetName(Fdo),
-          MinorFunction, 
-          PowerMinorFunctionName(MinorFunction)); 
+          MinorFunction,
+          PowerMinorFunctionName(MinorFunction));
 
     switch (PowerType) {
     case DevicePowerState:
@@ -1419,7 +1423,7 @@ FdoDispatchPower(
 
     Trace("%s: <==== (%02x:%s) (%08x)\n",
           __FdoGetName(Fdo),
-          MinorFunction, 
+          MinorFunction,
           PowerMinorFunctionName(MinorFunction),
           status);
 
@@ -1437,8 +1441,8 @@ fail1:
 
 static NTSTATUS
 FdoDispatchDefault(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     NTSTATUS            status;
@@ -1465,8 +1469,8 @@ fail1:
 
 NTSTATUS
 FdoDispatch(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1493,8 +1497,8 @@ FdoDispatch(
 
 NTSTATUS
 FdoCreate(
-    IN  PDEVICE_OBJECT                  PhysicalDeviceObject,
-    IN  XENFILT_EMULATED_OBJECT_TYPE    Type
+    _In_ PDEVICE_OBJECT                 PhysicalDeviceObject,
+    _In_ XENFILT_EMULATED_OBJECT_TYPE   Type
     )
 {
     PDEVICE_OBJECT                      LowerDeviceObject;
@@ -1615,7 +1619,7 @@ fail1:
 
 VOID
 FdoDestroy(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     )
 {
     PDEVICE_OBJECT      LowerDeviceObject = Fdo->LowerDeviceObject;
diff --git a/src/xenfilt/fdo.h b/src/xenfilt/fdo.h
index a2ee386..bd1d347 100644
--- a/src/xenfilt/fdo.h
+++ b/src/xenfilt/fdo.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -43,61 +43,61 @@ typedef struct _XENFILT_FDO XENFILT_FDO, *PXENFILT_FDO;
 
 extern NTSTATUS
 FdoCreate(
-    IN  PDEVICE_OBJECT                  PhysicalDeviceObject,
-    IN  XENFILT_EMULATED_OBJECT_TYPE    Type
+    _In_ PDEVICE_OBJECT                 PhysicalDeviceObject,
+    _In_ XENFILT_EMULATED_OBJECT_TYPE   Type
     );
 
 extern VOID
 FdoDestroy(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     );
 
 extern PCHAR
 FdoGetPrefix(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     );
 
 extern VOID
 FdoAddPhysicalDeviceObject(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PXENFILT_PDO   Pdo
     );
 
 extern VOID
 FdoRemovePhysicalDeviceObject(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PXENFILT_PDO   Pdo
     );
 
 extern VOID
 FdoAcquireMutex(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     );
 
 extern VOID
 FdoReleaseMutex(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     );
 
 extern PDEVICE_OBJECT
 FdoGetDeviceObject(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     );
 
 extern PDEVICE_OBJECT
 FdoGetPhysicalDeviceObject(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     );
 
 extern BOOLEAN
 FdoHasEnumerated(
-    IN  PXENFILT_FDO    Fdo
+    _In_ PXENFILT_FDO   Fdo
     );
 
 extern NTSTATUS
 FdoDispatch(
-    IN  PXENFILT_FDO    Fdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_FDO   Fdo,
+    _In_ PIRP           Irp
     );
 
 #endif  // _XENFILT_FDO_H
diff --git a/src/xenfilt/pdo.c b/src/xenfilt/pdo.c
index 3ce30a8..9c6ba99 100644
--- a/src/xenfilt/pdo.c
+++ b/src/xenfilt/pdo.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -68,7 +68,7 @@ struct _XENFILT_PDO {
 
 static FORCEINLINE PVOID
 __PdoAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, PDO_TAG);
@@ -76,7 +76,7 @@ __PdoAllocate(
 
 static FORCEINLINE VOID
 __PdoFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, PDO_TAG);
@@ -84,8 +84,8 @@ __PdoFree(
 
 static FORCEINLINE VOID
 __PdoSetDevicePnpState(
-    IN  PXENFILT_PDO        Pdo,
-    IN  DEVICE_PNP_STATE    State
+    _In_ PXENFILT_PDO       Pdo,
+    _In_ DEVICE_PNP_STATE   State
     )
 {
     PXENFILT_DX             Dx = Pdo->Dx;
@@ -99,8 +99,8 @@ __PdoSetDevicePnpState(
 
 VOID
 PdoSetDevicePnpState(
-    IN  PXENFILT_PDO        Pdo,
-    IN  DEVICE_PNP_STATE    State
+    _In_ PXENFILT_PDO       Pdo,
+    _In_ DEVICE_PNP_STATE   State
     )
 {
     __PdoSetDevicePnpState(Pdo, State);
@@ -108,8 +108,8 @@ PdoSetDevicePnpState(
 
 static FORCEINLINE VOID
 __PdoRestoreDevicePnpState(
-    IN  PXENFILT_PDO        Pdo,
-    IN  DEVICE_PNP_STATE    State
+    _In_ PXENFILT_PDO       Pdo,
+    _In_ DEVICE_PNP_STATE   State
     )
 {
     PXENFILT_DX             Dx = Pdo->Dx;
@@ -120,7 +120,7 @@ __PdoRestoreDevicePnpState(
 
 static FORCEINLINE DEVICE_PNP_STATE
 __PdoGetDevicePnpState(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     PXENFILT_DX         Dx = Pdo->Dx;
@@ -130,7 +130,7 @@ __PdoGetDevicePnpState(
 
 DEVICE_PNP_STATE
 PdoGetDevicePnpState(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     return __PdoGetDevicePnpState(Pdo);
@@ -138,8 +138,8 @@ PdoGetDevicePnpState(
 
 static FORCEINLINE VOID
 __PdoSetDevicePowerState(
-    IN  PXENFILT_PDO        Pdo,
-    IN  DEVICE_POWER_STATE  State
+    _In_ PXENFILT_PDO       Pdo,
+    _In_ DEVICE_POWER_STATE State
     )
 {
     PXENFILT_DX             Dx = Pdo->Dx;
@@ -149,7 +149,7 @@ __PdoSetDevicePowerState(
 
 static FORCEINLINE DEVICE_POWER_STATE
 __PdoGetDevicePowerState(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     PXENFILT_DX         Dx = Pdo->Dx;
@@ -159,8 +159,8 @@ __PdoGetDevicePowerState(
 
 static FORCEINLINE VOID
 __PdoSetSystemPowerState(
-    IN  PXENFILT_PDO        Pdo,
-    IN  SYSTEM_POWER_STATE  State
+    _In_ PXENFILT_PDO       Pdo,
+    _In_ SYSTEM_POWER_STATE State
     )
 {
     PXENFILT_DX             Dx = Pdo->Dx;
@@ -170,7 +170,7 @@ __PdoSetSystemPowerState(
 
 static FORCEINLINE SYSTEM_POWER_STATE
 __PdoGetSystemPowerState(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     PXENFILT_DX         Dx = Pdo->Dx;
@@ -180,7 +180,7 @@ __PdoGetSystemPowerState(
 
 PDEVICE_OBJECT
 PdoGetPhysicalDeviceObject(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     return Pdo->PhysicalDeviceObject;
@@ -188,8 +188,8 @@ PdoGetPhysicalDeviceObject(
 
 static FORCEINLINE VOID
 __PdoSetMissing(
-    IN  PXENFILT_PDO    Pdo,
-    IN  const CHAR      *Reason
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ const CHAR     *Reason
     )
 {
     Pdo->Reason = Reason;
@@ -198,8 +198,8 @@ __PdoSetMissing(
 
 VOID
 PdoSetMissing(
-    IN  PXENFILT_PDO    Pdo,
-    IN  const CHAR      *Reason
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ const CHAR     *Reason
     )
 {
     __PdoSetMissing(Pdo, Reason);
@@ -207,7 +207,7 @@ PdoSetMissing(
 
 static FORCEINLINE BOOLEAN
 __PdoIsMissing(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     return Pdo->Missing;
@@ -215,7 +215,7 @@ __PdoIsMissing(
 
 BOOLEAN
 PdoIsMissing(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     return __PdoIsMissing(Pdo);
@@ -223,17 +223,17 @@ PdoIsMissing(
 
 static FORCEINLINE PDEVICE_OBJECT
 __PdoGetDeviceObject(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     PXENFILT_DX         Dx = Pdo->Dx;
 
     return Dx->DeviceObject;
 }
-    
+
 PDEVICE_OBJECT
 PdoGetDeviceObject(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     return __PdoGetDeviceObject(Pdo);
@@ -241,7 +241,7 @@ PdoGetDeviceObject(
 
 static FORCEINLINE PXENFILT_FDO
 __PdoGetFdo(
-    IN  PXENFILT_PDO Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     return Pdo->Fdo;
@@ -249,7 +249,7 @@ __PdoGetFdo(
 
 static NTSTATUS
 PdoSetDeviceInformation(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     PXENFILT_DX         Dx = Pdo->Dx;
@@ -328,7 +328,7 @@ fail1:
 
 static VOID
 PdoClearDeviceInformation(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     PXENFILT_DX         Dx = Pdo->Dx;
@@ -352,7 +352,7 @@ PdoClearDeviceInformation(
 
 static FORCEINLINE PCHAR
 __PdoGetDeviceID(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     PXENFILT_DX         Dx = Pdo->Dx;
@@ -363,7 +363,7 @@ __PdoGetDeviceID(
 
 static FORCEINLINE PCHAR
 __PdoGetInstanceID(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     PXENFILT_DX         Dx = Pdo->Dx;
@@ -374,7 +374,7 @@ __PdoGetInstanceID(
 
 static FORCEINLINE XENFILT_EMULATED_OBJECT_TYPE
 __PdoGetType(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     return Pdo->Type;
@@ -382,7 +382,7 @@ __PdoGetType(
 
 static FORCEINLINE PCHAR
 __PdoGetLocationInformation(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     PXENFILT_DX         Dx = Pdo->Dx;
@@ -393,7 +393,7 @@ __PdoGetLocationInformation(
 
 static FORCEINLINE VOID
 __PdoSetName(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     NTSTATUS            status;
@@ -415,19 +415,20 @@ __PdoSetName(
 
 static FORCEINLINE PCHAR
 __PdoGetName(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     return Pdo->Name;
 }
 
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
+static IO_COMPLETION_ROUTINE PdoForwardIrpSynchronouslyCompletion;
+
+_Use_decl_annotations_
 static NTSTATUS
 PdoForwardIrpSynchronouslyCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp,
+    PVOID               Context
     )
 {
     PKEVENT             Event = Context;
@@ -442,8 +443,8 @@ PdoForwardIrpSynchronouslyCompletion(
 
 static NTSTATUS
 PdoForwardIrpSynchronously(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     KEVENT              Event;
@@ -478,8 +479,8 @@ PdoForwardIrpSynchronously(
 
 static NTSTATUS
 PdoStartDevice(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     POWER_STATE         PowerState;
@@ -521,8 +522,8 @@ fail1:
 
 static NTSTATUS
 PdoQueryStopDevice(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     NTSTATUS            status;
@@ -550,8 +551,8 @@ fail1:
 
 static NTSTATUS
 PdoCancelStopDevice(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     NTSTATUS            status;
@@ -580,8 +581,8 @@ fail1:
 
 static NTSTATUS
 PdoStopDevice(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     POWER_STATE         PowerState;
@@ -621,8 +622,8 @@ fail1:
 
 static NTSTATUS
 PdoQueryRemoveDevice(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     NTSTATUS            status;
@@ -650,8 +651,8 @@ fail1:
 
 static NTSTATUS
 PdoCancelRemoveDevice(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     NTSTATUS            status;
@@ -679,8 +680,8 @@ fail1:
 
 static NTSTATUS
 PdoSurpriseRemoval(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     NTSTATUS            status;
@@ -708,8 +709,8 @@ fail1:
 
 static NTSTATUS
 PdoRemoveDevice(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     PXENFILT_FDO        Fdo = __PdoGetFdo(Pdo);
@@ -773,8 +774,8 @@ fail1:
 #define DEFINE_PDO_QUERY_INTERFACE(_Interface)                      \
 static NTSTATUS                                                     \
 PdoQuery ## _Interface ## Interface(                                \
-    IN  PXENFILT_PDO    Pdo,                                        \
-    IN  PIRP            Irp                                         \
+    _In_ PXENFILT_PDO   Pdo,                                        \
+    _In_ PIRP           Irp                                         \
     )                                                               \
 {                                                                   \
     PIO_STACK_LOCATION  StackLocation;                              \
@@ -827,8 +828,8 @@ struct _INTERFACE_ENTRY PdoInterfaceTable[] = {
 
 static NTSTATUS
 PdoQueryInterface(
-    IN  PXENFILT_PDO        Pdo,
-    IN  PIRP                Irp
+    _In_ PXENFILT_PDO       Pdo,
+    _In_ PIRP               Irp
     )
 {
     PIO_STACK_LOCATION      StackLocation;
@@ -878,8 +879,8 @@ fail1:
 
 static NTSTATUS
 PdoQueryDeviceText(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -970,8 +971,8 @@ fail1:
 
 static NTSTATUS
 PdoQueryId(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1075,8 +1076,8 @@ fail1:
 
 static NTSTATUS
 PdoEject(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     PXENFILT_FDO        Fdo = __PdoGetFdo(Pdo);
@@ -1099,8 +1100,8 @@ PdoEject(
 
 static NTSTATUS
 PdoDispatchPnp(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1182,13 +1183,14 @@ fail1:
     return status;
 }
 
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
+static IO_COMPLETION_ROUTINE PdoSetDevicePowerUpComplete;
+
+_Use_decl_annotations_
 static NTSTATUS
 PdoSetDevicePowerUpComplete(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp,
+    PVOID               Context
     )
 {
     PXENFILT_PDO        Pdo = (PXENFILT_PDO)Context;
@@ -1221,8 +1223,8 @@ PdoSetDevicePowerUpComplete(
 
 static FORCEINLINE NTSTATUS
 __PdoSetDevicePowerUp(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     IoCopyCurrentIrpStackLocationToNext(Irp);
@@ -1237,8 +1239,8 @@ __PdoSetDevicePowerUp(
 
 static NTSTATUS
 __PdoSetDevicePowerDown(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1266,8 +1268,8 @@ __PdoSetDevicePowerDown(
 
 static NTSTATUS
 PdoSetDevicePower(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1281,7 +1283,7 @@ PdoSetDevicePower(
 
     Trace("%s: ====> (%s:%s)\n",
           __PdoGetName(Pdo),
-          DevicePowerStateName(DeviceState), 
+          DevicePowerStateName(DeviceState),
           PowerActionName(PowerAction));
 
     if (DeviceState == __PdoGetDevicePowerState(Pdo)) {
@@ -1298,7 +1300,7 @@ PdoSetDevicePower(
 done:
     Trace("%s: <==== (%s:%s)(%08x)\n",
           __PdoGetName(Pdo),
-          DevicePowerStateName(DeviceState), 
+          DevicePowerStateName(DeviceState),
           PowerActionName(PowerAction),
           status);
     return status;
@@ -1306,8 +1308,8 @@ done:
 
 static FORCEINLINE NTSTATUS
 __PdoDispatchDevicePower(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1331,13 +1333,14 @@ __PdoDispatchDevicePower(
     return status;
 }
 
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
+static IO_COMPLETION_ROUTINE PdoSetSystemPowerUpComplete;
+
+_Use_decl_annotations_
 static NTSTATUS
 PdoSetSystemPowerUpComplete(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
+    PDEVICE_OBJECT      DeviceObject,
+    PIRP                Irp,
+    PVOID               Context
     )
 {
     PXENFILT_PDO        Pdo = (PXENFILT_PDO)Context;
@@ -1366,8 +1369,8 @@ PdoSetSystemPowerUpComplete(
 
 static FORCEINLINE NTSTATUS
 __PdoSetSystemPowerUp(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     IoCopyCurrentIrpStackLocationToNext(Irp);
@@ -1382,8 +1385,8 @@ __PdoSetSystemPowerUp(
 
 static FORCEINLINE NTSTATUS
 __PdoSetSystemPowerDown(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1407,8 +1410,8 @@ __PdoSetSystemPowerDown(
 
 static NTSTATUS
 PdoSetSystemPower(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1422,7 +1425,7 @@ PdoSetSystemPower(
 
     Trace("%s: ====> (%s:%s)\n",
           __PdoGetName(Pdo),
-          SystemPowerStateName(SystemState), 
+          SystemPowerStateName(SystemState),
           PowerActionName(PowerAction));
 
     if (SystemState == __PdoGetSystemPowerState(Pdo)) {
@@ -1439,7 +1442,7 @@ PdoSetSystemPower(
 done:
     Trace("%s: <==== (%s:%s)(%08x)\n",
           __PdoGetName(Pdo),
-          SystemPowerStateName(SystemState), 
+          SystemPowerStateName(SystemState),
           PowerActionName(PowerAction),
           status);
     return status;
@@ -1447,8 +1450,8 @@ done:
 
 static FORCEINLINE NTSTATUS
 __PdoDispatchSystemPower(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1474,8 +1477,8 @@ __PdoDispatchSystemPower(
 
 static NTSTATUS
 PdoDispatchPower(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1503,8 +1506,8 @@ PdoDispatchPower(
 
     Trace("%s: ====> (%02x:%s)\n",
           __PdoGetName(Pdo),
-          MinorFunction, 
-          PowerMinorFunctionName(MinorFunction)); 
+          MinorFunction,
+          PowerMinorFunctionName(MinorFunction));
 
     switch (PowerType) {
     case DevicePowerState:
@@ -1527,7 +1530,7 @@ PdoDispatchPower(
 
     Trace("%s: <==== (%02x:%s) (%08x)\n",
           __PdoGetName(Pdo),
-          MinorFunction, 
+          MinorFunction,
           PowerMinorFunctionName(MinorFunction),
           status);
 
@@ -1545,8 +1548,8 @@ fail1:
 
 static NTSTATUS
 PdoDispatchDefault(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     NTSTATUS            status;
@@ -1573,8 +1576,8 @@ fail1:
 
 NTSTATUS
 PdoDispatch(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     )
 {
     PIO_STACK_LOCATION  StackLocation;
@@ -1601,7 +1604,7 @@ PdoDispatch(
 
 VOID
 PdoResume(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     UNREFERENCED_PARAMETER(Pdo);
@@ -1609,7 +1612,7 @@ PdoResume(
 
 VOID
 PdoSuspend(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     )
 {
     UNREFERENCED_PARAMETER(Pdo);
@@ -1617,18 +1620,18 @@ PdoSuspend(
 
 NTSTATUS
 PdoCreate(
-    PXENFILT_FDO                    Fdo,
-    PDEVICE_OBJECT                  PhysicalDeviceObject,
-    XENFILT_EMULATED_OBJECT_TYPE    Type
+    _In_ PXENFILT_FDO                   Fdo,
+    _In_ PDEVICE_OBJECT                 PhysicalDeviceObject,
+    _In_ XENFILT_EMULATED_OBJECT_TYPE   Type
     )
 {
-    PDEVICE_OBJECT                  LowerDeviceObject;
-    ULONG                           DeviceType;
-    PDEVICE_OBJECT                  FilterDeviceObject;
-    PXENFILT_DX                     Dx;
-    PXENFILT_PDO                    Pdo;
-    PCHAR                           CompatibleIDs;
-    NTSTATUS                        status;
+    PDEVICE_OBJECT                      LowerDeviceObject;
+    ULONG                               DeviceType;
+    PDEVICE_OBJECT                      FilterDeviceObject;
+    PXENFILT_DX                         Dx;
+    PXENFILT_PDO                        Pdo;
+    PCHAR                               CompatibleIDs;
+    NTSTATUS                            status;
 
     ASSERT(Type != XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN);
 
@@ -1757,7 +1760,7 @@ fail1:
 
 VOID
 PdoDestroy(
-    IN  PXENFILT_PDO            Pdo
+    _In_ PXENFILT_PDO           Pdo
     )
 {
     PDEVICE_OBJECT              LowerDeviceObject = Pdo->LowerDeviceObject;
diff --git a/src/xenfilt/pdo.h b/src/xenfilt/pdo.h
index 5b8d920..fbce164 100644
--- a/src/xenfilt/pdo.h
+++ b/src/xenfilt/pdo.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -43,67 +43,67 @@ typedef struct _XENFILT_PDO XENFILT_PDO, *PXENFILT_PDO;
 
 extern VOID
 PdoSetDevicePnpState(
-    IN  PXENFILT_PDO        Pdo,
-    IN  DEVICE_PNP_STATE    State
+    _In_ PXENFILT_PDO       Pdo,
+    _In_ DEVICE_PNP_STATE   State
     );
 
 extern DEVICE_PNP_STATE
 PdoGetDevicePnpState(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     );
 
 extern PDEVICE_OBJECT
 PdoGetPhysicalDeviceObject(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     );
 
 extern BOOLEAN
 PdoIsMissing(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     );
 
 extern VOID
 PdoSetMissing(
-    IN  PXENFILT_PDO    Pdo,
-    IN  const CHAR      *Reason
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ const CHAR     *Reason
     );
 
 extern BOOLEAN
 PdoIsMasked(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     );
 
 extern PDEVICE_OBJECT
 PdoGetDeviceObject(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     );
 
 extern NTSTATUS
 PdoCreate(
-    IN  PXENFILT_FDO                    Fdo,
-    IN  PDEVICE_OBJECT                  PhysicalDeviceObject,
-    IN  XENFILT_EMULATED_OBJECT_TYPE    Type
+    _In_ PXENFILT_FDO                   Fdo,
+    _In_ PDEVICE_OBJECT                 PhysicalDeviceObject,
+    _In_ XENFILT_EMULATED_OBJECT_TYPE   Type
     );
 
 extern VOID
 PdoResume(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     );
 
 extern VOID
 PdoSuspend(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     );
 
 extern VOID
 PdoDestroy(
-    IN  PXENFILT_PDO    Pdo
+    _In_ PXENFILT_PDO   Pdo
     );
 
 extern NTSTATUS
 PdoDispatch(
-    IN  PXENFILT_PDO    Pdo,
-    IN  PIRP            Irp
+    _In_ PXENFILT_PDO   Pdo,
+    _In_ PIRP           Irp
     );
 
 #endif  // _XENFILT_PDO_H
diff --git a/src/xenfilt/thread.c b/src/xenfilt/thread.c
index fe8639b..34bac05 100644
--- a/src/xenfilt/thread.c
+++ b/src/xenfilt/thread.c
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -50,7 +50,7 @@ struct _XENFILT_THREAD {
 
 static FORCEINLINE PVOID
 __ThreadAllocate(
-    IN  ULONG   Length
+    _In_ ULONG  Length
     )
 {
     return __AllocatePoolWithTag(NonPagedPool, Length, THREAD_TAG);
@@ -58,7 +58,7 @@ __ThreadAllocate(
 
 static FORCEINLINE VOID
 __ThreadFree(
-    IN  PVOID   Buffer
+    _In_ PVOID  Buffer
     )
 {
     __FreePoolWithTag(Buffer, THREAD_TAG);
@@ -66,7 +66,7 @@ __ThreadFree(
 
 static FORCEINLINE VOID
 __ThreadWake(
-    IN  PXENFILT_THREAD Thread
+    _In_ PXENFILT_THREAD    Thread
     )
 {
     KeSetEvent(&Thread->Event, IO_NO_INCREMENT, FALSE);
@@ -74,7 +74,7 @@ __ThreadWake(
 
 VOID
 ThreadWake(
-    IN  PXENFILT_THREAD Thread
+    _In_ PXENFILT_THREAD    Thread
     )
 {
     __ThreadWake(Thread);
@@ -82,7 +82,7 @@ ThreadWake(
 
 static FORCEINLINE VOID
 __ThreadAlert(
-    IN  PXENFILT_THREAD Thread
+    _In_ PXENFILT_THREAD    Thread
     )
 {
     Thread->Alerted = TRUE;
@@ -91,7 +91,7 @@ __ThreadAlert(
 
 VOID
 ThreadAlert(
-    IN  PXENFILT_THREAD Thread
+    _In_ PXENFILT_THREAD    Thread
     )
 {
     __ThreadAlert(Thread);
@@ -101,7 +101,7 @@ KSTART_ROUTINE  ThreadFunction;
 
 VOID
 ThreadFunction(
-    IN  PVOID       Argument
+    _In_ PVOID      Argument
     )
 {
     PXENFILT_THREAD Self = Argument;
@@ -116,16 +116,16 @@ ThreadFunction(
     // NOT REACHED
 }
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 NTSTATUS
 ThreadCreate(
-    IN  XENFILT_THREAD_FUNCTION Function,
-    IN  PVOID                   Context,
-    OUT PXENFILT_THREAD         *Thread
+    _In_ XENFILT_THREAD_FUNCTION    Function,
+    _In_ PVOID                      Context,
+    _Out_ PXENFILT_THREAD           *Thread
     )
 {
-    HANDLE                      Handle;
-    NTSTATUS                    status;
+    HANDLE                          Handle;
+    NTSTATUS                        status;
 
     ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
 
@@ -189,7 +189,7 @@ fail1:
 
 PKEVENT
 ThreadGetEvent(
-    IN  PXENFILT_THREAD Thread
+    _In_ PXENFILT_THREAD    Thread
     )
 {
     return &Thread->Event;
@@ -197,7 +197,7 @@ ThreadGetEvent(
 
 BOOLEAN
 ThreadIsAlerted(
-    IN  PXENFILT_THREAD Thread
+    _In_ PXENFILT_THREAD    Thread
     )
 {
     return Thread->Alerted;
@@ -205,7 +205,7 @@ ThreadIsAlerted(
 
 VOID
 ThreadJoin(
-    IN  PXENFILT_THREAD Thread
+    _In_ PXENFILT_THREAD    Thread
     )
 {
     LONG                References;
diff --git a/src/xenfilt/thread.h b/src/xenfilt/thread.h
index d3c4975..2d6d784 100644
--- a/src/xenfilt/thread.h
+++ b/src/xenfilt/thread.h
@@ -1,32 +1,32 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
@@ -39,37 +39,37 @@ typedef struct _XENFILT_THREAD XENFILT_THREAD, *PXENFILT_THREAD;
 
 typedef NTSTATUS (*XENFILT_THREAD_FUNCTION)(PXENFILT_THREAD, PVOID);
 
-__drv_requiresIRQL(PASSIVE_LEVEL)
+_IRQL_requires_(PASSIVE_LEVEL)
 extern NTSTATUS
 ThreadCreate(
-    IN  XENFILT_THREAD_FUNCTION Function,
-    IN  PVOID                   Context,
-    OUT PXENFILT_THREAD         *Thread
+    _In_ XENFILT_THREAD_FUNCTION    Function,
+    _In_ PVOID                      Context,
+    _Out_ PXENFILT_THREAD           *Thread
     );
 
 extern PKEVENT
 ThreadGetEvent(
-    IN  PXENFILT_THREAD Self
+    _In_ PXENFILT_THREAD    Self
     );
 
 extern BOOLEAN
 ThreadIsAlerted(
-    IN  PXENFILT_THREAD Self
+    _In_ PXENFILT_THREAD    Self
     );
 
 extern VOID
 ThreadWake(
-    IN  PXENFILT_THREAD Thread
+    _In_ PXENFILT_THREAD    Thread
     );
 
 extern VOID
 ThreadAlert(
-    IN  PXENFILT_THREAD Thread
+    _In_ PXENFILT_THREAD    Thread
     );
 
 extern VOID
 ThreadJoin(
-    IN  PXENFILT_THREAD Thread
+    _In_ PXENFILT_THREAD    Thread
     );
 
 #endif  // _XENFILT_THREAD_H
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:25 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025016.1400796 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCj-0008T6-Ew; Wed, 25 Jun 2025 14:34:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025016.1400796; Wed, 25 Jun 2025 14:34:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCj-0008Sp-9W; Wed, 25 Jun 2025 14:34:25 +0000
Received: by outflank-mailman (input) for mailman id 1025016;
 Wed, 25 Jun 2025 14:34:23 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=wc18=ZI=bounce.vates.tech=bounce-md_30504962.685c08e6.v1-28f065ad2cdc4b598b449e4db1cb7654@srs-se1.protection.inumbo.net>)
 id 1uURCh-0008AM-Ox
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:23 +0000
Received: from mail180-2.suw31.mandrillapp.com
 (mail180-2.suw31.mandrillapp.com [198.2.180.2])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 7b28b647-51d1-11f0-a30f-13f23c93f187;
 Wed, 25 Jun 2025 16:34:20 +0200 (CEST)
Received: from pmta11.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail180-2.suw31.mandrillapp.com (Mailchimp) with ESMTP id 4bS4864pNBzS62Rtt
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:14 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 28f065ad2cdc4b598b449e4db1cb7654; Wed, 25 Jun 2025 14:34:14 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7b28b647-51d1-11f0-a30f-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862054; x=1751132054;
	bh=qiQRr9Lr4JaBmQOzrKen6CFIBcd4P8FXPnPChR22ijA=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=1UU7HhNehU7DSrR6h9Sfwi53zyssE4Vy1rMJAXlNdcYNitTBC7qF3UvfbF9BNxFNN
	 SMuaiNousIOSjqFR5Zw4y7hnteyiYo9nHsJ6HkHosKIwDhXekusCITuKv2TBKQc/fd
	 zn8jxdbnUmd/NSEG4P1CowKW9AWMBhGwQYwh+yBsVuBnt9/MVXZQQQFIBgWQLi68vF
	 CmoVTC8tZBoEJcIoTl/2zfasTjaL9wFLlfW/t1XWAGIqtfvOEatz5kxbuvM/RvEU0x
	 vNDZOD+u7o5NZnzq1+Tg3wnguMJ6B6nxY2B9T8BVanxs9Vwptj/BShu+Rx3vCD+4M1
	 mvjPqg8Oe0Seg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862054; x=1751122554; i=ngoc-tu.dinh@vates.tech;
	bh=qiQRr9Lr4JaBmQOzrKen6CFIBcd4P8FXPnPChR22ijA=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=qLKiTlMo/h4XuqXNqiel81kwd8loD1804N4j+TcYj5ZDDzievwRdE15oqJnfTyXIZ
	 /y7NuQtqLlwW6K7NKjO2J9lZGoyQUyxyk98qwOReDeSlLcuASvscZPF9L3VedC1afg
	 vtXs4zei1HK6Z3Ei5vtJCNdCuM8Xat+W+oMliDsyNGGpSMJADUznYiA9gADzoSFOjE
	 XI8ClhXNYV8xlhFK/AyrJVBIOSJYi96oMC1bseQzoRt2C1NvdF5rkd3MNwhi0hWWVs
	 8g3aWXwviHYiZTVtunl3x21bz8pQrrCBCE5Sa7432JdUtrOutBHfwpb3sUNJQ8gSE2
	 vp+P2EK319M5g==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2009/13]=20monitor:=20Fix=20GetRequestKeyName=20allocation=20check?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862053992
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-10-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
References: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.28f065ad2cdc4b598b449e4db1cb7654?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:14 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

The wrong pointer was tested.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index ae20ac7..e36b1ff 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1118,7 +1118,7 @@ GetRequestKeyName(
     RequestKeyNameLength = MaxValueLength + sizeof (TCHAR);
 
     *RequestKeyName = calloc(1, RequestKeyNameLength);
-    if (RequestKeyName == NULL)
+    if (*RequestKeyName == NULL)
         goto fail2;
 
     Error = RegQueryValueEx(Context->ParametersKey,
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:25 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025017.1400800 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCj-0008Ts-KX; Wed, 25 Jun 2025 14:34:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025017.1400800; Wed, 25 Jun 2025 14:34:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCj-0008TN-Br; Wed, 25 Jun 2025 14:34:25 +0000
Received: by outflank-mailman (input) for mailman id 1025017;
 Wed, 25 Jun 2025 14:34:23 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=axAJ=ZI=bounce.vates.tech=bounce-md_30504962.685c08e7.v1-35a8829d4fdd4062baa41976ceebbd47@srs-se1.protection.inumbo.net>)
 id 1uURCh-000871-Og
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:23 +0000
Received: from mail134-21.atl141.mandrillapp.com
 (mail134-21.atl141.mandrillapp.com [198.2.134.21])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 7b1a6ada-51d1-11f0-b894-0df219b8e170;
 Wed, 25 Jun 2025 16:34:20 +0200 (CEST)
Received: from pmta10.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail134-21.atl141.mandrillapp.com (Mailchimp) with ESMTP id
 4bS4872z2zz1XLP5M
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:15 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 35a8829d4fdd4062baa41976ceebbd47; Wed, 25 Jun 2025 14:34:15 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7b1a6ada-51d1-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862055; x=1751132055;
	bh=YYD7BoyLfVQHSwk/PZxDkwTZwgDJTkZfOo8wtOD2sFI=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=prkXSLxGb0voKwPJix6yud56KF6NEXud0XU3T2hW+VYMMLQguvIPLkG7661cKpf1t
	 eNqXcHsGb+I3/yC3eKBRHn3BL4aH4uUACJ4lgBgU7Oke4fOx5xKMBQUChfH2Nr0ZyK
	 hfjCmjpsmZW5CryxSKSpAt965WmAEw2SUXxPigCInvfSN3SSHYINqtMQLsWjG4LHE/
	 yA+LoWLRf7mNq8NwISzT3mAUBuhJO1piIeeHm/gRSJtBoLuFSHDGcNnFFQKdpc+jR9
	 OF0vRLRkXrNMT2MgbM3YFszVQS0t42Gs7VwZ0u0zwjQuvwHdHyp2KAhDibDVd0Ja6R
	 p0LRjgv+Tp3zA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862055; x=1751122555; i=ngoc-tu.dinh@vates.tech;
	bh=YYD7BoyLfVQHSwk/PZxDkwTZwgDJTkZfOo8wtOD2sFI=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=r1JU/wsnqB6bXsddSgD+3LZpAeF4Q7gEXslAokZKVw1KaEQ5U7pRVvHnCE5qnr0Ft
	 zIYqK5aEazV7Av6TuUwJHZrN9VKUjTVhZ+J3H9r+Cc9unk3zgHa+A25b+W6U9WbX3o
	 DhutwZjby8OkKO2NdOY4o7/mssueGh1JXKLq5ZY9lBs8R9YhNSigcmQGb74fFw1OQ/
	 roQMH+PgTz2//Vb2lSdJrqS6xchFl6yUmxXk96pHKOjFrmemB0o+N/C2DP0LmwsGmD
	 ECYgxFZt74RFo26pwfrm9csYVs2o0hH7kM9wHWa7zc8jQVLm5df/NBsjCJ2vi3XiuS
	 ChdPwbk4VovBg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2013/13]=20Explicitly=20check=20HvmGetParam=20result=20via=20BUG=5FON?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862054809
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-14-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
References: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.35a8829d4fdd4062baa41976ceebbd47?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:15 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

The existing ASSERT only works in debug mode.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenbus/store.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/xenbus/store.c b/src/xenbus/store.c
index b0f2332..afb1954 100644
--- a/src/xenbus/store.c
+++ b/src/xenbus/store.c
@@ -2205,7 +2205,7 @@ StoreEnable(
     NTSTATUS                    status;
 
     status = HvmGetParam(HVM_PARAM_STORE_EVTCHN, &Value);
-    ASSERT(NT_SUCCESS(status));
+    BUG_ON(!NT_SUCCESS(status));
 
     Port = (ULONG)Value;
 
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:25 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025018.1400802 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCj-0008V5-Mf; Wed, 25 Jun 2025 14:34:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025018.1400802; Wed, 25 Jun 2025 14:34:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCj-0008Tk-Gz; Wed, 25 Jun 2025 14:34:25 +0000
Received: by outflank-mailman (input) for mailman id 1025018;
 Wed, 25 Jun 2025 14:34:24 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=YgnI=ZI=bounce.vates.tech=bounce-md_30504962.685c08e7.v1-4f0161d9e87d4c42b704752102483415@srs-se1.protection.inumbo.net>)
 id 1uURCi-000871-08
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:24 +0000
Received: from mail180-2.suw31.mandrillapp.com
 (mail180-2.suw31.mandrillapp.com [198.2.180.2])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 7b96b103-51d1-11f0-b894-0df219b8e170;
 Wed, 25 Jun 2025 16:34:21 +0200 (CEST)
Received: from pmta11.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail180-2.suw31.mandrillapp.com (Mailchimp) with ESMTP id 4bS4871WqVzS62Rtx
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:15 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 4f0161d9e87d4c42b704752102483415; Wed, 25 Jun 2025 14:34:15 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7b96b103-51d1-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862055; x=1751132055;
	bh=hlfolBRW0pGvLt2aaa2NzSdzy46ooBSOBGacjx3FkYo=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=12+qyNjmTR+drHxCIPo1S8KaE5NBZMk5G4VFvAs8HbBeV1ZFtR7TMngEQJV5lmyDA
	 OwUsHaCiH3mtdj8sIkFUZqe87bhrum++sAF+UzOwYRGU1GOR4zpaTbVXPJWsCfR48K
	 DeKYCw7xxePSqxweR1bSWGYzBAe0ct9uH0jp1ElZfMm6qbT7bwSTzDRs836nQymvHu
	 BQsCz+RWVJv50Iscku3isyPLx4TqeBWCOcEBALslSDa+ZjLC5SrEotG6qpNa0k/iwO
	 mv8GGm7TFBHIUyQzQULcO5yzbofJ7fiYhDfer1cn6evS+f8+aMlS3nO3PobuQOAJBA
	 dcC37+1/pAANw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862055; x=1751122555; i=ngoc-tu.dinh@vates.tech;
	bh=hlfolBRW0pGvLt2aaa2NzSdzy46ooBSOBGacjx3FkYo=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=XZuOVj40ZUhocDBmuglFWONHS9qaThRXNiElrD4WuHIy5SLBYRaGGZ62SDZ+8cmNY
	 Sg8nh3Z65iJZjmYqNmpM0LW5thIvFW38bttQVfGlajJnozwVLB/8Imj+gFcprCtZr5
	 x9KYKjW4pa1ysh5sYdXD46SUibuKWDcv77x87HKqosBXIMWKECflWy2yqlh1/+ChJd
	 5r1hIMRBxBpXryhP2FBEux/KKPcqsJDlRWuJ6nCteC87gtXr5uYtFWC1NZvEzdSZpM
	 Y977Onu/igWfeHMPdZFaKiLG8yqU1yWKIEJQCKf6OUCcnUfjq6kEoLgb82KiTyTXjZ
	 K3HMIBAF6bN7w==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2012/13]=20sync:=20Save/restore=20IRQL=20when=20disabling=20interrupts?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862054568
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-13-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
References: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.4f0161d9e87d4c42b704752102483415?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:15 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Doing so helps the compiler analyze IRQLs properly and avoids having to
suppress warnings.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenbus/suspend.c |  6 +++---
 src/xenbus/sync.c    | 50 ++++++++++++++++++++++++--------------------
 src/xenbus/sync.h    |  6 +++---
 3 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/src/xenbus/suspend.c b/src/xenbus/suspend.c
index 510973b..ffab58f 100644
--- a/src/xenbus/suspend.c
+++ b/src/xenbus/suspend.c
@@ -251,13 +251,13 @@ SuspendLate(
 }
 
 NTSTATUS
-#pragma prefast(suppress:28167) // Function changes IRQL
 SuspendTrigger(
     _In_ PINTERFACE         Interface
     )
 {
     PXENBUS_SUSPEND_CONTEXT Context = Interface->Context;
     KIRQL                   Irql;
+    KIRQL                   InterruptIrql;
     NTSTATUS                status;
 
     KeRaiseIrql(DISPATCH_LEVEL, &Irql);
@@ -266,7 +266,7 @@ SuspendTrigger(
               "SUSPEND: ====>\n");
 
     SyncCapture(Context, SuspendEarly, SuspendLate);
-    SyncDisableInterrupts();
+    SyncDisableInterrupts(&InterruptIrql);
 
     __SuspendLogTimers("PRE-SUSPEND");
 
@@ -282,7 +282,7 @@ SuspendTrigger(
     if (NT_SUCCESS(status))
         SyncRunEarly();
 
-    SyncEnableInterrupts();
+    SyncEnableInterrupts(InterruptIrql);
 
     if (NT_SUCCESS(status))
         SyncRunLate();
diff --git a/src/xenbus/sync.c b/src/xenbus/sync.c
index bf7ad0f..804df88 100644
--- a/src/xenbus/sync.c
+++ b/src/xenbus/sync.c
@@ -146,13 +146,13 @@ KDEFERRED_ROUTINE   SyncWorker;
 #pragma intrinsic(_enable)
 #pragma intrinsic(_disable)
 
-#pragma warning(push)
-#pragma warning(disable:28167) // Function changes IRQL and does not restore it before exit
-#pragma warning(disable:28156) // Actual IRQL is inconsistent with required IRQL
-
+_Must_inspect_result_
+_IRQL_requires_(DISPATCH_LEVEL)
+_When_(NT_SUCCESS(return), _IRQL_raises_(HIGH_LEVEL))
 static FORCEINLINE NTSTATUS
 __SyncProcessorDisableInterrupts(
-    VOID
+    _At_(*Irql, _IRQL_saves_)
+    _Out_ PKIRQL    Irql
     )
 {
     PSYNC_CONTEXT   Context = &SyncContext;
@@ -161,7 +161,7 @@ __SyncProcessorDisableInterrupts(
     LONG            New;
     NTSTATUS        status;
 
-    (VOID) KfRaiseIrql(HIGH_LEVEL);
+    KeRaiseIrql(HIGH_LEVEL, Irql);
     status = STATUS_SUCCESS;
 
     InterlockedIncrement(&Context->CompletionCount);
@@ -185,8 +185,7 @@ __SyncProcessorDisableInterrupts(
     } while (InterlockedCompareExchange(&Context->CompletionCount, New, Old) != Old);
 
     if (Old < Context->ProcessorCount) {
-#pragma prefast(suppress:28138) // Use constant rather than variable
-        KeLowerIrql(DISPATCH_LEVEL);
+        KeLowerIrql(*Irql);
         status = STATUS_UNSUCCESSFUL;
     }
 
@@ -209,17 +208,17 @@ __SyncProcessorRunEarly(
     InterlockedIncrement(&Context->CompletionCount);
 }
 
+_IRQL_requires_(HIGH_LEVEL)
 static FORCEINLINE VOID
 __SyncProcessorEnableInterrupts(
-    VOID
+    _In_ _IRQL_restores_ KIRQL  Irql
     )
 {
-    PSYNC_CONTEXT   Context = &SyncContext;
+    PSYNC_CONTEXT               Context = &SyncContext;
 
     _enable();
 
-#pragma prefast(suppress:28138) // Use constant rather than variable
-    KeLowerIrql(DISPATCH_LEVEL);
+    KeLowerIrql(Irql);
 
     InterlockedIncrement(&Context->CompletionCount);
 }
@@ -254,8 +253,8 @@ __SyncWait(
     }
 }
 
+_Use_decl_annotations_
 VOID
-#pragma prefast(suppress:28166) // Function does not restore IRQL
 SyncWorker(
     PKDPC               Dpc,
     PVOID               _Context,
@@ -267,12 +266,15 @@ SyncWorker(
     ULONG               Index;
     PROCESSOR_NUMBER    ProcNumber = { 0 };
     SYNC_REQUEST        Request;
+    KIRQL               Irql;
 
     UNREFERENCED_PARAMETER(Dpc);
     UNREFERENCED_PARAMETER(_Context);
     UNREFERENCED_PARAMETER(Argument1);
     UNREFERENCED_PARAMETER(Argument2);
 
+    Irql = DISPATCH_LEVEL;
+
     Index = KeGetCurrentProcessorNumberEx(&ProcNumber);
 
     ASSERT(SyncOwner >= 0 && Index != (ULONG)SyncOwner);
@@ -298,7 +300,7 @@ SyncWorker(
 
         switch (Context->Request) {
         case SYNC_REQUEST_DISABLE_INTERRUPTS:
-            status = __SyncProcessorDisableInterrupts();
+            status = __SyncProcessorDisableInterrupts(&Irql);
             break;
 
         case SYNC_REQUEST_RUN_EARLY:
@@ -306,7 +308,8 @@ SyncWorker(
             break;
 
         case SYNC_REQUEST_ENABLE_INTERRUPTS:
-            __SyncProcessorEnableInterrupts();
+            _Analysis_assume_(KeGetCurrentIrql() == HIGH_LEVEL);
+            __SyncProcessorEnableInterrupts(Irql);
             break;
 
         case SYNC_REQUEST_RUN_LATE:
@@ -321,6 +324,8 @@ SyncWorker(
             Request = Context->Request;
     }
 
+    ASSERT3U(KeGetCurrentIrql(), ==, DISPATCH_LEVEL);
+
     Trace("<==== (%u:%u)\n", ProcNumber.Group, ProcNumber.Number);
     InterlockedIncrement(&Context->CompletionCount);
 }
@@ -391,7 +396,8 @@ _IRQL_requires_(DISPATCH_LEVEL)
 _IRQL_raises_(HIGH_LEVEL)
 VOID
 SyncDisableInterrupts(
-    VOID
+    _At_(*Irql, _IRQL_saves_)
+    _Out_ PKIRQL    Irql
     )
 {
     PSYNC_CONTEXT   Context = &SyncContext;
@@ -408,7 +414,8 @@ SyncDisableInterrupts(
     KeMemoryBarrier();
 
     for (;;) {
-        status = __SyncProcessorDisableInterrupts();
+        status = __SyncProcessorDisableInterrupts(Irql);
+        _Analysis_assume_(NT_SUCCESS(status));
         if (NT_SUCCESS(status))
             break;
 
@@ -437,19 +444,19 @@ SyncRunEarly(
 }
 
 _IRQL_requires_(HIGH_LEVEL)
-_IRQL_raises_(DISPATCH_LEVEL)
 VOID
 SyncEnableInterrupts(
+    _In_ _IRQL_restores_ KIRQL  Irql
     )
 {
-    PSYNC_CONTEXT   Context = &SyncContext;
+    PSYNC_CONTEXT               Context = &SyncContext;
 
     ASSERT(SyncOwner >= 0);
 
     Context->CompletionCount = 0;
     KeMemoryBarrier();
 
-    __SyncProcessorEnableInterrupts();
+    __SyncProcessorEnableInterrupts(Irql);
 
     Context->Request = SYNC_REQUEST_ENABLE_INTERRUPTS;
     KeMemoryBarrier();
@@ -482,7 +489,6 @@ SyncRunLate(
 
 _IRQL_requires_(DISPATCH_LEVEL)
 VOID
-#pragma prefast(suppress:28167) // Function changes IRQL
 SyncRelease(
     VOID
     )
@@ -510,5 +516,3 @@ SyncRelease(
 
     Trace("<====\n");
 }
-
-#pragma warning(pop)
diff --git a/src/xenbus/sync.h b/src/xenbus/sync.h
index 9707548..701562f 100644
--- a/src/xenbus/sync.h
+++ b/src/xenbus/sync.h
@@ -56,7 +56,8 @@ _IRQL_requires_(DISPATCH_LEVEL)
 _IRQL_raises_(HIGH_LEVEL)
 VOID
 SyncDisableInterrupts(
-    VOID
+    _At_(*Irql, _IRQL_saves_)
+    _Out_ PKIRQL    Irql
     );
 
 extern
@@ -68,10 +69,9 @@ SyncRunEarly(
 
 extern
 _IRQL_requires_(HIGH_LEVEL)
-_IRQL_raises_(DISPATCH_LEVEL)
 VOID
 SyncEnableInterrupts(
-    VOID
+    _In_ _IRQL_restores_ KIRQL  Irql
     );
 
 extern
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Jun 25 14:34:26 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 25 Jun 2025 14:34:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1025019.1400809 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCk-00008x-18; Wed, 25 Jun 2025 14:34:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1025019.1400809; Wed, 25 Jun 2025 14:34:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uURCj-00007J-Rz; Wed, 25 Jun 2025 14:34:25 +0000
Received: by outflank-mailman (input) for mailman id 1025019;
 Wed, 25 Jun 2025 14:34:24 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=5+QA=ZI=bounce.vates.tech=bounce-md_30504962.685c08e6.v1-d767e59cf8ff47409c9915935199bd73@srs-se1.protection.inumbo.net>)
 id 1uURCi-0008AM-PJ
 for win-pv-devel@lists.xenproject.org; Wed, 25 Jun 2025 14:34:24 +0000
Received: from mail180-2.suw31.mandrillapp.com
 (mail180-2.suw31.mandrillapp.com [198.2.180.2])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 7b772587-51d1-11f0-a30f-13f23c93f187;
 Wed, 25 Jun 2025 16:34:21 +0200 (CEST)
Received: from pmta11.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail180-2.suw31.mandrillapp.com (Mailchimp) with ESMTP id 4bS4870N1rzS62RvC
 for <win-pv-devel@lists.xenproject.org>; Wed, 25 Jun 2025 14:34:15 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 d767e59cf8ff47409c9915935199bd73; Wed, 25 Jun 2025 14:34:14 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7b772587-51d1-11f0-a30f-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1750862055; x=1751132055;
	bh=quEdxQ6sPEltUsynyHDF+D6ArUChxiVr0kIVrGOMH9I=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=K+cKBIUNb4FrKIlSsXYfkOTlWWFRkkwvc4TCUC2XMS+coJlXsw8/aq9e4ZaQLJ2AL
	 Jj/8/fDDhtftU+eerWVTIEB28VoibujP8LowMbiqfa8oyRppGvD1qk0kgDAF2GQ+e1
	 OCn4vUejwlHEt/lK4+T07YGEek20ndASFc5sMshxFLDiO5YnsqY1h4ySpBut3mVlYb
	 mACs8DYpCO0XTTXQbZLOnNr7yAa1DbRPe/EFovK6WEl9BvkYK4iImm1cB2yr0uPci5
	 035qs2h/Bdup4Em+M4CArwggT3JJVNpBnszT/IBP5huX8hQSzGhf70HFYrtHiSPqVp
	 SKmPeTP+vmcqw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1750862055; x=1751122555; i=ngoc-tu.dinh@vates.tech;
	bh=quEdxQ6sPEltUsynyHDF+D6ArUChxiVr0kIVrGOMH9I=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=hRlImywJUldh0Ffj4zjuCTTQ/jK13oDKbXrk/4c5YFlBxVl9+X7IMEC03u4ekNWyt
	 EEcvRRzRLDfTQgM/+Ajk1JjmeZwwQwcZil9CJywAoCmP1SbIXtOh0I8NQWLwwu6q0c
	 02uUgf1HJmHakjKFqFVm719IhXBLgZ62n69XmUhXey0zBcbU1iTXS+Zm93MNMjv9wc
	 k+6/PZXLN80ZNp2CXmZhwR00Pa5aSWNy+wqmeDj45QDqYYV46KVFHr4C+I7hwK8Bsj
	 QvaLPt1ZjD/hlPRaooTkuXX/zqTdNebXQZtzJwgmtJ2U13NZsFoIKCVh9q2z3kkcvv
	 8opC8/MDkfVVA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[XENBUS=20PATCH=2011/13]=20Check=20for=20IoAttachDeviceToDeviceStack=20failure=20in=20FdoCreate?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1750862054372
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250625143404.1757-12-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
References: <20250625143404.1757-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.d767e59cf8ff47409c9915935199bd73?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250625:md
Date: Wed, 25 Jun 2025 14:34:14 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

IoAttachDeviceToDeviceStack may fail and is marked _Must_inspect_result_.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenbus/fdo.c | 103 +++++++++++++++++++++++++----------------------
 1 file changed, 54 insertions(+), 49 deletions(-)

diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index c876eb6..62e0bfd 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -5789,37 +5789,39 @@ FdoCreate(
     Fdo->PhysicalDeviceObject = PhysicalDeviceObject;
     Fdo->LowerDeviceObject = IoAttachDeviceToDeviceStack(FunctionDeviceObject,
                                                          PhysicalDeviceObject);
+    if (Fdo->LowerDeviceObject == NULL)
+        goto fail3;
 
     Fdo->SystemPowerWorkItem = IoAllocateWorkItem(FunctionDeviceObject);
     if (Fdo->SystemPowerWorkItem == NULL)
-        goto fail3;
+        goto fail4;
 
     Fdo->DevicePowerWorkItem = IoAllocateWorkItem(FunctionDeviceObject);
     if (Fdo->DevicePowerWorkItem == NULL)
-        goto fail4;
+        goto fail5;
 
     status = FdoAcquireLowerBusInterface(Fdo);
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail6;
 
     if (FdoGetBusData(Fdo,
                       PCI_WHICHSPACE_CONFIG,
                       &Header,
                       0,
                       sizeof (PCI_COMMON_HEADER)) == 0)
-        goto fail6;
+        goto fail7;
 
     status = __FdoSetVendorName(Fdo,
                                 Header.VendorID,
                                 Header.DeviceID);
     if (!NT_SUCCESS(status))
-        goto fail7;
+        goto fail8;
 
     __FdoSetName(Fdo);
 
     status = FdoSetActive(Fdo);
     if (!NT_SUCCESS(status))
-        goto fail8;
+        goto fail9;
 
     if (!__FdoIsActive(Fdo))
         goto done;
@@ -5836,47 +5838,47 @@ FdoCreate(
 
     status = DebugInitialize(Fdo, &Fdo->DebugContext);
     if (!NT_SUCCESS(status))
-        goto fail9;
+        goto fail10;
 
     status = SuspendInitialize(Fdo, &Fdo->SuspendContext);
     if (!NT_SUCCESS(status))
-        goto fail10;
+        goto fail11;
 
     status = SharedInfoInitialize(Fdo, &Fdo->SharedInfoContext);
     if (!NT_SUCCESS(status))
-        goto fail11;
+        goto fail12;
 
     status = EvtchnInitialize(Fdo, &Fdo->EvtchnContext);
     if (!NT_SUCCESS(status))
-        goto fail12;
+        goto fail13;
 
     status = RangeSetInitialize(Fdo, &Fdo->RangeSetContext);
     if (!NT_SUCCESS(status))
-        goto fail13;
+        goto fail14;
 
     status = CacheInitialize(Fdo, &Fdo->CacheContext);
     if (!NT_SUCCESS(status))
-        goto fail14;
+        goto fail15;
 
     status = GnttabInitialize(Fdo, &Fdo->GnttabContext);
     if (!NT_SUCCESS(status))
-        goto fail15;
+        goto fail16;
 
     status = StoreInitialize(Fdo, &Fdo->StoreContext);
     if (!NT_SUCCESS(status))
-        goto fail16;
+        goto fail17;
 
     status = ConsoleInitialize(Fdo, &Fdo->ConsoleContext);
     if (!NT_SUCCESS(status))
-        goto fail17;
+        goto fail18;
 
     status = UnplugInitialize(Fdo, &Fdo->UnplugContext);
     if (!NT_SUCCESS(status))
-        goto fail18;
+        goto fail19;
 
     status = FdoBalloonInitialize(Fdo);
     if (!NT_SUCCESS(status))
-        goto fail19;
+        goto fail20;
 
     status = DebugGetInterface(__FdoGetDebugContext(Fdo),
                                XENBUS_DEBUG_INTERFACE_VERSION_MAX,
@@ -5945,68 +5947,68 @@ done:
 
     return STATUS_SUCCESS;
 
-fail19:
-    Error("fail19\n");
+fail20:
+    Error("fail20\n");
 
     UnplugTeardown(Fdo->UnplugContext);
     Fdo->UnplugContext = NULL;
 
-fail18:
-    Error("fail18\n");
+fail19:
+    Error("fail19\n");
 
     ConsoleTeardown(Fdo->ConsoleContext);
     Fdo->ConsoleContext = NULL;
 
-fail17:
-    Error("fail17\n");
+fail18:
+    Error("fail18\n");
 
     StoreTeardown(Fdo->StoreContext);
     Fdo->StoreContext = NULL;
 
-fail16:
-    Error("fail16\n");
+fail17:
+    Error("fail17\n");
 
     GnttabTeardown(Fdo->GnttabContext);
     Fdo->GnttabContext = NULL;
 
-fail15:
-    Error("fail15\n");
+fail16:
+    Error("fail16\n");
 
     CacheTeardown(Fdo->CacheContext);
     Fdo->CacheContext = NULL;
 
-fail14:
-    Error("fail14\n");
+fail15:
+    Error("fail15\n");
 
     RangeSetTeardown(Fdo->RangeSetContext);
     Fdo->RangeSetContext = NULL;
 
-fail13:
-    Error("fail13\n");
+fail14:
+    Error("fail14\n");
 
     EvtchnTeardown(Fdo->EvtchnContext);
     Fdo->EvtchnContext = NULL;
 
-fail12:
-    Error("fail12\n");
+fail13:
+    Error("fail13\n");
 
     SharedInfoTeardown(Fdo->SharedInfoContext);
     Fdo->SharedInfoContext = NULL;
 
-fail11:
-    Error("fail11\n");
+fail12:
+    Error("fail12\n");
 
     SuspendTeardown(Fdo->SuspendContext);
     Fdo->SuspendContext = NULL;
 
-fail10:
-    Error("fail10\n");
+fail11:
+    Error("fail11\n");
 
     DebugTeardown(Fdo->DebugContext);
     Fdo->DebugContext = NULL;
 
-fail9:
-    Error("fail9\n");
+fail10:
+    Error("fail10\n");
 
     Fdo->UseMemoryHole = 0;
 
@@ -6016,37 +6018,40 @@ fail9:
     //
     Fdo->Active = FALSE;
 
-fail8:
-    Error("fail8\n");
+fail9:
+    Error("fail9\n");
 
     RtlZeroMemory(Fdo->VendorName, MAXNAMELEN);
 
+fail8:
+    Error("fail8\n");
+
 fail7:
     Error("fail7\n");
 
+    FdoReleaseLowerBusInterface(Fdo);
+
 fail6:
     Error("fail6\n");
 
-    FdoReleaseLowerBusInterface(Fdo);
+    IoFreeWorkItem(Fdo->DevicePowerWorkItem);
+    Fdo->DevicePowerWorkItem = NULL;
 
 fail5:
     Error("fail5\n");
 
-    IoFreeWorkItem(Fdo->DevicePowerWorkItem);
-    Fdo->DevicePowerWorkItem = NULL;
+    IoFreeWorkItem(Fdo->SystemPowerWorkItem);
+    Fdo->SystemPowerWorkItem = NULL;
 
 fail4:
     Error("fail4\n");
 
-    IoFreeWorkItem(Fdo->SystemPowerWorkItem);
-    Fdo->SystemPowerWorkItem = NULL;
+    if (Fdo->LowerDeviceObject)
+        IoDetachDevice(Fdo->LowerDeviceObject);
 
 fail3:
     Error("fail3\n");
 
-#pragma prefast(suppress:28183) // Fdo->LowerDeviceObject could be NULL
-    IoDetachDevice(Fdo->LowerDeviceObject);
-
     Fdo->PhysicalDeviceObject = NULL;
     Fdo->LowerDeviceObject = NULL;
     Fdo->Dx = NULL;
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Jun 27 15:13:50 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 27 Jun 2025 15:13:50 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1027717.1402242 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uVAlw-0005dO-Tq; Fri, 27 Jun 2025 15:13:48 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1027717.1402242; Fri, 27 Jun 2025 15:13:48 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uVAlw-0005dG-Qs; Fri, 27 Jun 2025 15:13:48 +0000
Received: by outflank-mailman (input) for mailman id 1027717;
 Fri, 27 Jun 2025 15:13:48 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=mkXY=ZK=bounce.vates.tech=bounce-md_30504962.685eb528.v1-c50fd73aa0854608bb3265bf85dc5f55@srs-se1.protection.inumbo.net>)
 id 1uVAlw-0005d9-Al
 for win-pv-devel@lists.xenproject.org; Fri, 27 Jun 2025 15:13:48 +0000
Received: from mail186-10.suw21.mandrillapp.com
 (mail186-10.suw21.mandrillapp.com [198.2.186.10])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 51965213-5369-11f0-a310-13f23c93f187;
 Fri, 27 Jun 2025 17:13:46 +0200 (CEST)
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-10.suw21.mandrillapp.com (Mailchimp) with ESMTP id
 4bTJwm6dHSz5QkLmP
 for <win-pv-devel@lists.xenproject.org>; Fri, 27 Jun 2025 15:13:44 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 c50fd73aa0854608bb3265bf85dc5f55; Fri, 27 Jun 2025 15:13:44 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 51965213-5369-11f0-a310-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1751037224; x=1751307224;
	bh=8+U8/aAt6qM9BoFX5WG8ecLWpEuJZhyYF6EogpLhh9U=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=YLoZLfz6GxbYAjEUSIQqhBD1B8Kr4Jqm1/yWH0mexS1bkO1vMrOnkrvT+MrzDWaD4
	 VyrGRu/EIDOHXlsgsqwqlVsFnnr7i9AmPuzLNvke2eRiwtlZBoEXdwBjoQpVMoqrDB
	 GsZR7kB4hHw2e774N06wsyXd05H1Ul57fmgqZ1QD5tXRF/9Q7IEghMBT/GWeVlM/n3
	 E38S6ZDRMtNuiPGoRusoQQIB+eN05rnui6p4g78/18BhsVpVLSjE5mW+6CQxqY4izu
	 LVFvYH+dOGv9k//VQjCE8neaHYXQI44BCkh/DhrLBBplbfc63xASRmkbM3n+jkQC0l
	 wZthJ6+/hbAPQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1751037224; x=1751297724; i=ngoc-tu.dinh@vates.tech;
	bh=8+U8/aAt6qM9BoFX5WG8ecLWpEuJZhyYF6EogpLhh9U=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=ZwCiue2CQ3u3y9YlAOJbauH8mE+i1SXTfJz9fn72l0dSzObTpiZwGGg2csFy+PEZD
	 IuhOALOudFQRlQo+Yfqw89x4k/kMEq9pbD4v6zjvPGe4hdJpctxhmDre3n6sorMWyr
	 qi6MnNw7p2GRYES5xK250dVf9Dr7ks9EpfSg2JFp53f2DleZxp2zPIBOWI1pWCkULy
	 K0+2Li5K+h5W3gowU/CsKdmJ6gmgaqL5EqvVzbbLQYEJ42uPuvRS7LUlewyO2T5e7v
	 qOM3H5TrytIrS6y6qx9FzS1IYTkRzz9qJ7BB08K0Yu8YAATdeaxQyObWMbHY9W3a2J
	 DeTvWdhGixpiQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=200/3]=20CI=20integration=20for=20Windows=20PV=20drivers?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1751037224078
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250627151342.2008-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.c50fd73aa0854608bb3265bf85dc5f55?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250627:md
Date: Fri, 27 Jun 2025 15:13:44 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Set up an automated pipeline with binary and CodeQL generation.

Tested on GitLab CI.

Also add some build script changes to improve the build process.

Tu Dinh (3):
  Add GitLab pipeline
  Throw on build command failure instead of exiting
  Always run Code Analysis on build

 .gitlab-ci.yml       | 46 ++++++++++++++++++++++++++++++++++++++++++++
 msbuild.ps1          | 17 ++++------------
 vs2019/targets.props |  4 ++++
 vs2022/targets.props |  4 ++++
 4 files changed, 58 insertions(+), 13 deletions(-)
 create mode 100644 .gitlab-ci.yml

-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Jun 27 15:13:54 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 27 Jun 2025 15:13:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1027718.1402245 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uVAm1-0005fM-Vz; Fri, 27 Jun 2025 15:13:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1027718.1402245; Fri, 27 Jun 2025 15:13:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uVAm1-0005fF-SL; Fri, 27 Jun 2025 15:13:53 +0000
Received: by outflank-mailman (input) for mailman id 1027718;
 Fri, 27 Jun 2025 15:13:52 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZkKP=ZK=bounce.vates.tech=bounce-md_30504962.685eb529.v1-a3021dbd89264a9483ef64488741965a@srs-se1.protection.inumbo.net>)
 id 1uVAm0-0005d9-O0
 for win-pv-devel@lists.xenproject.org; Fri, 27 Jun 2025 15:13:52 +0000
Received: from mail186-10.suw21.mandrillapp.com
 (mail186-10.suw21.mandrillapp.com [198.2.186.10])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 51b6023d-5369-11f0-a310-13f23c93f187;
 Fri, 27 Jun 2025 17:13:46 +0200 (CEST)
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-10.suw21.mandrillapp.com (Mailchimp) with ESMTP id
 4bTJwn3K50z5QkLnM
 for <win-pv-devel@lists.xenproject.org>; Fri, 27 Jun 2025 15:13:45 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 a3021dbd89264a9483ef64488741965a; Fri, 27 Jun 2025 15:13:45 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 51b6023d-5369-11f0-a310-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1751037225; x=1751307225;
	bh=VLpC1Q1WMgVvjOqP/xpF2HKFNSNmrkdE7f1JcMdmB/4=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=lOMOMlktPSkUDCIXWAcQN8S4xcbVOVSmZ7xZX0RkaT6zWXGgJrQJc7WiAiQG/ZIop
	 +jy8DTqc5Yv7RAXADWesxVwgppaVj446FOy8CFCXaohneRc8Q6OYg9kxBvOLeXK/eh
	 KnHE75770euleiEKhOxeXyQ5kxRT6SV0TKmiveyyQqe/THJkCWPwDPfssPUNTW/+yM
	 2tbK+hUcjFRIdlsDPV0XiomIV/8rSAS6aWAPMHgAEIHPIL9jZxFwII/IQTM/zPeucx
	 GqbBaMtKFWjAAdLRC3mDnRi0MBmCBtvo7DNqRXyMP0GKGw4oYb0o1uMqSeZI9KSq6m
	 wt3IUoVSBkD8Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1751037225; x=1751297725; i=ngoc-tu.dinh@vates.tech;
	bh=VLpC1Q1WMgVvjOqP/xpF2HKFNSNmrkdE7f1JcMdmB/4=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=rp+zDjeKUv8ePwNavhLZBlk+Aho6uVOhvLEMzFm2g8fH9p2CbePgRxdG3iqIwwMJ8
	 PJ7tUPjWPgYH1Zy+7wVGQR6WRLyy8F3i8t9Sm3qSl9u8f4+xpcN1/GcDmn5I+9hLbn
	 aU6DVMVdSfNhZbCP1DMpCnvWGYTk1Qn8IF7Xn1foshZcc9ir7bMmgEY87ArG05bRVF
	 D2BsWfjkNHEf8J6bWaYiIWZtwM2KyeWgS4BL2F2kx024lgvJh6qCVzxgKOa2GKnm3Q
	 UCCl3OSvfRiSNjdEp9ge6Fxbdxvv5VBoqU4mOd2+9ehcHmS0KNiJYWGHQbw18c7Pa0
	 AEbwbfk+27frg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=203/3]=20Always=20run=20Code=20Analysis=20on=20build?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1751037224849
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250627151342.2008-4-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250627151342.2008-1-ngoc-tu.dinh@vates.tech>
References: <20250627151342.2008-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.a3021dbd89264a9483ef64488741965a?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250627:md
Date: Fri, 27 Jun 2025 15:13:45 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Code Analysis is quick to run, and there's little reason not to run it.
Unconditionally run the recommended driver ruleset on build.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 msbuild.ps1          | 8 +-------
 vs2019/targets.props | 4 ++++
 vs2022/targets.props | 4 ++++
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/msbuild.ps1 b/msbuild.ps1
index d9785db..67f8ae0 100644
--- a/msbuild.ps1
+++ b/msbuild.ps1
@@ -18,8 +18,7 @@ Function Run-MSBuild {
 		[string]$Configuration,
 		[string]$Platform,
 		[string]$Target = "Build",
-		[string]$Inputs = "",
-		[switch]$CodeAnalysis
+		[string]$Inputs = ""
 	)
 
 	$c = "msbuild.exe"
@@ -31,10 +30,6 @@ Function Run-MSBuild {
 	if ($Inputs) {
 		$c += [string]::Format(" /p:Inputs=""{0}"" ", $Inputs)
 	}
-	if ($CodeAnalysis) {
-		$c += "/p:RunCodeAnalysis=true "
-		$c += "/p:EnablePREFast=true "
-	}
 
 	$c += Join-Path -Path $SolutionPath -ChildPath $Name
 
@@ -62,7 +57,6 @@ Function Run-MSBuildSDV {
 	Run-MSBuild $projpath $project $Configuration $Platform "Build"
 	Run-MSBuild $projpath $project $Configuration $Platform "sdv" "/clean"
 	Run-MSBuild $projpath $project $Configuration $Platform "sdv" "/check:default.sdv /debug"
-	Run-MSBuild $projpath $project $Configuration $Platform "Build" -CodeAnalysis
 	Run-MSBuild $projpath $project $Configuration $Platform "dvl"
 
 	$refine = Join-Path -Path $projpath -ChildPath "refine.sdv"
diff --git a/vs2019/targets.props b/vs2019/targets.props
index 53a8662..b55dc31 100644
--- a/vs2019/targets.props
+++ b/vs2019/targets.props
@@ -16,4 +16,8 @@
 		<TargetVersion>Windows10</TargetVersion>
 		<UseDebugLibraries>false</UseDebugLibraries>
 	</PropertyGroup>
+	<PropertyGroup Condition="'$(ConfigurationType)'=='Driver'">
+		<RunCodeAnalysis>true</RunCodeAnalysis>
+		<CodeAnalysisRuleSet>$([System.Environment]::GetEnvironmentVariable("WindowsSdkDir"))CodeAnalysis\DriverRecommendedRules.ruleset</CodeAnalysisRuleSet>
+	</PropertyGroup>
 </Project>
diff --git a/vs2022/targets.props b/vs2022/targets.props
index 3c31b6c..292f52a 100644
--- a/vs2022/targets.props
+++ b/vs2022/targets.props
@@ -8,4 +8,8 @@
 		<TargetVersion>Windows10</TargetVersion>
 		<UseDebugLibraries>false</UseDebugLibraries>
 	</PropertyGroup>
+	<PropertyGroup Condition="'$(ConfigurationType)'=='Driver'">
+		<RunCodeAnalysis>true</RunCodeAnalysis>
+		<CodeAnalysisRuleSet>$([System.Environment]::GetEnvironmentVariable("WindowsSdkDir"))CodeAnalysis\DriverRecommendedRules.ruleset</CodeAnalysisRuleSet>
+	</PropertyGroup>
 </Project>
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Jun 27 15:13:54 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 27 Jun 2025 15:13:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1027719.1402251 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uVAm2-0005fi-37; Fri, 27 Jun 2025 15:13:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1027719.1402251; Fri, 27 Jun 2025 15:13:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uVAm1-0005fQ-Tp; Fri, 27 Jun 2025 15:13:53 +0000
Received: by outflank-mailman (input) for mailman id 1027719;
 Fri, 27 Jun 2025 15:13:53 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=pvuZ=ZK=bounce.vates.tech=bounce-md_30504962.685eb529.v1-e0ad7bfd2cfa434f85c3fb46c82c2229@srs-se1.protection.inumbo.net>)
 id 1uVAm0-0005f2-Vi
 for win-pv-devel@lists.xenproject.org; Fri, 27 Jun 2025 15:13:52 +0000
Received: from mail187-29.suw11.mandrillapp.com
 (mail187-29.suw11.mandrillapp.com [198.2.187.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 51a7c50d-5369-11f0-b894-0df219b8e170;
 Fri, 27 Jun 2025 17:13:47 +0200 (CEST)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-29.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4bTJwn0wT2z7lmfkd
 for <win-pv-devel@lists.xenproject.org>; Fri, 27 Jun 2025 15:13:45 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 e0ad7bfd2cfa434f85c3fb46c82c2229; Fri, 27 Jun 2025 15:13:45 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 51a7c50d-5369-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1751037225; x=1751307225;
	bh=e/bMP/b6oY47+B1zFg/NdDJ+JOMkpq7RHw+VNlIJhWc=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=0F0qvxZ4VtK7e4go2z0+QIZow4tX4ZZ3kaHl/PQJmWXzhb9HmKUGBGzuEdaYYpgLv
	 P4aO0PyQJcL1wOZvqyRtqSa6Zd7ZvuSc4B93kZ30V9mBcyuu4ZZKCPnWSYdguGOuiZ
	 dRo0OmUG1t5lkoQK6EXL4lqdTQ4hTALnRRUBKYJR7qqK7adUqJgKXS/Q3bnrs8U05m
	 q1wFHjeR35I0oQ74ey4sC8gEiFXY8+vTCdwdK/jn4h7bQNH+TXJtFX7MIrMgLnt2KH
	 DjvdFmlfpUj3DcJkCULXckguplWJA1NVHO/oq1bZ0yqKmftKt4pbkYXxrQ2iAgruG0
	 spbe0IaDMsaaw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1751037225; x=1751297725; i=ngoc-tu.dinh@vates.tech;
	bh=e/bMP/b6oY47+B1zFg/NdDJ+JOMkpq7RHw+VNlIJhWc=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=nGovTZKysi8/X59s2Cb27N+VZvOyGbDkjQ4wt6Td1dlb8zG/jjmhkixd610YZQ6t6
	 u8LygPIzAeW3vOHNWFg+BRVuUHWiPpBpqNbB7NDWwZt3i0LgLb1NvmtFSnRN1ieXZs
	 uNU6kjN4SnWIVflgTfSsxFxm3Kl+v1xhFU7BFxSDRZX/AU6wRzjjEjGZnG5IYIMy0k
	 YkgREKyCNyAl9OvpKru3fi6VprK/jQWEn+eoUwE9IFapb79bvlWFy11ISWzxEU6Fe/
	 cEkZdGH27w1IIEd0TJUgBzkKwd9gOWK+/Q5XtKHqbyLMzYPMiwemQbHOfLBt8UVyHc
	 Ym0SzulpOEtcw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=201/3]=20Add=20GitLab=20pipeline?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1751037224404
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250627151342.2008-2-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250627151342.2008-1-ngoc-tu.dinh@vates.tech>
References: <20250627151342.2008-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.e0ad7bfd2cfa434f85c3fb46c82c2229?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250627:md
Date: Fri, 27 Jun 2025 15:13:45 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Run both free and checked CodeQL builds.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 .gitlab-ci.yml | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 .gitlab-ci.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..24b4356
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,46 @@
+# Required software:
+  # Latest PowerShell Core
+  # git
+    # Enable Git long paths so that files are cleaned correctly:
+    # git config --system core.longpaths true
+  # CodeQL (set in PATH)
+  # EWDK with EWDK_ROOT set to the mounted EWDK path
+# I also set the following in config.toml to shorten the build path:
+  # builds_dir = "C:/a"
+
+stages:
+  - build
+
+build-job:
+  tags:
+    - windows
+    - ewdk
+  stage: build
+  parallel:
+    matrix:
+      - BUILD_ARCH:
+          # x86 is no longer supported by new WDKs
+          - x64
+        BUILD_TYPE:
+          - checked
+          - free
+  script:
+    - Get-Content $Env:EWDK_ROOT\Version.txt
+    - codeql.exe pack download codeql/cpp-queries@0.9.0 microsoft/windows-drivers@1.1.0
+    - |
+      Invoke-WebRequest `
+        -Uri "https://raw.githubusercontent.com/microsoft/Windows-Driver-Developer-Supplemental-Tools/44a75acab6decc2676d0e0f045de47a20a238c3c/suites/windows_driver_recommended.qls" `
+        -OutFile windows_driver_recommended.qls
+    - |
+      Set-Content -Path build.cmd -Value `
+        "call %EWDK_ROOT%\BuildEnv\SetupBuildEnv.cmd",
+        # CodeQL is incompatible with x86
+        'pwsh.exe -NonInteractive -ExecutionPolicy Bypass -Command ".\build.ps1 -Type $Env:BUILD_TYPE -Arch $Env:BUILD_ARCH -CodeQL:($Env:BUILD_ARCH -ine ''x86'')"'
+    - cmd.exe /c build.cmd
+  artifacts:
+    name: $CI_PROJECT_NAME
+    paths:
+      - $CI_PROJECT_NAME/
+    when: on_success
+    access: all
+    expire_in: 30 days
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Jun 27 15:14:01 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 27 Jun 2025 15:14:01 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1027720.1402254 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uVAm9-0005kR-29; Fri, 27 Jun 2025 15:14:01 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1027720.1402254; Fri, 27 Jun 2025 15:14:01 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uVAm8-0005kK-VN; Fri, 27 Jun 2025 15:14:00 +0000
Received: by outflank-mailman (input) for mailman id 1027720;
 Fri, 27 Jun 2025 15:14:00 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=EXQS=ZK=bounce.vates.tech=bounce-md_30504962.685eb529.v1-f7b21946ad67431daa46d394307e024d@srs-se1.protection.inumbo.net>)
 id 1uVAm8-0005f2-48
 for win-pv-devel@lists.xenproject.org; Fri, 27 Jun 2025 15:14:00 +0000
Received: from mail187-29.suw11.mandrillapp.com
 (mail187-29.suw11.mandrillapp.com [198.2.187.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 51ad39b3-5369-11f0-b894-0df219b8e170;
 Fri, 27 Jun 2025 17:13:47 +0200 (CEST)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-29.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4bTJwn1ymVz7lmfkf
 for <win-pv-devel@lists.xenproject.org>; Fri, 27 Jun 2025 15:13:45 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 f7b21946ad67431daa46d394307e024d; Fri, 27 Jun 2025 15:13:45 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 51ad39b3-5369-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1751037225; x=1751307225;
	bh=OnPfcVlL0dq9RbwfLV7GOYWv+k9e3EIgpPyZh3OgyaA=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=0zzjDhnfrz2oE8benQnhQuefufsB/8ERZhjloqKVJtpRHCyoDwtNiSy0eKI5uithq
	 R1gqq1Du9O7SwdlnkQ9vljvVsJJKUJZxtW4x8Y9o9/RLh0VFKaYHa8HYdYbSkO81+P
	 neg5zV+jOtGyJNIdAtkAg7HkgPzuZ1NJP35OrdFjMDg0vPBkvTjtIzeGfowqa4m26h
	 3lgJixjTTg9gBJnmaN9RAlZYO6Gzny2G672jSQ9kOko4xKQiLSD7TMd+1wyyw047nO
	 yWMxJcncDlcLvYAL9N9FHgJSlgAOhE9CMNr6nNHv0vjww3vtu6EdQGvKjuMBHUpTHR
	 68lRH6oil8lFA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1751037225; x=1751297725; i=ngoc-tu.dinh@vates.tech;
	bh=OnPfcVlL0dq9RbwfLV7GOYWv+k9e3EIgpPyZh3OgyaA=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=ePtCj1PIFzYgHKF5f8zxa3/KKVEuVLu92bAusLe33c5PXUeyNuFuDqrucX6x/h4LJ
	 aSB8an2LFMhee0xoCmVQx67cR7RwWHO79OzFbeZ0yH8bYj0unWXR2GDaHFN9ZPOOPi
	 waHUzpOxXkD5uh32iaClQ3JLEuYI4EP8TRGk/QDpsiM0qS58zy1OgaRaaqecUlVe2d
	 bGsKvBta2t+whuDiiWlhZnLSlHZTGSAAhp5j9Cp5Zt8ebYCHPbRwyJBDmSLvWefaC0
	 YiebMCUhPrQz+AsaIdX/+YToFN520leg5s4z0jBmZEW4vt3TUYh41scGX3eUgd9DMg
	 pQI9yOFdlgoUA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=202/3]=20Throw=20on=20build=20command=20failure=20instead=20of=20exiting?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1751037224653
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20250627151342.2008-3-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250627151342.2008-1-ngoc-tu.dinh@vates.tech>
References: <20250627151342.2008-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.f7b21946ad67431daa46d394307e024d?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250627:md
Date: Fri, 27 Jun 2025 15:13:45 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Exiting is not sufficient to signal the error condition in some cases
(as observed on CI).

Explicitly throw an error instead.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 msbuild.ps1 | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/msbuild.ps1 b/msbuild.ps1
index 58053e2..d9785db 100644
--- a/msbuild.ps1
+++ b/msbuild.ps1
@@ -40,8 +40,7 @@ Function Run-MSBuild {
 
 	Invoke-Expression $c
 	if ($LASTEXITCODE -ne 0) {
-		Write-Host -ForegroundColor Red "ERROR: MSBuild failed, code:" $LASTEXITCODE
-		Exit $LASTEXITCODE
+		throw "ERROR: MSBuild failed, code: $LASTEXITCODE"
 	}
 }
 
@@ -117,8 +116,7 @@ Function Run-CodeQL {
 	$b += $database
 	Invoke-Expression $b
 	if ($LASTEXITCODE -ne 0) {
-		Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" $LASTEXITCODE
-		Exit $LASTEXITCODE
+		throw "ERROR: CodeQL failed, code: $LASTEXITCODE"
 	}
 	Remove-Item $bat
 
@@ -136,8 +134,7 @@ Function Run-CodeQL {
 
 	Invoke-Expression $c
 	if ($LASTEXITCODE -ne 0) {
-		Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" $LASTEXITCODE
-		Exit $LASTEXITCODE
+		throw "ERROR: CodeQL failed, code: $LASTEXITCODE"
 	}
 
 	Copy-Item $sarif -Destination $SolutionPath
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 30 10:26:58 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 30 Jun 2025 10:26:58 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1028991.1402746 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uWBix-0007Sq-Tm; Mon, 30 Jun 2025 10:26:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1028991.1402746; Mon, 30 Jun 2025 10:26:55 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uWBix-0007Sj-R5; Mon, 30 Jun 2025 10:26:55 +0000
Received: by outflank-mailman (input) for mailman id 1028991;
 Mon, 30 Jun 2025 10:26:54 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=7QgD=ZN=bounce.vates.tech=bounce-md_30504962.68626669.v1-ced7d10c75fe48f1bfb0b6c7c53edcda@srs-se1.protection.inumbo.net>)
 id 1uWBiw-0007Sb-HJ
 for win-pv-devel@lists.xenproject.org; Mon, 30 Jun 2025 10:26:54 +0000
Received: from mail187-29.suw11.mandrillapp.com
 (mail187-29.suw11.mandrillapp.com [198.2.187.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id bb9fa164-559c-11f0-a312-13f23c93f187;
 Mon, 30 Jun 2025 12:26:52 +0200 (CEST)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-29.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4bW2QK297dz7lmDDX
 for <win-pv-devel@lists.xenproject.org>; Mon, 30 Jun 2025 10:26:49 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 ced7d10c75fe48f1bfb0b6c7c53edcda; Mon, 30 Jun 2025 10:26:49 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: bb9fa164-559c-11f0-a312-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1751279209; x=1751549209;
	bh=hCWZU6vJVE4IuB5NlbKkE1J6EFzP2ZjGeWFbZXua78s=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=rn9rjo/J2XunRoxfQj0vsRcvSkhm7AjVD7si1+B0RgJkFB2XoK9r8CQwrVAshUj1P
	 T4KXRiQqeldwqAg5OquvNqqAcnB64uoJ98uzMVrIlR38R+bLMEDnnGDMXyFwFdAEbU
	 5H7/q+ZVSr3BsSHEO0ZA3MAJlWjh/gJI5uchpWz3+AGsz52495ma5eaxegbbuDtQqH
	 ZBqtuF3xooU7lBJYULCV/D3iuYuIq8tVRBbsi2SlpZx4FyEMEGk4+nNTpIEljp5Els
	 7mUaPFQPvXDbf2aPIN8gc5P6IneQB+ArWKteYsUqopTaTsk6RdBtzEt/jLLMH1XXbK
	 jiZ7aQCM0GS2Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1751279209; x=1751539709; i=ngoc-tu.dinh@vates.tech;
	bh=hCWZU6vJVE4IuB5NlbKkE1J6EFzP2ZjGeWFbZXua78s=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=WXVMHWpJj3LfDKiz6FHogSwXBlgLvbiLZ+TXWvwQq4tKAF5l9lqJbaJXVBp4Te85Q
	 gpcSyVYdI7P/HrcUWFpUd48LrluL9BmgSSN1B2Mewljs5cKyJOUr5ShAHFKLK9hmj7
	 rr1NTPuKvAZ6RWn5p8X/35ZdpZHhFubyD3c7khFu308/Y9ERwnNNcC1hovx4KNEjCi
	 WDSX8SIpR4NqHqNCOXnQH0zpOMPyswN/WN//D+wa+K/1OFrPcCAJnL4gYZ0OUvgzYj
	 MjLiAJ0WCSBLkFkve1rYsXIRa07HKvHnWRE93USFpy6RE9A0OZ/nmQQyvnrggDJ6Jn
	 o2x+qw8d3Ba6A==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH]=20Add=20Tu=20Dinh=20as=20a=20maintainer?=
X-Mailer: git-send-email 2.50.0.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1751279207715
To: win-pv-devel@lists.xenproject.org
Cc: "Owen Smith" <owen.smith@cloud.com>, "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Message-Id: <20250630102411.1265-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.ced7d10c75fe48f1bfb0b6c7c53edcda?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250630:md
Date: Mon, 30 Jun 2025 10:26:49 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

I would like to nominate myself as a maintainer of all Xen PV drivers
for Windows.

I have contributed patches to various areas of the drivers (security,
bug fixes, enhancements) and plan to continue working on improving them.

Owen (the current maintainer) has verbally supported this nomination.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7326c9e..2b07abc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -44,3 +44,5 @@ Maintainers List
 ----------------
 
 * Owen Smith <owen.smith@cloud.com>
+
+* Tu Dinh <ngoc-tu.dinh@vates.tech>
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 30 10:41:02 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 30 Jun 2025 10:41:02 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1029015.1402768 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uWBwb-0001pT-BU; Mon, 30 Jun 2025 10:41:01 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1029015.1402768; Mon, 30 Jun 2025 10:41:01 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uWBwb-0001pL-8j; Mon, 30 Jun 2025 10:41:01 +0000
Received: by outflank-mailman (input) for mailman id 1029015;
 Mon, 30 Jun 2025 10:41:00 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=DXXp=ZN=cloud.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1uWBwa-0001pF-Gd
 for win-pv-devel@lists.xenproject.org; Mon, 30 Jun 2025 10:41:00 +0000
Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com
 [2a00:1450:4864:20::629])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id b2fc32a3-559e-11f0-b894-0df219b8e170;
 Mon, 30 Jun 2025 12:40:55 +0200 (CEST)
Received: by mail-ej1-x629.google.com with SMTP id
 a640c23a62f3a-ae0dffaa8b2so716716766b.0
 for <win-pv-devel@lists.xenproject.org>; Mon, 30 Jun 2025 03:40:54 -0700 (PDT)
Received: from mewpvdipd1026.corp.cloud.com ([52.166.251.127])
 by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-ae353c0427bsm639128866b.84.2025.06.30.03.40.52
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 30 Jun 2025 03:40:52 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b2fc32a3-559e-11f0-b894-0df219b8e170
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=cloud.com; s=cloud; t=1751280053; x=1751884853; darn=lists.xenproject.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to;
        bh=0WKGEGCM4ald1/8zzX5dvSWq/n/4MVC+P9fni3PffvI=;
        b=dW/Ygi5msRnakqA5DxvLivAihpDGtoHf+nMPijF4hEc7Q+qWmM8Ygf7S7Zcc0btY/v
         sRF5qe9b2B74a2pk2TC5S6BGWKVGsinr1MBeqaLAHHwOu75t2+46JEwtNsdSSYC7VGu1
         Cago0XP7bDIskFL12kEP78ValDmdyFEthajIc=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1751280053; x=1751884853;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=0WKGEGCM4ald1/8zzX5dvSWq/n/4MVC+P9fni3PffvI=;
        b=Kj/AIDxM50JYtxuszmbu/AFNDjhJG7yvN/pr9EYtiVqBwx5F/aOdsNx6tBZzQX++dr
         cqSIwZs/t4zDODEiYGrnZSfxsGHPFwd7lAzw+iikx4PmzhSZh4pq/IvDGSoSKpJvv3yO
         yyOpjRSdrJa0KpjLxalQD/czWprULQRAD5bTRUBEK/f8Y1bfGpuN9xUSTXtpJFMUtmx+
         RPk+TOBItBGugMNFCcURI5aDP4DXD1b1Z+Ew0COV0diZM9+nbZnalNFnFs/S/Sl5pHJC
         aQhgcWZwVJZOfoEYQC4EOAcqmtbkmFI7xKd2yYzr2NFd3YM5VJ8+sxoMM/SQ98fnC+hi
         SUCw==
X-Gm-Message-State: AOJu0YwLHYgY+xgYfbFy+9I2WMpKXdeDZvtyyF1P/k1cHVn0N6jqyV3Q
	PIk8qAf9OxJ/+zcJo+utVE/KDE7fytP3L7x3+YWJAVoePvusyzqbHa3ELHLvYwAVoVbh2aDRUS8
	STbw=
X-Gm-Gg: ASbGncuZHKoOe2pPJGBhSFKK0gNxjt2jUb/AixcVmenNhCyL/2Dx9mzoHs/HWyo/8e1
	R5Tfwm1JRrLsq01ip0dWXKizh+KtJKTsBcqpUNOUiX22BX6P3sTJ2LMWjIP/q+GNN19iHxdxQB6
	Or02r2IexaWyJpW7A4DHZfyomlCyjM86kUhSMLYycLtaoMSaFAGQn6TLaRLPNeqEwkuHB6+6ZKj
	5PSanVf6qEX3nqzKaet9ns7b6IoV/77NUTuGuTFtnC2dWq9poY4hQRvP5na5I6o5x4EfF0i8q32
	V3/z6Ax3CSLXgMP94ps38AhcFfa3gKMsWlWiMXBZnjWWRD+13G2XrqVOH6m07gpRHCizRVoad8D
	oA5fM2EakB7wSykXr8Ww=
X-Google-Smtp-Source: AGHT+IF2kK9dl0ObdoMhDQVmklvpyX01q/hWcO7vFwtD9gnm6h8+pZ2AZp167iz5jbxu0/4JYCs3nA==
X-Received: by 2002:a17:907:a908:b0:ae3:6654:c0b2 with SMTP id a640c23a62f3a-ae36654c1c4mr937308766b.28.1751280052955;
        Mon, 30 Jun 2025 03:40:52 -0700 (PDT)
From: Owen Smith <owen.smith@cloud.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
Subject: [PATCH] Use UNPLUG v3
Date: Mon, 30 Jun 2025 11:40:24 +0100
Message-ID: <20250630104024.1463-1-owen.smith@cloud.com>
X-Mailer: git-send-email 2.46.0.windows.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Uses UnplugReboot to request a reboot from xenbus_monitor, rather than
writing values into an absolute registry path, which is a driver verifier
violation during Server 2025 WHQL testing.
Also removes the RequestKey from the INF file.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
---
 include/revision.h         |  3 +-
 include/unplug_interface.h | 40 +++++++++++++++-
 src/xenvif.inf             |  8 ++--
 src/xenvif/driver.c        | 93 --------------------------------------
 src/xenvif/driver.h        |  5 --
 src/xenvif/pdo.c           | 20 +++++++-
 6 files changed, 62 insertions(+), 107 deletions(-)

diff --git a/include/revision.h b/include/revision.h
index 2f4ac80..656f171 100644
--- a/include/revision.h
+++ b/include/revision.h
@@ -46,6 +46,7 @@
     DEFINE_REVISION(0x09000001,  2,  8,   2,  1,   1),  \
     DEFINE_REVISION(0x09000002,  2,  9,   2,  1,   1),  \
     DEFINE_REVISION(0x09000003,  2,  10,  2,  1,   1),  \
-    DEFINE_REVISION(0x09000004,  2,  10,  2,  1,   2)
+    DEFINE_REVISION(0x09000004,  2,  10,  2,  1,   2),  \
+    DEFINE_REVISION(0x09000005,  2,  10,  2,  1,   3)
 
 #endif  // _REVISION_H
diff --git a/include/unplug_interface.h b/include/unplug_interface.h
index dbdc76d..dad3afc 100644
--- a/include/unplug_interface.h
+++ b/include/unplug_interface.h
@@ -99,6 +99,28 @@ typedef BOOLEAN
     IN  XENBUS_UNPLUG_DEVICE_TYPE   Type
     );
 
+/*! \typedef XENBUS_UNPLUG_BOOT_EMULATED
+    \brief Should the boot disk be emulated
+
+    \param Interface The interface header
+*/
+typedef BOOLEAN
+(*XENBUS_UNPLUG_BOOT_EMULATED)(
+    IN  PINTERFACE                  Interface
+    );
+
+/*! \typedef XENBUS_UNPLUG_REBOOT
+    \brief Request a reboot to complete setup
+
+    \param Interface The interface header
+    \param Module The module name requesting a reboot
+*/
+typedef VOID
+(*XENBUS_UNPLUG_REBOOT)(
+    IN  PINTERFACE                  Interface,
+    IN  PCHAR                       Module
+    );
+
 // {73db6517-3d06-4937-989f-199b7501e229}
 DEFINE_GUID(GUID_XENBUS_UNPLUG_INTERFACE,
 0x73db6517, 0x3d06, 0x4937, 0x98, 0x9f, 0x19, 0x9b, 0x75, 0x01, 0xe2, 0x29);
@@ -126,7 +148,21 @@ struct _XENBUS_UNPLUG_INTERFACE_V2 {
     XENBUS_UNPLUG_IS_REQUESTED  UnplugIsRequested;
 };
 
-typedef struct _XENBUS_UNPLUG_INTERFACE_V2 XENBUS_UNPLUG_INTERFACE, *PXENBUS_UNPLUG_INTERFACE;
+/*! \struct _XENBUS_UNPLUG_INTERFACE_V3
+    \brief UNPLUG interface version 3
+    \ingroup interfaces
+*/
+struct _XENBUS_UNPLUG_INTERFACE_V3 {
+    INTERFACE                   Interface;
+    XENBUS_UNPLUG_ACQUIRE       UnplugAcquire;
+    XENBUS_UNPLUG_RELEASE       UnplugRelease;
+    XENBUS_UNPLUG_REQUEST       UnplugRequest;
+    XENBUS_UNPLUG_IS_REQUESTED  UnplugIsRequested;
+    XENBUS_UNPLUG_BOOT_EMULATED UnplugBootEmulated;
+    XENBUS_UNPLUG_REBOOT        UnplugReboot;
+};
+
+typedef struct _XENBUS_UNPLUG_INTERFACE_V3 XENBUS_UNPLUG_INTERFACE, *PXENBUS_UNPLUG_INTERFACE;
 
 /*! \def XENBUS_UNPLUG
     \brief Macro at assist in method invocation
@@ -137,6 +173,6 @@ typedef struct _XENBUS_UNPLUG_INTERFACE_V2 XENBUS_UNPLUG_INTERFACE, *PXENBUS_UNP
 #endif  // _WINDLL
 
 #define XENBUS_UNPLUG_INTERFACE_VERSION_MIN  1
-#define XENBUS_UNPLUG_INTERFACE_VERSION_MAX  2
+#define XENBUS_UNPLUG_INTERFACE_VERSION_MAX  3
 
 #endif  // _XENBUS_UNPLUG_INTERFACE_H
diff --git a/src/xenvif.inf b/src/xenvif.inf
index 8bfc37c..0430f04 100644
--- a/src/xenvif.inf
+++ b/src/xenvif.inf
@@ -56,9 +56,9 @@ xenvif.sys=0,,
 ; DisplayName		Section		DeviceID
 ; -----------		-------		--------
 
-%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VIF&REV_0900000A
-%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VIF&REV_0900000A
-%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VIF&REV_0900000A
+%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VIF&REV_0900000B
+%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VIF&REV_0900000B
+%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VIF&REV_0900000B
 
 [XenVif_Inst] 
 CopyFiles=XenVif_Copyfiles
@@ -83,7 +83,6 @@ HKR,,"BootFlags",0x00010003,0x81
 
 [XenVif_Parameters]
 HKR,"Parameters",,0x00000010
-HKR,"Parameters","RequestKey",0x00000000,%RequestKey%
 HKR,"Parameters","FrontendMaxQueues",0x00010001,0x00000008
 
 [XenVif_Unplug]
@@ -94,7 +93,6 @@ HKLM,%UnplugKey%,"NICS",0x00010001,0
 Vendor="@VENDOR_NAME@"
 DiskDesc="@PRODUCT_NAME@ PV Network Class Package"
 XenVifName="@PRODUCT_NAME@ PV Network Class"
-RequestKey="SYSTEM\CurrentControlSet\Services\xenbus_monitor\Request"
 UnplugKey="SYSTEM\CurrentControlSet\Services\XEN\Unplug"
 
 SERVICE_BOOT_START=0x0 
diff --git a/src/xenvif/driver.c b/src/xenvif/driver.c
index 3345607..438c21a 100644
--- a/src/xenvif/driver.c
+++ b/src/xenvif/driver.c
@@ -49,7 +49,6 @@ typedef struct _XENVIF_DRIVER {
     HANDLE              ParametersKey;
     HANDLE              AddressesKey;
     HANDLE              SettingsKey;
-    BOOLEAN             NeedReboot;
 } XENVIF_DRIVER, *PXENVIF_DRIVER;
 
 static XENVIF_DRIVER    Driver;
@@ -168,96 +167,6 @@ DriverGetSettingsKey(
     return __DriverGetSettingsKey();
 }
 
-#define MAXNAMELEN  256
-
-static FORCEINLINE VOID
-__DriverRequestReboot(
-    VOID
-    )
-{
-    PANSI_STRING    Ansi;
-    CHAR            RequestKeyName[MAXNAMELEN];
-    HANDLE          RequestKey;
-    HANDLE          SubKey;
-    NTSTATUS        status;
-
-    Info("====>\n");
-
-    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
-
-    status = RegistryQuerySzValue(__DriverGetParametersKey(),
-                                  "RequestKey",
-                                  NULL,
-                                  &Ansi);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = RtlStringCbPrintfA(RequestKeyName,
-                                MAXNAMELEN,
-                                "\\Registry\\Machine\\%Z",
-                                &Ansi[0]);
-    ASSERT(NT_SUCCESS(status));
-
-    status = RegistryCreateSubKey(NULL,
-                                  RequestKeyName,
-                                  REG_OPTION_NON_VOLATILE,
-                                  &RequestKey);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    status = RegistryCreateSubKey(RequestKey,
-                                  __MODULE__,
-                                  REG_OPTION_VOLATILE,
-                                  &SubKey);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    status = RegistryUpdateDwordValue(SubKey,
-                                      "Reboot",
-                                      1);
-    if (!NT_SUCCESS(status))
-        goto fail4;
-
-    RegistryCloseKey(SubKey);
-
-    RegistryFreeSzValue(Ansi);
-
-    Info("<====\n");
-
-    return;
-
-fail4:
-    Error("fail4\n");
-
-    RegistryCloseKey(SubKey);
-
-fail3:
-    Error("fail3\n");
-
-    RegistryCloseKey(RequestKey);
-
-fail2:
-    Error("fail2\n");
-
-    RegistryFreeSzValue(Ansi);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-}
-
-VOID
-DriverRequestReboot(
-    VOID
-    )
-{
-    if (Driver.NeedReboot)
-        return;
-
-    __DriverRequestReboot();
-
-    Driver.NeedReboot = TRUE;
-}
-
 DRIVER_UNLOAD       DriverUnload;
 
 VOID
@@ -273,8 +182,6 @@ DriverUnload(
 
     Trace("====>\n");
 
-    Driver.NeedReboot = FALSE;
-
     SettingsKey = __DriverGetSettingsKey();
     __DriverSetSettingsKey(NULL);
 
diff --git a/src/xenvif/driver.h b/src/xenvif/driver.h
index b5b9a3d..96be6df 100644
--- a/src/xenvif/driver.h
+++ b/src/xenvif/driver.h
@@ -58,11 +58,6 @@ DriverGetSettingsKey(
     VOID
     );
 
-extern VOID
-DriverRequestReboot(
-    VOID
-    );
-
 typedef struct _XENVIF_PDO  XENVIF_PDO, *PXENVIF_PDO;
 typedef struct _XENVIF_FDO  XENVIF_FDO, *PXENVIF_FDO;
 
diff --git a/src/xenvif/pdo.c b/src/xenvif/pdo.c
index a3ae061..28121ac 100644
--- a/src/xenvif/pdo.c
+++ b/src/xenvif/pdo.c
@@ -1253,6 +1253,24 @@ PdoUnplugRequest(
     XENBUS_UNPLUG(Release, &Pdo->UnplugInterface);
 }
 
+static VOID
+PdoRequestReboot(
+    IN  PXENVIF_PDO Pdo
+    )
+{
+    NTSTATUS        status;
+
+    status = XENBUS_UNPLUG(Acquire, &Pdo->UnplugInterface);
+    if (!NT_SUCCESS(status))
+        return;
+
+    XENBUS_UNPLUG(Reboot,
+                  &Pdo->UnplugInterface,
+                  __MODULE__);
+
+    XENBUS_UNPLUG(Release, &Pdo->UnplugInterface);
+}
+
 static BOOLEAN
 PdoUnplugRequested(
     IN  PXENVIF_PDO Pdo
@@ -1439,7 +1457,7 @@ PdoStartDevice(
     status = PdoParseMibTable(Pdo, SoftwareKey);
     if (status == STATUS_PNP_REBOOT_REQUIRED || !PdoUnplugRequested(Pdo)) {
         PdoUnplugRequest(Pdo, TRUE);
-        DriverRequestReboot();
+        PdoRequestReboot(Pdo);
 
         status = STATUS_PNP_REBOOT_REQUIRED;
         goto fail5;
-- 
2.46.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 30 11:20:39 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 30 Jun 2025 11:20:39 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1029034.1402782 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uWCYw-0006sZ-8Y; Mon, 30 Jun 2025 11:20:38 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1029034.1402782; Mon, 30 Jun 2025 11:20:38 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uWCYw-0006sS-5Q; Mon, 30 Jun 2025 11:20:38 +0000
Received: by outflank-mailman (input) for mailman id 1029034;
 Mon, 30 Jun 2025 11:20:36 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=DfEk=ZN=bounce.vates.tech=bounce-md_30504962.68627301.v1-54c05653f75541689c4d16ffe3948553@srs-se1.protection.inumbo.net>)
 id 1uWCYu-0006sM-MD
 for win-pv-devel@lists.xenproject.org; Mon, 30 Jun 2025 11:20:36 +0000
Received: from mail186-10.suw21.mandrillapp.com
 (mail186-10.suw21.mandrillapp.com [198.2.186.10])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 3d523168-55a4-11f0-a312-13f23c93f187;
 Mon, 30 Jun 2025 13:20:35 +0200 (CEST)
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-10.suw21.mandrillapp.com (Mailchimp) with ESMTP id
 4bW3cK37CZz5QkLkV
 for <win-pv-devel@lists.xenproject.org>; Mon, 30 Jun 2025 11:20:33 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 54c05653f75541689c4d16ffe3948553; Mon, 30 Jun 2025 11:20:33 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 3d523168-55a4-11f0-a312-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1751282433; x=1751552433;
	bh=WJanfQ53v2u6iOCw7jO8YSti2Mv5C96rrxLpf1btfSg=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=ykzP+Izw/wZJD+E/qB7J1O8fZnAV1NCF7bjz11q80GT9gKSAhA+PLrIpMGTS2eX8o
	 947fM7ioq9lwDA07ES2QIchPULQpGJS00RDi9477rCZ9Ymao1arck6pd5hLQtBhu/o
	 ZcJOt4tkJGp3X37Rf7g4kMaSXnTejFgRXbaZwJBt2+kMdiffFxhR8+GzvI7rypVqS0
	 hLm4BrEPkPktghawEdKKnPLPy3BIw7YaxIegOZf2NLe4ncmO/7nhHS4VG4D497rNWM
	 or1Kq7V2eTQw99K3KLOrdZD/CO7rYQmDPgVidT5xuudWiu4fcA/CmLvqib4eNx+NTC
	 VPmJEqldF9Nbg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1751282433; x=1751542933; i=ngoc-tu.dinh@vates.tech;
	bh=WJanfQ53v2u6iOCw7jO8YSti2Mv5C96rrxLpf1btfSg=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=dhckXTX1qzIrMhLgtcYlat6NhC6guvjIkS+1tkRh8wsXPiGuQ48DZ92j6F+AmOKZ0
	 dCsWPjY9ohQUFxa2WPdDDK9s2Llfn8zUdRHoiWvUYP2WY/tycUw5iuc0DuvOU7GjMk
	 91uJEs9RIUL5SKd5FYIq/2jg2CDr2Ae8eRqdnglG6Y0jOFh76LoacPWYCMF71KF5mU
	 DGMNN7rdVOgCguR+OLTY0chYhVBaQenfuSYrKaENZrHcSSsnbdlUu7q+L23BH/TJy2
	 D+PNPgRVa4jSy9/G/p5e2YHV84sVkg/u4cDuzsz4JHYxbaL9qqKYFiaty8VJR9CvVL
	 31Zv6SgUXaong==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH]=20Use=20UNPLUG=20v3?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1751282431696
Message-Id: <0aa3e6f2-9f12-4153-a462-5d23a10316dc@vates.tech>
To: "Owen Smith" <owen.smith@cloud.com>, win-pv-devel@lists.xenproject.org
References: <20250630104024.1463-1-owen.smith@cloud.com>
In-Reply-To: <20250630104024.1463-1-owen.smith@cloud.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.54c05653f75541689c4d16ffe3948553?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20250630:md
Date: Mon, 30 Jun 2025 11:20:33 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Thanks for the fix.

On 30/06/2025 12:41, Owen Smith wrote:
> Uses UnplugReboot to request a reboot from xenbus_monitor, rather than
> writing values into an absolute registry path, which is a driver verifier
> violation during Server 2025 WHQL testing.
> Also removes the RequestKey from the INF file.
> 
> Signed-off-by: Owen Smith <owen.smith@cloud.com>

Reviewed-by: Tu Dinh <ngoc-tu.dinh@vates.tech>

> ---
>   include/revision.h         |  3 +-
>   include/unplug_interface.h | 40 +++++++++++++++-
>   src/xenvif.inf             |  8 ++--
>   src/xenvif/driver.c        | 93 --------------------------------------
>   src/xenvif/driver.h        |  5 --
>   src/xenvif/pdo.c           | 20 +++++++-
>   6 files changed, 62 insertions(+), 107 deletions(-)
> 
> diff --git a/include/revision.h b/include/revision.h
> index 2f4ac80..656f171 100644
> --- a/include/revision.h
> +++ b/include/revision.h
> @@ -46,6 +46,7 @@
>       DEFINE_REVISION(0x09000001,  2,  8,   2,  1,   1),  \
>       DEFINE_REVISION(0x09000002,  2,  9,   2,  1,   1),  \
>       DEFINE_REVISION(0x09000003,  2,  10,  2,  1,   1),  \
> -    DEFINE_REVISION(0x09000004,  2,  10,  2,  1,   2)
> +    DEFINE_REVISION(0x09000004,  2,  10,  2,  1,   2),  \
> +    DEFINE_REVISION(0x09000005,  2,  10,  2,  1,   3)
>   
>   #endif  // _REVISION_H
> diff --git a/include/unplug_interface.h b/include/unplug_interface.h
> index dbdc76d..dad3afc 100644
> --- a/include/unplug_interface.h
> +++ b/include/unplug_interface.h
> @@ -99,6 +99,28 @@ typedef BOOLEAN
>       IN  XENBUS_UNPLUG_DEVICE_TYPE   Type
>       );
>   
> +/*! \typedef XENBUS_UNPLUG_BOOT_EMULATED
> +    \brief Should the boot disk be emulated
> +
> +    \param Interface The interface header
> +*/
> +typedef BOOLEAN
> +(*XENBUS_UNPLUG_BOOT_EMULATED)(
> +    IN  PINTERFACE                  Interface
> +    );
> +
> +/*! \typedef XENBUS_UNPLUG_REBOOT
> +    \brief Request a reboot to complete setup
> +
> +    \param Interface The interface header
> +    \param Module The module name requesting a reboot
> +*/
> +typedef VOID
> +(*XENBUS_UNPLUG_REBOOT)(
> +    IN  PINTERFACE                  Interface,
> +    IN  PCHAR                       Module
> +    );
> +
>   // {73db6517-3d06-4937-989f-199b7501e229}
>   DEFINE_GUID(GUID_XENBUS_UNPLUG_INTERFACE,
>   0x73db6517, 0x3d06, 0x4937, 0x98, 0x9f, 0x19, 0x9b, 0x75, 0x01, 0xe2, 0x29);
> @@ -126,7 +148,21 @@ struct _XENBUS_UNPLUG_INTERFACE_V2 {
>       XENBUS_UNPLUG_IS_REQUESTED  UnplugIsRequested;
>   };
>   
> -typedef struct _XENBUS_UNPLUG_INTERFACE_V2 XENBUS_UNPLUG_INTERFACE, *PXENBUS_UNPLUG_INTERFACE;
> +/*! \struct _XENBUS_UNPLUG_INTERFACE_V3
> +    \brief UNPLUG interface version 3
> +    \ingroup interfaces
> +*/
> +struct _XENBUS_UNPLUG_INTERFACE_V3 {
> +    INTERFACE                   Interface;
> +    XENBUS_UNPLUG_ACQUIRE       UnplugAcquire;
> +    XENBUS_UNPLUG_RELEASE       UnplugRelease;
> +    XENBUS_UNPLUG_REQUEST       UnplugRequest;
> +    XENBUS_UNPLUG_IS_REQUESTED  UnplugIsRequested;
> +    XENBUS_UNPLUG_BOOT_EMULATED UnplugBootEmulated;
> +    XENBUS_UNPLUG_REBOOT        UnplugReboot;
> +};
> +
> +typedef struct _XENBUS_UNPLUG_INTERFACE_V3 XENBUS_UNPLUG_INTERFACE, *PXENBUS_UNPLUG_INTERFACE;
>   
>   /*! \def XENBUS_UNPLUG
>       \brief Macro at assist in method invocation
> @@ -137,6 +173,6 @@ typedef struct _XENBUS_UNPLUG_INTERFACE_V2 XENBUS_UNPLUG_INTERFACE, *PXENBUS_UNP
>   #endif  // _WINDLL
>   
>   #define XENBUS_UNPLUG_INTERFACE_VERSION_MIN  1
> -#define XENBUS_UNPLUG_INTERFACE_VERSION_MAX  2
> +#define XENBUS_UNPLUG_INTERFACE_VERSION_MAX  3
>   
>   #endif  // _XENBUS_UNPLUG_INTERFACE_H
> diff --git a/src/xenvif.inf b/src/xenvif.inf
> index 8bfc37c..0430f04 100644
> --- a/src/xenvif.inf
> +++ b/src/xenvif.inf
> @@ -56,9 +56,9 @@ xenvif.sys=0,,
>   ; DisplayName		Section		DeviceID
>   ; -----------		-------		--------
>   
> -%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VIF&REV_0900000A
> -%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VIF&REV_0900000A
> -%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VIF&REV_0900000A
> +%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VIF&REV_0900000B
> +%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VIF&REV_0900000B
> +%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VIF&REV_0900000B
>   
>   [XenVif_Inst]
>   CopyFiles=XenVif_Copyfiles
> @@ -83,7 +83,6 @@ HKR,,"BootFlags",0x00010003,0x81
>   
>   [XenVif_Parameters]
>   HKR,"Parameters",,0x00000010
> -HKR,"Parameters","RequestKey",0x00000000,%RequestKey%
>   HKR,"Parameters","FrontendMaxQueues",0x00010001,0x00000008
>   
>   [XenVif_Unplug]
> @@ -94,7 +93,6 @@ HKLM,%UnplugKey%,"NICS",0x00010001,0
>   Vendor="@VENDOR_NAME@"
>   DiskDesc="@PRODUCT_NAME@ PV Network Class Package"
>   XenVifName="@PRODUCT_NAME@ PV Network Class"
> -RequestKey="SYSTEM\CurrentControlSet\Services\xenbus_monitor\Request"
>   UnplugKey="SYSTEM\CurrentControlSet\Services\XEN\Unplug"
>   
>   SERVICE_BOOT_START=0x0
> diff --git a/src/xenvif/driver.c b/src/xenvif/driver.c
> index 3345607..438c21a 100644
> --- a/src/xenvif/driver.c
> +++ b/src/xenvif/driver.c
> @@ -49,7 +49,6 @@ typedef struct _XENVIF_DRIVER {
>       HANDLE              ParametersKey;
>       HANDLE              AddressesKey;
>       HANDLE              SettingsKey;
> -    BOOLEAN             NeedReboot;
>   } XENVIF_DRIVER, *PXENVIF_DRIVER;
>   
>   static XENVIF_DRIVER    Driver;
> @@ -168,96 +167,6 @@ DriverGetSettingsKey(
>       return __DriverGetSettingsKey();
>   }
>   
> -#define MAXNAMELEN  256
> -
> -static FORCEINLINE VOID
> -__DriverRequestReboot(
> -    VOID
> -    )
> -{
> -    PANSI_STRING    Ansi;
> -    CHAR            RequestKeyName[MAXNAMELEN];
> -    HANDLE          RequestKey;
> -    HANDLE          SubKey;
> -    NTSTATUS        status;
> -
> -    Info("====>\n");
> -
> -    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
> -
> -    status = RegistryQuerySzValue(__DriverGetParametersKey(),
> -                                  "RequestKey",
> -                                  NULL,
> -                                  &Ansi);
> -    if (!NT_SUCCESS(status))
> -        goto fail1;
> -
> -    status = RtlStringCbPrintfA(RequestKeyName,
> -                                MAXNAMELEN,
> -                                "\\Registry\\Machine\\%Z",
> -                                &Ansi[0]);
> -    ASSERT(NT_SUCCESS(status));
> -
> -    status = RegistryCreateSubKey(NULL,
> -                                  RequestKeyName,
> -                                  REG_OPTION_NON_VOLATILE,
> -                                  &RequestKey);
> -    if (!NT_SUCCESS(status))
> -        goto fail2;
> -
> -    status = RegistryCreateSubKey(RequestKey,
> -                                  __MODULE__,
> -                                  REG_OPTION_VOLATILE,
> -                                  &SubKey);
> -    if (!NT_SUCCESS(status))
> -        goto fail3;
> -
> -    status = RegistryUpdateDwordValue(SubKey,
> -                                      "Reboot",
> -                                      1);
> -    if (!NT_SUCCESS(status))
> -        goto fail4;
> -
> -    RegistryCloseKey(SubKey);
> -
> -    RegistryFreeSzValue(Ansi);
> -
> -    Info("<====\n");
> -
> -    return;
> -
> -fail4:
> -    Error("fail4\n");
> -
> -    RegistryCloseKey(SubKey);
> -
> -fail3:
> -    Error("fail3\n");
> -
> -    RegistryCloseKey(RequestKey);
> -
> -fail2:
> -    Error("fail2\n");
> -
> -    RegistryFreeSzValue(Ansi);
> -
> -fail1:
> -    Error("fail1 (%08x)\n", status);
> -}
> -
> -VOID
> -DriverRequestReboot(
> -    VOID
> -    )
> -{
> -    if (Driver.NeedReboot)
> -        return;
> -
> -    __DriverRequestReboot();
> -
> -    Driver.NeedReboot = TRUE;
> -}
> -
>   DRIVER_UNLOAD       DriverUnload;
>   
>   VOID
> @@ -273,8 +182,6 @@ DriverUnload(
>   
>       Trace("====>\n");
>   
> -    Driver.NeedReboot = FALSE;
> -
>       SettingsKey = __DriverGetSettingsKey();
>       __DriverSetSettingsKey(NULL);
>   
> diff --git a/src/xenvif/driver.h b/src/xenvif/driver.h
> index b5b9a3d..96be6df 100644
> --- a/src/xenvif/driver.h
> +++ b/src/xenvif/driver.h
> @@ -58,11 +58,6 @@ DriverGetSettingsKey(
>       VOID
>       );
>   
> -extern VOID
> -DriverRequestReboot(
> -    VOID
> -    );
> -
>   typedef struct _XENVIF_PDO  XENVIF_PDO, *PXENVIF_PDO;
>   typedef struct _XENVIF_FDO  XENVIF_FDO, *PXENVIF_FDO;
>   
> diff --git a/src/xenvif/pdo.c b/src/xenvif/pdo.c
> index a3ae061..28121ac 100644
> --- a/src/xenvif/pdo.c
> +++ b/src/xenvif/pdo.c
> @@ -1253,6 +1253,24 @@ PdoUnplugRequest(
>       XENBUS_UNPLUG(Release, &Pdo->UnplugInterface);
>   }
>   
> +static VOID
> +PdoRequestReboot(
> +    IN  PXENVIF_PDO Pdo
> +    )
> +{
> +    NTSTATUS        status;
> +
> +    status = XENBUS_UNPLUG(Acquire, &Pdo->UnplugInterface);
> +    if (!NT_SUCCESS(status))
> +        return;
> +
> +    XENBUS_UNPLUG(Reboot,
> +                  &Pdo->UnplugInterface,
> +                  __MODULE__);
> +
> +    XENBUS_UNPLUG(Release, &Pdo->UnplugInterface);
> +}
> +
>   static BOOLEAN
>   PdoUnplugRequested(
>       IN  PXENVIF_PDO Pdo
> @@ -1439,7 +1457,7 @@ PdoStartDevice(
>       status = PdoParseMibTable(Pdo, SoftwareKey);
>       if (status == STATUS_PNP_REBOOT_REQUIRED || !PdoUnplugRequested(Pdo)) {
>           PdoUnplugRequest(Pdo, TRUE);
> -        DriverRequestReboot();
> +        PdoRequestReboot(Pdo);
>   
>           status = STATUS_PNP_REBOOT_REQUIRED;
>           goto fail5;



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Jun 30 11:22:28 2025
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 30 Jun 2025 11:22:28 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1029048.1402786 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uWCai-00072o-EL; Mon, 30 Jun 2025 11:22:28 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1029048.1402786; Mon, 30 Jun 2025 11:22:28 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1uWCai-00072h-Bc; Mon, 30 Jun 2025 11:22:28 +0000
Received: by outflank-mailman (input) for mailman id 1029048;
 Mon, 30 Jun 2025 11:22:27 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=DXXp=ZN=cloud.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1uWCah-00072b-5Q
 for win-pv-devel@lists.xenproject.org; Mon, 30 Jun 2025 11:22:27 +0000
Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com
 [2a00:1450:4864:20::12d])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 804e1fc4-55a4-11f0-a312-13f23c93f187;
 Mon, 30 Jun 2025 13:22:26 +0200 (CEST)
Received: by mail-lf1-x12d.google.com with SMTP id
 2adb3069b0e04-555163cd09aso1403811e87.3
 for <win-pv-devel@lists.xenproject.org>; Mon, 30 Jun 2025 04:22:26 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 804e1fc4-55a4-11f0-a312-13f23c93f187
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=cloud.com; s=cloud; t=1751282546; x=1751887346; darn=lists.xenproject.org;
        h=cc:to:subject:message-id:date:from:in-reply-to:references
         :mime-version:from:to:cc:subject:date:message-id:reply-to;
        bh=nrk4IIsBhY7k1jIM13yIpzWKBYBUbFNNIVWh5c2dLEs=;
        b=eqfxg/J3kx1AvzMhrdYVW5xpQUfE9f83VO7ZN069B87F9Ph3cdsKKvqHVDDID7zyiu
         oxPGReXVn1H9ghcxpNC1hQ+pocOp9ESZ3RM6/5MmnKkyfYSc07b7PoRd7Eo6kfKRBK03
         lm1VPi0H2GC/j35rAmm96Uh4vugflYWx1/CVQ=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1751282546; x=1751887346;
        h=cc:to:subject:message-id:date:from:in-reply-to:references
         :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=nrk4IIsBhY7k1jIM13yIpzWKBYBUbFNNIVWh5c2dLEs=;
        b=uEtvEP3woOyHG0RsmGrLYU136mr6G/yToQzlDLETUcb7oZCOn7EAofpehKE1CrFaf9
         6bzXIQuk5/uz1rZKHVM/8NOcO2ccTpyUO0CTXFxPxX08DM40GVAPwVjezS2lB3EjKddp
         HoYF13snnBWW+Oe4thAvXIfyPSn72xGMf4ZOIGSXNzOe4m0UH8PGQOeixPyr2lZBZW9h
         U8c49r2dhBymVpS/GeE3nq5zmXYnYLjkQr6a5Og6UnUGn1GE/1ldIqfz5q6c49wDbpW9
         pSFnrizD0uE2gcE+GT8lJcCN3FmZJVwoZXx7ch7TflF/IBAJFfA9jTG8XVoVPjI+Xrc1
         jNaQ==
X-Gm-Message-State: AOJu0YxdPfW7GGBpq6nGZR2J6YdlkU7/BiAXMwtrUYO5t0/VH1Mb0nDP
	U5Jug+nxqAWWwQ0Z351WgYyp82N/VP7/RHqi4dCdhpTfOzASL3tvNAtd9P6TlmMKqOoF8Dj9KBe
	0VHfOjXVb5npXi9Ogi2barMqUJP91HJQ1NOPKet5Y
X-Gm-Gg: ASbGnct3bN52bJBYoF5pGFcgOkHHPYBrg86QNH/lVVcWvwwxxSozlYHdFzG2nXGZ0bM
	5digNyEcIgOvuBai5i5IgHmnb2S5kpnoPAFXASA9bsi2UQws3iRIXdqP6VBfTy1vb8ly2pU4gO1
	IzwdpPhuxMt1AtCdPij9ggEGJlreXMcIdaSLfNJVqEBQc=
X-Google-Smtp-Source: AGHT+IGGTR+ePKhHrepjBVo7G+390IulGkCO9Os+LongQfaw+iyuWr0Re7tb1pL/PKsDKfbVmjLBPkJEtpz1urUwA50=
X-Received: by 2002:a05:6512:3b0b:b0:553:abd6:cd3 with SMTP id
 2adb3069b0e04-5550b7e96bcmr3786477e87.6.1751282545677; Mon, 30 Jun 2025
 04:22:25 -0700 (PDT)
MIME-Version: 1.0
References: <20250630102411.1265-1-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20250630102411.1265-1-ngoc-tu.dinh@vates.tech>
From: Owen Smith <owen.smith@cloud.com>
Date: Mon, 30 Jun 2025 12:22:13 +0100
X-Gm-Features: Ac12FXw5VKm4NmGVVlcaprj2RCK4bkeORdGdo7Qg3c8FfHuTldDzEWto7K4BWR8
Message-ID: <CAC_UY886n7hbtgnR8jfFZAcXXvcM1_ULBdD+C3d7SSa-qh0rOQ@mail.gmail.com>
Subject: Re: [PATCH] Add Tu Dinh as a maintainer
To: Tu Dinh <ngoc-tu.dinh@vates.tech>
Cc: win-pv-devel@lists.xenproject.org
Content-Type: multipart/alternative; boundary="000000000000096d790638c83ec7"

--000000000000096d790638c83ec7
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Acked-by: Owen Smith <owen.smith@cloud.com>

Will apply to all driver repos

On Mon, Jun 30, 2025 at 11:26=E2=80=AFAM Tu Dinh <ngoc-tu.dinh@vates.tech> =
wrote:

> I would like to nominate myself as a maintainer of all Xen PV drivers
> for Windows.
>
> I have contributed patches to various areas of the drivers (security,
> bug fixes, enhancements) and plan to continue working on improving them.
>
> Owen (the current maintainer) has verbally supported this nomination.
>
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
>  MAINTAINERS | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7326c9e..2b07abc 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -44,3 +44,5 @@ Maintainers List
>  ----------------
>
>  * Owen Smith <owen.smith@cloud.com>
> +
> +* Tu Dinh <ngoc-tu.dinh@vates.tech>
> --
> 2.50.0.windows.1
>
>
>
> Ngoc Tu Dinh | Vates XCP-ng Developer
>
> XCP-ng & Xen Orchestra - Vates solutions
>
> web: https://vates.tech
>
>

--000000000000096d790638c83ec7
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:monospac=
e">Acked-by: Owen Smith &lt;<a href=3D"mailto:owen.smith@cloud.com">owen.sm=
ith@cloud.com</a>&gt;</div><div class=3D"gmail_default" style=3D"font-famil=
y:monospace"><br></div><div class=3D"gmail_default" style=3D"font-family:mo=
nospace">Will apply to all driver repos</div></div><br><div class=3D"gmail_=
quote gmail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Mon, =
Jun 30, 2025 at 11:26=E2=80=AFAM Tu Dinh &lt;ngoc-tu.dinh@vates.tech&gt; wr=
ote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I would lik=
e to nominate myself as a maintainer of all Xen PV drivers<br>
for Windows.<br>
<br>
I have contributed patches to various areas of the drivers (security,<br>
bug fixes, enhancements) and plan to continue working on improving them.<br=
>
<br>
Owen (the current maintainer) has verbally supported this nomination.<br>
<br>
Signed-off-by: Tu Dinh &lt;ngoc-tu.dinh@vates.tech&gt;<br>
---<br>
=C2=A0MAINTAINERS | 2 ++<br>
=C2=A01 file changed, 2 insertions(+)<br>
<br>
diff --git a/MAINTAINERS b/MAINTAINERS<br>
index 7326c9e..2b07abc 100644<br>
--- a/MAINTAINERS<br>
+++ b/MAINTAINERS<br>
@@ -44,3 +44,5 @@ Maintainers List<br>
=C2=A0----------------<br>
<br>
=C2=A0* Owen Smith &lt;<a href=3D"mailto:owen.smith@cloud.com" target=3D"_b=
lank">owen.smith@cloud.com</a>&gt;<br>
+<br>
+* Tu Dinh &lt;ngoc-tu.dinh@vates.tech&gt;<br>
-- <br>
2.50.0.windows.1<br>
<br>
<br>
<br>
Ngoc Tu Dinh | Vates XCP-ng Developer<br>
<br>
XCP-ng &amp; Xen Orchestra - Vates solutions<br>
<br>
web: <a href=3D"https://vates.tech" rel=3D"noreferrer" target=3D"_blank">ht=
tps://vates.tech</a><br>
<br>
</blockquote></div>

--000000000000096d790638c83ec7--


