<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-text-flowed" style="font-family: -moz-fixed;
      font-size: 12px;" lang="x-unicode">Great summary, a few
      clarifications from my understanding
      <br>
      <br>
      On 14.04.22 11:26, Eric Pouech wrote:
      <br>
      <blockquote type="cite" style="color: #007cff;">
        <br>
        <br>
        Keep in mind:
        <br>
        - the same structure can have different sizes for fields, and
        different layouts
        <br>
          when compiled for PE or ELF, 32 or 64 bit, or different CPUs.
        <br>
          So the ELF part must handle those discrepancies if any.
        <br>
        - pointers will be of different sizes...
        <br>
        - allocation of memory can be harder to implement on ELF side
        (as one must
        <br>
          ensure that allocated memory can be accessed from 32 bit PE
        part)
        <br>
        <br>
      </blockquote>
      Even on the 64-bit side, memory existing on the PE side should
      have been allocated through wine's system, with valid information
      reflected from calls to functions like NtQueryVirtualMemory.
      <br>
      <blockquote type="cite" style="color: #007cff;">
        <br>
        - exception handling?
        <br>
        <br>
      </blockquote>
      All unixlib entries have an implicit stack exception handler
      around them, that, when caught, returns the exception code
      NTSTATUS from the function to the PE side.
      <br>
      <blockquote type="cite" style="color: #007cff;">
        <br>
        <br>
        Actually, there will be two distinct tables:
        <br>
        - one used for the invocation from 64 bit PE side,
        <br>
        - the second one used for the invocation from 32 bit PE side.
        <br>
        <br>
        Upon invocation, their argument will be mapped to the 32 bit or
        the 64 bit
        <br>
        layout of the argument structure.
        <br>
        This allows either to adapt the implementation to any difference
        between the 32
        <br>
        and 64 bit worlds.
        <br>
        <br>
      </blockquote>
      This is a bit confusingly worded, the second table
      "__wine_unix_call_wow64_funcs" will map the incoming 32-bit ABI
      argument structure to the 64 bit ABI, call the 64 bit handler,
      then map the outgoing 64bit ABI argument structure, (the same
      structure is used both for input and output parameters) into the
      equivalent 32-bit ABI structure again.
      <br>
      <blockquote type="cite" style="color: #007cff;">
        <br>
        <br>
        <br>
        It's still not clear to me how the new module wow64 will be
        activated.
        <br>
        <br>
      </blockquote>
      <br>
      As far as I understand it, wow64.dll is simply a 64-bit PE that is
      loaded by the 64-bit ntdll.dll in a wow64 process.  64-bit
      ntdll.dll also loads 32-bit ntdll.dll, which, when used on wow64,
      will call into wow64.dll for system calls, by means of using
      wow64cpu.dll to perform a context switch to the 64-bit CPU mode.
      <br>
    </div>
  </body>
</html>