Python ctypes.wintypes.LPVOID Examples

The following are 30 code examples for showing how to use ctypes.wintypes.LPVOID(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module ctypes.wintypes , or try the search function .

Example 1
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def Indicate(self, object_count, obj_array):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.c_long,
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'lObjectCount'),
                      (_In_, 'apObjArray'),
                      )

        _Indicate = prototype(IWbemObjectSink_Indicate_Idx,
                              'Indicate',
                              paramflags)
        _Indicate.errcheck = winapi.RAISE_NON_ZERO_ERR
        _Indicate(self.this,
                  object_count,
                  obj_array.this if obj_array else None
                  ) 
Example 2
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def GetNames(self, flags):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.c_long,
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'lFlags'),
                      (_Out_, 'pNames'),
                      )

        _GetNames = prototype(IWbemQualifierSet_GetNames_Idx,
                              'GetNames',
                              paramflags)
        _GetNames.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _GetNames(self.this,
                               flags
                               )
        return_obj = ctypes.cast(wintypes.LPVOID(return_obj), ctypes.POINTER(winapi.SAFEARRAY))
        return return_obj 
Example 3
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def GetQualifierSet(self):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_Out_, 'ppQualSet'),
                      )

        _GetQualifierSet = prototype(IWbemClassObject_GetQualifierSet_Idx,
                                     'GetQualifierSet',
                                     paramflags)
        _GetQualifierSet.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _GetQualifierSet(self.this
                                      )
        try:
            return_obj = IWbemQualifierSet(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 4
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def GetNames(self, qualifier_name, flags, qualifier_val):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       wintypes.LPCWSTR,
                                       ctypes.c_long,
                                       ctypes.POINTER(winapi.VARIANT),
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'wszQualifierName'),
                      (_In_, 'lFlags'),
                      (_In_, 'pQualifierVal'),
                      (_Out_, 'pNames'),
                      )

        _GetNames = prototype(IWbemClassObject_GetNames_Idx,
                              'GetNames',
                              paramflags)
        _GetNames.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _GetNames(self.this,
                               qualifier_name,
                               flags,
                               ctypes.byref(qualifier_val) if qualifier_val else None
                               )
        return_obj = ctypes.cast(wintypes.LPVOID(return_obj), ctypes.POINTER(winapi.SAFEARRAY))
        return return_obj 
