forked from spender-sandbox/cuckoomon-modified
-
Notifications
You must be signed in to change notification settings - Fork 1
/
hooks.h
2744 lines (2368 loc) · 71.6 KB
/
hooks.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
/*
Cuckoo Sandbox - Automated Malware Analysis
Copyright (C) 2010-2014 Cuckoo Sandbox Developers
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 3 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <windns.h>
#include <wininet.h>
#include <mswsock.h>
#include "ntapi.h"
#include <tlhelp32.h>
//
// File Hooks
//
extern HOOKDEF(NTSTATUS, WINAPI, NtQueryAttributesFile,
__in POBJECT_ATTRIBUTES ObjectAttributes,
__out PFILE_BASIC_INFORMATION FileInformation
);
extern HOOKDEF(NTSTATUS, WINAPI, NtQueryFullAttributesFile,
__in POBJECT_ATTRIBUTES ObjectAttributes,
__out PFILE_NETWORK_OPEN_INFORMATION FileInformation
);
extern HOOKDEF(NTSTATUS, WINAPI, NtCreateFile,
__out PHANDLE FileHandle,
__in ACCESS_MASK DesiredAccess,
__in POBJECT_ATTRIBUTES ObjectAttributes,
__out PIO_STATUS_BLOCK IoStatusBlock,
__in_opt PLARGE_INTEGER AllocationSize,
__in ULONG FileAttributes,
__in ULONG ShareAccess,
__in ULONG CreateDisposition,
__in ULONG CreateOptions,
__in PVOID EaBuffer,
__in ULONG EaLength
);
extern HOOKDEF(NTSTATUS, WINAPI, NtOpenFile,
__out PHANDLE FileHandle,
__in ACCESS_MASK DesiredAccess,
__in POBJECT_ATTRIBUTES ObjectAttributes,
__out PIO_STATUS_BLOCK IoStatusBlock,
__in ULONG ShareAccess,
__in ULONG OpenOptions
);
extern HOOKDEF(NTSTATUS, WINAPI, NtReadFile,
__in HANDLE FileHandle,
__in_opt HANDLE Event,
__in_opt PIO_APC_ROUTINE ApcRoutine,
__in_opt PVOID ApcContext,
__out PIO_STATUS_BLOCK IoStatusBlock,
__out PVOID Buffer,
__in ULONG Length,
__in_opt PLARGE_INTEGER ByteOffset,
__in_opt PULONG Key
);
extern HOOKDEF(NTSTATUS, WINAPI, NtWriteFile,
__in HANDLE FileHandle,
__in_opt HANDLE Event,
__in_opt PIO_APC_ROUTINE ApcRoutine,
__in_opt PVOID ApcContext,
__out PIO_STATUS_BLOCK IoStatusBlock,
__in PVOID Buffer,
__in ULONG Length,
__in_opt PLARGE_INTEGER ByteOffset,
__in_opt PULONG Key
);
extern HOOKDEF(NTSTATUS, WINAPI, NtDeleteFile,
__in POBJECT_ATTRIBUTES ObjectAttributes
);
extern HOOKDEF(NTSTATUS, WINAPI, NtDeviceIoControlFile,
__in HANDLE FileHandle,
__in HANDLE Event,
__in PIO_APC_ROUTINE ApcRoutine,
__in PVOID ApcContext,
__out PIO_STATUS_BLOCK IoStatusBlock,
__in ULONG IoControlCode,
__in PVOID InputBuffer,
__in ULONG InputBufferLength,
__out PVOID OutputBuffer,
__in ULONG OutputBufferLength
);
extern HOOKDEF(NTSTATUS, WINAPI, NtQueryDirectoryFile,
__in HANDLE FileHandle,
__in_opt HANDLE Event,
__in_opt PIO_APC_ROUTINE ApcRoutine,
__in_opt PVOID ApcContext,
__out PIO_STATUS_BLOCK IoStatusBlock,
__out PVOID FileInformation,
__in ULONG Length,
__in FILE_INFORMATION_CLASS FileInformationClass,
__in BOOLEAN ReturnSingleEntry,
__in_opt PUNICODE_STRING FileName,
__in BOOLEAN RestartScan
);
extern HOOKDEF(NTSTATUS, WINAPI, NtQueryInformationFile,
__in HANDLE FileHandle,
__out PIO_STATUS_BLOCK IoStatusBlock,
__out PVOID FileInformation,
__in ULONG Length,
__in FILE_INFORMATION_CLASS FileInformationClass
);
extern HOOKDEF(NTSTATUS, WINAPI, NtSetInformationFile,
__in HANDLE FileHandle,
__out PIO_STATUS_BLOCK IoStatusBlock,
__in PVOID FileInformation,
__in ULONG Length,
__in FILE_INFORMATION_CLASS FileInformationClass
);
extern HOOKDEF(NTSTATUS, WINAPI, NtOpenDirectoryObject,
__out PHANDLE DirectoryHandle,
__in ACCESS_MASK DesiredAccess,
__in POBJECT_ATTRIBUTES ObjectAttributes
);
extern HOOKDEF(NTSTATUS, WINAPI, NtCreateDirectoryObject,
__out PHANDLE DirectoryHandle,
__in ACCESS_MASK DesiredAccess,
__in POBJECT_ATTRIBUTES ObjectAttributes
);
extern HOOKDEF(NTSTATUS, WINAPI, NtQueryDirectoryObject,
__in HANDLE DirectoryHandle,
__out_opt PVOID Buffer,
__in ULONG Length,
__in BOOLEAN ReturnSingleEntry,
__in BOOLEAN RestartScan,
__inout PULONG Context,
__out_opt PULONG ReturnLength
);
extern HOOKDEF_NOTAIL(WINAPI, MoveFileWithProgressW,
__in LPWSTR lpExistingFileName,
__in_opt LPWSTR lpNewFileName,
__in_opt LPPROGRESS_ROUTINE lpProgressRoutine,
__in_opt LPVOID lpData,
__in DWORD dwFlags
);
extern HOOKDEF_ALT(BOOL, WINAPI, MoveFileWithProgressW,
__in LPWSTR lpExistingFileName,
__in_opt LPWSTR lpNewFileName,
__in_opt LPPROGRESS_ROUTINE lpProgressRoutine,
__in_opt LPVOID lpData,
__in DWORD dwFlags
);
extern HOOKDEF_NOTAIL(WINAPI, MoveFileWithProgressTransactedW,
__in LPWSTR lpExistingFileName,
__in_opt LPWSTR lpNewFileName,
__in_opt LPPROGRESS_ROUTINE lpProgressRoutine,
__in_opt LPVOID lpData,
__in DWORD dwFlags,
__in HANDLE hTransaction
);
extern HOOKDEF_ALT(BOOL, WINAPI, MoveFileWithProgressTransactedW,
__in LPWSTR lpExistingFileName,
__in_opt LPWSTR lpNewFileName,
__in_opt LPPROGRESS_ROUTINE lpProgressRoutine,
__in_opt LPVOID lpData,
__in DWORD dwFlags,
__in HANDLE hTransaction
);
extern HOOKDEF(BOOL, WINAPI, CreateDirectoryW,
__in LPCTSTR lpPathName,
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
extern HOOKDEF(BOOL, WINAPI, CreateDirectoryExW,
__in LPWSTR lpTemplateDirectory,
__in LPWSTR lpNewDirectory,
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
extern HOOKDEF(BOOL, WINAPI, RemoveDirectoryA,
__in LPCTSTR lpPathName
);
extern HOOKDEF(BOOL, WINAPI, RemoveDirectoryW,
__in LPWSTR lpPathName
);
extern HOOKDEF(HANDLE, WINAPI, FindFirstFileExA,
__in LPCTSTR lpFileName,
__in FINDEX_INFO_LEVELS fInfoLevelId,
__out LPVOID lpFindFileData,
__in FINDEX_SEARCH_OPS fSearchOp,
__reserved LPVOID lpSearchFilter,
__in DWORD dwAdditionalFlags
);
extern HOOKDEF(HANDLE, WINAPI, FindFirstFileExW,
__in LPWSTR lpFileName,
__in FINDEX_INFO_LEVELS fInfoLevelId,
__out LPVOID lpFindFileData,
__in FINDEX_SEARCH_OPS fSearchOp,
__reserved LPVOID lpSearchFilter,
__in DWORD dwAdditionalFlags
);
extern HOOKDEF(BOOL, WINAPI, FindNextFileW,
__in HANDLE hFindFile,
__out LPWIN32_FIND_DATAW lpFindFileData
);
extern HOOKDEF(BOOL, WINAPI, CopyFileA,
__in LPCTSTR lpExistingFileName,
__in LPCTSTR lpNewFileName,
__in BOOL bFailIfExists
);
extern HOOKDEF(BOOL, WINAPI, CopyFileW,
__in LPWSTR lpExistingFileName,
__in LPWSTR lpNewFileName,
__in BOOL bFailIfExists
);
extern HOOKDEF_NOTAIL(WINAPI, CopyFileExW,
_In_ LPWSTR lpExistingFileName,
_In_ LPWSTR lpNewFileName,
_In_opt_ LPPROGRESS_ROUTINE lpProgressRoutine,
_In_opt_ LPVOID lpData,
_In_opt_ LPBOOL pbCancel,
_In_ DWORD dwCopyFlags
);
extern HOOKDEF_ALT(BOOL, WINAPI, CopyFileExW,
_In_ LPWSTR lpExistingFileName,
_In_ LPWSTR lpNewFileName,
_In_opt_ LPPROGRESS_ROUTINE lpProgressRoutine,
_In_opt_ LPVOID lpData,
_In_opt_ LPBOOL pbCancel,
_In_ DWORD dwCopyFlags
);
extern HOOKDEF(BOOL, WINAPI, DeleteFileA,
__in LPCSTR lpFileName
);
extern HOOKDEF(BOOL, WINAPI, DeleteFileW,
__in LPWSTR lpFileName
);
extern HOOKDEF(BOOL, WINAPI, GetDiskFreeSpaceExA,
_In_opt_ PCTSTR lpDirectoryName,
_Out_opt_ PULARGE_INTEGER lpFreeBytesAvailable,
_Out_opt_ PULARGE_INTEGER lpTotalNumberOfBytes,
_Out_opt_ PULARGE_INTEGER lpTotalNumberOfFreeBytes
);
extern HOOKDEF(BOOL, WINAPI, GetDiskFreeSpaceExW,
_In_opt_ PCWSTR lpDirectoryName,
_Out_opt_ PULARGE_INTEGER lpFreeBytesAvailable,
_Out_opt_ PULARGE_INTEGER lpTotalNumberOfBytes,
_Out_opt_ PULARGE_INTEGER lpTotalNumberOfFreeBytes
);
extern HOOKDEF(BOOL, WINAPI, GetDiskFreeSpaceA,
_In_ PCTSTR lpRootPathName,
_Out_ LPDWORD lpSectorsPerCluster,
_Out_ LPDWORD lpBytesPerSector,
_Out_ LPDWORD lpNumberOfFreeClusters,
_Out_ LPDWORD lpTotalNumberOfClusters
);
extern HOOKDEF(BOOL, WINAPI, GetDiskFreeSpaceW,
_In_ PCWSTR lpRootPathName,
_Out_ LPDWORD lpSectorsPerCluster,
_Out_ LPDWORD lpBytesPerSector,
_Out_ LPDWORD lpNumberOfFreeClusters,
_Out_ LPDWORD lpTotalNumberOfClusters
);
extern HOOKDEF(BOOL, WINAPI, GetVolumeNameForVolumeMountPointW,
_In_ LPCWSTR lpszVolumeMountPoint,
_Out_ LPWSTR lpszVolumeName,
_In_ DWORD cchBufferLength
);
extern HOOKDEF(HRESULT, WINAPI, SHGetFolderPathW,
_In_ HWND hwndOwner,
_In_ int nFolder,
_In_ HANDLE hToken,
_In_ DWORD dwFlags,
_Out_ LPWSTR pszPath
);
extern HOOKDEF(HRESULT, WINAPI, SHGetKnownFolderPath,
_In_ GUID *rfid,
_In_ DWORD dwFlags,
_In_opt_ HANDLE hToken,
_Out_ PWSTR *ppszPath
);
extern HOOKDEF(DWORD_PTR, WINAPI, SHGetFileInfoW,
_In_ LPCWSTR pszPath,
DWORD dwFileAttributes,
_Inout_ SHFILEINFOW *psfi,
UINT cbFileInfo,
UINT uFlags
);
extern HOOKDEF(BOOL, WINAPI, GetFileVersionInfoW,
_In_ LPCWSTR lptstrFilename,
_Reserved_ DWORD dwHandle,
_In_ DWORD dwLen,
_Out_ LPVOID lpData
);
extern HOOKDEF(DWORD, WINAPI, GetFileVersionInfoSizeW,
_In_ LPCWSTR lptstrFilename,
_Out_opt_ LPDWORD lpdwHandle
);
extern HOOKDEF(HANDLE, WINAPI, FindFirstChangeNotificationW,
_In_ LPCWSTR lpPathName,
_In_ BOOL bWatchSubtree,
_In_ DWORD dwNotifyFilter
);
extern HOOKDEF(BOOL, WINAPI, GetVolumeInformationByHandleW,
_In_ HANDLE hFile,
_Out_opt_ LPWSTR lpVolumeNameBuffer,
_In_ DWORD nVolumeNameSize,
_Out_opt_ LPDWORD lpVolumeSerialNumber,
_Out_opt_ LPDWORD
lpMaximumComponentLength,
_Out_opt_ LPDWORD lpFileSystemFlags,
_Out_opt_ LPWSTR lpFileSystemNameBuffer,
_In_ DWORD nFileSystemNameSize
);
//
// Registry Hooks
//
extern HOOKDEF(LONG, WINAPI, RegOpenKeyExA,
__in HKEY hKey,
__in_opt LPCTSTR lpSubKey,
__reserved DWORD ulOptions,
__in REGSAM samDesired,
__out PHKEY phkResult
);
extern HOOKDEF(LONG, WINAPI, RegOpenKeyExW,
__in HKEY hKey,
__in_opt LPWSTR lpSubKey,
__reserved DWORD ulOptions,
__in REGSAM samDesired,
__out PHKEY phkResult
);
extern HOOKDEF(LONG, WINAPI, RegCreateKeyExA,
__in HKEY hKey,
__in LPCTSTR lpSubKey,
__reserved DWORD Reserved,
__in_opt LPTSTR lpClass,
__in DWORD dwOptions,
__in REGSAM samDesired,
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
__out PHKEY phkResult,
__out_opt LPDWORD lpdwDisposition
);
extern HOOKDEF(LONG, WINAPI, RegCreateKeyExW,
__in HKEY hKey,
__in LPWSTR lpSubKey,
__reserved DWORD Reserved,
__in_opt LPWSTR lpClass,
__in DWORD dwOptions,
__in REGSAM samDesired,
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
__out PHKEY phkResult,
__out_opt LPDWORD lpdwDisposition
);
extern HOOKDEF(LONG, WINAPI, RegDeleteKeyA,
__in HKEY hKey,
__in LPCTSTR lpSubKey
);
extern HOOKDEF(LONG, WINAPI, RegDeleteKeyW,
__in HKEY hKey,
__in LPWSTR lpSubKey
);
extern HOOKDEF(LONG, WINAPI, RegEnumKeyW,
__in HKEY hKey,
__in DWORD dwIndex,
__out LPWSTR lpName,
__in DWORD cchName
);
extern HOOKDEF(LONG, WINAPI, RegEnumKeyExA,
__in HKEY hKey,
__in DWORD dwIndex,
__out LPTSTR lpName,
__inout LPDWORD lpcName,
__reserved LPDWORD lpReserved,
__inout LPTSTR lpClass,
__inout_opt LPDWORD lpcClass,
__out_opt PFILETIME lpftLastWriteTime
);
extern HOOKDEF(LONG, WINAPI, RegEnumKeyExW,
__in HKEY hKey,
__in DWORD dwIndex,
__out LPWSTR lpName,
__inout LPDWORD lpcName,
__reserved LPDWORD lpReserved,
__inout LPWSTR lpClass,
__inout_opt LPDWORD lpcClass,
__out_opt PFILETIME lpftLastWriteTime
);
extern HOOKDEF(LONG, WINAPI, RegEnumValueA,
__in HKEY hKey,
__in DWORD dwIndex,
__out LPTSTR lpValueName,
__inout LPDWORD lpcchValueName,
__reserved LPDWORD lpReserved,
__out_opt LPDWORD lpType,
__out_opt LPBYTE lpData,
__inout_opt LPDWORD lpcbData
);
extern HOOKDEF(LONG, WINAPI, RegEnumValueW,
__in HKEY hKey,
__in DWORD dwIndex,
__out LPWSTR lpValueName,
__inout LPDWORD lpcchValueName,
__reserved LPDWORD lpReserved,
__out_opt LPDWORD lpType,
__out_opt LPBYTE lpData,
__inout_opt LPDWORD lpcbData
);
extern HOOKDEF(LONG, WINAPI, RegSetValueExA,
__in HKEY hKey,
__in_opt LPCTSTR lpValueName,
__reserved DWORD Reserved,
__in DWORD dwType,
__in const BYTE *lpData,
__in DWORD cbData
);
extern HOOKDEF(LONG, WINAPI, RegSetValueExW,
__in HKEY hKey,
__in_opt LPWSTR lpValueName,
__reserved DWORD Reserved,
__in DWORD dwType,
__in const BYTE *lpData,
__in DWORD cbData
);
extern HOOKDEF(LONG, WINAPI, RegQueryValueExA,
__in HKEY hKey,
__in_opt LPCTSTR lpValueName,
__reserved LPDWORD lpReserved,
__out_opt LPDWORD lpType,
__out_opt LPBYTE lpData,
__inout_opt LPDWORD lpcbData
);
extern HOOKDEF(LONG, WINAPI, RegQueryValueExW,
__in HKEY hKey,
__in_opt LPWSTR lpValueName,
__reserved LPDWORD lpReserved,
__out_opt LPDWORD lpType,
__out_opt LPBYTE lpData,
__inout_opt LPDWORD lpcbData
);
extern HOOKDEF(LONG, WINAPI, RegDeleteValueA,
__in HKEY hKey,
__in_opt LPCTSTR lpValueName
);
extern HOOKDEF(LONG, WINAPI, RegDeleteValueW,
__in HKEY hKey,
__in_opt LPWSTR lpValueName
);
extern HOOKDEF(LONG, WINAPI, RegQueryInfoKeyA,
_In_ HKEY hKey,
_Out_opt_ LPTSTR lpClass,
_Inout_opt_ LPDWORD lpcClass,
_Reserved_ LPDWORD lpReserved,
_Out_opt_ LPDWORD lpcSubKeys,
_Out_opt_ LPDWORD lpcMaxSubKeyLen,
_Out_opt_ LPDWORD lpcMaxClassLen,
_Out_opt_ LPDWORD lpcValues,
_Out_opt_ LPDWORD lpcMaxValueNameLen,
_Out_opt_ LPDWORD lpcMaxValueLen,
_Out_opt_ LPDWORD lpcbSecurityDescriptor,
_Out_opt_ PFILETIME lpftLastWriteTime
);
extern HOOKDEF(LONG, WINAPI, RegQueryInfoKeyW,
_In_ HKEY hKey,
_Out_opt_ LPWSTR lpClass,
_Inout_opt_ LPDWORD lpcClass,
_Reserved_ LPDWORD lpReserved,
_Out_opt_ LPDWORD lpcSubKeys,
_Out_opt_ LPDWORD lpcMaxSubKeyLen,
_Out_opt_ LPDWORD lpcMaxClassLen,
_Out_opt_ LPDWORD lpcValues,
_Out_opt_ LPDWORD lpcMaxValueNameLen,
_Out_opt_ LPDWORD lpcMaxValueLen,
_Out_opt_ LPDWORD lpcbSecurityDescriptor,
_Out_opt_ PFILETIME lpftLastWriteTime
);
extern HOOKDEF(LONG, WINAPI, RegCloseKey,
__in HKEY hKey
);
extern HOOKDEF(LONG, WINAPI, RegNotifyChangeKeyValue,
_In_ HKEY hKey,
_In_ BOOL bWatchSubtree,
_In_ DWORD dwNotifyFilter,
_In_opt_ HANDLE hEvent,
_In_ BOOL fAsynchronous
);
//
// Native Registry Hooks
//
extern HOOKDEF(NTSTATUS, WINAPI, NtCreateKey,
__out PHANDLE KeyHandle,
__in ACCESS_MASK DesiredAccess,
__in POBJECT_ATTRIBUTES ObjectAttributes,
__reserved ULONG TitleIndex,
__in_opt PUNICODE_STRING Class,
__in ULONG CreateOptions,
__out_opt PULONG Disposition
);
extern HOOKDEF(NTSTATUS, WINAPI, NtOpenKey,
__out PHANDLE KeyHandle,
__in ACCESS_MASK DesiredAccess,
__in POBJECT_ATTRIBUTES ObjectAttributes
);
extern HOOKDEF(NTSTATUS, WINAPI, NtOpenKeyEx,
__out PHANDLE KeyHandle,
__in ACCESS_MASK DesiredAccess,
__in POBJECT_ATTRIBUTES ObjectAttributes,
__in ULONG OpenOptions
);
extern HOOKDEF(NTSTATUS, WINAPI, NtRenameKey,
__in HANDLE KeyHandle,
__in PUNICODE_STRING NewName
);
extern HOOKDEF(NTSTATUS, WINAPI, NtReplaceKey,
__in POBJECT_ATTRIBUTES NewHiveFileName,
__in HANDLE KeyHandle,
__in POBJECT_ATTRIBUTES BackupHiveFileName
);
extern HOOKDEF(NTSTATUS, WINAPI, NtEnumerateKey,
__in HANDLE KeyHandle,
__in ULONG Index,
__in KEY_INFORMATION_CLASS KeyInformationClass,
__out_opt PVOID KeyInformation,
__in ULONG Length,
__out PULONG ResultLength
);
extern HOOKDEF(NTSTATUS, WINAPI, NtEnumerateValueKey,
__in HANDLE KeyHandle,
__in ULONG Index,
__in KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
__out_opt PVOID KeyValueInformation,
__in ULONG Length,
__out PULONG ResultLength
);
extern HOOKDEF(NTSTATUS, WINAPI, NtSetValueKey,
__in HANDLE KeyHandle,
__in PUNICODE_STRING ValueName,
__in_opt ULONG TitleIndex,
__in ULONG Type,
__in_opt PVOID Data,
__in ULONG DataSize
);
extern HOOKDEF(NTSTATUS, WINAPI, NtQueryValueKey,
__in HANDLE KeyHandle,
__in PUNICODE_STRING ValueName,
__in KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
__out_opt PVOID KeyValueInformation,
__in ULONG Length,
__out PULONG ResultLength
);
extern HOOKDEF(NTSTATUS, WINAPI, NtQueryMultipleValueKey,
__in HANDLE KeyHandle,
__inout PKEY_VALUE_ENTRY ValueEntries,
__in ULONG EntryCount,
__out PVOID ValueBuffer,
__inout PULONG BufferLength,
__out_opt PULONG RequiredBufferLength
);
extern HOOKDEF(NTSTATUS, WINAPI, NtDeleteKey,
__in HANDLE KeyHandle
);
extern HOOKDEF(NTSTATUS, WINAPI, NtDeleteValueKey,
__in HANDLE KeyHandle,
__in PUNICODE_STRING ValueName
);
extern HOOKDEF(NTSTATUS, WINAPI, NtLoadKey,
__in POBJECT_ATTRIBUTES TargetKey,
__in POBJECT_ATTRIBUTES SourceFile
);
extern HOOKDEF(NTSTATUS, WINAPI, NtLoadKey2,
__in POBJECT_ATTRIBUTES TargetKey,
__in POBJECT_ATTRIBUTES SourceFile,
__in ULONG Flags
);
extern HOOKDEF(NTSTATUS, WINAPI, NtLoadKeyEx,
__in POBJECT_ATTRIBUTES TargetKey,
__in POBJECT_ATTRIBUTES SourceFile,
__in ULONG Flags,
__in_opt HANDLE TrustClassKey
);
extern HOOKDEF(NTSTATUS, WINAPI, NtQueryKey,
__in HANDLE KeyHandle,
__in KEY_INFORMATION_CLASS KeyInformationClass,
__out_opt PVOID KeyInformation,
__in ULONG Length,
__out PULONG ResultLength
);
extern HOOKDEF(NTSTATUS, WINAPI, NtSaveKey,
__in HANDLE KeyHandle,
__in HANDLE FileHandle
);
extern HOOKDEF(NTSTATUS, WINAPI, NtSaveKeyEx,
__in HANDLE KeyHandle,
__in HANDLE FileHandle,
__in ULONG Format
);
//
// Window Hooks
//
extern HOOKDEF_NOTAIL(WINAPI, CreateWindowExA,
__in DWORD dwExStyle,
__in_opt LPCSTR lpClassName,
__in_opt LPCSTR lpWindowName,
__in DWORD dwStyle,
__in int x,
__in int y,
__in int nWidth,
__in int nHeight,
__in_opt HWND hWndParent,
__in_opt HMENU hMenu,
__in_opt HINSTANCE hInstance,
__in_opt LPVOID lpParam
);
extern HOOKDEF_NOTAIL(WINAPI, CreateWindowExW,
__in DWORD dwExStyle,
__in_opt LPWSTR lpClassName,
__in_opt LPWSTR lpWindowName,
__in DWORD dwStyle,
__in int x,
__in int y,
__in int nWidth,
__in int nHeight,
__in_opt HWND hWndParent,
__in_opt HMENU hMenu,
__in_opt HINSTANCE hInstance,
__in_opt LPVOID lpParam
);
extern HOOKDEF(HWND, WINAPI, FindWindowA,
__in_opt LPCTSTR lpClassName,
__in_opt LPCTSTR lpWindowName
);
extern HOOKDEF(HWND, WINAPI, FindWindowW,
__in_opt LPWSTR lpClassName,
__in_opt LPWSTR lpWindowName
);
extern HOOKDEF(HWND, WINAPI, FindWindowExA,
__in_opt HWND hwndParent,
__in_opt HWND hwndChildAfter,
__in_opt LPCTSTR lpszClass,
__in_opt LPCTSTR lpszWindow
);
extern HOOKDEF(HWND, WINAPI, FindWindowExW,
__in_opt HWND hwndParent,
__in_opt HWND hwndChildAfter,
__in_opt LPWSTR lpszClass,
__in_opt LPWSTR lpszWindow
);
extern HOOKDEF(BOOL, WINAPI, EnumWindows,
_In_ WNDENUMPROC lpEnumFunc,
_In_ LPARAM lParam
);
extern HOOKDEF(BOOL, WINAPI, SendNotifyMessageA,
_In_ HWND hWnd,
_In_ UINT Msg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
extern HOOKDEF(BOOL, WINAPI, SendNotifyMessageW,
_In_ HWND hWnd,
_In_ UINT Msg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
extern HOOKDEF(LONG, WINAPI, SetWindowLongA,
_In_ HWND hWnd,
_In_ int nIndex,
_In_ LONG dwNewLong
);
extern HOOKDEF(LONG_PTR, WINAPI, SetWindowLongPtrA,
_In_ HWND hWnd,
_In_ int nIndex,
_In_ LONG_PTR dwNewLong
);
extern HOOKDEF(LONG, WINAPI, SetWindowLongW,
_In_ HWND hWnd,
_In_ int nIndex,
_In_ LONG dwNewLong
);
extern HOOKDEF(LONG_PTR, WINAPI, SetWindowLongPtrW,
_In_ HWND hWnd,
_In_ int nIndex,
_In_ LONG_PTR dwNewLong
);
//
// Sync Hooks
//
extern HOOKDEF(NTSTATUS, WINAPI, NtCreateMutant,
__out PHANDLE MutantHandle,
__in ACCESS_MASK DesiredAccess,
__in_opt POBJECT_ATTRIBUTES ObjectAttributes,
__in BOOLEAN InitialOwner
);
extern HOOKDEF(NTSTATUS, WINAPI, NtOpenMutant,
__out PHANDLE MutantHandle,
__in ACCESS_MASK DesiredAccess,
__in POBJECT_ATTRIBUTES ObjectAttributes
);
extern HOOKDEF(NTSTATUS, WINAPI, NtCreateEvent,
__out PHANDLE EventHandle,
__in ACCESS_MASK DesiredAccess,
__in_opt POBJECT_ATTRIBUTES ObjectAttributes,
__in DWORD EventType,
__in BOOLEAN InitialState
);
extern HOOKDEF(NTSTATUS, WINAPI, NtOpenEvent,
__out PHANDLE EventHandle,
__in ACCESS_MASK DesiredAccess,
__in POBJECT_ATTRIBUTES ObjectAttributes
);
extern HOOKDEF(NTSTATUS, WINAPI, NtCreateNamedPipeFile,
OUT PHANDLE NamedPipeFileHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG ShareAccess,
IN ULONG CreateDisposition,
IN ULONG CreateOptions,
IN BOOLEAN WriteModeMessage,
IN BOOLEAN ReadModeMessage,
IN BOOLEAN NonBlocking,
IN ULONG MaxInstances,
IN ULONG InBufferSize,
IN ULONG OutBufferSize,
IN PLARGE_INTEGER DefaultTimeOut
);
extern HOOKDEF(NTSTATUS, WINAPI, NtAddAtom,
IN PWCHAR AtomName,
IN ULONG AtomNameLength,
OUT PRTL_ATOM Atom
);
extern HOOKDEF(NTSTATUS, WINAPI, NtDeleteAtom,
IN RTL_ATOM Atom
);
extern HOOKDEF(NTSTATUS, WINAPI, NtFindAtom,
IN PWCHAR AtomName,
IN ULONG AtomNameLength,
OUT PRTL_ATOM Atom OPTIONAL
);
extern HOOKDEF(NTSTATUS, WINAPI, NtAddAtomEx,
IN PWCHAR AtomName,
IN ULONG AtomNameLength,
OUT PRTL_ATOM Atom,
IN PVOID Unknown
);
//
// Process Hooks
//
extern HOOKDEF(HANDLE, WINAPI, CreateToolhelp32Snapshot,
__in DWORD dwFlags,
__in DWORD th32ProcessID
);
extern HOOKDEF(BOOL, WINAPI, Process32FirstW,
__in HANDLE hSnapshot,
__out LPPROCESSENTRY32W lppe
);
extern HOOKDEF(BOOL, WINAPI, Process32NextW,
__in HANDLE hSnapshot,
__out LPPROCESSENTRY32W lppe
);
extern HOOKDEF(NTSTATUS, WINAPI, NtCreateProcess,
__out PHANDLE ProcessHandle,
__in ACCESS_MASK DesiredAccess,
__in_opt POBJECT_ATTRIBUTES ObjectAttributes,
__in HANDLE ParentProcess,
__in BOOLEAN InheritObjectTable,
__in_opt HANDLE SectionHandle,
__in_opt HANDLE DebugPort,
__in_opt HANDLE ExceptionPort
);
extern HOOKDEF(NTSTATUS, WINAPI, NtCreateProcessEx,
__out PHANDLE ProcessHandle,
__in ACCESS_MASK DesiredAccess,
__in_opt POBJECT_ATTRIBUTES ObjectAttributes,
__in HANDLE ParentProcess,
__in ULONG Flags,
__in_opt HANDLE SectionHandle,
__in_opt HANDLE DebugPort,
__in_opt HANDLE ExceptionPort,
__in BOOLEAN InJob
);
extern HOOKDEF(NTSTATUS, WINAPI, NtCreateUserProcess,
__out PHANDLE ProcessHandle,
__out PHANDLE ThreadHandle,
__in ACCESS_MASK ProcessDesiredAccess,
__in ACCESS_MASK ThreadDesiredAccess,
__in_opt POBJECT_ATTRIBUTES ProcessObjectAttributes,
__in_opt POBJECT_ATTRIBUTES ThreadObjectAttributes,
__in ULONG ProcessFlags,
__in ULONG ThreadFlags,
__in_opt PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
__inout PPS_CREATE_INFO CreateInfo,
__in_opt PPS_ATTRIBUTE_LIST AttributeList
);
extern HOOKDEF(NTSTATUS, WINAPI, RtlCreateUserProcess,
IN PUNICODE_STRING ImagePath,
IN ULONG ObjectAttributes,
IN OUT PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
IN PSECURITY_DESCRIPTOR ProcessSecurityDescriptor OPTIONAL,
IN PSECURITY_DESCRIPTOR ThreadSecurityDescriptor OPTIONAL,
IN HANDLE ParentProcess,
IN BOOLEAN InheritHandles,
IN HANDLE DebugPort OPTIONAL,
IN HANDLE ExceptionPort OPTIONAL,
OUT PRTL_USER_PROCESS_INFORMATION ProcessInformation
);
extern HOOKDEF(NTSTATUS, WINAPI, NtOpenProcess,
__out PHANDLE ProcessHandle,
__in ACCESS_MASK DesiredAccess,
__in POBJECT_ATTRIBUTES ObjectAttributes,
__in_opt PCLIENT_ID ClientId
);
extern HOOKDEF(NTSTATUS, WINAPI, NtTerminateProcess,
__in_opt HANDLE ProcessHandle,
__in NTSTATUS ExitStatus
);
extern HOOKDEF(NTSTATUS, WINAPI, NtResumeProcess,
__in HANDLE ProcessHandle
);
extern HOOKDEF(NTSTATUS, WINAPI, NtCreateSection,
__out PHANDLE SectionHandle,
__in ACCESS_MASK DesiredAccess,
__in_opt POBJECT_ATTRIBUTES ObjectAttributes,
__in_opt PLARGE_INTEGER MaximumSize,
__in ULONG SectionPageProtection,
__in ULONG AllocationAttributes,
__in_opt HANDLE FileHandle
);
extern HOOKDEF(NTSTATUS, WINAPI, NtDuplicateObject,
__in HANDLE SourceProcessHandle,
__in HANDLE SourceHandle,
__in_opt HANDLE TargetProcessHandle,
__out_opt PHANDLE TargetHandle,
__in ACCESS_MASK DesiredAccess,
__in ULONG HandleAttributes,
__in ULONG Options
);
extern HOOKDEF(NTSTATUS, WINAPI, NtMakeTemporaryObject,
__in HANDLE ObjectHandle
);
extern HOOKDEF(NTSTATUS, WINAPI, NtMakePermanentObject,
__in HANDLE ObjectHandle
);
extern HOOKDEF(NTSTATUS, WINAPI, NtOpenSection,
__out PHANDLE SectionHandle,
__in ACCESS_MASK DesiredAccess,
__in POBJECT_ATTRIBUTES ObjectAttributes
);
extern HOOKDEF(BOOL, WINAPI, CreateProcessInternalW,
__in_opt LPVOID lpUnknown1,
__in_opt LPWSTR lpApplicationName,
__inout_opt LPWSTR lpCommandLine,
__in_opt LPSECURITY_ATTRIBUTES lpProcessAttributes,
__in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes,
__in BOOL bInheritHandles,
__in DWORD dwCreationFlags,
__in_opt LPVOID lpEnvironment,
__in_opt LPWSTR lpCurrentDirectory,
__in LPSTARTUPINFO lpStartupInfo,
__out LPPROCESS_INFORMATION lpProcessInformation,
__in_opt LPVOID lpUnknown2
);
extern HOOKDEF(BOOL, WINAPI, WaitForDebugEvent,
__out LPDEBUG_EVENT lpDebugEvent,
__in DWORD dwMilliseconds
);
extern HOOKDEF(NTSTATUS, WINAPI, DbgUiWaitStateChange,
__out PDBGUI_WAIT_STATE_CHANGE StateChange,
__in_opt PLARGE_INTEGER Timeout
);
extern HOOKDEF_NOTAIL(WINAPI, RtlDispatchException,
__in PEXCEPTION_RECORD ExceptionRecord,
__in PCONTEXT Context
);