1# DExTer : Debugging Experience Tester 2# ~~~~~~ ~ ~~ ~ ~~ 3# 4# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5# See https://llvm.org/LICENSE.txt for license information. 6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 8from ctypes import * 9 10# Error codes are negative when received by python, but are typically 11# represented by unsigned hex elsewhere. Subtract 2^32 from the unsigned 12# hex to produce negative error codes. 13E_NOINTERFACE = 0x80004002 - 0x100000000 14E_FAIL = 0x80004005 - 0x100000000 15E_EINVAL = 0x80070057 - 0x100000000 16E_INTERNALEXCEPTION = 0x80040205 - 0x100000000 17S_FALSE = 1 18 19# This doesn't fit into any convenient category 20DEBUG_ANY_ID = 0xFFFFFFFF 21 22class WinError(Exception): 23 def __init__(self, msg, hstatus): 24 self.hstatus = hstatus 25 super(WinError, self).__init__(msg) 26 27def aborter(res, msg, ignore=[]): 28 if res != 0 and res not in ignore: 29 # Convert a negative error code to a positive unsigned one, which is 30 # now NTSTATUSes appear in documentation. 31 if res < 0: 32 res += 0x100000000 33 msg = '{:08X} : {}'.format(res, msg) 34 raise WinError(msg, res) 35 36IID_Data4_Type = c_ubyte * 8 37 38class IID(Structure): 39 _fields_ = [ 40 ("Data1", c_uint), 41 ("Data2", c_ushort), 42 ("Data3", c_ushort), 43 ("Data4", IID_Data4_Type) 44 ] 45 46c_ulong_p = POINTER(c_ulong) 47c_ulong64_p = POINTER(c_ulonglong) 48