Example 5
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def GetPropertyQualifierSet(self, property_param):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       wintypes.LPCWSTR,
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'wszProperty'),
                      (_Out_, 'ppQualSet'),
                      )

        _GetPropertyQualifierSet = prototype(IWbemClassObject_GetPropertyQualifierSet_Idx,
                                             'GetPropertyQualifierSet',
                                             paramflags)
        _GetPropertyQualifierSet.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _GetPropertyQualifierSet(self.this,
                                              property_param
                                              )
        try:
            return_obj = IWbemQualifierSet(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 6
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def SpawnDerivedClass(self, flags):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.c_long,
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'lFlags'),
                      (_Out_, 'ppNewClass'),
                      )

        _SpawnDerivedClass = prototype(IWbemClassObject_SpawnDerivedClass_Idx,
                                       'SpawnDerivedClass',
                                       paramflags)
        _SpawnDerivedClass.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _SpawnDerivedClass(self.this,
                                        flags
                                        )
        try:
            return_obj = IWbemClassObject(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 7
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def SpawnInstance(self, flags):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.c_long,
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'lFlags'),
                      (_Out_, 'ppNewInstance'),
                      )

        _SpawnInstance = prototype(IWbemClassObject_SpawnInstance_Idx,
                                   'SpawnInstance',
                                   paramflags)
        _SpawnInstance.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _SpawnInstance(self.this,
                                    flags
                                    )
        try:
            return_obj = IWbemClassObject(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 8
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def GetMethodQualifierSet(self, method):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       wintypes.LPCWSTR,
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'wszMethod'),
                      (_Out_, 'ppQualSet'),
                      )

        _GetMethodQualifierSet = prototype(IWbemClassObject_GetMethodQualifierSet_Idx,
                                           'GetMethodQualifierSet',
                                           paramflags)
        _GetMethodQualifierSet.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _GetMethodQualifierSet(self.this,
                                            method
                                            )
        try:
            return_obj = IWbemQualifierSet(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 9
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def Clone(self):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_Out_, 'ppEnum'),
                      )

        _Clone = prototype(IEnumWbemClassObject_Clone_Idx,
                           'Clone',
                           paramflags)
        _Clone.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _Clone(self.this
                            )
        try:
            return_obj = IEnumWbemClassObject(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 10
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def GetResultObject(self, timeout):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.c_long,
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'lTimeout'),
                      (_Out_, 'ppResultObject'),
                      )

        _GetResultObject = prototype(IWbemCallResult_GetResultObject_Idx,
                                     'GetResultObject',
                                     paramflags)
        _GetResultObject.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _GetResultObject(self.this,
                                      timeout
                                      )
        try:
            return_obj = IWbemClassObject(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 11
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def GetResultServices(self, timeout):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.c_long,
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'lTimeout'),
                      (_Out_, 'ppServices'),
                      )

        _GetResultServices = prototype(IWbemCallResult_GetResultServices_Idx,
                                       'GetResultServices',
                                       paramflags)
        _GetResultServices.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _GetResultServices(self.this,
                                        timeout
                                        )
        try:
            return_obj = IWbemServices(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 12
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def Clone(self):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_Out_, 'ppNewCopy'),
                      )

        _Clone = prototype(IWbemContext_Clone_Idx,
                           'Clone',
                           paramflags)
        _Clone.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _Clone(self.this
                            )
        try:
            return_obj = IWbemContext(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 13
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def GetNames(self, flags):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.c_long,
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'lFlags'),
                      (_Out_, 'pNames'),
                      )

        _GetNames = prototype(IWbemContext_GetNames_Idx,
                              'GetNames',
                              paramflags)
        _GetNames.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _GetNames(self.this,
                               flags
                               )
        return_obj = ctypes.cast(wintypes.LPVOID(return_obj), ctypes.POINTER(winapi.SAFEARRAY))
        return return_obj 
Example 14
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 6 votes vote down vote up
def QueryObjectSink(self, flags):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.c_long,
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'lFlags'),
                      (_Out_, 'ppResponseHandler'),
                      )

        _QueryObjectSink = prototype(IWbemServices_QueryObjectSink_Idx,
                                     'QueryObjectSink',
                                     paramflags)
        _QueryObjectSink.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _QueryObjectSink(self.this,
                                      flags
                                      )
        try:
            return_obj = IWbemObjectSink(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 15
Project: cWMI   Author: fireeye   File: com.py    License: Apache License 2.0 6 votes vote down vote up
def QueryInterface(self, riid):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.POINTER(winapi.GUID),
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'riid'),
                      (_Out_, 'ppvObject', ctypes.pointer(wintypes.LPVOID(None)))
                      )

        _QueryInterface = prototype(IUnknown_QueryInterface_Idx,
                                    'QueryInterface',
                                    paramflags)
        _QueryInterface.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_ptr = _QueryInterface(self.this,
                                     ctypes.byref(riid))
        return IUnknown(return_ptr.contents) 
Example 16
Project: cWMI   Author: fireeye   File: winapi.py    License: Apache License 2.0 6 votes vote down vote up
def CoInitializeEx(reserved, co_init):
    prototype = ctypes.WINFUNCTYPE(
        HRESULT,
        wintypes.LPVOID,
        wintypes.DWORD
    )

    paramflags = (
        (_In_, 'pvReserved'),
        (_In_, 'dwCoInit')
    )

    _CoInitializeEx = prototype(('CoInitializeEx', ole32), paramflags)
    _CoInitializeEx.errcheck = RAISE_NON_ZERO_ERR

    return _CoInitializeEx(reserved, co_init) 
