5 ms·
Porting Windows Dynamic Link Libraries to Linux
- gadnium79 9y agowhy?
- detaro 9y agoThat's answered in the README.
- adrianpike 9y ago...why not?
- analognoise 9y agoI've always thought why is more important than why not. Example: "I'm going to hit myself in the dick with a hammer."
- int_19h 9y agoYour example has an obvious great answer to "why not?", though, so no harm done in asking that question first.
- bitwize 9y agoWell, why don't you MARRY safe science if you love it so much!! :)
- mirimir 9y agoActually, that's not so problematic unless there's an anvil involved, or the hammer is moving quickly.
- sqeaky 9y agoI still don't think its a problem. I can swing the hammer if AnalogNoise cannot build up sufficient speed.
- alnitak 9y agoWhile I agree the grandparent's comment doesn't add much to the conversation, and even has many obvious answers, why is a more interesting question. You are basically questioning if there is a need to change the status quo, or put in physics terms, why do you want to expend energy to move from the local stable point? What is the point with higher stability you want to reach, and what are the characteristics that make this point desirable and justify the energy expenditure?
- faragon 9y agoVery cool, to load .dll, so tests/builds/packaging can be run in Linux. There is also the possibility of signing .exe/.dll on Linux. AFAIK, the remaining stuff is to sign .msi files.
- tathougies 9y agoWhy not just use full-on WINE? The basic system calls are pretty much fully covered. It seems this duplicates a lot of work.
- Arnavion 9y agoAre the Windows API implementations of WINE usable by a native Linux program (eg as a library of some sort)? That seems to be the requirement here.
- chrisseaton 9y agoYes - using WINE as a library is one way of porting to Linux.
- snarfy 9y agoYes, I've written a windows dll loader for linux based on wine myself. It's fairly simple to add support for LoadLibrary() and GetProcAddress() to a linux program using wine libraries.
- tathougies 9y agoWINE's had this ability for more than a decade -- see winelib.
- SA500 9y ago'This project does not replace Wine or Winelib. Winelib is used to port Windows C++ projects to Linux, and Wine is intended to run full Windows applications. This project is intended to allow native Linux code to load simple Windows DLLs. The closest analogy would be ndiswrapper but for userspace.'
- deleted 9y ago[deleted]
- psykotic 9y agoThis reminds me of a tool Jeff Roberts wrote at RAD Game Tools which would repackage libraries so they were loadable on Linux. At the time the motivation was that MSVC was generating much better code than GCC for Bink, so he'd compile on Windows with MSVC and cross-link to Linux with his custom tool.
- reacweb 9y agoDoes MSVC still generate better code than GCC ? I do not find any recent benchmark.
- omgtehlion 9y agoGenerally, no. But you should benchmark your own code. In my experience, some code paths are better optimized by cl.exe, some by gcc. Overall difference is negligible though.
- jackmott 9y agoit's never been true in general but still happens sometimes.
- sqeaky 9y agoOf things I have benchmarked in the past 5 or so years GCC has not been beaten by GCC for any of my workloads or benchmarks. I do mostly things related to 3d graphics and are heavy on the CPU, but what little IO I have done follows this pattern too. As near as I can tell msvc is strictly inferior except for windows community adoption than gcc/mingw. Of course, benchmark your workload, I could be doing something odd that you are not.
- cupantae 9y agoGCC has not been beaten by GCC --> MSVC has not been beaten by GCC ftfy
- steeve 9y agoDid anyone find info on how are user32.dll and kernel32.dll handled ?
- bonzini 9y agoThere are stubs, or reimplementations on top of the C library, for a relatively small subset of functions: https://github.com/taviso/loadlibrary/tree/master/peloader/winapi https://github.com/taviso/loadlibrary/tree/master/peloader/w... (see e.g. Files.c in there for an example of mapping Windows API functions to libc).
- kazinator 9y agoDid this close to twenty years ago. Ported a COM DLL to Linux and one of the executables using it. I implemented everything it needed. COM functions like CoCreateInstance, entry points like DllCanUnloadNow, Windows Sockets and whatnot. The registry API! Ha. I mapped HKEY_CURRENT_USER to configuration files rooted in the user's home directory, and HKEY_LOCAL_MACHINE to /etc. The lib's DllRegisterServer nicely registered its COM class inside the fake registry. Don "COM is Love" Box would have teared up had he seen this.
- yuhong 9y agoOpen Group had COMsource: http://www.opengroup.org/comsource/ http://www.opengroup.org/comsource/
- blinkingled 9y agoSoftware AG had DCOM (EntireX?) implementation for Solaris/Linux back in the day It was freely downloadable and came with working examples :)
- deleted 9y ago[deleted]
- rwj 9y agoSame thing here. Wrote enough of a COM implementation that some software could be compiled native on Linux. The cool bit was that we automatically generated the Python bindings as well, so all the COM components were easily accessible for scripting.
- pierrec 9y agoThis is cool and a lot lighter than WINE, though the important keyword is self-contained Windows libraries. I gather this won't work on DLLs that call any of the plethora of Windows APIs. I'm actually very surprised that any non-trivial DLLs are self-contained in this way, like his example of Windows Defender which I thought would call 1000 Windows API functions.
- tyingq 9y agoI would imagine anti virus products are more self contained so that they don't rely on potentially compromised code.
- bonzini 9y agoA bunch of C runtime library and Windows APIs are implemented or stubbed: * https://github.com/taviso/loadlibrary/tree/master/peloader/winapi https://github.com/taviso/loadlibrary/tree/master/peloader/w... * https://github.com/taviso/loadlibrary/blob/master/peloader/crt.c https://github.com/taviso/loadlibrary/blob/master/peloader/c...
- deleted 9y ago[deleted]
- partycoder 9y agoI don't know if I would like software ported to Linux in this way. I already have mixed feelings about WINE. My concern is really on the legal side of things. What if these things are patent protected and people start getting sued?
- mariuolo 9y agoDo you realise this is a debugging tool?
- shmerl 9y agoSounds like reimplementing what Wine already does.
- beagle3 9y agoNote that the author is Tavis Ormandy, the guy who (among many, many other things) discovered one of the worst Windows security vulns, that was patched last month -- and from the README it seems like this is part of the toolchest he used for this particular discovery. To all people wondering why not wine or winelib - this is for ease of debugging and fuzzing DLLs, not for actually running software. Wine and Winelib bring way too much baggage for those uses.
- weinzierl 9y agoIf you like this, you might also like the Witchcraft Compiler Collection[1] by Jonathan Brossard. It approaches from a different angle (relinking), but (as far as I understand it) can help to solve the same problem Tavis tackles. In the end they both allow the dynamic analysis of PE files in Linux. Both tools only work if the architecture is the same in both worlds, I think. EDIT: [2] is an intro to the Witchcraft Compiler Collection from Black Hat Europe 2016 which is probably more helpful than the link to the repo. [1] https://github.com/endrazine/wcc/blob/master/README.md https://github.com/endrazine/wcc/blob/master/README.md [2] https://www.blackhat.com/docs/eu-16/materials/eu-16-Brossard-Witchcraft-Compiler-Collection-Towards-Self-Aware-Computer-Programs.pdf https://www.blackhat.com/docs/eu-16/materials/eu-16-Brossard...
- hexmiles 9y agoI read the readme, but i still can't understand how is different than winelib (and i don't know much of ndiswrapper internal). I understand that since is a debugging oriented tool has a different scope than wine, but why don't use (at least partially) the already implemented windows function? I am missing something? maybe this is more efficient o maybe wine is not enough modular?
- ConfucianNardin 9y agoWinelib requires you to (re-)compile from source. This project allows you to load (some) windows DLLs as-is.