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


Python ctypes.c_ulong方法代码示例

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


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

示例1: windowsRam

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def windowsRam(self):
        """
        Uses Windows API to check RAM
        """
        kernel32 = ctypes.windll.kernel32
        c_ulong = ctypes.c_ulong

        class MEMORYSTATUS(ctypes.Structure):
            _fields_ = [
                ("dwLength", c_ulong),
                ("dwMemoryLoad", c_ulong),
                ("dwTotalPhys", c_ulong),
                ("dwAvailPhys", c_ulong),
                ("dwTotalPageFile", c_ulong),
                ("dwAvailPageFile", c_ulong),
                ("dwTotalVirtual", c_ulong),
                ("dwAvailVirtual", c_ulong)
            ]

        memoryStatus = MEMORYSTATUS()
        memoryStatus.dwLength = ctypes.sizeof(MEMORYSTATUS)
        kernel32.GlobalMemoryStatus(ctypes.byref(memoryStatus))

        return int(memoryStatus.dwTotalPhys / 1024 ** 2) 
开发者ID:mbusb,项目名称:multibootusb,代码行数:26,代码来源:gen.py

示例2: getChannelData_Chan_No_On_Card

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def getChannelData_Chan_No_On_Card(self, channel):
        """Get the channel number on the card.
        Retrieves the channel number, as numbered locally on the card, device
        connected to channel.
        Args:
            channel (int): The channel you are interested in
        Returns:
            number (int): The local channel number
        """
        self.fn = inspect.currentframe().f_code.co_name
        number = ct.c_ulong()
        self.dll.canGetChannelData(channel,
                                   canCHANNELDATA_CHAN_NO_ON_CARD,
                                   ct.byref(number), ct.sizeof(number))
        buf_type = ct.c_uint * 1
        buf = buf_type()
        self.dll.canGetChannelData(channel,
                                   canCHANNELDATA_CHAN_NO_ON_CARD,
                                   ct.byref(buf), ct.sizeof(buf))
        return number.value 
开发者ID:diyjac,项目名称:Udacity-SDC-Radar-Driver-Micro-Challenge,代码行数:22,代码来源:canlib.py

示例3: getChannelData_CardNumber

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def getChannelData_CardNumber(self, channel):
        """Get the card number
        Retrieves the card's number in the computer. Each card type is numbered
        separately. For example, the first PCIEcan card in a machine will have
        number 0, the second PCIEcan number 1, etc.
        Args:
            channel (int): The channel you are interested in
        Returns:
            card_number (int): The device's card number
        """
        self.fn = inspect.currentframe().f_code.co_name
        buf_type = ct.c_ulong
        buf = buf_type()
        self.dll.canGetChannelData(channel,
                                   canCHANNELDATA_CARD_NUMBER,
                                   ct.byref(buf), ct.sizeof(buf))
        return buf.value 
开发者ID:diyjac,项目名称:Udacity-SDC-Radar-Driver-Micro-Challenge,代码行数:19,代码来源:canlib.py

示例4: getChannelData_EAN

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def getChannelData_EAN(self, channel):
        """Get EAN code
        Retrieves the EAN number for the device connected to channel. If there
        is no EAN number, "00-00000-00000-0" will be returned.
        Args:
            channel (int): The channel you are interested in
        Returns:
            ean (str): The device's EAN number
        """
        self.fn = inspect.currentframe().f_code.co_name
        buf_type = ct.c_ulong * 2
        buf = buf_type()
        self.dll.canGetChannelData(channel,
                                   canCHANNELDATA_CARD_UPC_NO,
                                   ct.byref(buf), ct.sizeof(buf))
        (ean_lo, ean_hi) = struct.unpack('LL', buf)

        return "%02x-%05x-%05x-%x" % (ean_hi >> 12,
                                      ((ean_hi & 0xfff) << 8) | (ean_lo >> 24),
                                      (ean_lo >> 4) & 0xfffff, ean_lo & 0xf) 
开发者ID:diyjac,项目名称:Udacity-SDC-Radar-Driver-Micro-Challenge,代码行数:22,代码来源:canlib.py

示例5: getChannelData_EAN_short

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def getChannelData_EAN_short(self, channel):
        """Get short EAN code
        Retrieves the short EAN number, aka product number, for the device
        connected to channel. If there is no EAN number, "00000-0" will be
        returned.
        Args:
            channel (int): The channel you are interested in
        Returns:
            ean (str): The device's shortened EAN number
        """
        self.fn = inspect.currentframe().f_code.co_name
        buf_type = ct.c_ulong * 2
        buf = buf_type()
        self.dll.canGetChannelData(channel,
                                   canCHANNELDATA_CARD_UPC_NO,
                                   ct.byref(buf), ct.sizeof(buf))
        (ean_lo, ean_hi) = struct.unpack('LL', buf)
        return "%04x-%x" % ((ean_lo >> 4) & 0xffff, ean_lo & 0xf) 
