当前位置: 首页>>代码示例>>Python>>正文


Python ctypes.CFUNCTYPE属性代码示例

本文整理汇总了Python中ctypes.CFUNCTYPE属性的典型用法代码示例。如果您正苦于以下问题:Python ctypes.CFUNCTYPE属性的具体用法?Python ctypes.CFUNCTYPE怎么用?Python ctypes.CFUNCTYPE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在ctypes的用法示例。


在下文中一共展示了ctypes.CFUNCTYPE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute_64bits_code_from_syswow

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def execute_64bits_code_from_syswow(shellcode):
    """shellcode must not end by a ret"""
    if not windows.current_process.is_wow_64:
        raise ValueError("Calling execute_64bits_code_from_syswow from non-syswow process")
    addr = windows.winproxy.VirtualAlloc(dwSize=0x1000)
    # post-exec 32bits stub (xor eax, eax; ret)
    ret = "\xC3"
    ret_addr = addr
    shell_code_addr = ret_addr + len(ret) + len(dummy_jump)
    # ljmp
    jump = "\xea" + struct.pack("<I", shell_code_addr) + chr(CS_64bits) + "\x00\x00"
    jump_addr = ret_addr + len(ret)
    # Return to 32bits stub
    shellcode += genere_return_32bits_stub(ret_addr)
    # WRITE ALL THE STUBS
    windows.current_process.write_memory(ret_addr, ret)
    windows.current_process.write_memory(jump_addr, jump)
    windows.current_process.write_memory(shell_code_addr, shellcode)
    # Execute
    exec_stub = ctypes.CFUNCTYPE(HRESULT)(jump_addr)
    return exec_stub() 
开发者ID:sogeti-esec-lab,项目名称:LKD,代码行数:23,代码来源:syswow64.py

示例2: set_monitor_callback

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def set_monitor_callback(self, callback):
        """Install callback for monitor.

        Parameters
        ----------
        callback : function
            Takes a string and an NDArrayHandle.

        Examples
        --------
        >>> def mon_callback(*args, **kwargs):
        >>>     print("Do your stuff here.")
        >>>
        >>> texe.set_monitor_callback(mon_callback)
        """
        cb_type = ctypes.CFUNCTYPE(None, ctypes.c_char_p, NDArrayHandle, ctypes.c_void_p)
        self._monitor_callback = cb_type(_monitor_callback_wrapper(callback))
        check_call(_LIB.MXExecutorSetMonitorCallback(
            self.handle,
            self._monitor_callback,
            None)) 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:23,代码来源:executor.py

示例3: uiWindowOnClosing

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def uiWindowOnClosing(window, callback, data):
    """
    Executes the callback function on window closing.

    :param window: uiWindow
    :param callback: function
    :param data: data
    :return: reference to C callback function
    """

    c_type = ctypes.CFUNCTYPE(
        ctypes.c_int, ctypes.POINTER(uiWindow), ctypes.c_void_p)
    c_callback = c_type(callback)

    clibui.uiWindowOnClosing(window, c_callback, data)

    return c_callback


# - int uiWindowBorderless(uiWindow *w); 
开发者ID:joaoventura,项目名称:pylibui,代码行数:22,代码来源:window.py

示例4: uiWindowOnContentSizeChanged

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def uiWindowOnContentSizeChanged(window, callback, data):
    """
    Executes the callback function on window's content size change.

    :param window: uiWindow
    :param callback: function
    :param data: data
    :return: reference to C callback function
    """

    c_type = ctypes.CFUNCTYPE(
        ctypes.c_int, ctypes.POINTER(uiWindow), ctypes.c_void_p)
    c_callback = c_type(callback)

    clibui.uiWindowOnContentSizeChanged(window, c_callback, data)

    return c_callback


# - void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *w, void *data), void *data); 
开发者ID:joaoventura,项目名称:pylibui,代码行数:22,代码来源:window.py

