Implementing Fiber-Local Storage Callbacks: sharing data between DLLs

John Sheu sheu at google.com
Wed Aug 31 04:12:23 CDT 2016


TL;WR: I'd like to share a struct definition between ntdll and
kernel32, passed through the PEB.  Is this kosher according to Wine
style/design, and if so, which header should I stick it in?

--

I'd like to have fiber-local storage callbacks in Wine.

http://source.winehq.org/git/wine.git/commit/556fef3d
http://source.winehq.org/git/wine.git/commit/ab11a5ae
http://source.winehq.org/git/wine.git/commit/4e8f43f4

So, after writing the conformance tests, it's time to implement the feature :-)


I've got the feature all done, except for one issue.  The proximate
issue is that when NtTerminateProcess is used on Windows, FLS
callbacks are not called for threads that are aborted (and those
threads do not get a DLL_THREAD_DETACH notification).  However, if
during DLL_PROCESS_DETACH the FLS slot is then freed, then the
callbacks are called on behalf of those (already-terminated) threads
by the process-detaching thread.  The behavior appears to be thus: if
the thread is exited cleanly (through LdrShutdownThread), then the FLS
callbacks are called for that thread; otherwise on an unclean exit the
FLS slots for the thread are transferred to some global list, and the
callbacks for that list are called when FlsFree is later called.

The underlying problem regards doing that transfer to the global list.
LdrShutdownThread and its other friends reside in ntdll, so ntdll will
have to know how to manage FLS.  The FLS API however resides in
kernel32, so kernel32 will have to know, as well.  For this purpose
I'd like to pass a common struct between ntdll and kernel32 through
PEB.FlsListHead.  What I see though is that include/winternl.h
contains (almost all) publicly Microsoft-documented struct
definitions, and I don't see anywhere else where such common structs
are presently shared between two DLLs.  So is it the case that the
convention in Wine is to not do such things as sharing structs, or is
this also done elsewhere and I just need to find the right header for
it?

Thanks,
-John Sheu



More information about the wine-devel mailing list