Executable gives DLL load failed when run on another PC

Issues related to Enigma Virtual Box
Post Reply
baykiwi
Posts: 5
Joined: Wed Nov 16, 2016 10:46 pm

Executable gives DLL load failed when run on another PC

Post by baykiwi »

Hi

I am trying to use Enigma Virtual Box 7.70 to make a cut-down portable version of python2.7. I included a copy of all the necessary .pyc, .dll files as well as _socket.pyd, _ssl.pyd into the default directory and created an executable that runs on the host machine (Win7 64bit).

Copying the executable onto a Win 2003 server (x64) machine, the program starts up but fails on an import socket. Here are the outputs of python -vv on both machines:

HOST Win7:

>>> import socket
# trying socket.pyd
# trying socket.py
# socket.pyc matches socket.py
import socket # precompiled from socket.pyc
import gc # builtin
import time # builtin
# trying _socket.pyd
import _socket # dynamically loaded from _socket.pyd
# trying _ssl.pyd
import _ssl # dynamically loaded from _ssl.pyd
import cStringIO # builtin
>>>

REMOTE Win2003:

>>> import socket
# trying socket.pyd
# trying socket.py
# socket.pyc matches socket.py
import socket # precompiled from socket.pyc
import gc # builtin
import time # builtin
# trying _socket.pyd
# clear[1] _threshold2
# clear[1] _threshold0
# clear[1] _threshold1
# clear[2] __file__
# clear[2] gc
# clear[2] __name__
# clear[2] __doc__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "socket.py", line 51, in <module>
import _socket
ImportError: DLL load failed: Invalid access to memory location.
>>>

Does anyone know how to resolve this issue please?

Thanks
Colin Brown
Enigma
Site Admin
Posts: 2939
Joined: Wed Aug 20, 2008 2:24 pm

Re: Executable gives DLL load failed when run on another PC

Post by Enigma »

HI Colin,

it would be better if you send us this non packed exe file with all necessary files in Virtual Box at support@enigmaprotector.com, we will try to check it out.

Would it be possible to do?
Enigma
Site Admin
Posts: 2939
Joined: Wed Aug 20, 2008 2:24 pm

Re: Executable gives DLL load failed when run on another PC

Post by Enigma »

We have tested your files, even the original files are not starting at Win 2003, the program itself is not compatible with Win 2003.
baykiwi
Posts: 5
Joined: Wed Nov 16, 2016 10:46 pm

Re: Executable gives DLL load failed when run on another PC

Post by baykiwi »

Hi folks

I have used PyInstaller to make an executable of the following script (on Win7):

import socket, time
print 'socket module import successful'
time.sleep(10.0)

The distribution directory contains:
_hashlib.pyd
_socket.pyd
_ssl.pyd
bz2.pyd
Microsoft.VC90.CRT.manifest
msvcm90.dll
msvcp90.dll
msvcr90.dll
python27.dll
select.pyd
test.exe
test.exe.manifest
unicodedata.pyd

Copying all these file onto a Windows 2003 server share, the test program executes successfully. It seems that python2.7 does run under Windows 2003 and allow me to import the socket module.

Colin
baykiwi
Posts: 5
Joined: Wed Nov 16, 2016 10:46 pm

Re: Executable gives DLL load failed when run on another PC

Post by baykiwi »

Hi folks

Further to my last post I have now used PyInstaller to make an application console.exe based on the code:

import code
vars = globals().copy()
vars.update(locals())
shell = code.InteractiveConsole(vars)
shell.interact()

I then used Enigma to take all the output files from PyInstaller to make console_packed.exe. It runs up ok under Windows 2003 with an interactive console. If I now put the files socket.pyc, _socket.pyd and _ssl.pyd in the same directory I can import socket successfully. If I modify the code above to also import socket and rebuild through PyInstaller and Enigma the code runs on the original Win7 box but fails with the same DLL import error on Windows 2003. There is obviously something special in how .pyd files are imported that is fundamentally different to how .dll files are imported. Maybe the writers of PyInstaller have a good reason why they do not wrap the .pyd files into their executable?

Colin
baykiwi
Posts: 5
Joined: Wed Nov 16, 2016 10:46 pm

Re: Executable gives DLL load failed when run on another PC

Post by baykiwi »

Hi

Taking the two Enigma encapsulated PyInstaller executables from my last post (one with and one without "import socket") and running them on a Windows (64 bit) Server 2012, both programs ran without error. This server did not have Python2.7 installed.

Summarising: The software without the encapsulated socket import runs on all the machines and works with the external socket modules in the same directory. The issue of .pyd loading for the executable with the encapsulated (internal) socket import occurs between the 2003 - 2012 OS software versions (possibly an ntdll.dll difference?)

Colin
baykiwi
Posts: 5
Joined: Wed Nov 16, 2016 10:46 pm

Re: Executable gives DLL load failed when run on another PC

Post by baykiwi »

Hi

I now have the "console" code with built-in socket import running on WinXT Professional V2002 SP 3. To do this I resurrected a VirtualBox WinXT image and loaded Python2.7, PyInstaller and Enigma Virtual Box and rebuilt the boxed image. As a matter of interest I then copied the image across and tried to run it under Windows 2003 Server. It failed trying to load msvcr100.dll. The WinXP build is using msvcr90.dll. It appears that one can create fully encapsulated executables on earlier versions of Windows so long as you build them on a machine that uses a corresponding set of dynamic link libraries.

Colin

PS: Just found that the Win95 boxed image runs under Windows 7 - surprise, surprise.
Post Reply