-
Notifications
You must be signed in to change notification settings - Fork 0
/
win_defines.py
73 lines (64 loc) · 2.01 KB
/
win_defines.py
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
from ctypes import *
from ctypes.wintypes import *
# map wintypes
SBYTE = c_byte
SWORD = c_int16
SDWORD = c_int32
QWORD = c_uint64
SQWORD = c_int64
LPBYTE = POINTER(c_ubyte)
LPDWORD = POINTER(DWORD)
LPTSTR = POINTER(c_char)
# Map size_t to SIZE_T
try:
SIZE_T = c_size_t
SSIZE_T = c_ssize_t
except AttributeError:
# Size of a pointer
SIZE_T = {1:BYTE, 2:WORD, 4:DWORD, 8:QWORD}[sizeof(LPVOID)]
SSIZE_T = {1:SBYTE, 2:SWORD, 4:SDWORD, 8:SQWORD}[sizeof(LPVOID)]
PAGE_EXECUTE_READWRITE = 0x00000040
PAGE_READWRITE = 0x04
PROCESS_ALL_ACCESS = ( 0x000F0000 | 0x00100000 | 0xFFF )
VIRTUAL_MEM = ( 0x1000 | 0x2000 )
CREATE_NEW_CONSOLE = 0x00000010
class SECURITY_ATTRIBUTES(Structure):
_fields_ = [
('nLength', DWORD),
('lpSecurityDescriptor', LPVOID),
('bInheritHandle', BOOL),
]
LPSECURITY_ATTRIBUTES = POINTER(SECURITY_ATTRIBUTES)
# Structures for CreateProcessA() function
# STARTUPINFO describes how to spawn the process
class STARTUPINFO(Structure):
_fields_ = [
("cb", DWORD),
("lpReserved", LPTSTR),
("lpDesktop", LPTSTR),
("lpTitle", LPTSTR),
("dwX", DWORD),
("dwY", DWORD),
("dwXSize", DWORD),
("dwYSize", DWORD),
("dwXCountChars", DWORD),
("dwYCountChars", DWORD),
("dwFillAttribute",DWORD),
("dwFlags", DWORD),
("wShowWindow", WORD),
("cbReserved2", WORD),
("lpReserved2", LPBYTE),
("hStdInput", HANDLE),
("hStdOutput", HANDLE),
("hStdError", HANDLE),
]
# PROCESS_INFORMATION receives its information
# after the target process has been successfully
# started.
class PROCESS_INFORMATION(Structure):
_fields_ = [
("hProcess", HANDLE),
("hThread", HANDLE),
("dwProcessId", DWORD),
("dwThreadId", DWORD),
]