From 3829c49c3b55a9ea4edfe2c5f974282ebdcc1939 Mon Sep 17 00:00:00 2001 From: vToMy Date: Thu, 1 Aug 2024 21:03:49 +0300 Subject: [PATCH] link wintun to python architecture as opposed to machine architecture --- pytun_pmd3/wintun.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pytun_pmd3/wintun.py b/pytun_pmd3/wintun.py index 3fc691a..4d859ad 100644 --- a/pytun_pmd3/wintun.py +++ b/pytun_pmd3/wintun.py @@ -13,8 +13,24 @@ DEFAULT_ADAPTER_NAME = 'pywintun' DEFAULT_RING_CAPCITY = 0x400000 + +def get_python_arch(): + python_compiler = platform.python_compiler() + if '32 bit' in python_compiler: + if 'Intel' in python_compiler: + return 'x86' + elif 'ARM' in python_compiler: + return 'arm' + elif '64 bit' in python_compiler: + if 'AMD64' in python_compiler: + return 'amd64' + elif 'ARM64' in python_compiler: + return 'arm64' + return platform.machine() # best effort + + # Load the Wintun library -wintun = WinDLL(str(Path(__file__).parent / f'wintun/bin/{platform.uname().machine}/wintun.dll'), use_last_error=True) +wintun = WinDLL(str(Path(__file__).parent / f'wintun/bin/{get_python_arch()}/wintun.dll'), use_last_error=True) iphlpapi = WinDLL('Iphlpapi.dll') kernel32 = WinDLL('kernel32.dll')