| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
extern void *slp_switch_raw(void *(*save_state)(void*, void*), |
| 5 |
void *(*restore_state)(void*, void*), |
| 6 |
void *extra); |
| 7 |
|
| 8 |
#undef STATIC_NOINLINE |
| 9 |
#define STATIC_NOINLINE static __declspec(noinline) |
| 10 |
|
| 11 |
#define WIN32_LEAN_AND_MEAN |
| 12 |
#include <windows.h> |
| 13 |
|
| 14 |
|
| 15 |
#pragma optimize("", off) |
| 16 |
#pragma warning(disable:4733) |
| 17 |
|
| 18 |
static void *slp_switch(void *(*save_state)(void*, void*), |
| 19 |
void *(*restore_state)(void*, void*), |
| 20 |
void *extra) |
| 21 |
{ |
| 22 |
|
| 23 |
DWORD seh_state = __readfsdword(FIELD_OFFSET(NT_TIB, ExceptionList)); |
| 24 |
void * result = slp_switch_raw(save_state, restore_state, extra); |
| 25 |
__writefsdword(FIELD_OFFSET(NT_TIB, ExceptionList), seh_state); |
| 26 |
return result; |
| 27 |
} |
| 28 |
#pragma warning(default:4733) |
| 29 |
#pragma optimize("", on) |