mirror of
https://github.com/naksyn/PythonMemoryModule
synced 2026-06-06 16:24:25 +00:00
command line support (partial) via PEB stomping
This update include support to passing command line parameters to unmanaged exe via PEB stomping. This technique is not working with every executable since it depends on which functions are used to pass arguments. Generally, to get a universally working technique would be required to hook GetCommandlineA GetCommandlineW __getmainargs and __wgetmainargs since PEB stomping won't cover all cases, more details here: https://blog-30cm-tw.translate.goog/2020/08/windows-c-mainargc-argv.html?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=it&_x_tr_pto=wapp However, during my testing I found that mimikatz and several go binaries are working just by doing PEB stomping. On the other hand, cmdline passing via PEB stomping alone to mingw and VS compiled binaries won't likely work.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
from .apiproxy import is_implemented, get_target, resolve
|
||||
from .error import WinproxyError, ExportNotFound
|
||||
from .apis import * # Import all functions
|
||||
@@ -0,0 +1,122 @@
|
||||
import ctypes
|
||||
import functools
|
||||
|
||||
import windows.generated_def as gdef
|
||||
from .error import ExportNotFound
|
||||
from windows.pycompat import is_py3
|
||||
|
||||
# Utils
|
||||
def is_implemented(apiproxy):
|
||||
"""Return :obj:`True` if DLL/Api can be found"""
|
||||
try:
|
||||
apiproxy.force_resolution()
|
||||
except ExportNotFound:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def get_target(apiproxy):
|
||||
"""POC for newshook"""
|
||||
return apiproxy.target_dll, apiproxy.target_func
|
||||
|
||||
|
||||
def resolve(apiproxy):
|
||||
"""Resolve the address of ``apiproxy``. Might raise if ``apiproxy`` is not implemented"""
|
||||
apiproxy.force_resolution()
|
||||
func = ctypes.WinDLL(apiproxy.target_dll)[apiproxy.target_func]
|
||||
return ctypes.cast(func, gdef.PVOID).value
|
||||
|
||||
|
||||
class NeededParameterType(object):
|
||||
_inst = None
|
||||
|
||||
def __new__(cls):
|
||||
if cls._inst is None:
|
||||
cls._inst = super(NeededParameterType, cls).__new__(cls)
|
||||
return cls._inst
|
||||
|
||||
def __repr__(self):
|
||||
return "NeededParameter"
|
||||
|
||||
NeededParameter = NeededParameterType()
|
||||
sentinel = object()
|
||||
|
||||
class ApiProxy(object):
|
||||
APIDLL = None
|
||||
"""Create a python wrapper around a kernel32 function"""
|
||||
def __init__(self, func_name=None, error_check=sentinel, deffunc_module=None):
|
||||
self.deffunc_module = deffunc_module if deffunc_module is not None else gdef.winfuncs
|
||||
self.func_name = func_name
|
||||
if error_check is sentinel:
|
||||
error_check = self.default_error_check
|
||||
|
||||
self.error_check = error_check
|
||||
self._cprototyped = None
|
||||
|
||||
def __call__(self, python_proxy):
|
||||
# Use the name of the sub-function if None was given
|
||||
if self.func_name is None:
|
||||
self.func_name = python_proxy.__name__
|
||||
|
||||
errchk = None
|
||||
if self.error_check is not None:
|
||||
errchk = functools.wraps(self.error_check)(functools.partial(self.error_check, self.func_name))
|
||||
|
||||
prototype = getattr(self.deffunc_module, self.func_name + "Prototype")
|
||||
params = getattr(self.deffunc_module, self.func_name + "Params")
|
||||
python_proxy.prototype = prototype
|
||||
python_proxy.params = params
|
||||
python_proxy.errcheck = errchk
|
||||
python_proxy.target_dll = self.APIDLL
|
||||
python_proxy.target_func = self.func_name
|
||||
# Give access to the 'ApiProxy' object from the function
|
||||
python_proxy.proxy = self
|
||||
params_name = [param[1] for param in params]
|
||||
if (self.error_check.__doc__):
|
||||
doc = python_proxy.__doc__
|
||||
doc = doc if doc else ""
|
||||
python_proxy.__doc__ = doc + "\nErrcheck:\n " + self.error_check.__doc__
|
||||
|
||||
def generate_ctypes_function():
|
||||
try:
|
||||
api_dll = ctypes.windll[self.APIDLL]
|
||||
except WindowsError as e:
|
||||
if e.winerror == gdef.ERROR_BAD_EXE_FORMAT:
|
||||
e.strerror = e.strerror.replace("%1", "<{0}>".format(self.APIDLL))
|
||||
raise
|
||||
try:
|
||||
c_prototyped = prototype((self.func_name, api_dll), params)
|
||||
except (AttributeError, WindowsError):
|
||||
raise ExportNotFound(self.func_name, self.APIDLL)
|
||||
if errchk is not None:
|
||||
c_prototyped.errcheck = errchk
|
||||
self._cprototyped = c_prototyped
|
||||
|
||||
def perform_call(*args):
|
||||
if self._cprototyped is None:
|
||||
generate_ctypes_function()
|
||||
try:
|
||||
return self._cprototyped(*args)
|
||||
except ctypes.ArgumentError as e:
|
||||
# We just add a conversion ctypes argument fail
|
||||
# We can do some heavy computation if needed
|
||||
# Not a case that normally happen
|
||||
|
||||
# "argument 2: <type 'exceptions.TypeError'>: wrong type"
|
||||
# Thx ctypes..
|
||||
argnbstr, ecx, reason = e.args[0].split(":") # py2 / py3 compat :)
|
||||
if not argnbstr.startswith("argument "):
|
||||
raise # Don't knnow if it can happen
|
||||
argnb = int(argnbstr[len("argument "):])
|
||||
badarg = args[argnb - 1]
|
||||
if badarg is NeededParameter:
|
||||
badargname = params_name[argnb - 1]
|
||||
raise TypeError("{0}: Missing Mandatory parameter <{1}>".format(self.func_name, badargname))
|
||||
# Not NeededParameter: the caller need to fix the used param :)
|
||||
# raise the real ctypes error
|
||||
raise
|
||||
|
||||
|
||||
setattr(python_proxy, "ctypes_function", perform_call)
|
||||
setattr(python_proxy, "force_resolution", generate_ctypes_function)
|
||||
return python_proxy
|
||||
@@ -0,0 +1,27 @@
|
||||
from .advapi32 import *
|
||||
from .cfgmgr32 import *
|
||||
from .crypt32 import *
|
||||
from .cryptui import *
|
||||
from .dbghelp import *
|
||||
from .dnsapi import *
|
||||
from .iphlpapi import *
|
||||
from .kernel32 import *
|
||||
from .ktmw32 import *
|
||||
from .ntdll import *
|
||||
from .netapi32 import *
|
||||
from .ole32 import *
|
||||
from .oleaut32 import *
|
||||
from .oleacc import *
|
||||
from .psapi import *
|
||||
from .setupapi import *
|
||||
from .shell32 import *
|
||||
from .shlwapi import *
|
||||
from .tdh import *
|
||||
from .user32 import *
|
||||
from .version import *
|
||||
from .virtdisk import *
|
||||
from .wevtapi import *
|
||||
from .winhttp import *
|
||||
from .wininet import *
|
||||
from .wintrust import *
|
||||
from .ws2_32 import *
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,745 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
import windows.pycompat
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import fail_on_zero, succeed_on_zero, result_is_error_code, result_is_handle, no_error_check, result_is_ntstatus
|
||||
|
||||
class Advapi32Proxy(ApiProxy):
|
||||
APIDLL = "advapi32"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
# Process
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CreateProcessAsUserA(hToken, lpApplicationName, lpCommandLine=None, lpProcessAttributes=None, lpThreadAttributes=None, bInheritHandles=False,
|
||||
dwCreationFlags=0, lpEnvironment=None, lpCurrentDirectory=None, lpStartupInfo=None, lpProcessInformation=None):
|
||||
if lpStartupInfo is None:
|
||||
StartupInfo = gdef.STARTUPINFOA()
|
||||
StartupInfo.cb = ctypes.sizeof(StartupInfo)
|
||||
StartupInfo.dwFlags = 0
|
||||
# StartupInfo.wShowWindow = gdef.SW_HIDE
|
||||
lpStartupInfo = ctypes.byref(StartupInfo)
|
||||
if lpProcessInformation is None:
|
||||
lpProcessInformation = ctypes.byref(gdef.PROCESS_INFORMATION())
|
||||
return CreateProcessAsUserA.ctypes_function(hToken, lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation)
|
||||
|
||||
return CreateProcessAsUserA.ctypes_function(hToken, lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CreateProcessAsUserW(hToken, lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation):
|
||||
return CreateProcessAsUserW.ctypes_function(hToken, lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation)
|
||||
|
||||
|
||||
# Token
|
||||
|
||||
@Advapi32Proxy()
|
||||
def OpenProcessToken(ProcessHandle=None, DesiredAccess=NeededParameter, TokenHandle=NeededParameter):
|
||||
"""If ProcessHandle is None: take the current process"""
|
||||
if ProcessHandle is None:
|
||||
# TODO: FAIL
|
||||
ProcessHandle = GetCurrentProcess()
|
||||
return OpenProcessToken.ctypes_function(ProcessHandle, DesiredAccess, TokenHandle)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def OpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle):
|
||||
return OpenThreadToken.ctypes_function(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def SetThreadToken(Thread, Token):
|
||||
if isinstance(Thread, (int, long)):
|
||||
Thread = gdef.HANDLE(Thread)
|
||||
return SetThreadToken.ctypes_function(Thread, Token)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def DuplicateToken(ExistingTokenHandle, ImpersonationLevel, DuplicateTokenHandle):
|
||||
return DuplicateToken.ctypes_function(ExistingTokenHandle, ImpersonationLevel, DuplicateTokenHandle)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def DuplicateTokenEx(hExistingToken, dwDesiredAccess, lpTokenAttributes, ImpersonationLevel, TokenType, phNewToken):
|
||||
return DuplicateTokenEx.ctypes_function(hExistingToken, dwDesiredAccess, lpTokenAttributes, ImpersonationLevel, TokenType, phNewToken)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetTokenInformation(TokenHandle=NeededParameter, TokenInformationClass=NeededParameter, TokenInformation=None, TokenInformationLength=0, ReturnLength=None):
|
||||
if ReturnLength is None:
|
||||
ReturnLength = ctypes.byref(gdef.DWORD())
|
||||
return GetTokenInformation.ctypes_function(TokenHandle, TokenInformationClass, TokenInformation, TokenInformationLength, ReturnLength)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def SetTokenInformation(TokenHandle, TokenInformationClass, TokenInformation, TokenInformationLength):
|
||||
return SetTokenInformation.ctypes_function(TokenHandle, TokenInformationClass, TokenInformation, TokenInformationLength)
|
||||
|
||||
|
||||
# Token - Privilege
|
||||
|
||||
@Advapi32Proxy()
|
||||
def LookupPrivilegeValueA(lpSystemName=None, lpName=NeededParameter, lpLuid=NeededParameter):
|
||||
return LookupPrivilegeValueA.ctypes_function(lpSystemName, lpName, lpLuid)
|
||||
|
||||
|
||||
@Advapi32Proxy()
|
||||
def LookupPrivilegeValueW(lpSystemName=None, lpName=NeededParameter, lpLuid=NeededParameter):
|
||||
return LookupPrivilegeValueW.ctypes_function(lpSystemName, lpName, lpLuid)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def LookupPrivilegeNameA(lpSystemName, lpLuid, lpName, cchName):
|
||||
return LookupPrivilegeNameA.ctypes_function(lpSystemName, lpLuid, lpName, cchName)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def LookupPrivilegeNameW(lpSystemName, lpLuid, lpName, cchName):
|
||||
return LookupPrivilegeNameW.ctypes_function(lpSystemName, lpLuid, lpName, cchName)
|
||||
|
||||
|
||||
@Advapi32Proxy()
|
||||
def AdjustTokenPrivileges(TokenHandle, DisableAllPrivileges=False, NewState=NeededParameter, BufferLength=None, PreviousState=None, ReturnLength=None):
|
||||
if BufferLength is None:
|
||||
BufferLength = ctypes.sizeof(NewState)
|
||||
return AdjustTokenPrivileges.ctypes_function(TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength)
|
||||
|
||||
# Access check
|
||||
|
||||
@Advapi32Proxy()
|
||||
def MapGenericMask(AccessMask, GenericMapping):
|
||||
return MapGenericMask.ctypes_function(AccessMask, GenericMapping)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def AccessCheck(pSecurityDescriptor, ClientToken, DesiredAccess, GenericMapping, PrivilegeSet, PrivilegeSetLength, GrantedAccess, AccessStatus):
|
||||
return AccessCheck.ctypes_function(pSecurityDescriptor, ClientToken, DesiredAccess, GenericMapping, PrivilegeSet, PrivilegeSetLength, GrantedAccess, AccessStatus)
|
||||
|
||||
# Sid
|
||||
|
||||
@Advapi32Proxy()
|
||||
def LookupAccountSidA(lpSystemName, lpSid, lpName, cchName, lpReferencedDomainName, cchReferencedDomainName, peUse):
|
||||
return LookupAccountSidA.ctypes_function(lpSystemName, lpSid, lpName, cchName, lpReferencedDomainName, cchReferencedDomainName, peUse)
|
||||
|
||||
|
||||
@Advapi32Proxy()
|
||||
def LookupAccountSidW(lpSystemName, lpSid, lpName, cchName, lpReferencedDomainName, cchReferencedDomainName, peUse):
|
||||
return LookupAccountSidW.ctypes_function(lpSystemName, lpSid, lpName, cchName, lpReferencedDomainName, cchReferencedDomainName, peUse)
|
||||
|
||||
|
||||
@Advapi32Proxy()
|
||||
def LookupAccountNameA(lpSystemName, lpAccountName, Sid, cbSid, ReferencedDomainName, cchReferencedDomainName, peUse):
|
||||
return LookupAccountNameA.ctypes_function(lpSystemName, lpAccountName, Sid, cbSid, ReferencedDomainName, cchReferencedDomainName, peUse)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def LookupAccountNameW(lpSystemName, lpAccountName, Sid, cbSid, ReferencedDomainName, cchReferencedDomainName, peUse):
|
||||
return LookupAccountNameW.ctypes_function(lpSystemName, lpAccountName, Sid, cbSid, ReferencedDomainName, cchReferencedDomainName, peUse)
|
||||
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CreateWellKnownSid(WellKnownSidType, DomainSid=None, pSid=None, cbSid=NeededParameter):
|
||||
return CreateWellKnownSid.ctypes_function(WellKnownSidType, DomainSid, pSid, cbSid)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetLengthSid(pSid):
|
||||
return GetLengthSid.ctypes_function(pSid)
|
||||
|
||||
|
||||
@Advapi32Proxy(error_check=no_error_check)
|
||||
def EqualSid(pSid1, pSid2):
|
||||
return EqualSid.ctypes_function(pSid1, pSid2)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetSidSubAuthority(pSid, nSubAuthority):
|
||||
return GetSidSubAuthority.ctypes_function(pSid, nSubAuthority)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetSidSubAuthorityCount(pSid):
|
||||
return GetSidSubAuthorityCount.ctypes_function(pSid)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def ConvertStringSidToSidA(StringSid, Sid):
|
||||
return ConvertStringSidToSidA.ctypes_function(StringSid, Sid)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def ConvertStringSidToSidW(StringSid, Sid):
|
||||
return ConvertStringSidToSidW.ctypes_function(StringSid, Sid)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def ConvertSidToStringSidA(Sid, StringSid):
|
||||
return ConvertSidToStringSidA.ctypes_function(Sid, StringSid)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def ConvertSidToStringSidW(Sid, StringSid):
|
||||
return ConvertSidToStringSidW.ctypes_function(Sid, StringSid)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CopySid(nDestinationSidLength, pDestinationSid, pSourceSid):
|
||||
return CopySid.ctypes_function(nDestinationSidLength, pDestinationSid, pSourceSid)
|
||||
|
||||
|
||||
# Security descriptor
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def GetNamedSecurityInfoA(pObjectName, ObjectType, SecurityInfo, ppsidOwner=None, ppsidGroup=None, ppDacl=None, ppSacl=None, ppSecurityDescriptor=None):
|
||||
return GetNamedSecurityInfoA.ctypes_function(pObjectName, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def GetNamedSecurityInfoW(pObjectName, ObjectType, SecurityInfo, ppsidOwner=None, ppsidGroup=None, ppDacl=None, ppSacl=None, ppSecurityDescriptor=None):
|
||||
return GetNamedSecurityInfoW.ctypes_function(pObjectName, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def GetSecurityInfo(handle, ObjectType, SecurityInfo, ppsidOwner=None, ppsidGroup=None, ppDacl=None, ppSacl=None, ppSecurityDescriptor=None):
|
||||
return GetSecurityInfo.ctypes_function(handle, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def SetSecurityInfo(handle, ObjectType, SecurityInfo, psidOwner, psidGroup, pDacl, pSacl):
|
||||
return SetSecurityInfo.ctypes_function(handle, ObjectType, SecurityInfo, psidOwner, psidGroup, pDacl, pSacl)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def SetNamedSecurityInfoA(pObjectName, ObjectType, SecurityInfo, psidOwner, psidGroup, pDacl, pSacl):
|
||||
return SetNamedSecurityInfoA.ctypes_function(pObjectName, ObjectType, SecurityInfo, psidOwner, psidGroup, pDacl, pSacl)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def SetNamedSecurityInfoW(pObjectName, ObjectType, SecurityInfo, psidOwner, psidGroup, pDacl, pSacl):
|
||||
return SetNamedSecurityInfoW.ctypes_function(pObjectName, ObjectType, SecurityInfo, psidOwner, psidGroup, pDacl, pSacl)
|
||||
|
||||
|
||||
@Advapi32Proxy()
|
||||
def InitializeSecurityDescriptor(pSecurityDescriptor, dwRevision):
|
||||
return InitializeSecurityDescriptor.ctypes_function(pSecurityDescriptor, dwRevision)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def IsValidSecurityDescriptor(pSecurityDescriptor):
|
||||
return IsValidSecurityDescriptor.ctypes_function(pSecurityDescriptor)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def ConvertStringSecurityDescriptorToSecurityDescriptorA(StringSecurityDescriptor, StringSDRevision, SecurityDescriptor, SecurityDescriptorSize):
|
||||
return ConvertStringSecurityDescriptorToSecurityDescriptorA.ctypes_function(StringSecurityDescriptor, StringSDRevision, SecurityDescriptor, SecurityDescriptorSize)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def ConvertStringSecurityDescriptorToSecurityDescriptorW(StringSecurityDescriptor, StringSDRevision, SecurityDescriptor, SecurityDescriptorSize):
|
||||
return ConvertStringSecurityDescriptorToSecurityDescriptorW.ctypes_function(StringSecurityDescriptor, StringSDRevision, SecurityDescriptor, SecurityDescriptorSize)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def ConvertSecurityDescriptorToStringSecurityDescriptorA(SecurityDescriptor, RequestedStringSDRevision, SecurityInformation, StringSecurityDescriptor, StringSecurityDescriptorLen):
|
||||
return ConvertSecurityDescriptorToStringSecurityDescriptorA.ctypes_function(SecurityDescriptor, RequestedStringSDRevision, SecurityInformation, StringSecurityDescriptor, StringSecurityDescriptorLen)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def ConvertSecurityDescriptorToStringSecurityDescriptorW(SecurityDescriptor, RequestedStringSDRevision, SecurityInformation, StringSecurityDescriptor, StringSecurityDescriptorLen):
|
||||
return ConvertSecurityDescriptorToStringSecurityDescriptorW.ctypes_function(SecurityDescriptor, RequestedStringSDRevision, SecurityInformation, StringSecurityDescriptor, StringSecurityDescriptorLen)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetSecurityDescriptorDacl(pSecurityDescriptor, lpbDaclPresent, pDacl, lpbDaclDefaulted):
|
||||
return GetSecurityDescriptorDacl.ctypes_function(pSecurityDescriptor, lpbDaclPresent, pDacl, lpbDaclDefaulted)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetSecurityDescriptorLength(pSecurityDescriptor):
|
||||
return GetSecurityDescriptorLength.ctypes_function(pSecurityDescriptor)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetSecurityDescriptorControl(pSecurityDescriptor, pControl, lpdwRevision):
|
||||
return GetSecurityDescriptorControl.ctypes_function(pSecurityDescriptor, pControl, lpdwRevision)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetSecurityDescriptorOwner(pSecurityDescriptor, pOwner, lpbOwnerDefaulted):
|
||||
return GetSecurityDescriptorOwner.ctypes_function(pSecurityDescriptor, pOwner, lpbOwnerDefaulted)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def SetSecurityDescriptorOwner(pSecurityDescriptor, pOwner, bOwnerDefaulted):
|
||||
return SetSecurityDescriptorOwner.ctypes_function(pSecurityDescriptor, pOwner, bOwnerDefaulted)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetSecurityDescriptorGroup(pSecurityDescriptor, pGroup, lpbGroupDefaulted):
|
||||
return GetSecurityDescriptorGroup.ctypes_function(pSecurityDescriptor, pGroup, lpbGroupDefaulted)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetSecurityDescriptorSacl(pSecurityDescriptor, lpbSaclPresent, pSacl, lpbSaclDefaulted):
|
||||
return GetSecurityDescriptorSacl.ctypes_function(pSecurityDescriptor, lpbSaclPresent, pSacl, lpbSaclDefaulted)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def MakeAbsoluteSD(pSelfRelativeSecurityDescriptor, pAbsoluteSecurityDescriptor, lpdwAbsoluteSecurityDescriptorSize, pDacl, lpdwDaclSize, pSacl, lpdwSaclSize, pOwner, lpdwOwnerSize, pPrimaryGroup, lpdwPrimaryGroupSize):
|
||||
return MakeAbsoluteSD.ctypes_function(pSelfRelativeSecurityDescriptor, pAbsoluteSecurityDescriptor, lpdwAbsoluteSecurityDescriptorSize, pDacl, lpdwDaclSize, pSacl, lpdwSaclSize, pOwner, lpdwOwnerSize, pPrimaryGroup, lpdwPrimaryGroupSize)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def MakeSelfRelativeSD(pAbsoluteSecurityDescriptor, pSelfRelativeSecurityDescriptor, lpdwBufferLength):
|
||||
return MakeSelfRelativeSD.ctypes_function(pAbsoluteSecurityDescriptor, pSelfRelativeSecurityDescriptor, lpdwBufferLength)
|
||||
|
||||
# ACE - ACL
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass):
|
||||
return GetAclInformation.ctypes_function(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetAce(pAcl, dwAceIndex, pAce):
|
||||
return GetAce.ctypes_function(pAcl, dwAceIndex, pAce)
|
||||
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetStringConditionFromBinary(BinaryAceCondition, BinaryAceConditionSize=None, Reserved1=0, StringAceCondition=NeededParameter):
|
||||
if BinaryAceConditionSize is None:
|
||||
BinaryAceConditionSize = len(BinaryAceCondition)
|
||||
return GetStringConditionFromBinary.ctypes_function(BinaryAceCondition, BinaryAceConditionSize, Reserved1, StringAceCondition)
|
||||
|
||||
# Registry
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegOpenKeyExA(hKey, lpSubKey, ulOptions, samDesired, phkResult):
|
||||
return RegOpenKeyExA.ctypes_function(hKey, lpSubKey, ulOptions, samDesired, phkResult)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegOpenKeyExW(hKey, lpSubKey, ulOptions, samDesired, phkResult):
|
||||
return RegOpenKeyExW.ctypes_function(hKey, lpSubKey, ulOptions, samDesired, phkResult)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegCreateKeyExA(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition):
|
||||
return RegCreateKeyExA.ctypes_function(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegCreateKeyExW(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition):
|
||||
return RegCreateKeyExW.ctypes_function(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegGetValueA(hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData):
|
||||
return RegGetValueA.ctypes_function(hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegGetValueW(hkey, lpSubKey=None, lpValue=NeededParameter, dwFlags=0, pdwType=None, pvData=None, pcbData=None):
|
||||
return RegGetValueW.ctypes_function(hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegQueryValueExA(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData):
|
||||
return RegQueryValueExA.ctypes_function(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegQueryValueExW(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData):
|
||||
return RegQueryValueExW.ctypes_function(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegCloseKey(hKey):
|
||||
return RegCloseKey.ctypes_function(hKey)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegSetValueExW(hKey, lpValueName, Reserved, dwType, lpData, cbData):
|
||||
return RegSetValueExW.ctypes_function(hKey, lpValueName, Reserved, dwType, lpData, cbData)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegSetValueExA(hKey, lpValueName, Reserved, dwType, lpData, cbData):
|
||||
return RegSetValueExA.ctypes_function(hKey, lpValueName, Reserved, dwType, lpData, cbData)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegSetKeyValueA(hKey, lpSubKey, lpValueName, dwType, lpData, cbData):
|
||||
return RegSetKeyValueA.ctypes_function(hKey, lpSubKey, lpValueName, dwType, lpData, cbData)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegSetKeyValueW(hKey, lpSubKey, lpValueName, dwType, lpData, cbData):
|
||||
return RegSetKeyValueW.ctypes_function(hKey, lpSubKey, lpValueName, dwType, lpData, cbData)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegEnumKeyExA(hKey, dwIndex, lpName, lpcchName, lpReserved, lpClass, lpcchClass, lpftLastWriteTime):
|
||||
return RegEnumKeyExA.ctypes_function(hKey, dwIndex, lpName, lpcchName, lpReserved, lpClass, lpcchClass, lpftLastWriteTime)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegEnumKeyExW(hKey, dwIndex, lpName, lpcchName, lpReserved, lpClass, lpcchClass, lpftLastWriteTime):
|
||||
return RegEnumKeyExW.ctypes_function(hKey, dwIndex, lpName, lpcchName, lpReserved, lpClass, lpcchClass, lpftLastWriteTime)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegGetKeySecurity(hKey, SecurityInformation, pSecurityDescriptor, lpcbSecurityDescriptor):
|
||||
return RegGetKeySecurity.ctypes_function(hKey, SecurityInformation, pSecurityDescriptor, lpcbSecurityDescriptor)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegQueryInfoKeyA(hKey, lpClass, lpcchClass, lpReserved, lpcSubKeys, lpcbMaxSubKeyLen, lpcbMaxClassLen, lpcValues, lpcbMaxValueNameLen, lpcbMaxValueLen, lpcbSecurityDescriptor, lpftLastWriteTime):
|
||||
return RegQueryInfoKeyA.ctypes_function(hKey, lpClass, lpcchClass, lpReserved, lpcSubKeys, lpcbMaxSubKeyLen, lpcbMaxClassLen, lpcValues, lpcbMaxValueNameLen, lpcbMaxValueLen, lpcbSecurityDescriptor, lpftLastWriteTime)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegQueryInfoKeyW(hKey, lpClass, lpcchClass, lpReserved, lpcSubKeys, lpcbMaxSubKeyLen, lpcbMaxClassLen, lpcValues, lpcbMaxValueNameLen, lpcbMaxValueLen, lpcbSecurityDescriptor, lpftLastWriteTime):
|
||||
return RegQueryInfoKeyW.ctypes_function(hKey, lpClass, lpcchClass, lpReserved, lpcSubKeys, lpcbMaxSubKeyLen, lpcbMaxClassLen, lpcValues, lpcbMaxValueNameLen, lpcbMaxValueLen, lpcbSecurityDescriptor, lpftLastWriteTime)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegDeleteKeyValueW(hKey, lpSubKey, lpValueName):
|
||||
return RegDeleteKeyValueW.ctypes_function(hKey, lpSubKey, lpValueName)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegDeleteKeyValueA(hKey, lpSubKey, lpValueName):
|
||||
return RegDeleteKeyValueA.ctypes_function(hKey, lpSubKey, lpValueName)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegDeleteKeyExA(hKey, lpSubKey, samDesired, Reserved):
|
||||
return RegDeleteKeyExA.ctypes_function(hKey, lpSubKey, samDesired, Reserved)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegDeleteKeyExW(hKey, lpSubKey, samDesired, Reserved):
|
||||
return RegDeleteKeyExW.ctypes_function(hKey, lpSubKey, samDesired, Reserved)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegDeleteValueA(hKey, lpValueName):
|
||||
return RegDeleteValueA.ctypes_function(hKey, lpValueName)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegDeleteValueW(hKey, lpValueName):
|
||||
return RegDeleteValueW.ctypes_function(hKey, lpValueName)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegDeleteTreeA(hKey, lpSubKey):
|
||||
return RegDeleteTreeA.ctypes_function(hKey, lpSubKey)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegDeleteTreeW(hKey, lpSubKey):
|
||||
return RegDeleteTreeW.ctypes_function(hKey, lpSubKey)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegEnumValueA(hKey, dwIndex, lpValueName, lpcchValueName, lpReserved, lpType, lpData, lpcbData):
|
||||
return RegEnumValueA.ctypes_function(hKey, dwIndex, lpValueName, lpcchValueName, lpReserved, lpType, lpData, lpcbData)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegEnumValueW(hKey, dwIndex, lpValueName, lpcchValueName, lpReserved, lpType, lpData, lpcbData):
|
||||
return RegEnumValueW.ctypes_function(hKey, dwIndex, lpValueName, lpcchValueName, lpReserved, lpType, lpData, lpcbData)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegSaveKeyA(hKey, lpFile, lpSecurityAttributes):
|
||||
return RegSaveKeyA.ctypes_function(hKey, lpFile, lpSecurityAttributes)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegSaveKeyW(hKey, lpFile, lpSecurityAttributes):
|
||||
return RegSaveKeyW.ctypes_function(hKey, lpFile, lpSecurityAttributes)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegSaveKeyExA(hKey, lpFile, lpSecurityAttributes, Flags):
|
||||
return RegSaveKeyExA.ctypes_function(hKey, lpFile, lpSecurityAttributes, Flags)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegSaveKeyExW(hKey, lpFile, lpSecurityAttributes, Flags):
|
||||
return RegSaveKeyExW.ctypes_function(hKey, lpFile, lpSecurityAttributes, Flags)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegLoadKeyA(hKey, lpSubKey, lpFile):
|
||||
return RegLoadKeyA.ctypes_function(hKey, lpSubKey, lpFile)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegLoadKeyW(hKey, lpSubKey, lpFile):
|
||||
return RegLoadKeyW.ctypes_function(hKey, lpSubKey, lpFile)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegUnLoadKeyA(hKey, lpSubKey):
|
||||
return RegUnLoadKeyA.ctypes_function(hKey, lpSubKey)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegUnLoadKeyW(hKey, lpSubKey):
|
||||
return RegUnLoadKeyW.ctypes_function(hKey, lpSubKey)
|
||||
|
||||
# Service
|
||||
|
||||
@Advapi32Proxy()
|
||||
def OpenSCManagerA(lpMachineName=None, lpDatabaseName=None, dwDesiredAccess=gdef.SC_MANAGER_ALL_ACCESS):
|
||||
return OpenSCManagerA.ctypes_function(lpMachineName, lpDatabaseName, dwDesiredAccess)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def OpenSCManagerW(lpMachineName=None, lpDatabaseName=None, dwDesiredAccess=gdef.SC_MANAGER_ALL_ACCESS):
|
||||
return OpenSCManagerW.ctypes_function(lpMachineName, lpDatabaseName, dwDesiredAccess)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def EnumServicesStatusExA(hSCManager, InfoLevel, dwServiceType, dwServiceState, lpServices, cbBufSize, pcbBytesNeeded, lpServicesReturned, lpResumeHandle, pszGroupName):
|
||||
return EnumServicesStatusExA.ctypes_function(hSCManager, InfoLevel, dwServiceType, dwServiceState, lpServices, cbBufSize, pcbBytesNeeded, lpServicesReturned, lpResumeHandle, pszGroupName)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def EnumServicesStatusExW(hSCManager, InfoLevel, dwServiceType, dwServiceState, lpServices, cbBufSize, pcbBytesNeeded, lpServicesReturned, lpResumeHandle, pszGroupName):
|
||||
return EnumServicesStatusExW.ctypes_function(hSCManager, InfoLevel, dwServiceType, dwServiceState, lpServices, cbBufSize, pcbBytesNeeded, lpServicesReturned, lpResumeHandle, pszGroupName)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def StartServiceA(hService, dwNumServiceArgs, lpServiceArgVectors):
|
||||
return StartServiceA.ctypes_function(hService, dwNumServiceArgs, lpServiceArgVectors)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def StartServiceW(hService, dwNumServiceArgs, lpServiceArgVectors):
|
||||
return StartServiceW.ctypes_function(hService, dwNumServiceArgs, lpServiceArgVectors)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def OpenServiceA(hSCManager, lpServiceName, dwDesiredAccess):
|
||||
return OpenServiceA.ctypes_function(hSCManager, lpServiceName, dwDesiredAccess)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def OpenServiceW(hSCManager, lpServiceName, dwDesiredAccess):
|
||||
return OpenServiceW.ctypes_function(hSCManager, lpServiceName, dwDesiredAccess)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def ControlService(hService, dwControl, lpServiceStatus):
|
||||
return ControlService.ctypes_function(hService, dwControl, lpServiceStatus)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CloseServiceHandle(hSCObject):
|
||||
return CloseServiceHandle.ctypes_function(hSCObject)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def QueryServiceStatus(hService, lpServiceStatus):
|
||||
return QueryServiceStatus.ctypes_function(hService, lpServiceStatus)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def QueryServiceStatusEx(hService, InfoLevel, lpBuffer, cbBufSize, pcbBytesNeeded):
|
||||
return QueryServiceStatusEx.ctypes_function(hService, InfoLevel, lpBuffer, cbBufSize, pcbBytesNeeded)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def DeleteService(hService):
|
||||
return DeleteService.ctypes_function(hService)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetServiceDisplayNameA(hSCManager, lpServiceName, lpDisplayName, lpcchBuffer):
|
||||
return GetServiceDisplayNameA.ctypes_function(hSCManager, lpServiceName, lpDisplayName, lpcchBuffer)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetServiceDisplayNameW(hSCManager, lpServiceName, lpDisplayName, lpcchBuffer):
|
||||
return GetServiceDisplayNameW.ctypes_function(hSCManager, lpServiceName, lpDisplayName, lpcchBuffer)
|
||||
|
||||
# Event log
|
||||
|
||||
@Advapi32Proxy()
|
||||
def OpenEventLogA(lpUNCServerName=None, lpSourceName=NeededParameter):
|
||||
return OpenEventLogA.ctypes_function(lpUNCServerName, lpSourceName)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def OpenEventLogW(lpUNCServerName=None, lpSourceName=NeededParameter):
|
||||
return OpenEventLogW.ctypes_function(lpUNCServerName, lpSourceName)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def OpenBackupEventLogA(lpUNCServerName=None, lpSourceName=NeededParameter):
|
||||
return OpenBackupEventLogA.ctypes_function(lpUNCServerName, lpSourceName)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def OpenBackupEventLogW(lpUNCServerName=None, lpSourceName=NeededParameter):
|
||||
return OpenBackupEventLogW.ctypes_function(lpUNCServerName, lpSourceName)
|
||||
|
||||
|
||||
@Advapi32Proxy()
|
||||
def ReadEventLogA(hEventLog, dwReadFlags, dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded):
|
||||
return ReadEventLogA.ctypes_function(hEventLog, dwReadFlags, dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def ReadEventLogW(hEventLog, dwReadFlags, dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded):
|
||||
return ReadEventLogW.ctypes_function(hEventLog, dwReadFlags, dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetEventLogInformation(hEventLog, dwInfoLevel, lpBuffer, cbBufSize, pcbBytesNeeded):
|
||||
return GetEventLogInformation.ctypes_function(hEventLog, dwInfoLevel, lpBuffer, cbBufSize, pcbBytesNeeded)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def GetNumberOfEventLogRecords(hEventLog, NumberOfRecords):
|
||||
return GetNumberOfEventLogRecords.ctypes_function(hEventLog, NumberOfRecords)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CloseEventLog(hEventLog):
|
||||
return CloseEventLog.ctypes_function(hEventLog)
|
||||
|
||||
|
||||
# Crypto
|
||||
## Crypto key
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptGenKey(hProv, Algid, dwFlags, phKey):
|
||||
return CryptGenKey.ctypes_function(hProv, Algid, dwFlags, phKey)
|
||||
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptDestroyKey(hKey):
|
||||
return CryptDestroyKey.ctypes_function(hKey)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptExportKey(hKey, hExpKey, dwBlobType, dwFlags, pbData, pdwDataLen):
|
||||
return CryptExportKey.ctypes_function(hKey, hExpKey, dwBlobType, dwFlags, pbData, pdwDataLen)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptImportKey(hProv, pbData, dwDataLen, hPubKey, dwFlags, phKey):
|
||||
return CryptImportKey.ctypes_function(hProv, pbData, dwDataLen, hPubKey, dwFlags, phKey)
|
||||
|
||||
## crypt context
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptAcquireContextA(phProv, pszContainer, pszProvider, dwProvType, dwFlags):
|
||||
return CryptAcquireContextA.ctypes_function(phProv, pszContainer, pszProvider, dwProvType, dwFlags)
|
||||
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptAcquireContextW(phProv, pszContainer, pszProvider, dwProvType, dwFlags):
|
||||
return CryptAcquireContextW.ctypes_function(phProv, pszContainer, pszProvider, dwProvType, dwFlags)
|
||||
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptReleaseContext(hProv, dwFlags):
|
||||
return CryptReleaseContext.ctypes_function(hProv, dwFlags)
|
||||
|
||||
## Encrypt / Decrypt
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptEncrypt(hKey, hHash, Final, dwFlags, pbData, pdwDataLen, dwBufLen):
|
||||
return CryptEncrypt.ctypes_function(hKey, hHash, Final, dwFlags, pbData, pdwDataLen, dwBufLen)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptDecrypt(hKey, hHash, Final, dwFlags, pbData, pdwDataLen):
|
||||
return CryptDecrypt.ctypes_function(hKey, hHash, Final, dwFlags, pbData, pdwDataLen)
|
||||
|
||||
## Crypt Key
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptDeriveKey(hProv, Algid, hBaseData, dwFlags, phKey):
|
||||
return CryptDeriveKey.ctypes_function(hProv, Algid, hBaseData, dwFlags, phKey)
|
||||
|
||||
## Crypt hash
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptCreateHash(hProv, Algid, hKey=None, dwFlags=0, phHash=NeededParameter):
|
||||
return CryptCreateHash.ctypes_function(hProv, Algid, hKey, dwFlags, phHash)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptHashData(hHash, pbData, dwDataLen=None, dwFlags=0):
|
||||
if isinstance(pbData, windows.pycompat.anybuff):
|
||||
pbData = (gdef.BYTE * len(pbData))(*bytearray(pbData))
|
||||
if dwDataLen is None:
|
||||
dwDataLen = len(pbData)
|
||||
return CryptHashData.ctypes_function(hHash, pbData, dwDataLen, dwFlags)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptGetHashParam(hHash, dwParam, pbData, pdwDataLen=None, dwFlags=0):
|
||||
if pdwDataLen is None:
|
||||
pdwDataLen = ctypes.sizeof(pbData)
|
||||
return CryptGetHashParam.ctypes_function(hHash, dwParam, pbData, pdwDataLen, dwFlags)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptVerifySignatureA(hHash, pbSignature, dwSigLen, hPubKey, szDescription, dwFlags):
|
||||
return CryptVerifySignatureA.ctypes_function(hHash, pbSignature, dwSigLen, hPubKey, szDescription, dwFlags)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptVerifySignatureW(hHash, pbSignature, dwSigLen, hPubKey, szDescription, dwFlags):
|
||||
return CryptVerifySignatureW.ctypes_function(hHash, pbSignature, dwSigLen, hPubKey, szDescription, dwFlags)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptSignHashA(hHash, dwKeySpec, szDescription, dwFlags, pbSignature, pdwSigLen):
|
||||
return CryptSignHashA.ctypes_function(hHash, dwKeySpec, szDescription, dwFlags, pbSignature, pdwSigLen)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptSignHashW(hHash, dwKeySpec, szDescription, dwFlags, pbSignature, pdwSigLen):
|
||||
return CryptSignHashW.ctypes_function(hHash, dwKeySpec, szDescription, dwFlags, pbSignature, pdwSigLen)
|
||||
|
||||
@Advapi32Proxy()
|
||||
def CryptDestroyHash(hHash):
|
||||
return CryptDestroyHash.ctypes_function(hHash)
|
||||
|
||||
|
||||
## Event Tracing
|
||||
@Advapi32Proxy(error_check=succeed_on_zero)
|
||||
def EnumerateTraceGuidsEx(TraceQueryInfoClass, InBuffer, InBufferSize, OutBuffer, OutBufferSize, ReturnLength):
|
||||
if isinstance(InBuffer, gdef.GUID):
|
||||
# GUID is not convertible to a pointer directly
|
||||
# But we want to use it as an array for this function
|
||||
# Test/Assert on InBufferSize?
|
||||
InBuffer = ctypes.cast(ctypes.pointer(InBuffer), gdef.PVOID) # Caller keep a ref
|
||||
return EnumerateTraceGuidsEx.ctypes_function(TraceQueryInfoClass, InBuffer, InBufferSize, OutBuffer, OutBufferSize, ReturnLength)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def QueryAllTracesA(PropertyArray, PropertyArrayCount, SessionCount):
|
||||
return QueryAllTracesA.ctypes_function(PropertyArray, PropertyArrayCount, SessionCount)
|
||||
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def QueryAllTracesW(PropertyArray, PropertyArrayCount, SessionCount):
|
||||
return QueryAllTracesW.ctypes_function(PropertyArray, PropertyArrayCount, SessionCount)
|
||||
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_handle)
|
||||
def OpenTraceA(Logfile):
|
||||
return OpenTraceA.ctypes_function(Logfile)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_handle)
|
||||
def OpenTraceW(Logfile):
|
||||
return OpenTraceW.ctypes_function(Logfile)
|
||||
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def StartTraceA(TraceHandle, InstanceName, Properties):
|
||||
return StartTraceA.ctypes_function(TraceHandle, InstanceName, Properties)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def StartTraceW(TraceHandle, InstanceName, Properties):
|
||||
return StartTraceW.ctypes_function(TraceHandle, InstanceName, Properties)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def StopTraceA(TraceHandle, InstanceName, Properties):
|
||||
return StopTraceA.ctypes_function(TraceHandle, InstanceName, Properties)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def StopTraceW(TraceHandle, InstanceName, Properties):
|
||||
return StopTraceW.ctypes_function(TraceHandle, InstanceName, Properties)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def ControlTraceA(TraceHandle, InstanceName, Properties, ControlCode):
|
||||
return ControlTraceA.ctypes_function(TraceHandle, InstanceName, Properties, ControlCode)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def ControlTraceW(TraceHandle, InstanceName, Properties, ControlCode):
|
||||
return ControlTraceW.ctypes_function(TraceHandle, InstanceName, Properties, ControlCode)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def ProcessTrace(HandleArray, HandleCount, StartTime, EndTime):
|
||||
return ProcessTrace.ctypes_function(HandleArray, HandleCount, StartTime, EndTime)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def EnableTrace(Enable, EnableFlag, EnableLevel, ControlGuid, SessionHandle):
|
||||
return EnableTrace.ctypes_function(Enable, EnableFlag, EnableLevel, ControlGuid, SessionHandle)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def EnableTraceEx(ProviderId, SourceId, TraceHandle, IsEnabled, Level, MatchAnyKeyword, MatchAllKeyword, EnableProperty, EnableFilterDesc):
|
||||
return EnableTraceEx.ctypes_function(ProviderId, SourceId, TraceHandle, IsEnabled, Level, MatchAnyKeyword, MatchAllKeyword, EnableProperty, EnableFilterDesc)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def EnableTraceEx2(TraceHandle, ProviderId, ControlCode, Level, MatchAnyKeyword, MatchAllKeyword, Timeout, EnableParameters):
|
||||
return EnableTraceEx2.ctypes_function(TraceHandle, ProviderId, ControlCode, Level, MatchAnyKeyword, MatchAllKeyword, Timeout, EnableParameters)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def TraceQueryInformation(SessionHandle, InformationClass, TraceInformation, InformationLength, ReturnLength):
|
||||
return TraceQueryInformation.ctypes_function(SessionHandle, InformationClass, TraceInformation, InformationLength, ReturnLength)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def TraceSetInformation(SessionHandle, InformationClass, TraceInformation, InformationLength):
|
||||
return TraceSetInformation.ctypes_function(SessionHandle, InformationClass, TraceInformation, InformationLength)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegisterTraceGuidsW(RequestAddress, RequestContext, ControlGuid, GuidCount, TraceGuidReg, MofImagePath, MofResourceName, RegistrationHandle):
|
||||
return RegisterTraceGuidsW.ctypes_function(RequestAddress, RequestContext, ControlGuid, GuidCount, TraceGuidReg, MofImagePath, MofResourceName, RegistrationHandle)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def RegisterTraceGuidsA(RequestAddress, RequestContext, ControlGuid, GuidCount, TraceGuidReg, MofImagePath, MofResourceName, RegistrationHandle):
|
||||
return RegisterTraceGuidsA.ctypes_function(RequestAddress, RequestContext, ControlGuid, GuidCount, TraceGuidReg, MofImagePath, MofResourceName, RegistrationHandle)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_error_code)
|
||||
def TraceEvent(SessionHandle, EventTrace):
|
||||
return TraceEvent.ctypes_function(SessionHandle, EventTrace)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_handle)
|
||||
def GetTraceLoggerHandle(Buffer):
|
||||
return GetTraceLoggerHandle.ctypes_function(Buffer)
|
||||
|
||||
|
||||
# Lsa APIs
|
||||
@Advapi32Proxy(error_check=result_is_ntstatus)
|
||||
def LsaOpenPolicy(SystemName=None, ObjectAttributes=None, DesiredAccess=NeededParameter, PolicyHandle=NeededParameter):
|
||||
if ObjectAttributes is None:
|
||||
ObjectAttributes = gdef.LSA_OBJECT_ATTRIBUTES()
|
||||
return LsaOpenPolicy.ctypes_function(SystemName, ObjectAttributes, DesiredAccess, PolicyHandle)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_ntstatus)
|
||||
def LsaQueryInformationPolicy(PolicyHandle, InformationClass, Buffer):
|
||||
return LsaQueryInformationPolicy.ctypes_function(PolicyHandle, InformationClass, Buffer)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_ntstatus)
|
||||
def LsaClose(ObjectHandle):
|
||||
return LsaClose.ctypes_function(ObjectHandle)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_ntstatus)
|
||||
def LsaNtStatusToWinError(Status):
|
||||
return LsaNtStatusToWinError.ctypes_function(Status)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_ntstatus)
|
||||
def LsaLookupNames(PolicyHandle, Count, Names, ReferencedDomains, Sids):
|
||||
return LsaLookupNames.ctypes_function(PolicyHandle, Count, Names, ReferencedDomains, Sids)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_ntstatus)
|
||||
def LsaLookupNames2(PolicyHandle, Flags, Count, Names, ReferencedDomains, Sids):
|
||||
return LsaLookupNames2.ctypes_function(PolicyHandle, Flags, Count, Names, ReferencedDomains, Sids)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_ntstatus)
|
||||
def LsaLookupSids(PolicyHandle, Count, Sids, ReferencedDomains, Names):
|
||||
return LsaLookupSids.ctypes_function(PolicyHandle, Count, Sids, ReferencedDomains, Names)
|
||||
|
||||
@Advapi32Proxy(error_check=result_is_ntstatus)
|
||||
def LsaLookupSids2(PolicyHandle, LookupOptions, Count, Sids, ReferencedDomains, Names):
|
||||
return LsaLookupSids2.ctypes_function(PolicyHandle, LookupOptions, Count, Sids, ReferencedDomains, Names)
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
import ctypes
|
||||
from ctypes import wintypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter, is_implemented
|
||||
from ..error import WinproxyError, result_is_error_code
|
||||
|
||||
CFGMGR32_ERRORS = gdef.FlagMapper(
|
||||
gdef.CR_SUCCESS,
|
||||
gdef.CR_DEFAULT,
|
||||
gdef.CR_OUT_OF_MEMORY,
|
||||
gdef.CR_INVALID_POINTER,
|
||||
gdef.CR_INVALID_FLAG,
|
||||
gdef.CR_INVALID_DEVNODE,
|
||||
gdef.CR_INVALID_DEVINST,
|
||||
gdef.CR_INVALID_RES_DES,
|
||||
gdef.CR_INVALID_LOG_CONF,
|
||||
gdef.CR_INVALID_ARBITRATOR,
|
||||
gdef.CR_INVALID_NODELIST,
|
||||
gdef.CR_DEVNODE_HAS_REQS,
|
||||
gdef.CR_DEVINST_HAS_REQS,
|
||||
gdef.CR_INVALID_RESOURCEID,
|
||||
gdef.CR_DLVXD_NOT_FOUND,
|
||||
gdef.CR_NO_SUCH_DEVNODE,
|
||||
gdef.CR_NO_SUCH_DEVINST,
|
||||
gdef.CR_NO_MORE_LOG_CONF,
|
||||
gdef.CR_NO_MORE_RES_DES,
|
||||
gdef.CR_ALREADY_SUCH_DEVNODE,
|
||||
gdef.CR_ALREADY_SUCH_DEVINST,
|
||||
gdef.CR_INVALID_RANGE_LIST,
|
||||
gdef.CR_INVALID_RANGE,
|
||||
gdef.CR_FAILURE,
|
||||
gdef.CR_NO_SUCH_LOGICAL_DEV,
|
||||
gdef.CR_CREATE_BLOCKED,
|
||||
gdef.CR_NOT_SYSTEM_VM,
|
||||
gdef.CR_REMOVE_VETOED,
|
||||
gdef.CR_APM_VETOED,
|
||||
gdef.CR_INVALID_LOAD_TYPE,
|
||||
gdef.CR_BUFFER_SMALL,
|
||||
gdef.CR_NO_ARBITRATOR,
|
||||
gdef.CR_NO_REGISTRY_HANDLE,
|
||||
gdef.CR_REGISTRY_ERROR,
|
||||
gdef.CR_INVALID_DEVICE_ID,
|
||||
gdef.CR_INVALID_DATA,
|
||||
gdef.CR_INVALID_API,
|
||||
gdef.CR_DEVLOADER_NOT_READY,
|
||||
gdef.CR_NEED_RESTART,
|
||||
gdef.CR_NO_MORE_HW_PROFILES,
|
||||
gdef.CR_DEVICE_NOT_THERE,
|
||||
gdef.CR_NO_SUCH_VALUE,
|
||||
gdef.CR_WRONG_TYPE,
|
||||
gdef.CR_INVALID_PRIORITY,
|
||||
gdef.CR_NOT_DISABLEABLE,
|
||||
gdef.CR_FREE_RESOURCES,
|
||||
gdef.CR_QUERY_VETOED,
|
||||
gdef.CR_CANT_SHARE_IRQ,
|
||||
gdef.CR_NO_DEPENDENT,
|
||||
gdef.CR_SAME_RESOURCES,
|
||||
gdef.CR_NO_SUCH_REGISTRY_KEY,
|
||||
gdef.CR_INVALID_MACHINENAME,
|
||||
gdef.CR_REMOTE_COMM_FAILURE,
|
||||
gdef.CR_MACHINE_UNAVAILABLE,
|
||||
gdef.CR_NO_CM_SERVICES,
|
||||
gdef.CR_ACCESS_DENIED,
|
||||
gdef.CR_CALL_NOT_IMPLEMENTED,
|
||||
gdef.CR_INVALID_PROPERTY,
|
||||
gdef.CR_DEVICE_INTERFACE_ACTIVE,
|
||||
gdef.CR_NO_SUCH_DEVICE_INTERFACE,
|
||||
gdef.CR_INVALID_REFERENCE_STRING,
|
||||
gdef.CR_INVALID_CONFLICT_LIST,
|
||||
gdef.CR_INVALID_INDEX,
|
||||
gdef.CR_INVALID_STRUCTURE_SIZE
|
||||
)
|
||||
|
||||
|
||||
|
||||
class CfgMgr32Error(WinproxyError):
|
||||
def __new__(cls, func_name, error_code):
|
||||
error_flag = CFGMGR32_ERRORS[error_code]
|
||||
api_error = super(WinproxyError, cls).__new__(cls)
|
||||
api_error.api_name = func_name
|
||||
api_error.winerror = error_flag
|
||||
api_error.strerror = error_flag.name
|
||||
api_error.args = (func_name, api_error.winerror, api_error.strerror)
|
||||
return api_error
|
||||
|
||||
def tst_error(func_name, result, func, args):
|
||||
if result:
|
||||
raise CfgMgr32Error(func_name, result)
|
||||
return args
|
||||
|
||||
class CfgMgr32Proxy(ApiProxy):
|
||||
APIDLL = "CfgMgr32"
|
||||
# We can make a custom error_check taht translate error code to CR_ flags if needed
|
||||
default_error_check = staticmethod(tst_error)
|
||||
|
||||
|
||||
|
||||
@CfgMgr32Proxy()
|
||||
def CM_Enumerate_Classes(ulClassIndex, ClassGuid, ulFlags):
|
||||
return CM_Enumerate_Classes.ctypes_function(ulClassIndex, ClassGuid, ulFlags)
|
||||
|
||||
|
||||
@CfgMgr32Proxy()
|
||||
def CM_Get_First_Log_Conf(plcLogConf, dnDevInst, ulFlags):
|
||||
return CM_Get_First_Log_Conf.ctypes_function(plcLogConf, dnDevInst, ulFlags)
|
||||
|
||||
@CfgMgr32Proxy()
|
||||
def CM_Get_First_Log_Conf_Ex(plcLogConf, dnDevInst, ulFlags, hMachine):
|
||||
return CM_Get_First_Log_Conf_Ex.ctypes_function(plcLogConf, dnDevInst, ulFlags, hMachine)
|
||||
|
||||
@CfgMgr32Proxy()
|
||||
def CM_Get_Next_Log_Conf(plcLogConf, lcLogConf, ulFlags=0):
|
||||
return CM_Get_Next_Log_Conf.ctypes_function(plcLogConf, lcLogConf, ulFlags)
|
||||
|
||||
@CfgMgr32Proxy()
|
||||
def CM_Get_Next_Log_Conf_Ex(plcLogConf, lcLogConf, ulFlags, hMachine):
|
||||
return CM_Get_Next_Log_Conf_Ex.ctypes_function(plcLogConf, lcLogConf, ulFlags, hMachine)
|
||||
|
||||
|
||||
@CfgMgr32Proxy()
|
||||
def CM_Free_Res_Des_Handle(hRes):
|
||||
return CM_Free_Res_Des_Handle.ctypes_function(hRes)
|
||||
|
||||
@CfgMgr32Proxy()
|
||||
def CM_Get_Next_Res_Des(prdResDes, rdResDes, ForResource, pResourceID, ulFlags=0):
|
||||
return CM_Get_Next_Res_Des.ctypes_function(prdResDes, rdResDes, ForResource, pResourceID, ulFlags)
|
||||
|
||||
|
||||
@CfgMgr32Proxy()
|
||||
def CM_Get_Res_Des_Data_Size(pulSize, rdResDes, ulFlags=0):
|
||||
return CM_Get_Res_Des_Data_Size.ctypes_function(pulSize, rdResDes, ulFlags)
|
||||
|
||||
|
||||
@CfgMgr32Proxy()
|
||||
def CM_Get_Res_Des_Data(rdResDes, Buffer, BufferLen, ulFlags=0):
|
||||
return CM_Get_Res_Des_Data.ctypes_function(rdResDes, Buffer, BufferLen, ulFlags)
|
||||
|
||||
|
||||
@CfgMgr32Proxy()
|
||||
def CM_Get_Parent(pdnDevInst, dnDevInst, ulFlags=0):
|
||||
return CM_Get_Parent.ctypes_function(pdnDevInst, dnDevInst, ulFlags)
|
||||
@@ -0,0 +1,241 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import no_error_check, fail_on_zero
|
||||
|
||||
import windows.pycompat
|
||||
from windows.pycompat import int_types
|
||||
|
||||
class Crypt32Proxy(ApiProxy):
|
||||
APIDLL = "crypt32"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
# Certificate
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertStrToNameA(dwCertEncodingType, pszX500, dwStrType, pvReserved, pbEncoded, pcbEncoded, ppszError):
|
||||
return CertStrToNameA.ctypes_function(dwCertEncodingType, pszX500, dwStrType, pvReserved, pbEncoded, pcbEncoded, ppszError)
|
||||
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertStrToNameW(dwCertEncodingType, pszX500, dwStrType, pvReserved, pbEncoded, pcbEncoded, ppszError):
|
||||
return CertStrToNameW.ctypes_function(dwCertEncodingType, pszX500, dwStrType, pvReserved, pbEncoded, pcbEncoded, ppszError)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertGetNameStringA(pCertContext, dwType, dwFlags, pvTypePara, pszNameString, cchNameString):
|
||||
return CertGetNameStringA.ctypes_function(pCertContext, dwType, dwFlags, pvTypePara, pszNameString, cchNameString)
|
||||
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertGetNameStringW(pCertContext, dwType, dwFlags, pvTypePara, pszNameString, cchNameString):
|
||||
return CertGetNameStringW.ctypes_function(pCertContext, dwType, dwFlags, pvTypePara, pszNameString, cchNameString)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertCreateSelfSignCertificate(hCryptProvOrNCryptKey, pSubjectIssuerBlob, dwFlags, pKeyProvInfo, pSignatureAlgorithm, pStartTime, pEndTime, pExtensions):
|
||||
return CertCreateSelfSignCertificate.ctypes_function(hCryptProvOrNCryptKey, pSubjectIssuerBlob, dwFlags, pKeyProvInfo, pSignatureAlgorithm, pStartTime, pEndTime, pExtensions)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertGetCertificateContextProperty(pCertContext, dwPropId, pvData, pcbData):
|
||||
return CertGetCertificateContextProperty.ctypes_function(pCertContext, dwPropId, pvData, pcbData)
|
||||
|
||||
@Crypt32Proxy(error_check=no_error_check)
|
||||
def CertEnumCertificateContextProperties(pCertContext, dwPropId):
|
||||
return CertEnumCertificateContextProperties.ctypes_function(pCertContext, dwPropId)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertCreateCertificateContext(dwCertEncodingType, pbCertEncoded, cbCertEncoded):
|
||||
return CertCreateCertificateContext.ctypes_function(dwCertEncodingType, pbCertEncoded, cbCertEncoded)
|
||||
|
||||
|
||||
## Certificate chain
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertGetCertificateChain(hChainEngine, pCertContext, pTime, hAdditionalStore, pChainPara, dwFlags, pvReserved, ppChainContext):
|
||||
return CertGetCertificateChain.ctypes_function(hChainEngine, pCertContext, pTime, hAdditionalStore, pChainPara, dwFlags, pvReserved, ppChainContext)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertDuplicateCertificateContext(pCertContext):
|
||||
return CertDuplicateCertificateContext.ctypes_function(pCertContext)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertFreeCertificateContext(pCertContext):
|
||||
return CertFreeCertificateContext.ctypes_function(pCertContext)
|
||||
|
||||
@Crypt32Proxy(error_check=no_error_check)
|
||||
def CertCompareCertificate(dwCertEncodingType, pCertId1, pCertId2):
|
||||
"""This function does not raise is compare has failed:
|
||||
return 0 if cert are NOT equals
|
||||
"""
|
||||
return CertCompareCertificate.ctypes_function(dwCertEncodingType, pCertId1, pCertId2)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptHashCertificate(hCryptProv, Algid, dwFlags, pbEncoded, cbEncoded, pbComputedHash, pcbComputedHash):
|
||||
return CryptHashCertificate.ctypes_function(hCryptProv, Algid, dwFlags, pbEncoded, cbEncoded, pbComputedHash, pcbComputedHash)
|
||||
|
||||
## Certificate store
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertOpenStore(lpszStoreProvider, dwMsgAndCertEncodingType, hCryptProv, dwFlags, pvPara):
|
||||
if isinstance(lpszStoreProvider, int_types):
|
||||
lpszStoreProvider = gdef.LPCSTR(lpszStoreProvider)
|
||||
return CertOpenStore.ctypes_function(lpszStoreProvider, dwMsgAndCertEncodingType, hCryptProv, dwFlags, pvPara)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertAddCertificateContextToStore(hCertStore, pCertContext, dwAddDisposition, ppStoreContext):
|
||||
return CertAddCertificateContextToStore.ctypes_function(hCertStore, pCertContext, dwAddDisposition, ppStoreContext)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertFindCertificateInStore(hCertStore, dwCertEncodingType, dwFindFlags, dwFindType, pvFindPara, pPrevCertContext):
|
||||
return CertFindCertificateInStore.ctypes_function(hCertStore, dwCertEncodingType, dwFindFlags, dwFindType, pvFindPara, pPrevCertContext)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertEnumCertificatesInStore(hCertStore, pPrevCertContext):
|
||||
return CertEnumCertificatesInStore.ctypes_function(hCertStore, pPrevCertContext)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def PFXExportCertStoreEx(hStore, pPFX, szPassword, pvPara, dwFlags):
|
||||
return PFXExportCertStoreEx.ctypes_function(hStore, pPFX, szPassword, pvPara, dwFlags)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def PFXImportCertStore(pPFX, szPassword, dwFlags):
|
||||
return PFXImportCertStore.ctypes_function(pPFX, szPassword, dwFlags)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertEnumCTLsInStore(hCertStore, pPrevCtlContext):
|
||||
return CertEnumCTLsInStore.ctypes_function(hCertStore, pPrevCtlContext)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CertCloseStore(hCertStore, dwFlags):
|
||||
return CertCloseStore.ctypes_function(hCertStore, dwFlags)
|
||||
|
||||
|
||||
# Key
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptAcquireCertificatePrivateKey(pCert, dwFlags, pvParameters, phCryptProvOrNCryptKey, pdwKeySpec, pfCallerFreeProvOrNCryptKey):
|
||||
return CryptAcquireCertificatePrivateKey.ctypes_function(pCert, dwFlags, pvParameters, phCryptProvOrNCryptKey, pdwKeySpec, pfCallerFreeProvOrNCryptKey)
|
||||
|
||||
|
||||
|
||||
# Encrypt / Decrypt
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptEncryptMessage(pEncryptPara, cRecipientCert, rgpRecipientCert, pbToBeEncrypted, cbToBeEncrypted, pbEncryptedBlob, pcbEncryptedBlob):
|
||||
if isinstance(pbToBeEncrypted, windows.pycompat.anybuff):
|
||||
# Transform string to array of byte
|
||||
pbToBeEncrypted = (gdef.BYTE * len(pbToBeEncrypted))(*bytearray(pbToBeEncrypted))
|
||||
if cbToBeEncrypted is None and pbToBeEncrypted is not None:
|
||||
cbToBeEncrypted = len(pbToBeEncrypted)
|
||||
return CryptEncryptMessage.ctypes_function(pEncryptPara, cRecipientCert, rgpRecipientCert, pbToBeEncrypted, cbToBeEncrypted, pbEncryptedBlob, pcbEncryptedBlob)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptDecryptMessage(pDecryptPara, pbEncryptedBlob, cbEncryptedBlob, pbDecrypted, pcbDecrypted, ppXchgCert):
|
||||
return CryptDecryptMessage.ctypes_function(pDecryptPara, pbEncryptedBlob, cbEncryptedBlob, pbDecrypted, pcbDecrypted, ppXchgCert)
|
||||
|
||||
|
||||
|
||||
|
||||
# Sign / Verify
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptSignMessage(pSignPara, fDetachedSignature, cToBeSigned, rgpbToBeSigned, rgcbToBeSigned, pbSignedBlob, pcbSignedBlob):
|
||||
return CryptSignMessage.ctypes_function(pSignPara, fDetachedSignature, cToBeSigned, rgpbToBeSigned, rgcbToBeSigned, pbSignedBlob, pcbSignedBlob)
|
||||
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptSignAndEncryptMessage(pSignPara, pEncryptPara, cRecipientCert, rgpRecipientCert, pbToBeSignedAndEncrypted, cbToBeSignedAndEncrypted, pbSignedAndEncryptedBlob, pcbSignedAndEncryptedBlob):
|
||||
return CryptSignAndEncryptMessage.ctypes_function(pSignPara, pEncryptPara, cRecipientCert, rgpRecipientCert, pbToBeSignedAndEncrypted, cbToBeSignedAndEncrypted, pbSignedAndEncryptedBlob, pcbSignedAndEncryptedBlob)
|
||||
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptVerifyMessageSignature(pVerifyPara, dwSignerIndex, pbSignedBlob, cbSignedBlob, pbDecoded, pcbDecoded, ppSignerCert):
|
||||
return CryptVerifyMessageSignature.ctypes_function(pVerifyPara, dwSignerIndex, pbSignedBlob, cbSignedBlob, pbDecoded, pcbDecoded, ppSignerCert)
|
||||
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptVerifyMessageSignatureWithKey(pVerifyPara, pPublicKeyInfo, pbSignedBlob, cbSignedBlob, pbDecoded, pcbDecoded):
|
||||
return CryptVerifyMessageSignatureWithKey.ctypes_function(pVerifyPara, pPublicKeyInfo, pbSignedBlob, cbSignedBlob, pbDecoded, pcbDecoded)
|
||||
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptVerifyMessageHash(pHashPara, pbHashedBlob, cbHashedBlob, pbToBeHashed, pcbToBeHashed, pbComputedHash, pcbComputedHash):
|
||||
return CryptVerifyMessageHash.ctypes_function(pHashPara, pbHashedBlob, cbHashedBlob, pbToBeHashed, pcbToBeHashed, pbComputedHash, pcbComputedHash)
|
||||
|
||||
|
||||
# Crypt-object
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptEncodeObjectEx(dwCertEncodingType, lpszStructType, pvStructInfo, dwFlags, pEncodePara, pvEncoded, pcbEncoded):
|
||||
lpszStructType = gdef.LPCSTR(lpszStructType) if isinstance(lpszStructType, int_types) else lpszStructType
|
||||
return CryptEncodeObjectEx.ctypes_function(dwCertEncodingType, lpszStructType, pvStructInfo, dwFlags, pEncodePara, pvEncoded, pcbEncoded)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptQueryObject(dwObjectType, pvObject, dwExpectedContentTypeFlags, dwExpectedFormatTypeFlags, dwFlags, pdwMsgAndCertEncodingType, pdwContentType, pdwFormatType, phCertStore, phMsg, ppvContext):
|
||||
return CryptQueryObject.ctypes_function(dwObjectType, pvObject, dwExpectedContentTypeFlags, dwExpectedFormatTypeFlags, dwFlags, pdwMsgAndCertEncodingType, pdwContentType, pdwFormatType, phCertStore, phMsg, ppvContext)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptDecodeObject(dwCertEncodingType, lpszStructType, pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo):
|
||||
return CryptDecodeObject.ctypes_function(dwCertEncodingType, lpszStructType, pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptMsgGetParam(hCryptMsg, dwParamType, dwIndex, pvData, pcbData):
|
||||
return CryptMsgGetParam.ctypes_function(hCryptMsg, dwParamType, dwIndex, pvData, pcbData)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptMsgOpenToEncode(dwMsgEncodingType, dwFlags, dwMsgType, pvMsgEncodeInfo, pszInnerContentObjID, pStreamInfo):
|
||||
return CryptMsgOpenToEncode.ctypes_function(dwMsgEncodingType, dwFlags, dwMsgType, pvMsgEncodeInfo, pszInnerContentObjID, pStreamInfo)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptMsgOpenToDecode(dwMsgEncodingType, dwFlags, dwMsgType, hCryptProv, pRecipientInfo, pStreamInfo):
|
||||
return CryptMsgOpenToDecode.ctypes_function(dwMsgEncodingType, dwFlags, dwMsgType, hCryptProv, pRecipientInfo, pStreamInfo)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptMsgUpdate(hCryptMsg, pbData, cbData, fFinal):
|
||||
return CryptMsgUpdate.ctypes_function(hCryptMsg, pbData, cbData, fFinal)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptMsgControl(hCryptMsg, dwFlags, dwCtrlType, pvCtrlPara):
|
||||
return CryptMsgControl.ctypes_function(hCryptMsg, dwFlags, dwCtrlType, pvCtrlPara)
|
||||
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptMsgVerifyCountersignatureEncoded(hCryptProv, dwEncodingType, pbSignerInfo, cbSignerInfo, pbSignerInfoCountersignature, cbSignerInfoCountersignature, pciCountersigner):
|
||||
return CryptMsgVerifyCountersignatureEncoded.ctypes_function(hCryptProv, dwEncodingType, pbSignerInfo, cbSignerInfo, pbSignerInfoCountersignature, cbSignerInfoCountersignature, pciCountersigner)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptMsgVerifyCountersignatureEncodedEx(hCryptProv, dwEncodingType, pbSignerInfo, cbSignerInfo, pbSignerInfoCountersignature, cbSignerInfoCountersignature, dwSignerType, pvSigner, dwFlags, pvExtra):
|
||||
return CryptMsgVerifyCountersignatureEncodedEx.ctypes_function(hCryptProv, dwEncodingType, pbSignerInfo, cbSignerInfo, pbSignerInfoCountersignature, cbSignerInfoCountersignature, dwSignerType, pvSigner, dwFlags, pvExtra)
|
||||
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptMsgClose(hCryptMsg):
|
||||
return CryptMsgClose.ctypes_function(hCryptMsg)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptEnumOIDFunction(dwEncodingType, pszFuncName, pszOID, dwFlags, pvArg, pfnEnumOIDFunc):
|
||||
return CryptEnumOIDFunction.ctypes_function(dwEncodingType, pszFuncName, pszOID, dwFlags, pvArg, pfnEnumOIDFunc)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptGetOIDFunctionValue(dwEncodingType, pszFuncName, pszOID, pwszValueName, pdwValueType, pbValueData, pcbValueData):
|
||||
return Cry
|
||||
ptGetOIDFunctionValue.ctypes_function(dwEncodingType, pszFuncName, pszOID, pwszValueName, pdwValueType, pbValueData, pcbValueData)
|
||||
|
||||
|
||||
# DPAPI
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptProtectData(pDataIn, szDataDescr=None, pOptionalEntropy=None, pvReserved=None, pPromptStruct=None, dwFlags=0, pDataOut=NeededParameter):
|
||||
return CryptProtectData.ctypes_function(pDataIn, szDataDescr, pOptionalEntropy, pvReserved, pPromptStruct, dwFlags, pDataOut)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptUnprotectData(pDataIn, ppszDataDescr=None, pOptionalEntropy=None, pvReserved=None, pPromptStruct=None, dwFlags=0, pDataOut=NeededParameter):
|
||||
return CryptUnprotectData.ctypes_function(pDataIn, ppszDataDescr, pOptionalEntropy, pvReserved, pPromptStruct, dwFlags, pDataOut)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptProtectMemory(pDataIn, cbDataIn, dwFlags):
|
||||
return CryptProtectMemory.ctypes_function(pDataIn, cbDataIn, dwFlags)
|
||||
|
||||
@Crypt32Proxy()
|
||||
def CryptUnprotectMemory(pDataIn, cbDataIn, dwFlags):
|
||||
return CryptUnprotectMemory.ctypes_function(pDataIn, cbDataIn, dwFlags)
|
||||
@@ -0,0 +1,14 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import fail_on_zero
|
||||
|
||||
class CryptUIProxy(ApiProxy):
|
||||
APIDLL = "cryptui"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
|
||||
@CryptUIProxy()
|
||||
def CryptUIDlgViewContext(dwContextType, pvContext, hwnd, pwszTitle, dwFlags, pvReserved):
|
||||
return CryptUIDlgViewContext.ctypes_function(dwContextType, pvContext, hwnd, pwszTitle, dwFlags, pvReserved)
|
||||
@@ -0,0 +1,193 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
from windows.pycompat import int_types
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import fail_on_zero
|
||||
|
||||
class DbgHelpProxy(ApiProxy):
|
||||
APIDLL = "dbghelp"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
# We keep the simple definition where callback UserContext are PVOID
|
||||
# Be we want to be able to pass arbitrary python object (list/dict)
|
||||
# So ctypes magic to make the py_object->pvoid transformation
|
||||
# !! this code loose a ref to obj.
|
||||
# Should still work as our calling-caller method keep a ref
|
||||
def transform_pyobject_to_pvoid(obj):
|
||||
if obj is None or isinstance(obj, int_types):
|
||||
return obj
|
||||
return ctypes.POINTER(gdef.PVOID)(ctypes.py_object(obj))[0]
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymInitialize(hProcess, UserSearchPath, fInvadeProcess):
|
||||
return SymInitialize.ctypes_function(hProcess, UserSearchPath, fInvadeProcess)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymCleanup(hProcess):
|
||||
return SymCleanup.ctypes_function(hProcess)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymLoadModuleExA(hProcess, hFile, ImageName, ModuleName, BaseOfDll, DllSize, Data, Flags):
|
||||
return SymLoadModuleExA.ctypes_function(hProcess, hFile, ImageName, ModuleName, BaseOfDll, DllSize, Data, Flags)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymLoadModuleExW(hProcess, hFile, ImageName, ModuleName, BaseOfDll, DllSize, Data, Flags):
|
||||
return SymLoadModuleExW.ctypes_function(hProcess, hFile, ImageName, ModuleName, BaseOfDll, DllSize, Data, Flags)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymUnloadModule64(hProcess, BaseOfDll):
|
||||
return SymUnloadModule64.ctypes_function(hProcess, BaseOfDll)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymFromAddr(hProcess, Address, Displacement, Symbol):
|
||||
return SymFromAddr.ctypes_function(hProcess, Address, Displacement, Symbol)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymGetModuleInfo64(hProcess, dwAddr, ModuleInfo):
|
||||
return SymGetModuleInfo64.ctypes_function(hProcess, dwAddr, ModuleInfo)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymFromName(hProcess, Name, Symbol):
|
||||
return SymFromName.ctypes_function(hProcess, Name, Symbol)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymLoadModuleEx(hProcess, hFile, ImageName, ModuleName, BaseOfDll, DllSize, Data, Flags):
|
||||
return SymLoadModuleEx.ctypes_function(hProcess, hFile, ImageName, ModuleName, BaseOfDll, DllSize, Data, Flags)
|
||||
|
||||
@DbgHelpProxy(error_check=None)
|
||||
def SymSetOptions(SymOptions):
|
||||
return SymSetOptions.ctypes_function(SymOptions)
|
||||
|
||||
@DbgHelpProxy(error_check=None)
|
||||
def SymGetOptions():
|
||||
return SymGetOptions.ctypes_function()
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymGetSearchPath(hProcess, SearchPath, SearchPathLength=None):
|
||||
if SearchPath and SearchPathLength is None:
|
||||
SearchPathLength = len(SearchPath)
|
||||
return SymGetSearchPath.ctypes_function(hProcess, SearchPath, SearchPathLength)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymGetSearchPathW(hProcess, SearchPath, SearchPathLength=None):
|
||||
if SearchPath and SearchPathLength is None:
|
||||
SearchPathLength = len(SearchPath)
|
||||
return SymGetSearchPathW.ctypes_function(hProcess, SearchPath, SearchPathLength)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymSetSearchPath(hProcess, SearchPath):
|
||||
return SymSetSearchPath.ctypes_function(hProcess, SearchPath)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymSetSearchPathW(hProcess, SearchPath):
|
||||
return SymSetSearchPathW.ctypes_function(hProcess, SearchPath)
|
||||
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymGetTypeInfo(hProcess, ModBase, TypeId, GetType, pInfo):
|
||||
return SymGetTypeInfo.ctypes_function(hProcess, ModBase, TypeId, GetType, pInfo)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymEnumSymbols(hProcess, BaseOfDll, Mask, EnumSymbolsCallback, UserContext=None):
|
||||
UserContext = transform_pyobject_to_pvoid(UserContext)
|
||||
return SymEnumSymbols.ctypes_function(hProcess, BaseOfDll, Mask, EnumSymbolsCallback, UserContext)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymEnumSymbolsEx(hProcess, BaseOfDll, Mask, EnumSymbolsCallback, UserContext=None, Options=NeededParameter):
|
||||
UserContext = transform_pyobject_to_pvoid(UserContext)
|
||||
return SymEnumSymbolsEx.ctypes_function(hProcess, BaseOfDll, Mask, EnumSymbolsCallback, UserContext, Options)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymEnumSymbolsForAddr(hProcess, Address, EnumSymbolsCallback, UserContext=None):
|
||||
UserContext = transform_pyobject_to_pvoid(UserContext)
|
||||
return SymEnumSymbolsForAddr.ctypes_function(hProcess, Address, EnumSymbolsCallback, UserContext)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymEnumSymbolsForAddrW(hProcess, Address, EnumSymbolsCallback, UserContext=None):
|
||||
UserContext = transform_pyobject_to_pvoid(UserContext)
|
||||
return SymEnumSymbolsForAddrW.ctypes_function(hProcess, Address, EnumSymbolsCallback, UserContext)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymEnumTypes(hProcess, BaseOfDll, EnumSymbolsCallback, UserContext=None):
|
||||
UserContext = transform_pyobject_to_pvoid(UserContext)
|
||||
return SymEnumTypes.ctypes_function(hProcess, BaseOfDll, EnumSymbolsCallback, UserContext)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymEnumTypesByName(hProcess, BaseOfDll, mask, EnumSymbolsCallback, UserContext=None):
|
||||
UserContext = transform_pyobject_to_pvoid(UserContext)
|
||||
return SymEnumTypesByName.ctypes_function(hProcess, BaseOfDll, mask, EnumSymbolsCallback, UserContext)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymEnumerateModules64(hProcess, EnumModulesCallback, UserContext=None):
|
||||
UserContext = transform_pyobject_to_pvoid(UserContext)
|
||||
return SymEnumerateModules64.ctypes_function(hProcess, EnumModulesCallback, UserContext)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymGetTypeFromName(hProcess, BaseOfDll, Name, Symbol):
|
||||
return SymGetTypeFromName.ctypes_function(hProcess, BaseOfDll, Name, Symbol)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymSearch(hProcess, BaseOfDll, Index, SymTag, Mask, Address, EnumSymbolsCallback, UserContext, Options):
|
||||
UserContext = transform_pyobject_to_pvoid(UserContext)
|
||||
return SymSearch.ctypes_function(hProcess, BaseOfDll, Index, SymTag, Mask, Address, EnumSymbolsCallback, UserContext, Options)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymSearchW(hProcess, BaseOfDll, Index, SymTag, Mask, Address, EnumSymbolsCallback, UserContext, Options):
|
||||
UserContext = transform_pyobject_to_pvoid(UserContext)
|
||||
return SymSearchW.ctypes_function(hProcess, BaseOfDll, Index, SymTag, Mask, Address, EnumSymbolsCallback, UserContext, Options)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymRefreshModuleList(hProcess):
|
||||
return SymRefreshModuleList.ctypes_function(hProcess)
|
||||
|
||||
# Helpers
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymFunctionTableAccess(hProcess, AddrBase):
|
||||
return SymFunctionTableAccess.ctypes_function(hProcess, AddrBase)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymFunctionTableAccess64(hProcess, AddrBase):
|
||||
return SymFunctionTableAccess64.ctypes_function(hProcess, AddrBase)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymGetModuleBase(hProcess, dwAddr):
|
||||
return SymGetModuleBase.ctypes_function(hProcess, dwAddr)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymGetModuleBase64(hProcess, qwAddr):
|
||||
return SymGetModuleBase64.ctypes_function(hProcess, qwAddr)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymEnumProcesses(EnumProcessesCallback, UserContext=None):
|
||||
return SymEnumProcesses.ctypes_function(EnumProcessesCallback, UserContext)
|
||||
|
||||
## Sym callback
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymRegisterCallback(hProcess, CallbackFunction, UserContext=None):
|
||||
return SymRegisterCallback.ctypes_function(hProcess, CallbackFunction, UserContext)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymRegisterCallback64(hProcess, CallbackFunction, UserContext=0):
|
||||
return SymRegisterCallback64.ctypes_function(hProcess, CallbackFunction, UserContext)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def SymRegisterCallbackW64(hProcess, CallbackFunction, UserContext=0):
|
||||
return SymRegisterCallbackW64.ctypes_function(hProcess, CallbackFunction, UserContext)
|
||||
|
||||
|
||||
# Stack walk
|
||||
|
||||
@DbgHelpProxy()
|
||||
def StackWalk64(MachineType, hProcess, hThread, StackFrame, ContextRecord, ReadMemoryRoutine, FunctionTableAccessRoutine, GetModuleBaseRoutine, TranslateAddress):
|
||||
return StackWalk64.ctypes_function(MachineType, hProcess, hThread, StackFrame, ContextRecord, ReadMemoryRoutine, FunctionTableAccessRoutine, GetModuleBaseRoutine, TranslateAddress)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def StackWalkEx(MachineType, hProcess, hThread, StackFrame, ContextRecord, ReadMemoryRoutine, FunctionTableAccessRoutine, GetModuleBaseRoutine, TranslateAddress, Flags):
|
||||
return StackWalkEx.ctypes_function(MachineType, hProcess, hThread, StackFrame, ContextRecord, ReadMemoryRoutine, FunctionTableAccessRoutine, GetModuleBaseRoutine, TranslateAddress, Flags)
|
||||
|
||||
@DbgHelpProxy()
|
||||
def StackWalk(MachineType, hProcess, hThread, StackFrame, ContextRecord, ReadMemoryRoutine, FunctionTableAccessRoutine, GetModuleBaseRoutine, TranslateAddress):
|
||||
return StackWalk.ctypes_function(MachineType, hProcess, hThread, StackFrame, ContextRecord, ReadMemoryRoutine, FunctionTableAccessRoutine, GetModuleBaseRoutine, TranslateAddress)
|
||||
@@ -0,0 +1,32 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import fail_on_zero, result_is_error_code, no_error_check
|
||||
|
||||
class DNSapiProxy(ApiProxy):
|
||||
APIDLL = "dnsapi"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
|
||||
@DNSapiProxy()
|
||||
def DnsGetCacheDataTable(DnsEntries):
|
||||
return DnsGetCacheDataTable.ctypes_function(DnsEntries)
|
||||
|
||||
|
||||
@DNSapiProxy(error_check=result_is_error_code)
|
||||
def DnsQuery_A(pszName, wType, Options, pExtra, ppQueryResults, pReserved):
|
||||
return DnsQuery_A.ctypes_function(pszName, wType, Options, pExtra, ppQueryResults, pReserved)
|
||||
|
||||
|
||||
@DNSapiProxy(error_check=result_is_error_code)
|
||||
def DnsQuery_W(pszName, wType, Options, pExtra, ppQueryResults, pReserved):
|
||||
return DnsQuery_W.ctypes_function(pszName, wType, Options, pExtra, ppQueryResults, pReserved)
|
||||
|
||||
@DNSapiProxy(error_check=result_is_error_code)
|
||||
def DnsQueryEx(pQueryRequest, pQueryResults, pCancelHandle):
|
||||
return DnsQueryEx.ctypes_function(pQueryRequest, pQueryResults, pCancelHandle)
|
||||
|
||||
@DNSapiProxy(error_check=no_error_check)
|
||||
def DnsFree(pData, FreeType):
|
||||
return DnsFree.ctypes_function(pData, FreeType)
|
||||
@@ -0,0 +1,47 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import succeed_on_zero
|
||||
|
||||
class IphlpapiProxy(ApiProxy):
|
||||
APIDLL = "iphlpapi"
|
||||
default_error_check = staticmethod(succeed_on_zero)
|
||||
|
||||
|
||||
@IphlpapiProxy()
|
||||
def SetTcpEntry(pTcpRow):
|
||||
return SetTcpEntry.ctypes_function(pTcpRow)
|
||||
|
||||
@IphlpapiProxy()
|
||||
def GetExtendedTcpTable(pTcpTable, pdwSize=None, bOrder=True, ulAf=NeededParameter, TableClass=gdef.TCP_TABLE_OWNER_PID_ALL, Reserved=0):
|
||||
if pdwSize is None:
|
||||
pdwSize = gdef.ULONG(ctypes.sizeof(pTcpTable))
|
||||
return GetExtendedTcpTable.ctypes_function(pTcpTable, pdwSize, bOrder, ulAf, TableClass, Reserved)
|
||||
|
||||
@IphlpapiProxy()
|
||||
def GetInterfaceInfo(pIfTable, dwOutBufLen=None):
|
||||
if dwOutBufLen is None:
|
||||
dwOutBufLen = gdef.ULONG(ctypes.sizeof(pIfTable))
|
||||
return GetInterfaceInfo.ctypes_function(pIfTable, dwOutBufLen)
|
||||
|
||||
@IphlpapiProxy()
|
||||
def GetIfTable(pIfTable, pdwSize, bOrder=False):
|
||||
return GetIfTable.ctypes_function(pIfTable, pdwSize, bOrder)
|
||||
|
||||
@IphlpapiProxy()
|
||||
def GetIpAddrTable(pIpAddrTable, pdwSize, bOrder=False):
|
||||
return GetIpAddrTable.ctypes_function(pIpAddrTable, pdwSize, bOrder)
|
||||
|
||||
|
||||
@IphlpapiProxy()
|
||||
def GetIpNetTable(IpNetTable, SizePointer, Order):
|
||||
return GetIpNetTable.ctypes_function(IpNetTable, SizePointer, Order)
|
||||
|
||||
@IphlpapiProxy()
|
||||
def GetAdaptersInfo(AdapterInfo, SizePointer):
|
||||
return GetAdaptersInfo.ctypes_function(AdapterInfo, SizePointer)
|
||||
|
||||
@IphlpapiProxy()
|
||||
def GetPerAdapterInfo(IfIndex, pPerAdapterInfo, pOutBufLen):
|
||||
return GetPerAdapterInfo.ctypes_function(IfIndex, pPerAdapterInfo, pOutBufLen)
|
||||
@@ -0,0 +1,935 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import (fail_on_zero,
|
||||
no_error_check,
|
||||
result_is_handle,
|
||||
succeed_on_zero,
|
||||
fail_on_minus_one)
|
||||
|
||||
|
||||
class Kernel32Proxy(ApiProxy):
|
||||
APIDLL = "kernel32"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
# Process
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetCurrentProcess():
|
||||
return GetCurrentProcess.ctypes_function()
|
||||
|
||||
@Kernel32Proxy()
|
||||
def ExitProcess(uExitCode):
|
||||
return ExitProcess.ctypes_function(uExitCode)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def TerminateProcess(hProcess, uExitCode):
|
||||
return TerminateProcess.ctypes_function(hProcess, uExitCode)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetExitCodeProcess(hProcess, lpExitCode):
|
||||
return GetExitCodeProcess.ctypes_function(hProcess, lpExitCode)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetProcessId(Process):
|
||||
return GetProcessId.ctypes_function(Process)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreateProcessA(lpApplicationName, lpCommandLine=None, lpProcessAttributes=None, lpThreadAttributes=None, bInheritHandles=False,
|
||||
dwCreationFlags=0, lpEnvironment=None, lpCurrentDirectory=None, lpStartupInfo=None, lpProcessInformation=None):
|
||||
if lpStartupInfo is None:
|
||||
StartupInfo = gdef.STARTUPINFOA()
|
||||
StartupInfo.cb = ctypes.sizeof(StartupInfo)
|
||||
StartupInfo.dwFlags = gdef.STARTF_USESHOWWINDOW
|
||||
StartupInfo.wShowWindow = gdef.SW_HIDE
|
||||
lpStartupInfo = ctypes.byref(StartupInfo)
|
||||
if lpProcessInformation is None:
|
||||
lpProcessInformation = ctypes.byref(gdef.PROCESS_INFORMATION())
|
||||
return CreateProcessA.ctypes_function(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreateProcessW(lpApplicationName, lpCommandLine=None, lpProcessAttributes=None, lpThreadAttributes=None, bInheritHandles=False,
|
||||
dwCreationFlags=0, lpEnvironment=None, lpCurrentDirectory=None, lpStartupInfo=None, lpProcessInformation=None):
|
||||
if lpStartupInfo is None:
|
||||
StartupInfo = gdef.STARTUPINFOW()
|
||||
StartupInfo.cb = ctypes.sizeof(StartupInfo)
|
||||
StartupInfo.dwFlags = gdef.STARTF_USESHOWWINDOW
|
||||
StartupInfo.wShowWindow = gdef.SW_HIDE
|
||||
lpStartupInfo = ctypes.byref(StartupInfo)
|
||||
if lpProcessInformation is None:
|
||||
lpProcessInformation = ctypes.byref(gdef.PROCESS_INFORMATION())
|
||||
return CreateProcessW.ctypes_function(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def OpenProcess(dwDesiredAccess=gdef.PROCESS_ALL_ACCESS, bInheritHandle=0, dwProcessId=NeededParameter):
|
||||
return OpenProcess.ctypes_function(dwDesiredAccess, bInheritHandle, dwProcessId)
|
||||
|
||||
|
||||
## Process Infos
|
||||
@Kernel32Proxy()
|
||||
def GetProcessTimes(hProcess, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime):
|
||||
return GetProcessTimes.ctypes_function(hProcess, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetPriorityClass(hProcess):
|
||||
return GetPriorityClass.ctypes_function(hProcess)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def SetPriorityClass(hProcess, dwPriorityClass):
|
||||
return SetPriorityClass.ctypes_function(hProcess, dwPriorityClass)
|
||||
|
||||
|
||||
PROCESS_MITIGATION_STUCTS = (gdef.PROCESS_MITIGATION_ASLR_POLICY,
|
||||
gdef.PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY,
|
||||
gdef.PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY,
|
||||
gdef.PROCESS_MITIGATION_DEP_POLICY,
|
||||
gdef.PROCESS_MITIGATION_DYNAMIC_CODE_POLICY,
|
||||
gdef.PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY,
|
||||
gdef.PROCESS_MITIGATION_IMAGE_LOAD_POLICY,
|
||||
gdef.PROCESS_MITIGATION_POLICY,
|
||||
gdef.PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY,
|
||||
gdef.PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetProcessMitigationPolicy(hProcess, MitigationPolicy, lpBuffer, dwLength=None):
|
||||
if dwLength is None:
|
||||
dwLength = ctypes.sizeof(lpBuffer)
|
||||
return GetProcessMitigationPolicy.ctypes_function(hProcess, MitigationPolicy, lpBuffer, dwLength)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def SetProcessMitigationPolicy(MitigationPolicy, lpBuffer, dwLength=None):
|
||||
if dwLength is None:
|
||||
dwLength = ctypes.sizeof(lpBuffer)
|
||||
if isinstance(lpBuffer, PROCESS_MITIGATION_STUCTS):
|
||||
lpBuffer = ctypes.byref(lpBuffer)
|
||||
return SetProcessMitigationPolicy.ctypes_function(MitigationPolicy, lpBuffer, dwLength)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetProcessDEPPolicy(hProcess, lpFlags, lpPermanent):
|
||||
return GetProcessDEPPolicy.ctypes_function(hProcess, lpFlags, lpPermanent)
|
||||
|
||||
## Process Infos ThreadAttribute
|
||||
|
||||
# ProcThreadAttributeList
|
||||
def initializeprocthreadattributelist_error_check(func_name, result, func, args):
|
||||
if result:
|
||||
return args
|
||||
error = GetLastError()
|
||||
if error == gdef.ERROR_INSUFFICIENT_BUFFER and args[0] is None:
|
||||
return args
|
||||
raise WinproxyError(func_name)
|
||||
|
||||
@Kernel32Proxy(error_check=initializeprocthreadattributelist_error_check)
|
||||
def InitializeProcThreadAttributeList(lpAttributeList=None, dwAttributeCount=NeededParameter, dwFlags=0, lpSize=NeededParameter):
|
||||
return InitializeProcThreadAttributeList.ctypes_function(lpAttributeList, dwAttributeCount, dwFlags, lpSize)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def UpdateProcThreadAttribute(lpAttributeList, dwFlags=0, Attribute=NeededParameter, lpValue=NeededParameter, cbSize=NeededParameter, lpPreviousValue=None, lpReturnSize=None):
|
||||
return UpdateProcThreadAttribute.ctypes_function(lpAttributeList, dwFlags, Attribute, lpValue, cbSize, lpPreviousValue, lpReturnSize)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def DeleteProcThreadAttributeList(lpAttributeList):
|
||||
return DeleteProcThreadAttributeList.ctypes_function(lpAttributeList)
|
||||
|
||||
|
||||
## Process-module
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetModuleHandleA(lpModuleName):
|
||||
return GetModuleHandleA.ctypes_function(lpModuleName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetModuleHandleW(lpModuleName):
|
||||
return GetModuleHandleW.ctypes_function(lpModuleName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetModuleFileNameA(hModule, lpFilename, nSize):
|
||||
return GetModuleFileNameA.ctypes_function(hModule, lpFilename, nSize)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetModuleFileNameW(hModule, lpFilename, nSize):
|
||||
return GetModuleFileNameW.ctypes_function(hModule, lpFilename, nSize)
|
||||
|
||||
## Thread
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetExitCodeThread(hThread, lpExitCode):
|
||||
return GetExitCodeThread.ctypes_function(hThread, lpExitCode)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetCurrentThread():
|
||||
return GetCurrentThread.ctypes_function()
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetCurrentThreadId():
|
||||
return GetCurrentThreadId.ctypes_function()
|
||||
|
||||
@Kernel32Proxy()
|
||||
def TerminateThread(hThread, dwExitCode):
|
||||
return TerminateThread.ctypes_function(hThread, dwExitCode)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def ExitThread(dwExitCode):
|
||||
return ExitThread.ctypes_function(dwExitCode)
|
||||
|
||||
@Kernel32Proxy(error_check=fail_on_minus_one)
|
||||
def ResumeThread(hThread):
|
||||
return ResumeThread.ctypes_function(hThread)
|
||||
|
||||
@Kernel32Proxy(error_check=fail_on_minus_one)
|
||||
def SuspendThread(hThread):
|
||||
return SuspendThread.ctypes_function(hThread)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetThreadId(Thread):
|
||||
return GetThreadId.ctypes_function(Thread)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreateThread(lpThreadAttributes=None, dwStackSize=0, lpStartAddress=NeededParameter, lpParameter=NeededParameter, dwCreationFlags=0, lpThreadId=None):
|
||||
return CreateThread.ctypes_function(lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, lpThreadId)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreateRemoteThread(hProcess=NeededParameter, lpThreadAttributes=None, dwStackSize=0,
|
||||
lpStartAddress=NeededParameter, lpParameter=NeededParameter, dwCreationFlags=0, lpThreadId=None):
|
||||
return CreateRemoteThread.ctypes_function(hProcess, lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, lpThreadId)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetThreadContext(hThread, lpContext):
|
||||
# TODO: RM ME IF TEST PASS
|
||||
# if lpContext is None:
|
||||
# Context = CONTEXT()
|
||||
# context.ContextFlags = CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS
|
||||
# lpContext = ctypes.byref(Context)
|
||||
return GetThreadContext.ctypes_function(hThread, lpContext)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def SetThreadContext(hThread, lpContext):
|
||||
return SetThreadContext.ctypes_function(hThread, lpContext)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def OpenThread(dwDesiredAccess=gdef.THREAD_ALL_ACCESS, bInheritHandle=0, dwThreadId=NeededParameter):
|
||||
return OpenThread.ctypes_function(dwDesiredAccess, bInheritHandle, dwThreadId)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def SetThreadAffinityMask(hThread=None, dwThreadAffinityMask=NeededParameter):
|
||||
"""If hThread is not given, it will be the current thread"""
|
||||
if hThread is None:
|
||||
hThread = GetCurrentThread()
|
||||
return SetThreadAffinityMask.ctypes_function(hThread, dwThreadAffinityMask)
|
||||
|
||||
|
||||
## Memory
|
||||
|
||||
@Kernel32Proxy(error_check=succeed_on_zero)
|
||||
def LocalFree(hMem):
|
||||
return LocalFree.ctypes_function(hMem)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def VirtualAlloc(lpAddress=0, dwSize=NeededParameter, flAllocationType=gdef.MEM_COMMIT, flProtect=gdef.PAGE_EXECUTE_READWRITE):
|
||||
return VirtualAlloc.ctypes_function(lpAddress, dwSize, flAllocationType, flProtect)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def VirtualFree(lpAddress, dwSize=0, dwFreeType=gdef.MEM_RELEASE):
|
||||
return VirtualFree.ctypes_function(lpAddress, dwSize, dwFreeType)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def VirtualProtect(lpAddress, dwSize, flNewProtect, lpflOldProtect=None):
|
||||
if lpflOldProtect is None:
|
||||
lpflOldProtect = ctypes.byref(gdef.DWORD())
|
||||
return VirtualProtect.ctypes_function(lpAddress, dwSize, flNewProtect, lpflOldProtect)
|
||||
|
||||
|
||||
## Memory remote
|
||||
|
||||
@Kernel32Proxy()
|
||||
def VirtualQueryEx(hProcess, lpAddress, lpBuffer, dwLength):
|
||||
return VirtualQueryEx.ctypes_function(hProcess, lpAddress, lpBuffer, dwLength)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def VirtualAllocEx(hProcess, lpAddress=0, dwSize=NeededParameter, flAllocationType=gdef.MEM_COMMIT, flProtect=gdef.PAGE_EXECUTE_READWRITE):
|
||||
return VirtualAllocEx.ctypes_function(hProcess, lpAddress, dwSize, flAllocationType, flProtect)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def VirtualFreeEx(hProcess, lpAddress, dwSize=0, dwFreeType=gdef.MEM_RELEASE):
|
||||
return VirtualFreeEx.ctypes_function(hProcess, lpAddress, dwSize, dwFreeType)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def VirtualProtectEx(hProcess, lpAddress, dwSize, flNewProtect, lpflOldProtect=None):
|
||||
if lpflOldProtect is None:
|
||||
lpflOldProtect = ctypes.byref(gdef.DWORD())
|
||||
return VirtualProtectEx.ctypes_function(hProcess, lpAddress, dwSize, flNewProtect, lpflOldProtect)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def ReadProcessMemory(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead=None):
|
||||
return ReadProcessMemory.ctypes_function(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def WriteProcessMemory(hProcess, lpBaseAddress, lpBuffer, nSize=None, lpNumberOfBytesWritten=None):
|
||||
"""Computer nSize with len(lpBuffer) if not given"""
|
||||
if nSize is None:
|
||||
nSize = len(lpBuffer)
|
||||
return WriteProcessMemory.ctypes_function(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten)
|
||||
|
||||
|
||||
## Error
|
||||
|
||||
@Kernel32Proxy(error_check=no_error_check)
|
||||
def GetLastError():
|
||||
return GetLastError.ctypes_function()
|
||||
|
||||
## Handle
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CloseHandle(hObject):
|
||||
return CloseHandle.ctypes_function(hObject)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def DuplicateHandle(hSourceProcessHandle, hSourceHandle, hTargetProcessHandle, lpTargetHandle, dwDesiredAccess=0, bInheritHandle=False, dwOptions=0):
|
||||
return DuplicateHandle.ctypes_function(hSourceProcessHandle, hSourceHandle, hTargetProcessHandle, lpTargetHandle, dwDesiredAccess, bInheritHandle, dwOptions)
|
||||
|
||||
|
||||
|
||||
## Process Modules
|
||||
@Kernel32Proxy()
|
||||
def GetProcAddress(hModule, lpProcName):
|
||||
return GetProcAddress.ctypes_function(hModule, lpProcName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def LoadLibraryA(lpFileName):
|
||||
return LoadLibraryA.ctypes_function(lpFileName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def LoadLibraryW(lpFileName):
|
||||
return LoadLibraryW.ctypes_function(lpFileName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def LoadLibraryExA(lpLibFileName, hFile, dwFlags):
|
||||
return LoadLibraryExA.ctypes_function(lpLibFileName, hFile, dwFlags)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def LoadLibraryExW(lpLibFileName, hFile, dwFlags):
|
||||
return LoadLibraryExW.ctypes_function(lpLibFileName, hFile, dwFlags)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FreeLibrary(hLibModule):
|
||||
return FreeLibrary.ctypes_function(hLibModule)
|
||||
|
||||
## Version
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetVersionExA(lpVersionInformation):
|
||||
return GetVersionExA.ctypes_function(lpVersionInformation)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetVersionExW(lpVersionInformation):
|
||||
return GetVersionExW.ctypes_function(lpVersionInformation)
|
||||
|
||||
|
||||
|
||||
## Hardware
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetCurrentProcessorNumber():
|
||||
return GetCurrentProcessorNumber.ctypes_function()
|
||||
|
||||
## Console
|
||||
|
||||
@Kernel32Proxy()
|
||||
def AllocConsole():
|
||||
return AllocConsole.ctypes_function()
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FreeConsole():
|
||||
return FreeConsole.ctypes_function()
|
||||
|
||||
@Kernel32Proxy()
|
||||
def SetConsoleCtrlHandler(HandlerRoutine, Add):
|
||||
return SetConsoleCtrlHandler.ctypes_function(HandlerRoutine, Add)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetStdHandle(nStdHandle):
|
||||
return GetStdHandle.ctypes_function(nStdHandle)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def SetStdHandle(nStdHandle, hHandle):
|
||||
return SetStdHandle.ctypes_function(nStdHandle, hHandle)
|
||||
|
||||
## System
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetComputerNameA(lpBuffer, lpnSize):
|
||||
return GetComputerNameA.ctypes_function(lpBuffer, lpnSize)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetComputerNameW(lpBuffer, lpnSize):
|
||||
return GetComputerNameW.ctypes_function(lpBuffer, lpnSize)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetComputerNameExA(NameType, lpBuffer, nSize):
|
||||
return GetComputerNameExA.ctypes_function(NameType, lpBuffer, nSize)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetComputerNameExW(NameType, lpBuffer, nSize):
|
||||
return GetComputerNameExW.ctypes_function(NameType, lpBuffer, nSize)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetWindowsDirectoryA(lpBuffer, uSize=None):
|
||||
if uSize is None:
|
||||
uSize = gdef.DWORD(len(lpBuffer))
|
||||
return GetWindowsDirectoryA.ctypes_function(lpBuffer, uSize)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetWindowsDirectoryW(lpBuffer, uSize=None):
|
||||
if uSize is None:
|
||||
uSize = gdef.DWORD(len(lpBuffer))
|
||||
return GetWindowsDirectoryW.ctypes_function(lpBuffer, uSize)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetProductInfo(dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, dwSpMinorVersion, pdwReturnedProductType):
|
||||
return GetProductInfo.ctypes_function(dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, dwSpMinorVersion, pdwReturnedProductType)
|
||||
|
||||
|
||||
|
||||
|
||||
## Other
|
||||
|
||||
@Kernel32Proxy(error_check=no_error_check)
|
||||
def lstrcmpA(lpString1, lpString2):
|
||||
return lstrcmpA.ctypes_function(lpString1, lpString2)
|
||||
|
||||
@Kernel32Proxy(error_check=no_error_check)
|
||||
def lstrcmpW(lpString1, lpString2):
|
||||
return lstrcmpW.ctypes_function(lpString1, lpString2)
|
||||
|
||||
@Kernel32Proxy("Sleep", no_error_check)
|
||||
def Sleep(dwMilliseconds):
|
||||
return Sleep.ctypes_function(dwMilliseconds)
|
||||
|
||||
@Kernel32Proxy("SleepEx", no_error_check)
|
||||
def SleepEx(dwMilliseconds, bAlertable=False):
|
||||
return SleepEx.ctypes_function(dwMilliseconds, bAlertable)
|
||||
|
||||
|
||||
@Kernel32Proxy(error_check=succeed_on_zero)
|
||||
def WaitForSingleObject(hHandle, dwMilliseconds=gdef.INFINITE):
|
||||
return WaitForSingleObject.ctypes_function(hHandle, dwMilliseconds)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def DeviceIoControl(hDevice, dwIoControlCode, lpInBuffer, nInBufferSize=None, lpOutBuffer=NeededParameter, nOutBufferSize=None, lpBytesReturned=None, lpOverlapped=None):
|
||||
if nInBufferSize is None:
|
||||
nInBufferSize = len(lpInBuffer)
|
||||
if nOutBufferSize is None:
|
||||
nOutBufferSize = len(lpOutBuffer)
|
||||
if lpBytesReturned is None:
|
||||
# Some windows check 0 / others does not
|
||||
lpBytesReturned = ctypes.byref(gdef.DWORD())
|
||||
return DeviceIoControl.ctypes_function(hDevice, dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped)
|
||||
|
||||
|
||||
# Wow64
|
||||
|
||||
@Kernel32Proxy()
|
||||
def Wow64DisableWow64FsRedirection(OldValue=None):
|
||||
if OldValue is None:
|
||||
OldValue = gdef.PVOID()
|
||||
return Wow64DisableWow64FsRedirection.ctypes_function(OldValue)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def Wow64RevertWow64FsRedirection(OldValue=None):
|
||||
if OldValue is None:
|
||||
OldValue = gdef.PVOID()
|
||||
return Wow64RevertWow64FsRedirection.ctypes_function(OldValue)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def Wow64EnableWow64FsRedirection(Wow64FsEnableRedirection):
|
||||
return Wow64EnableWow64FsRedirection.ctypes_function(Wow64FsEnableRedirection)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def Wow64GetThreadContext(hThread, lpContext):
|
||||
return Wow64GetThreadContext.ctypes_function(hThread, lpContext)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def Wow64SetThreadContext(hThread, lpContext):
|
||||
return Wow64SetThreadContext.ctypes_function(hThread, lpContext)
|
||||
|
||||
|
||||
|
||||
## File
|
||||
|
||||
@Kernel32Proxy(error_check=result_is_handle)
|
||||
def CreateFileA(lpFileName, dwDesiredAccess=gdef.GENERIC_READ, dwShareMode=0, lpSecurityAttributes=None, dwCreationDisposition=gdef.OPEN_EXISTING, dwFlagsAndAttributes=gdef.FILE_ATTRIBUTE_NORMAL, hTemplateFile=None):
|
||||
return CreateFileA.ctypes_function(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile)
|
||||
|
||||
|
||||
@Kernel32Proxy(error_check=result_is_handle)
|
||||
def CreateFileW(lpFileName, dwDesiredAccess=gdef.GENERIC_READ, dwShareMode=0, lpSecurityAttributes=None, dwCreationDisposition=gdef.OPEN_EXISTING, dwFlagsAndAttributes=gdef.FILE_ATTRIBUTE_NORMAL, hTemplateFile=None):
|
||||
return CreateFileW.ctypes_function(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile)
|
||||
|
||||
@Kernel32Proxy(error_check=result_is_handle)
|
||||
def CreateFileTransactedA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile, hTransaction, pusMiniVersion, pExtendedParameter):
|
||||
return CreateFileTransactedA.ctypes_function(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile, hTransaction, pusMiniVersion, pExtendedParameter)
|
||||
|
||||
@Kernel32Proxy(error_check=result_is_handle)
|
||||
def CreateFileTransactedW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile, hTransaction, pusMiniVersion, pExtendedParameter):
|
||||
return CreateFileTransactedW.ctypes_function(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile, hTransaction, pusMiniVersion, pExtendedParameter)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def ReadFile(hFile, lpBuffer, nNumberOfBytesToRead=None, lpNumberOfBytesRead=None, lpOverlapped=None):
|
||||
if nNumberOfBytesToRead is None:
|
||||
nNumberOfBytesToRead = len(lpBuffer)
|
||||
if lpOverlapped is None and lpNumberOfBytesRead is None:
|
||||
lpNumberOfBytesRead = ctypes.byref(gdef.DWORD())
|
||||
return ReadFile.ctypes_function(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite=None, lpNumberOfBytesWritten=None, lpOverlapped=None):
|
||||
if nNumberOfBytesToWrite is None:
|
||||
nNumberOfBytesToWrite = len(lpBuffer)
|
||||
if lpOverlapped is None and lpNumberOfBytesWritten is None:
|
||||
lpNumberOfBytesWritten = ctypes.byref(gdef.DWORD())
|
||||
return WriteFile.ctypes_function(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreateFileMappingA(hFile, lpFileMappingAttributes=None, flProtect=gdef.PAGE_READWRITE, dwMaximumSizeHigh=0, dwMaximumSizeLow=NeededParameter, lpName=NeededParameter):
|
||||
return CreateFileMappingA.ctypes_function(hFile, lpFileMappingAttributes, flProtect, dwMaximumSizeHigh, dwMaximumSizeLow, lpName)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreateFileMappingW(hFile, lpFileMappingAttributes=None, flProtect=gdef.PAGE_READWRITE, dwMaximumSizeHigh=0, dwMaximumSizeLow=0, lpName=NeededParameter):
|
||||
return CreateFileMappingW.ctypes_function(hFile, lpFileMappingAttributes, flProtect, dwMaximumSizeHigh, dwMaximumSizeLow, lpName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def OpenFileMappingW(dwDesiredAccess, bInheritHandle, lpName):
|
||||
return OpenFileMappingW.ctypes_function(dwDesiredAccess, bInheritHandle, lpName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def OpenFileMappingA(dwDesiredAccess, bInheritHandle, lpName):
|
||||
return OpenFileMappingA.ctypes_function(dwDesiredAccess, bInheritHandle, lpName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def MapViewOfFile(hFileMappingObject, dwDesiredAccess=gdef.FILE_MAP_ALL_ACCESS, dwFileOffsetHigh=0, dwFileOffsetLow=0, dwNumberOfBytesToMap=NeededParameter):
|
||||
return MapViewOfFile.ctypes_function(hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh, dwFileOffsetLow, dwNumberOfBytesToMap)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def UnmapViewOfFile(lpBaseAddress):
|
||||
return UnmapViewOfFile.ctypes_function(lpBaseAddress)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindFirstFileA(lpFileName, lpFindFileData):
|
||||
return FindFirstFileA.ctypes_function(lpFileName, lpFindFileData)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindFirstFileW(lpFileName, lpFindFileData):
|
||||
return FindFirstFileW.ctypes_function(lpFileName, lpFindFileData)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindNextFileA(hFindFile, lpFindFileData):
|
||||
return FindNextFileA.ctypes_function(hFindFile, lpFindFileData)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindNextFileW(hFindFile, lpFindFileData):
|
||||
return FindNextFileW.ctypes_function(hFindFile, lpFindFileData)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindClose(hFindFile):
|
||||
return FindClose.ctypes_function(hFindFile)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindFirstChangeNotificationA(lpPathName, bWatchSubtree, dwNotifyFilter):
|
||||
return FindFirstChangeNotificationA.ctypes_function(lpPathName, bWatchSubtree, dwNotifyFilter)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindFirstChangeNotificationW(lpPathName, bWatchSubtree, dwNotifyFilter):
|
||||
return FindFirstChangeNotificationW.ctypes_function(lpPathName, bWatchSubtree, dwNotifyFilter)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindNextChangeNotification(hChangeHandle):
|
||||
return FindNextChangeNotification.ctypes_function(hChangeHandle)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindCloseChangeNotification(hChangeHandle):
|
||||
return FindCloseChange
|
||||
Notification.ctypes_function(hChangeHandle)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindNextChangeNotification(hChangeHandle):
|
||||
return FindNextChangeNotification.ctypes_function(hChangeHandle)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def ReadDirectoryChangesW(hDirectory, lpBuffer, nBufferLength, bWatchSubtree, dwNotifyFilter, lpBytesReturned, lpOverlapped, lpCompletionRoutine):
|
||||
return ReadDirectoryChangesW.ctypes_function(hDirectory, lpBuffer, nBufferLength, bWatchSubtree, dwNotifyFilter, lpBytesReturned, lpOverlapped, lpCompletionRoutine)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def ReadDirectoryChangesExW(hDirectory, lpBuffer, nBufferLength, bWatchSubtree, dwNotifyFilter, lpBytesReturned, lpOverlapped, lpCompletionRoutine, ReadDirectoryNotifyInformationClass):
|
||||
return ReadDirectoryChangesExW.ctypes_function(hDirectory, lpBuffer, nBufferLength, bWatchSubtree, dwNotifyFilter, lpBytesReturned, lpOverlapped, lpCompletionRoutine, ReadDirectoryNotifyInformationClass)
|
||||
|
||||
|
||||
|
||||
## Tlhelp (snapshoot)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreateToolhelp32Snapshot(dwFlags, th32ProcessID=0):
|
||||
return CreateToolhelp32Snapshot.ctypes_function(dwFlags, th32ProcessID)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def Thread32First(hSnapshot, lpte):
|
||||
"""Set byref(lpte) if needed"""
|
||||
if type(lpte) == gdef.THREADENTRY32:
|
||||
lpte = ctypes.byref(lpte)
|
||||
return Thread32First.ctypes_function(hSnapshot, lpte)
|
||||
|
||||
@Kernel32Proxy(error_check=no_error_check)
|
||||
def Thread32Next(hSnapshot, lpte):
|
||||
"""Set byref(lpte) if needed"""
|
||||
if type(lpte) == gdef.THREADENTRY32:
|
||||
lpte = ctypes.byref(lpte)
|
||||
return Thread32Next.ctypes_function(hSnapshot, lpte)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def Process32First(hSnapshot, lpte):
|
||||
return Process32First.ctypes_function(hSnapshot, lpte)
|
||||
|
||||
@Kernel32Proxy(error_check=no_error_check)
|
||||
def Process32Next(hSnapshot, lpte):
|
||||
return Process32Next.ctypes_function(hSnapshot, lpte)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def Process32FirstW(hSnapshot, lppe):
|
||||
return Process32FirstW.ctypes_function(hSnapshot, lppe)
|
||||
|
||||
@Kernel32Proxy(error_check=no_error_check)
|
||||
def Process32NextW(hSnapshot, lppe):
|
||||
return Process32NextW.ctypes_function(hSnapshot, lppe)
|
||||
|
||||
|
||||
## VEH
|
||||
|
||||
@Kernel32Proxy()
|
||||
def AddVectoredContinueHandler(FirstHandler=1, VectoredHandler=NeededParameter):
|
||||
return AddVectoredContinueHandler.ctypes_function(FirstHandler, VectoredHandler)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def AddVectoredExceptionHandler(FirstHandler=1, VectoredHandler=NeededParameter):
|
||||
return AddVectoredExceptionHandler.ctypes_function(FirstHandler, VectoredHandler)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def RemoveVectoredExceptionHandler(Handler):
|
||||
return RemoveVectoredExceptionHandler.ctypes_function(Handler)
|
||||
|
||||
## Event
|
||||
|
||||
@Kernel32Proxy()
|
||||
def OpenEventA(dwDesiredAccess, bInheritHandle, lpName):
|
||||
return OpenEventA.ctypes_function(dwDesiredAccess, bInheritHandle, lpName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def OpenEventW(dwDesiredAccess, bInheritHandle, lpName):
|
||||
return OpenEventW.ctypes_function(dwDesiredAccess, bInheritHandle, lpName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreateEventA(lpEventAttributes, bManualReset, bInitialState, lpName):
|
||||
return CreateEventA.ctypes_function(lpEventAttributes, bManualReset, bInitialState, lpName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreateEventW(lpEventAttributes, bManualReset, bInitialState, lpName):
|
||||
return CreateEventW.ctypes_function(lpEventAttributes, bManualReset, bInitialState, lpName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreateEventExA(lpEventAttributes, lpName, dwFlags, dwDesiredAccess):
|
||||
return CreateEventExA.ctypes_function(lpEventAttributes, lpName, dwFlags, dwDesiredAccess)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreateEventExW(lpEventAttributes, lpName, dwFlags, dwDesiredAccess):
|
||||
return CreateEventExW.ctypes_function(lpEventAttributes, lpName, dwFlags, dwDesiredAccess)
|
||||
|
||||
|
||||
## Path
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetLongPathNameA(lpszShortPath, lpszLongPath, cchBuffer=None):
|
||||
if cchBuffer is None:
|
||||
cchBuffer = len(lpszLongPath)
|
||||
return GetLongPathNameA.ctypes_function(lpszShortPath, lpszLongPath, cchBuffer)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetLongPathNameW(lpszShortPath, lpszLongPath, cchBuffer=None):
|
||||
if cchBuffer is None:
|
||||
cchBuffer = len(lpszLongPath)
|
||||
return GetLongPathNameW.ctypes_function(lpszShortPath, lpszLongPath, cchBuffer)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetShortPathNameA(lpszLongPath, lpszShortPath, cchBuffer=None):
|
||||
if cchBuffer is None:
|
||||
cchBuffer = len(lpszShortPath)
|
||||
return GetShortPathNameA.ctypes_function(lpszLongPath, lpszShortPath, cchBuffer)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetShortPathNameW(lpszLongPath, lpszShortPath, cchBuffer=None):
|
||||
if cchBuffer is None:
|
||||
cchBuffer = len(lpszShortPath)
|
||||
return GetShortPathNameW.ctypes_function(lpszLongPath, lpszShortPath, cchBuffer)
|
||||
|
||||
|
||||
# Debug-API
|
||||
|
||||
@Kernel32Proxy(error_check=no_error_check)
|
||||
def IsDebuggerPresent():
|
||||
return IsDebuggerPresent.ctypes_function()
|
||||
|
||||
@Kernel32Proxy()
|
||||
def WaitForDebugEvent(lpDebugEvent, dwMilliseconds=gdef.INFINITE):
|
||||
return WaitForDebugEvent.ctypes_function(lpDebugEvent, dwMilliseconds)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def DebugBreak():
|
||||
return DebugBreak.ctypes_function()
|
||||
|
||||
@Kernel32Proxy()
|
||||
def ContinueDebugEvent(dwProcessId, dwThreadId, dwContinueStatus):
|
||||
return ContinueDebugEvent.ctypes_function(dwProcessId, dwThreadId, dwContinueStatus)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def DebugActiveProcess(dwProcessId):
|
||||
return DebugActiveProcess.ctypes_function(dwProcessId)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def DebugActiveProcessStop(dwProcessId):
|
||||
return DebugActiveProcessStop.ctypes_function(dwProcessId)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def DebugSetProcessKillOnExit(KillOnExit):
|
||||
return DebugSetProcessKillOnExit.ctypes_function(KillOnExit)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def DebugBreakProcess(Process):
|
||||
return DebugBreakProcess.ctypes_function(Process)
|
||||
|
||||
# Volumes
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetLogicalDriveStringsA(nBufferLength, lpBuffer):
|
||||
return GetLogicalDriveStringsA.ctypes_function(nBufferLength, lpBuffer)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetLogicalDriveStringsW(nBufferLength, lpBuffer):
|
||||
return GetLogicalDriveStringsW.ctypes_function(nBufferLength, lpBuffer)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetVolumeNameForVolumeMountPointA(lpszVolumeMountPoint, lpszVolumeName, cchBufferLength):
|
||||
return GetVolumeNameForVolumeMountPointA.ctypes_function(lpszVolumeMountPoint, lpszVolumeName, cchBufferLength)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetVolumeNameForVolumeMountPointW(lpszVolumeMountPoint, lpszVolumeName, cchBufferLength):
|
||||
return GetVolumeNameForVolumeMountPointW.ctypes_function(lpszVolumeMountPoint, lpszVolumeName, cchBufferLength)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetDriveTypeA(lpRootPathName):
|
||||
return GetDriveTypeA.ctypes_function(lpRootPathName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetDriveTypeW(lpRootPathName):
|
||||
return GetDriveTypeW.ctypes_function(lpRootPathName)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def QueryDosDeviceA(lpDeviceName, lpTargetPath, ucchMax):
|
||||
return QueryDosDeviceA.ctypes_function(lpDeviceName, lpTargetPath, ucchMax)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def QueryDosDeviceW(lpDeviceName, lpTargetPath, ucchMax):
|
||||
return QueryDosDeviceW.ctypes_function(lpDeviceName, lpTargetPath, ucchMax)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetVolumeInformationA(lpRootPathName, lpVolumeNameBuffer, nVolumeNameSize, lpVolumeSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize):
|
||||
if nVolumeNameSize == 0 and lpVolumeNameBuffer is not None:
|
||||
nVolumeNameSize = len(lpVolumeNameBuffer)
|
||||
if nFileSystemNameSize == 0 and lpFileSystemNameBuffer is not None:
|
||||
nFileSystemNameSize = len(lpFileSystemNameBuffer)
|
||||
return GetVolumeInformationA.ctypes_function(lpRootPathName, lpVolumeNameBuffer, nVolumeNameSize, lpVolumeSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetVolumeInformationW(lpRootPathName, lpVolumeNameBuffer=None, nVolumeNameSize=0, lpVolumeSerialNumber=None, lpMaximumComponentLength=None, lpFileSystemFlags=None, lpFileSystemNameBuffer=None, nFileSystemNameSize=0):
|
||||
if nVolumeNameSize == 0 and lpVolumeNameBuffer is not None:
|
||||
nVolumeNameSize = len(lpVolumeNameBuffer)
|
||||
if nFileSystemNameSize == 0 and lpFileSystemNameBuffer is not None:
|
||||
nFileSystemNameSize = len(lpFileSystemNameBuffer)
|
||||
return GetVolumeInformationW.ctypes_function(lpRootPathName, lpVolumeNameBuffer, nVolumeNameSize, lpVolumeSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindFirstVolumeA(lpszVolumeName, cchBufferLength):
|
||||
if cchBufferLength is None:
|
||||
cchBufferLength = len(lpszVolumeName)
|
||||
return FindFirstVolumeA.ctypes_function(lpszVolumeName, cchBufferLength)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindFirstVolumeW(lpszVolumeName, cchBufferLength):
|
||||
if cchBufferLength is None:
|
||||
cchBufferLength = len(lpszVolumeName)
|
||||
return FindFirstVolumeW.ctypes_function(lpszVolumeName, cchBufferLength)
|
||||
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindNextVolumeA(hFindVolume, lpszVolumeName, cchBufferLength):
|
||||
if cchBufferLength is None:
|
||||
cchBufferLength = len(lpszVolumeName)
|
||||
return FindNextVolumeA.ctypes_function(hFindVolume, lpszVolumeName, cchBufferLength)
|
||||
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindNextVolumeW(hFindVolume, lpszVolumeName, cchBufferLength):
|
||||
if cchBufferLength is None:
|
||||
cchBufferLength = len(lpszVolumeName)
|
||||
return FindNextVolumeW.ctypes_function(hFindVolume, lpszVolumeName, cchBufferLength)
|
||||
|
||||
# pipe
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreateNamedPipeA(lpName, dwOpenMode, dwPipeMode, nMaxInstances, nOutBufferSize, nInBufferSize, nDefaultTimeOut, lpSecurityAttributes):
|
||||
return CreateNamedPipeA.ctypes_function(lpName, dwOpenMode, dwPipeMode, nMaxInstances, nOutBufferSize, nInBufferSize, nDefaultTimeOut, lpSecurityAttributes)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreateNamedPipeW(lpName, dwOpenMode, dwPipeMode, nMaxInstances, nOutBufferSize, nInBufferSize, nDefaultTimeOut, lpSecurityAttributes):
|
||||
return CreateNamedPipeW.ctypes_function(lpName, dwOpenMode, dwPipeMode, nMaxInstances, nOutBufferSize, nInBufferSize, nDefaultTimeOut, lpSecurityAttributes)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def ConnectNamedPipe(hNamedPipe, lpOverlapped):
|
||||
return ConnectNamedPipe.ctypes_function(hNamedPipe, lpOverlapped)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def SetNamedPipeHandleState(hNamedPipe, lpMode, lpMaxCollectionCount, lpCollectDataTimeout):
|
||||
return SetNamedPipeHandleState.ctypes_function(hNamedPipe, lpMode, lpMaxCollectionCount, lpCollectDataTimeout)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def CreatePipe(hReadPipe, hWritePipe, lpPipeAttributes, nSize):
|
||||
return CreatePipe.ctypes_function(hReadPipe, hWritePipe, lpPipeAttributes, nSize)
|
||||
|
||||
# Firmware
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetFirmwareEnvironmentVariableA(lpName, lpGuid, pBuffer, nSize):
|
||||
return GetFirmwareEnvironmentVariableA.ctypes_function(lpName, lpGuid, pBuffer, nSize)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetFirmwareEnvironmentVariableW(lpName, lpGuid, pBuffer, nSize):
|
||||
return GetFirmwareEnvironmentVariableW.ctypes_function(lpName, lpGuid, pBuffer, nSize)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetFirmwareEnvironmentVariableExA(lpName, lpGuid, pBuffer, nSize, pdwAttribubutes):
|
||||
return GetFirmwareEnvironmentVariableExA.ctypes_function(lpName, lpGuid, pBuffer, nSize, pdwAttribubutes)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def GetFirmwareEnvironmentVariableExW(lpName, lpGuid, pBuffer, nSize, pdwAttribubutes):
|
||||
return GetFirmwareEnvironmentVariableExW.ctypes_function(lpName, lpGuid, pBuffer, nSize, pdwAttribubutes)
|
||||
|
||||
#####
|
||||
|
||||
# Time
|
||||
|
||||
@Kernel32Proxy(error_check=fail_on_zero)
|
||||
def FileTimeToSystemTime(lpFileTime, lpSystemTime):
|
||||
return FileTimeToSystemTime.ctypes_function(lpFileTime, lpSystemTime)
|
||||
|
||||
@Kernel32Proxy(error_check=fail_on_zero)
|
||||
def SystemTimeToFileTime(lpSystemTime, lpFileTime):
|
||||
return SystemTimeToFileTime.ctypes_function(lpSystemTime, lpFileTime)
|
||||
|
||||
@Kernel32Proxy(error_check=None)
|
||||
def GetSystemTime(lpSystemTime):
|
||||
return GetSystemTime.ctypes_function(lpSystemTime)
|
||||
|
||||
@Kernel32Proxy(error_check=None)
|
||||
def GetSystemTimeAsFileTime(lpSystemTimeAsFileTime):
|
||||
return GetSystemTimeAsFileTime.ctypes_function(lpSystemTimeAsFileTime)
|
||||
|
||||
|
||||
@Kernel32Proxy(error_check=fail_on_zero)
|
||||
def GetSystemTimes(lpIdleTime, lpKernelTime, lpUserTime):
|
||||
return GetSystemTimes.ctypes_function(lpIdleTime, lpKernelTime, lpUserTime)
|
||||
|
||||
@Kernel32Proxy(error_check=None)
|
||||
def GetLocalTime(lpSystemTime):
|
||||
return GetLocalTime.ctypes_function(lpSystemTime)
|
||||
|
||||
@Kernel32Proxy(error_check=None)
|
||||
def GetTickCount():
|
||||
return GetTickCount.ctypes_function()
|
||||
|
||||
@Kernel32Proxy(error_check=None)
|
||||
def GetTickCount64():
|
||||
return GetTickCount64.ctypes_function()
|
||||
|
||||
#####
|
||||
|
||||
# Heap
|
||||
|
||||
@Kernel32Proxy(error_check=fail_on_zero)
|
||||
def HeapAlloc(hHeap, dwFlags, dwBytes):
|
||||
return HeapAlloc.ctypes_function(hHeap, dwFlags, dwBytes)
|
||||
|
||||
|
||||
#####
|
||||
|
||||
# Resources
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindResourceA(hModule, lpName, lpType):
|
||||
return FindResourceA.ctypes_function(hModule, lpName, lpType)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FindResourceW(hModule, lpName, lpType):
|
||||
return FindResourceW.ctypes_function(hModule, lpName, lpType)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def SizeofResource(hModule, hResInfo):
|
||||
return SizeofResource.ctypes_function(hModule, hResInfo)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def LoadResource(hModule, hResInfo):
|
||||
return LoadResource.ctypes_function(hModule, hResInfo)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def LockResource(hResData):
|
||||
return LockResource.ctypes_function(hResData)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def FreeResource(hResData):
|
||||
return FreeResource.ctypes_function(hResData)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def EnumResourceTypesA(hModule, lpEnumFunc, lParam):
|
||||
return EnumResourceTypesA.ctypes_function(hModule, lpEnumFunc, lParam)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def EnumResourceTypesW(hModule, lpEnumFunc, lParam):
|
||||
return EnumResourceTypesW.ctypes_function(hModule, lpEnumFunc, lParam)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def EnumResourceNamesA(hModule, lpType, lpEnumFunc, lParam):
|
||||
return EnumResourceNamesA.ctypes_function(hModule, lpType, lpEnumFunc, lParam)
|
||||
|
||||
@Kernel32Proxy()
|
||||
def EnumResourceNamesW(hModule, lpType, lpEnumFunc, lParam):
|
||||
return EnumResourceNamesW.ctypes_function(hModule, lpType, lpEnumFunc, lParam)
|
||||
@@ -0,0 +1,29 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import fail_on_zero
|
||||
|
||||
class Ktmw32Proxy(ApiProxy):
|
||||
APIDLL = "Ktmw32"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
|
||||
@Ktmw32Proxy()
|
||||
def CommitTransaction(TransactionHandle):
|
||||
return CommitTransaction.ctypes_function(TransactionHandle)
|
||||
|
||||
|
||||
@Ktmw32Proxy()
|
||||
def CreateTransaction(lpTransactionAttributes, UOW, CreateOptions, IsolationLevel, IsolationFlags, Timeout, Description):
|
||||
return CreateTransaction.ctypes_function(lpTransactionAttributes, UOW, CreateOptions, IsolationLevel, IsolationFlags, Timeout, Description)
|
||||
|
||||
|
||||
@Ktmw32Proxy()
|
||||
def RollbackTransaction(TransactionHandle):
|
||||
return RollbackTransaction.ctypes_function(TransactionHandle)
|
||||
|
||||
|
||||
@Ktmw32Proxy()
|
||||
def OpenTransaction(dwDesiredAccess, TransactionId):
|
||||
return OpenTransaction.ctypes_function(dwDesiredAccess, TransactionId)
|
||||
@@ -0,0 +1,58 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import succeed_on_zero
|
||||
|
||||
class NetApi32Proxy(ApiProxy):
|
||||
APIDLL = "netapi32"
|
||||
default_error_check = staticmethod(succeed_on_zero)
|
||||
|
||||
|
||||
@NetApi32Proxy()
|
||||
def NetLocalGroupGetMembers(servername, localgroupname, level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle):
|
||||
return NetLocalGroupGetMembers.ctypes_function(servername, localgroupname, level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle)
|
||||
|
||||
@NetApi32Proxy()
|
||||
def NetQueryDisplayInformation(ServerName, Level, Index, EntriesRequested, PreferredMaximumLength, ReturnedEntryCount, SortedBuffer):
|
||||
return NetQueryDisplayInformation.ctypes_function(ServerName, Level, Index, EntriesRequested, PreferredMaximumLength, ReturnedEntryCount, SortedBuffer)
|
||||
|
||||
@NetApi32Proxy()
|
||||
def NetUserEnum(servername, level, filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle):
|
||||
return NetUserEnum.ctypes_function(servername, level, filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle)
|
||||
|
||||
@NetApi32Proxy()
|
||||
def NetGroupEnum(servername, level, bufptr, prefmaxlen, entriesread, totalentries, resume_handle):
|
||||
return NetGroupEnum.ctypes_function(servername, level, bufptr, prefmaxlen, entriesread, totalentries, resume_handle)
|
||||
|
||||
@NetApi32Proxy()
|
||||
def NetGroupGetInfo(servername, groupname, level, bufptr):
|
||||
return NetGroupGetInfo.ctypes_function(servername, groupname, level, bufptr)
|
||||
|
||||
@NetApi32Proxy()
|
||||
def NetGroupGetUsers(servername, groupname, level, bufptr, prefmaxlen, entriesread, totalentries, ResumeHandle):
|
||||
return NetGroupGetUsers.ctypes_function(servername, groupname, level, bufptr, prefmaxlen, entriesread, totalentries, ResumeHandle)
|
||||
|
||||
@NetApi32Proxy()
|
||||
def NetLocalGroupEnum(servername, level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle):
|
||||
return NetLocalGroupEnum.ctypes_function(servername, level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle)
|
||||
|
||||
@NetApi32Proxy()
|
||||
def NetLocalGroupGetInfo(servername, groupname, level, bufptr):
|
||||
return NetLocalGroupGetInfo.ctypes_function(servername, groupname, level, bufptr)
|
||||
|
||||
@NetApi32Proxy()
|
||||
def NetLocalGroupGetMembers(servername, localgroupname, level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle):
|
||||
return NetLocalGroupGetMembers.ctypes_function(servername, localgroupname, level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle)
|
||||
|
||||
@NetApi32Proxy()
|
||||
def NetLocalGroupGetInfo(servername, groupname, level, bufptr):
|
||||
return NetLocalGroupGetInfo.ctypes_function(servername, groupname, level, bufptr)
|
||||
|
||||
@NetApi32Proxy()
|
||||
def NetLocalGroupEnum(servername, level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle):
|
||||
return NetLocalGroupEnum.ctypes_function(servername, level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle)
|
||||
|
||||
@NetApi32Proxy()
|
||||
def NetApiBufferFree(Buffer):
|
||||
return NetApiBufferFree.ctypes_function(Buffer)
|
||||
@@ -0,0 +1,425 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import WinproxyError, result_is_ntstatus, fail_on_zero
|
||||
|
||||
class NtdllProxy(ApiProxy):
|
||||
APIDLL = "ntdll"
|
||||
default_error_check = staticmethod(result_is_ntstatus)
|
||||
|
||||
|
||||
# Process
|
||||
|
||||
@NtdllProxy()
|
||||
def NtOpenProcess(ProcessHandle, DesiredAccess, ObjectAttributes, ClientId):
|
||||
return NtOpenProcess.ctypes_function(ProcessHandle, DesiredAccess, ObjectAttributes, ClientId)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtTerminateProcess(ProcessHandle, ExitStatus):
|
||||
return NtTerminateProcess.ctypes_function(ProcessHandle, ExitStatus)
|
||||
|
||||
# Memory
|
||||
|
||||
@NtdllProxy()
|
||||
def NtReadVirtualMemory(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead):
|
||||
return NtReadVirtualMemory.ctypes_function(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtWriteVirtualMemory(ProcessHandle, BaseAddress, Buffer, NumberOfBytesToWrite, NumberOfBytesWritten):
|
||||
return NtWriteVirtualMemory.ctypes_function(ProcessHandle, BaseAddress, Buffer, NumberOfBytesToWrite, NumberOfBytesWritten)
|
||||
|
||||
# Wow64
|
||||
|
||||
@NtdllProxy()
|
||||
def NtWow64ReadVirtualMemory64(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead=None):
|
||||
return NtWow64ReadVirtualMemory64.ctypes_function(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtWow64WriteVirtualMemory64(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten=None):
|
||||
return NtWow64WriteVirtualMemory64.ctypes_function(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten)
|
||||
|
||||
# File
|
||||
|
||||
@NtdllProxy()
|
||||
def NtCreateFile(FileHandle, DesiredAccess, ObjectAttributes, IoStatusBlock, AllocationSize, FileAttributes, ShareAccess, CreateDisposition, CreateOptions, EaBuffer, EaLength):
|
||||
return NtCreateFile.ctypes_function(FileHandle, DesiredAccess, ObjectAttributes, IoStatusBlock, AllocationSize, FileAttributes, ShareAccess, CreateDisposition, CreateOptions, EaBuffer, EaLength)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtOpenFile(FileHandle, DesiredAccess, ObjectAttributes, IoStatusBlock, ShareAccess, OpenOptions):
|
||||
return NtOpenFile.ctypes_function(FileHandle, DesiredAccess, ObjectAttributes, IoStatusBlock, ShareAccess, OpenOptions)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtSetInformationFile(FileHandle, IoStatusBlock, FileInformation, Length, FileInformationClass):
|
||||
return NtSetInformationFile.ctypes_function(FileHandle, IoStatusBlock, FileInformation, Length, FileInformationClass)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtQueryInformationFile(FileHandle, IoStatusBlock, FileInformation, Length=None, FileInformationClass=NeededParameter):
|
||||
if Length is None:
|
||||
Length = ctypes.sizeof(FileInformation)
|
||||
return NtQueryInformationFile.ctypes_function(FileHandle, IoStatusBlock, FileInformation, Length, FileInformationClass)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtQueryDirectoryFile(FileHandle, Event=None, ApcRoutine=None, ApcContext=None, IoStatusBlock=NeededParameter, FileInformation=NeededParameter, Length=None, FileInformationClass=NeededParameter, ReturnSingleEntry=NeededParameter, FileName=None, RestartScan=NeededParameter):
|
||||
if Length is None:
|
||||
Length = ctypes.sizeof(FileInformation)
|
||||
return NtQueryDirectoryFile.ctypes_function(FileHandle, Event, ApcRoutine, ApcContext, IoStatusBlock, FileInformation, Length, FileInformationClass, ReturnSingleEntry, FileName, RestartScan)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtQueryVolumeInformationFile(FileHandle, IoStatusBlock, FsInformation, Length=None, FsInformationClass=NeededParameter):
|
||||
if Length is None:
|
||||
Length = ctypes.sizeof(FsInformation)
|
||||
return NtQueryVolumeInformationFile.ctypes_function(FileHandle, IoStatusBlock, FsInformation, Length, FsInformationClass)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtQueryEaFile(FileHandle, IoStatusBlock, Buffer, Length, ReturnSingleEntry, EaList, EaListLength, EaIndex, RestartScan):
|
||||
return NtQueryEaFile.ctypes_function(FileHandle, IoStatusBlock, Buffer, Length, ReturnSingleEntry, EaList, EaListLength, EaIndex, RestartScan)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtSetEaFile(FileHandle, IoStatusBlock, Buffer, Length):
|
||||
return NtSetEaFile.ctypes_function(FileHandle, IoStatusBlock, Buffer, Length)
|
||||
|
||||
|
||||
# Process
|
||||
|
||||
@NtdllProxy()
|
||||
def NtQueryInformationProcess(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength=0, ReturnLength=None):
|
||||
if ProcessInformation is not None and ProcessInformationLength == 0:
|
||||
ProcessInformationLength = ctypes.sizeof(ProcessInformation)
|
||||
if type(ProcessInformation) == gdef.PROCESS_BASIC_INFORMATION:
|
||||
ProcessInformation = ctypes.byref(ProcessInformation)
|
||||
if ReturnLength is None:
|
||||
ReturnLength = ctypes.byref(gdef.ULONG())
|
||||
return NtQueryInformationProcess.ctypes_function(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength, ReturnLength)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtSetInformationProcess(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength=0):
|
||||
if not ProcessInformationLength:
|
||||
ProcessInformationLength = ctypes.sizeof(ProcessInformation)
|
||||
return NtSetInformationProcess.ctypes_function(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def LdrLoadDll(PathToFile, Flags, ModuleFileName, ModuleHandle):
|
||||
return LdrLoadDll.ctypes_function(PathToFile, Flags, ModuleFileName, ModuleHandle)
|
||||
|
||||
@NtdllProxy()
|
||||
def RtlGetUnloadEventTraceEx(ElementSize, ElementCount, EventTrace):
|
||||
return RtlGetUnloadEventTraceEx.ctypes_function(ElementSize, ElementCount, EventTrace)
|
||||
|
||||
|
||||
# Thread
|
||||
|
||||
@NtdllProxy()
|
||||
def NtGetContextThread(hThread, lpContext):
|
||||
return NtGetContextThread.ctypes_function(hThread, lpContext)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtQueryInformationThread(ThreadHandle, ThreadInformationClass, ThreadInformation, ThreadInformationLength=0, ReturnLength=None):
|
||||
if ReturnLength is None:
|
||||
ReturnLength = ctypes.byref(gdef.ULONG())
|
||||
if ThreadInformation is not None and ThreadInformationLength == 0:
|
||||
ThreadInformationLength = ctypes.sizeof(ThreadInformation)
|
||||
return NtQueryInformationThread.ctypes_function(ThreadHandle, ThreadInformationClass, ThreadInformation, ThreadInformationLength, ReturnLength)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtCreateProcessEx(ProcessHandle, DesiredAccess, ObjectAttributes=None, ParentProcess=NeededParameter, Flags=NeededParameter, SectionHandle=NeededParameter, DebugPort=None, ExceptionPort=None, InJob=False):
|
||||
return NtCreateProcessEx.ctypes_function(ProcessHandle, DesiredAccess, ObjectAttributes, ParentProcess, Flags, SectionHandle, DebugPort, ExceptionPort, InJob)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtCreateThreadEx(ThreadHandle=None, DesiredAccess=0x1fffff, ObjectAttributes=0, ProcessHandle=NeededParameter, lpStartAddress=NeededParameter, lpParameter=NeededParameter, CreateSuspended=0, dwStackSize=0, Unknown1=0, Unknown2=0, Unknown=0):
|
||||
if ThreadHandle is None:
|
||||
ThreadHandle = ctypes.byref(gdef.HANDLE())
|
||||
return NtCreateThreadEx.ctypes_function(ThreadHandle, DesiredAccess, ObjectAttributes, ProcessHandle, lpStartAddress, lpParameter, CreateSuspended, dwStackSize, Unknown1, Unknown2, Unknown3)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtSetContextThread(hThread, lpContext):
|
||||
return NtSetContextThread.ctypes_function(hThread, lpContext)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtDelayExecution(Alertable, DelayInterval):
|
||||
return NtDelayExecution.ctypes_function(Alertable, DelayInterval)
|
||||
|
||||
|
||||
# Memory
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAllocateVirtualMemory(ProcessHandle, BaseAddress, ZeroBits, RegionSize, AllocationType, Protect):
|
||||
return NtAllocateVirtualMemory.ctypes_function(ProcessHandle, BaseAddress, ZeroBits, RegionSize, AllocationType, Protect)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtFreeVirtualMemory(ProcessHandle, BaseAddress, RegionSize, FreeType):
|
||||
return NtFreeVirtualMemory.ctypes_function(ProcessHandle, BaseAddress, RegionSize, FreeType)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtProtectVirtualMemory(ProcessHandle, BaseAddress, NumberOfBytesToProtect, NewAccessProtection, OldAccessProtection=None):
|
||||
if OldAccessProtection is None:
|
||||
OldAccessProtection = gdef.DWORD()
|
||||
return NtProtectVirtualMemory.ctypes_function(ProcessHandle, BaseAddress, NumberOfBytesToProtect, NewAccessProtection, OldAccessProtection)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtQueryVirtualMemory(ProcessHandle, BaseAddress, MemoryInformationClass, MemoryInformation=NeededParameter, MemoryInformationLength=0, ReturnLength=None):
|
||||
if ReturnLength is None:
|
||||
ReturnLength = ctypes.byref(gdef.ULONG())
|
||||
if MemoryInformation is not None and MemoryInformationLength == 0:
|
||||
ProcessInformationLength = ctypes.sizeof(MemoryInformation)
|
||||
if type(MemoryInformation) == gdef.MEMORY_BASIC_INFORMATION64:
|
||||
MemoryInformation = ctypes.byref(MemoryInformation)
|
||||
return NtQueryVirtualMemory.ctypes_function(ProcessHandle, BaseAddress, MemoryInformationClass, MemoryInformation=NeededParameter, MemoryInformationLength=0, ReturnLength=None)
|
||||
|
||||
|
||||
# System
|
||||
|
||||
def ntquerysysteminformation_error_check(func_name, result, func, args):
|
||||
if result == 0:
|
||||
return args
|
||||
# Ignore STATUS_INFO_LENGTH_MISMATCH if SystemInformation is None
|
||||
if result == gdef.STATUS_INFO_LENGTH_MISMATCH and args[1] is None:
|
||||
return args
|
||||
raise WinproxyError("{0} failed with NTStatus {1}".format(func_name, hex(result)))
|
||||
|
||||
|
||||
@NtdllProxy(error_check=ntquerysysteminformation_error_check)
|
||||
def NtQuerySystemInformation(SystemInformationClass, SystemInformation=None, SystemInformationLength=0, ReturnLength=NeededParameter):
|
||||
if SystemInformation is not None and SystemInformationLength == 0:
|
||||
SystemInformationLength = ctypes.sizeof(SystemInformation)
|
||||
return NtQuerySystemInformation.ctypes_function(SystemInformationClass, SystemInformation, SystemInformationLength, ReturnLength)
|
||||
|
||||
# path
|
||||
|
||||
@NtdllProxy(error_check=fail_on_zero)
|
||||
def RtlDosPathNameToNtPathName_U(DosName, NtName=None, PartName=None, RelativeName=None):
|
||||
return RtlDosPathNameToNtPathName_U.ctypes_function(DosName, NtName, PartName, RelativeName)
|
||||
|
||||
|
||||
|
||||
# kernel Object
|
||||
|
||||
@NtdllProxy()
|
||||
def NtQueryObject(Handle, ObjectInformationClass, ObjectInformation=None, ObjectInformationLength=0, ReturnLength=NeededParameter):
|
||||
return NtQueryObject.ctypes_function(Handle, ObjectInformationClass, ObjectInformation, ObjectInformationLength, ReturnLength)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtOpenDirectoryObject(DirectoryHandle, DesiredAccess, ObjectAttributes):
|
||||
return NtOpenDirectoryObject.ctypes_function(DirectoryHandle, DesiredAccess, ObjectAttributes)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtQueryDirectoryObject(DirectoryHandle, Buffer, Length, ReturnSingleEntry, RestartScan, Context, ReturnLength):
|
||||
return NtQueryDirectoryObject.ctypes_function(DirectoryHandle, Buffer, Length, ReturnSingleEntry, RestartScan, Context, ReturnLength)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtCreateSymbolicLinkObject(pHandle, DesiredAccess, ObjectAttributes, DestinationName):
|
||||
return NtCreateSymbolicLinkObject.ctypes_function(pHandle, DesiredAccess, ObjectAttributes, DestinationName)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtOpenSymbolicLinkObject(LinkHandle, DesiredAccess, ObjectAttributes):
|
||||
return NtOpenSymbolicLinkObject.ctypes_function(LinkHandle, DesiredAccess, ObjectAttributes)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtQuerySymbolicLinkObject(LinkHandle, LinkTarget, ReturnedLength):
|
||||
return NtQuerySymbolicLinkObject.ctypes_function(LinkHandle, LinkTarget, ReturnedLength)
|
||||
|
||||
|
||||
# Event
|
||||
|
||||
@NtdllProxy()
|
||||
def NtOpenEvent(EventHandle, DesiredAccess, ObjectAttributes):
|
||||
return NtOpenEvent.ctypes_function(EventHandle, DesiredAccess, ObjectAttributes)
|
||||
|
||||
|
||||
# LPC
|
||||
|
||||
@NtdllProxy()
|
||||
def NtConnectPort(PortHandle, PortName, SecurityQos, ClientView, ServerView, MaxMessageLength, ConnectionInformation, ConnectionInformationLength):
|
||||
return NtConnectPort.ctypes_function(PortHandle, PortName, SecurityQos, ClientView, ServerView, MaxMessageLength, ConnectionInformation, ConnectionInformationLength)
|
||||
|
||||
|
||||
# ALPC
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAlpcCreatePort(PortHandle, ObjectAttributes, PortAttributes):
|
||||
return NtAlpcCreatePort.ctypes_function(PortHandle, ObjectAttributes, PortAttributes)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAlpcConnectPort(PortHandle, PortName, ObjectAttributes, PortAttributes, Flags, RequiredServerSid, ConnectionMessage, BufferLength, OutMessageAttributes, InMessageAttributes, Timeout):
|
||||
return NtAlpcConnectPort.ctypes_function(PortHandle, PortName, ObjectAttributes, PortAttributes, Flags, RequiredServerSid, ConnectionMessage, BufferLength, OutMessageAttributes, InMessageAttributes, Timeout)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAlpcConnectPortEx(PortHandle, ConnectionPortObjectAttributes, ClientPortObjectAttributes, PortAttributes, Flags, ServerSecurityRequirements, ConnectionMessage, BufferLength, OutMessageAttributes, InMessageAttributes, Timeout):
|
||||
return NtAlpcConnectPortEx.ctypes_function(PortHandle, ConnectionPortObjectAttributes, ClientPortObjectAttributes, PortAttributes, Flags, ServerSecurityRequirements, ConnectionMessage, BufferLength, OutMessageAttributes, InMessageAttributes, Timeout)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAlpcAcceptConnectPort(PortHandle, ConnectionPortHandle, Flags, ObjectAttributes, PortAttributes, PortContext, ConnectionRequest, ConnectionMessageAttributes, AcceptConnection):
|
||||
return NtAlpcAcceptConnectPort.ctypes_function(PortHandle, ConnectionPortHandle, Flags, ObjectAttributes, PortAttributes, PortContext, ConnectionRequest, ConnectionMessageAttributes, AcceptConnection)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAlpcQueryInformation(PortHandle, PortInformationClass, PortInformation, Length, ReturnLength):
|
||||
return NtAlpcQueryInformation.ctypes_function(PortHandle, PortInformationClass, PortInformation, Length, ReturnLength)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAlpcDisconnectPort(PortHandle, Flags):
|
||||
return NtAlpcDisconnectPort.ctypes_function(PortHandle, Flags)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAlpcSendWaitReceivePort(PortHandle, Flags, SendMessage, SendMessageAttributes, ReceiveMessage, BufferLength, ReceiveMessageAttributes, Timeout):
|
||||
return NtAlpcSendWaitReceivePort.ctypes_function(PortHandle, Flags, SendMessage, SendMessageAttributes, ReceiveMessage, BufferLength, ReceiveMessageAttributes, Timeout)
|
||||
|
||||
@NtdllProxy()
|
||||
def AlpcInitializeMessageAttribute(AttributeFlags, Buffer, BufferSize, RequiredBufferSize):
|
||||
return AlpcInitializeMessageAttribute.ctypes_function(AttributeFlags, Buffer, BufferSize, RequiredBufferSize)
|
||||
|
||||
@NtdllProxy()
|
||||
def AlpcGetMessageAttribute(Buffer, AttributeFlag):
|
||||
return AlpcGetMessageAttribute.ctypes_function(Buffer, AttributeFlag)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAlpcCreatePortSection(PortHandle, Flags, SectionHandle, SectionSize, AlpcSectionHandle, ActualSectionSize):
|
||||
return NtAlpcCreatePortSection.ctypes_function(PortHandle, Flags, SectionHandle, SectionSize, AlpcSectionHandle, ActualSectionSize)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAlpcDeletePortSection(PortHandle, Flags, SectionHandle):
|
||||
return NtAlpcDeletePortSection.ctypes_function(PortHandle, Flags, SectionHandle)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAlpcCreateSectionView(PortHandle, Flags, ViewAttributes):
|
||||
return NtAlpcCreateSectionView.ctypes_function(PortHandle, Flags, ViewAttributes)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAlpcDeleteSectionView(PortHandle, Flags, ViewBase):
|
||||
return NtAlpcDeleteSectionView.ctypes_function(PortHandle, Flags, ViewBase)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAlpcQueryInformationMessage(PortHandle, PortMessage, MessageInformationClass, MessageInformation, Length, ReturnLength):
|
||||
return NtAlpcQueryInformationMessage.ctypes_function(PortHandle, PortMessage, MessageInformationClass, MessageInformation, Length, ReturnLength)
|
||||
|
||||
@NtdllProxy()
|
||||
def TpCallbackSendAlpcMessageOnCompletion(TpHandle, PortHandle, Flags, SendMessage):
|
||||
return TpCallbackSendAlpcMessageOnCompletion.ctypes_function(TpHandle, PortHandle, Flags, SendMessage)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtAlpcImpersonateClientOfPort(PortHandle, Message, Flags):
|
||||
return NtAlpcImpersonateClientOfPort.ctypes_function(PortHandle, Message, Flags)
|
||||
|
||||
|
||||
# Compression
|
||||
|
||||
@NtdllProxy()
|
||||
def RtlDecompressBuffer(CompressionFormat, UncompressedBuffer, UncompressedBufferSize, CompressedBuffer, CompressedBufferSize=None, FinalUncompressedSize=NeededParameter):
|
||||
if CompressedBufferSize is None:
|
||||
CompressedBufferSize = len(CompressedBuffer)
|
||||
return RtlDecompressBuffer.ctypes_function(CompressionFormat, UncompressedBuffer, UncompressedBufferSize, CompressedBuffer, CompressedBufferSize, FinalUncompressedSize)
|
||||
|
||||
@NtdllProxy()
|
||||
def RtlDecompressBufferEx(CompressionFormat, UncompressedBuffer, UncompressedBufferSize, CompressedBuffer, CompressedBufferSize=None, FinalUncompressedSize=NeededParameter, WorkSpace=NeededParameter):
|
||||
if CompressedBufferSize is None:
|
||||
CompressedBufferSize = len(CompressedBuffer)
|
||||
# TODO: automatic 'WorkSpace' size calc + allocation ?
|
||||
return RtlDecompressBufferEx.ctypes_function(CompressionFormat, UncompressedBuffer, UncompressedBufferSize, CompressedBuffer, CompressedBufferSize, FinalUncompressedSize, WorkSpace)
|
||||
|
||||
@NtdllProxy()
|
||||
def RtlGetCompressionWorkSpaceSize(CompressionFormatAndEngine, CompressBufferWorkSpaceSize, CompressFragmentWorkSpaceSize):
|
||||
return RtlGetCompressionWorkSpaceSize.ctypes_function(CompressionFormatAndEngine, CompressBufferWorkSpaceSize, CompressFragmentWorkSpaceSize)
|
||||
|
||||
@NtdllProxy()
|
||||
def RtlCompressBuffer(CompressionFormatAndEngine, UncompressedBuffer, UncompressedBufferSize, CompressedBuffer, CompressedBufferSize, UncompressedChunkSize=4096, FinalCompressedSize=NeededParameter, WorkSpace=NeededParameter):
|
||||
return RtlCompressBuffer.ctypes_function(CompressionFormatAndEngine, UncompressedBuffer, UncompressedBufferSize, CompressedBuffer, CompressedBufferSize, UncompressedChunkSize, FinalCompressedSize, WorkSpace)
|
||||
|
||||
|
||||
# Section
|
||||
|
||||
@NtdllProxy()
|
||||
def NtCreateSection(SectionHandle, DesiredAccess, ObjectAttributes, MaximumSize, SectionPageProtection, AllocationAttributes, FileHandle):
|
||||
return NtCreateSection.ctypes_function(SectionHandle, DesiredAccess, ObjectAttributes, MaximumSize, SectionPageProtection, AllocationAttributes, FileHandle)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtOpenSection(SectionHandle, DesiredAccess, ObjectAttributes):
|
||||
return NtOpenSection.ctypes_function(SectionHandle, DesiredAccess, ObjectAttributes)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtMapViewOfSection(SectionHandle, ProcessHandle, BaseAddress, ZeroBits, CommitSize, SectionOffset, ViewSize, InheritDisposition, AllocationType, Win32Protect):
|
||||
return NtMapViewOfSection.ctypes_function(SectionHandle, ProcessHandle, BaseAddress, ZeroBits, CommitSize, SectionOffset, ViewSize, InheritDisposition, AllocationType, Win32Protect)
|
||||
|
||||
|
||||
@NtdllProxy()
|
||||
def NtUnmapViewOfSection(ProcessHandle, BaseAddress):
|
||||
return NtUnmapViewOfSection.ctypes_function(ProcessHandle, BaseAddress)
|
||||
|
||||
# Registry
|
||||
|
||||
@NtdllProxy()
|
||||
def NtOpenKey(KeyHandle, DesiredAccess, ObjectAttributes):
|
||||
return NtOpenKey.ctypes_function(KeyHandle, DesiredAccess, ObjectAttributes)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtCreateKey(pKeyHandle, DesiredAccess, ObjectAttributes, TitleIndex, Class, CreateOptions, Disposition):
|
||||
return NtCreateKey.ctypes_function(pKeyHandle, DesiredAccess, ObjectAttributes, TitleIndex, Class, CreateOptions, Disposition)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtSetValueKey(KeyHandle, ValueName, TitleIndex, Type, Data, DataSize):
|
||||
return NtSetValueKey.ctypes_function(KeyHandle, ValueName, TitleIndex, Type, Data, DataSize)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtQueryValueKey(KeyHandle, ValueName, KeyValueInformationClass, KeyValueInformation, Length, ResultLength):
|
||||
return NtQueryValueKey.ctypes_function(KeyHandle, ValueName, KeyValueInformationClass, KeyValueInformation, Length, ResultLength)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtEnumerateValueKey(KeyHandle, Index, KeyValueInformationClass, KeyValueInformation, Length, ResultLength):
|
||||
return NtEnumerateValueKey.ctypes_function(KeyHandle, Index, KeyValueInformationClass, KeyValueInformation, Length, ResultLength)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtDeleteValueKey(KeyHandle, ValueName):
|
||||
return NtDeleteValueKey.ctypes_function(KeyHandle, ValueName)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtQueryLicenseValue(Name, Type, Buffer, Length=None, DataLength=NeededParameter):
|
||||
if Length is None and Buffer:
|
||||
Length = len(buffer)
|
||||
return NtQueryLicenseValue.ctypes_function(Name, Type, Buffer, Length, DataLength)
|
||||
|
||||
@NtdllProxy()
|
||||
def NtQueryKey(KeyHandle, KeyInformationClass, KeyInformation, Length, ResultLength):
|
||||
return NtQueryKey.ctypes_function(KeyHandle, KeyInformationClass, KeyInformation, Length, ResultLength)
|
||||
|
||||
# Other
|
||||
|
||||
@NtdllProxy()
|
||||
def RtlEqualUnicodeString(String1, String2, CaseInSensitive):
|
||||
return RtlEqualUnicodeString.ctypes_function(String1, String2, CaseInSensitive)
|
||||
|
||||
@NtdllProxy(error_check=None)
|
||||
def RtlMoveMemory(Destination, Source, Length):
|
||||
return RtlMoveMemory.ctypes_function(Destination, Source, Length)
|
||||
|
||||
|
||||
# Firmware
|
||||
@NtdllProxy()
|
||||
def NtEnumerateSystemEnvironmentValuesEx(InformationClass, Buffer, BufferLength):
|
||||
return NtEnumerateSystemEnvironmentValuesEx.ctypes_function(InformationClass, Buffer, BufferLength)
|
||||
|
||||
|
||||
# Pipe
|
||||
@NtdllProxy()
|
||||
def NtCreateNamedPipeFile(NamedPipeFileHandle, DesiredAccess, ObjectAttributes, IoStatusBlock, ShareAccess, CreateDisposition, CreateOptions, WriteModeMessage, ReadModeMessage, NonBlocking, MaxInstances, InBufferSize, OutBufferSize, DefaultTimeOut):
|
||||
return NtCreateNamedPipeFile.ctypes_function(NamedPipeFileHandle, DesiredAccess, ObjectAttributes, IoStatusBlock, ShareAccess, CreateDisposition, CreateOptions, WriteModeMessage, ReadModeMessage, NonBlocking, MaxInstances, InBufferSize, OutBufferSize, DefaultTimeOut)
|
||||
|
||||
|
||||
#########
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import no_error_check
|
||||
|
||||
# IMPORTANT:
|
||||
# Functions that returns HRESULT (like CoInitializeEx) will raise if HRESULT is an error
|
||||
# even if there is no error check on the return value
|
||||
|
||||
class Ole32Proxy(ApiProxy):
|
||||
APIDLL = "ole32"
|
||||
default_error_check = staticmethod(no_error_check)
|
||||
|
||||
|
||||
@Ole32Proxy()
|
||||
def CoInitializeEx(pvReserved=None, dwCoInit=gdef.COINIT_MULTITHREADED):
|
||||
return CoInitializeEx.ctypes_function(pvReserved, dwCoInit)
|
||||
|
||||
|
||||
@Ole32Proxy()
|
||||
def CoInitializeSecurity(pSecDesc, cAuthSvc, asAuthSvc, pReserved1, dwAuthnLevel, dwImpLevel, pAuthList, dwCapabilities, pReserved3):
|
||||
return CoInitializeSecurity.ctypes_function(pSecDesc, cAuthSvc, asAuthSvc, pReserved1, dwAuthnLevel, dwImpLevel, pAuthList, dwCapabilities, pReserved3)
|
||||
|
||||
|
||||
@Ole32Proxy()
|
||||
def CoCreateInstance(rclsid, pUnkOuter=None, dwClsContext=gdef.CLSCTX_INPROC_SERVER, riid=NeededParameter, ppv=NeededParameter):
|
||||
return CoCreateInstance.ctypes_function(rclsid, pUnkOuter, dwClsContext, riid, ppv)
|
||||
|
||||
@Ole32Proxy()
|
||||
def CoCreateInstanceEx(rclsid, punkOuter, dwClsCtx, pServerInfo, dwCount, pResults):
|
||||
return CoCreateInstanceEx.ctypes_function(rclsid, punkOuter, dwClsCtx, pServerInfo, dwCount, pResults)
|
||||
|
||||
|
||||
@Ole32Proxy()
|
||||
def CoGetClassObject(rclsid, dwClsContext, pvReserved, riid, ppv):
|
||||
return CoGetClassObject.ctypes_function(rclsid, dwClsContext, pvReserved, riid, ppv)
|
||||
|
||||
@Ole32Proxy()
|
||||
def CoGetInterceptor(iidIntercepted, punkOuter, iid, ppv):
|
||||
return CoGetInterceptor.ctypes_function(iidIntercepted, punkOuter, iid, ppv)
|
||||
|
||||
@Ole32Proxy()
|
||||
def CLSIDFromProgID(lpszProgID, lpclsid):
|
||||
return CLSIDFromProgID.ctypes_function(lpszProgID, lpclsid)
|
||||
|
||||
@Ole32Proxy()
|
||||
def CoTaskMemFree(pv):
|
||||
return CoTaskMemFree.ctypes_function(pv)
|
||||
@@ -0,0 +1,13 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter, is_implemented
|
||||
from ..error import succeed_on_zero
|
||||
|
||||
class OleaccProxy(ApiProxy):
|
||||
APIDLL = "Oleacc"
|
||||
default_error_check = staticmethod(succeed_on_zero)
|
||||
|
||||
@OleaccProxy()
|
||||
def ObjectFromLresult(lResult, riid, wParam, ppvObject):
|
||||
return ObjectFromLresult.ctypes_function(lResult, riid, wParam, ppvObject)
|
||||
@@ -0,0 +1,43 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import no_error_check, fail_on_zero, succeed_on_zero
|
||||
|
||||
# IMPORTANT:
|
||||
# Functions that returns HRESULT (like CoInitializeEx) will raise if HRESULT is an error
|
||||
# even if there is no error check on the return value
|
||||
|
||||
class Ole32Proxy(ApiProxy):
|
||||
APIDLL = "oleaut32"
|
||||
default_error_check = staticmethod(no_error_check)
|
||||
|
||||
|
||||
@Ole32Proxy()
|
||||
def SysAllocString(psz):
|
||||
return SysAllocString.ctypes_function(psz)
|
||||
|
||||
|
||||
@Ole32Proxy()
|
||||
def SysFreeString(bstrString):
|
||||
return SysFreeString.ctypes_function(bstrString)
|
||||
|
||||
@Ole32Proxy(error_check=fail_on_zero)
|
||||
def SafeArrayCreate(vt, cDims, rgsabound):
|
||||
return SafeArrayCreate.ctypes_function(vt, cDims, rgsabound)
|
||||
|
||||
|
||||
@Ole32Proxy(error_check=succeed_on_zero)
|
||||
def SafeArrayDestroy(psa):
|
||||
return SafeArrayDestroy.ctypes_function(psa)
|
||||
|
||||
|
||||
@Ole32Proxy(error_check=succeed_on_zero)
|
||||
def SafeArrayPutElement(psa, rgIndices, pv):
|
||||
return SafeArrayPutElement.ctypes_function(psa, rgIndices, pv)
|
||||
|
||||
|
||||
@Ole32Proxy(error_check=succeed_on_zero)
|
||||
def SafeArrayGetElement(psa, rgIndices, pv):
|
||||
return SafeArrayGetElement.ctypes_function(psa, rgIndices, pv)
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import fail_on_zero
|
||||
|
||||
class PsapiProxy(ApiProxy):
|
||||
APIDLL = "psapi"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
|
||||
@PsapiProxy()
|
||||
def GetMappedFileNameW(hProcess, lpv, lpFilename, nSize=None):
|
||||
if nSize is None:
|
||||
nSize = ctypes.sizeof(lpFilename)
|
||||
return GetMappedFileNameW.ctypes_function(hProcess, lpv, lpFilename, nSize)
|
||||
|
||||
@PsapiProxy()
|
||||
def GetMappedFileNameA(hProcess, lpv, lpFilename, nSize=None):
|
||||
if nSize is None:
|
||||
nSize = ctypes.sizeof(lpFilename)
|
||||
return GetMappedFileNameA.ctypes_function(hProcess, lpv, lpFilename, nSize)
|
||||
|
||||
@PsapiProxy()
|
||||
def QueryWorkingSet(hProcess, pv, cb):
|
||||
return QueryWorkingSet.ctypes_function(hProcess, pv, cb)
|
||||
|
||||
@PsapiProxy()
|
||||
def QueryWorkingSetEx(hProcess, pv, cb):
|
||||
return QueryWorkingSetEx.ctypes_function(hProcess, pv, cb)
|
||||
|
||||
@PsapiProxy()
|
||||
def GetModuleBaseNameA(hProcess, hModule, lpBaseName, nSize=None):
|
||||
if nSize is None:
|
||||
nSize = len(lpBaseName)
|
||||
return GetModuleBaseNameA.ctypes_function(hProcess, hModule, lpBaseName, nSize)
|
||||
|
||||
@PsapiProxy()
|
||||
def GetModuleBaseNameW(hProcess, hModule, lpBaseName, nSize=None):
|
||||
if nSize is None:
|
||||
nSize = len(lpBaseName)
|
||||
return GetModuleBaseNameW.ctypes_function(hProcess, hModule, lpBaseName, nSize)
|
||||
|
||||
@PsapiProxy()
|
||||
def GetProcessImageFileNameA(hProcess, lpImageFileName, nSize=None):
|
||||
if nSize is None:
|
||||
nSize = len(lpImageFileName)
|
||||
return GetProcessImageFileNameA.ctypes_function(hProcess, lpImageFileName, nSize)
|
||||
|
||||
@PsapiProxy()
|
||||
def GetProcessImageFileNameW(hProcess, lpImageFileName, nSize=None):
|
||||
if nSize is None:
|
||||
nSize = len(lpImageFileName)
|
||||
return GetProcessImageFileNameW.ctypes_function(hProcess, lpImageFileName, nSize)
|
||||
|
||||
@PsapiProxy()
|
||||
def GetProcessMemoryInfo(Process, ppsmemCounters, cb):
|
||||
return GetProcessMemoryInfo.ctypes_function(Process, ppsmemCounters, cb)
|
||||
@@ -0,0 +1,78 @@
|
||||
import ctypes
|
||||
from ctypes import wintypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter, is_implemented
|
||||
from ..error import succeed_on_zero, fail_on_zero, result_is_handle, no_error_check
|
||||
|
||||
|
||||
MAX_CLASS_NAME_LEN = 32
|
||||
MAX_DEV_LEN = 1000
|
||||
|
||||
|
||||
class SetupApiProxy(ApiProxy):
|
||||
APIDLL = "SetupApi"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
|
||||
@SetupApiProxy()
|
||||
def SetupDiClassNameFromGuidA(ClassGuid, ClassName, ClassNameSize=None, RequiredSize=None):
|
||||
"""
|
||||
Given a class Guid, return the name associated or raise an Exception
|
||||
"""
|
||||
if ClassNameSize is None:
|
||||
ClassNameSize = ctypes.sizeof(ClassName)
|
||||
return SetupDiClassNameFromGuidA.ctypes_function(ClassGuid, ClassName, ClassNameSize, RequiredSize)
|
||||
|
||||
|
||||
@SetupApiProxy()
|
||||
def SetupDiClassNameFromGuidW(Guid):
|
||||
|
||||
"""
|
||||
Given a class Guid, return the name associated or raise an Exception
|
||||
"""
|
||||
if ClassNameSize is None:
|
||||
ClassNameSize = ctypes.sizeof(ClassName)
|
||||
return SetupDiClassNameFromGuidW.ctypes_function(ClassGuid, ClassName, ClassNameSize, RequiredSize)
|
||||
|
||||
|
||||
@SetupApiProxy(error_check=result_is_handle)
|
||||
def SetupDiGetClassDevsA(Guid, Enumerator=None, hwndParent=None, Flags=0):
|
||||
"""
|
||||
Given a class GUID, return a HANDLE to the device's information set or raise an Exception
|
||||
"""
|
||||
return SetupDiGetClassDevsA.ctypes_function(Guid, Enumerator, hwndParent, Flags)
|
||||
|
||||
@SetupApiProxy(error_check=result_is_handle)
|
||||
def SetupDiGetClassDevsW(Guid, Enumerator=None, hwndParent=None, Flags=0):
|
||||
"""
|
||||
Given a class GUID, return a HANDLE to the device's information set or raise an Exception
|
||||
"""
|
||||
return SetupDiGetClassDevsW.ctypes_function(Guid, Enumerator, hwndParent, Flags)
|
||||
|
||||
@SetupApiProxy()
|
||||
def SetupDiEnumDeviceInfo(DeviceInfoSet, MemberIndex, DeviceInfoData):
|
||||
"""
|
||||
Given a device information set, return the info associated with the index
|
||||
or raise ERROR_NO_MORE_ITEMS if there is none anymore.
|
||||
"""
|
||||
return SetupDiEnumDeviceInfo.ctypes_function(DeviceInfoSet, MemberIndex, DeviceInfoData)
|
||||
|
||||
@SetupApiProxy()
|
||||
def SetupDiEnumDeviceInterfaces(DeviceInfoSet, DeviceInfoData, InterfaceClassGuid, MemberIndex, DeviceInterfaceData):
|
||||
return SetupDiEnumDeviceInterfaces.ctypes_function(DeviceInfoSet, DeviceInfoData, InterfaceClassGuid, MemberIndex, DeviceInterfaceData)
|
||||
|
||||
@SetupApiProxy()
|
||||
def SetupDiGetDeviceRegistryPropertyA(DeviceInfoSet, DeviceInfoData, Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize, RequiredSize):
|
||||
return SetupDiGetDeviceRegistryPropertyA.ctypes_function(DeviceInfoSet, DeviceInfoData, Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize, RequiredSize)
|
||||
|
||||
@SetupApiProxy()
|
||||
def SetupDiGetDeviceRegistryPropertyW(DeviceInfoSet, DeviceInfoData, Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize, RequiredSize):
|
||||
return SetupDiGetDeviceRegistryPropertyW.ctypes_function(DeviceInfoSet, DeviceInfoData, Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize, RequiredSize)
|
||||
|
||||
|
||||
|
||||
|
||||
@SetupApiProxy()
|
||||
def SetupDiDestroyDeviceInfoList(hDevInfo):
|
||||
return SetupDiDestroyDeviceInfoList.ctypes_function(hDevInfo)
|
||||
@@ -0,0 +1,29 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import fail_on_zero, succeed_on_zero
|
||||
|
||||
class Shell32Proxy(ApiProxy):
|
||||
APIDLL = "shell32"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
@Shell32Proxy()
|
||||
def ShellExecuteA(hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd):
|
||||
return ShellExecuteA.ctypes_function(hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd)
|
||||
|
||||
@Shell32Proxy()
|
||||
def ShellExecuteW(hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd):
|
||||
return ShellExecuteW.ctypes_function(hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd)
|
||||
|
||||
@Shell32Proxy()
|
||||
def SHGetPathFromIDListA(pidl, pszPath):
|
||||
return SHGetPathFromIDListA.ctypes_function(pidl, pszPath)
|
||||
|
||||
@Shell32Proxy()
|
||||
def SHGetPathFromIDListW(pidl, pszPath):
|
||||
return SHGetPathFromIDListW.ctypes_function(pidl, pszPath)
|
||||
|
||||
@Shell32Proxy(error_check=succeed_on_zero)
|
||||
def SHFileOperationA(lpFileOp):
|
||||
return SHFileOperationA.ctypes_function(lpFileOp)
|
||||
@@ -0,0 +1,27 @@
|
||||
import ctypes
|
||||
import windows
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter, is_implemented
|
||||
from ..error import fail_on_zero
|
||||
|
||||
class ShlwapiProxy(ApiProxy):
|
||||
APIDLL = "Shlwapi"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
@ShlwapiProxy()
|
||||
def StrStrIW(pszFirst, pszSrch):
|
||||
return StrStrIW.ctypes_function(pszFirst, pszSrch)
|
||||
|
||||
@ShlwapiProxy()
|
||||
def StrStrIA(pszFirst, pszSrch):
|
||||
return StrStrIA.ctypes_function(pszFirst, pszSrch)
|
||||
|
||||
@ShlwapiProxy()
|
||||
def IsOS(dwOS):
|
||||
if not is_implemented(IsOS) and windows.system.version[0] < 6:
|
||||
# Before Vista:
|
||||
# If so use ordinal 437 from DOCUMENTATION
|
||||
# https://docs.microsoft.com/en-us/windows/desktop/api/shlwapi/nf-shlwapi-isos#remarks
|
||||
IsOS.proxy.func_name = 437
|
||||
return IsOS.ctypes_function(dwOS)
|
||||
@@ -0,0 +1,16 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import result_is_error_code
|
||||
|
||||
# TDH: Trace Data Helper
|
||||
# https://docs.microsoft.com/en-us/windows/desktop/etw/retrieving-event-data-using-tdh
|
||||
|
||||
class TdhProxy(ApiProxy):
|
||||
APIDLL = "tdh"
|
||||
default_error_check = staticmethod(result_is_error_code)
|
||||
|
||||
@TdhProxy()
|
||||
def TdhEnumerateProviders(pBuffer, pBufferSize):
|
||||
return TdhEnumerateProviders.ctypes_function(pBuffer, pBufferSize)
|
||||
@@ -0,0 +1,119 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import fail_on_zero, no_error_check
|
||||
|
||||
class User32Proxy(ApiProxy):
|
||||
APIDLL = "user32"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
|
||||
# Window
|
||||
|
||||
@User32Proxy()
|
||||
def EnumWindows(lpEnumFunc, lParam):
|
||||
return EnumWindows.ctypes_function(lpEnumFunc, lParam)
|
||||
|
||||
@User32Proxy()
|
||||
def GetParent(hWnd):
|
||||
return GetParent.ctypes_function(hWnd)
|
||||
|
||||
@User32Proxy(error_check=no_error_check)
|
||||
def GetWindowTextA(hWnd, lpString, nMaxCount):
|
||||
return GetWindowTextA.ctypes_function(hWnd, lpString, nMaxCount)
|
||||
|
||||
@User32Proxy()
|
||||
def GetWindowTextW(hWnd, lpString, nMaxCount):
|
||||
return GetWindowTextW.ctypes_function(hWnd, lpString, nMaxCount)
|
||||
|
||||
@User32Proxy()
|
||||
def FindWindowA(lpClassName, lpWindowName):
|
||||
return FindWindowA.ctypes_function(lpClassName, lpWindowName)
|
||||
|
||||
@User32Proxy()
|
||||
def FindWindowW(lpClassName, lpWindowName):
|
||||
return FindWindowW.ctypes_function(lpClassName, lpWindowName)
|
||||
|
||||
@User32Proxy()
|
||||
def GetWindowModuleFileNameA(hwnd, pszFileName, cchFileNameMax):
|
||||
return GetWindowModuleFileNameA.ctypes_function(hwnd, pszFileName, cchFileNameMax)
|
||||
|
||||
@User32Proxy()
|
||||
def GetWindowModuleFileNameW(hwnd, pszFileName, cchFileNameMax):
|
||||
return GetWindowModuleFileNameW.ctypes_function(hwnd, pszFileName, cchFileNameMax)
|
||||
|
||||
@User32Proxy()
|
||||
def EnumChildWindows(hWndParent, lpEnumFunc, lParam):
|
||||
return EnumChildWindows.ctypes_function(hWndParent, lpEnumFunc, lParam)
|
||||
|
||||
@User32Proxy()
|
||||
def GetClassInfoExA(hinst, lpszClass, lpwcx):
|
||||
return GetClassInfoExA.ctypes_function(hinst, lpszClass, lpwcx)
|
||||
|
||||
@User32Proxy()
|
||||
def GetClassInfoExW(hinst, lpszClass, lpwcx):
|
||||
return GetClassInfoExW.ctypes_function(hinst, lpszClass, lpwcx)
|
||||
|
||||
@User32Proxy()
|
||||
def GetWindowThreadProcessId(hWnd, lpdwProcessId):
|
||||
return GetWindowThreadProcessId.ctypes_function(hWnd, lpdwProcessId)
|
||||
|
||||
@User32Proxy()
|
||||
def WindowFromPoint(Point):
|
||||
return WindowFromPoint.ctypes_function(Point)
|
||||
|
||||
@User32Proxy()
|
||||
def GetWindowRect(hWnd, lpRect):
|
||||
return GetWindowRect.ctypes_function(hWnd, lpRect)
|
||||
|
||||
@User32Proxy("RealGetWindowClassA")
|
||||
def RealGetWindowClassA(hwnd, pszType, cchType=None):
|
||||
if cchType is None:
|
||||
cchType = len(pszType)
|
||||
return RealGetWindowClassA.ctypes_function(hwnd, pszType, cchType)
|
||||
|
||||
@User32Proxy("RealGetWindowClassW")
|
||||
def RealGetWindowClassW(hwnd, pszType, cchType=None):
|
||||
if cchType is None:
|
||||
cchType = len(pszType)
|
||||
return RealGetWindowClassW.ctypes_function(hwnd, pszType, cchType)
|
||||
|
||||
@User32Proxy("GetClassNameA")
|
||||
def GetClassNameA (hwnd, pszType, cchType=None):
|
||||
if cchType is None:
|
||||
cchType = len(pszType)
|
||||
return GetClassNameA .ctypes_function(hwnd, pszType, cchType)
|
||||
|
||||
@User32Proxy("GetClassNameW")
|
||||
def GetClassNameW (hwnd, pszType, cchType=None):
|
||||
if cchType is None:
|
||||
cchType = len(pszType)
|
||||
return GetClassNameW .ctypes_function(hwnd, pszType, cchType)
|
||||
|
||||
## Windows Message
|
||||
|
||||
@User32Proxy()
|
||||
def MessageBoxA(hWnd=0, lpText=NeededParameter, lpCaption=None, uType=0):
|
||||
return MessageBoxA.ctypes_function(hWnd, lpText, lpCaption, uType)
|
||||
|
||||
@User32Proxy()
|
||||
def MessageBoxW(hWnd=0, lpText=NeededParameter, lpCaption=None, uType=0):
|
||||
return MessageBoxW.ctypes_function(hWnd, lpText, lpCaption, uType)
|
||||
|
||||
# Cursor
|
||||
|
||||
@User32Proxy()
|
||||
def GetCursorPos(lpPoint):
|
||||
return GetCursorPos.ctypes_function(lpPoint)
|
||||
|
||||
# System
|
||||
|
||||
|
||||
# If the function succeeds, the return value is the requested system metric or configuration setting.
|
||||
# If the function fails, the return value is 0. GetLastError does not provide extended error information.
|
||||
# And 0 is also a valid return value.. Thanks a lot..
|
||||
|
||||
@User32Proxy(error_check=no_error_check)
|
||||
def GetSystemMetrics(nIndex):
|
||||
return GetSystemMetrics.ctypes_function(nIndex)
|
||||
@@ -0,0 +1,67 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import fail_on_zero
|
||||
|
||||
class VersionProxy(ApiProxy):
|
||||
APIDLL = "version"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
|
||||
@VersionProxy()
|
||||
def GetFileVersionInfoA(lptstrFilename, dwHandle=0, dwLen=None, lpData=NeededParameter):
|
||||
if dwLen is None and lpData is not None:
|
||||
dwLen = len(lpData)
|
||||
return GetFileVersionInfoA.ctypes_function(lptstrFilename, dwHandle, dwLen, lpData)
|
||||
|
||||
|
||||
@VersionProxy()
|
||||
def GetFileVersionInfoW(lptstrFilename, dwHandle=0, dwLen=None, lpData=NeededParameter):
|
||||
if dwLen is None and lpData is not None:
|
||||
dwLen = len(lpData)
|
||||
return GetFileVersionInfoW.ctypes_function(lptstrFilename, dwHandle, dwLen, lpData)
|
||||
|
||||
|
||||
@VersionProxy()
|
||||
def GetFileVersionInfoExA(dwFlags, lpwstrFilename, dwHandle, dwLen, lpData):
|
||||
return GetFileVersionInfoExA.ctypes_function(dwFlags, lpwstrFilename, dwHandle, dwLen, lpData)
|
||||
|
||||
|
||||
@VersionProxy()
|
||||
def GetFileVersionInfoExW(dwFlags, lpwstrFilename, dwHandle, dwLen, lpData):
|
||||
return GetFileVersionInfoExW.ctypes_function(dwFlags, lpwstrFilename, dwHandle, dwLen, lpData)
|
||||
|
||||
|
||||
@VersionProxy()
|
||||
def GetFileVersionInfoSizeA(lptstrFilename, lpdwHandle=None):
|
||||
if lpdwHandle is None:
|
||||
lpdwHandle = ctypes.byref(gdef.DWORD())
|
||||
return GetFileVersionInfoSizeA.ctypes_function(lptstrFilename, lpdwHandle)
|
||||
|
||||
|
||||
@VersionProxy()
|
||||
def GetFileVersionInfoSizeW(lptstrFilename, lpdwHandle=None):
|
||||
if lpdwHandle is None:
|
||||
lpdwHandle = ctypes.byref(gdef.DWORD())
|
||||
return GetFileVersionInfoSizeW.ctypes_function(lptstrFilename, lpdwHandle)
|
||||
|
||||
|
||||
@VersionProxy()
|
||||
def GetFileVersionInfoSizeExA(dwFlags, lpwstrFilename, lpdwHandle=None):
|
||||
return GetFileVersionInfoSizeExA.ctypes_function(dwFlags, lpwstrFilename, lpdwHandle)
|
||||
|
||||
|
||||
@VersionProxy()
|
||||
def GetFileVersionInfoSizeExW(dwFlags, lpwstrFilename, lpdwHandle=None):
|
||||
return GetFileVersionInfoSizeExW.ctypes_function(dwFlags, lpwstrFilename, lpdwHandle)
|
||||
|
||||
|
||||
@VersionProxy()
|
||||
def VerQueryValueA(pBlock, lpSubBlock, lplpBuffer, puLen):
|
||||
return VerQueryValueA.ctypes_function(pBlock, lpSubBlock, lplpBuffer, puLen)
|
||||
|
||||
|
||||
@VersionProxy()
|
||||
def VerQueryValueW(pBlock, lpSubBlock, lplpBuffer, puLen):
|
||||
return VerQueryValueW.ctypes_function(pBlock, lpSubBlock, lplpBuffer, puLen)
|
||||
@@ -0,0 +1,18 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import no_error_check, result_is_error_code
|
||||
|
||||
class VirtDiskProxy(ApiProxy):
|
||||
APIDLL = "virtdisk"
|
||||
default_error_check = staticmethod(result_is_error_code)
|
||||
|
||||
|
||||
@VirtDiskProxy()
|
||||
def OpenVirtualDisk(VirtualStorageType, Path, VirtualDiskAccessMask, Flags, Parameters, Handle):
|
||||
return OpenVirtualDisk.ctypes_function(VirtualStorageType, Path, VirtualDiskAccessMask, Flags, Parameters, Handle)
|
||||
|
||||
@VirtDiskProxy()
|
||||
def AttachVirtualDisk(VirtualDiskHandle, SecurityDescriptor, Flags, ProviderSpecificFlags, Parameters, Overlapped):
|
||||
return AttachVirtualDisk.ctypes_function(VirtualDiskHandle, SecurityDescriptor, Flags, ProviderSpecificFlags, Parameters, Overlapped)
|
||||
@@ -0,0 +1,131 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import fail_on_zero
|
||||
|
||||
class WevtapiProxy(ApiProxy):
|
||||
APIDLL = "Wevtapi"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
|
||||
# Session
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtOpenSession(LoginClass, Login, Timeout=0, Flags=0):
|
||||
return EvtOpenSession.ctypes_function(LoginClass, Login, Timeout, Flags)
|
||||
|
||||
# Event
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtOpenLog(Session, Path, Flags):
|
||||
return EvtOpenLog.ctypes_function(Session, Path, Flags)
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtClose(Object):
|
||||
return EvtClose.ctypes_function(Object)
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtQuery(Session, Path, Query, Flags):
|
||||
return EvtQuery.ctypes_function(Session, Path, Query, Flags)
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtNext(ResultSet, EventArraySize, EventArray, Timeout, Flags, Returned):
|
||||
return EvtNext.ctypes_function(ResultSet, EventArraySize, EventArray, Timeout, Flags, Returned)
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtSeek(ResultSet, Position, Bookmark, Timeout, Flags):
|
||||
return EvtSeek.ctypes_function(ResultSet, Position, Bookmark, Timeout, Flags)
|
||||
|
||||
|
||||
# Channel
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtOpenChannelEnum(Session, Flags):
|
||||
return EvtOpenChannelEnum.ctypes_function(Session, Flags)
|
||||
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtNextChannelPath(ChannelEnum, ChannelPathBufferSize, ChannelPathBuffer, ChannelPathBufferUsed):
|
||||
return EvtNextChannelPath.ctypes_function(ChannelEnum, ChannelPathBufferSize, ChannelPathBuffer, ChannelPathBufferUsed)
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtOpenChannelConfig(Session, ChannelPath, Flags):
|
||||
return EvtOpenChannelConfig.ctypes_function(Session, ChannelPath, Flags)
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtGetChannelConfigProperty(ChannelConfig, PropertyId, Flags, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed):
|
||||
return EvtGetChannelConfigProperty.ctypes_function(ChannelConfig, PropertyId, Flags, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed)
|
||||
|
||||
# Publisher
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtOpenPublisherEnum(Session, Flags):
|
||||
return EvtOpenPublisherEnum.ctypes_function(Session, Flags)
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtNextPublisherId(PublisherEnum, PublisherIdBufferSize, PublisherIdBuffer, PublisherIdBufferUsed):
|
||||
return EvtNextPublisherId.ctypes_function(PublisherEnum, PublisherIdBufferSize, PublisherIdBuffer, PublisherIdBufferUsed)
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtOpenPublisherMetadata(Session, PublisherIdentity, LogFilePath, Locale, Flags):
|
||||
return EvtOpenPublisherMetadata.ctypes_function(Session, PublisherIdentity, LogFilePath, Locale, Flags)
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtGetPublisherMetadataProperty(PublisherMetadata, PropertyId, Flags, PublisherMetadataPropertyBufferSize, PublisherMetadataPropertyBuffer, PublisherMetadataPropertyBufferUsed):
|
||||
return EvtGetPublisherMetadataProperty.ctypes_function(PublisherMetadata, PropertyId, Flags, PublisherMetadataPropertyBufferSize, PublisherMetadataPropertyBuffer, PublisherMetadataPropertyBufferUsed)
|
||||
|
||||
|
||||
# Evt metadata
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtOpenEventMetadataEnum(PublisherMetadata, Flags):
|
||||
return EvtOpenEventMetadataEnum.ctypes_function(PublisherMetadata, Flags)
|
||||
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtNextEventMetadata(EventMetadataEnum, Flags):
|
||||
return EvtNextEventMetadata.ctypes_function(EventMetadataEnum, Flags)
|
||||
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtGetEventMetadataProperty(EventMetadata, PropertyId, Flags, EventMetadataPropertyBufferSize, EventMetadataPropertyBuffer, EventMetadataPropertyBufferUsed):
|
||||
return EvtGetEventMetadataProperty.ctypes_function(EventMetadata, PropertyId, Flags, EventMetadataPropertyBufferSize, EventMetadataPropertyBuffer, EventMetadataPropertyBufferUsed)
|
||||
|
||||
# Render
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtCreateRenderContext(ValuePathsCount, ValuePaths, Flags):
|
||||
return EvtCreateRenderContext.ctypes_function(ValuePathsCount, ValuePaths, Flags)
|
||||
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtRender(Context, Fragment, Flags, BufferSize, Buffer, BufferUsed, PropertyCount):
|
||||
return EvtRender.ctypes_function(Context, Fragment, Flags, BufferSize, Buffer, BufferUsed, PropertyCount)
|
||||
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtFormatMessage(PublisherMetadata, Event, MessageId, ValueCount, Values, Flags, BufferSize, Buffer, BufferUsed):
|
||||
return EvtFormatMessage.ctypes_function(PublisherMetadata, Event, MessageId, ValueCount, Values, Flags, BufferSize, Buffer, BufferUsed)
|
||||
|
||||
# Other
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtGetLogInfo(Log, PropertyId, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed):
|
||||
return EvtGetLogInfo.ctypes_function(Log, PropertyId, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed)
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtGetObjectArraySize(ObjectArray, ObjectArraySize):
|
||||
return EvtGetObjectArraySize.ctypes_function(ObjectArray, ObjectArraySize)
|
||||
|
||||
|
||||
@WevtapiProxy()
|
||||
def EvtGetObjectArrayProperty(ObjectArray, PropertyId, ArrayIndex, Flags, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed):
|
||||
return EvtGetObjectArrayProperty.ctypes_function(ObjectArray, PropertyId, ArrayIndex, Flags, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed)
|
||||
|
||||
|
||||
####
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
|
||||
from ..error import (fail_on_zero)
|
||||
|
||||
|
||||
class WinHTTPProxy(ApiProxy):
|
||||
APIDLL = "winhttp"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
@WinHTTPProxy()
|
||||
def WinHttpOpen(pszAgentW, dwAccessType, pszProxyW, pszProxyBypassW, dwFlags):
|
||||
return WinHttpOpen.ctypes_function(pszAgentW, dwAccessType, pszProxyW, pszProxyBypassW, dwFlags)
|
||||
|
||||
@WinHTTPProxy()
|
||||
def WinHttpCloseHandle(hInternet):
|
||||
return WinHttpCloseHandle.ctypes_function(hInternet)
|
||||
|
||||
@WinHTTPProxy()
|
||||
def WinHttpConnect(hSession, pswzServerName, nServerPort, dwReserved):
|
||||
return WinHttpConnect.ctypes_function(hSession, pswzServerName, nServerPort, dwReserved)
|
||||
|
||||
@WinHTTPProxy()
|
||||
def WinHttpQueryDataAvailable(hRequest, lpdwNumberOfBytesAvailable):
|
||||
return WinHttpQueryDataAvailable.ctypes_function(hRequest, lpdwNumberOfBytesAvailable)
|
||||
|
||||
@WinHTTPProxy()
|
||||
def WinHttpReadData(hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead):
|
||||
return WinHttpReadData.ctypes_function(hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead)
|
||||
|
||||
@WinHTTPProxy()
|
||||
def WinHttpOpenRequest(hConnect, pwszVerb, pwszObjectName, pwszVersion, pwszReferrer, ppwszAcceptTypes, dwFlags):
|
||||
return WinHttpOpenRequest.ctypes_function(hConnect, pwszVerb, pwszObjectName, pwszVersion, pwszReferrer, ppwszAcceptTypes, dwFlags)
|
||||
|
||||
@WinHTTPProxy()
|
||||
def WinHttpSendRequest(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength, dwTotalLength, dwContext):
|
||||
return WinHttpSendRequest.ctypes_function(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength, dwTotalLength, dwContext)
|
||||
|
||||
@WinHTTPProxy()
|
||||
def WinHttpReceiveResponse(hRequest, lpReserved):
|
||||
return WinHttpReceiveResponse.ctypes_function(hRequest, lpReserved)
|
||||
|
||||
@WinHTTPProxy()
|
||||
def WinHttpAddRequestHeaders(hRequest, lpszHeaders, dwHeadersLength, dwModifiers):
|
||||
return WinHttpAddRequestHeaders.ctypes_function(hRequest, lpszHeaders, dwHeadersLength, dwModifiers)
|
||||
|
||||
@WinHTTPProxy()
|
||||
def WinHttpQueryHeaders(hRequest, dwInfoLevel, pwszName, lpBuffer, lpdwBufferLength, lpdwIndex):
|
||||
return WinHttpQueryHeaders.ctypes_function(hRequest, dwInfoLevel, pwszName, lpBuffer, lpdwBufferLength, lpdwIndex)
|
||||
@@ -0,0 +1,95 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
|
||||
from ..error import (fail_on_zero)
|
||||
|
||||
|
||||
class WinInetProxy(ApiProxy):
|
||||
APIDLL = "wininet"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
@WinInetProxy()
|
||||
def InternetCheckConnectionA(lpszUrl, dwFlags, dwReserved):
|
||||
return InternetCheckConnectionA.ctypes_function(lpszUrl, dwFlags, dwReserved)
|
||||
|
||||
@WinInetProxy()
|
||||
def InternetCheckConnectionW(lpszUrl, dwFlags, dwReserved):
|
||||
return InternetCheckConnectionW.ctypes_function(lpszUrl, dwFlags, dwReserved)
|
||||
|
||||
@WinInetProxy()
|
||||
def InternetOpenA(lpszAgent, dwAccessType, lpszProxy, lpszProxyBypass, dwFlags):
|
||||
return InternetOpenA.ctypes_function(lpszAgent, dwAccessType, lpszProxy, lpszProxyBypass, dwFlags)
|
||||
|
||||
@WinInetProxy()
|
||||
def InternetOpenW(lpszAgent, dwAccessType, lpszProxy, lpszProxyBypass, dwFlags):
|
||||
return InternetOpenW.ctypes_function(lpszAgent, dwAccessType, lpszProxy, lpszProxyBypass, dwFlags)
|
||||
|
||||
@WinInetProxy()
|
||||
def InternetOpenUrlA(hInternet, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext):
|
||||
return InternetOpenUrlA.ctypes_function(hInternet, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext)
|
||||
|
||||
@WinInetProxy()
|
||||
def InternetOpenUrlW(hInternet, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext):
|
||||
return InternetOpenUrlW.ctypes_function(hInternet, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext)
|
||||
|
||||
@WinInetProxy()
|
||||
def InternetConnectA(hInternet, lpszServerName, nServerPort, lpszUserName, lpszPassword, dwService, dwFlags, dwContext):
|
||||
return InternetConnectA.ctypes_function(hInternet, lpszServerName, nServerPort, lpszUserName, lpszPassword, dwService, dwFlags, dwContext)
|
||||
|
||||
@WinInetProxy()
|
||||
def InternetConnectW(hInternet, lpszServerName, nServerPort, lpszUserName, lpszPassword, dwService, dwFlags, dwContext):
|
||||
return InternetConnectW.ctypes_function(hInternet, lpszServerName, nServerPort, lpszUserName, lpszPassword, dwService, dwFlags, dwContext)
|
||||
|
||||
@WinInetProxy()
|
||||
def HttpOpenRequestA(hConnect, lpszVerb, lpszObjectName, lpszVersion, lpszReferrer, lplpszAcceptTypes, dwFlags, dwContext):
|
||||
return HttpOpenRequestA.ctypes_function(hConnect, lpszVerb, lpszObjectName, lpszVersion, lpszReferrer, lplpszAcceptTypes, dwFlags, dwContext)
|
||||
|
||||
@WinInetProxy()
|
||||
def HttpOpenRequestW(hConnect, lpszVerb, lpszObjectName, lpszVersion, lpszReferrer, lplpszAcceptTypes, dwFlags, dwContext):
|
||||
return HttpOpenRequestW.ctypes_function(hConnect, lpszVerb, lpszObjectName, lpszVersion, lpszReferrer, lplpszAcceptTypes, dwFlags, dwContext)
|
||||
|
||||
@WinInetProxy()
|
||||
def InternetSetOptionA(hInternet, dwOption, lpBuffer, dwBufferLength):
|
||||
return InternetSetOptionA.ctypes_function(hInternet, dwOption, lpBuffer, dwBufferLength)
|
||||
|
||||
@WinInetProxy()
|
||||
def InternetSetOptionW(hInternet, dwOption, lpBuffer, dwBufferLength):
|
||||
return InternetSetOptionW.ctypes_function(hInternet, dwOption, lpBuffer, dwBufferLength)
|
||||
|
||||
@WinInetProxy()
|
||||
def HttpSendRequestA(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength):
|
||||
return HttpSendRequestA.ctypes_function(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength)
|
||||
|
||||
@WinInetProxy()
|
||||
def HttpSendRequestW(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength):
|
||||
return HttpSendRequestW.ctypes_function(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength)
|
||||
|
||||
@WinInetProxy()
|
||||
def InternetReadFile(hFile, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead):
|
||||
return InternetReadFile.ctypes_function(hFile, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead)
|
||||
|
||||
@WinInetProxy()
|
||||
def InternetReadFileExA(hFile, lpBuffersOut, dwFlags, dwContext):
|
||||
return InternetReadFileExA.ctypes_function(hFile, lpBuffersOut, dwFlags, dwContext)
|
||||
|
||||
@WinInetProxy()
|
||||
def InternetReadFileExW(hFile, lpBuffersOut, dwFlags, dwContext):
|
||||
return InternetReadFileExW.ctypes_function(hFile, lpBuffersOut, dwFlags, dwContext)
|
||||
|
||||
@WinInetProxy()
|
||||
def HttpQueryInfoA(hRequest, dwInfoLevel, lpBuffer, lpdwBufferLength, lpdwIndex):
|
||||
return HttpQueryInfoA.ctypes_function(hRequest, dwInfoLevel, lpBuffer, lpdwBufferLength, lpdwIndex)
|
||||
|
||||
@WinInetProxy()
|
||||
def HttpQueryInfoW(hRequest, dwInfoLevel, lpBuffer, lpdwBufferLength, lpdwIndex):
|
||||
return HttpQueryInfoW.ctypes_function(hRequest, dwInfoLevel, lpBuffer, lpdwBufferLength, lpdwIndex)
|
||||
|
||||
@WinInetProxy()
|
||||
def HttpSendRequestA(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength):
|
||||
return HttpSendRequestA.ctypes_function(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength)
|
||||
|
||||
@WinInetProxy()
|
||||
def HttpSendRequestW(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength):
|
||||
return HttpSendRequestW.ctypes_function(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength)
|
||||
@@ -0,0 +1,68 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import no_error_check, fail_on_zero
|
||||
|
||||
class WinTrustProxy(ApiProxy):
|
||||
APIDLL = "wintrust"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
|
||||
# Trust
|
||||
|
||||
@WinTrustProxy(error_check=no_error_check)
|
||||
def WinVerifyTrust(hwnd, pgActionID, pWVTData):
|
||||
return WinVerifyTrust.ctypes_function(hwnd, pgActionID, pWVTData)
|
||||
|
||||
# Catalog
|
||||
|
||||
@WinTrustProxy()
|
||||
def CryptCATAdminCalcHashFromFileHandle(hFile, pcbHash, pbHash, dwFlags):
|
||||
return CryptCATAdminCalcHashFromFileHandle.ctypes_function(hFile, pcbHash, pbHash, dwFlags)
|
||||
|
||||
@WinTrustProxy()
|
||||
def CryptCATAdminCalcHashFromFileHandle2(hCatAdmin, hFile, pcbHash, pbHash, dwFlags):
|
||||
return CryptCATAdminCalcHashFromFileHandle2.ctypes_function(hCatAdmin, hFile, pcbHash, pbHash, dwFlags)
|
||||
|
||||
@WinTrustProxy(error_check=no_error_check)
|
||||
def CryptCATAdminEnumCatalogFromHash(hCatAdmin, pbHash, cbHash, dwFlags, phPrevCatInfo):
|
||||
return CryptCATAdminEnumCatalogFromHash.ctypes_function(hCatAdmin, pbHash, cbHash, dwFlags, phPrevCatInfo)
|
||||
|
||||
@WinTrustProxy()
|
||||
def CryptCATAdminAcquireContext(phCatAdmin, pgSubsystem, dwFlags):
|
||||
return CryptCATAdminAcquireContext.ctypes_function(phCatAdmin, pgSubsystem, dwFlags)
|
||||
|
||||
@WinTrustProxy()
|
||||
def CryptCATAdminAcquireContext2(phCatAdmin, pgSubsystem, pwszHashAlgorithm, pStrongHashPolicy, dwFlags):
|
||||
return CryptCATAdminAcquireContext2.ctypes_function(phCatAdmin, pgSubsystem, pwszHashAlgorithm, pStrongHashPolicy, dwFlags)
|
||||
|
||||
|
||||
@WinTrustProxy()
|
||||
def CryptCATCatalogInfoFromContext(hCatInfo, psCatInfo, dwFlags):
|
||||
return CryptCATCatalogInfoFromContext.ctypes_function(hCatInfo, psCatInfo, dwFlags)
|
||||
|
||||
|
||||
@WinTrustProxy(error_check=no_error_check)
|
||||
def CryptCATAdminReleaseCatalogContext(hCatAdmin, hCatInfo, dwFlags):
|
||||
return CryptCATAdminReleaseCatalogContext.ctypes_function(hCatAdmin, hCatInfo, dwFlags)
|
||||
|
||||
|
||||
@WinTrustProxy()
|
||||
def CryptCATAdminReleaseContext(hCatAdmin, dwFlags):
|
||||
return CryptCATAdminReleaseContext.ctypes_function(hCatAdmin, dwFlags)
|
||||
|
||||
|
||||
@WinTrustProxy(error_check=no_error_check)
|
||||
def CryptCATEnumerateAttr(hCatalog, pCatMember, pPrevAttr):
|
||||
return CryptCATEnumerateAttr.ctypes_function(hCatalog, pCatMember, pPrevAttr)
|
||||
|
||||
|
||||
@WinTrustProxy(error_check=no_error_check)
|
||||
def CryptCATEnumerateCatAttr(hCatalog, pPrevAttr):
|
||||
return CryptCATEnumerateCatAttr.ctypes_function(hCatalog, pPrevAttr)
|
||||
|
||||
|
||||
@WinTrustProxy(error_check=no_error_check)
|
||||
def CryptCATEnumerateMember(hCatalog, pPrevMember):
|
||||
return CryptCATEnumerateMember.ctypes_function(hCatalog, pPrevMember)
|
||||
@@ -0,0 +1,76 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
|
||||
from ..error import WinproxyError, succeed_on_zero, no_error_check, fail_on_minus_one
|
||||
|
||||
len_ = len
|
||||
|
||||
class Ws2_32Proxy(ApiProxy):
|
||||
APIDLL = "ws2_32"
|
||||
default_error_check = staticmethod(succeed_on_zero)
|
||||
|
||||
def check_invalid_socket(func_name, result, func, args):
|
||||
if result == gdef.INVALID_SOCKET:
|
||||
raise WinproxyError(func_name, error_code=WSAGetLastError())
|
||||
return args
|
||||
|
||||
@Ws2_32Proxy()
|
||||
def WSAStartup(wVersionRequested, lpWSAData):
|
||||
if isinstance(lpWSAData, gdef.WSADATA):
|
||||
lpWSAData = ctypes.byref(lpWSAData) # Not naturally done as lpWSAData is defined as a PVOID due to WSADATA32/WSADATA64 types
|
||||
return WSAStartup.ctypes_function(wVersionRequested, lpWSAData)
|
||||
|
||||
|
||||
@Ws2_32Proxy()
|
||||
def WSACleanup():
|
||||
return WSACleanup.ctypes_function()
|
||||
|
||||
@Ws2_32Proxy(error_check=no_error_check)
|
||||
def WSAGetLastError():
|
||||
return WSAGetLastError.ctypes_function()
|
||||
|
||||
@Ws2_32Proxy()
|
||||
def getaddrinfo(pNodeName, pServiceName, pHints, ppResult):
|
||||
return getaddrinfo.ctypes_function(pNodeName, pServiceName, pHints, ppResult)
|
||||
|
||||
@Ws2_32Proxy()
|
||||
def GetAddrInfoW(pNodeName, pServiceName, pHints, ppResult):
|
||||
return GetAddrInfoW.ctypes_function(pNodeName, pServiceName, pHints, ppResult)
|
||||
|
||||
@Ws2_32Proxy(error_check=check_invalid_socket)
|
||||
def WSASocketA(af, type, protocol, lpProtocolInfo, g, dwFlags):
|
||||
return WSASocketA.ctypes_function(af, type, protocol, lpProtocolInfo, g, dwFlags)
|
||||
|
||||
@Ws2_32Proxy(error_check=check_invalid_socket)
|
||||
def WSASocketW(af, type, protocol, lpProtocolInfo, g, dwFlags):
|
||||
return WSASocketW.ctypes_function(af, type, protocol, lpProtocolInfo, g, dwFlags)
|
||||
|
||||
@Ws2_32Proxy(error_check=check_invalid_socket)
|
||||
def socket(af, type, protocol):
|
||||
return socket.ctypes_function(af, type, protocol)
|
||||
|
||||
@Ws2_32Proxy(error_check=fail_on_minus_one) # SOCKET_ERROR
|
||||
def connect(s, name, namelen):
|
||||
return connect.ctypes_function(s, name, namelen)
|
||||
|
||||
@Ws2_32Proxy(error_check=fail_on_minus_one) # SOCKET_ERROR
|
||||
def send(s, buf, len=None, flags=0):
|
||||
if len is None:
|
||||
len = len_(buf)
|
||||
return send.ctypes_function(s, buf, len, flags)
|
||||
|
||||
@Ws2_32Proxy(error_check=fail_on_minus_one) # SOCKET_ERROR
|
||||
def recv(s, buf, len=None, flags=0):
|
||||
if len is None:
|
||||
len = len_(buf)
|
||||
return recv.ctypes_function(s, buf, len, flags)
|
||||
|
||||
@Ws2_32Proxy(error_check=fail_on_minus_one) # SOCKET_ERROR
|
||||
def shutdown(s, how):
|
||||
return shutdown.ctypes_function(s, how)
|
||||
|
||||
@Ws2_32Proxy(error_check=fail_on_minus_one) # SOCKET_ERROR
|
||||
def closesocket(s):
|
||||
return closesocket.ctypes_function(s)
|
||||
@@ -0,0 +1,79 @@
|
||||
import ctypes
|
||||
|
||||
import windows.generated_def as gdef
|
||||
from windows.generated_def.ntstatus import NtStatusException
|
||||
|
||||
|
||||
# ApiProxy stuff
|
||||
class ExportNotFound(RuntimeError):
|
||||
def __init__(self, func_name, api_name):
|
||||
self.func_name = func_name
|
||||
self.api_name = api_name
|
||||
super(ExportNotFound, self).__init__("Function {0} not found into {1}".format(func_name, api_name))
|
||||
|
||||
|
||||
# PFW Winproxy Exception type
|
||||
class WinproxyError(WindowsError):
|
||||
def __new__(cls, func_name, error_code=None):
|
||||
win_error = ctypes.WinError(error_code) #GetLastError by default
|
||||
api_error = super(WinproxyError, cls).__new__(cls)
|
||||
api_error.api_name = func_name
|
||||
api_error.winerror = win_error.winerror & 0xffffffff
|
||||
api_error.strerror = win_error.strerror
|
||||
api_error.args = (func_name, win_error.winerror, win_error.strerror)
|
||||
return api_error
|
||||
|
||||
def __init__(self, func_name, error_code=None):
|
||||
super(WinproxyError, self).__init__(func_name)
|
||||
|
||||
def __repr__(self):
|
||||
return "{0}: {1}".format(self.api_name, super(WinproxyError, self).__repr__())
|
||||
|
||||
def __str__(self):
|
||||
return "{0}: {1}".format(self.api_name, super(WinproxyError, self).__str__())
|
||||
|
||||
|
||||
# winproxy Error check
|
||||
no_error_check = None
|
||||
|
||||
def fail_on_minus_one(func_name, result, func, args):
|
||||
"""Raise WinproxyError if call result is -1"""
|
||||
if result == -1:
|
||||
raise WinproxyError(func_name)
|
||||
return args
|
||||
|
||||
|
||||
def fail_on_zero(func_name, result, func, args):
|
||||
"""raise WinproxyError if result is 0"""
|
||||
if not result:
|
||||
raise WinproxyError(func_name)
|
||||
return args
|
||||
|
||||
|
||||
def succeed_on_zero(func_name, result, func, args):
|
||||
"""raise WinproxyError if result is NOT 0"""
|
||||
if result:
|
||||
raise WinproxyError(func_name)
|
||||
return args
|
||||
|
||||
|
||||
def result_is_error_code(func_name, result, func, args):
|
||||
"""raise WinproxyError(result) if result is NOT 0"""
|
||||
if result:
|
||||
raise WinproxyError(func_name, error_code=result)
|
||||
return args
|
||||
|
||||
|
||||
def result_is_ntstatus(func_name, result, func, args):
|
||||
"""raise NtStatusException is result is not 0"""
|
||||
if result:
|
||||
raise NtStatusException(result & 0xffffffff)
|
||||
return args
|
||||
|
||||
|
||||
def result_is_handle(func_name, result, func, args):
|
||||
"""raise WinproxyError is result is INVALID_HANDLE_VALUE"""
|
||||
if result == gdef.INVALID_HANDLE_VALUE:
|
||||
raise WinproxyError(func_name)
|
||||
return args
|
||||
|
||||
Reference in New Issue
Block a user