forked from taviso/loadlibrary
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwinnt_types.h
1902 lines (1678 loc) · 60.2 KB
/
winnt_types.h
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
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2003-2005 Pontus Fuchs, Giridhar Pemmasani
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef _WINNT_TYPES_H_
#define _WINNT_TYPES_H_
#define DLL_PROCESS_ATTACH 1
#define DLL_PROCESS_DETACH 0
#define DLL_THREAD_ATTACH 2
#define DLL_THREAD_DETACH 3
#define TRUE 1
#define FALSE 0
#define HANDLE PVOID
#define HMODULE PVOID
#define INVALID_HANDLE_VALUE ((HANDLE)(-1))
#define PASSIVE_LEVEL 0
#define APC_LEVEL 1
#define DISPATCH_LEVEL 2
#define DEVICE_LEVEL_BASE 4
/* soft interrupts / bottom-half's are disabled at SOFT_IRQL */
#define SOFT_IRQL (DEVICE_LEVEL_BASE + 1)
#define DIRQL (DEVICE_LEVEL_BASE + 2)
#define STATUS_WAIT_0 0
#define STATUS_SUCCESS 0
#define STATUS_ALERTED 0x00000101
#define STATUS_TIMEOUT 0x00000102
#define STATUS_PENDING 0x00000103
#define STATUS_FAILURE 0xC0000001
#define STATUS_NOT_IMPLEMENTED 0xC0000002
#define STATUS_INVALID_PARAMETER 0xC000000D
#define STATUS_NO_SUCH_FILE 0xC000000F
#define STATUS_INVALID_DEVICE_REQUEST 0xC0000010
#define STATUS_MORE_PROCESSING_REQUIRED 0xC0000016
#define STATUS_ACCESS_DENIED 0xC0000022
#define STATUS_BUFFER_TOO_SMALL 0xC0000023
#define STATUS_OBJECT_NAME_INVALID 0xC0000023
#define STATUS_MUTANT_NOT_OWNED 0xC0000046
#define STATUS_RESOURCES 0xC000009A
#define STATUS_DELETE_PENDING 0xC0000056
#define STATUS_INSUFFICIENT_RESOURCES 0xC000009A
#define STATUS_NOT_SUPPORTED 0xC00000BB
#define STATUS_INVALID_PARAMETER_2 0xC00000F0
#define STATUS_NO_MEMORY 0xC0000017
#define STATUS_CANCELLED 0xC0000120
#define STATUS_DEVICE_REMOVED 0xC00002B6
#define STATUS_DEVICE_NOT_CONNECTED 0xC000009D
#define STATUS_BUFFER_OVERFLOW 0x80000005
#define SL_PENDING_RETURNED 0x01
#define SL_INVOKE_ON_CANCEL 0x20
#define SL_INVOKE_ON_SUCCESS 0x40
#define SL_INVOKE_ON_ERROR 0x80
#define IRP_MJ_CREATE 0x00
#define IRP_MJ_CREATE_NAMED_PIPE 0x01
#define IRP_MJ_CLOSE 0x02
#define IRP_MJ_READ 0x03
#define IRP_MJ_WRITE 0x04
#define IRP_MJ_DEVICE_CONTROL 0x0E
#define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0F
#define IRP_MJ_POWER 0x16
#define IRP_MJ_SYSTEM_CONTROL 0x0E
#define IRP_MJ_PNP 0x1b
#define IRP_MJ_MAXIMUM_FUNCTION 0x1b
#define IRP_MN_WAIT_WAKE 0x00
#define IRP_MN_POWER_SEQUENCE 0x01
#define IRP_MN_SET_POWER 0x02
#define IRP_MN_QUERY_POWER 0x03
#define IRP_MN_REGINFO 0x08
#define IRP_MN_REGINFO_EX 0x0b
#define IRP_MN_START_DEVICE 0x00
#define IRP_MN_QUERY_REMOVE_DEVICE 0x01
#define IRP_MN_REMOVE_DEVICE 0x02
#define IRP_MN_CANCEL_REMOVE_DEVICE 0x03
#define IRP_MN_STOP_DEVICE 0x04
#define IRP_MN_QUERY_STOP_DEVICE 0x05
#define IRP_MN_CANCEL_STOP_DEVICE 0x06
#define IRP_MN_QUERY_DEVICE_RELATIONS 0x07
#define IRP_MN_QUERY_INTERFACE 0x08
#define IRP_BUFFERED_IO 0x00000010
#define IRP_DEALLOCATE_BUFFER 0x00000020
#define IRP_INPUT_OPERATION 0x00000040
#define IRP_DEFFER_IO_COMPLETION 0x00000800
#define THREAD_WAIT_OBJECTS 3
#define MAX_WAIT_OBJECTS 64
#define LOW_PRIORITY 0
#define LOW_REALTIME_PRIORITY 16
#define HIGH_PRIORITY 31
#define MAXIMUM_PRIORITY 32
#define MAX_PATH 260
#define PROCESSOR_FEATURE_MAX 64
#define IO_NO_INCREMENT 0
#define WMIREG_ACTION_REGISTER 1
#define WMIREG_ACTION_DEREGISTER 2
#define WMIREG_ACTION_REREGISTER 3
#define WMIREG_ACTION_UPDATE_GUIDS 4
#define WMIREGISTER 0
#define WMIUPDATE 1
#define ERROR_FILE_NOT_FOUND 2
#define FILE_ATTRIBUTE_DIRECTORY 16
#define FILE_ATTRIBUTE_ARCHIVE 32
#define FILE_ATTRIBUTE_NORMAL 128
#define FILE_ATTRIBUTE_COMPRESSED 0x800
#define INVALID_FILE_ATTRIBUTES -1;
#define ERROR_INSUFFICIENT_BUFFER 0x7A
#define noregparm __attribute__((regparm(0)))
#define regparm3 __attribute__((regparm(3)))
#define wstdcall __attribute__((__stdcall__, regparm(0)))
#define __packed __attribute__((packed))
#define wfastcall __attribute__((fastcall))
#define STATIC static
#define VOID void
#define WINAPI __attribute__((__stdcall__))
#define KI_USER_SHARED_DATA 0xffdf0000
#define MM_SHARED_USER_DATA_VA 0x7ffe0000
typedef uint8_t BOOLEAN, BOOL;
typedef void *PVOID;
typedef uint8_t BYTE;
typedef uint8_t *PBYTE;
typedef uint8_t *LPBYTE;
typedef int8_t CHAR;
typedef char *PCHAR;
typedef wchar_t WCHAR;
typedef CHAR *LPSTR;
typedef const char *LPCSTR;
typedef WCHAR *LPWSTR;
typedef const WCHAR *LPCWSTR;
typedef WCHAR *PWSTR;
typedef uint8_t UCHAR;
typedef uint8_t *PUCHAR;
typedef uint16_t SHORT;
typedef uint16_t USHORT;
typedef uint16_t *PUSHORT;
typedef uint16_t WORD;
typedef int32_t INT;
typedef uint32_t UINT;
typedef uint32_t DWORD, *PDWORD;
typedef int32_t LONG;
typedef uint32_t ULONG;
typedef uint32_t *PULONG;
typedef int64_t LONGLONG;
typedef uint64_t ULONGLONG, *PULONGLONG;
typedef uint64_t ULONGULONG;
typedef uint64_t ULONG64;
typedef uint64_t QWORD, *PQWORD;
typedef uint16_t WCHAR, *PWCHAR;
typedef HANDLE *PHANDLE;
typedef LONG HRESULT;
typedef CHAR CCHAR;
typedef SHORT CSHORT;
typedef LONGLONG LARGE_INTEGER;
typedef LONG NTSTATUS;
typedef LONG KPRIORITY;
typedef LARGE_INTEGER PHYSICAL_ADDRESS;
typedef UCHAR KIRQL;
typedef CHAR KPROCESSOR_MODE;
/* ULONG_PTR is 32 bits on 32-bit platforms and 64 bits on 64-bit
* platform, which is same as 'unsigned long' in Linux */
typedef unsigned long ULONG_PTR;
typedef size_t SIZE_T;
typedef ULONG_PTR KAFFINITY;
typedef ULONG ACCESS_MASK;
typedef ULONG_PTR PFN_NUMBER;
typedef ULONG SECURITY_INFORMATION;
/* non-negative numbers indicate success */
#define NT_SUCCESS(status) ((NTSTATUS)(status) >= 0)
typedef struct _FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME, *PFILETIME;
typedef struct ansi_string {
USHORT length;
USHORT max_length;
char *buf;
} ANSI_STRING, *PANSI_STRING;
typedef struct unicode_string {
USHORT Length;
USHORT MaximumLength;
wchar_t *Buffer;
} UNICODE_STRING, *PUNICODE_STRING;
struct nt_slist {
struct nt_slist *next;
};
union nt_slist_head {
ULONGLONG align;
struct {
struct nt_slist *next;
USHORT depth;
USHORT sequence;
};
};
typedef union nt_slist_head nt_slist_header;
struct nt_list {
struct nt_list *next;
struct nt_list *prev;
};
typedef ULONG_PTR NT_SPIN_LOCK;
enum kdpc_importance {LowImportance, MediumImportance, HighImportance};
struct kdpc;
typedef void (*DPC)(struct kdpc *kdpc, void *ctx, void *arg1,
void *arg2) wstdcall;
struct kdpc {
SHORT type;
UCHAR nr_cpu;
UCHAR importance;
struct nt_list list;
DPC func;
void *ctx;
void *arg1;
void *arg2;
union {
NT_SPIN_LOCK *lock;
/* 'lock' is not used; 'queued' represents whether
* kdpc is queued or not */
int queued;
};
};
enum pool_type {
NonPagedPool, PagedPool, NonPagedPoolMustSucceed, DontUseThisType,
NonPagedPoolCacheAligned, PagedPoolCacheAligned,
NonPagedPoolCacheAlignedMustS, MaxPoolType,
NonPagedPoolSession = 32,
PagedPoolSession = NonPagedPoolSession + 1,
NonPagedPoolMustSucceedSession = PagedPoolSession + 1,
DontUseThisTypeSession = NonPagedPoolMustSucceedSession + 1,
NonPagedPoolCacheAlignedSession = DontUseThisTypeSession + 1,
PagedPoolCacheAlignedSession = NonPagedPoolCacheAlignedSession + 1,
NonPagedPoolCacheAlignedMustSSession = PagedPoolCacheAlignedSession + 1
};
enum memory_caching_type_orig {
MmFrameBufferCached = 2
};
enum memory_caching_type {
MmNonCached = FALSE, MmCached = TRUE,
MmWriteCombined = MmFrameBufferCached, MmHardwareCoherentCached,
MmNonCachedUnordered, MmUSWCCached, MmMaximumCacheType
};
enum lock_operation {
IoReadAccess, IoWriteAccess, IoModifyAccess
};
enum mode {
KernelMode, UserMode, MaximumMode
};
struct mdl {
struct mdl *next;
CSHORT size;
CSHORT flags;
/* NdisFreeBuffer doesn't pass pool, so we store pool in
* unused field 'process' */
union {
void *process;
void *pool;
};
void *mappedsystemva;
void *startva;
ULONG bytecount;
ULONG byteoffset;
};
#define MDL_MAPPED_TO_SYSTEM_VA 0x0001
#define MDL_PAGES_LOCKED 0x0002
#define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
#define MDL_ALLOCATED_FIXED_SIZE 0x0008
#define MDL_PARTIAL 0x0010
#define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
#define MDL_IO_PAGE_READ 0x0040
#define MDL_WRITE_OPERATION 0x0080
#define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
#define MDL_FREE_EXTRA_PTES 0x0200
#define MDL_IO_SPACE 0x0800
#define MDL_NETWORK_HEADER 0x1000
#define MDL_MAPPING_CAN_FAIL 0x2000
#define MDL_ALLOCATED_MUST_SUCCEED 0x4000
#define MDL_POOL_ALLOCATED 0x0400
#define MDL_CACHE_ALLOCATED 0x8000
#define PAGE_START(ptr) ((void *)((ULONG_PTR)(ptr) & ~(PAGE_SIZE - 1)))
#define BYTE_OFFSET(ptr) ((ULONG)((ULONG_PTR)(ptr) & (PAGE_SIZE - 1)))
#define MmGetMdlByteCount(mdl) ((mdl)->bytecount)
#define MmGetMdlVirtualAddress(mdl) ((mdl)->startva + (mdl)->byteoffset)
#define MmGetMdlByteOffset(mdl) ((mdl)->byteoffset)
#define MmGetSystemAddressForMdl(mdl) ((mdl)->mappedsystemva)
#define MmGetSystemAddressForMdlSafe(mdl, priority) ((mdl)->mappedsystemva)
#define MmGetMdlPfnArray(mdl) ((PFN_NUMBER *)(mdl + 1))
#define MmInitializeMdl(mdl, baseva, length) \
do { \
(mdl)->next = NULL; \
(mdl)->size = MmSizeOfMdl(baseva, length); \
(mdl)->flags = 0; \
(mdl)->startva = PAGE_START(baseva); \
(mdl)->byteoffset = BYTE_OFFSET(baseva); \
(mdl)->bytecount = length; \
(mdl)->mappedsystemva = baseva; \
TRACE4("%p %p %p %d %d", (mdl), baseva, (mdl)->startva, \
(mdl)->byteoffset, length); \
} while (0)
struct kdevice_queue_entry {
struct nt_list list;
ULONG sort_key;
BOOLEAN inserted;
};
struct kdevice_queue {
USHORT type;
USHORT size;
struct nt_list list;
NT_SPIN_LOCK lock;
BOOLEAN busy;
};
struct wait_context_block {
struct kdevice_queue_entry wait_queue_entry;
void *device_routine;
void *device_context;
ULONG num_regs;
void *device_object;
void *current_irp;
void *buffer_chaining_dpc;
};
struct wait_block {
struct nt_list list;
struct task_struct *thread;
void *object;
int *wait_done;
USHORT wait_key;
USHORT wait_type;
};
struct dispatcher_header {
UCHAR type;
UCHAR absolute;
UCHAR size;
UCHAR inserted;
LONG signal_state;
struct nt_list wait_blocks;
};
enum event_type {
NotificationEvent,
SynchronizationEvent,
};
enum timer_type {
NotificationTimer = NotificationEvent,
SynchronizationTimer = SynchronizationEvent,
};
enum dh_type {
NotificationObject = NotificationEvent,
SynchronizationObject = SynchronizationEvent,
MutexObject,
SemaphoreObject,
ThreadObject,
};
enum wait_type {
WaitAll, WaitAny
};
/* objects that use dispatcher_header have it as the first field, so
* whenever we need to initialize dispatcher_header, we can convert
* that object into a nt_event and access dispatcher_header */
struct nt_event {
struct dispatcher_header dh;
};
struct wrap_timer;
#define WRAP_TIMER_MAGIC 47697249
struct nt_timer {
struct dispatcher_header dh;
/* We can't fit Linux timer in this structure. Instead of
* padding the nt_timer structure, we replace due_time field
* with *wrap_timer and allocate memory for it when nt_timer is
* initialized */
union {
ULONGLONG due_time;
struct wrap_timer *wrap_timer;
};
struct nt_list nt_timer_list;
struct kdpc *kdpc;
union {
LONG period;
LONG wrap_timer_magic;
};
};
struct nt_mutex {
struct dispatcher_header dh;
struct nt_list list;
struct task_struct *owner_thread;
BOOLEAN abandoned;
BOOLEAN apc_disable;
};
struct nt_semaphore {
struct dispatcher_header dh;
LONG limit;
};
struct nt_thread {
struct dispatcher_header dh;
/* the rest in Windows is a long structure; since this
* structure is opaque to drivers, we just define what we
* need */
int pid;
NTSTATUS status;
struct task_struct *task;
struct nt_list irps;
NT_SPIN_LOCK lock;
KPRIORITY prio;
};
#define set_object_type(dh, type) ((dh)->type = (type))
#define is_notify_object(dh) ((dh)->type == NotificationObject)
#define is_synch_object(dh) ((dh)->type == SynchronizationObject)
#define is_mutex_object(dh) ((dh)->type == MutexObject)
#define is_semaphore_object(dh) ((dh)->type == SemaphoreObject)
#define is_nt_thread_object(dh) ((dh)->type == ThreadObject)
#define IO_TYPE_ADAPTER 1
#define IO_TYPE_CONTROLLER 2
#define IO_TYPE_DEVICE 3
#define IO_TYPE_DRIVER 4
#define IO_TYPE_FILE 5
#define IO_TYPE_IRP 6
#define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
struct irp;
struct dev_obj_ext;
struct driver_object;
struct device_object {
CSHORT type;
USHORT size;
LONG ref_count;
struct driver_object *drv_obj;
struct device_object *next;
struct device_object *attached;
struct irp *current_irp;
void *io_timer;
ULONG flags;
ULONG characteristics;
void *vpb;
void *dev_ext;
CCHAR stack_count;
union {
struct nt_list queue_list;
struct wait_context_block wcb;
} queue;
ULONG align_req;
struct kdevice_queue dev_queue;
struct kdpc dpc;
ULONG active_threads;
void *security_desc;
struct nt_event lock;
USHORT sector_size;
USHORT spare1;
struct dev_obj_ext *dev_obj_ext;
void *reserved;
};
struct dev_obj_ext {
CSHORT type;
CSHORT size;
struct device_object *dev_obj;
struct device_object *attached_to;
};
struct io_status_block {
union {
NTSTATUS status;
void *pointer;
};
ULONG_PTR info;
};
#define DEVICE_TYPE ULONG
struct driver_extension;
typedef NTSTATUS driver_dispatch_t(struct device_object *dev_obj,
struct irp *irp) wstdcall;
struct driver_object {
CSHORT type;
CSHORT size;
struct device_object *dev_obj;
ULONG flags;
void *start;
ULONG driver_size;
void *section;
struct driver_extension *drv_ext;
struct unicode_string name;
struct unicode_string *hardware_database;
void *fast_io_dispatch;
void *init;
void *start_io;
void (*unload)(struct driver_object *driver) wstdcall;
driver_dispatch_t *major_func[IRP_MJ_MAXIMUM_FUNCTION + 1];
};
struct driver_extension {
struct driver_object *drv_obj;
NTSTATUS (*add_device)(struct driver_object *drv_obj,
struct device_object *dev_obj);
ULONG count;
struct unicode_string service_key_name;
struct nt_list custom_ext;
};
struct custom_ext {
struct nt_list list;
void *client_id;
};
struct wrap_bin_file;
struct file_object {
CSHORT type;
CSHORT size;
struct device_object *dev_obj;
void *volume_parameter_block;
void *fs_context;
void *fs_context2;
void *section_object_pointer;
void *private_cache_map;
NTSTATUS final_status;
union {
struct file_object *related_file_object;
struct wrap_bin_file *wrap_bin_file;
};
BOOLEAN lock_operation;
BOOLEAN delete_pending;
BOOLEAN read_access;
BOOLEAN write_access;
BOOLEAN delete_access;
BOOLEAN shared_read;
BOOLEAN shared_write;
BOOLEAN shared_delete;
ULONG flags;
struct unicode_string _name_;
LARGE_INTEGER current_byte_offset;
ULONG waiters;
ULONG busy;
void *last_lock;
struct nt_event lock;
struct nt_event event;
void *completion_context;
};
#define POINTER_ALIGN
#define CACHE_ALIGN __attribute__((aligned(128)))
enum system_power_state {
PowerSystemUnspecified = 0,
PowerSystemWorking, PowerSystemSleeping1, PowerSystemSleeping2,
PowerSystemSleeping3, PowerSystemHibernate, PowerSystemShutdown,
PowerSystemMaximum,
};
enum device_power_state {
PowerDeviceUnspecified = 0,
PowerDeviceD0, PowerDeviceD1, PowerDeviceD2, PowerDeviceD3,
PowerDeviceMaximum,
};
union power_state {
enum system_power_state system_state;
enum device_power_state device_state;
};
enum power_state_type {
SystemPowerState = 0, DevicePowerState,
};
enum power_action {
PowerActionNone = 0,
PowerActionReserved, PowerActionSleep, PowerActionHibernate,
PowerActionShutdown, PowerActionShutdownReset, PowerActionShutdownOff,
PowerActionWarmEject,
};
typedef struct guid {
ULONG data1;
USHORT data2;
USHORT data3;
UCHAR data4[8];
} GUID, *PGUID, *LPGUID;
struct nt_interface {
USHORT size;
USHORT version;
void *context;
void (*reference)(void *context) wstdcall;
void (*dereference)(void *context) wstdcall;
};
enum interface_type {
InterfaceTypeUndefined = -1, Internal, Isa, Eisa, MicroChannel,
TurboChannel, PCIBus, VMEBus, NuBus, PCMCIABus, CBus, MPIBus,
MPSABus, ProcessorInternal, InternalPowerBus, PNPISABus,
PNPBus, MaximumInterfaceType,
};
#define CmResourceTypeNull 0
#define CmResourceTypePort 1
#define CmResourceTypeInterrupt 2
#define CmResourceTypeMemory 3
#define CmResourceTypeDma 4
#define CmResourceTypeDeviceSpecific 5
#define CmResourceTypeBusNumber 6
#define CmResourceTypeMaximum 7
#define CmResourceTypeNonArbitrated 128
#define CmResourceTypeConfigData 128
#define CmResourceTypeDevicePrivate 129
#define CmResourceTypePcCardConfig 130
#define CmResourceTypeMfCardConfig 131
enum cm_share_disposition {
CmResourceShareUndetermined = 0, CmResourceShareDeviceExclusive,
CmResourceShareDriverExclusive, CmResourceShareShared
};
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0
#define CM_RESOURCE_INTERRUPT_LATCHED 1
#define CM_RESOURCE_MEMORY_READ_WRITE 0x0000
#define CM_RESOURCE_MEMORY_READ_ONLY 0x0001
#define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002
#define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004
#define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008
#define CM_RESOURCE_MEMORY_24 0x0010
#define CM_RESOURCE_MEMORY_CACHEABLE 0x0020
#define CM_RESOURCE_PORT_MEMORY 0x0000
#define CM_RESOURCE_PORT_IO 0x0001
#define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004
#define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008
#define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010
#define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020
#define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040
#define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080
#define CM_RESOURCE_DMA_8 0x0000
#define CM_RESOURCE_DMA_16 0x0001
#define CM_RESOURCE_DMA_32 0x0002
#define CM_RESOURCE_DMA_8_AND_16 0x0004
#define CM_RESOURCE_DMA_BUS_MASTER 0x0008
#define CM_RESOURCE_DMA_TYPE_A 0x0010
#define CM_RESOURCE_DMA_TYPE_B 0x0020
#define CM_RESOURCE_DMA_TYPE_F 0x0040
#define MAX_RESOURCES 20
#pragma pack(push,4)
struct cm_partial_resource_descriptor {
UCHAR type;
UCHAR share;
USHORT flags;
union {
struct {
PHYSICAL_ADDRESS start;
ULONG length;
} generic;
struct {
PHYSICAL_ADDRESS start;
ULONG length;
} port;
struct {
ULONG level;
ULONG vector;
KAFFINITY affinity;
} interrupt;
struct {
PHYSICAL_ADDRESS start;
ULONG length;
} memory;
struct {
ULONG channel;
ULONG port;
ULONG reserved1;
} dma;
struct {
ULONG data[3];
} device_private;
struct {
ULONG start;
ULONG length;
ULONG reserved;
} bus_number;
struct {
ULONG data_size;
ULONG reserved1;
ULONG reserved2;
} device_specific_data;
} u;
};
#pragma pack(pop)
struct cm_partial_resource_list {
USHORT version;
USHORT revision;
ULONG count;
struct cm_partial_resource_descriptor partial_descriptors[1];
};
struct cm_full_resource_descriptor {
enum interface_type interface_type;
ULONG bus_number;
struct cm_partial_resource_list partial_resource_list;
};
struct cm_resource_list {
ULONG count;
struct cm_full_resource_descriptor list[1];
};
enum file_info_class {
FileDirectoryInformation = 1,
FileBasicInformation = 4,
FileStandardInformation = 5,
FileNameInformation = 9,
FilePositionInformation = 14,
FileAlignmentInformation = 17,
FileNetworkOpenInformation = 34,
FileAttributeTagInformation = 35,
FileMaximumInformation = 41,
};
enum fs_info_class {
FileFsVolumeInformation = 1,
FileFsDeviceInformation = 4,
/* ... */
FileFsMaximumInformation = 9,
};
enum device_relation_type {
BusRelations, EjectionRelations, PowerRelations, RemovalRelations,
TargetDeviceRelation, SingleBusRelations,
};
enum bus_query_id_type {
BusQueryDeviceID = 0, BusQueryHardwareIDs = 1,
BusQueryCompatibleIDs = 2, BusQueryInstanceID = 3,
BusQueryDeviceSerialNumber = 4,
};
enum device_text_type {
DeviceTextDescription = 0, DeviceTextLocationInformation = 1,
};
enum device_usage_notification_type {
DeviceUsageTypeUndefined, DeviceUsageTypePaging,
DeviceUsageTypeHibernation, DevbiceUsageTypeDumpFile,
};
#define METHOD_BUFFERED 0
#define METHOD_IN_DIRECT 1
#define METHOD_OUT_DIRECT 2
#define METHOD_NEITHER 3
#define CTL_CODE(dev_type, func, method, access) \
(((dev_type) << 16) | ((access) << 14) | ((func) << 2) | (method))
#define IO_METHOD_FROM_CTL_CODE(code) (code & 0x3)
struct io_stack_location {
UCHAR major_fn;
UCHAR minor_fn;
UCHAR flags;
UCHAR control;
union {
struct {
void *security_context;
ULONG options;
USHORT POINTER_ALIGN file_attributes;
USHORT share_access;
ULONG POINTER_ALIGN ea_length;
} create;
struct {
ULONG length;
ULONG POINTER_ALIGN key;
LARGE_INTEGER byte_offset;
} read;
struct {
ULONG length;
ULONG POINTER_ALIGN key;
LARGE_INTEGER byte_offset;
} write;
struct {
ULONG length;
enum file_info_class POINTER_ALIGN file_info_class;
} query_file;
struct {
ULONG length;
enum file_info_class POINTER_ALIGN file_info_class;
struct file_object *file_object;
union {
struct {
BOOLEAN replace_if_exists;
BOOLEAN advance_only;
};
ULONG cluster_count;
void *delete_handle;
};
} set_file;
struct {
ULONG length;
enum fs_info_class POINTER_ALIGN fs_info_class;
} query_volume;
struct {
ULONG output_buf_len;
ULONG POINTER_ALIGN input_buf_len;
ULONG POINTER_ALIGN code;
void *type3_input_buf;
} dev_ioctl;
struct {
SECURITY_INFORMATION security_info;
ULONG POINTER_ALIGN length;
} query_security;
struct {
SECURITY_INFORMATION security_info;
void *security_descriptor;
} set_security;
struct {
void *vpb;
struct device_object *device_object;
} mount_volume;
struct {
void *vpb;
struct device_object *device_object;
} verify_volume;
struct {
void *srb;
} scsi;
struct {
enum device_relation_type type;
} query_device_relations;
struct {
const struct guid *type;
USHORT size;
USHORT version;
struct nt_interface *intf;
void *intf_data;
} query_intf;
struct {
void *capabilities;
} device_capabilities;
struct {
void *io_resource_requirement_list;
} filter_resource_requirements;
struct {
ULONG which_space;
void *buffer;
ULONG offset;
ULONG POINTER_ALIGN length;
} read_write_config;
struct {
BOOLEAN lock;
} set_lock;
struct {
enum bus_query_id_type id_type;
} query_id;
struct {
enum device_text_type device_text_type;
ULONG POINTER_ALIGN locale_id;
} query_device_text;
struct {
BOOLEAN in_path;
BOOLEAN reserved[3];
enum device_usage_notification_type POINTER_ALIGN type;
} usage_notification;
struct {
enum system_power_state power_state;
} wait_wake;
struct {
void *power_sequence;
} power_sequence;
struct {
ULONG sys_context;
enum power_state_type POINTER_ALIGN type;
union power_state POINTER_ALIGN state;
enum power_action POINTER_ALIGN shutdown_type;
} power;
struct {
struct cm_resource_list *allocated_resources;
struct cm_resource_list *allocated_resources_translated;
} start_device;
struct {
ULONG_PTR provider_id;
void *data_path;
ULONG buf_len;
void *buf;
} wmi;
struct {
void *arg1;
void *arg2;
void *arg3;
void *arg4;
} others;
} params;
struct device_object *dev_obj;
struct file_object *file_obj;
NTSTATUS (*completion_routine)(struct device_object *,
struct irp *, void *) wstdcall;
void *context;
};
struct kapc {
CSHORT type;
CSHORT size;
ULONG spare0;
struct nt_thread *thread;
struct nt_list list;
void *kernele_routine;
void *rundown_routine;
void *normal_routine;
void *normal_context;
void *sys_arg1;
void *sys_arg2;
CCHAR apc_state_index;
KPROCESSOR_MODE apc_mode;
BOOLEAN inserted;
};
#define IRP_NOCACHE 0x00000001
#define IRP_SYNCHRONOUS_API 0x00000004
#define IRP_ASSOCIATED_IRP 0x00000008
enum urb_state {
URB_INVALID = 1, URB_ALLOCATED, URB_SUBMITTED,
URB_COMPLETED, URB_FREE, URB_SUSPEND, URB_INT_UNLINKED };
struct wrap_urb {
struct nt_list list;