sumit kr

I am not clear about ThreadHijacker tool to test my application.It inserts /AV in to the app.

I think that there must be the code to handle the structerd exception in my app.

so i am trying to use following code :

#include "stdafx.h"

#include <windows.h>

#include "errorrep.h"

static LONG WINAPI ExceptionFilter( struct _EXCEPTION_POINTERS * pExceptionPointers );

int _tmain(int argc, _TCHAR* argv[])

{

DWORD *pdw = NULL;

BOOL fUseGlobalExceptionFilter = FALSE;

if (argc > 1 && _stricmp(argv[1], "UseGlobalFilter") == 0)

{

LPTOP_LEVEL_EXCEPTION_FILTER myfunc = SetUnhandledExceptionFilter(ExceptionFilter);

if(myfunc == NULL){

exit(0); }

// cause a fault

*pdw = 1;

SetUnhandledExceptionFilter(ExceptionFilter);

}

else

{

__try

{

// cause a fault

*pdw = 1;

}__except(ExceptionFilter(GetExceptionInformation()))

{ }

}

return 0;

}

static LONG WINAPI ExceptionFilter( struct _EXCEPTION_POINTERS * pExceptionPointers )

{

LONG lRet = EXCEPTION_CONTINUE_SEARCH;

HMODULE hFaultRepDll = LoadLibrary( _T("FaultRep.dll")) ;

if ( hFaultRepDll )

{

pfn_REPORTFAULT pfn = (pfn_REPORTFAULT)GetProcAddress( hFaultRepDll,

_T("ReportFault") ) ;

if ( pfn )

{

EFaultRepRetVal rc = pfn( pExceptionPointers, 0) ;

lRet = EXCEPTION_EXECUTE_HANDLER;

}

FreeLibrary(hFaultRepDll );

}return lRet ;

}

Here I am trying two approches to handle exception : 1) Thru SetUnhandledExceptionFilter

2) Thru TRy-Catch block..

2 is ok and working but i cant use it in my app becoz my app is MDI appl and on using it , error comes of unwinding object function..

WIth 1st option i am tring hard but not successful as SetUnHandledExceptionFilter returns NULL value everytime. even after Kerne32.dll is loaded....

As i think that this func. ,i can easily use in my App class to handle all top-level exceptions as it is in the main thread..

Please provide me any soloutions...

Thanks!




Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

Matthew Braun - MSFT

Hello sumit kr,

ThreadHijacker attempts to hijack the thread it is pointed to by the user, hence causing an A/V or Access Violation in the address space. Taking the text verbatim, it states that the application UI thread should only handle exceptions that are known and expected. Any unexpected exceptions such as an access violation should be handled by WER. I dont think you need to write any WER code in your application (unless you want to). Simply put, do not include a try/catch block arround your applications main function/method. For the logo cert you must signup for a WinQual account so you will get access to WER.

Thanks!

Matthew Braun






Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

sumit kr

Hi ,

Firstly, thanks for ur useful reply. As u said there is no need to write a code but on injecting a/v from Threadhijacker to my exe , it gets crashed and closed without repoting any wer dialog box. Also I want to ask that on XP there is different wer dialog box appears while on Vista 32 bit it is different, is it ok

Also on WinQual site they mentioned to use REportFault api in ur code.

So, Plz clear my understanding and also provide any solution in this regard.

Thanks !






Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

Matthew Braun - MSFT

Hello sumit kr,

Are you enclosing your main method in a generic try/catch block of some sorts As I stated before, this test case is essentially verifying that your application UI thread only handles known exceptions such as custom exceptions or invalid argument exceptions and not unknown exceptions caused by external processes (which is what TheadHijacker is doing). The differences in the WER dialog box between Windows versions is ok, these are changes that Microsoft has made to make the UI more intuitive to end users. Also the ReportFault API you have mentioned has been decrimented, please use the new WERAPI described here

http://msdn2.microsoft.com/en-us/library/ms681656.aspx

They state this because you have better control of your applications error reporting when utilizing this API which by the way has been VASTLY improved since XP/2003. I encourage you to use this API in your application.

Thanks!

Matthew Braun






Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

sumit kr

Hi Mathew,

Thaks for ur reply. I have not used try/catch in my main app . I have tried one thing :-

I wrote code for causing access violation in my application i.e these two lines

DWORD *pwd = NULL;

*pwd = 3;

when I run my application , The wer dialog box appears on Windows XP but not on Vista 32 bit , where it simply crashes silently.

Also I would like u to know that in my app, the code is so vast , there are so many dlls and I do not have any idea abt the code inside them.

So, I would like to know that is there any way to track the code responsible for this problem or I need to check the code of all dlls. Also I tried one method for this :- Simply I run the app and in VS 2005 ,Attach that process and then I tried to crash it but the information i got from call stack or other debug windows is insufficient.

Can I get waiver for this for Vista Logo certification..

Also, I want to know that 'Send error Report' dialog box appears only after my app is registered with WinQual site.






Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

OgonEk

I have another question but related to the test case.

Test case verification section says:

