Debian Codegraph @

cross-project-tests/debuginfo-tests/dexter/dex/debugger/dbgeng/utils.py

raw
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
8 from 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.
13 E_NOINTERFACE = 0x80004002 - 0x100000000
14 E_FAIL = 0x80004005 - 0x100000000
15 E_EINVAL = 0x80070057 - 0x100000000
16 E_INTERNALEXCEPTION = 0x80040205 - 0x100000000
17 S_FALSE = 1
18
19 # This doesn't fit into any convenient category
20 DEBUG_ANY_ID = 0xFFFFFFFF
21
22
23 class WinError(Exception):
24 def __init__(self, msg, hstatus):
25 self.hstatus = hstatus
26 super(WinError, self).__init__(msg)
27
28
29 def aborter(res, msg, ignore=[]):
30 if res != 0 and res not in ignore:
31 # Convert a negative error code to a positive unsigned one, which is
32 # now NTSTATUSes appear in documentation.
33 if res < 0:
34 res += 0x100000000
35 msg = "{:08X} : {}".format(res, msg)
36 raise WinError(msg, res)
37
38
39 IID_Data4_Type = c_ubyte * 8
40
41
42 class IID(Structure):
43 _fields_ = [
44 ("Data1", c_uint),
45 ("Data2", c_ushort),
46 ("Data3", c_ushort),
47 ("Data4", IID_Data4_Type),
48 ]
49
50
51 c_ulong_p = POINTER(c_ulong)
52 c_ulong64_p = POINTER(c_ulonglong)