mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-16 02:02:53 -07:00
Also updates: - importlib-metadata-0.7 - jaraco-windows - jaraco.classes-1.5 - jaraco.collections-1.6.0 - jaraco.functools-1.20 - jaraco.structures-1.1.2 - jaraco.text-1.10.1 - jaraco.ui-1.6 - more-itertools-4.3.0 - path.py-11.5.0 - six-1.12.0
62 lines
1.3 KiB
Python
62 lines
1.3 KiB
Python
"""
|
|
Support for Credential Vault
|
|
"""
|
|
|
|
import ctypes
|
|
from ctypes.wintypes import DWORD, LPCWSTR, BOOL, LPWSTR, FILETIME
|
|
|
|
try:
|
|
from ctypes.wintypes import LPBYTE
|
|
except ImportError:
|
|
LPBYTE = ctypes.POINTER(ctypes.wintypes.BYTE)
|
|
|
|
|
|
class CredentialAttribute(ctypes.Structure):
|
|
_fields_ = []
|
|
|
|
|
|
class Credential(ctypes.Structure):
|
|
_fields_ = [
|
|
('flags', DWORD),
|
|
('type', DWORD),
|
|
('target_name', LPWSTR),
|
|
('comment', LPWSTR),
|
|
('last_written', FILETIME),
|
|
('credential_blob_size', DWORD),
|
|
('credential_blob', LPBYTE),
|
|
('persist', DWORD),
|
|
('attribute_count', DWORD),
|
|
('attributes', ctypes.POINTER(CredentialAttribute)),
|
|
('target_alias', LPWSTR),
|
|
('user_name', LPWSTR),
|
|
]
|
|
|
|
def __del__(self):
|
|
ctypes.windll.advapi32.CredFree(ctypes.byref(self))
|
|
|
|
|
|
PCREDENTIAL = ctypes.POINTER(Credential)
|
|
|
|
CredRead = ctypes.windll.advapi32.CredReadW
|
|
CredRead.argtypes = (
|
|
LPCWSTR, # TargetName
|
|
DWORD, # Type
|
|
DWORD, # Flags
|
|
ctypes.POINTER(PCREDENTIAL), # Credential
|
|
)
|
|
CredRead.restype = BOOL
|
|
|
|
CredWrite = ctypes.windll.advapi32.CredWriteW
|
|
CredWrite.argtypes = (
|
|
PCREDENTIAL, # Credential
|
|
DWORD, # Flags
|
|
)
|
|
CredWrite.restype = BOOL
|
|
|
|
CredDelete = ctypes.windll.advapi32.CredDeleteW
|
|
CredDelete.argtypes = (
|
|
LPCWSTR, # TargetName
|
|
DWORD, # Type
|
|
DWORD, # Flags
|
|
)
|
|
CredDelete.restype = BOOL
|