Skip to content

Commit acc6b32

Browse files
committed
Replace legacy stack restore with _resetstkoflw()
That code won't build on x64, because inline assembly is not supported on that platform, but calling `_resetstkoflw()` is simpler anyway. After we have fixed this, we also enable SEH again. This needs to be thoroughly tested, though.
1 parent f426f16 commit acc6b32

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

sapi/isapi/php_isapi.c

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636

3737
#ifdef PHP_WIN32
38-
// #define PHP_ENABLE_SEH
38+
#define PHP_ENABLE_SEH
3939
#endif
4040

4141
/*
@@ -723,29 +723,7 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB)
723723
} __except(exceptionhandler(&e, GetExceptionInformation())) {
724724
char buf[1024];
725725
if (_exception_code()==EXCEPTION_STACK_OVERFLOW) {
726-
LPBYTE lpPage;
727-
static SYSTEM_INFO si;
728-
static MEMORY_BASIC_INFORMATION mi;
729-
static DWORD dwOldProtect;
730-
731-
GetSystemInfo(&si);
732-
733-
/* Get page ESP is pointing to */
734-
// _asm mov lpPage, esp;
735-
736-
/* Get stack allocation base */
737-
VirtualQuery(lpPage, &mi, sizeof(mi));
738-
739-
/* Go to the page below the current page */
740-
lpPage = (LPBYTE) (mi.BaseAddress) - si.dwPageSize;
741-
742-
/* Free pages below current page */
743-
if (!VirtualFree(mi.AllocationBase, (LPBYTE)lpPage - (LPBYTE) mi.AllocationBase, MEM_DECOMMIT)) {
744-
_endthread();
745-
}
746-
747-
/* Restore the guard page */
748-
if (!VirtualProtect(lpPage, si.dwPageSize, PAGE_GUARD | PAGE_READWRITE, &dwOldProtect)) {
726+
if (!_resetstkoflw()) {
749727
_endthread();
750728
}
751729

0 commit comments

Comments
 (0)