用于调试打印的 MS 标志中的奇怪值
Strange values in MS flags for debug print
我在 Microsoft 驱动程序代码示例调试跟踪标志中看到:
#define DEBUG_TRACE_ERROR 0x00000001 // Errors - whenever we return a failure code
#define DEBUG_TRACE_LOAD_UNLOAD 0x00000002 // Loading/unloading of the filter
#define DEBUG_TRACE_INSTANCES 0x00000004 // Attach / detatch of instances
#define DEBUG_TRACE_METADATA_OPERATIONS 0x00000008 // Operation to access / modify in memory metadata
#define DEBUG_TRACE_ALL_IO 0x00000010 // All IO operations tracked by this filter
#define DEBUG_TRACE_INFO 0x00000020 // Misc. information
#define DEBUG_TRACE_ALL 0xFFFFFFFF // All flags
据我所知,标志应该是 2 的幂(例如 1、2、4、8、16、32)才能不相交。
但是为什么 DEBUG_TRACE_ALL_IO 是 10 而 DEBUG_TRACE_INFO 是 20 而不是 16 和 32?
因为这段代码中的值是十六进制的。 0x10 = 16.
Hex: 0x00000001 0x00000002 0x00000004 0x00000008 0x0000010 0x00000020
Dec: 1 2 4 8 16 32
我在 Microsoft 驱动程序代码示例调试跟踪标志中看到:
#define DEBUG_TRACE_ERROR 0x00000001 // Errors - whenever we return a failure code
#define DEBUG_TRACE_LOAD_UNLOAD 0x00000002 // Loading/unloading of the filter
#define DEBUG_TRACE_INSTANCES 0x00000004 // Attach / detatch of instances
#define DEBUG_TRACE_METADATA_OPERATIONS 0x00000008 // Operation to access / modify in memory metadata
#define DEBUG_TRACE_ALL_IO 0x00000010 // All IO operations tracked by this filter
#define DEBUG_TRACE_INFO 0x00000020 // Misc. information
#define DEBUG_TRACE_ALL 0xFFFFFFFF // All flags
据我所知,标志应该是 2 的幂(例如 1、2、4、8、16、32)才能不相交。 但是为什么 DEBUG_TRACE_ALL_IO 是 10 而 DEBUG_TRACE_INFO 是 20 而不是 16 和 32?
因为这段代码中的值是十六进制的。 0x10 = 16.
Hex: 0x00000001 0x00000002 0x00000004 0x00000008 0x0000010 0x00000020
Dec: 1 2 4 8 16 32