source: trunk/dll/ufortify.h@ 1567

Last change on this file since 1567 was 1077, checked in by Steven Levine, 17 years ago

Enhance Fortify infrastructure
Add Fortify_SetOwner Fortify_ChangeOwner Fortify_ChangeScope
Add FORTIFY_VERBOSE_SCOPE_ENTER_EXIT support
Add more fm/2 Fortify tooling and rework existing tooling for correct nesting
Still lots to do for cross-thread allocations
Add misc.h
Add walkem.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1/*
2 * $Id: ufortify.h 1077 2008-07-18 18:11:54Z stevenhl $
3 *
4 * FILE:
5 * ufortify.h
6 *
7 * DESCRIPTION:
8 * User options for fortify. Changes to this file require fortify.c to be
9 * recompiled, but nothing else.
10 */
11
12 /* 18 Jul 08 SHL Add FORTIFY_VERBOSE_SCOPE_ENTER_EXIT
13 */
14
15// 28 Jan 08 SHL
16#define FORTIFY_STORAGE _export /* storage for public functions */
17
18#define FORTIFY_ALIGNMENT sizeof(double) /* Byte alignment of all memory blocks */
19
20#define FORTIFY_BEFORE_SIZE 32 /* Bytes to allocate before block */
21#define FORTIFY_BEFORE_VALUE 0xA3 /* Fill value before block */
22
23#define FORTIFY_AFTER_SIZE 32 /* Bytes to allocate after block */
24#define FORTIFY_AFTER_VALUE 0xA5 /* Fill value after block */
25
26#define FORTIFY_FILL_ON_ALLOCATE /* Nuke out malloc'd memory */
27#define FORTIFY_FILL_ON_ALLOCATE_VALUE 0xA7 /* Value to initialize with */
28
29#define FORTIFY_FILL_ON_DEALLOCATE /* free'd memory is cleared */
30#define FORTIFY_FILL_ON_DEALLOCATE_VALUE 0xA9 /* Value to de-initialize with */
31
32#define FORTIFY_FILL_ON_CORRUPTION /* Nuke out corrupted memory */
33
34/* #define FORTIFY_CHECK_ALL_MEMORY_ON_ALLOCATE */
35/* #define FORTIFY_CHECK_ALL_MEMORY_ON_DEALLOCATE */
36#define FORTIFY_PARANOID_DEALLOCATE
37
38/* #define FORTIFY_WARN_ON_ZERO_MALLOC */ /* A debug is issued on a malloc(0) */
39/* #define FORTIFY_FAIL_ON_ZERO_MALLOC */ /* A malloc(0) will fail */
40
41#define FORTIFY_WARN_ON_ALLOCATE_FAIL /* A debug is issued on a failed alloc */
42#define FORTIFY_WARN_ON_FALSE_FAIL /* See Fortify_SetAllocateFailRate */
43#define FORTIFY_WARN_ON_SIZE_T_OVERFLOW /* Watch for breaking the 64K limit in */
44 /* some braindead architectures... */
45
46#define FORTIFY_TRACK_DEALLOCATED_MEMORY
47#define FORTIFY_DEALLOCATED_MEMORY_LIMIT 1048576 /* Maximum amount of deallocated bytes to keep */
48/* #define FORTIFY_WARN_WHEN_DISCARDING_DEALLOCATED_MEMORY */
49/* #define FORTIFY_VERBOSE_WARN_WHEN_DISCARDING_DEALLOCATED_MEMORY */
50#define FORTIFY_VERBOSE_SCOPE_ENTER_EXIT /* Log all scope entry and exit */
51
52/* #define FORTIFY_NO_PERCENT_P */ /* sprintf() doesn't support %p */
53#define FORTIFY_STRDUP /* if you use non-ANSI strdup() */
54
55// #include "_malloc.h"
56#ifdef __cplusplus
57extern "C" {
58#endif
59#ifdef __BORLANDC__
60// See bc20\source\rtl\rtlinc\_malloc.h
61void _RTLENTRY _EXPFUNC _lock_heap (void);
62void _RTLENTRY _EXPFUNC _unlock_heap(void);
63#endif
64
65#ifdef __WATCOMC__
66// 05 May 08 SHL
67// J:\sla_dev2\ow.dev\bld\clib\h\heapacc.h
68extern void (*_AccessNHeap)( void );
69extern void (*_ReleaseNHeap)( void );
70#endif
71#ifdef __cplusplus
72}
73#endif
74
75#ifdef __BORLANDC__
76#define FORTIFY_LOCK() _lock_heap() // 28 Jan 08 SHL
77#define FORTIFY_UNLOCK() _unlock_heap() // 28 Jan 08 SHL
78#endif
79#ifdef __WATCOMC__
80#define FORTIFY_LOCK() _AccessNHeap() // 05 May 08 SHL
81#define FORTIFY_UNLOCK() _ReleaseNHeap() // 05 May 08 SHL
82#endif
83
84#define FORTIFY_DELETE_STACK_SIZE 256
85
86#ifdef __cplusplus /* C++ only options go here */
87
88/* #define FORTIFY_PROVIDE_ARRAY_NEW */
89/* #define FORTIFY_PROVIDE_ARRAY_DELETE */
90
91/* #define FORTIFY_AUTOMATIC_LOG_FILE */
92 #define FORTIFY_LOG_FILENAME "fortify.log"
93 #include <iostream.h>
94 #define FORTIFY_FIRST_ERROR_FUNCTION cout << "\a\a\aFortify Hit Generated!\n"
95
96#endif /* __cplusplus */
Note: See TracBrowser for help on using the repository browser.