[Bug 10467] Making Microsoft .NET 2.0 to work in wine, based on example app FastMD5 1.4 for NET 2.0

wine-bugs at winehq.org wine-bugs at winehq.org
Wed Mar 26 17:49:06 CDT 2008


http://bugs.winehq.org/show_bug.cgi?id=10467





--- Comment #55 from Anastasius Focht <focht at gmx.net>  2008-03-26 17:49:05 ---
Hello,

--- quote ---
StackLimit is supposed to point above the guard page, it's the start of the
valid area (and yes there are apps that depend on this). So if .NET starts
looking from StackLimit, creating a Windows-style guard page is not going to
help.
--- quote ---

As I already explained, there is currently no other way - there has to be a
PAGE_GUARD page between StackLimit and current thread stack addr (< StackBase).

I illustrate the problem for other interested people a bit more...

Consider the following common scenario...

--- memory map for typical PE ---

address   size     contains                    type     mapped as
00240000  00001000 guard page                  private  (no access)
00241000  0010F000 main thread stack           private  read-write
..
00400000  00001000 PE header                   image    read-write-copy
00401000  00047000 .text (code,imports)        image    read-write-copy
00448000  00007000 .rsrc (data, res)           image    read-write-copy
0044F000  00001000                             image    read-write-copy
00450000  00001000 .reloc (relocations)        image    read-write-copy
..
--- memory map for typical PE ---

stack_lower_bound == 0x240000 == NtCurrentTeb()->DeallocationStack

--- retrieve lower stack bound ---
MEMORY_BASIC_INFORMATION info;
DWORD addr;
VirtualQuery( &addr, &info, sizeof(MEMORY_BASIC_INFORMATION));
--- retrieve lower stack bound ---

offset  value     comment
$+00    0034F000  BaseAddress
$+04    00240000  AllocationBase
$+08    00000004  AllocationProtect
$+0C    00001000  RegionSize
$+10    00001000  State
$+14    00000004  Protect
$+18    00020000  Type

stack_lower_bound = info.AllocationBase;

stack_base = NtCurrentTeb()->Tib.StackBase; ( == 0x350000)

--- retrieve stack base ---
mov     eax, large fs:[18h] ; NtCurrentTeb()
mov     eax, [eax+4]        ; NtCurrentTeb()->Tib.StackBase
--- retrieve stack base ---

guard page search algorithm (TRUE = found):

--- algorithm to search for guard page ---

search_start_addr = NtCurrentTeb()->Tib.StackLimit  (= stack_lower_bound +
page_size) == 0x241000 (page_size = 0x1000 for x86)

{
   addr = search_start_addr;
   while( addr < stack_base)
   {
       VirtualQuery( addr, &info, sizeof(MEMORY_BASIC_INFORMATION));
       if( info.Protect & PAGE_GUARD)
          return TRUE;
       addr += info.RegionSize;
   }
   return FALSE;
}

--- algorithm to search for guard page ---



More information about the wine-bugs mailing list