示例5: uiSpinboxOnChanged

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def uiSpinboxOnChanged(spinbox, callback, data):
    """
    Executes the callback function on value changed.

    :param spinbox: uiSpinbox
    :param callback: function
    :param data: data
    :return: reference to C callback function
    """
    c_type = ctypes.CFUNCTYPE(
        ctypes.c_int, ctypes.POINTER(uiSpinbox), ctypes.c_void_p)
    c_callback = c_type(callback)

    clibui.uiSpinboxOnChanged(spinbox, c_callback, data)

    return c_callback


# - uiSpinbox *uiNewSpinbox(int min, int max); 
开发者ID:joaoventura,项目名称:pylibui,代码行数:21,代码来源:spinbox.py

示例6: uiButtonOnClicked

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def uiButtonOnClicked(button, callback, data):
    """
    Executes the callback function on button click.

    :param button: uiButton
    :param callback: function
    :param data: data
    :return: reference to C callback function
    """
    c_type = ctypes.CFUNCTYPE(
        ctypes.c_int, ctypes.POINTER(uiButton), ctypes.c_void_p)
    c_callback = c_type(callback)

    clibui.uiButtonOnClicked(button, c_callback, data)

    return c_callback


# - uiButton *uiNewButton(const char *text); 
开发者ID:joaoventura,项目名称:pylibui,代码行数:21,代码来源:button.py

示例7: uiRadioButtonsOnSelected

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def uiRadioButtonsOnSelected(radio_buttons, callback, data):
    """
    Executes a callback function when an item selected.

    :param radio_buttons: uiRadioButtons
    :param callback: function
    :param data: data
    :return: reference to C callback function
    """

    c_type = ctypes.CFUNCTYPE(
        ctypes.c_int, ctypes.POINTER(uiRadioButtons), ctypes.c_void_p)
    c_callback = c_type(callback)

    clibui.uiRadioButtonsOnSelected(radio_buttons, c_callback, data)

    return c_callback


# - uiRadioButtons *uiNewRadioButtons(void); 
开发者ID:joaoventura,项目名称:pylibui,代码行数:22,代码来源:radiobuttons.py

示例8: uiMultilineEntryOnChanged

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def uiMultilineEntryOnChanged(entry, callback, data):
    """
    Executes the callback function on multiline entry change.

    :param entry: uiMultilineEntry
    :param callback: function
    :param data: data
    :return: reference to C callback function
    """
    c_type = ctypes.CFUNCTYPE(
        ctypes.c_int, ctypes.POINTER(uiMultilineEntry), ctypes.c_void_p)
    c_callback = c_type(callback)

    clibui.uiMultilineEntryOnChanged(entry, c_callback, data)

    return c_callback


# - int uiMultilineEntryReadOnly(uiMultilineEntry *e); 
开发者ID:joaoventura,项目名称:pylibui,代码行数:21,代码来源:multilineentry.py

示例9: uiCheckboxOnToggled

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def uiCheckboxOnToggled(checkbox, callback, data):
    """
    Executes the callback function on checkbox toggle.

    :param checkbox: uiCheckbox
    :param callback: function
    :param data: data
    :return: reference to C callback function
    """
    c_type = ctypes.CFUNCTYPE(
        ctypes.c_int, ctypes.POINTER(uiCheckbox), ctypes.c_void_p)
    c_callback = c_type(callback)

    clibui.uiCheckboxOnToggled(checkbox, c_callback, data)

    return c_callback


# - int uiCheckboxChecked(uiCheckbox *c); 
开发者ID:joaoventura,项目名称:pylibui,代码行数:21,代码来源:checkbox.py

示例10: uiComboboxOnSelected

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def uiComboboxOnSelected(combobox, callback, data):
    """
    Executes a callback function when an item selected.

    :param combobox: uiCombobox
    :param callback: function
    :param data: data
    :return: reference to C callback function
    """

    c_type = ctypes.CFUNCTYPE(
        ctypes.c_int, ctypes.POINTER(uiCombobox), ctypes.c_void_p)
    c_callback = c_type(callback)

    clibui.uiComboboxOnSelected(combobox, c_callback, data)

    return c_callback 
开发者ID:joaoventura,项目名称:pylibui,代码行数:19,代码来源:combobox.py

