1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
// All files in the project carrying such notice may not be copied, modified, or distributed
// except according to those terms.
use shared::basetsd::DWORD_PTR;
use shared::minwindef::{
    BOOL, BYTE, DWORD, HKEY, LPBYTE, LPCVOID, LPDWORD, PFILETIME, PHKEY, ULONG
};
use um::minwinbase::LPSECURITY_ATTRIBUTES;
use um::reason::{
    SHTDN_REASON_FLAG_PLANNED, SHTDN_REASON_LEGACY_API, SHTDN_REASON_MAJOR_HARDWARE,
    SHTDN_REASON_MAJOR_OTHER, SHTDN_REASON_MAJOR_SOFTWARE, SHTDN_REASON_MAJOR_SYSTEM,
    SHTDN_REASON_MINOR_HUNG, SHTDN_REASON_MINOR_INSTALLATION, SHTDN_REASON_MINOR_OTHER,
    SHTDN_REASON_MINOR_RECONFIG, SHTDN_REASON_MINOR_UNSTABLE, SHTDN_REASON_UNKNOWN,
};
use um::winnt::{
    ACCESS_MASK, BOOLEAN, HANDLE, LONG, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PBOOLEAN, PLONG,
    PSECURITY_DESCRIPTOR, PVOID, SECURITY_INFORMATION,
};
pub type LSTATUS = LONG;
pub const RRF_RT_REG_NONE: DWORD = 0x00000001;
pub const RRF_RT_REG_SZ: DWORD = 0x00000002;
pub const RRF_RT_REG_EXPAND_SZ: DWORD = 0x00000004;
pub const RRF_RT_REG_BINARY: DWORD = 0x00000008;
pub const RRF_RT_REG_DWORD: DWORD = 0x00000010;
pub const RRF_RT_REG_MULTI_SZ: DWORD = 0x00000020;
pub const RRF_RT_REG_QWORD: DWORD = 0x00000040;
pub const RRF_RT_DWORD: DWORD = RRF_RT_REG_BINARY | RRF_RT_REG_DWORD;
pub const RRF_RT_QWORD: DWORD = RRF_RT_REG_BINARY | RRF_RT_REG_QWORD;
pub const RRF_RT_ANY: DWORD = 0x0000ffff;
pub const RRF_SUBKEY_WOW6464KEY: DWORD = 0x00010000;
pub const RRF_SUBKEY_WOW6432KEY: DWORD = 0x00020000;
pub const RRF_WOW64_MASK: DWORD = 0x00030000;
pub const RRF_NOEXPAND: DWORD = 0x10000000;
pub const RRF_ZEROONFAILURE: DWORD = 0x20000000;
pub const REG_PROCESS_APPKEY: DWORD = 0x00000001;
pub type REGSAM = ACCESS_MASK;
pub const HKEY_CLASSES_ROOT: HKEY = 0x80000000i32 as usize as HKEY;
pub const HKEY_CURRENT_USER: HKEY = 0x80000001i32 as usize as HKEY;
pub const HKEY_LOCAL_MACHINE: HKEY = 0x80000002i32 as usize as HKEY;
pub const HKEY_USERS: HKEY = 0x80000003i32 as usize as HKEY;
pub const HKEY_PERFORMANCE_DATA: HKEY = 0x80000004i32 as usize as HKEY;
pub const HKEY_PERFORMANCE_TEXT: HKEY = 0x80000050i32 as usize as HKEY;
pub const HKEY_PERFORMANCE_NLSTEXT: HKEY = 0x80000060i32 as usize as HKEY;
pub const HKEY_CURRENT_CONFIG: HKEY = 0x80000005i32 as usize as HKEY;
pub const HKEY_DYN_DATA: HKEY = 0x80000006i32 as usize as HKEY;
pub const HKEY_CURRENT_USER_LOCAL_SETTINGS: HKEY = 0x80000007i32 as usize as HKEY;
// PROVIDER_KEEPS_VALUE_LENGTH
// val_context
// PVALUEA
// PVALUEW
// QUERYHANDLER
// REG_PROVIDER
STRUCT!{struct VALENTA {
    ve_valuename: LPSTR,
    ve_valuelen: DWORD,
    ve_valueptr: DWORD_PTR,
    ve_type: DWORD,
}}
pub type PVALENTA = *mut VALENTA;
STRUCT!{struct VALENTW {
    ve_valuename: LPWSTR,
    ve_valuelen: DWORD,
    ve_valueptr: DWORD_PTR,
    ve_type: DWORD,
}}
pub type PVALENTW = *mut VALENTW;
// WIN31_CLASS
pub const REG_MUI_STRING_TRUNCATE: DWORD = 0x00000001;
pub const REG_SECURE_CONNECTION: DWORD = 1;
extern "system" {
    pub fn RegCloseKey(
        hKey: HKEY,
    ) -> LSTATUS;
    pub fn RegOverridePredefKey(
        hKey: HKEY,
        hNewHKey: HKEY,
    ) -> LSTATUS;
    pub fn RegOpenUserClassesRoot(
        hToken: HANDLE,
        dwOptions: DWORD,
        samDesired: REGSAM,
        phkResult: PHKEY,
    ) -> LSTATUS;
    pub fn RegOpenCurrentUser(
        samDesired: REGSAM,
        phkResult: PHKEY,
    ) -> LSTATUS;
    pub fn RegDisablePredefinedCache() -> LSTATUS;
    pub fn RegDisablePredefinedCacheEx() -> LSTATUS;
    pub fn RegConnectRegistryA(
        lpMachineName: LPCSTR,
        hKey: HKEY,
        phkResult: PHKEY,
    ) -> LSTATUS;
    pub fn RegConnectRegistryW(
        lpMachineName: LPCWSTR,
        hKey: HKEY,
        phkResult: PHKEY,
    ) -> LSTATUS;
    pub fn RegConnectRegistryExA(
        lpMachineName: LPCSTR,
        hKey: HKEY,
        flags: ULONG,
        phkResult: PHKEY,
    ) -> LSTATUS;
    pub fn RegConnectRegistryExW(
        lpMachineName: LPCWSTR,
        hKey: HKEY,
        flags: ULONG,
        phkResult: PHKEY,
    ) -> LSTATUS;
    pub fn RegCreateKeyA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        phkResult: PHKEY,
    ) -> LSTATUS;
    pub fn RegCreateKeyW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        phkResult: PHKEY,
    ) -> LSTATUS;
    pub fn RegCreateKeyExA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        Reserved: DWORD,
        lpClass: LPSTR,
        dwOptions: DWORD,
        samDesired: REGSAM,
        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
        phkResult: PHKEY,
        lpdwDisposition: LPDWORD,
    ) -> LSTATUS;
    pub fn RegCreateKeyExW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        Reserved: DWORD,
        lpClass: LPWSTR,
        dwOptions: DWORD,
        samDesired: REGSAM,
        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
        phkResult: PHKEY,
        lpdwDisposition: LPDWORD,
    ) -> LSTATUS;
    pub fn RegCreateKeyTransactedA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        Reserved: DWORD,
        lpClass: LPSTR,
        dwOptions: DWORD,
        samDesired: REGSAM,
        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
        phkResult: PHKEY,
        lpdwDisposition: LPDWORD,
        hTransaction: HANDLE,
        pExtendedParemeter: PVOID,
    ) -> LSTATUS;
    pub fn RegCreateKeyTransactedW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        Reserved: DWORD,
        lpClass: LPWSTR,
        dwOptions: DWORD,
        samDesired: REGSAM,
        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
        phkResult: PHKEY,
        lpdwDisposition: LPDWORD,
        hTransaction: HANDLE,
        pExtendedParemeter: PVOID,
    ) -> LSTATUS;
    pub fn RegDeleteKeyA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
    ) -> LSTATUS;
    pub fn RegDeleteKeyW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
    ) -> LSTATUS;
    pub fn RegDeleteKeyExA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        samDesired: REGSAM,
        Reserved: DWORD,
    ) -> LSTATUS;
    pub fn RegDeleteKeyExW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        samDesired: REGSAM,
        Reserved: DWORD,
    ) -> LSTATUS;
    pub fn RegDeleteKeyTransactedA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        samDesired: REGSAM,
        Reserved: DWORD,
        hTransaction: HANDLE,
        pExtendedParemeter: PVOID,
    ) -> LSTATUS;
    pub fn RegDeleteKeyTransactedW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        samDesired: REGSAM,
        Reserved: DWORD,
        hTransaction: HANDLE,
        pExtendedParemeter: PVOID,
    ) -> LSTATUS;
    pub fn RegDisableReflectionKey(
        hBase: HKEY,
    ) -> LONG;
    pub fn RegEnableReflectionKey(
        hBase: HKEY,
    ) -> LONG;
    pub fn RegQueryReflectionKey(
        hBase: HKEY,
        bIsReflectionDisabled: *mut BOOL,
    ) -> LONG;
    pub fn RegDeleteValueA(
        hKey: HKEY,
        lpValueName: LPCSTR,
    ) -> LSTATUS;
    pub fn RegDeleteValueW(
        hKey: HKEY,
        lpValueName: LPCWSTR,
    ) -> LSTATUS;
    pub fn RegEnumKeyA(
        hKey: HKEY,
        dwIndex: DWORD,
        lpName: LPSTR,
        cchName: DWORD,
    ) -> LSTATUS;
    pub fn RegEnumKeyW(
        hKey: HKEY,
        dwIndex: DWORD,
        lpName: LPWSTR,
        cchName: DWORD,
    ) -> LSTATUS;
    pub fn RegEnumKeyExA(
        hKey: HKEY,
        dwIndex: DWORD,
        lpName: LPSTR,
        lpcName: LPDWORD,
        lpReserved: LPDWORD,
        lpClass: LPSTR,
        lpcClass: LPDWORD,
        lpftLastWriteTime: PFILETIME,
    ) -> LSTATUS;
    pub fn RegEnumKeyExW(
        hKey: HKEY,
        dwIndex: DWORD,
        lpName: LPWSTR,
        lpcName: LPDWORD,
        lpReserved: LPDWORD,
        lpClass: LPWSTR,
        lpcClass: LPDWORD,
        lpftLastWriteTime: PFILETIME,
    ) -> LSTATUS;
    pub fn RegEnumValueA(
        hKey: HKEY,
        dwIndex: DWORD,
        lpValueName: LPSTR,
        lpcchValueName: LPDWORD,
        lpReserved: LPDWORD,
        lpType: LPDWORD,
        lpData: LPBYTE,
        lpcbData: LPDWORD,
    ) -> LSTATUS;
    pub fn RegEnumValueW(
        hKey: HKEY,
        dwIndex: DWORD,
        lpValueName: LPWSTR,
        lpcchValueName: LPDWORD,
        lpReserved: LPDWORD,
        lpType: LPDWORD,
        lpData: LPBYTE,
        lpcbData: LPDWORD,
    ) -> LSTATUS;
    pub fn RegFlushKey(
        hKey: HKEY,
    ) -> LSTATUS;
    pub fn RegGetKeySecurity(
        hKey: HKEY,
        SecurityInformation: SECURITY_INFORMATION,
        pSecurityDescriptor: PSECURITY_DESCRIPTOR,
        lpcbSecurityDescriptor: LPDWORD,
    ) -> LSTATUS;
    pub fn RegLoadKeyA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        lpFile: LPCSTR,
    ) -> LSTATUS;
    pub fn RegLoadKeyW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        lpFile: LPCWSTR,
    ) -> LSTATUS;
    pub fn RegNotifyChangeKeyValue(
        hKey: HKEY,
        bWatchSubtree: BOOL,
        dwNotifyFilter: DWORD,
        hEvent: HANDLE,
        fAsynchronous: BOOL,
    ) -> LSTATUS;
    pub fn RegOpenKeyA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        phkResult: PHKEY,
    ) -> LSTATUS;
    pub fn RegOpenKeyW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        phkResult: PHKEY,
    ) -> LSTATUS;
    pub fn RegOpenKeyExA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        ulOptions: DWORD,
        samDesired: REGSAM,
        phkResult: PHKEY,
    ) -> LSTATUS;
    pub fn RegOpenKeyExW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        ulOptions: DWORD,
        samDesired: REGSAM,
        phkResult: PHKEY,
    ) -> LSTATUS;
    pub fn RegOpenKeyTransactedA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        ulOptions: DWORD,
        samDesired: REGSAM,
        phkResult: PHKEY,
        hTransaction: HANDLE,
        pExtendedParemeter: PVOID,
    ) -> LSTATUS;
    pub fn RegOpenKeyTransactedW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        ulOptions: DWORD,
        samDesired: REGSAM,
        phkResult: PHKEY,
        hTransaction: HANDLE,
        pExtendedParemeter: PVOID,
    ) -> LSTATUS;
    pub fn RegQueryInfoKeyA(
        hKey: HKEY,
        lpClass: LPSTR,
        lpcClass: LPDWORD,
        lpReserved: LPDWORD,
        lpcSubKeys: LPDWORD,
        lpcMaxSubKeyLen: LPDWORD,
        lpcMaxClassLen: LPDWORD,
        lpcValues: LPDWORD,
        lpcMaxValueNameLen: LPDWORD,
        lpcMaxValueLen: LPDWORD,
        lpcbSecurityDescriptor: LPDWORD,
        lpftLastWriteTime: PFILETIME,
    ) -> LSTATUS;
    pub fn RegQueryInfoKeyW(
        hKey: HKEY,
        lpClass: LPWSTR,
        lpcClass: LPDWORD,
        lpReserved: LPDWORD,
        lpcSubKeys: LPDWORD,
        lpcMaxSubKeyLen: LPDWORD,
        lpcMaxClassLen: LPDWORD,
        lpcValues: LPDWORD,
        lpcMaxValueNameLen: LPDWORD,
        lpcMaxValueLen: LPDWORD,
        lpcbSecurityDescriptor: LPDWORD,
        lpftLastWriteTime: PFILETIME,
    ) -> LSTATUS;
    pub fn RegQueryValueA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        lpData: LPSTR,
        lpcbData: PLONG,
    ) -> LSTATUS;
    pub fn RegQueryValueW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        lpData: LPWSTR,
        lpcbData: PLONG,
    ) -> LSTATUS;
    pub fn RegQueryMultipleValuesA(
        hKey: HKEY,
        val_list: PVALENTA,
        num_vals: DWORD,
        lpValueBuf: LPSTR,
        ldwTotsize: LPDWORD,
    ) -> LSTATUS;
    pub fn RegQueryMultipleValuesW(
        hKey: HKEY,
        val_list: PVALENTW,
        num_vals: DWORD,
        lpValueBuf: LPWSTR,
        ldwTotsize: LPDWORD,
    ) -> LSTATUS;
    pub fn RegQueryValueExA(
        hKey: HKEY,
        lpValueName: LPCSTR,
        lpReserved: LPDWORD,
        lpType: LPDWORD,
        lpData: LPBYTE,
        lpcbData: LPDWORD,
    ) -> LSTATUS;
    pub fn RegQueryValueExW(
        hKey: HKEY,
        lpValueName: LPCWSTR,
        lpReserved: LPDWORD,
        lpType: LPDWORD,
        lpData: LPBYTE,
        lpcbData: LPDWORD,
    ) -> LSTATUS;
    pub fn RegReplaceKeyA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        lpNewFile: LPCSTR,
        lpOldFile: LPCSTR,
    ) -> LSTATUS;
    pub fn RegReplaceKeyW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        lpNewFile: LPCWSTR,
        lpOldFile: LPCWSTR,
    ) -> LSTATUS;
    pub fn RegRestoreKeyA(
        hKey: HKEY,
        lpFile: LPCSTR,
        dwFlags: DWORD,
    ) -> LSTATUS;
    pub fn RegRestoreKeyW(
        hKey: HKEY,
        lpFile: LPCWSTR,
        dwFlags: DWORD,
    ) -> LSTATUS;
    pub fn RegRenameKey(
        hKey: HKEY,
        lpSubKeyName: LPCWSTR,
        lpNewKeyName: LPCWSTR,
    ) -> LSTATUS;
    pub fn RegSaveKeyA(
        hKey: HKEY,
        lpFile: LPCSTR,
        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
    ) -> LSTATUS;
    pub fn RegSaveKeyW(
        hKey: HKEY,
        lpFile: LPCWSTR,
        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
    ) -> LSTATUS;
    pub fn RegSetKeySecurity(
        hKey: HKEY,
        SecurityInformation: SECURITY_INFORMATION,
        pSecurityDescriptor: PSECURITY_DESCRIPTOR,
    ) -> LSTATUS;
    pub fn RegSetValueA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        dwType: DWORD,
        lpData: LPCSTR,
        cbData: DWORD,
    ) -> LSTATUS;
    pub fn RegSetValueW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        dwType: DWORD,
        lpData: LPCWSTR,
        cbData: DWORD,
    ) -> LSTATUS;
    pub fn RegSetValueExA(
        hKey: HKEY,
        lpValueName: LPCSTR,
        Reserved: DWORD,
        dwType: DWORD,
        lpData: *const BYTE,
        cbData: DWORD,
    ) -> LSTATUS;
    pub fn RegSetValueExW(
        hKey: HKEY,
        lpValueName: LPCWSTR,
        Reserved: DWORD,
        dwType: DWORD,
        lpData: *const BYTE,
        cbData: DWORD,
    ) -> LSTATUS;
    pub fn RegUnLoadKeyA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
    ) -> LSTATUS;
    pub fn RegUnLoadKeyW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
    ) -> LSTATUS;
    pub fn RegDeleteKeyValueA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        lpValueName: LPCSTR,
    ) -> LSTATUS;
    pub fn RegDeleteKeyValueW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        lpValueName: LPCWSTR,
    ) -> LSTATUS;
    pub fn RegSetKeyValueA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
        lpValueName: LPCSTR,
        dwType: DWORD,
        lpData: LPCVOID,
        cbData: DWORD,
    ) -> LSTATUS;
    pub fn RegSetKeyValueW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
        lpValueName: LPCWSTR,
        dwType: DWORD,
        lpData: LPCVOID,
        cbData: DWORD,
    ) -> LSTATUS;
    pub fn RegDeleteTreeA(
        hKey: HKEY,
        lpSubKey: LPCSTR,
    ) -> LSTATUS;
    pub fn RegDeleteTreeW(
        hKey: HKEY,
        lpSubKey: LPCWSTR,
    ) -> LSTATUS;
    pub fn RegCopyTreeA(
        hKeySrc: HKEY,
        lpSubKey: LPCSTR,
        hKeyDest: HKEY,
    ) -> LSTATUS;
    pub fn RegGetValueA(
        hkey: HKEY,
        lpSubKey: LPCSTR,
        lpValue: LPCSTR,
        dwFlags: DWORD,
        pdwType: LPDWORD,
        pvData: PVOID,
        pcbData: LPDWORD,
    ) -> LSTATUS;
    pub fn RegGetValueW(
        hkey: HKEY,
        lpSubKey: LPCWSTR,
        lpValue: LPCWSTR,
        dwFlags: DWORD,
        pdwType: LPDWORD,
        pvData: PVOID,
        pcbData: LPDWORD,
    ) -> LSTATUS;
    pub fn RegCopyTreeW(
        hKeySrc: HKEY,
        lpSubKey: LPCWSTR,
        hKeyDest: HKEY,
    ) -> LSTATUS;
    pub fn RegLoadMUIStringA(
        hKey: HKEY,
        pszValue: LPCSTR,
        pszOutBuf: LPSTR,
        cbOutBuf: DWORD,
        pcbData: LPDWORD,
        Flags: DWORD,
        pszDirectory: LPCSTR,
    ) -> LSTATUS;
    pub fn RegLoadMUIStringW(
        hKey: HKEY,
        pszValue: LPCWSTR,
        pszOutBuf: LPWSTR,
        cbOutBuf: DWORD,
        pcbData: LPDWORD,
        Flags: DWORD,
        pszDirectory: LPCWSTR,
    ) -> LSTATUS;
    pub fn RegLoadAppKeyA(
        lpFile: LPCSTR,
        phkResult: PHKEY,
        samDesired: REGSAM,
        dwOptions: DWORD,
        Reserved: DWORD,
    ) -> LSTATUS;
    pub fn RegLoadAppKeyW(
        lpFile: LPCWSTR,
        phkResult: PHKEY,
        samDesired: REGSAM,
        dwOptions: DWORD,
        Reserved: DWORD,
    ) -> LSTATUS;
    pub fn InitiateSystemShutdownA(
        lpMachineName: LPSTR,
        lpMessage: LPSTR,
        dwTimeout: DWORD,
        bForceAppsClosed: BOOL,
        bRebootAfterShutdown: BOOL,
    ) -> BOOL;
    pub fn InitiateSystemShutdownW(
        lpMachineName: LPWSTR,
        lpMessage: LPWSTR,
        dwTimeout: DWORD,
        bForceAppsClosed: BOOL,
        bRebootAfterShutdown: BOOL,
    ) -> BOOL;
    pub fn AbortSystemShutdownA(
        lpMachineName: LPSTR,
    ) -> BOOL;
    pub fn AbortSystemShutdownW(
        lpMachineName: LPWSTR,
    ) -> BOOL;
}
pub const REASON_SWINSTALL: DWORD = SHTDN_REASON_MAJOR_SOFTWARE | SHTDN_REASON_MINOR_INSTALLATION;
pub const REASON_HWINSTALL: DWORD = SHTDN_REASON_MAJOR_HARDWARE | SHTDN_REASON_MINOR_INSTALLATION;
pub const REASON_SERVICEHANG: DWORD = SHTDN_REASON_MAJOR_SOFTWARE | SHTDN_REASON_MINOR_HUNG;
pub const REASON_UNSTABLE: DWORD = SHTDN_REASON_MAJOR_SYSTEM | SHTDN_REASON_MINOR_UNSTABLE;
pub const REASON_SWHWRECONF: DWORD = SHTDN_REASON_MAJOR_SOFTWARE | SHTDN_REASON_MINOR_RECONFIG;
pub const REASON_OTHER: DWORD = SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER;
pub const REASON_UNKNOWN: DWORD = SHTDN_REASON_UNKNOWN;
pub const REASON_LEGACY_API: DWORD = SHTDN_REASON_LEGACY_API;
pub const REASON_PLANNED_FLAG: DWORD = SHTDN_REASON_FLAG_PLANNED;
pub const MAX_SHUTDOWN_TIMEOUT: DWORD = 10 * 365 * 24 * 60 * 60;
extern "system" {
    pub fn InitiateSystemShutdownExA(
        lpMachineName: LPSTR,
        lpMessage: LPSTR,
        dwTimeout: DWORD,
        bForceAppsClosed: BOOL,
        bRebootAfterShutdown: BOOL,
        dwReason: DWORD,
    ) -> BOOL;
    pub fn InitiateSystemShutdownExW(
        lpMachineName: LPWSTR,
        lpMessage: LPWSTR,
        dwTimeout: DWORD,
        bForceAppsClosed: BOOL,
        bRebootAfterShutdown: BOOL,
        dwReason: DWORD,
    ) -> BOOL;
}
pub const SHUTDOWN_FORCE_OTHERS: DWORD = 0x00000001;
pub const SHUTDOWN_FORCE_SELF: DWORD = 0x00000002;
pub const SHUTDOWN_RESTART: DWORD = 0x00000004;
pub const SHUTDOWN_POWEROFF: DWORD = 0x00000008;
pub const SHUTDOWN_NOREBOOT: DWORD = 0x00000010;
pub const SHUTDOWN_GRACE_OVERRIDE: DWORD = 0x00000020;
pub const SHUTDOWN_INSTALL_UPDATES: DWORD = 0x00000040;
pub const SHUTDOWN_RESTARTAPPS: DWORD = 0x00000080;
pub const SHUTDOWN_SKIP_SVC_PRESHUTDOWN: DWORD = 0x00000100;
pub const SHUTDOWN_HYBRID: DWORD = 0x00000200;
pub const SHUTDOWN_RESTART_BOOTOPTIONS: DWORD = 0x00000400;
pub const SHUTDOWN_SOFT_REBOOT: DWORD = 0x00000800;
pub const SHUTDOWN_MOBILE_UI: DWORD = 0x00001000;
pub const SHUTDOWN_ARSO: DWORD = 0x00002000;
extern "system" {
    pub fn InitiateShutdownA(
        lpMachineName: LPSTR,
        lpMessage: LPSTR,
        dwGracePeriod: DWORD,
        dwShutdownFlags: DWORD,
        dwReason: DWORD,
    ) -> DWORD;
    pub fn InitiateShutdownW(
        lpMachineName: LPWSTR,
        lpMessage: LPWSTR,
        dwGracePeriod: DWORD,
        dwShutdownFlags: DWORD,
        dwReason: DWORD,
    ) -> DWORD;
    pub fn CheckForHiberboot(
        pHiberboot: PBOOLEAN,
        bClearFlag: BOOLEAN,
    ) -> DWORD;
    pub fn RegSaveKeyExA(
        hKey: HKEY,
        lpFile: LPCSTR,
        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
        Flags: DWORD,
    ) -> LSTATUS;
    pub fn RegSaveKeyExW(
        hKey: HKEY,
        lpFile: LPCWSTR,
        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
        Flags: DWORD,
    ) -> LSTATUS;
}