python - How do I tell which actual dll is being returned (x86 v x64)? -
let's focus on 1 dll: c:\windows\system32\wbem\wmiutils.dll. why? because it's file in discovered windows delivers different dll depending on process architecture.
tldr; there way programmatically determine actual path of dll returned file system redirector?
i understand if launched x86 process, c:\windows\syswow64\wbem\wmiutils.dll. and, if launched x64 process, c:\windows\system32\wbem\wmiutils.dll.
i need determine wmiutils.dll i'm looking at. redirector makes system32\wbem\wmiutils.dll , feel identical it's not. if use parent path, c:\windows\system32\wbem though may/may not looking @ c:\windows\syswow64\wbem.
any sweet python magic make happen? can't seem see other languages can port. based on use case, i've come couple hacks they're that. hoping has found solution easy parent path works in case.
import ctypes, hashlib k32 = ctypes.windll.kernel32 oldvalue = ctypes.c_long(0) k32.wow64disablewow64fsredirection(ctypes.byref(oldvalue)) # should open 32-bit open(r"c:\windows\system32\wbem\wmiutil.dll", "rb") f: checksum32 = hashlib.md5(f.read()).hexdigest() k32.wow64revertwow64fsredirection(oldvalue) # should use windows thinks need open(r"c:\windows\system32\wbem\wmiutil.dll", "rb") f: checksum64 = hashlib.md5(f.read()).hexdigest() if (checksum32 != checksum64): print("you're running 64bit wmiutil dll")
i don't have windows python test this, should work according https://msdn.microsoft.com/en-us/library/windows/desktop/aa365745%28v=vs.85%29.aspx.
i think easier way test creating struct , seeing if it's 8 bytes or 4 bytes. can assume windows using 64-bit version of dlls if it's 8 bytes.
Comments
Post a Comment