示例11: uiSliderOnChanged

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def uiSliderOnChanged(slider, callback, data):
    """
    Executes the callback function on value changed.

    :param slider: uiSlider
    :param callback: function
    :param data: data
    :return: reference to C callback function
    """
    c_type = ctypes.CFUNCTYPE(
        ctypes.c_int, ctypes.POINTER(uiSlider), ctypes.c_void_p)
    c_callback = c_type(callback)

    clibui.uiSliderOnChanged(slider, c_callback, data)

    return c_callback


# - uiSlider *uiNewSlider(int min, int max); 
开发者ID:joaoventura,项目名称:pylibui,代码行数:21,代码来源:slider.py

示例12: __init__

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def __init__(self, master):
            try:
                sys.frozen	# don't want to try updating python.exe
                self.updater = ctypes.cdll.WinSparkle
                self.updater.win_sparkle_set_appcast_url(update_feed)	# py2exe won't let us embed this in resources

                # set up shutdown callback
                global root
                root = master
                self.callback_t = ctypes.CFUNCTYPE(None)	# keep reference
                self.callback_fn = self.callback_t(shutdown_request)
                self.updater.win_sparkle_set_shutdown_request_callback(self.callback_fn)

                self.updater.win_sparkle_init()

            except:
                from traceback import print_exc
                print_exc()
                self.updater = None 
开发者ID:EDCD,项目名称:EDMarketConnector,代码行数:21,代码来源:update.py

示例13: ENepanet

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def ENepanet(self,nomeinp, nomerpt='', nomebin='', vfunc=None):
        """Runs a complete EPANET simulation.

        Arguments:
        nomeinp: name of the input file
        nomerpt: name of an output report file
        nomebin: name of an optional binary output file
        vfunc  : pointer to a user-supplied function which accepts a character string as its argument."""  
        if vfunc is not None:
            CFUNC = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_char_p)
            callback= CFUNC(vfunc)
        else:
            callback= None
        ierr= self._lib.EN_epanet(self.ph, ctypes.c_char_p(nomeinp.encode()), 
                            ctypes.c_char_p(nomerpt.encode()), 
                            ctypes.c_char_p(nomebin.encode()), 
                            callback)
        if ierr!=0: raise ENtoolkitError(self, ierr) 
开发者ID:Vitens,项目名称:epynet,代码行数:20,代码来源:epanet2.py

示例14: add_method

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def add_method(cls_name, selector_name, fn, type_encoding):
    cls = ObjCClass(cls_name).ptr

    selector = sel(selector_name)

    if c.class_getInstanceMethod(cls, selector):
        error('Failed to add method, class {} already provides method {}'.format(cls_name, selector_name))
        return

    parsed_types = parse_types(type_encoding)
    restype = parsed_types[0]
    argtypes = parsed_types[1]

    IMPTYPE = CFUNCTYPE(restype, *argtypes)
    imp = IMPTYPE(fn)
    retain_global(imp)

    did_add = c.class_addMethod(cls, selector, imp, c_char_p(type_encoding.encode('utf-8')))
    if not did_add:
        error('Failed to add class method')

    return did_add 
开发者ID:zrzka,项目名称:blackmamba,代码行数:24,代码来源:runtime.py

示例15: __init__

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import CFUNCTYPE [as 别名]
def __init__(self, block_ptr, restype=None, argtypes=None):
        self._block_ptr = block_ptr
        self._block = cast(self._block_ptr, POINTER(_Block))

        if not argtypes:
            argtypes = []

        if self._regular_calling_convention():
            # First arg is pointer to block, hide it from user
            argtypes.insert(0, c_void_p)

        if self._has_signature():
            # TODO - Validate restype & argtypes against signature
            #      - Signature is not always populated
            pass

        self._func = None

        if self._regular_calling_convention():
            IMPTYPE = CFUNCTYPE(restype, *argtypes)
            self._func = IMPTYPE(self._block.contents.invoke) 
开发者ID:zrzka,项目名称:blackmamba,代码行数:23,代码来源:runtime.py


注:本文中的ctypes.CFUNCTYPE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。