Skip to content

Commit

Permalink
Merge pull request #13 from vToMy/master
Browse files Browse the repository at this point in the history
link wintun to python architecture as opposed to machine architecture
  • Loading branch information
doronz88 committed Aug 4, 2024
2 parents af49d0e + 3829c49 commit cd5f68a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pytun_pmd3/wintun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down

0 comments on commit cd5f68a

Please sign in to comment.