-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathprecomp.h
180 lines (139 loc) · 3.51 KB
/
precomp.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
/**
* PROJECT: Native Shell
* COPYRIGHT: LGPL; See LICENSE in the top level directory
* FILE: precomp.h
* DESCRIPTION: Precompiled header.
* DEVELOPERS: See CONTRIBUTORS.md in the top level directory
*/
#define WIN32_NO_STATUS
#define NTOS_MODE_USER
#include <stdio.h>
#include <stdarg.h>
#include <excpt.h>
#include <windef.h>
#include <winnt.h>
#include <ntndk.h>
#include <ntddkbd.h>
#include <sdkddkver.h>
#include "ntfile.h"
#include "ntreg.h"
// Device type for input/output
typedef enum _CON_DEVICE_TYPE
{
KeyboardType,
MouseType
} CON_DEVICE_TYPE;
// Display functions
NTSTATUS
__cdecl RtlCliDisplayString(
IN PCH Message,
...);
NTSTATUS
RtlCliPrintString(
IN PUNICODE_STRING Message);
NTSTATUS
RtlCliPutChar(
IN WCHAR Char);
// Input functions
NTSTATUS
RtlCliOpenInputDevice(
OUT PHANDLE Handle,
IN CON_DEVICE_TYPE Type);
CHAR RtlCliGetChar(
IN HANDLE hDriver);
PCHAR
RtlCliGetLine(
IN HANDLE hDriver);
// System information functions
NTSTATUS
RtlCliListDrivers(
VOID);
NTSTATUS
RtlCliListProcesses(
VOID);
NTSTATUS
RtlCliDumpSysInfo(
VOID);
NTSTATUS
RtlCliShutdown(
VOID);
NTSTATUS
RtlCliReboot(
VOID);
NTSTATUS
RtlCliPowerOff(
VOID);
// Hardware functions
NTSTATUS
RtlCliListHardwareTree(
VOID);
// File functions
NTSTATUS
RtlCliListDirectory(
PWCHAR CurrentDirectory);
NTSTATUS
RtlCliSetCurrentDirectory(
PCHAR Directory);
ULONG
RtlCliGetCurrentDirectory(
IN OUT PWSTR CurrentDirectory);
// Keyboard:
HANDLE hKeyboard;
typedef struct _KBD_RECORD
{
WORD wVirtualScanCode;
DWORD dwControlKeyState;
UCHAR AsciiChar;
BOOL bKeyDown;
} KBD_RECORD, *PKBD_RECORD;
void IntTranslateKey(PKEYBOARD_INPUT_DATA InputData, KBD_RECORD *kbd_rec);
#define RIGHT_ALT_PRESSED 0x0001 // the right alt key is pressed.
#define LEFT_ALT_PRESSED 0x0002 // the left alt key is pressed.
#define RIGHT_CTRL_PRESSED 0x0004 // the right ctrl key is pressed.
#define LEFT_CTRL_PRESSED 0x0008 // the left ctrl key is pressed.
#define SHIFT_PRESSED 0x0010 // the shift key is pressed.
#define NUMLOCK_ON 0x0020 // the numlock light is on.
#define SCROLLLOCK_ON 0x0040 // the scrolllock light is on.
#define CAPSLOCK_ON 0x0080 // the capslock light is on.
#define ENHANCED_KEY 0x0100 // the key is enhanced.
// Process:
NTSTATUS CreateNativeProcess(IN PCWSTR file_name, IN PCWSTR cmd_line, OUT PHANDLE hProcess);
#define BUFFER_SIZE 1024
#define NUM_ARGS 256
// Command processing:
#define CMDSTR(x) x, strlen(x)
CHAR **StringToArguments(CHAR *string, UINT *argc);
BOOL GetFullPath(IN PCSTR filename, OUT PWSTR out, IN BOOL add_slash);
BOOL FileExists(PCWSTR fname);
// Registry
NTSTATUS OpenKey(OUT PHANDLE pHandle, IN PWCHAR key);
NTSTATUS RegWrite(HANDLE hKey, INT type, PWCHAR key_name, PVOID data, DWORD size);
NTSTATUS RegReadValue(HANDLE hKey, PWCHAR key_name, OUT PULONG type, OUT PVOID data, IN ULONG buf_size, OUT PULONG out_size);
//===========================================================
// Helper Functions for ntreg.c
//===========================================================
BOOLEAN SetUnicodeString(
UNICODE_STRING *pustrRet,
WCHAR *pwszData);
BOOLEAN
DisplayString(
WCHAR *pwszData);
HANDLE
InitHeapMemory(void);
BOOLEAN
DeinitHeapMemory(
HANDLE hHeap);
PVOID
kmalloc(
HANDLE hHeap,
int nSize);
BOOLEAN
kfree(
HANDLE hHeap,
PVOID pMemory);
BOOLEAN
AppendString(
WCHAR *pszInput,
WCHAR *pszAppend);
UINT GetStringLength(
WCHAR *pszInput);