I'm trying to write a test that checks for data overruns
using VirtualAlloc and VirtualProtect and I think
I may have found a bug.  Here is the problem:

DWORD dwPageSize;
BYTE * twoPages, temp;
DWORD flOldProtect;
twoPages = VirtualAlloc(NULL, 2 * dwPageSize, MEM_RESERVE | MEM_COMMIT,  
PAGE_READWRITE);
res = VirtualProtect(twoPages + dwPageSize, dwPageSize, PAGE_NOACCESS,  &flOldProtect);
temp = twoPages[dwPageSize + 1];    // should cause exception but  doesn't in wine
twoPages[dwPageSize + 1] = 0;        // does cause exception

Say, that code fragment wasn't complete, was it? Looks like dwPageSize was uninitialized...

I would like to write a test to check the exception handling
but I don't know how to do a __try and __except in C.

OK, I don't know much about it either. A little googling shows: http://www.kerneltraffic.org/wine/wn20030516_170.html#8 makes it sound like __try is hard to do with gcc. You might need to punt and, when compiling with gcc, do nothing unless building in winelib, where you'd set up a handler for SIGSEGV to catch the bad access. http://www.codeproject.com/cpp/transactions.asp?df=100&forumid=11253&exp=0&select=435857 has some examples of how __try is used in visual C. (Note that you can download a copy of visual C's commandline compiler free from Microsoft.)

What confuses me is, doesn't MinGW support __try?  Hrm.
- Dan

--
My technical stuff: http://kegel.com
My politics: see http://www.misleader.org for examples of why I'm for regime change



Reply via email to