Jul-27-2018, 12:30 AM
I'm not sure about how to proceed when dealing with Windows (W10 1803, if that helps). Here's the code I'm trying to work with:
token = ctypes.create_unicode_buffer(1024) handle = ctypes.windll.Kernel32.GetModuleHandleW() print(ctypes.windll.Advapi32.OpenProcessToken(handle, 'WRITE_OWNER', token)) print(ctypes.windll.Kernel32.GetLastError()) sys.exit()The error I get is 6 - unknown handle. So, my question is: how do I get the handle. Eventually, what I want to do is enable the SE_TAKE_OWNERSHIP_NAME privilege and open a registry key with WRITE_OWNER access. Microsoft makes you go through 10 steps to do one simple thing. So, I'm trying to change the privileges of the access token of the script (Python.exe, I guess) so that I can access an administrator level registry key.