开发者ID:diyjac,项目名称:Udacity-SDC-Radar-Driver-Micro-Challenge,代码行数:20,代码来源:canlib.py

示例6: getChannelData_Serial

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def getChannelData_Serial(self, channel):
        """Get device serial number
        Retrieves the serial number for the device connected to channel. If the
        device does not have a serial number, 0 is returned.
        Args:
            channel (int): The channel you are interested in
        Returns:
            serial (int): The device serial number
        """
        self.fn = inspect.currentframe().f_code.co_name
        buf_type = ct.c_ulong * 2
        buf = buf_type()
        self.dll.canGetChannelData(channel,
                                   canCHANNELDATA_CARD_SERIAL_NO,
                                   ct.byref(buf), ct.sizeof(buf))
        (serial_lo, serial_hi) = struct.unpack('LL', buf)
        # serial_hi is always 0
        return serial_lo 
开发者ID:diyjac,项目名称:Udacity-SDC-Radar-Driver-Micro-Challenge,代码行数:20,代码来源:canlib.py

示例7: enum_pids

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def enum_pids():
	
	max_array = c_ulong * 4096 # define long array to capture all the processes
	pProcessIds = max_array() # array to store the list of processes
	pBytesReturned = c_ulong() # the number of bytes returned in the array
	#EnumProcess 
	res = EnumProcesses(
		ctypes.byref(pProcessIds),
		ctypes.sizeof(pProcessIds),
		ctypes.byref(pBytesReturned)
	)
	if res == 0:
		logging.error(WinError(get_last_error()))
		return []
  
	# get the number of returned processes
	nReturned = int(pBytesReturned.value/ctypes.sizeof(c_ulong()))
	return [i for i in pProcessIds[:nReturned]]
	
#https://msdn.microsoft.com/en-us/library/windows/desktop/ms683217(v=vs.85).aspx 
开发者ID:skelsec,项目名称:minidump,代码行数:22,代码来源:createminidump.py

示例8: _migrate_page_call

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def _migrate_page_call(pid, max_node, old_nodes, new_node) -> int:
    """Wrapper on migrate_pages function using libc syscall"""

    pid = int(pid)
    max = ctypes.c_ulong(max_node + 1)
    old = ctypes.pointer(ctypes.c_ulong(old_nodes))
    new = ctypes.pointer(ctypes.c_ulong(new_node))

    # Example memory_migrate(256, pid, 5, 13 -> b'1101', 2 -> b'0010')
    result = LIBC.syscall(NR_MIGRATE_PAGES, pid, max, old, new)

    if result == -1:
        errno = ctypes.get_errno()
        raise UnableToMigratePages('Unable to migrate pages: {}, {}.'
                                   .format(errno, os.strerror(errno)))
    log.log(TRACE, 'Number of not moved pages (return from migrate_pages syscall): %d', result)
    return result 
开发者ID:intel,项目名称:workload-collocation-agent,代码行数:19,代码来源:cgroups_allocations.py

示例9: get_curr_window

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def get_curr_window():
		user32 = ctypes.windll.user32
		kernel32 = ctypes.windll.kernel32
		hwnd = user32.GetForegroundWindow()
		pid = ctypes.c_ulong(0)
		user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
		process_id = "%d" % pid.value
		executable = ctypes.create_string_buffer(512)
		h_process = kernel32.OpenProcess(0x400 | 0x10, False, pid)
		ctypes.windll.psapi.GetModuleBaseNameA(h_process, None, ctypes.byref(executable), 512)
		window_title = ctypes.create_string_buffer(512)
		length = user32.GetWindowTextA(hwnd, ctypes.byref(window_title), 512)
		pid_info = "\n[ PID %s - %s - %s ]" % (process_id, executable.value, window_title.value)
		kernel32.CloseHandle(hwnd)
		kernel32.CloseHandle(h_process)
		return pid_info 
开发者ID:mvrozanti,项目名称:RAT-via-Telegram,代码行数:18,代码来源:RATAttack.py

示例10: set_color

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def set_color(fg_col, bg_col):
    global last_fg_col
    global last_bg_col
    if fg_col == last_fg_col and bg_col == last_bg_col:
        return
    last_fg_col = fg_col
    last_bg_col = bg_col
    if is_windows:
        # convert from (rgb+2) to bgr
        fg_col = rgb3_to_bgr3(fg_col-2)
        bg_col = rgb3_to_bgr3(bg_col-2)
        col_attr = fg_col | (bg_col << 4)
        stdout_handle = ctypes.windll.kernel32.GetStdHandle(ctypes.c_ulong(-11))
        ctypes.windll.kernel32.SetConsoleTextAttribute(stdout_handle, col_attr)
    else:
        color = str(fg_col + 28)
        sys.stdout.write('\x1b['+color+'m')
        color = str(bg_col + 38)
        sys.stdout.write('\x1b['+color+'m')

