Skip to content

Commit a6080e8

Browse files
[viostor] WIP-phase1 - Various fixes and enhancements
See PR for more info Signed-off-by: benyamin-codez <115509179+benyamin-codez@users.noreply.github.com>
1 parent c2af034 commit a6080e8

11 files changed

Lines changed: 2885 additions & 1132 deletions

viostor/ntddi_ver.h

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*
2+
* This include file contains NTDDI_ globals and routines
3+
*
4+
* Copyright (c) 2012-2026 Red Hat, Inc.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions
8+
* are met :
9+
* 1. Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and / or other materials provided with the distribution.
14+
* 3. Neither the names of the copyright holders nor the names of their contributors
15+
* may be used to endorse or promote products derived from this software
16+
* without specific prior written permission.
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
18+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
* ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
21+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27+
* SUCH DAMAGE.
28+
*/
29+
30+
#ifndef ___NTDDIVER_H__
31+
#define ___NTDDIVER_H__
32+
33+
// #include <sdkddkver.h>
34+
35+
// The following are additional definitions not found in current EWDK(s)
36+
// at <drive:>\Program Files\Windows Kits\10\Include\10.0.<build>.0\shared\sdkddkver.h
37+
38+
// clang-format off
39+
#ifndef NTDDI_WINTHRESHOLD
40+
#define NTDDI_WINTHRESHOLD 0x0A000000 /* ABRACADABRA_THRESHOLD */
41+
#endif
42+
43+
#define NTDDI_THRESHOLD NTDDI_WINTHRESHOLD
44+
45+
#ifndef NTDDI_WIN10_NI
46+
#define NTDDI_WIN10_NI 0x0A00000C // Windows 10.0.22449-22631 / Nickel / 22H2
47+
#define NTDDI_WIN10_CU 0x0A00000D // Windows 10.0.25057-25236 / Copper / 23H1
48+
#endif
49+
50+
#ifndef NTDDI_WIN11
51+
#define NTDDI_WIN11 NTDDI_WIN10_CO
52+
#define NTDDI_WIN11_CO NTDDI_WIN10_CO // Windows 10.0.21277-22000 / Cobalt / 21H2
53+
#define NTDDI_WIN11_NI NTDDI_WIN10_NI // Windows 10.0.22449-22631 / Nickel / 22H2
54+
#define NTDDI_WIN11_CU NTDDI_WIN10_CU // Windows 10.0.25057-25236 / Copper / 23H1
55+
#endif
56+
57+
#ifndef NTDDI_WIN11_ZN
58+
#define NTDDI_WIN11_ZN 0x0A00000E // Windows 10.0.25246-25398 / Zinc / 23H2
59+
#define NTDDI_WIN11_GA 0x0A00000F // Windows 10.0.25905-25941 / Gallium / 24H1
60+
#define NTDDI_WIN11_GE 0x0A000010 // Windows 10.0.25947-26100 / Germanium / 24H2
61+
#endif
62+
63+
#ifndef NTDDI_WIN11_DT
64+
#define NTDDI_WIN11_DT 0x0A000011 // Windows 10.0.27686-27686 / Dilithium / 25H1
65+
#define NTDDI_WIN11_SE NTDDI_WIN11_DT // Windows 10.0.27691-27788 / Selenium / 25H2
66+
#endif
67+
68+
#ifndef NTDDI_WIN11_BR
69+
#define NTDDI_WIN11_BR 0x0A000012 // Windows 10.0.27798-28020 / Bromine / 26H1
70+
#define NTDDI_WIN11_KR NTDDI_WIN11_BR // Windows 10.0.29426-? / Krypton / 26H2
71+
#endif
72+
// clang-format on
73+
74+
static const char *GetNtddiDesc()
75+
{
76+
switch (NTDDI_VERSION)
77+
{
78+
case NTDDI_WIN10:
79+
return "NTDDI_VERSION : THRESHOLD | Windows 10.0.10240 | 1507 | Threshold 1";
80+
case NTDDI_WIN10_TH2:
81+
return "NTDDI_VERSION : WIN10_TH2 | Windows 10.0.10586 | 1511 | Threshold 2";
82+
case NTDDI_WIN10_RS1:
83+
return "NTDDI_VERSION : WIN10_RS1 | Windows 10.0.14393 | 1607 | Redstone 1";
84+
case NTDDI_WIN10_RS2:
85+
return "NTDDI_VERSION : WIN10_RS2 | Windows 10.0.15063 | 1703 | Redstone 2";
86+
case NTDDI_WIN10_RS3:
87+
return "NTDDI_VERSION : WIN10_RS3 | Windows 10.0.16299 | 1709 | Redstone 3";
88+
case NTDDI_WIN10_RS4:
89+
return "NTDDI_VERSION : WIN10_RS4 | Windows 10.0.17134 | 1803 | Redstone 4";
90+
case NTDDI_WIN10_RS5:
91+
return "NTDDI_VERSION : WIN10_RS5 | Windows 10.0.17763 | 1809 | Redstone 5";
92+
case NTDDI_WIN10_19H1:
93+
return "NTDDI_VERSION : WIN10_19H1 | Windows 10.0.18362 | 19H1 | Titanium";
94+
case NTDDI_WIN10_VB:
95+
return "NTDDI_VERSION : WIN10_VB | Windows 10.0.19041 | 2004 | Vibranium";
96+
case NTDDI_WIN10_MN:
97+
return "NTDDI_VERSION : WIN10_MN | Windows 10.0.19042 | 20H2 | Manganese";
98+
case NTDDI_WIN10_FE:
99+
return "NTDDI_VERSION : WIN10_FE | Windows 10.0.19043 | 21H1 | Iron";
100+
case NTDDI_WIN10_CO:
101+
return "NTDDI_VERSION : WIN10_CO | Windows 10.0.19044-22000 | 21H2 | Cobalt";
102+
case NTDDI_WIN10_NI:
103+
return "NTDDI_VERSION : WIN10_NI | Windows 10.0.22449-22631 | 22H2 | Nickel";
104+
case NTDDI_WIN10_CU:
105+
return "NTDDI_VERSION : WIN10_CU | Windows 10.0.25057-25236 | 23H1 | Copper";
106+
case NTDDI_WIN11_ZN:
107+
return "NTDDI_VERSION : WIN11_ZN | Windows 10.0.25246-25398 | 23H2 | Zinc";
108+
case NTDDI_WIN11_GA:
109+
return "NTDDI_VERSION : WIN11_GA | Windows 10.0.25905-25941 | 24H1 | Gallium";
110+
case NTDDI_WIN11_GE:
111+
return "NTDDI_VERSION : WIN11_GE | Windows 10.0.25947-26100 | 24H2 | Germanium";
112+
case NTDDI_WIN11_DT:
113+
return "NTDDI_VERSION : WIN11_DT | Windows 10.0.27686-27691 | 25H1 | Dilithium";
114+
case NTDDI_WIN11_BR:
115+
return "NTDDI_VERSION : WIN11_BR | Windows 10.0.27798-28020 | 26H1 | Bromine";
116+
default:
117+
return "UNKNOWN";
118+
}
119+
}
120+
121+
#endif //___NTDDIVER_H__