1. All of the application¡¯s executables above; when injected Access Violation (AV) resulted in the application crashing and must display the WER (Windows Error Reporting) dialog message in order to pass this test case. This means that the application AV failure properly allowed Windows Error Reporting to report this crash.
2. There must be both an Error message with ¡°Source¡± listed as Application Error and an Information message with ¡°Source¡± listed as Windows Error Reporting for each executable above in order to pass this test case.

Is it a test failure if:
a) Our application displays the WER dialog message;
b) Application Error is written to Event Viewer log;
c) There is no Information message as Windows Error Reporting in Event Viewer log




Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

dwkor

Hi!

In my case, either ThreadHijacker or programmatically generated AV displays dialog box: "Application has encountered a user-defined breakpoint" with 3 options:

1. Check Online

2. Close the program

3. Debug

It also generates entry in Event Log with generic code 10000 although, there is no WER dialog pops up. Strange thing, that when I'm using ThreadHijacker against standard notepad, it does not display WER dialogs either. In such case, there is similar "Application has stopped working" box with options: Check online and Close program.

Can you please give me some ideas how to solve that

Thank you,

Dmitri





Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

Oliver Lundt - MSFT

The WER dialog box that pops up is the dialog box that gives the options: 1. Check Online 2. Close the program 3. Debug

In the event log you are looking for the source of the Log as Windows Error Messagng.

I hope that helps.






Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

dwkor

Thank you very much, Oliver!

In my event log, source marked as "Application Error". Is it still correct

And also, can you please clarify one thing I'm a little bit confused when WER actually sends error reports available via WinQual Will it be additional choice in the case, if application has been signed

Sincerely,

Dmitri





Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

Oliver Lundt - MSFT

There should be two event logs. One with "Application Error" and another with "Windows Error Reporting"

Stopping WER from reporting to winqual is not optional for Logo Certification. You can still implent you own custom error handling, but WER needs to be able to report as well. One way to do this is to re-throw after your custom logic in a catch...





Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

dwkor

Oliver,

Unfortunately I do not have any "Windows Error Reporting" entries in my event log. Only "Application Error" ones (for both - my app and notepad).

As for my second question - I meant a little bit different thing. In XP WER displays dialog box with button "Send error report to Microsoft". So I was confused, when exactly dialog box with "Check online", "Close application" options sends those reports. Although, looks like something with WER does not work right so maybe I just don't see those dialogs.

Don't think it matters, but I'm using not activated version of Vista installed in Virtual PC 2004 session. Is there any chance, that it could be a problem

Thank you,

Dmitri





Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

yoorikan

You wrote:
>> You can still implent you own custom error handling, but WER needs to be able to report as well.
If so, is it possible that first we send the error report to our server first and then call WER




Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

Oliver Lundt - MSFT

That's correct, you should probably do your custom logging first and the rethrow the error for WER to log. It would look like this in C#

try
{
.....Code that breaks

}
Catch(exception ex)
{
.....Custome error handling
throw; // rethrow the error for WER to pickup,

}


throw ex:
Is incorrect and would not get picked up by WER. Something to do with .net runtime would now pick it up before WER






Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

Oleg63

Hello Matthew,

I understand, the new API has been VASTLY improved, but I didn't found any example of use this new API.

I've implementation which works perfectly on XP, but doesn't work at all on Vista:

The WER implementation is:

static TCHAR szPath[MAX_PATH+1];
static TCHAR szFr[] = _T("\\System32\\FaultRep.dll");

TCHAR * GetFullPathToFaultrepDll(void)
{
UINT rc;

rc = GetSystemWindowsDirectory(szPath, ARRAYSIZE(szPath));
if (rc == 0 || rc > ARRAYSIZE(szPath) - ARRAYSIZE(szFr) - 1)
return NULL;

_tcscat_s(szPath, MAX_PATH, szFr);
return szPath;
}

static LONG WINAPI ExceptionFilter( struct _EXCEPTION_POINTERS * pExceptionPointers )
{
LONG lRet = EXCEPTION_CONTINUE_SEARCH;
TCHAR * psz = GetFullPathToFaultrepDll();
if( psz )
{
HMODULE hFaultRepDll = LoadLibrary( psz ) ;
if( hFaultRepDll )
{
pfn_REPORTFAULT pfn = (pfn_REPORTFAULT)GetProcAddress( hFaultRepDll, "ReportFault" ) ;
if( pfn )
{
EFaultRepRetVal rc = pfn( pExceptionPointers, 0) ;
lRet = EXCEPTION_EXECUTE_HANDLER;
}
FreeLibrary(hFaultRepDll);
}
}
return lRet ;
}

BOOL CMyTestMFCApp::InitInstance()
{

........

SetUnhandledExceptionFilter(ExceptionFilter);

return TRUE;
}

The faultrep.dll's are different:

on XP I've v. 5.2

on Vista v. 6.0.6

Could you please clarify for me the changes with WER, and how to fix my implementation for Vista.

Thanks

Oleg.





Re: Application Compatibility for Windows Vista Test Case 32: Is WER necessary for this test case

Tania S Engel

I too had the exact same problem, until I selected option 1: Check online for a solution and close the program. Then and only then will the EventViewer Information log with Source=Windows Error Reporting appear.