我正在为某人编写Python3脚本,该脚本通过ctypes利用advapi dll及其LogonUserW函数。
运行代码时
在__init__函数中
dll_location = find_library("advapi32");
if (dll_location == None):
raise FileNotFoundError
adv_dll = WinDLL(dll_location);
#gets the pointer to the function
logonUser = adv_dll.LogonUserW;
self.logonUser = logonUser
登录(用户名,域,密码)功能
#Sets the parameters to call the DLL
loginType = DWORD(2)
loginProvider = DWORD(0)
handle = PHANDLE()
user = LPCSTR(username.encode());
pw = LPCSTR(password.encode());
dom = LPCSTR(domain.encode());
rescode = self.logonUser(user, dom, pw, loginType, loginProvider, handle);
它引发 OSError: exception: access violation writing 0x0000000000000000
任何想法可能导致错误的原因以及如何解决?
PS:是的,我知道我不遵循PEP 8的变量名,我通常是Java程序员。
相关分类