當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。