| 1 |
""" |
| 2 |
Support routines for subprocess and multiprocess module. |
| 3 |
Currently, this extension module is only required when using the |
| 4 |
modules on Windows. |
| 5 |
""" |
| 6 |
|
| 7 |
import sys |
| 8 |
|
| 9 |
if sys.platform != 'win32': |
| 10 |
raise ModuleNotFoundError("The '_winapi' module is only available on Windows", name="_winapi") |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
if sys.maxsize > 2 ** 31: |
| 15 |
from _pypy_winbase_cffi64 import ffi as _ffi |
| 16 |
else: |
| 17 |
from _pypy_winbase_cffi import ffi as _ffi |
| 18 |
_kernel32 = _ffi.dlopen('kernel32') |
| 19 |
|
| 20 |
GetVersion = _kernel32.GetVersion |
| 21 |
NULL = _ffi.NULL |
| 22 |
|
| 23 |
def SetLastError(errno): |
| 24 |
return _kernel32.SetLastError(errno) |
| 25 |
|
| 26 |
def GetLastError(): |
| 27 |
return _kernel32.GetLastError() |
| 28 |
|
| 29 |
def GetACP(): |
| 30 |
return _kernel32.GetACP() |
| 31 |
|
| 32 |
|
| 33 |
def raise_WinError(type=WindowsError): |
| 34 |
code, message = _ffi.getwinerror() |
| 35 |
excep = type(None, message, None ,code) |
| 36 |
raise excep |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
def RaiseFromWindowsErr(err): |
| 41 |
if err == 0: |
| 42 |
err = _kernel32.GetLastError() |
| 43 |
|
| 44 |
if err == ERROR_CONNECTION_REFUSED: |
| 45 |
type = ConnectionRefusedError |
| 46 |
elif err == ERROR_CONNECTION_ABORTED: |
| 47 |
type = ConnectionAbortedError |
| 48 |
else: |
| 49 |
type = WindowsError |
| 50 |
|
| 51 |
raise_WinError(type) |
| 52 |
|
| 53 |
def _int2handle(val): |
| 54 |
return _ffi.cast("HANDLE", val) |
| 55 |
|
| 56 |
def _handle2int(handle): |
| 57 |
return int(_ffi.cast("intptr_t", handle)) |
| 58 |
|
| 59 |
def CreatePipe(attributes, size): |
| 60 |
handles = _ffi.new("HANDLE[2]") |
| 61 |
|
| 62 |
res = _kernel32.CreatePipe(handles, handles + 1, NULL, size) |
| 63 |
|
| 64 |
if not res: |
| 65 |
RaiseFromWindowsErr(GetLastError()) |
| 66 |
|
| 67 |
return _handle2int(handles[0]), _handle2int(handles[1]) |
| 68 |
|
| 69 |
def CreateNamedPipe(*args): |
| 70 |
handle = _kernel32.CreateNamedPipeW(*args) |
| 71 |
if handle == INVALID_HANDLE_VALUE: |
| 72 |
RaiseFromWindowsErr(0) |
| 73 |
return _handle2int(handle) |
| 74 |
|
| 75 |
def CreateFile(*args): |
| 76 |
handle = _kernel32.CreateFileW(*args) |
| 77 |
if handle == INVALID_HANDLE_VALUE: |
| 78 |
RaiseFromWindowsErr(0) |
| 79 |
return _handle2int(handle) |
| 80 |
|
| 81 |
def SetNamedPipeHandleState(namedpipe, mode, max_collection_count, collect_data_timeout): |
| 82 |
d0 = _ffi.new('DWORD[1]', [mode]) |
| 83 |
if max_collection_count is None: |
| 84 |
d1 = NULL |
| 85 |
else: |
| 86 |
d1 = _ffi.new('DWORD[1]', [max_collection_count]) |
| 87 |
if collect_data_timeout is None: |
| 88 |
d2 = NULL |
| 89 |
else: |
| 90 |
d2 = _ffi.new('DWORD[1]', [collect_data_timeout]) |
| 91 |
ret = _kernel32.SetNamedPipeHandleState(_int2handle(namedpipe), d0, d1, d2) |
| 92 |
if not ret: |
| 93 |
raise_WinError() |
| 94 |
|
| 95 |
class Overlapped(object): |
| 96 |
def __init__(self, handle): |
| 97 |
self.overlapped = _ffi.new('OVERLAPPED[1]') |
| 98 |
self.handle = _handle2int(handle) |
| 99 |
self.readbuffer = None |
| 100 |
self.pending = 0 |
| 101 |
self.completed = 0 |
| 102 |
self.writebuffer = None |
| 103 |
self.overlapped[0].hEvent = \ |
| 104 |
_kernel32.CreateEventW(NULL, True, False, NULL) |
| 105 |
if not self.overlapped[0].hEvent: |
| 106 |
raise_WinError(IOError) |
| 107 |
def __del__(self): |
| 108 |
|
| 109 |
err = _kernel32.GetLastError() |
| 110 |
bytes = _ffi.new('DWORD[1]') |
| 111 |
if self.pending: |
| 112 |
result = _kernel32.CancelIoEx(_int2handle(self.handle), self.overlapped) |
| 113 |
if result: |
| 114 |
_kernel32.GetOverlappedResult(_int2handle(self.handle), self.overlapped, bytes, True) |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
CloseHandle(_int2handle(self.overlapped[0].hEvent)) |
| 121 |
_kernel32.SetLastError(err) |
| 122 |
|
| 123 |
@property |
| 124 |
def event(self): |
| 125 |
return _handle2int(self.overlapped[0].hEvent) |
| 126 |
|
| 127 |
def GetOverlappedResult(self, wait): |
| 128 |
transferred = _ffi.new('DWORD[1]', [0]) |
| 129 |
res = _kernel32.GetOverlappedResult(_int2handle(self.handle), self.overlapped, transferred, wait != 0) |
| 130 |
|
| 131 |
if res: |
| 132 |
err = ERROR_SUCCESS |
| 133 |
else: |
| 134 |
err = _kernel32.GetLastError() |
| 135 |
|
| 136 |
if err in (ERROR_SUCCESS, ERROR_MORE_DATA, ERROR_OPERATION_ABORTED): |
| 137 |
self.completed = 1 |
| 138 |
self.pending = 0 |
| 139 |
elif res != ERROR_IO_INCOMPLETE: |
| 140 |
self.pending = 0 |
| 141 |
|
| 142 |
raise_WinError(IOError) |
| 143 |
|
| 144 |
if self.completed and self.readbuffer: |
| 145 |
if transferred[0] != len(self.readbuffer): |
| 146 |
tempbuffer = _ffi.new("CHAR[]", transferred[0]) |
| 147 |
_ffi.memmove(tempbuffer, self.readbuffer, transferred[0]) |
| 148 |
self.readbuffer = tempbuffer |
| 149 |
return transferred[0], err |
| 150 |
|
| 151 |
def getbuffer(self): |
| 152 |
if not self.completed: |
| 153 |
raise ValueError("can't get read buffer before GetOverlappedResult() " |
| 154 |
"signals the operation completed") |
| 155 |
if self.readbuffer: |
| 156 |
result = bytes(_ffi.buffer(self.readbuffer)) |
| 157 |
else: |
| 158 |
result = None |
| 159 |
return result |
| 160 |
|
| 161 |
def cancel(self): |
| 162 |
ret = True |
| 163 |
if self.pending: |
| 164 |
ret = _kernel32.CancelIoEx(_int2handle(self.handle), self.overlapped) |
| 165 |
if not ret and _kernel32.GetLastError() != ERROR_NOT_FOUND: |
| 166 |
raise_WinError(IOError) |
| 167 |
self.pending = 0 |
| 168 |
return None |
| 169 |
|
| 170 |
|
| 171 |
def ReadFile(handle, size, overlapped): |
| 172 |
nread = _ffi.new("DWORD*") |
| 173 |
use_overlapped = overlapped |
| 174 |
|
| 175 |
buf = _ffi.new("CHAR[]", size) |
| 176 |
if not buf: |
| 177 |
raise_WinError(IOError) |
| 178 |
err = 0 |
| 179 |
if use_overlapped: |
| 180 |
overlapped = Overlapped(handle) |
| 181 |
overlapped.readbuffer = buf |
| 182 |
ret = _kernel32.ReadFile(_int2handle(handle), buf, size, nread, |
| 183 |
overlapped.overlapped) |
| 184 |
if not ret: |
| 185 |
err = _kernel32.GetLastError() |
| 186 |
if err == ERROR_IO_PENDING: |
| 187 |
overlapped.pending = 1 |
| 188 |
elif err != ERROR_MORE_DATA: |
| 189 |
raise_WinError(IOError) |
| 190 |
return overlapped, err |
| 191 |
else: |
| 192 |
ret = _kernel32.ReadFile(_int2handle(handle), buf, size, nread, |
| 193 |
_ffi.NULL) |
| 194 |
|
| 195 |
if not ret: |
| 196 |
err = _kernel32.GetLastError() |
| 197 |
if err != ERROR_MORE_DATA: |
| 198 |
raise_WinError(IOError) |
| 199 |
return nread[0], err |
| 200 |
|
| 201 |
def WriteFile(handle, buffer, overlapped=False): |
| 202 |
written = _ffi.new("DWORD*") |
| 203 |
use_overlapped = overlapped |
| 204 |
overlapped = None |
| 205 |
err = 0 |
| 206 |
if use_overlapped: |
| 207 |
overlapped = Overlapped(handle) |
| 208 |
if not overlapped: |
| 209 |
return _ffi.NULL |
| 210 |
overlapped.writebuffer = bytes(buffer) |
| 211 |
buf = overlapped.writebuffer |
| 212 |
ret = _kernel32.WriteFile(_int2handle(handle), buf , len(buf), written, overlapped.overlapped) |
| 213 |
if not ret: |
| 214 |
err = _kernel32.GetLastError() |
| 215 |
if err == ERROR_IO_PENDING: |
| 216 |
overlapped.pending = 1 |
| 217 |
else: |
| 218 |
raise_WinError(IOError) |
| 219 |
return overlapped, err |
| 220 |
else: |
| 221 |
buf = _ffi.new("CHAR[]", bytes(buffer)) |
| 222 |
ret = _kernel32.WriteFile(_int2handle(handle), buf , len(buf), written, _ffi.NULL) |
| 223 |
if not ret: |
| 224 |
raise_WinError(IOError) |
| 225 |
return written[0], err |
| 226 |
|
| 227 |
|
| 228 |
def ConnectNamedPipe(handle, overlapped=False): |
| 229 |
handle = _int2handle(handle) |
| 230 |
if overlapped: |
| 231 |
ov = Overlapped(handle) |
| 232 |
else: |
| 233 |
ov = Overlapped(None) |
| 234 |
success = _kernel32.ConnectNamedPipe(handle, ov.overlapped) |
| 235 |
if overlapped: |
| 236 |
|
| 237 |
assert success == 0 |
| 238 |
err = _kernel32.GetLastError() |
| 239 |
if err == ERROR_IO_PENDING: |
| 240 |
ov.pending = 1 |
| 241 |
elif err == ERROR_PIPE_CONNECTED: |
| 242 |
_kernel32.SetEvent(ov.overlapped[0].hEvent) |
| 243 |
else: |
| 244 |
del ov |
| 245 |
RaiseFromWindowsErr(err) |
| 246 |
return ov |
| 247 |
elif not success: |
| 248 |
RaiseFromWindowsErr(0) |
| 249 |
|
| 250 |
def GetCurrentProcess(): |
| 251 |
return _handle2int(_kernel32.GetCurrentProcess()) |
| 252 |
|
| 253 |
def DuplicateHandle(source_process, source, target_process, access, inherit, options=0): |
| 254 |
|
| 255 |
target = _ffi.new("HANDLE[1]") |
| 256 |
|
| 257 |
res = _kernel32.DuplicateHandle( |
| 258 |
_int2handle(source_process), |
| 259 |
_int2handle(source), |
| 260 |
_int2handle(target_process), |
| 261 |
target, access, inherit, options) |
| 262 |
|
| 263 |
if not res: |
| 264 |
raise_WinError() |
| 265 |
|
| 266 |
return _handle2int(target[0]) |
| 267 |
|
| 268 |
def _Z(input): |
| 269 |
if input is None: |
| 270 |
return _ffi.NULL |
| 271 |
if isinstance(input, str): |
| 272 |
return input |
| 273 |
raise TypeError("str or None expected, got %r" % ( |
| 274 |
type(input).__name__,)) |
| 275 |
|
| 276 |
def CreateProcess(name, command_line, process_attr, thread_attr, |
| 277 |
inherit, flags, env, start_dir, startup_info): |
| 278 |
si = _ffi.new("STARTUPINFO *") |
| 279 |
if startup_info is not None: |
| 280 |
si.dwFlags = startup_info.dwFlags |
| 281 |
si.wShowWindow = startup_info.wShowWindow |
| 282 |
|
| 283 |
|
| 284 |
if startup_info.hStdInput: |
| 285 |
si.hStdInput = _int2handle(startup_info.hStdInput) |
| 286 |
if startup_info.hStdOutput: |
| 287 |
si.hStdOutput = _int2handle(startup_info.hStdOutput) |
| 288 |
if startup_info.hStdError: |
| 289 |
si.hStdError = _int2handle(startup_info.hStdError) |
| 290 |
|
| 291 |
pi = _ffi.new("PROCESS_INFORMATION *") |
| 292 |
flags |= CREATE_UNICODE_ENVIRONMENT |
| 293 |
|
| 294 |
if env is not None: |
| 295 |
envbuf = "" |
| 296 |
for k, v in env.items(): |
| 297 |
envbuf += "%s=%s\0" % (k, v) |
| 298 |
envbuf += '\0' |
| 299 |
else: |
| 300 |
envbuf = _ffi.NULL |
| 301 |
|
| 302 |
res = _kernel32.CreateProcessW(_Z(name), _Z(command_line), _ffi.NULL, |
| 303 |
_ffi.NULL, inherit, flags, envbuf, |
| 304 |
_Z(start_dir), si, pi) |
| 305 |
|
| 306 |
if not res: |
| 307 |
raise_WinError() |
| 308 |
|
| 309 |
return (_handle2int(pi.hProcess), |
| 310 |
_handle2int(pi.hThread), |
| 311 |
pi.dwProcessId, |
| 312 |
pi.dwThreadId) |
| 313 |
|
| 314 |
def OpenProcess(desired_access, inherit_handle, process_id): |
| 315 |
handle = _kernel32.OpenProcess(desired_access, inherit_handle, process_id) |
| 316 |
if handle == _ffi.NULL: |
| 317 |
RaiseFromWindowsErr(0) |
| 318 |
handle = INVALID_HANDLE_VALUE |
| 319 |
|
| 320 |
return _handle2int(handle) |
| 321 |
|
| 322 |
def PeekNamedPipe(handle, size=0): |
| 323 |
nread = _ffi.new("DWORD*") |
| 324 |
navail = _ffi.new("DWORD*") |
| 325 |
nleft = _ffi.new("DWORD*") |
| 326 |
|
| 327 |
if size < 0: |
| 328 |
raise ValueError("negative size") |
| 329 |
|
| 330 |
if size: |
| 331 |
buf = _ffi.new("CHAR[]", size) |
| 332 |
if not buf: |
| 333 |
return _ffi.NULL |
| 334 |
|
| 335 |
ret = _kernel32.PeekNamedPipe(_int2handle(handle), buf, size, nread, |
| 336 |
navail, nleft) |
| 337 |
if not ret: |
| 338 |
|
| 339 |
|
| 340 |
RaiseFromWindowsErr(0) |
| 341 |
|
| 342 |
|
| 343 |
return buf, navail[0], nleft[0] |
| 344 |
else: |
| 345 |
ret = _kernel32.PeekNamedPipe(_int2handle(handle), _ffi.NULL, 0, _ffi.NULL, navail, nleft) |
| 346 |
if not ret: |
| 347 |
|
| 348 |
|
| 349 |
RaiseFromWindowsErr(0) |
| 350 |
return navail[0], nleft[0] |
| 351 |
|
| 352 |
def WaitForSingleObject(handleI, milliseconds): |
| 353 |
|
| 354 |
if handleI < 0: |
| 355 |
SetLastError(ERROR_INVALID_HANDLE) |
| 356 |
raise_WinError() |
| 357 |
handle = _int2handle(handleI) |
| 358 |
if milliseconds < 0: |
| 359 |
milliseconds = INFINITE |
| 360 |
res = _kernel32.WaitForSingleObject(handle, milliseconds) |
| 361 |
if res == WAIT_FAILED: |
| 362 |
raise_WinError() |
| 363 |
return int(res) |
| 364 |
|
| 365 |
|
| 366 |
def WaitNamedPipe(namedpipe, milliseconds): |
| 367 |
namedpipe = _ffi.new("CHAR[]", namedpipe.encode("ascii", "ignore")) |
| 368 |
res = _kernel32.WaitNamedPipeA(namedpipe, milliseconds) |
| 369 |
|
| 370 |
if res < 0: |
| 371 |
raise RaiseFromWindowsErr(0) |
| 372 |
|
| 373 |
|
| 374 |
def WaitForMultipleObjects(handle_sequence, waitflag, milliseconds): |
| 375 |
if len(handle_sequence) > MAXIMUM_WAIT_OBJECTS: |
| 376 |
return None |
| 377 |
handle_sequence = list(map(_int2handle, handle_sequence)) |
| 378 |
handle_sequence = _ffi.new("HANDLE[]", handle_sequence) |
| 379 |
|
| 380 |
res = _kernel32.WaitForMultipleObjects(len(handle_sequence), handle_sequence, waitflag, milliseconds) |
| 381 |
|
| 382 |
if res == WAIT_FAILED: |
| 383 |
raise_WinError() |
| 384 |
return int(res) |
| 385 |
|
| 386 |
|
| 387 |
def GetExitCodeProcess(handle): |
| 388 |
|
| 389 |
code = _ffi.new("DWORD[1]") |
| 390 |
|
| 391 |
res = _kernel32.GetExitCodeProcess(_int2handle(handle), code) |
| 392 |
|
| 393 |
if not res: |
| 394 |
raise_WinError() |
| 395 |
|
| 396 |
return code[0] |
| 397 |
|
| 398 |
def TerminateProcess(handle, exitcode): |
| 399 |
|
| 400 |
|
| 401 |
res = _kernel32.TerminateProcess(_int2handle(handle), |
| 402 |
_ffi.cast("UINT", exitcode)) |
| 403 |
|
| 404 |
if not res: |
| 405 |
raise_WinError() |
| 406 |
|
| 407 |
def GetStdHandle(stdhandle): |
| 408 |
stdhandle = _ffi.cast("DWORD", stdhandle) |
| 409 |
res = _kernel32.GetStdHandle(stdhandle) |
| 410 |
|
| 411 |
if not res: |
| 412 |
return None |
| 413 |
else: |
| 414 |
return _handle2int(res) |
| 415 |
|
| 416 |
def CloseHandle(handle): |
| 417 |
res = _kernel32.CloseHandle(_int2handle(handle)) |
| 418 |
|
| 419 |
if not res: |
| 420 |
raise_WinError() |
| 421 |
|
| 422 |
def GetFileType(handle): |
| 423 |
res = _kernel32.GetFileType(_int2handle(handle)) |
| 424 |
|
| 425 |
if res == FILE_TYPE_UNKNOWN and GetLastError() != 0: |
| 426 |
raise_WinError() |
| 427 |
return res |
| 428 |
|
| 429 |
def GetModuleFileName(module): |
| 430 |
buf = _ffi.new("wchar_t[]", _MAX_PATH) |
| 431 |
res = _kernel32.GetModuleFileNameW(_int2handle(module), buf, _MAX_PATH) |
| 432 |
|
| 433 |
if not res: |
| 434 |
raise_WinError() |
| 435 |
return _ffi.string(buf) |
| 436 |
|
| 437 |
def ExitProcess(exitcode): |
| 438 |
_kernel32.ExitProcess(exitcode) |
| 439 |
|
| 440 |
ZERO_MEMORY = 0x00000008 |
| 441 |
|
| 442 |
def malloc(size): |
| 443 |
return _kernel32.HeapAlloc(_kernel32.GetProcessHeap(),ZERO_MEMORY,size) |
| 444 |
|
| 445 |
def free(voidptr): |
| 446 |
_kernel32.HeapFree(_kernel32.GetProcessHeap(),0, voidptr) |
| 447 |
|
| 448 |
def CreateFileMapping(*args): |
| 449 |
handle = _kernel32.CreateFileMappingW(*args) |
| 450 |
if handle == INVALID_HANDLE_VALUE: |
| 451 |
RaiseFromWindowsErr(0) |
| 452 |
return _handle2int(handle) |
| 453 |
|
| 454 |
def OpenFileMapping(*args): |
| 455 |
handle = _kernel32.OpenFileMappingW(*args) |
| 456 |
if not handle: |
| 457 |
RaiseFromWindowsErr(0) |
| 458 |
return _handle2int(handle) |
| 459 |
|
| 460 |
def MapViewOfFile(handle, *args): |
| 461 |
address = _kernel32.MapViewOfFile(_int2handle(handle), *args) |
| 462 |
if not address: |
| 463 |
RaiseFromWindowsErr(0) |
| 464 |
return address |
| 465 |
|
| 466 |
def VirtualQuerySize(address): |
| 467 |
mem_basic_info = _ffi.new("MEMORY_BASIC_INFORMATION[1]") |
| 468 |
|
| 469 |
size_of_buf = _kernel32.VirtualQuery(address, mem_basic_info, _ffi.sizeof(mem_basic_info)) |
| 470 |
if size_of_buf == 0: |
| 471 |
RaiseFromWindowsErr(0) |
| 472 |
return mem_basic_info[0].RegionSize |
| 473 |
|
| 474 |
|
| 475 |
STD_INPUT_HANDLE = -10 |
| 476 |
STD_OUTPUT_HANDLE = -11 |
| 477 |
STD_ERROR_HANDLE = -12 |
| 478 |
DUPLICATE_SAME_ACCESS = 2 |
| 479 |
DUPLICATE_CLOSE_SOURCE = 1 |
| 480 |
STARTF_USESTDHANDLES = 0x100 |
| 481 |
STARTF_USESHOWWINDOW = 0x001 |
| 482 |
SW_HIDE = 0 |
| 483 |
INFINITE = 0xffffffff |
| 484 |
WAIT_OBJECT_0 = 0 |
| 485 |
WAIT_ABANDONED_0 = 0x80 |
| 486 |
WAIT_TIMEOUT = 0x102 |
| 487 |
WAIT_FAILED = 0xFFFFFFFF |
| 488 |
DEBUG_PROCESS = 0x00000001 |
| 489 |
DEBUG_ONLY_THIS_PROCESS = 0x00000002 |
| 490 |
CREATE_SUSPENDED = 0x00000004 |
| 491 |
DETACHED_PROCESS = 0x00000008 |
| 492 |
CREATE_NEW_CONSOLE = 0x010 |
| 493 |
CREATE_NEW_PROCESS_GROUP = 0x200 |
| 494 |
CREATE_UNICODE_ENVIRONMENT = 0x400 |
| 495 |
STILL_ACTIVE = 259 |
| 496 |
_MAX_PATH = 260 |
| 497 |
INFINITE = 0xFFFFFFFF |
| 498 |
|
| 499 |
ERROR_SUCCESS = 0 |
| 500 |
ERROR_INVALID_HANDLE = 6 |
| 501 |
ERROR_NETNAME_DELETED = 64 |
| 502 |
ERROR_BROKEN_PIPE = 109 |
| 503 |
ERROR_SEM_TIMEOUT = 121 |
| 504 |
ERROR_PIPE_BUSY = 231 |
| 505 |
ERROR_NO_DATA = 232 |
| 506 |
ERROR_MORE_DATA = 234 |
| 507 |
ERROR_PIPE_CONNECTED = 535 |
| 508 |
ERROR_OPERATION_ABORTED = 995 |
| 509 |
ERROR_IO_INCOMPLETE = 996 |
| 510 |
ERROR_IO_PENDING = 997 |
| 511 |
ERROR_NOT_FOUND = 1168 |
| 512 |
ERROR_CONNECTION_REFUSED = 1225 |
| 513 |
ERROR_CONNECTION_ABORTED = 1236 |
| 514 |
ERROR_ALREADY_EXISTS = 0xB7 |
| 515 |
|
| 516 |
|
| 517 |
PIPE_ACCESS_INBOUND = 0x00000001 |
| 518 |
PIPE_ACCESS_OUTBOUND = 0x00000002 |
| 519 |
PIPE_ACCESS_DUPLEX = 0x00000003 |
| 520 |
PIPE_WAIT = 0x00000000 |
| 521 |
PIPE_NOWAIT = 0x00000001 |
| 522 |
PIPE_READMODE_BYTE = 0x00000000 |
| 523 |
PIPE_READMODE_MESSAGE = 0x00000002 |
| 524 |
PIPE_TYPE_BYTE = 0x00000000 |
| 525 |
PIPE_TYPE_MESSAGE = 0x00000004 |
| 526 |
PIPE_ACCEPT_REMOTE_CLIENTS = 0x00000000 |
| 527 |
PIPE_REJECT_REMOTE_CLIENTS = 0x00000008 |
| 528 |
|
| 529 |
PIPE_UNLIMITED_INSTANCES = 255 |
| 530 |
|
| 531 |
GENERIC_READ = 0x80000000 |
| 532 |
GENERIC_WRITE = 0x40000000 |
| 533 |
GENERIC_EXECUTE= 0x20000000 |
| 534 |
GENERIC_ALL = 0x10000000 |
| 535 |
INVALID_HANDLE_VALUE = _int2handle(-1) |
| 536 |
FILE_FLAG_WRITE_THROUGH = 0x80000000 |
| 537 |
FILE_FLAG_OVERLAPPED = 0x40000000 |
| 538 |
FILE_FLAG_NO_BUFFERING = 0x20000000 |
| 539 |
FILE_FLAG_RANDOM_ACCESS = 0x10000000 |
| 540 |
FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000 |
| 541 |
FILE_FLAG_DELETE_ON_CLOSE = 0x04000000 |
| 542 |
FILE_FLAG_BACKUP_SEMANTICS = 0x02000000 |
| 543 |
FILE_FLAG_POSIX_SEMANTICS = 0x01000000 |
| 544 |
FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000 |
| 545 |
FILE_FLAG_OPEN_NO_RECALL = 0x00100000 |
| 546 |
FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000 |
| 547 |
|
| 548 |
NMPWAIT_WAIT_FOREVER = 0xffffffff |
| 549 |
NMPWAIT_NOWAIT = 0x00000001 |
| 550 |
NMPWAIT_USE_DEFAULT_WAIT = 0x00000000 |
| 551 |
|
| 552 |
FILE_READ_DATA = 1 |
| 553 |
FILE_WRITE_DATA = 2 |
| 554 |
FILE_APPEND_DATA = 4 |
| 555 |
FILE_READ_EA = 8 |
| 556 |
FILE_WRITE_EA = 16 |
| 557 |
FILE_EXECUTE = 32 |
| 558 |
FILE_READ_ATTRIBUTES = 128 |
| 559 |
FILE_WRITE_ATTRIBUTES = 256 |
| 560 |
READ_CONTROL = 0x00020000 |
| 561 |
SYNCHRONIZE = 0x00100000 |
| 562 |
STANDARD_RIGHTS_EXECUTE = READ_CONTROL |
| 563 |
STANDARD_RIGHTS_READ = READ_CONTROL |
| 564 |
STANDARD_RIGHTS_WRITE = READ_CONTROL |
| 565 |
|
| 566 |
FILE_GENERIC_EXECUTE = FILE_EXECUTE | FILE_READ_ATTRIBUTES | STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE |
| 567 |
FILE_GENERIC_READ = FILE_READ_ATTRIBUTES | FILE_READ_DATA | FILE_READ_EA | STANDARD_RIGHTS_READ | SYNCHRONIZE |
| 568 |
FILE_GENERIC_WRITE = FILE_APPEND_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_DATA | FILE_WRITE_EA | STANDARD_RIGHTS_WRITE | SYNCHRONIZE |
| 569 |
|
| 570 |
PROCESS_DUP_HANDLE = 0x0040 |
| 571 |
|
| 572 |
CREATE_NEW = 1 |
| 573 |
CREATE_ALWAYS = 2 |
| 574 |
OPEN_EXISTING = 3 |
| 575 |
OPEN_ALWAYS = 4 |
| 576 |
TRUNCATE_EXISTING = 5 |
| 577 |
|
| 578 |
MAXIMUM_WAIT_OBJECTS = 64 |
| 579 |
|
| 580 |
BELOW_NORMAL_PRIORITY_CLASS = 0x00004000 |
| 581 |
ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000 |
| 582 |
NORMAL_PRIORITY_CLASS = 0x00000020 |
| 583 |
IDLE_PRIORITY_CLASS = 0x00000040 |
| 584 |
HIGH_PRIORITY_CLASS = 0x00000080 |
| 585 |
REALTIME_PRIORITY_CLASS = 0x00000100 |
| 586 |
BELOW_NORMAL_PRIORITY_CLASS = 0x00004000 |
| 587 |
CREATE_BREAKAWAY_FROM_JOB = 0x01000000 |
| 588 |
CREATE_DEFAULT_ERROR_MODE = 0x04000000 |
| 589 |
CREATE_NO_WINDOW = 0x08000000 |
| 590 |
|
| 591 |
FILE_TYPE_CHAR = 2 |
| 592 |
FILE_TYPE_DISK = 1 |
| 593 |
FILE_TYPE_PIPE = 3 |
| 594 |
FILE_TYPE_REMOTE = 32768 |
| 595 |
FILE_TYPE_UNKNOWN = 0 |
| 596 |
|
| 597 |
|
| 598 |
PAGE_EXECUTE_READ = 0x20 |
| 599 |
PAGE_EXECUTE_READWRITE = 0x40 |
| 600 |
PAGE_EXECUTE_WRITECOPY = 0x80 |
| 601 |
PAGE_READONLY = 0x02 |
| 602 |
PAGE_READWRITE = 0x04 |
| 603 |
PAGE_WRITECOPY = 0x08 |
| 604 |
SEC_COMMIT = 0x8000000 |
| 605 |
SEC_IMAGE = 0x1000000 |
| 606 |
SEC_IMAGE_NO_EXECUTE = 0x11000000 |
| 607 |
SEC_LARGE_PAGES = 0x80000000 |
| 608 |
SEC_NOCACHE = 0x10000000 |
| 609 |
SEC_RESERVE = 0x4000000 |
| 610 |
SEC_WRITECOMBINE = 0x40000000 |
| 611 |
|
| 612 |
|
| 613 |
STANDARD_RIGHTS_REQUIRED = 0x000F0000 |
| 614 |
SECTION_QUERY = 0x0001 |
| 615 |
SECTION_MAP_WRITE = 0x0002 |
| 616 |
SECTION_MAP_READ = 0x0004 |
| 617 |
SECTION_MAP_EXECUTE = 0x0008 |
| 618 |
SECTION_EXTEND_SIZE = 0x0010 |
| 619 |
SECTION_MAP_EXECUTE_EXPLICIT = 0x0020 |
| 620 |
SECTION_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY| |
| 621 |
SECTION_MAP_WRITE | |
| 622 |
SECTION_MAP_READ | |
| 623 |
SECTION_MAP_EXECUTE | |
| 624 |
SECTION_EXTEND_SIZE) |
| 625 |
|
| 626 |
|
| 627 |
FILE_MAP_WRITE = SECTION_MAP_WRITE |
| 628 |
FILE_MAP_READ = SECTION_MAP_READ |
| 629 |
FILE_MAP_ALL_ACCESS = SECTION_ALL_ACCESS |
| 630 |
FILE_MAP_EXECUTE = SECTION_MAP_EXECUTE_EXPLICIT |
| 631 |
FILE_MAP_COPY = 0x00000001 |
| 632 |
FILE_MAP_RESERVE = 0x80000000 |
| 633 |
FILE_MAP_TARGETS_INVALID = 0x40000000 |
| 634 |
FILE_MAP_LARGE_PAGES = 0x20000000 |