Hello,
during my PE shared sections experiments I have found the following
behavior of most native system dlls like for example commdlg32:
- When the library is loaded the first time, it creates a global
heap using CreateHeap and the undocumented flag 0x4000000.
- On win95 this flag has the effect, that the resulting heap is
visable and usable in the address spaces of _all_ processes
immediately.
- If another application load the dll, it retrieves a pointer to that
shared heap from a shared section of the dll and starts using that
heap. This is also the explanation of the crashes, I described in a
previous mail.
Now the question is, if we want to support that 0x4000000 flag in WINE
and if yes, how this can be done. I am not sure and would like to
know, if this flag is supported under NT/2000, maybe somebody can
enlighten me here?
In include/winnt.h,there are allready some definitions in the range
of this flag. I would like to change them to 0x10000000 and so on, if
nobody tells me, that this region is also use by some hidden
feature. BTW, does anybody know, if there is a known definition for
0x4000000 ?
#define HEAP_WINE_SEGPTR 0x01000000 /* Not a Win32 flag */
#define HEAP_WINE_CODESEG 0x02000000 /* Not a Win32 flag */
#define HEAP_WINE_CODE16SEG 0x04000000 /* Not a Win32 flag */
#define HEAP_WINE_SHARED 0x08000000 /* Not a Win32 flag */
A workaround, which works for some applications, that I have tested,
is to simply return a pointer to the system heap, if a shared heap is
requested. But of course, this has some drawbacks, since the system
heap can not grow and is created with a fixed set of parameters, while
the application might request others. Furthermore, the system heap
might become a bottleneck, if this method is used, by a lot of
applications.
A possibility, I see, to implement this feature in WINE goes as
follows:
- if some application uses this flags, the wineserver is called.
- the winserver stops all threads.
- it than looks for a address range, which is free in the address
spaces of all processes. What's the best way to do this?
/proc/???/maps ?
- it creates a file to be mmapped shared into all processes.
- It sets up the context of the first thread of all processes to call
a function, which mmaps the file into the process' address space.
- the threads are resumed until they make a server call, to signal,
that they are done, mmaping the file.
- the original thread is resumed. It sets up the heap and,
when done, calls again the server.
- Now the context of all the threads is restored and they are
resumed.
Actually, I am not sure, if that makes sense at all :-/ So again, all
comments are very appreciated :-)
Greetings,
Peter
--
Peter Ganten
[EMAIL PROTECTED]