Skip to content

Commit f2a287d

Browse files
committed
Add some ctypes generation + HRESULT_FACILITY macro
1 parent e693024 commit f2a287d

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

ctypes_generation/definitions/defines/error_helper.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,22 @@
22
#define ERROR_SEVERITY_SUCCESS 0x00000000
33
#define ERROR_SEVERITY_INFORMATIONAL 0x40000000
44
#define ERROR_SEVERITY_WARNING 0x80000000
5-
#define ERROR_SEVERITY_ERROR 0xC0000000
5+
#define ERROR_SEVERITY_ERROR 0xC0000000
6+
7+
// https://learn.microsoft.com/en-us/windows/win32/com/structure-of-com-error-codes
8+
// Define the facility codes
9+
//
10+
#define FACILITY_WINDOWS 0x8
11+
#define FACILITY_WIN32 0x7
12+
#define FACILITY_STORAGE 0x3
13+
#define FACILITY_RPC 0x1
14+
#define FACILITY_NULL 0x0
15+
#define FACILITY_ITF 0x4
16+
#define FACILITY_DISPATCH 0x2
17+
18+
19+
//
20+
// Define the severity codes
21+
//
22+
#define STATUS_SEVERITY_SUCCESS 0x0
23+
#define STATUS_SEVERITY_COERROR 0x2

ctypes_generation/definitions/defines/template.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@
1717

1818
def CTL_CODE(DeviceType, Function, Method, Access):
1919
return (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
20+
21+
# https://learn.microsoft.com/en-us/windows/win32/api/winerror/nf-winerror-hresult_facility
22+
# Original MACRO:
23+
# #define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff)
24+
25+
def HRESULT_FACILITY(hr):
26+
return (((hr) >> 16) & 0x1fff)

0 commit comments

Comments
 (0)