forked from Thomas-Mielke-Software/EasyCash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CrashRpt.h
1799 lines (1686 loc) · 78.5 KB
/
CrashRpt.h
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
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*************************************************************************************
This file is a part of CrashRpt library.
Copyright (c) 2003-2013 The CrashRpt project authors. All Rights Reserved.
Use of this source code is governed by a BSD-style license
that can be found in the License.txt file in the root of the source
tree. All contributing project authors may
be found in the Authors.txt file in the root of the source tree.
***************************************************************************************/
/*! \file CrashRpt.h
* \brief Defines the interface for the CrashRpt.DLL.
* \date 2003
* \author Michael Carruth
* \author Oleg Krivtsov (zeXspectrum)
*/
#ifndef _CRASHRPT_H_
#define _CRASHRPT_H_
#include <windows.h>
#include <dbghelp.h>
// Define SAL macros to be empty if some old Visual Studio used
#ifndef __reserved
#define __reserved
#endif
#ifndef __in
#define __in
#endif
#ifndef __in_opt
#define __in_opt
#endif
#ifndef __out_ecount_z
#define __out_ecount_z(x)
#endif
#ifdef __cplusplus
#define CRASHRPT_EXTERNC extern "C"
#else
#define CRASHRPT_EXTERNC
#endif
#define CRASHRPTAPI(rettype) CRASHRPT_EXTERNC rettype WINAPI
//! Current CrashRpt version
#define CRASHRPT_VER 1402
/*! \defgroup CrashRptAPI CrashRpt Functions */
/*! \defgroup DeprecatedAPI Obsolete Functions */
/*! \defgroup CrashRptStructs CrashRpt Structures */
/*! \defgroup CrashRptWrappers CrashRpt Wrapper Classes */
/*! \ingroup DeprecatedAPI
* \brief Client crash callback function prototype
* \param[in] lpvState Must be set to NULL.
*
* \remarks
*
* This function is deprecated, it is recommended to use \ref PFNCRASHCALLBACK()
* instead.
*
* The crash callback function is called when crash occurs. This way client application is
* notified about the crash.
*
* It is generally unsafe to do complex actions (e.g. memory allocation, heap operations) inside of this callback.
* The application state may be unstable.
*
* One reason the application may use this callback for is to close handles to open log files that the
* application plans to include into the error report. Files should be accessible for reading, otherwise
* CrashRpt won't be able to include them into error report.
*
* It is also possible (but not recommended) to add files, properties, desktop screenshots,
* registry keys inside of the crash callback function.
*
* The crash callback function should typically return \c TRUE to allow generate error report.
* Returning \c FALSE will prevent crash report generation.
*
* The following example shows how to use the crash callback function.
*
* \code
* // define the crash callback
* BOOL CALLBACK CrashCallback(LPVOID lpvState)
* {
* // Do something...
*
* return TRUE;
* }
* \endcode
*
* \sa crAddFile2(), PFNCRASHCALLBACK()
*/
typedef BOOL (CALLBACK *LPGETLOGFILE) (__reserved LPVOID lpvState);
// Exception types used in CR_EXCEPTION_INFO::exctype structure member.
#define CR_SEH_EXCEPTION 0 //!< SEH exception.
#define CR_CPP_TERMINATE_CALL 1 //!< C++ terminate() call.
#define CR_CPP_UNEXPECTED_CALL 2 //!< C++ unexpected() call.
#define CR_CPP_PURE_CALL 3 //!< C++ pure virtual function call (VS .NET and later).
#define CR_CPP_NEW_OPERATOR_ERROR 4 //!< C++ new operator fault (VS .NET and later).
#define CR_CPP_SECURITY_ERROR 5 //!< Buffer overrun error (VS .NET only).
#define CR_CPP_INVALID_PARAMETER 6 //!< Invalid parameter exception (VS 2005 and later).
#define CR_CPP_SIGABRT 7 //!< C++ SIGABRT signal (abort).
#define CR_CPP_SIGFPE 8 //!< C++ SIGFPE signal (flotating point exception).
#define CR_CPP_SIGILL 9 //!< C++ SIGILL signal (illegal instruction).
#define CR_CPP_SIGINT 10 //!< C++ SIGINT signal (CTRL+C).
#define CR_CPP_SIGSEGV 11 //!< C++ SIGSEGV signal (invalid storage access).
#define CR_CPP_SIGTERM 12 //!< C++ SIGTERM signal (termination request).
/*! \ingroup CrashRptStructs
* \brief This structure contains information about the crash.
*
* The information provided by this structure includes the exception type, exception code,
* exception pointers and so on. These are needed to generate crash minidump file and
* provide the developer with other information about the error. This structure is used by
* the crGenerateErrorReport() function. Pointer to this structure is also passed to the
* crash callback function (see the \ref PFNCRASHCALLBACK() function prototype).
*
* Structure members details are provided below:
*
* \b cb [in]
*
* This must contain the size of this structure in bytes.
*
* \b pexcptrs [in, optional]
*
* Should contain the exception pointers. If this parameter is NULL,
* the current CPU state is used to generate exception pointers.
*
* \b exctype [in]
*
* The type of exception. This parameter may be one of the following:
* - \ref CR_SEH_EXCEPTION SEH (Structured Exception Handling) exception
* - \ref CR_CPP_TERMINATE_CALL C++ terminate() function call
* - \ref CR_CPP_UNEXPECTED_CALL C++ unexpected() function call
* - \ref CR_CPP_PURE_CALL Pure virtual method call (Visual Studio .NET 2003 and later)
* - \ref CR_CPP_NEW_OPERATOR_ERROR C++ 'new' operator error (Visual Studio .NET 2003 and later)
* - \ref CR_CPP_SECURITY_ERROR Buffer overrun (Visual Studio .NET 2003 only)
* - \ref CR_CPP_INVALID_PARAMETER Invalid parameter error (Visual Studio 2005 and later)
* - \ref CR_CPP_SIGABRT C++ SIGABRT signal
* - \ref CR_CPP_SIGFPE C++ floating point exception
* - \ref CR_CPP_SIGILL C++ illegal instruction
* - \ref CR_CPP_SIGINT C++ SIGINT signal
* - \ref CR_CPP_SIGSEGV C++ invalid storage access
* - \ref CR_CPP_SIGTERM C++ termination request
*
* \b code [in, optional]
*
* Used if \a exctype is \ref CR_SEH_EXCEPTION and represents the SEH exception code.
* If \a pexptrs is NULL, this value is used when generating exception information for initializing
* \c pexptrs->ExceptionRecord->ExceptionCode member, otherwise it is ignored.
*
* \b fpe_subcode [in, optional]
*
* Used if \a exctype is equal to \ref CR_CPP_SIGFPE. It defines the floating point
* exception subcode (see \c signal() function ducumentation in MSDN).
*
* \b expression, \b function, \b file and \b line [in, optional]
*
* These parameters are used when \a exctype is \ref CR_CPP_INVALID_PARAMETER.
* These members are typically non-zero when using debug version of CRT.
*
* \b bManual [in]
*
* Since v.1.2.4, \a bManual parameter should be equal to TRUE if the report is generated manually.
* The value of \a bManual parameter affects the automatic application restart behavior. If the application
* restart is requested by the \ref CR_INST_APP_RESTART flag of CR_INSTALL_INFO::dwFlags structure member,
* and if \a bManual is FALSE, the application will be
* restarted after error report generation. If \a bManual is TRUE, the application won't be restarted.
*
* \b hSenderProcess [out]
*
* As of v.1.2.8, \a hSenderProcess parameter will contain the handle to the <b>CrashSender.exe</b> process when
* \ref crGenerateErrorReport function returns. The caller may use this handle to wait until <b>CrashSender.exe</b>
* process exits and check the exit code. When the handle is not needed anymore, release it with the \b CloseHandle() function.
*/
typedef struct tagCR_EXCEPTION_INFO
{
WORD cb; //!< Size of this structure in bytes; should be initialized before using.
PEXCEPTION_POINTERS pexcptrs; //!< Exception pointers.
int exctype; //!< Exception type.
DWORD code; //!< Code of SEH exception.
unsigned int fpe_subcode; //!< Floating point exception subcode.
const wchar_t* expression; //!< Assertion expression.
const wchar_t* function; //!< Function in which assertion happened.
const wchar_t* file; //!< File in which assertion happened.
unsigned int line; //!< Line number.
BOOL bManual; //!< Flag telling if the error report is generated manually or not.
HANDLE hSenderProcess; //!< Handle to the CrashSender.exe process.
}
CR_EXCEPTION_INFO;
typedef CR_EXCEPTION_INFO* PCR_EXCEPTION_INFO;
// Stages of crash report generation (used by the crash callback function).
#define CR_CB_STAGE_PREPARE 10 //!< Stage after exception pointers've been retrieved.
#define CR_CB_STAGE_FINISH 20 //!< Stage after the launch of CrashSender.exe process.
/*! \ingroup CrashRptStructs
* \struct CR_CRASH_CALLBACK_INFOW()
* \brief This structure contains information passed to crash callback function PFNCRASHCALLBACK().
*
* \remarks
*
* The information contained in this structure may be used by the crash callback function
* to determine what type of crash has occurred and perform some action. For example,
* the client application may prefer to continue its execution on some type of crash, and
* terminate itself on another type of crash.
*
* Below, the stucture fields are described:
*
* \b cb [in]
*
* This contains the size of this structure in bytes.
*
* \b nStage [in]
*
* This field specifies the crash report generation stage. The callback function
* can be called once per each stage (depending on callback function's return value).
* Currently, there are two stages:
* - \ref CR_CB_STAGE_PREPARE Stage after exception pointers've been retrieved.
* - \ref CR_CB_STAGE_FINISH Stage after the launch of CrashSender.exe process.
*
* \b pszErrorReportFolder [in]
*
* This field contains the absolute path to the directory containing uncompressed
* crash report files.
*
* \b pExceptionInfo [in]
*
* This field contains a pointer to \ref CR_EXCEPTION_INFO structure.
*
* \b pUserParam [in, optional]
*
* This is a pointer to user-specified data passed to the crSetCrashCallback() function
* as \b pUserParam argument.
*
* \b bContinueExecution [in, out]
*
* This field is set to FALSE by default. The crash callback function may set it
* to true if it wants to continue its execution after crash report generation
* (otherwise the program will be terminated).
*
*
* \ref CR_CRASH_CALLBACK_INFOW and \ref CR_CRASH_CALLBACK_INFOA are
* wide-character and multi-byte character versions of \ref CR_CRASH_CALLBACK_INFO
* structure. In your program, use the \ref CR_CRASH_CALLBACK_INFO typedef which
* is a character-set-independent version of the structure name.
*
* \sa PFNCRASHCALLBACK()
*/
typedef struct tagCR_CRASH_CALLBACK_INFOW
{
WORD cb; //!< Size of this structure in bytes.
int nStage; //!< Stage.
LPCWSTR pszErrorReportFolder; //!< Directory where crash report files are located.
CR_EXCEPTION_INFO* pExceptionInfo; //!< Pointer to information about the crash.
LPVOID pUserParam; //!< Pointer to user-defined data.
BOOL bContinueExecution; //!< Whether to terminate the process (the default) or to continue program execution.
}
CR_CRASH_CALLBACK_INFOW;
/*! \ingroup CrashRptStructs
* \struct CR_CRASH_CALLBACK_INFOA
* \copydoc CR_CRASH_CALLBACK_INFOW
*/
typedef struct tagCR_CRASH_CALLBACK_INFOA
{
WORD cb; //!< Size of this structure in bytes.
int nStage; //!< Stage.
LPCSTR pszErrorReportFolder; //!< Directory where crash report files are located.
CR_EXCEPTION_INFO* pExceptionInfo; //!< Pointer to information about the crash.
LPVOID pUserParam; //!< Pointer to user-defined data.
BOOL bContinueExecution; //!< Whether to terminate the process (the default) or to continue program execution.
}
CR_CRASH_CALLBACK_INFOA;
/*! \brief Character set-independent mapping of CR_CRASH_CALLBACK_INFOW and CR_CRASH_CALLBACK_INFOA structures.
* \ingroup CrashRptStructs
*/
#ifdef UNICODE
typedef CR_CRASH_CALLBACK_INFOW CR_CRASH_CALLBACK_INFO;
#else
typedef CR_CRASH_CALLBACK_INFOA CR_CRASH_CALLBACK_INFO;
#endif // UNICODE
// Constants that may be returned by the crash callback function.
#define CR_CB_CANCEL 0 //!< Cancel crash report generation on the current stage.
#define CR_CB_DODEFAULT 1 //!< Proceed to the next stages of crash report generation without calling crash callback function.
#define CR_CB_NOTIFY_NEXT_STAGE 2 //!< Proceed and call the crash callback for the next stage.
/*! \ingroup CrashRptAPI
* \brief Client crash callback function prototype.
* \param[in] pInfo Points to information about the crash.
*
* \remarks
*
* The crash callback function is called when a crash occurs. This way client application is
* notified about the crash.
*
* Crash information is passed by CrashRpt to the callback function through the \b pInfo parameter as
* a pointer to \ref CR_CRASH_CALLBACK_INFO structure. See below for a code example.
*
* It is generally unsafe to do complex actions (e.g. memory allocation, heap operations) inside of this callback.
* The application state may be unstable.
*
* One reason the application may use this callback for is to close handles to open log files that the
* application plans to include into the error report. Files should be accessible for reading, otherwise
* CrashRpt won't be able to include them into error report.
*
* It is also possible (but not recommended) to add files (see crAddFile2()),
* properties (see crAddProperty()), desktop screenshots (see crAddScreenshot2())
* and registry keys (see crAddRegKey()) inside of the crash callback function.
*
* By default, CrashRpt terminates the client application after crash report generation and
* launching the <i>CrashSender.exe</i> process. However, it is possible to continue program
* execution after crash report generation by seting \ref CR_CRASH_CALLBACK_INFO::bContinueExecution
* structure field to \a TRUE.
*
* The crash report generation consists of several stages. First, exception pointers are retrieved
* and the callback function is called for the first time. The callback function may check the
* retrieved exception information and decide wheter to proceed with crash report generation or to
* continue client program execution. On the next stage, the \a CrashSender.exe
* process is launched and the crash callback function is (optionally) called for the second time.
* Further crash report data collection and delivery work is performed in \a CrashSender.exe process.
* The crash callback may use the provided handle to \a CrashSender.exe process to wait until it exits.
*
* The crash callback function should typically return \ref CR_CB_DODEFAULT constant to proceed
* with error report generation without being called back on the next stage(s). Returning the
* \ref CR_CB_NOTIFY_NEXT_STAGE constant causes CrashRpt to call the crash callback function on the next
* stage, too. Returning \ref CR_CB_CANCEL constant will prevent further stage(s) of crash report generation.
*
* \ref PFNCRASHCALLBACKW() and \ref PFNCRASHCALLBACKA() are
* wide-character and multi-byte character versions of \ref PFNCRASHCALLBACK()
* function.
*
* The following code example shows the simplest way of using the crash callback function:
*
* \code
* // Define the crash callback
* int CALLBACK CrashCallback(CR_CRASH_CALLBACK_INFO* pInfo)
* {
*
* // Do something...
*
* // Proceed with crash report generation.
* // This return code also makes CrashRpt to not call this callback function for
* // the next crash report generation stage.
* return CR_CB_DODEFAULT;
* }
* \endcode
*
* The following code example shows how to use the crash callback function to be notified
* on every stage of crash report generation:
*
* \code
* // Define the crash callback
* int CALLBACK CrashCallback(CR_CRASH_CALLBACK_INFO* pInfo)
* {
*
* // We want to continue program execution after crash report generation
* pInfo->bContinueExecution = TRUE;
*
* switch(pInfo->nStage)
* {
* case CR_CB_STAGE_PREPARE:
* // do something
* break;
* case CR_CB_STAGE_FINISH:
* // do something
* break;
* }
*
* // Proceed to the next stage.
* return CR_CB_NOTIFY_NEXT_STAGE;
* }
* \endcode
*
* \sa CR_CRASH_CALLBACK_INFO, crSetCrashCallback(), crAddFile2(), crAddProperty(), crAddScreenshot2(), crAddRegKey()
*/
typedef int (CALLBACK *PFNCRASHCALLBACKW) (CR_CRASH_CALLBACK_INFOW* pInfo);
/*! \ingroup CrashRptAPI
* \copydoc PFNCRASHCALLBACKW()
*/
typedef int (CALLBACK *PFNCRASHCALLBACKA) (CR_CRASH_CALLBACK_INFOA* pInfo);
/*! \brief Character set-independent mapping of \ref PFNCRASHCALLBACKW() and \ref PFNCRASHCALLBACKA() function prototrypes.
* \ingroup CrashRptStructs
*/
#ifdef UNICODE
typedef PFNCRASHCALLBACKW PFNCRASHCALLBACK;
#else
typedef PFNCRASHCALLBACKA PFNCRASHCALLBACK;
#endif // UNICODE
/*! \ingroup CrashRptAPI
* \brief Sets the crash callback function.
*
* \return This function returns zero if succeeded. Use crGetLastErrorMsg() to retrieve the error message on fail.
*
* \param[in] pfnCallbackFunc Pointer to the crash callback function.
* \param[in] lpParam User defined parameter. Optional.
*
* \remarks
*
* Use this to set the crash callback function that will be called on crash. This function
* is available since v.1.4.0.
*
* For the crash callback function prototype, see documentation for PFNCRASHCALLBACK().
*
* Optional \b lpParam parameter can be a pointer to user-defined data. It will be passed to the
* crash callback function as \ref CR_CRASH_CALLBACK_INFO::pUserParam structure member.
*
* \sa
* PFNCRASHCALLBACK()
*/
CRASHRPTAPI(int)
crSetCrashCallbackW(
PFNCRASHCALLBACKW pfnCallbackFunc,
LPVOID lpParam
);
/*! \ingroup CrashRptAPI
* \copydoc crSetCrashCallbackW()
*/
CRASHRPTAPI(int)
crSetCrashCallbackA(
PFNCRASHCALLBACKA pfnCallbackFunc,
LPVOID lpParam
);
/*! \brief Character set-independent mapping of crSetCrashCallbackW() and crSetCrashCallbackA() functions.
* \ingroup CrashRptAPI
*/
#ifdef UNICODE
#define crSetCrashCallback crSetCrashCallbackW
#else
#define crSetCrashCallback crSetCrashCallbackA
#endif //UNICODE
// Array indices for CR_INSTALL_INFO::uPriorities.
#define CR_HTTP 0 //!< Send error report via HTTP (or HTTPS) connection.
#define CR_SMTP 1 //!< Send error report via SMTP connection.
#define CR_SMAPI 2 //!< Send error report via simple MAPI (using default mail client).
//! Special priority constant that allows to skip certain delivery method.
#define CR_NEGATIVE_PRIORITY ((UINT)-1)
// Flags for CR_INSTALL_INFO::dwFlags
#define CR_INST_STRUCTURED_EXCEPTION_HANDLER 0x1 //!< Install SEH handler (deprecated name, use \ref CR_INST_SEH_EXCEPTION_HANDLER instead).
#define CR_INST_SEH_EXCEPTION_HANDLER 0x1 //!< Install SEH handler.
#define CR_INST_TERMINATE_HANDLER 0x2 //!< Install terminate handler.
#define CR_INST_UNEXPECTED_HANDLER 0x4 //!< Install unexpected handler.
#define CR_INST_PURE_CALL_HANDLER 0x8 //!< Install pure call handler (VS .NET and later).
#define CR_INST_NEW_OPERATOR_ERROR_HANDLER 0x10 //!< Install new operator error handler (VS .NET and later).
#define CR_INST_SECURITY_ERROR_HANDLER 0x20 //!< Install security error handler (VS .NET and later).
#define CR_INST_INVALID_PARAMETER_HANDLER 0x40 //!< Install invalid parameter handler (VS 2005 and later).
#define CR_INST_SIGABRT_HANDLER 0x80 //!< Install SIGABRT signal handler.
#define CR_INST_SIGFPE_HANDLER 0x100 //!< Install SIGFPE signal handler.
#define CR_INST_SIGILL_HANDLER 0x200 //!< Install SIGILL signal handler.
#define CR_INST_SIGINT_HANDLER 0x400 //!< Install SIGINT signal handler.
#define CR_INST_SIGSEGV_HANDLER 0x800 //!< Install SIGSEGV signal handler.
#define CR_INST_SIGTERM_HANDLER 0x1000 //!< Install SIGTERM signal handler.
#define CR_INST_ALL_POSSIBLE_HANDLERS 0x1FFF //!< Install all possible exception handlers.
#define CR_INST_CRT_EXCEPTION_HANDLERS 0x1FFE //!< Install exception handlers for the linked CRT module.
#define CR_INST_NO_GUI 0x2000 //!< Do not show GUI, send report silently (use for non-GUI apps only).
#define CR_INST_HTTP_BINARY_ENCODING 0x4000 //!< Deprecated, do not use.
#define CR_INST_DONT_SEND_REPORT 0x8000 //!< Don't send error report immediately, just save it locally.
#define CR_INST_APP_RESTART 0x10000 //!< Restart the application on crash.
#define CR_INST_NO_MINIDUMP 0x20000 //!< Do not include minidump file to crash report.
#define CR_INST_SEND_QUEUED_REPORTS 0x40000 //!< CrashRpt should send error reports that are waiting to be delivered.
#define CR_INST_STORE_ZIP_ARCHIVES 0x80000 //!< CrashRpt should store both uncompressed error report files and ZIP archives.
#define CR_INST_SEND_MANDATORY 0x100000 //!< This flag removes the "Close" and "Other actions" buttons from Error Report dialog, thus making the sending procedure mandatory for user.
#define CR_INST_SHOW_ADDITIONAL_INFO_FIELDS 0x200000 //!< Makes "Your E-mail" and "Describe what you were doing when the problem occurred" fields of Error Report dialog always visible.
#define CR_INST_ALLOW_ATTACH_MORE_FILES 0x400000 //!< Adds an ability for user to attach more files to crash report by clicking "Attach More File(s)" item from context menu of Error Report Details dialog.
#define CR_INST_AUTO_THREAD_HANDLERS 0x800000 //!< If this flag is set, installs exception handlers for newly created threads automatically.
/*! \ingroup CrashRptStructs
* \struct CR_INSTALL_INFOW()
* \brief This structure defines the general information used by crInstallW() function.
*
* \remarks
*
* \ref CR_INSTALL_INFOW and \ref CR_INSTALL_INFOA structures are wide-character and multi-byte character
* versions of \ref CR_INSTALL_INFO. \ref CR_INSTALL_INFO typedef defines character set independent mapping.
*
* Below, structure members are described in details. Required parameters must always be specified, while optional
* ones may be set with 0 (zero) or NULL. Most of parameters are optional.
*
* \b cb [in, required]
*
* This must contain the size of this structure in bytes.
*
* \b pszAppName [in, optional]
*
* This is the friendly name of the client application. The application name is
* displayed in the Error Report dialog. If this parameter is NULL, the name of EXE file
* that was used to start caller process becomes the application name.
*
* \b pszAppVersion [in, optional]
*
* Should be the application version. Example: "1.0.1".
*
* If this equals to NULL, product version is extracted from the executable file which started
* the caller process, and this product version is used as application version. If the executable file
* doesn's have a version info resource, the \ref crInstall() function will fail.
*
* \b pszEmailTo [in, optional]
*
* This is the email address of the recipient of error reports (or several E-mail adresses separated with semicolon),
* for example "[email protected]" or "[email protected];[email protected]". If several E-mail addresses are
* specified, error report will be delivered to each of them. If this parameter equals to NULL,
* the crash report won't be sent using E-mail client.
*
* Keep this NULL if you plan to use large error reports (more than several MB in size), because
* large emails may be rejected by the mail server.
*
* \b pszEmailSubject [in, optional]
*
* This is the subject of the email message. If this parameter is NULL,
* the default subject of form '[app_name] [app_version] Error Report' is generated.
*
* \a pszUrl is the URL of a server-side script that would receive crash report data via HTTP or HTTPS
* connection. If this parmeter is NULL, HTTP(S) connection won't be used to send crash reports. For
* example of a server-side script that can receive crash reports, see \ref sending_error_reports.
*
* HTTP(S) transport is the recommended way of sending large error reports (more than several MB in size).
* To define a custom port for HTTP(S) connection, use the following URL format: "http://example.com[:port]/crashrpt.php" or
* "https://example.com[:port]/crashrpt.php", where optional \a port is the placeholder for the port number.
*
* \b pszCrashSenderPath [in, optional]
*
* This is the absolute path to the directory where CrashSender.exe is located.
* The crash sender process is responsible for letting end user know about the crash and
* sending the error report. If this is NULL, it is assumed that CrashSender.exe is located in
* the same directory as CrashRpt.dll.
*
*
* \b uPriorities [in, optional]
*
* This is an array that defines the preferred methods of sending error reports.
* The available methods are: HTTP (or HTTPS) connection, SMTP connection or simple MAPI (default mail client).
*
* A priority is a non-negative integer number or special constant \ref CR_NEGATIVE_PRIORITY.
* The greater positive number defines the greater priority.
* Specify the \ref CR_NEGATIVE_PRIORITY to skip the given delivery method.
*
* The element having index \ref CR_HTTP defines priority for using HTML connection.
* The element having index \ref CR_SMTP defines priority for using SMTP connection.
* The element having index \ref CR_SMAPI defines priority for using the default mail client.
*
* The methods having greater priority will be tried first. If priorities are equal to each other, HTTP (or HTTPS)
* connection will be tried the first, SMTP connection will be tried the second and simple MAPI will be tried
* the last.
*
* \b dwFlags [in, optional]
*
* Since v1.1.2, \a dwFlags can be used to define behavior parameters. This can be a combination of the following values:
*
* <table>
* <tr><td colspan="2"> <i>Use the combination of the following constants to specify what exception handlers to install:</i>
* <tr><td> \ref CR_INST_ALL_POSSIBLE_HANDLERS <td> Install all available exception handlers.
* <tr><td> \ref CR_INST_SEH_EXCEPTION_HANDLER <td> Install SEH exception handler.
* <tr><td> \ref CR_INST_PURE_CALL_HANDLER <td> Install pure call handler (VS .NET and later).
* <tr><td> \ref CR_INST_NEW_OPERATOR_ERROR_HANDLER <td> Install new operator error handler (VS .NET and later).
* <tr><td> \ref CR_INST_SECURITY_ERROR_HANDLER <td> Install security errror handler (VS .NET and later).
* <tr><td> \ref CR_INST_INVALID_PARAMETER_HANDLER <td> Install invalid parameter handler (VS 2005 and later).
* <tr><td> \ref CR_INST_SIGABRT_HANDLER <td> Install SIGABRT signal handler.
* <tr><td> \ref CR_INST_SIGINT_HANDLER <td> Install SIGINT signal handler.
* <tr><td> \ref CR_INST_SIGTERM_HANDLER <td> Install SIGTERM signal handler.
* <tr><td colspan="2"> <i>Use the combination of the following constants to define behavior parameters:</i>
* <tr><td> \ref CR_INST_NO_GUI
* <td> <b>Available since v.1.2.2</b> Do not show GUI.
*
* It is not recommended to use this flag for regular GUI-based applications.
* Use this only for services that have no GUI.
* <tr><td> \ref CR_INST_DONT_SEND_REPORT
* <td> <b>Available since v.1.2.2</b> This parameter means 'do not send error report immediately on crash, just save it locally'.
* Use this if you have direct access to the machine where crash happens and do not need
* to send report over the Internet. You can use this in couple with \ref CR_INST_STORE_ZIP_ARCHIVES flag to store zipped error reports
* along with uncompressed error report files.
* <tr><td> \ref CR_INST_APP_RESTART
* <td> <b>Available since v.1.2.4</b> This parameter allows to automatically restart the application on crash. The command line
* for the application is taken from \a pszRestartCmdLine parameter. To avoid cyclic restarts of an application which crashes on startup,
* the application is restarted only if at least 60 seconds elapsed since its start.
* <tr><td> \ref CR_INST_NO_MINIDUMP
* <td> <b>Available since v.1.2.4</b> Specify this parameter if you want minidump file not to be included into crash report. The default
* behavior is to include the minidump file.
*
* <tr><td> \ref CR_INST_SEND_QUEUED_REPORTS
* <td> <b>Available since v.1.2.5</b> Specify this parameter to send all queued reports. Those
* report files are by default stored in <i>%LOCAL_APPDATA%\\CrashRpt\\UnsentCrashReports\\%AppName%_%AppVersion%</i> folder.
* If this is specified, CrashRpt checks if it's time to remind user about recent errors in the application and offers to send
* all queued error reports.
*
* <tr><td> \ref CR_INST_STORE_ZIP_ARCHIVES
* <td> <b>Available since v.1.2.7</b> This parameter can be used in couple with \ref CR_INST_DONT_SEND_REPORT flag to store not only uncompressed
* error report files, but also ZIP archives. By default (if this flag omitted) CrashRpt stores all error report files
* in uncompressed state.
*
* <tr><td> \ref CR_INST_SEND_MANDATORY
* <td> <b>Available since v.1.3.1</b> This parameter makes sending procedure mandatory by removing the "Close" button
* and "Other actions..." button from the Error Report dialog. Typically, it is not recommended to use this flag,
* unless you intentionally want users to always send error reports for your application.
* <tr><td> \ref CR_INST_SHOW_ADDITIONAL_INFO_FIELDS
* <td> <b>Available since v.1.3.1</b> This parameter makes "Your E-mail" and "Describe what you were doing when the
* problem occurred" fields of Error Report dialog always visible. By default (when this parameter not specified),
* these fields are hidden and user needs to click the "Provide additional info (recommended)" link to show them.
*
* <tr><td> \ref CR_INST_ALLOW_ATTACH_MORE_FILES
* <td> <b>Available since v.1.3.1</b> Adds an ability for user to attach more files to crash report by choosing
* "Attach More File(s)" item from context menu of Error Report Details dialog. By default this feature is disabled.
*
* <tr><td> \ref CR_INST_AUTO_THREAD_HANDLERS
* <td> <b>Available since v.1.4.2</b> Specifying this flag results in automatic installation of all available exception handlers to
* all threads that will be created in the future. This flag only works if CrashRpt is compiled as a DLL, it does
* not work if you compile CrashRpt as static library.
* </table>
*
* \b pszPrivacyPolicyURL [in, optional]
*
* This parameter defines the URL for the Privacy Policy hyperlink of the
* Error Report dialog. If this parameter is NULL, the link is not displayed. For information on
* the Privacy Policy, see \ref error_report. This parameter is available since v1.1.2.
*
* \b pszDebugHelpDLL [in, optional]
*
* This parameter defines the location of the dbghelp.dll to load.
* If this parameter is NULL, the dbghelp.dll is searched using the default search sequence.
* This parameter is available since v1.2.1.
*
* \b uMiniDumpType [in, optional]
*
* This parameter defines the minidump type. For the list of available minidump
* types, see the documentation for the MiniDumpWriteDump() function in MSDN.
* Parameter is available since v.1.2.1.
*
* It is recommended to set this
* parameter with zero (equivalent of MiniDumpNormal constant). Other values may increase the minidump
* size significantly.
*
* \b pszErrorReportSaveDir [in, optional]
*
* This parameter defines the directory where to save the error reports.
* If this is NULL, the default directory is used (%%LOCAL_APP_DATA%\\CrashRpt\\UnsentCrashReports\\%%AppName%%_%%AppVersion%).
* This parameter is available since v.1.2.2.
*
* \b pszRestartCmdLine [in, optional]
*
* This arameter defines the string that specifies the
* command-line arguments for the application when it is restarted (when using \ref CR_INST_APP_RESTART flag).
* Do not include the name of the executable in the command line; it is added automatically. This parameter
* can be NULL. Available since v.1.2.4.
*
* \b pszLangFilePath [in, optional]
*
* This parameter defines the absolute path (including file name) for language file.
* If this is NULL, the lang file is assumed to be located in the same dir as CrashSender.exe file and have
* the name crashrpt_lang.ini.
* This parameter is available since v.1.2.4.
*
* \b pszEmailText [in, optional]
*
* This parameter defines the custom E-mail text that is used when deliverying error report
* as E-mail. If this is NULL, the default E-mail text is used. It is recommended to set this parameter with NULL.
* This parameter is available since v.1.2.4.
*
* \b pszSmtpProxy [in, optional]
*
* This parameter defines the network address (IP or domain) and, optionally, port formatted as "address[:port]"
* of SMTP server. Examples: "192.168.1.1:2525", "mail.example.com:25".
* If this parameter is NULL, the SMTP server address is resolved using the MX record of recipient's mailbox.
* You should typically set this parameter with NULL, except in the
* case when your software is a server and custom SMTP configuration is required. This parameter is available since v.1.2.4.
*
* \b pszCustomSenderIcon [in, optional]
*
* This parameter can be used to define a custom icon for <i>Error Report</i> dialog. This parameter is
* available since v.1.2.8.
*
* The value of this parameter should be absolute path to the module containing the icon resource, followed
* by resource identifier separated by comma. You can set this parameter with NULL to use the default icon.
*
* The resource identifier is a zero-based index of the icon to retrieve. For example, if this value is 0,
* the first icon in the specified file is used. If the identifier is a negative number not equal to -1,
* the icon in the specified file whose resource identifier is equal to the absolute value of the resource
* identifier is used.
* Example: "D:\MyApp\Resources.dll, -128".
*
* \b pszSmtpLogin [in, optional]
*
* This parameter defines the login name for SMTP authentication. It is typically used together with
* \ref pszSmtpProxy and \ref pszSmtpPassword parameter.
* If this parameter is ommitted (NULL), no SMTP autentication is used. This parameter is available since v.1.3.1.
*
* \b pszSmtpPassword [in, optional]
*
* This parameter defines the password for SMTP authentication. It is used in pair with \ref pszSmtpLogin parameter.
* This parameter is available since v.1.3.1.
*/
typedef struct tagCR_INSTALL_INFOW
{
WORD cb; //!< Size of this structure in bytes; must be initialized before using!
LPCWSTR pszAppName; //!< Name of application.
LPCWSTR pszAppVersion; //!< Application version.
LPCWSTR pszEmailTo; //!< E-mail address of crash reports recipient.
LPCWSTR pszEmailSubject; //!< Subject of crash report e-mail.
LPCWSTR pszUrl; //!< URL of server-side script (used in HTTP connection).
LPCWSTR pszCrashSenderPath; //!< Directory name where CrashSender.exe is located.
LPGETLOGFILE pfnCrashCallback; //!< Deprecated, do not use.
UINT uPriorities[5]; //!< Array of error sending transport priorities.
DWORD dwFlags; //!< Flags.
LPCWSTR pszPrivacyPolicyURL; //!< URL of privacy policy agreement.
LPCWSTR pszDebugHelpDLL; //!< File name or folder of Debug help DLL.
MINIDUMP_TYPE uMiniDumpType; //!< Minidump type.
LPCWSTR pszErrorReportSaveDir; //!< Directory where to save error reports.
LPCWSTR pszRestartCmdLine; //!< Command line for application restart (without executable name).
LPCWSTR pszLangFilePath; //!< Path to the language file (including file name).
LPCWSTR pszEmailText; //!< Custom E-mail text (used when deliverying report as E-mail).
LPCWSTR pszSmtpProxy; //!< Network address and port to be used as SMTP proxy.
LPCWSTR pszCustomSenderIcon; //!< Custom icon used for Error Report dialog.
LPCWSTR pszSmtpLogin; //!< Login name used for SMTP authentication when sending error report as E-mail.
LPCWSTR pszSmtpPassword; //!< Password used for SMTP authentication when sending error report as E-mail.
}
CR_INSTALL_INFOW;
typedef CR_INSTALL_INFOW* PCR_INSTALL_INFOW;
/*! \ingroup CrashRptStructs
* \struct CR_INSTALL_INFOA
* \copydoc CR_INSTALL_INFOW
*/
typedef struct tagCR_INSTALL_INFOA
{
WORD cb; //!< Size of this structure in bytes; must be initialized before using!
LPCSTR pszAppName; //!< Name of application.
LPCSTR pszAppVersion; //!< Application version.
LPCSTR pszEmailTo; //!< E-mail address of crash reports recipient.
LPCSTR pszEmailSubject; //!< Subject of crash report e-mail.
LPCSTR pszUrl; //!< URL of server-side script (used in HTTP connection).
LPCSTR pszCrashSenderPath; //!< Directory name where CrashSender.exe is located.
LPGETLOGFILE pfnCrashCallback; //!< Deprecated, do not use.
UINT uPriorities[5]; //!< Array of error sending transport priorities.
DWORD dwFlags; //!< Flags.
LPCSTR pszPrivacyPolicyURL; //!< URL of privacy policy agreement.
LPCSTR pszDebugHelpDLL; //!< File name or folder of Debug help DLL.
MINIDUMP_TYPE uMiniDumpType; //!< Mini dump type.
LPCSTR pszErrorReportSaveDir; //!< Directory where to save error reports.
LPCSTR pszRestartCmdLine; //!< Command line for application restart (without executable name).
LPCSTR pszLangFilePath; //!< Path to the language file (including file name).
LPCSTR pszEmailText; //!< Custom E-mail text (used when deliverying report as E-mail).
LPCSTR pszSmtpProxy; //!< Network address and port to be used as SMTP proxy.
LPCSTR pszCustomSenderIcon; //!< Custom icon used for Error Report dialog.
LPCSTR pszSmtpLogin; //!< Login name used for SMTP authentication when sending error report as E-mail.
LPCSTR pszSmtpPassword; //!< Password used for SMTP authentication when sending error report as E-mail.
PFNCRASHCALLBACKA pfnCrashCallback2; //!< Crash callback function.
}
CR_INSTALL_INFOA;
typedef CR_INSTALL_INFOA* PCR_INSTALL_INFOA;
/*! \brief Character set-independent mapping of CR_INSTALL_INFOW and CR_INSTALL_INFOA structures.
* \ingroup CrashRptStructs
*/
#ifdef UNICODE
typedef CR_INSTALL_INFOW CR_INSTALL_INFO;
typedef PCR_INSTALL_INFOW PCR_INSTALL_INFO;
#else
typedef CR_INSTALL_INFOA CR_INSTALL_INFO;
typedef PCR_INSTALL_INFOA PCR_INSTALL_INFO;
#endif // UNICODE
/*! \ingroup CrashRptAPI
* \brief Installs exception handlers for the caller process.
*
* \return
* This function returns zero if succeeded.
*
* \param[in] pInfo General congiration information.
*
* \remarks
*
* This function installs unhandled exception filter for the caller process.
* It also installs various CRT exception/error handlers that function for all threads of the caller process.
* For more information, see \ref exception_handling
*
* Below is the list of installed handlers:
* - Top-level SEH exception filter [ \c SetUnhandledExceptionFilter() ]
* - C++ pure virtual call handler (Visual Studio .NET 2003 and later) [ \c _set_purecall_handler() ]
* - C++ invalid parameter handler (Visual Studio .NET 2005 and later) [ \c _set_invalid_parameter_handler() ]
* - C++ new operator error handler (Visual Studio .NET 2003 and later) [ \c _set_new_handler() ]
* - C++ buffer overrun handler (Visual Studio .NET 2003 only) [ \c _set_security_error_handler() ]
* - C++ abort handler [ \c signal(SIGABRT) ]
* - C++ illegal instruction handler [ \c signal(SIGINT) ]
* - C++ termination request [ \c signal(SIGTERM) ]
*
* In a multithreaded program, additionally use crInstallToCurrentThread2() function for each execution
* thread, except the main one.
*
* The \a pInfo parameter contains all required information needed to install CrashRpt.
*
* This function fails when \a pInfo->pszCrashSenderPath doesn't contain valid path to CrashSender.exe
* or when \a pInfo->pszCrashSenderPath is equal to NULL, but \b CrashSender.exe is not located in the
* directory where \b CrashRpt.dll located.
*
* On crash, the crash minidump file is created, which contains CPU information and
* stack trace information. Also XML file is created that contains additional
* information that may be helpful for crash analysis. These files along with several additional
* files added with crAddFile2() are packed to a single ZIP file.
*
* When crash information is collected, another process, <b>CrashSender.exe</b>, is launched
* and the process where crash had occured is terminated. The CrashSender process is
* responsible for letting the user know about the crash and send the error report.
*
* The error report can be sent over E-mail using address and subject passed to the
* function as \ref CR_INSTALL_INFO structure members. Another way of sending error report is an HTTP
* request using \a pszUrl member of \ref CR_INSTALL_INFO.
*
* This function may fail if an appropriate language file (\b crashrpt_lang.ini) is not found
* in the directory where the \b CrashSender.exe file is located.
*
* If this function fails, use crGetLastErrorMsg() to retrieve the error message.
*
* crInstallW() and crInstallA() are wide-character and multi-byte character versions of crInstall()
* function. The \ref crInstall macro defines character set independent mapping for these functions.
*
* For code example, see \ref simple_example.
*
* \sa crInstallW(), crInstallA(), crInstall(), CR_INSTALL_INFOW,
* CR_INSTALL_INFOA, CR_INSTALL_INFO, crUninstall(),
* CrAutoInstallHelper
*/
CRASHRPTAPI(int)
crInstallW(
__in PCR_INSTALL_INFOW pInfo
);
/*! \ingroup CrashRptAPI
* \copydoc crInstallW()
*/
CRASHRPTAPI(int)
crInstallA(
__in PCR_INSTALL_INFOA pInfo
);
/*! \brief Character set-independent mapping of crInstallW() and crInstallA() functions.
* \ingroup CrashRptAPI
*/
#ifdef UNICODE
#define crInstall crInstallW
#else
#define crInstall crInstallA
#endif //UNICODE
/*! \ingroup CrashRptAPI
* \brief Uninitializes the CrashRpt library and unsinstalls exception handlers previously installed with crInstall().
*
* \return
* This function returns zero if succeeded.
*
* \remarks
*
* Call this function on application exit to uninitialize the library and uninstall exception
* handlers previously installed with crInstall(). After function call, the exception handlers
* are restored to states they had before calling crInstall().
*
* This function fails if crInstall() wasn't previously called in context of the
* caller process.
*
* When this function fails, use the crGetLastErrorMsg() function to retrieve the error message.
*
* \sa crInstallW(), crInstallA(), crInstall(),
* CrAutoInstallHelper
*/
CRASHRPTAPI(int)
crUninstall();
/*! \ingroup CrashRptAPI
* \brief Installs exception handlers to the caller thread.
* \return This function returns zero if succeeded.
* \param[in] dwFlags Flags.
*
* \remarks
*
* This function is available <b>since v.1.1.2</b>.
*
* The function sets exception handlers for the caller thread. If you have
* several execution threads, you ought to call the function for each thread,
* except the main one.
*
* \a dwFlags defines what exception handlers to install. Use zero value
* to install all possible exception handlers. Or use a combination of the following constants:
*
* - \ref CR_INST_TERMINATE_HANDLER Install terminate handler
* - \ref CR_INST_UNEXPECTED_HANDLER Install unexpected handler
* - \ref CR_INST_SIGFPE_HANDLER Install SIGFPE signal handler
* - \ref CR_INST_SIGILL_HANDLER Install SIGILL signal handler
* - \ref CR_INST_SIGSEGV_HANDLER Install SIGSEGV signal handler
*
* Example:
*
* \code
* DWORD WINAPI ThreadProc(LPVOID lpParam)
* {
* // Install exception handlers
* crInstallToCurrentThread2(0);
*
* // Your code...
*
* // Uninstall exception handlers
* crUninstallFromCurrentThread();
*
* return 0;
* }
* \endcode
*
* \sa
* crInstall()
*/
CRASHRPTAPI(int)
crInstallToCurrentThread2(DWORD dwFlags);
/*! \ingroup CrashRptAPI
* \brief Uninstalls C++ exception handlers from the current thread.
* \return This function returns zero if succeeded.
*
* \remarks
*
* This function unsets exception handlers from the caller thread. If you have
* several execution threads, you ought to call the function for each thread.
* After calling this function, the exception handlers for current thread are
* replaced with the handlers that were before call of crInstallToCurrentThread2().
*
* This function fails if crInstallToCurrentThread2() wasn't called for current thread.
*
* When this function fails, use crGetLastErrorMsg() to retrieve the error message.
*
* No need to call this function for the main execution thread. The crUninstall()
* will automatically uninstall C++ exception handlers for the main thread.
*
* \sa crInstallToCurrentThread2(),
* crUninstallFromCurrentThread(), CrThreadAutoInstallHelper
*/
CRASHRPTAPI(int)
crUninstallFromCurrentThread();
// Flags for crAddFile2() function.
#define CR_AF_TAKE_ORIGINAL_FILE 0 //!< Take the original file (do not copy it to the error report folder).
#define CR_AF_MAKE_FILE_COPY 1 //!< Copy the file to the error report folder.
#define CR_AF_FILE_MUST_EXIST 0 //!< Function will fail if file doesn't exist at the moment of function call.
#define CR_AF_MISSING_FILE_OK 2 //!< Do not fail if file is missing (assume it will be created later).
#define CR_AF_ALLOW_DELETE 4 //!< If this flag is specified, the file will be deletable from context menu of Error Report Details dialog.
/*! \ingroup CrashRptAPI
* \brief Adds a file to crash report.
*
* \return This function returns zero if succeeded.
*
* \param[in] pszFile Absolute path to the file (or file search pattern) to add to crash report, required.
* \param[in] pszDestFile Destination file name, optional.
* \param[in] pszDesc File description (used in Error Report Details dialog), optional.
* \param[in] dwFlags Flags, optional.
*
* This function can be called anytime after crInstall() to add one or more
* files to the generated crash report.
*
* When this function is called, the file is marked to be added to the error report,
* then the function returns control to the caller.
* When a crash occurs, all marked files are added to the report by the \b CrashSender.exe process.
* If a file is locked by someone for exclusive access, the file won't be included.
* Inside of \ref PFNCRASHCALLBACK() crash callback,
* close open file handles and ensure files to be included are acessible for reading.
*
* \a pszFile should be either a valid absolute path to the file or a file search
* pattern (e.g. "*.log") to be added to crash report.
*
* \a pszDestFile should be the name of destination file. This parameter can be used
* to specify different file name for the file in ZIP archive. If this parameter is NULL, the pszFile
* file name is used as destination file name. If \a pszFile is a search pattern, this argument
* is ignored.
*
* \a pszDesc is a short description of the file. It can be NULL.
*
* \a dwFlags parameter defines the behavior of the function. This can be a combination of the following flags: