Skip to content

Instantly share code, notes, and snippets.

@jhasse
Created March 14, 2019 15:44
Show Gist options
  • Save jhasse/d86eea4efc1d00ea5c4e6165523b414c to your computer and use it in GitHub Desktop.
Save jhasse/d86eea4efc1d00ea5c4e6165523b414c to your computer and use it in GitHub Desktop.
import sys
import subprocess
import os
import shutil
import re
old_dll = ""
def copy_dlls(binary):
print("\nChecking " + binary)
process = subprocess.run(
[
'C:\\msys64\\mingw64\\bin\\ntldd.exe',
binary,
],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False
)
output = process.stdout.decode('utf-8', errors='ignore')
for line in output.splitlines():
dll = ''
try:
dll = re.match(r'(.*) => (.*\.[dD][lL][lL]) \((.*)\)', line).group(2)
except AttributeError:
print(" Can't parse line: " + line)
continue
paths = ['C:\\msys64\\mingw64\\bin']
found = False
for path in paths:
if dll.startswith(path):
found = True
if not found:
print(' Skipping ' + dll)
continue
print(' Copying ' + dll)
shutil.copy(dll, os.getcwd())
copy_dlls(os.path.basename(dll))
copy_dlls(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment