1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7     FxBugcheck.h
8 
9 Abstract:
10     This module contains private macros/defines for crashdumps.
11 
12 --*/
13 
14 #ifndef __FXBUGCHECK_H__
15 #define __FXBUGCHECK_H__
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 //
22 // Macro for doing pointer arithmetic.
23 //
24 #define Add2Ptr(P,I) ((PVOID)((PUCHAR)(P) + (I)))
25 
26 //
27 // This macro takes a length & rounds it up to a multiple of the alignment
28 // Alignment is given as a power of 2
29 //
30 #define EXP_ALIGN_UP_PTR_ON_BOUNDARY(_length, _alignment) \
31           (PVOID) ((((ULONG_PTR) (_length)) + ((_alignment)-1)) & \
32                               ~(ULONG_PTR)((_alignment) - 1))
33 
34 //
35 // Checks if 1st argument is aligned on given power of 2 boundary specified
36 // by 2nd argument
37 //
38 #define EXP_IS_PTR_ALIGNED_ON_BOUNDARY(_pointer, _alignment) \
39         ((((ULONG_PTR) (_pointer)) & ((_alignment) - 1)) == 0)
40 
41 
42 //
43 // This macro takes a size and rounds it down to a multiple of the alignemnt.
44 // Alignment doesn't need to be a power of 2.
45 //
46 #define EXP_ALIGN_DOWN_ON_BOUNDARY(_size, _alignment) \
47         ((_size) - ((_size) % _alignment))
48 
49 //
50 // Define the max data size the bugcheck callback can write. Per callback the
51 // total size is around 16K on 32bit OS (32K on 64bit OS).
52 //
53 #ifdef _WIN64
54 #define FX_MAX_DUMP_SIZE                    (32*1024)
55 #else
56 #define FX_MAX_DUMP_SIZE                    (16*1024)
57 #endif
58 
59 //
60 // Maximum number of CPUs supported by the driver tracker.
61 //
62 #define FX_DRIVER_TRACKER_MAX_CPUS          256     // Max Win7 processors.
63 
64 //
65 // The initial/increment size of the array to hold driver info.
66 //
67 #define FX_DUMP_DRIVER_INFO_INCREMENT       10      // # entries.
68 
69 //
70 // The max size of the array to hold the driver info. This is the max data
71 // we can write into the minidump.
72 //
73 #define FX_MAX_DUMP_DRIVER_INFO_COUNT \
74     (FX_MAX_DUMP_SIZE/sizeof(FX_DUMP_DRIVER_INFO_ENTRY))
75 
76 //
77 // During run-time we store info about the loaded drivers in an array
78 // of FX_DUMP_DRIVER_INFO_ENTRY struct entries, on a crash we write the
79 // entire array in the minidump for postmortem analysis.
80 //
81 typedef struct _FX_DUMP_DRIVER_INFO_ENTRY {
82     PFX_DRIVER_GLOBALS  FxDriverGlobals;
83     WDF_VERSION         Version;
84     CHAR                DriverName[WDF_DRIVER_GLOBALS_NAME_LEN];
85 } FX_DUMP_DRIVER_INFO_ENTRY, *PFX_DUMP_DRIVER_INFO_ENTRY;
86 
87 #ifdef __cplusplus
88 } // extern "C"
89 #endif
90 
91 #endif // __FXBUGCHECK_H__
92