Piyush Hari

Hi,

I have developed a windows client application in Visual C++ . I am now developing an Error-Reporting feature so that whenever my application crashes, I can report it to my server. My simplest algorithm will be :

1) detect a crash
2) pop up the UI to let the user send additional data
3) send crash data + user's additional data

First, I want to know how can I detect an application crash on windows

Take Care,
Piyush


Re: Visual C++ General How do I detect an application crash ?

Christopher Prest

The simplest way is creating a daemon or a windows service that is running external to your code that checks to see if it crashes.

pseudo:

1) start main.exe program

2) main.exe does a system call to run daemon.exe or start a daemon service

3) daemon.exe starts up and watches main.exe, if main.exe drops out of the process list scope, do something (i.e. restart main.exe or send an email to the owner)

this is a quick and easy cross platform way of doing it.




Re: Visual C++ General How do I detect an application crash ?

Piyush Hari

Thanks Christopher,

Can you let me know how daemon service can check if main.exe drops out of the process list scope. Thats what I am looking for precisely.

Thanks again,
Piyush





Re: Visual C++ General How do I detect an application crash ?

Simple Samples

It is not clear to me whether you intend to do this for all applications or for just the ones you have developed. I will assume you need to do this just for your applications. I think you should report errors from within your application, not from a monitor, whenever possible; for one reason, you can report more information that way.

For questions about external error reporting, you are more likely to get better answers in a forum or newsgroup in which your question is within the scope of the forum or newsgroup.

One thing you might look at is the Microsoft Online Crash Analysis (OCA). Have you ever had a crash or other error and then Windows asks to send an error report back to Microsoft I think but I am not sure that you can get use of that facility too for your applications.






Re: Visual C++ General How do I detect an application crash ?

Simple Samples

Note that Christopher's answer is a cross-platform solution. Windows does not have daemons; a Windows service is the equivalent of a Unix daemon. I think that Christopher is providing a solution using Unix terminology and API.

There are many critical design descisions you need to make that you have not provided answers to, at least not here.

Should the monitored application be independent of the monitor In other words, is it sufficient for the monitored application to start the monitor, or should the monitor start independently without depending on the monitored application to do anything If they are to be independent, then how is the monitor going to detect the monitored application If you use the filename of the exe then what happens if someone renames it and/or executes a different program with the same name Even if the filename is the same name, then a totally different file can be have the same name. So the solution might depend on the purpose, whether for security or for reliability.






Re: Visual C++ General How do I detect an application crash ?

Piyush Hari

To be clear, I am looking for an error reporting program similar to Windows Error Reporting in which , when an application crashes, the crash dump is sent to the server. I want this for ONLY my application. As Christopher suggested, I will have an external windows service monitoring my application and as soon as my application fails, it will pop up a send error report and once the user clicks it, the crash dump will be sent over.




Re: Visual C++ General How do I detect an application crash ?

Piyush Hari

Simple, I agree with you - I can report more information from within my application. My main concern is that if the application crashes, do you think, the function that reports that information will still work I doubt it. Thats why I was looking for an external monitoring tool.





Re: Visual C++ General How do I detect an application crash ?

kbjorklu

You could sign up to WER, which you already mentioned. Then your crash reports get sent to a Microsoft server, and you can browse them there. I haven't done this myself, so I don't know what the costs and sign up requirements are.

Another way is to use your own crash handler by SetUnhandledExceptionFilter. In the crash handler, you can use MiniDumpWriteDump to create a stack trace of the crash, and then e.g. use MAPISendMail to send the dump to you by e-mail.




Re: Visual C++ General How do I detect an application crash ?

Simple Samples

Piyush Hari wrote:
if the application crashes, do you think, the function that reports that information will still work I doubt it.
I don't doubt it. If you are careful, catastrophic errors will be rare. Windows and C++ have many ways to prevent and detect errors. Their intent is to make monitors as you describe unnecesary as much as possible.

Have you used any other application that has a special monitor for it