mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 530448 - Make TestPoisonArea.cpp compile on mingw, r=zwol
This commit is contained in:
parent
b0ab558420
commit
e787295d9f
@ -394,6 +394,27 @@ ReserveNegativeControl()
|
||||
return (uintptr_t)result;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static BOOL
|
||||
IsBadExecPtr(uintptr_t ptr)
|
||||
{
|
||||
BOOL ret = false;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__try {
|
||||
((void (*)())ptr)();
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
ret = true;
|
||||
}
|
||||
#else
|
||||
printf("INFO | exec test not supported on MinGW build\n");
|
||||
// We do our best
|
||||
ret = IsBadReadPtr((const void*)ptr, 1);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Test each page. */
|
||||
static bool
|
||||
TestPage(const char *pagelabel, uintptr_t pageaddr, int should_succeed)
|
||||
@ -413,15 +434,23 @@ TestPage(const char *pagelabel, uintptr_t pageaddr, int should_succeed)
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
__try {
|
||||
unsigned char scratch;
|
||||
switch (test) {
|
||||
case 0: scratch = *(volatile unsigned char *)opaddr; break;
|
||||
case 1: ((void (*)())opaddr)(); break;
|
||||
case 2: *(volatile unsigned char *)opaddr = 0; break;
|
||||
default: abort();
|
||||
}
|
||||
BOOL badptr;
|
||||
|
||||
switch (test) {
|
||||
case 0: badptr = IsBadReadPtr((const void*)opaddr, 1); break;
|
||||
case 1: badptr = IsBadExecPtr(opaddr); break;
|
||||
case 2: badptr = IsBadWritePtr((void*)opaddr, 1); break;
|
||||
default: abort();
|
||||
}
|
||||
|
||||
if (badptr) {
|
||||
if (should_succeed) {
|
||||
printf("TEST-UNEXPECTED-FAIL | %s %s\n", oplabel, pagelabel);
|
||||
failed = true;
|
||||
} else {
|
||||
printf("TEST-PASS | %s %s\n", oplabel, pagelabel);
|
||||
}
|
||||
} else {
|
||||
// if control reaches this point the probe succeeded
|
||||
if (should_succeed) {
|
||||
printf("TEST-PASS | %s %s\n", oplabel, pagelabel);
|
||||
@ -429,17 +458,6 @@ TestPage(const char *pagelabel, uintptr_t pageaddr, int should_succeed)
|
||||
printf("TEST-UNEXPECTED-FAIL | %s %s\n", oplabel, pagelabel);
|
||||
failed = true;
|
||||
}
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
// Unfortunately, there is no equivalent of strsignal().
|
||||
DWORD code = GetExceptionCode();
|
||||
if (should_succeed) {
|
||||
printf("TEST-UNEXPECTED-FAIL | %s %s | exception code %x\n",
|
||||
oplabel, pagelabel, code);
|
||||
failed = true;
|
||||
} else {
|
||||
printf("TEST-PASS | %s %s | exception code %x\n",
|
||||
oplabel, pagelabel, code);
|
||||
}
|
||||
}
|
||||
#else
|
||||
pid_t pid = fork();
|
||||
|
Loading…
Reference in New Issue
Block a user