| 561 | |
| 562 | #if mxWindows |
| 563 | ULONG GetCurrentThreadStackLimits_Win7( _Out_ PULONG_PTR LowLimit, _Out_ PULONG_PTR HighLimit ) |
| 564 | { |
| 565 | static void (WINAPI* GetCurrentThreadStackLimits)(PULONG_PTR , PULONG_PTR); |
| 566 | |
| 567 | if (!GetCurrentThreadStackLimits) |
| 568 | { |
| 569 | *(void**)&GetCurrentThreadStackLimits = GetProcAddress(GetModuleHandle("kernel32"), "GetCurrentThreadStackLimits"); |
| 570 | |
| 571 | if (!GetCurrentThreadStackLimits) |
| 572 | { |
| 573 | NT_TIB* tib = (NT_TIB*)NtCurrentTeb(); |
| 574 | *HighLimit = (ULONG_PTR)tib->StackBase; |
| 575 | |
| 576 | MEMORY_BASIC_INFORMATION mbi; |
| 577 | if (VirtualQuery(tib->StackLimit, &mbi, sizeof(mbi))) |
| 578 | { |
| 579 | *LowLimit = (ULONG_PTR)mbi.AllocationBase; |
| 580 | return 0; |
| 581 | } |
| 582 | |
| 583 | return GetLastError(); |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | GetCurrentThreadStackLimits(LowLimit, HighLimit); |
| 588 | return 0; |
| 589 | } |
| 590 | #endif |
| 591 | |
| 592 | char* fxCStackLimit() |