Example 17
Project: cWMI   Author: fireeye   File: winapi.py    License: Apache License 2.0 6 votes vote down vote up
def CoCreateInstance(clsid, unk, ctx, iid):
    prototype = ctypes.WINFUNCTYPE(
        HRESULT,
        ctypes.POINTER(GUID),
        wintypes.LPVOID,
        wintypes.DWORD,
        ctypes.POINTER(GUID),
        ctypes.POINTER(wintypes.LPVOID)
    )

    paramflags = (
        (_In_, 'rclsid'),
        (_In_, 'pUnkOuter'),
        (_In_, 'dwClsContext'),
        (_In_, 'riid'),
        (_Out_, 'ppv')
    )

    _CoCreateInstance = prototype(('CoCreateInstance', ole32), paramflags)
    _CoCreateInstance.errcheck = RAISE_NON_ZERO_ERR
    return _CoCreateInstance(clsid, unk, ctx, iid) 
Example 18
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 5 votes vote down vote up
def GetMethod(self, name, flags):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       wintypes.LPCWSTR,
                                       ctypes.c_long,
                                       ctypes.POINTER(wintypes.LPVOID),
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'wszName'),
                      (_In_, 'lFlags'),
                      (_Out_, 'ppInSignature'),
                      (_Out_, 'ppOutSignature'),
                      )

        _GetMethod = prototype(IWbemClassObject_GetMethod_Idx,
                               'GetMethod',
                               paramflags)
        _GetMethod.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj, return_obj2 = _GetMethod(self.this,
                                             name,
                                             flags
                                             )
        try:
            return_obj = IWbemClassObject(return_obj)
        except WindowsError:
            return_obj = None
        try:
            return_obj2 = IWbemClassObject(return_obj2)
        except WindowsError:
            return_obj2 = None
        return return_obj, return_obj2 
Example 19
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 5 votes vote down vote up
def NextMethod(self, flags):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.c_long,
                                       ctypes.POINTER(BSTR),
                                       ctypes.POINTER(wintypes.LPVOID),
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'lFlags'),
                      (_Out_, 'pstrName'),
                      (_Out_, 'ppInSignature'),
                      (_Out_, 'ppOutSignature'),
                      )

        _NextMethod = prototype(IWbemClassObject_NextMethod_Idx,
                                'NextMethod',
                                paramflags)
        _NextMethod.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj, return_obj2, return_obj3 = _NextMethod(self.this,
                                                           flags
                                                           )
        return_obj = winapi.convert_bstr_to_str(return_obj)
        try:
            return_obj2 = IWbemClassObject(return_obj2)
        except WindowsError:
            return_obj2 = None
        try:
            return_obj3 = IWbemClassObject(return_obj3)
        except WindowsError:
            return_obj3 = None
        return return_obj, return_obj2, return_obj3 
Example 20
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 5 votes vote down vote up
def GetObjectWithResult(self, object_path, flags, ctx):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       BSTR,
                                       ctypes.c_long,
                                       ctypes.POINTER(IWbemContext),
                                       ctypes.POINTER(wintypes.LPVOID),
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'strObjectPath'),
                      (_In_, 'lFlags'),
                      (_In_, 'pCtx'),
                      (_Out_, 'ppObject'),
                      (_Out_, 'ppCallResult'),
                      )

        _GetObject = prototype(IWbemServices_GetObject_Idx,
                               'GetObject',
                               paramflags)
        _GetObject.errcheck = winapi.RAISE_NON_ZERO_ERR
        object_path_bstr = winapi.SysAllocString(object_path) if object_path is not None else None
        try:
            return_obj, return_obj2 = _GetObject(self.this,
                                                 object_path_bstr,
                                                 flags,
                                                 ctx.this if ctx else None
                                                 )
        finally:
            if object_path_bstr is not None:
                winapi.SysFreeString(object_path_bstr)
        try:
            return_obj = IWbemClassObject(return_obj)
        except WindowsError:
            return_obj = None
        try:
            return_obj2 = IWbemCallResult(return_obj2)
        except WindowsError:
            return_obj2 = None
        return return_obj, return_obj2 