# TODO: any other encodings to check for? 
开发者ID:theinternetftw,项目名称:xyppy,代码行数:23,代码来源:term.py

示例11: getch_impl

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def getch_impl():
    # TODO: This windows impl keeps pipes/redirects from working. Need ReadFile for that,
    # with more complicated handling (personally, I'm just going to keep using unix/cygwin
    # for pipe-y debug stuff...)
    # TODO: Windows escape seqs via ReadConsoleInput, convert to VT100 seqs for more commonality.
    if is_windows:
        stdin_handle = ctypes.windll.kernel32.GetStdHandle(ctypes.c_ulong(-10))
        one_char_buf = ctypes.c_uint32()
        chars_read = ctypes.c_uint32()
        # NOTE: W version of this function == ERROR_NOACCESS after text color set in photopia!?
        result = ctypes.windll.kernel32.ReadConsoleA(stdin_handle,
                                                     ctypes.byref(one_char_buf),
                                                     1,
                                                     ctypes.byref(chars_read),
                                                     0)

        if result == 0 or chars_read.value != 1:
            last_err = ctypes.windll.kernel32.GetLastError()
            print('LAST ERR', last_err)
            err('failed to read console')

        return chr(one_char_buf.value)
    else: #Unix
        return sys.stdin.read(1) 
开发者ID:theinternetftw,项目名称:xyppy,代码行数:26,代码来源:term.py

示例12: getWindowByPID

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def getWindowByPID(self, pid, order=0):
        """ Returns a handle for the first window that matches the provided PID """
        if pid <= 0:
            return None
        EnumWindowsProc = ctypes.WINFUNCTYPE(
            ctypes.c_bool,
            ctypes.POINTER(ctypes.c_int),
            ctypes.py_object)
        def callback(hwnd, context):
            if ctypes.windll.user32.IsWindowVisible(hwnd):
                pid = ctypes.c_ulong()
                ctypes.windll.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
                if context["pid"] == int(pid.value) and not context["handle"]:
                    if context["order"] > 0:
                        context["order"] -= 1
                    else:
                        context["handle"] = hwnd
            return True
        data = {"pid": pid, "handle": None, "order": order}
        ctypes.windll.user32.EnumWindows(EnumWindowsProc(callback), ctypes.py_object(data))
        return data["handle"] 
开发者ID:glitchassassin,项目名称:lackey,代码行数:23,代码来源:PlatformManagerWindows.py

示例13: execute

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def execute(self, window):
        # Ensure that the primary mouse button is the *left* button before
        # sending events.
        primary_changed = windll.user32.SwapMouseButton(0)

        # Prepare and send the mouse events.
        zero = pointer(c_ulong(0))
        inputs = [MouseInput(0, 0, flag[1], flag[0], 0, zero)
                  for flag in self._flags]
        array = make_input_array(inputs)
        send_input_array(array)

        # Swap the primary mouse button back if it was previously set to
        # *right*.
        if primary_changed:
            windll.user32.SwapMouseButton(1) 
开发者ID:dictation-toolbox,项目名称:dragonfly,代码行数:18,代码来源:_win32.py

示例14: OpenDynamicChannel

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def OpenDynamicChannel(self, channelname, priority):
		# C+Python = OMG...
		global pywintypes
		import ctypes.wintypes
		import ctypes
		import pywintypes
		import win32api

		wts = ctypes.windll.LoadLibrary("Wtsapi32.dll")

		hWTSHandle = wts.WTSVirtualChannelOpenEx(0xFFFFFFFF, channelname, 0x00000001 | priority)
		if not hWTSHandle:
			common.internal_print("Opening channel failed: {0}".format(win32api.GetLastError()), -1)
			return None

		WTSVirtualFileHandle = 1
		vcFileHandlePtr = ctypes.pointer(ctypes.c_int())
		length = ctypes.c_ulong(0)

		if not wts.WTSVirtualChannelQuery(hWTSHandle, WTSVirtualFileHandle, ctypes.byref(vcFileHandlePtr), ctypes.byref(length)):
			wts.WTSVirtualChannelClose(hWTSHandle)
			common.internal_print("Channel query: {0}".format(win32api.GetLastError()), -1)
			return None

		common.internal_print("Connected to channel: {0}".format(channelname))

		return pywintypes.HANDLE(vcFileHandlePtr.contents.value) 
开发者ID:earthquake,项目名称:XFLTReaT,代码行数:29,代码来源:RDP.py

示例15: MAKELONG

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ulong [as 别名]
def MAKELONG(a,b): return (ctypes.c_ulong)(((a)&0xffff)|((b)<<16)) 
开发者ID:Wyliodrin,项目名称:pybass,代码行数:3,代码来源:pybass.py


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