Aw: Re: Possible to call winlib function from native program ?

Chip Davis cdavis at codeweavers.com
Thu Sep 6 11:04:44 CDT 2018


I don't understand. If you're P/Invoking Win32 DLLs, why don't you just run your .NET program in Wine in the first place?

September 6, 2018 7:01 AM, "Wilma Feuerstein" <officedev at gmx.ch (mailto:%22Wilma%20Feuerstein%22%20<officedev at gmx.ch>)> wrote:
Thanks, but no, it doesn't come any smaller - the 100 API calls is the internal API. 
Poking through the wine code, I've come to the same conclusion in the meantime. 
Not modular and not reusable. 
I'm still a bit alienated, as I think others have to have had the same problem before. 
But I guess it's just not a planned/intended use case. 
Well then wine/winelib as such is useless for me. 
Wine has non-the-less been useful, as I can look at the source of the functions, and determine what they actually do. 
Have managed to replace 2 COM-calls already. 
I'm just going to have to use a C#-Freetype-wrapper to copycat the textmetrics struct initialzation and all the code around in C#. 
usp10# with a little gdi32# so to say. 
   Gesendet: Dienstag, 04. September 2018 um 03:13 Uhr
Von: "Stefan Dösinger" <stefandoesinger at gmail.com (mailto:stefandoesinger at gmail.com)>
An: "Wilma Feuerstein" <officedev at gmx.ch (mailto:officedev at gmx.ch)>
Cc: wine-devel at winehq.org (mailto:wine-devel at winehq.org)
Betreff: Re: Possible to call winlib function from native program ? 
Am 30.08.2018 um 23:56 schrieb Wilma Feuerstein <officedev at gmx.ch (mailto:officedev at gmx.ch)>: 
I'll have to think about whether it might be easer ripping the respective code out of wine. You can try, but my guess is that you'll run into calls to lower-level Wine functions that will cause you the same pain as dlopen does. 
Writing a socket server for ~100 APIs with byref-arguments, with C and Windows-size datatypes on one side, and C# on Linux on the other, where the C# code runs inside a web-server, seems like a daunting task that might be more complex than writing a basic web server.You don't necessarily have to marshall the Win32 API. Do you have any internal APIs in your software (e.g. between your host process and a plugin) that is smaller?
	Is it not somehow possible to load the wine-server process inside the libtest.dll.so-constructor ? #define LINUX_ATTACH_DLL __attribute__((constructor)) whether that server process would be started inside the same process or outside wouldn't matter much. I don't know for sure. You could read through Wine's init code in loader/main.c, libwine and ntdll and see if you can reconstruct it elsewhere. It is certainly not a simple task. 
If I had to manually dlopen the dependencies between crypt32.dll, user32.dll, advapi32.dll and bcrypt.dll - and whatever - in the right order, that's something I could live with. The problem isn't just loading the libraries, you also have to resolve the imports. You might be able to dlopen ntdll.dll and then use LdrLoadDll to load the higher level DLLs. 
But just looking at the first lines of LdrLoadDll brings up a call to NtCurrentTeb(), which will return NULL unless you also call the right ntdll init code. 
Chip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20180906/4113fced/attachment-0001.html>


More information about the wine-devel mailing list