SMBIOS Library
miniddk.h
Go to the documentation of this file.
1 // vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:
2 /*
3  * Copyright (C) 2005 Dell Inc.
4  * by Michael Brown <Michael_E_Brown@dell.com>
5  * Licensed under the Open Software License version 2.1
6  *
7  * Alternatively, you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published
9  * by the Free Software Foundation; either version 2 of the License,
10  * or (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  * See the GNU General Public License for more details.
16  */
17 
18 
19 #ifndef MINIDDK_H
20 #define MINIDDK_H
21 
22 #include <windows.h>
23 #include <stdio.h>
24 
25 
26 //From #include "ntdef.h"
27 typedef LONG NTSTATUS;
28 
29 //
30 // Generic test for success on any status value (non-negative numbers
31 // indicate success).
32 //
33 
34 #define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
35 //
36 // Unicode strings are counted 16-bit character strings. If they are
37 // NULL terminated, Length does not include trailing NULL.
38 //
39 
40 typedef struct _UNICODE_STRING
41 {
42  USHORT Length;
43  USHORT MaximumLength;
44 #ifdef MIDL_PASS
45 
46  [size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT * Buffer;
47 #else // MIDL_PASS
48 
49  PWSTR Buffer;
50 #endif // MIDL_PASS
51 }
55 #define UNICODE_NULL ((WCHAR)0) // winnt
56 
57 //
58 // Valid values for the Attributes field
59 //
60 
61 #define OBJ_INHERIT 0x00000002L
62 #define OBJ_PERMANENT 0x00000010L
63 #define OBJ_EXCLUSIVE 0x00000020L
64 #define OBJ_CASE_INSENSITIVE 0x00000040L
65 #define OBJ_OPENIF 0x00000080L
66 #define OBJ_OPENLINK 0x00000100L
67 #define OBJ_KERNEL_HANDLE 0x00000200L
68 #define OBJ_VALID_ATTRIBUTES 0x000003F2L
69 
70 //
71 // Object Attributes structure
72 //
73 
74 typedef struct _OBJECT_ATTRIBUTES
75 {
76  ULONG Length;
77  HANDLE RootDirectory;
78  PUNICODE_STRING ObjectName;
79  ULONG Attributes;
80  PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR
81  PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE
82 }
85 
86 //++
87 //
88 // VOID
89 // InitializeObjectAttributes(
90 // OUT POBJECT_ATTRIBUTES p,
91 // IN PUNICODE_STRING n,
92 // IN ULONG a,
93 // IN HANDLE r,
94 // IN PSECURITY_DESCRIPTOR s
95 // )
96 //
97 //--
98 
99 #define InitializeObjectAttributes( p, n, a, r, s ) { \
100  (p)->Length = sizeof( OBJECT_ATTRIBUTES ); \
101  (p)->RootDirectory = r; \
102  (p)->Attributes = a; \
103  (p)->ObjectName = n; \
104  (p)->SecurityDescriptor = s; \
105  (p)->SecurityQualityOfService = NULL; \
106  }
107 
108 //
109 // Physical address.
110 //
111 
112 typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
113 
114 //
115 // From winnt.h
116 //
117 //
118 // Section Information Structures.
119 //
120 
121 typedef enum _SECTION_INHERIT {
125 
126 //
127 // Section Access Rights.
128 //
129 
130 // begin_winnt
131 #define SECTION_QUERY 0x0001
132 #define SECTION_MAP_WRITE 0x0002
133 #define SECTION_MAP_READ 0x0004
134 #define SECTION_MAP_EXECUTE 0x0008
135 #define SECTION_EXTEND_SIZE 0x0010
136 
137 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY|\
138  SECTION_MAP_WRITE | \
139  SECTION_MAP_READ | \
140  SECTION_MAP_EXECUTE | \
141  SECTION_EXTEND_SIZE)
142 
143 // From ntddk.h
144 #define NtCurrentProcess() ( (HANDLE) -1 )
145 
146 // NtDll Func decls same as ZwOpenSection
147 typedef NTSTATUS (__stdcall *NtOpenSectionPtr) (
148  OUT PHANDLE SectionHandle,
149  IN ACCESS_MASK DesiredAccess,
150  IN POBJECT_ATTRIBUTES ObjectAttributes );
151 
152 // Same as ZwClose
153 typedef NTSTATUS (__stdcall *NtClosePtr) (
154  IN HANDLE Handle );
155 
156 // Same as ZwMapViewOfSection
157 typedef NTSTATUS (__stdcall *NtMapViewOfSectionPtr) (
158  IN HANDLE SectionHandle,
159  IN HANDLE ProcessHandle,
160  IN OUT PVOID *BaseAddress OPTIONAL,
161  IN ULONG ZeroBits OPTIONAL,
162  IN ULONG CommitSize,
163  IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
164  IN OUT PULONG ViewSize,
166  IN ULONG AllocationType OPTIONAL,
167  IN ULONG Protect );
168 
169 // Same as ZwUnmapViewOfSection
170 typedef NTSTATUS (__stdcall *NtUnmapViewOfSectionPtr) (
171  IN HANDLE ProcessHandle,
172  IN PVOID BaseAddress );
173 
174 typedef VOID (__stdcall *RtlInitUnicodeStringPtr) (
175  IN OUT PUNICODE_STRING DestinationString,
176  IN PCWSTR SourceString );
177 
178 
179 // For Debug Control
180 typedef enum _DEBUG_CONTROL_CODE {
192 
193 
194 typedef NTSTATUS (__stdcall *ZwSystemDebugControlPtr) (
195  IN DEBUG_CONTROL_CODE ControlCode,
197  IN ULONG InputBufferLength,
198  OUT PVOID OutputBuffer OPTIONAL,
199  IN ULONG OutputBufferLength,
200  OUT PULONG ReturnLength OPTIONAL );
201 
202 typedef NTSTATUS (__stdcall *EnumSystemFirmwareTablesPtr) (
203  IN DWORD iFirmwareTableProviderSignature,
204  OUT PVOID InputBuffer,
205  IN DWORD InputBufferLength );
206 
207 typedef NTSTATUS (__stdcall *GetSystemFirmwareTablePtr) (
208  IN DWORD iFirmwareTableProviderSignature,
209  IN DWORD FirmwareTableID,
210  OUT PVOID InputBuffer,
211  IN DWORD InputBufferLength );
212 
213 // See
214 typedef struct _IO_STRUCT
215 {
216  DWORD Addr;
217  DWORD Reserved1;
218  PVOID pBuf;
219  DWORD NumBytes;
220  DWORD Reserved4;
221  DWORD Reserved5;
222  DWORD Reserved6;
223  DWORD Reserved7;
224 }
225 IO_STRUCT;
226 
227 #ifdef LIBSMBIOS_WIN_USE_WMI
228 
229 // Define the WMI SMBIOS Information Structure
230 
231 typedef struct _WMISMBIOSINFO {
232  u8 majorVersion;
233  u8 minorVersion;
234  u32 bufferSize;
235  u8 *buffer;
236 } WMISMBIOSINFO;
237 
238 #endif
239 
240 #pragma pack(push,1)
241 typedef struct MEM_STRUCT
242 {
243  DWORD Addr;
244  DWORD Reserved1;
245  void *pBuf;
246  DWORD NumBytes;
247 }
248 MEM_STRUCT;
249 #pragma pack(pop,1)
250 
251 #endif /* MINIDDK_H */