viostor/viostor.vcxproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@
135135
</ItemDefinitionGroup>
136136
<ItemDefinitionGroup Condition="'$(Configuration)'=='Win10 Release'">
137137
<ClCompile>
138-
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
138+
<PreprocessorDefinitions>%(PreprocessorDefinitions);NTDDI_VERSION=NTDDI_WIN10</PreprocessorDefinitions>
139139
</ClCompile>
140140
<Link>
141141
<AdditionalDependencies>%(AdditionalDependencies);storport.lib</AdditionalDependencies>
142142
</Link>
143143
</ItemDefinitionGroup>
144144
<ItemDefinitionGroup Condition="'$(Configuration)'=='Win11 Release'">
145145
<ClCompile>
146-
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
146+
<PreprocessorDefinitions>%(PreprocessorDefinitions);NTDDI_VERSION=NTDDI_WIN10_CO</PreprocessorDefinitions>
147147
</ClCompile>
148148
<Link>
149149
<AdditionalDependencies>%(AdditionalDependencies);storport.lib</AdditionalDependencies>
@@ -225,6 +225,8 @@
225225
<ClInclude Include="virtio_stor_hw_helper.h" />
226226
<ClInclude Include="virtio_stor_trace.h" />
227227
<ClInclude Include="virtio_stor_utils.h" />
228+
<ClInclude Include="virtio_stor_reg_helper.h" />
229+
<ClInclude Include="ntddi_ver.h" />
228230
</ItemGroup>
229231
<ItemGroup>
230232
<ResourceCompile Include="virtio_stor.rc" />
@@ -234,6 +236,7 @@
234236
<ClCompile Include="virtio_stor.c" />
235237
<ClCompile Include="virtio_stor_hw_helper.c" />
236238
<ClCompile Include="virtio_stor_utils.c" />
239+
<ClCompile Include="virtio_stor_reg_helper.c" />
237240
</ItemGroup>
238241
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
239242
<Import Project="$(MSBuildProjectDirectory)\..\build\Driver.Common.targets" />

0 commit comments

Comments
 (0)