XomPie icon indicating copy to clipboard operation
XomPie copied to clipboard

Problems compiling kernelxp.dll

Open Mireso opened this issue 5 years ago • 4 comments

In order to support Python 3.7 I need to add InitializeProcThreadAttributeList, UpdateProcThreadAttribute, and DeleteProcThreadAttributeList to kernelxp.dll by copying and pasting code from the Wine project into the kernelxp source file and compiling it with the following command suggested in the source:

gcc -shared -D_UNICODE -DUNICODE -Wl,--kill-at,--enable-stdcall-fixup,-s -L kernelxp.def -o kernelxp.dll kernelxp.c -lmsvcp140 -lmsvcrt -lntdll -lpsapi

I tried this with the unaltered kernelxp.c supplied, but I am not a programmer, so I have run into problems straight away. When I installed Mingw-w64 v8.1 and ran the above command I encountered an error message about headers which I reproduce below:

In file included from D:/mingw32/i686-w64-mingw32/include/minwindef.h:163, from D:/mingw32/i686-w64-mingw32/include/windef.h:8, from D:/mingw32/i686-w64-mingw32/include/windows.h:69, from kernelxp.c:2: kernelxp.c:246:17: error: conflicting types for '_InterlockedCompareExchange64' LONGLONG WINAPI InterlockedCompareExchange64(LONGLONG volatile *Destination, LONGLONG Exchange, LONGLONG Comperand) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from D:/mingw32/i686-w64-mingw32/include/winnt.h:27, from D:/mingw32/i686-w64-mingw32/include/minwindef.h:163, from D:/mingw32/i686-w64-mingw32/include/windef.h:8, from D:/mingw32/i686-w64-mingw32/include/windows.h:69, from kernelxp.c:2: D:/mingw32/i686-w64-mingw32/include/psdk_inc/intrin-impl.h:1397:9: note: previous definition of '_InterlockedCompareExchange64' was here __int64 _InterlockedCompareExchange64(__int64 volatile *Destination, __int64 ExChange, __int 64 Comperand) {

I also installed Mingw (gcc-6.3.0-1) and received the following error message:

kernelxp.c:3:22: fatal error: winternl.h: No such file or directory #include <winternl.h>

Can you provide precise instructions on how to compile the Xompie modules including information about the build environment such as Linux, MSYS2, or Cygwin. Also is there a possibility that importing functions from Wine into the Xompie modules would require additional headers to be included, and if so how do I select them?

Mireso avatar Jan 03 '20 09:01 Mireso

this #include <winternl.h> part are you sure your mingw-w64 don't have that file? I always build my own gcc from scratch, I have gcc 4.8 and 6.4 using mingw-w64 5.0.4 if you wanna try I put it in my other repo https://github.com/tumagonx/XPitory/tree/master/compiler/gcc xompie doesn't need msys just gcc with mingw-w64 (not mingw32) should be enough. it's possible import from Wine the hardest part is shell32 since it's hardwired with explorer.exe, but those mentioned threading API might be difficult to, so far some of those are being emulated/based on pthread (which itself being emulated upon more primitive NT threading).

tumagonx avatar Jan 03 '20 19:01 tumagonx

How about waiting for Pypy? their py3.6 implementation is easier to fix for XP than cpython's.

tumagonx avatar Jan 03 '20 19:01 tumagonx

I attempted to compile the unaltered kernelxp.c using gcc485+boost155.7 from your github repository, but I received the error message:

../i686-w64-mingw32/bin/ld.exe: cannot find -lmsvcp140

In the i686-w64-mingw32\lib directory there is no libmsvrp140.a, but there is a libvcruntime140.a, so I changed the option -lmsvcp140 to -lvcruntime140, and then I received the following error:

%TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x152): undefined reference to _imp____crtCloseThreadpoolTimer@4' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x16c): undefined reference to _imp____crtCloseThreadpoolWait@4' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x1be): undefined reference to _imp____crtCompareStringEx@36' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x1ed): undefined reference to _imp____crtCreateEventExW@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x22a): undefined reference to _imp____crtCreateSemaphoreExW@24' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x252): undefined reference to _imp____crtCreateSymbolicLinkW@12' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x27a): undefined reference to _imp____crtCreateThreadpoolTimer@12' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x2a2): undefined reference to _imp____crtCreateThreadpoolWait@12' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x2b6): undefined reference to _imp____crtFlushProcessWriteBuffers@0' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x2d2): undefined reference to _imp____crtFreeLibraryWhenCallbackReturns@8' %TEMP%ccV5CJSb.o:kernelxp.c:(.text+0x2e6): undefined reference to _imp____crtGetCurrentProcessorNumber@0' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x310): undefined reference to _imp____crtGetFileInformationByHandleEx@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x33f): undefined reference to _imp____crtGetLocaleInfoEx@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x359): undefined reference to _imp____crtGetSystemTimePreciseAsFileTime@4' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x36d): undefined reference to _imp____crtGetTickCount64@0' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x399): undefined reference to _imp____crtInitOnceExecuteOnce@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x3c1): undefined reference to _imp____crtInitializeCriticalSectionEx@12' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x413): undefined reference to _imp____crtLCMapStringEx@36' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x442): undefined reference to _imp____crtSetFileInformationByHandle@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x471): undefined reference to _imp____crtSetThreadpoolTimer@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x499): undefined reference to _imp____crtSetThreadpoolWait@12' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x4ba): undefined reference to _imp____crtWaitForThreadpoolTimerCallbacks@8' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x82c): undefined reference to _imp____crtCreateSymbolicLinkW@12' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x1c53): undefined reference to _imp____crtCreateEventExW@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x1cd3): undefined reference to _imp____crtCreateEventExW@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x1d1a): undefined reference to _imp____crtCreateSemaphoreExW@24' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x1dab): undefined reference to `_imp____crtCreateSemaphoreExW@24'

I did think of fixing PyPy because their latest version is the equivalent of Python 3.69 and I need Python 3.61 for the Electrum bitcoin wallet. You would only need to compile it so that pypy3.exe calls GetTickCount instead of GetTickCount64. There are two missing imports for libpypy3-c.dll, but these have been supplied by a stub dll w2_xx.dll created by 404notfound at the MSFN forum. However, I still want to backport Python 3.7 to XP just for the hell of it.

Mireso avatar Jan 05 '20 10:01 Mireso

looks like libmsvcp140.dll.a has not been generated, please open msvcp140.def and execute that commented dlltool line, and then try compile again

tumagonx avatar Jan 05 '20 10:01 tumagonx