-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBugTrap.h
More file actions
880 lines (815 loc) · 24.8 KB
/
BugTrap.h
File metadata and controls
880 lines (815 loc) · 24.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
/*
* This is a part of the BugTrap package.
* Copyright (c) 2005-2009 IntelleSoft.
* All rights reserved.
*
* Description: Definitions of external functions.
* Author: Maksim Pyatkovskiy.
*
* This source code is only intended as a supplement to the
* BugTrap package reference and related electronic documentation
* provided with the product. See these sources for detailed
* information regarding the BugTrap package.
*/
#ifndef _BUGTRAP_H_
#define _BUGTRAP_H_
#pragma once
#if defined _MANAGED && ! defined _UNICODE
#error Managed version of BugTrap requires Unicode character set
#endif // _MANAGED && ! _UNICODE
/*
* The following ifdef block is the standard way of creating macros which make exporting
* from a DLL simpler. All files within this DLL are compiled with the BUGTRAP_EXPORTS
* symbol defined on the command line. this symbol should not be defined on any project
* that uses this DLL. This way any other project whose source files include this file see
* BUGTRAP_API functions as being imported from a DLL, whereas this DLL sees symbols
* defined with this macro as being exported.
*/
#ifdef BUGTRAP_EXPORTS
#define BUGTRAP_API __declspec(dllexport)
#else
#define BUGTRAP_API __declspec(dllimport)
#endif // ! BUGTRAP_EXPORTS
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/**
* @defgroup TypeDef Common type definitions
* @{
*/
/**
* @brief Type of action which is performed in response to the error.
*/
typedef enum BUGTRAP_ACTIVITY_tag
{
/**
* @brief Display BugTrap dialog to allow user selecting desirable
* option. This is the default option.
*/
BTA_SHOWUI = 1,
/**
* @brief Automatically save error report to file.
* Use BT_SetReportFilePath() to specify report path.
*/
BTA_SAVEREPORT = 2,
/**
* @brief Automatically send error report by e-mail.
*/
BTA_MAILREPORT = 3,
/**
* @brief Automatically send bug report to support server.
*/
BTA_SENDREPORT = 4,
/**
* @brief Call custom handler specified by BT_SetCustomActivityHandler().
*/
BTA_CUSTOM = 5,
}
BUGTRAP_ACTIVITY;
/**
* @brief Different BugTrap options. You can use any combinations
* of these flags.
*/
typedef enum BUGTRAP_FLAGS_tag
{
/**
* @brief Equivalent of no options.
*/
BTF_NONE = 0x000,
/**
* @brief In detailed mode BugTrap generates mini-dump and
* packs custom log files within the report.
*/
BTF_DETAILEDMODE = 0x001,
/**
* @brief BugTrap may open its own editor for e-mail messages
* instead of the editor used by the system. Use this
* option if you aren't aware of the type of e-mail
* client installed on user computers.
*/
BTF_EDITMAIL = 0x002,
/**
* @brief Specify this option to attach bug report to e-mail
* messages. Be careful with this option. It's potentially
* dangerous for the detailed mode because of even zipped
* mini-dump may require huge size. It may exceed the
* maximum size of e-mail message supported by Internet
* provider.
*/
BTF_ATTACHREPORT = 0x004,
/**
* @brief Set this flag to add list of all processes and loaded
* modules to the report. Disable this option to speedup report
* generation.
*/
BTF_LISTPROCESSES = 0x008,
/**
* @brief By default BugTrap displays simplified dialog on the
* screen allowing user to perform only common actions. Enable
* this flag to immediately display dialog with advanced error
* information.
*/
BTF_SHOWADVANCEDUI = 0x010,
/**
* @brief Bug report in detailed error mode may also include a
* screen shot automatically captured by BugTrap. By default this
* option is disabled to minimize report size, but it may be useful
* if you want to know which dialogs were shown on the screen.
*/
BTF_SCREENCAPTURE = 0x020,
#ifdef _MANAGED
/**
* @brief Generate native stack trace and modules information along
* with managed exception information. Disable this option to speedup
* report generation.
*/
BTF_NATIVEINFO = 0x040,
#endif // _MANAGED
/**
* @brief When enabled, BugTrap injects fake SetUnhandledExceptionFilter()
* to handle the most severe C runtime errors. Usually such errors
* are not being reported to custom unhandled exception filters. This
* flag vanishes any attempts of C runtime library to override
* unhandled exception filter defined in BugTrap. This option should
* be used with caution, because such technique may be incompatible
* with future Windows versions.
*/
BTF_INTERCEPTSUEF = 0x080,
/**
* @brief When report is being sent over TCP/HTTP protocol, BugTrap could
* ask user to provide verbal description of the problem if this option is
* enabled. BugTrap always prompts user to describe error for reports
* transmitted over email regardless this option.
*/
BTF_DESCRIBEERROR = 0x100,
/**
* @brief Automatically restart the application after the crash has been
* handled.
*/
BTF_RESTARTAPP = 0x200
}
BUGTRAP_FLAGS;
/**
* @brief These flags control application termination mode:
* whatever the application needs to be terminated after error handling,
* control should passed to another exception handler.
*/
typedef enum BUGTRAP_EXITMODE_tag
{
/**
* @brief BugTrap executes desirable action (usually displays the dialog).
* The application is being terminated when user closes the dialog. This is default action.
*/
BTEM_TERMINATEAPP,
/**
* @brief BugTrap executes desirable action and continues to search up the stack for a handler.
*/
BTEM_CONTINUESEARCH,
/**
* @brief BugTrap executes desirable action and transfers control to the exception handlers.
*/
BTEM_EXECUTEHANDLER
}
BUGTRAP_EXITMODE;
/**
* @brief Set of available log levels.
*/
typedef enum BUGTRAP_LOGLEVEL_tag
{
/**
* @brief All message levels are prohibited.
*/
BTLL_NONE = 0,
/**
* @brief Error message.
*/
BTLL_ERROR = 1,
/**
* @brief Waning message.
*/
BTLL_WARNING = 2,
/**
* @brief Important information message.
*/
BTLL_IMPORTANT = 3,
/**
* @brief Regular information message.
*/
BTLL_INFO = 4,
/**
* @brief Verbose information message.
*/
BTLL_VERBOSE = 5,
/**
* @brief All levels of messages are accepted.
*/
BTLL_ALL = BTLL_INFO
}
BUGTRAP_LOGLEVEL;
/**
* @brief Type of log echo mode.
*/
typedef enum BUGTRAP_LOGECHOTYPE_tag
{
/**
* @brief Do not duplicate log output to file.
*/
BTLE_NONE = 0x00,
/**
* @brief Send a copy of log output to STDOUT (mutually exclusive with STDERR mode).
*/
BTLE_STDOUT = 0x01,
/**
* @brief Send a copy of log output to STDERR (mutually exclusive with STDOUT mode).
*/
BTLE_STDERR = 0x02,
/**
* @brief Send a copy of log output to the debugger (can accompany STDOUT or STDERR mode).
*/
BTLE_DBGOUT = 0x04
}
BUGTRAP_LOGECHOTYPE;
/**
* @brief Set of log file options.
*/
typedef enum BUGTRAP_LOGFLAGS_tag
{
/**
* @brief Do not show any additional entries in the log.
*/
BTLF_NONE = 0x00,
/**
* @brief Use this option if you want to store message levels in a file.
*/
BTLF_SHOWLOGLEVEL = 0x01,
/**
* @brief Use this option if you want to store message timestamps in a file.
* Timestamps are stored in universal (locale independent) format: YYYY/MM/DD HH:MM:SS
*/
BTLF_SHOWTIMESTAMP = 0x02
}
BUGTRAP_LOGFLAGS;
/**
* @brief Format of error report.
*/
typedef enum BUGTRAP_REPORTFORMAT_tag
{
/**
* @brief Report stored in structured XML format.
*/
BTRF_XML = 1,
/**
* @brief Report stored in plain text format.
*/
BTRF_TEXT = 2
}
BUGTRAP_REPORTFORMAT;
/**
* @brief Format of log file.
*/
typedef enum BUGTRAP_LOGFORMAT_tag
{
/**
* @brief Log stored in structured XML format.
* Log data is entirely stored in memory until application exists or crashes.
* It is designed for fast IO and it cannot handle large logs.
*/
BTLF_XML = 1,
/**
* @brief Log stored in plain text format.
* Log data is entirely stored in memory until application exists or crashes.
* It is designed for fast IO and it cannot handle large logs.
*/
BTLF_TEXT = 2,
/**
* @brief Log stored in plain text format.
* Unlike @a BTLF_XML and @a BTLF_TEXT log data is not cached in memory.
* This type of log is optimized for large logs.
*/
BTLF_STREAM = 3
}
BUGTRAP_LOGFORMAT;
/**
* @brief Type of user defined message displayed on the screen.
*/
typedef enum BUGTRAP_DIALOGMESSAGE_tag
{
/**
* @brief 1st line of introduction message.
*/
BTDM_INTRO1 = 1,
/**
* @brief A bunch of lines of introduction message.
*/
BTDM_INTRO2 = 2
}
BUGTRAP_DIALOGMESSAGE;
/**
* @brief Type of log file attached to the report.
*/
typedef enum BUGTRAP_LOGTYPE_tag
{
/**
* @brief Regular log file maintained by the user.
*/
BTLT_LOGFILE,
/**
* @brief Log file that's exported from the registry.
*/
BTLT_REGEXPORT
}
BUGTRAP_LOGTYPE;
/**
* @brief Log file entry structure return by BT_GetLogFileEntry() for regular log files.
*/
typedef struct BUGTRAP_LOGFILEENTRY_tag
{
/**
* @brief Log file name.
*/
TCHAR szLogFileName[MAX_PATH];
}
BUGTRAP_LOGFILEENTRY;
/**
* @brief Log file entry structure return by BT_GetLogFileEntry() for log files exported from the registry.
*/
typedef struct BUGTRAP_REGEXPORTENTRY_tag
{
/**
* @brief Log file name.
*/
TCHAR szLogFileName[MAX_PATH];
/**
* @brief Exported registry key.
*/
TCHAR szRegKey[MAX_PATH];
}
BUGTRAP_REGEXPORTENTRY;
/**
* @brief Type definition of user-defined error handler that's called before and after main BugTrap dialog.
*/
typedef void (CALLBACK * BT_ErrHandler)(INT_PTR nErrHandlerParam);
/**
* @brief Type definition of user-defined activity handler.
*/
typedef void (CALLBACK * BT_CustomActivityHandler)(LPCTSTR pszReportFilePath, INT_PTR nCustomActivityHandlerParam);
/** @} */
/**
* @defgroup AppTitle Application title management
* @{
*/
/**
* @brief Get application name.
*/
BUGTRAP_API LPCTSTR APIENTRY BT_GetAppName(void);
/**
* @brief Set application name of the project where BugTrap is used.
*/
BUGTRAP_API void APIENTRY BT_SetAppName(LPCTSTR pszAppName);
/**
* @brief Get application version number.
*/
BUGTRAP_API LPCTSTR APIENTRY BT_GetAppVersion(void);
/**
* @brief Set application version number.
*/
BUGTRAP_API void APIENTRY BT_SetAppVersion(LPCTSTR pszAppVersion);
/**
* @brief Read application name and version number from version info block.
* @note @a hModule can be set to NULL for the main executable.
*/
BUGTRAP_API BOOL APIENTRY BT_ReadVersionInfo(HMODULE hModule);
/** @} */
/**
* @defgroup ModuleOfInterest Module of interest
* Only exceptions that contain the module of interest at the stack trace will
* be processed. If no module of interest set, all exceptions will be processed.
* @{
*/
/**
* @brief Get module of interest
*/
BUGTRAP_API HMODULE APIENTRY BT_GetModule();
/**
* @brief Set module of interest
*/
BUGTRAP_API void APIENTRY BT_SetModule(HMODULE hModule);
/** @} */
/**
* @defgroup UserInterface User interface customization.
* @{
*/
/**
* @brief Get user defined message displayed on the screen.
*/
BUGTRAP_API LPCTSTR APIENTRY BT_GetDialogMessage(BUGTRAP_DIALOGMESSAGE eDialogMessage);
/**
* @brief Set user defined message displayed on the screen.
*/
BUGTRAP_API void APIENTRY BT_SetDialogMessage(BUGTRAP_DIALOGMESSAGE eDialogMessage, LPCTSTR pszMessage);
/** @} */
/**
* @defgroup SupportURL Support URL management
* @{
*/
/**
* @brief Get HTTP address of product support site.
*/
BUGTRAP_API LPCTSTR APIENTRY BT_GetSupportURL(void);
/**
* @brief Set HTTP address of product support site.
*/
BUGTRAP_API void APIENTRY BT_SetSupportURL(LPCTSTR pszSupportURL);
/**
* @brief Get product support e-mail address.
*/
BUGTRAP_API LPCTSTR APIENTRY BT_GetSupportEMail(void);
/**
* @brief Set product support e-mail address.
*/
BUGTRAP_API void APIENTRY BT_SetSupportEMail(LPCTSTR pszSupportEMail);
/** @} */
/**
* @defgroup SrvConfig Server configuration
* @{
*/
/// Use this port for HTTP protocol.
#define BUGTRAP_HTTP_PORT 80
/**
* @brief Get host name of BugTrap Server. This server can automatically
* gather bug reports for the application.
*/
BUGTRAP_API LPCTSTR APIENTRY BT_GetSupportHost(void);
/**
* @brief Set host name (address) of BugTrap Server. This server
* can automatically gather bug reports for the application.
*/
BUGTRAP_API void APIENTRY BT_SetSupportHost(LPCTSTR pszSupportHost);
/**
* @brief Get port number of BugTrap Server. This server can automatically
* gather bug reports for the application.
*/
BUGTRAP_API SHORT APIENTRY BT_GetSupportPort(void);
/**
* @brief Set port number of BugTrap Server. This server
* can automatically gather bug reports for the application.
*/
BUGTRAP_API void APIENTRY BT_SetSupportPort(SHORT nSupportPort);
/**
* @brief Set host name (address) and port number of BugTrap Server. This server
* can automatically gather bug reports for the application.
*/
BUGTRAP_API void APIENTRY BT_SetSupportServer(LPCTSTR pszSupportHost, SHORT nSupportPort);
/**
* @brief Get error notification e-mail address.
* BugTrap Server may automatically notify product support by e-mail about new bug reports.
*/
BUGTRAP_API LPCTSTR APIENTRY BT_GetNotificationEMail(void);
/**
* @brief Set error notification e-mail address.
* BugTrap Server may automatically notify product support by e-mail about new bug reports.
*/
BUGTRAP_API void APIENTRY BT_SetNotificationEMail(LPCTSTR pszNotificationEMail);
/** @} */
/**
* @defgroup CustomReport Report customization
* @{
*/
/// Disables mini-dump generation in detailed mode.
#define MiniDumpNoDump MAXDWORD
/**
* @brief Get current BugTrap options.
*/
BUGTRAP_API DWORD APIENTRY BT_GetFlags(void);
/**
* @brief Set various BugTrap options.
*/
BUGTRAP_API void APIENTRY BT_SetFlags(DWORD dwFlags);
/**
* @brief Get the type of produced mini-dump in detailed mode.
*/
BUGTRAP_API DWORD APIENTRY BT_GetDumpType(void);
/**
* @brief Set the type of produced mini-dump in detailed mode.
*/
BUGTRAP_API void APIENTRY BT_SetDumpType(DWORD dwDumpType);
/**
* @brief Get format of error report.
*/
BUGTRAP_API BUGTRAP_REPORTFORMAT APIENTRY BT_GetReportFormat(void);
/**
* @brief Set format of error report.
*/
BUGTRAP_API void APIENTRY BT_SetReportFormat(BUGTRAP_REPORTFORMAT eReportFormat);
/**
* @brief Get user defined message. This message may be printed to a log file.
*/
BUGTRAP_API LPCTSTR APIENTRY BT_GetUserMessage(void);
/**
* @brief Set user defined message. This message may be printed to a log file.
*/
BUGTRAP_API void APIENTRY BT_SetUserMessage(LPCTSTR pszUserMessage);
/**
* @brief Set user defined message. This message may be printed to a log file.
*/
BUGTRAP_API void APIENTRY BT_SetUserMessageFromCode(DWORD dwErrorCode);
/** @} */
/**
* @defgroup SilentFunc Silent mode configuration
* @{
*/
/**
* @brief Get the type of action which is performed in response to the error.
*/
BUGTRAP_API BUGTRAP_ACTIVITY APIENTRY BT_GetActivityType(void);
/**
* @brief Set the type of action which is performed in response to the error.
*/
BUGTRAP_API void APIENTRY BT_SetActivityType(BUGTRAP_ACTIVITY eActivityType);
/**
* @brief Get application termination mode.
*/
BUGTRAP_API BUGTRAP_EXITMODE APIENTRY BT_GetExitMode(void);
/**
* @brief Set application termination mode.
*/
BUGTRAP_API void APIENTRY BT_SetExitMode(BUGTRAP_EXITMODE eExitMode);
/**
* @brief Get the path of error report.
*/
BUGTRAP_API LPCTSTR APIENTRY BT_GetReportFilePath(void);
/**
* @brief Set the path of error report.
* This function has effect only for @a BTA_SAVEREPORT activity.
*/
BUGTRAP_API void APIENTRY BT_SetReportFilePath(LPCTSTR pszReportFilePath);
/**
* @brief Get the name of MAPI profile.
*/
BUGTRAP_API LPCTSTR APIENTRY BT_GetMailProfile(void);
/**
* @brief Set the name and password of MAPI profile.
*/
BUGTRAP_API void APIENTRY BT_SetMailProfile(LPCTSTR pszMailProfile, LPCTSTR pszMailPassword);
/** @} */
/**
* @defgroup LogFiles Custom log files management
* @{
*/
/**
* @brief Export registry key to the file.
*/
BUGTRAP_API int APIENTRY BT_ExportRegistryKey(LPCTSTR pszRegFile, LPCTSTR pszRegKey);
/**
* @brief Add custom log entry to the list of custom log files
* attached to bug report.
*/
BUGTRAP_API void APIENTRY BT_AddLogFile(LPCTSTR pszLogFile);
/**
* @brief Add custom log entry to the list of custom log files
* attached to bug report.
*/
BUGTRAP_API void APIENTRY BT_AddRegFile(LPCTSTR pszRegFile, LPCTSTR pszRegKey);
/**
* @brief Delete custom log entry from the list of custom log files
* attached to bug report.
*/
BUGTRAP_API void APIENTRY BT_DeleteLogFile(LPCTSTR pszLogFile);
/**
* @brief Clear the list of custom log files attached to bug report.
*/
BUGTRAP_API void APIENTRY BT_ClearLogFiles(void);
/**
* @brief Get number of log files attached to the report.
*/
BUGTRAP_API DWORD APIENTRY BT_GetLogFilesCount(void);
/**
* @brief This function enumerates log file entries that will be attached to the report.
*/
BUGTRAP_API DWORD APIENTRY BT_GetLogFileEntry(INT_PTR nLogFileIndexOrName, BOOL bGetByIndex, BUGTRAP_LOGTYPE* peLogType, PDWORD pdwLogEntrySize, PVOID pLogEntry);
/** @} */
/**
* @defgroup CustomErrHandlers Custom error handlers
* @{
*/
/**
* @brief Get address of error handler called before BugTrap dialog.
*/
BUGTRAP_API BT_ErrHandler APIENTRY BT_GetPreErrHandler(void);
/**
* @brief Set address of error handler called before BugTrap dialog.
*/
BUGTRAP_API void APIENTRY BT_SetPreErrHandler(BT_ErrHandler pfnPreErrHandler, INT_PTR nPreErrHandlerParam);
/**
* @brief Get address of error handler called after BugTrap dialog.
*/
BUGTRAP_API BT_ErrHandler APIENTRY BT_GetPostErrHandler(void);
/**
* @brief Set address of error handler called after BugTrap dialog.
*/
BUGTRAP_API void APIENTRY BT_SetPostErrHandler(BT_ErrHandler pfnPostErrHandler, INT_PTR nPostErrHandlerParam);
/** @} */
/**
* @defgroup CustomActivityHandlers Custom activity handlers
* @{
*/
/**
* @brief Get address of custom activity handler called at processing BugTrap action.
*/
BUGTRAP_API BT_CustomActivityHandler APIENTRY BT_GetCustomActivityHandler(void);
/**
* @brief Set address of custom activity handler called at processing BugTrap action.
*/
BUGTRAP_API void APIENTRY BT_SetCustomActivityHandler(BT_CustomActivityHandler pfnCustomActivityHandler, INT_PTR nCustomActivityHandlerParam);
/** @} */
/**
* @defgroup TracingFunc Tracing functions
* @{
*/
/**
* @brief Open custom log file. This function is thread safe.
*/
BUGTRAP_API INT_PTR APIENTRY BT_OpenLogFile(LPCTSTR pszLogFileName, BUGTRAP_LOGFORMAT eLogFormat);
/**
* @brief Close custom log file. This function is thread safe.
*/
BUGTRAP_API BOOL APIENTRY BT_CloseLogFile(INT_PTR iHandle);
/**
* @brief Flush contents of the log file.
* @note This function is optional and not required in normal conditions.
*/
BUGTRAP_API BOOL APIENTRY BT_FlushLogFile(INT_PTR iHandle);
/**
* @brief Get custom log file name. This function is thread safe.
*/
BUGTRAP_API LPCTSTR APIENTRY BT_GetLogFileName(INT_PTR iHandle);
/**
* @brief Get maximum log file size in records. This function is thread safe.
*/
BUGTRAP_API DWORD APIENTRY BT_GetLogSizeInEntries(INT_PTR iHandle);
/**
* @brief Set maximum log file size in records. This function is thread safe.
*/
BUGTRAP_API BOOL APIENTRY BT_SetLogSizeInEntries(INT_PTR iHandle, DWORD dwLogSizeInEntries);
/**
* @brief Get maximum log file size in bytes. This function is thread safe.
*/
BUGTRAP_API DWORD APIENTRY BT_GetLogSizeInBytes(INT_PTR iHandle);
/**
* @brief Set maximum log file size in bytes. This function is thread safe.
*/
BUGTRAP_API BOOL APIENTRY BT_SetLogSizeInBytes(INT_PTR iHandle, DWORD dwLogSizeInEntries);
/**
* @brief Return true if time stamp is added to every log entry.
*/
BUGTRAP_API DWORD APIENTRY BT_GetLogFlags(INT_PTR iHandle);
/**
* @brief Set true if time stamp is added to every log entry.
*/
BUGTRAP_API BOOL APIENTRY BT_SetLogFlags(INT_PTR iHandle, DWORD dwLogFlags);
/**
* @brief Return minimal log level accepted by tracing functions.
*/
BUGTRAP_API BUGTRAP_LOGLEVEL APIENTRY BT_GetLogLevel(INT_PTR iHandle);
/**
* @brief Set minimal log level accepted by tracing functions.
*/
BUGTRAP_API BOOL APIENTRY BT_SetLogLevel(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel);
/**
* @brief Get echo mode.
*/
BUGTRAP_API DWORD APIENTRY BT_GetLogEchoMode(INT_PTR iHandle);
/**
* @brief Set echo mode.
*/
BUGTRAP_API BOOL APIENTRY BT_SetLogEchoMode(INT_PTR iHandle, DWORD dwLogEchoMode);
/**
* @brief Clear log file. This function is thread safe.
*/
BUGTRAP_API BOOL APIENTRY BT_ClearLog(INT_PTR iHandle);
/**
* @brief Insert entry into the beginning of custom log file. This function is thread safe.
*/
BUGTRAP_API BOOL CDECL BT_InsLogEntryF(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszFormat, ...);
/**
* @brief Append entry to the end of custom log file. This function is thread safe.
*/
BUGTRAP_API BOOL CDECL BT_AppLogEntryF(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszFormat, ...);
/**
* @brief Insert entry into the beginning of custom log file. This function is thread safe.
*/
BUGTRAP_API BOOL APIENTRY BT_InsLogEntryV(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszFormat, va_list argList);
/**
* @brief Append entry to the end of custom log file. This function is thread safe.
*/
BUGTRAP_API BOOL APIENTRY BT_AppLogEntryV(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszFormat, va_list argList);
/**
* @brief Insert entry into the beginning of custom log file. This function is thread safe.
*/
BUGTRAP_API BOOL APIENTRY BT_InsLogEntry(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszEntry);
/**
* @brief Append entry to the end of custom log file. This function is thread safe.
*/
BUGTRAP_API BOOL APIENTRY BT_AppLogEntry(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszEntry);
/** @} */
/**
* @defgroup InternalFunc Internal functions
* @{
*/
/**
* Explicitly installs BugTrap exception filter.
* @note Normally you should not call this function.
*/
BUGTRAP_API LPTOP_LEVEL_EXCEPTION_FILTER APIENTRY BT_InstallSehFilter(void);
/**
* Explicitly uninstalls BugTrap exception filter and restores the previous exception filter.
* @note Normally you should not call this function.
*/
BUGTRAP_API void APIENTRY BT_UninstallSehFilter(void);
/**
* @brief Explicitly intercepts SetUnhandledExceptionFilter() in a module.
* This function could be useful for dynamically loaded modules.
*/
BUGTRAP_API void BT_InterceptSUEF(HMODULE hModule, BOOL bOverride);
/**
* @brief Take a snapshot of program memory and save it to a file.
*/
BUGTRAP_API BOOL APIENTRY BT_SaveSnapshot(PCTSTR pszFileName);
/**
* @brief Take a snapshot of program memory and save it to a file.
*/
BUGTRAP_API BOOL APIENTRY BT_SaveSnapshotEx(PEXCEPTION_POINTERS pExceptionPointers, PCTSTR pszFileName);
/**
* @brief Take a snapshot of program memory and send over network.
*/
BUGTRAP_API BOOL APIENTRY BT_SendSnapshot(void);
/**
* @brief Take a snapshot of program memory and send over network.
*/
BUGTRAP_API BOOL APIENTRY BT_SendSnapshotEx(PEXCEPTION_POINTERS pExceptionPointers);
/**
* @brief Take a snapshot of program memory and e-mail it.
*/
BUGTRAP_API BOOL APIENTRY BT_MailSnapshot(void);
/**
* @brief Take a snapshot of program memory and e-mail it.
*/
BUGTRAP_API BOOL APIENTRY BT_MailSnapshotEx(PEXCEPTION_POINTERS pExceptionPointers);
/**
* @brief Executes structured exception filter.
* @note Don't call this function directly in your code.
*/
BUGTRAP_API LONG CALLBACK BT_SehFilter(PEXCEPTION_POINTERS pExceptionPointers);
/**
* @brief Simulates access violation in C++ application. Used by set_terminate().
* @note Don't call this function directly in your code.
*/
BUGTRAP_API void CDECL BT_CallSehFilter(void);
/**
* @brief Executes C++ exception filter.
* @note Don't call this function directly in your code.
*/
BUGTRAP_API LONG CALLBACK BT_CppFilter(PEXCEPTION_POINTERS pExceptionPointers);
/**
* @brief Simulates access violation in C++ application. Used by set_terminate().
* @note Don't call this function directly in your code.
*/
BUGTRAP_API void CDECL BT_CallCppFilter(void);
#ifdef _MANAGED
/**
* @brief Executes .NET exception filter.
* @note Don't call this function directly in your code.
*/
BUGTRAP_API LONG CALLBACK BT_NetFilter(PEXCEPTION_POINTERS pExceptionPointers);
/**
* @brief Simulates access violation in .NET application. Used by set_terminate().
* @note Don't call this function directly in your code.
*/
BUGTRAP_API void CDECL BT_CallNetFilter(void);
#endif // _MANAGED
/**
* Installs BugTrap handler to be called by the runtime in response to
* unhandled C++ exception.
*/
#if defined __cplusplus && defined _INC_EH
#define BT_SetTerminate() set_terminate(BT_CallCppFilter)
#else
#define BT_SetTerminate()
#endif // __cplusplus && _INC_EH
/** @} */
#ifdef __cplusplus
}
#endif // __cplusplus
#ifdef __cplusplus
#include "BTTrace.h"
#if defined __ATLWIN_H__ && defined __AFX_H__
#define BT_DO_NOT_USE_DEFAULT_NAMESPACES
#endif // __ATLWIN_H__ && __AFX_H__
#ifdef __ATLWIN_H__
#include "BTAtlWindow.h"
#endif // __ATLWIN_H__
#ifdef __AFX_H__
#include "BTMfcWindow.h"
#endif // __AFX_H__
#endif // __cplusplus
#endif // _BUGTRAP_H_