Example 21
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 5 votes vote down vote up
def PutClassWithResult(self, object_param, flags, ctx):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       ctypes.POINTER(IWbemClassObject),
                                       ctypes.c_long,
                                       ctypes.POINTER(IWbemContext),
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'pObject'),
                      (_In_, 'lFlags'),
                      (_In_, 'pCtx'),
                      (_Out_, 'ppCallResult'),
                      )

        _PutClass = prototype(IWbemServices_PutClass_Idx,
                              'PutClass',
                              paramflags)
        _PutClass.errcheck = winapi.RAISE_NON_ZERO_ERR
        return_obj = _PutClass(self.this,
                               object_param.this if object_param else None,
                               flags,
                               ctx.this if ctx else None
                               )
        try:
            return_obj = IWbemCallResult(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 22
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 5 votes vote down vote up
def DeleteClassWithResult(self, class_param, flags, ctx):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       BSTR,
                                       ctypes.c_long,
                                       ctypes.POINTER(IWbemContext),
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'strClass'),
                      (_In_, 'lFlags'),
                      (_In_, 'pCtx'),
                      (_Out_, 'ppCallResult'),
                      )

        _DeleteClass = prototype(IWbemServices_DeleteClass_Idx,
                                 'DeleteClass',
                                 paramflags)
        _DeleteClass.errcheck = winapi.RAISE_NON_ZERO_ERR
        class_param_bstr = winapi.SysAllocString(class_param) if class_param is not None else None
        try:
            return_obj = _DeleteClass(self.this,
                                      class_param_bstr,
                                      flags,
                                      ctx.this if ctx else None
                                      )
        finally:
            if class_param_bstr is not None:
                winapi.SysFreeString(class_param_bstr)
        try:
            return_obj = IWbemCallResult(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 23
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 5 votes vote down vote up
def CreateClassEnum(self, superclass, flags, ctx):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       BSTR,
                                       ctypes.c_long,
                                       ctypes.POINTER(IWbemContext),
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'strSuperclass'),
                      (_In_, 'lFlags'),
                      (_In_, 'pCtx'),
                      (_Out_, 'ppEnum'),
                      )

        _CreateClassEnum = prototype(IWbemServices_CreateClassEnum_Idx,
                                     'CreateClassEnum',
                                     paramflags)
        _CreateClassEnum.errcheck = winapi.RAISE_NON_ZERO_ERR
        superclass_bstr = winapi.SysAllocString(superclass) if superclass is not None else None
        try:
            return_obj = _CreateClassEnum(self.this,
                                          superclass_bstr,
                                          flags,
                                          ctx.this if ctx else None
                                          )
        finally:
            if superclass_bstr is not None:
                winapi.SysFreeString(superclass_bstr)
        try:
            return_obj = IEnumWbemClassObject(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 24
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 5 votes vote down vote up
def DeleteInstanceWithResult(self, object_path, flags, ctx):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       BSTR,
                                       ctypes.c_long,
                                       ctypes.POINTER(IWbemContext),
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'strObjectPath'),
                      (_In_, 'lFlags'),
                      (_In_, 'pCtx'),
                      (_Out_, 'ppCallResult'),
                      )

        _DeleteInstance = prototype(IWbemServices_DeleteInstance_Idx,
                                    'DeleteInstance',
                                    paramflags)
        _DeleteInstance.errcheck = winapi.RAISE_NON_ZERO_ERR
        object_path_bstr = winapi.SysAllocString(object_path) if object_path is not None else None
        try:
            return_obj = _DeleteInstance(self.this,
                                         object_path_bstr,
                                         flags,
                                         ctx.this if ctx else None
                                         )
        finally:
            if object_path_bstr is not None:
                winapi.SysFreeString(object_path_bstr)
        try:
            return_obj = IWbemCallResult(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 25
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 5 votes vote down vote up
def CreateInstanceEnum(self, filter_param, flags, ctx):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       BSTR,
                                       ctypes.c_long,
                                       ctypes.POINTER(IWbemContext),
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'strFilter'),
                      (_In_, 'lFlags'),
                      (_In_, 'pCtx'),
                      (_Out_, 'ppEnum'),
                      )

        _CreateInstanceEnum = prototype(IWbemServices_CreateInstanceEnum_Idx,
                                        'CreateInstanceEnum',
                                        paramflags)
        _CreateInstanceEnum.errcheck = winapi.RAISE_NON_ZERO_ERR
        filter_param_bstr = winapi.SysAllocString(filter_param) if filter_param is not None else None
        try:
            return_obj = _CreateInstanceEnum(self.this,
                                             filter_param_bstr,
                                             flags,
                                             ctx.this if ctx else None
                                             )
        finally:
            if filter_param_bstr is not None:
                winapi.SysFreeString(filter_param_bstr)
        try:
            return_obj = IEnumWbemClassObject(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 26
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 5 votes vote down vote up
def ExecQuery(self, query_language, query, flags, ctx):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       BSTR,
                                       BSTR,
                                       ctypes.c_long,
                                       ctypes.POINTER(IWbemContext),
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'strQueryLanguage'),
                      (_In_, 'strQuery'),
                      (_In_, 'lFlags'),
                      (_In_, 'pCtx'),
                      (_Out_, 'ppEnum'),
                      )

        _ExecQuery = prototype(IWbemServices_ExecQuery_Idx,
                               'ExecQuery',
                               paramflags)
        _ExecQuery.errcheck = winapi.RAISE_NON_ZERO_ERR
        query_language_bstr = winapi.SysAllocString(query_language) if query_language is not None else None
        query_bstr = winapi.SysAllocString(query) if query is not None else None
        try:
            return_obj = _ExecQuery(self.this,
                                    query_language_bstr,
                                    query_bstr,
                                    flags,
                                    ctx.this if ctx else None
                                    )
        finally:
            if query_language_bstr is not None:
                winapi.SysFreeString(query_language_bstr)
            if query_bstr is not None:
                winapi.SysFreeString(query_bstr)
        try:
            return_obj = IEnumWbemClassObject(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 27
Project: cWMI   Author: fireeye   File: wmi.py    License: Apache License 2.0 5 votes vote down vote up
def ExecNotificationQuery(self, query_language, query, flags, ctx):
        prototype = ctypes.WINFUNCTYPE(HRESULT,
                                       BSTR,
                                       BSTR,
                                       ctypes.c_long,
                                       ctypes.POINTER(IWbemContext),
                                       ctypes.POINTER(wintypes.LPVOID))

        paramflags = ((_In_, 'strQueryLanguage'),
                      (_In_, 'strQuery'),
                      (_In_, 'lFlags'),
                      (_In_, 'pCtx'),
                      (_Out_, 'ppEnum'),
                      )

        _ExecNotificationQuery = prototype(IWbemServices_ExecNotificationQuery_Idx,
                                           'ExecNotificationQuery',
                                           paramflags)
        _ExecNotificationQuery.errcheck = winapi.RAISE_NON_ZERO_ERR
        query_language_bstr = winapi.SysAllocString(query_language) if query_language is not None else None
        query_bstr = winapi.SysAllocString(query) if query is not None else None
        try:
            return_obj = _ExecNotificationQuery(self.this,
                                                query_language_bstr,
                                                query_bstr,
                                                flags,
                                                ctx.this if ctx else None
                                                )
        finally:
            if query_language_bstr is not None:
                winapi.SysFreeString(query_language_bstr)
            if query_bstr is not None:
                winapi.SysFreeString(query_bstr)
        try:
            return_obj = IEnumWbemClassObject(return_obj)
        except WindowsError:
            return_obj = None
        return return_obj 
Example 28
Project: cWMI   Author: fireeye   File: winapi.py    License: Apache License 2.0 5 votes vote down vote up
def CoSetProxyBlanket(proxy,
                      authn_svc,
                      authz_svc,
                      server_p_name,
                      authn_level,
                      imp_level,
                      auth_info,
                      capabilities):
    prototype = ctypes.WINFUNCTYPE(
        HRESULT,
        wintypes.LPVOID,
        wintypes.DWORD,
        wintypes.DWORD,
        wintypes.OLESTR,
        wintypes.DWORD,
        wintypes.DWORD,
        RPC_AUTH_IDENTITY_HANDLE,
        wintypes.DWORD
    )

    paramflags = (
        (_In_, 'pProxy'),
        (_In_, 'dwAuthnSvc'),
        (_In_, 'dwAuthzSvc'),
        (_In_, 'pServerPrincName'),
        (_In_, 'dwAuthnLevel'),
        (_In_, 'dwImpLevel'),
        (_In_, 'pAuthInfo'),
        (_In_, 'dwCapabilities')
    )

    _CoSetProxyBlanket = prototype(('CoSetProxyBlanket', ole32), paramflags)
    _CoSetProxyBlanket.errcheck = RAISE_NON_ZERO_ERR
    return _CoSetProxyBlanket(proxy,
                              authn_svc,
                              authz_svc,
                              server_p_name,
                              authn_level,
                              imp_level,
                              auth_info,
                              capabilities) 
Example 29
Project: win_driver_plugin   Author: FSecureLABS   File: driverlib.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def send_ioctl(self, ioctl, inbuf, inbufsiz, outbuf, outbufsiz):
        """See: DeviceIoControl function
        http://msdn.microsoft.com/en-us/library/aa363216(v=vs.85).aspx
        """
        DeviceIoControl_Fn = ctypes.windll.kernel32.DeviceIoControl
        DeviceIoControl_Fn.argtypes = [
                wintypes.HANDLE,                    # _In_          HANDLE hDevice
                wintypes.DWORD,                     # _In_          DWORD dwIoControlCode
                wintypes.LPVOID,                    # _In_opt_      LPVOID lpInBuffer
                wintypes.DWORD,                     # _In_          DWORD nInBufferSize
                wintypes.LPVOID,                    # _Out_opt_     LPVOID lpOutBuffer
                wintypes.DWORD,                     # _In_          DWORD nOutBufferSize
                LPDWORD,                            # _Out_opt_     LPDWORD lpBytesReturned
                LPOVERLAPPED]                       # _Inout_opt_   LPOVERLAPPED lpOverlapped
        DeviceIoControl_Fn.restype = wintypes.BOOL
        # allocate a DWORD, and take its reference
        dwBytesReturned = wintypes.DWORD(0)
        lpBytesReturned = ctypes.byref(dwBytesReturned)
        status = DeviceIoControl_Fn(self.handle,
                      ioctl,
                      inbuf,
                      inbufsiz,
                      outbuf,
                      outbufsiz,
                      lpBytesReturned,
                      None)

        return status, dwBytesReturned 
Example 30
Project: gd.py   Author: NeKitDS   File: win.py    License: MIT License 5 votes vote down vote up
def read_process_memory(
    handle: wintypes.HANDLE,
    base_address: wintypes.LPVOID,
    buffer: wintypes.LPCVOID,
    size: ctypes.c_size_t,
    size_ptr: ctypes.POINTER(ctypes.c_size_t),
) -> wintypes.BOOL:
    pass