tumagonx / XomPie

Simple tools that might™ make newer application with trivial compatibility issue to run™ on Windows XP
GNU Lesser General Public License v3.0
61 stars 8 forks source link

Problems compiling kernelxp.dll #4

Open Mireso opened 4 years ago

Mireso commented 4 years ago

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

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?

tumagonx commented 4 years ago

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 commented 4 years ago

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

Mireso commented 4 years ago

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_impcrtCloseThreadpoolWait@4' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x1be): undefined reference to _imp____crtCompareStringEx@36' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x1ed): undefined reference to_impcrtCreateEventExW@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x22a): undefined reference to _imp____crtCreateSemaphoreExW@24' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x252): undefined reference to_impcrtCreateSymbolicLinkW@12' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x27a): undefined reference to _imp____crtCreateThreadpoolTimer@12' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x2a2): undefined reference to_impcrtCreateThreadpoolWait@12' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x2b6): undefined reference to _imp____crtFlushProcessWriteBuffers@0' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x2d2): undefined reference to_impcrtFreeLibraryWhenCallbackReturns@8' %TEMP%ccV5CJSb.o:kernelxp.c:(.text+0x2e6): undefined reference to _imp____crtGetCurrentProcessorNumber@0' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x310): undefined reference to_impcrtGetFileInformationByHandleEx@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x33f): undefined reference to _imp____crtGetLocaleInfoEx@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x359): undefined reference to_impcrtGetSystemTimePreciseAsFileTime@4' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x36d): undefined reference to _imp____crtGetTickCount64@0' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x399): undefined reference to_impcrtInitOnceExecuteOnce@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x3c1): undefined reference to _imp____crtInitializeCriticalSectionEx@12' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x413): undefined reference to_impcrtLCMapStringEx@36' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x442): undefined reference to _imp____crtSetFileInformationByHandle@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x471): undefined reference to_impcrtSetThreadpoolTimer@16' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x499): undefined reference to _imp____crtSetThreadpoolWait@12' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x4ba): undefined reference to_impcrtWaitForThreadpoolTimerCallbacks@8' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x82c): undefined reference to _imp____crtCreateSymbolicLinkW@12' %TEMP%\ccV5CJSb.o:kernelxp.c:(.text+0x1c53): undefined reference to_impcrtCreateEventExW@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.

tumagonx commented 4 years ago

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