Python ctypes.c_uint64() Examples
The following are 30
code examples of ctypes.c_uint64().
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 also want to check out all available functions/classes of the module
ctypes
, or try the search function
.
Example #1
Source File: windows.py From BoomER with GNU General Public License v3.0 | 6 votes |
def process_is_wow64(handle=None): """ Determine whether the process associated with the handle is running in WOW64 or not. :param int handle: A handle to the process to check. :return: Whether the process is running in WOW64 or not. :rtype: bool """ if not hasattr(ctypes.windll.kernel32, 'IsWow64Process'): return False if platform.architecture()[0] == '64bit': ctypes.windll.kernel32.IsWow64Process.argtypes = [ctypes.c_uint64, ctypes.POINTER(ctypes.c_bool)] handle = (handle or -1) is_wow64 = ctypes.c_bool() if not ctypes.windll.kernel32.IsWow64Process(handle, ctypes.byref(is_wow64)): raise WindowsProcessError('Error: IsWow64Process', get_last_error=ctypes.windll.kernel32.GetLastError()) return is_wow64.value
Example #2
Source File: leveldb.py From MCEdit-Unified with ISC License | 6 votes |
def approximateDiskSizes(self, *ranges): if self._snapshot is not None: raise TypeError("cannot calculate disk sizes on leveldb snapshot") assert len(ranges) > 0 key_type = ctypes.c_void_p * len(ranges) len_type = ctypes.c_size_t * len(ranges) start_keys, start_lens = key_type(), len_type() end_keys, end_lens = key_type(), len_type() sizes = (ctypes.c_uint64 * len(ranges))() for i, range_ in enumerate(ranges): assert isinstance(range_, tuple) and len(range_) == 2 assert isinstance(range_[0], str) and isinstance(range_[1], str) start_keys[i] = ctypes.cast(range_[0], ctypes.c_void_p) end_keys[i] = ctypes.cast(range_[1], ctypes.c_void_p) start_lens[i], end_lens[i] = len(range_[0]), len(range_[1]) _ldb.leveldb_approximate_sizes(self._db.ref, len(ranges), start_keys, start_lens, end_keys, end_lens, sizes) return list(sizes)
Example #3
Source File: additional_api.py From reapy with MIT License | 6 votes |
def MIDI_GetTrackHash(p0, p1, p2, p3): a = _RPR._ft['MIDI_GetTrackHash'] f = ct.CFUNCTYPE(ct.c_byte, ct.c_uint64, ct.c_byte, ct.c_char_p, ct.c_int)(a) t = (_RPR.rpr_packp('MediaTrack*', p0), ct.c_byte(p1), packs_l(p2), ct.c_int(p3)) r = f(t[0], t[1], t[2], t[3]) return (r, p0, p1, unpacks_l(t[2]), p3) # def RPR_MIDI_InsertCC(p0, p1, p2, p3, p4, p5, p6, p7): # a = _ft['MIDI_InsertCC'] # f = CFUNCTYPE( # c_byte, c_uint64, c_byte, c_byte, c_double, c_int, c_int, c_int, c_int # )(a) # t = ( # rpr_packp('MediaItem_Take*', p0), c_byte(p1), c_byte(p2), c_double(p3), # c_int(p4), c_int(p5), c_int(p6), c_int(p7) # ) # r = f(t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7]) # return r
Example #4
Source File: messages.py From olympe with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _ar_arsdk_encode_type_info(cls, ar_argtype): arsdk_encode_type_info_map = { arsdkparser.ArArgType.I8: (od.ARSDK_ARG_TYPE_I8, "i8", ctypes.c_int8), arsdkparser.ArArgType.U8: (od.ARSDK_ARG_TYPE_U8, "u8", ctypes.c_uint8), arsdkparser.ArArgType.I16: (od.ARSDK_ARG_TYPE_I16, "i16", ctypes.c_int16), arsdkparser.ArArgType.U16: (od.ARSDK_ARG_TYPE_U16, "u16", ctypes.c_uint16), arsdkparser.ArArgType.I32: (od.ARSDK_ARG_TYPE_I32, "i32", ctypes.c_int32), arsdkparser.ArArgType.U32: (od.ARSDK_ARG_TYPE_U32, "u32", ctypes.c_uint32), arsdkparser.ArArgType.I64: (od.ARSDK_ARG_TYPE_I64, "i64", ctypes.c_int64), arsdkparser.ArArgType.U64: (od.ARSDK_ARG_TYPE_U64, "u64", ctypes.c_uint64), arsdkparser.ArArgType.FLOAT: (od.ARSDK_ARG_TYPE_FLOAT, "f32", ctypes.c_float), arsdkparser.ArArgType.DOUBLE: (od.ARSDK_ARG_TYPE_DOUBLE, "f64", ctypes.c_double), arsdkparser.ArArgType.STRING: (od.ARSDK_ARG_TYPE_STRING, "cstr", od.char_pointer_cast), arsdkparser.ArArgType.ENUM: (od.ARSDK_ARG_TYPE_ENUM, "i32", ctypes.c_int32), } return arsdk_encode_type_info_map[ar_argtype]
Example #5
Source File: dbginterface.py From LKD with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get_modules(self): """Return a list of (currModuleName, currImageName, currLoadedImageName)""" self.reload("") currModuleName = (c_char * 1024)() currImageName = (c_char * 1024)() currLoadedImageName = (c_char * 1024)() currModuleNameSize = DWORD(0) currImageNameSize = DWORD(0) currLoadedImageNameSize = DWORD(0) currModuleBase = ULONG64(0) numModulesLoaded = DWORD(0) numModulesUnloaded = DWORD(0) self.DebugSymbols.GetNumberModules(byref(numModulesLoaded), byref(numModulesUnloaded)) res = [] for i in range(numModulesLoaded.value): self.DebugSymbols.GetModuleByIndex(i, byref(currModuleBase)) self.DebugSymbols.GetModuleNames(i, c_uint64(currModuleBase.value), byref(currImageName), 1023, byref(currImageNameSize), byref(currModuleName), 1023, byref(currModuleNameSize), byref(currLoadedImageName), 1023, byref(currLoadedImageNameSize)) # Removing trailing \x00 res.append((currModuleName[:currModuleNameSize.value - 1], currImageName[:currImageNameSize.value - 1], currLoadedImageName[:currLoadedImageNameSize.value - 1])) return res
Example #6
Source File: dbginterface.py From LKD with BSD 3-Clause "New" or "Revised" License | 6 votes |
def write_virtual_memory(self, addr, data): """Write data to a given virtual address :param addr: The Symbol to write to :type addr: Symbol :param size: The Data to write :type size: str or ctypes.Structure :returns: the size written -- :class:`int` """ try: # ctypes structure size = ctypes.sizeof(data) buffer = ctypes.byref(data) except TypeError: # buffer size = len(data) buffer = data written = ULONG(0) addr = self.resolve_symbol(addr) self.DebugDataSpaces.WriteVirtual(c_uint64(addr), buffer, size, byref(written)) return written.value
Example #7
Source File: nifpga.py From nifpga-python with MIT License | 6 votes |
def _return_ctype(self): """ Returns the associated ctype of a given datatype. """ _datatype_ctype = { DataType.Bool: ctypes.c_uint8, DataType.I8: ctypes.c_int8, DataType.U8: ctypes.c_uint8, DataType.I16: ctypes.c_int16, DataType.U16: ctypes.c_uint16, DataType.I32: ctypes.c_int32, DataType.U32: ctypes.c_uint32, DataType.I64: ctypes.c_int64, DataType.U64: ctypes.c_uint64, DataType.Sgl: ctypes.c_float, DataType.Dbl: ctypes.c_double, DataType.Fxp: ctypes.c_uint32, DataType.Cluster: ctypes.c_uint32, } return _datatype_ctype[self]
Example #8
Source File: leveldb.py From opsbro with MIT License | 6 votes |
def approximateDiskSizes(self, *ranges): if self._snapshot is not None: raise TypeError("cannot calculate disk sizes on leveldb snapshot") assert len(ranges) > 0 key_type = ctypes.c_void_p * len(ranges) len_type = ctypes.c_size_t * len(ranges) start_keys, start_lens = key_type(), len_type() end_keys, end_lens = key_type(), len_type() sizes = (ctypes.c_uint64 * len(ranges))() for i, range_ in enumerate(ranges): assert isinstance(range_, tuple) and len(range_) == 2 assert isinstance(range_[0], str) and isinstance(range_[1], str) start_keys[i] = ctypes.cast(range_[0], ctypes.c_void_p) end_keys[i] = ctypes.cast(range_[1], ctypes.c_void_p) start_lens[i], end_lens[i] = len(range_[0]), len(range_[1]) _ldb.leveldb_approximate_sizes(self._db.ref, len(ranges), start_keys, start_lens, end_keys, end_lens, sizes) return list(sizes)
Example #9
Source File: leveldb.py From leveldb-py with MIT License | 6 votes |
def approximateDiskSizes(self, *ranges): if self._snapshot is not None: raise TypeError("cannot calculate disk sizes on leveldb snapshot") assert len(ranges) > 0 key_type = ctypes.c_void_p * len(ranges) len_type = ctypes.c_size_t * len(ranges) start_keys, start_lens = key_type(), len_type() end_keys, end_lens = key_type(), len_type() sizes = (ctypes.c_uint64 * len(ranges))() for i, range_ in enumerate(ranges): assert isinstance(range_, tuple) and len(range_) == 2 assert isinstance(range_[0], str) and isinstance(range_[1], str) start_keys[i] = ctypes.cast(range_[0], ctypes.c_void_p) end_keys[i] = ctypes.cast(range_[1], ctypes.c_void_p) start_lens[i], end_lens[i] = len(range_[0]), len(range_[1]) _ldb.leveldb_approximate_sizes(self._db.ref, len(ranges), start_keys, start_lens, end_keys, end_lens, sizes) return list(sizes)
Example #10
Source File: leveldb.py From GDMC with ISC License | 6 votes |
def approximateDiskSizes(self, *ranges): if self._snapshot is not None: raise TypeError("cannot calculate disk sizes on leveldb snapshot") assert len(ranges) > 0 key_type = ctypes.c_void_p * len(ranges) len_type = ctypes.c_size_t * len(ranges) start_keys, start_lens = key_type(), len_type() end_keys, end_lens = key_type(), len_type() sizes = (ctypes.c_uint64 * len(ranges))() for i, range_ in enumerate(ranges): assert isinstance(range_, tuple) and len(range_) == 2 assert isinstance(range_[0], str) and isinstance(range_[1], str) start_keys[i] = ctypes.cast(range_[0], ctypes.c_void_p) end_keys[i] = ctypes.cast(range_[1], ctypes.c_void_p) start_lens[i], end_lens[i] = len(range_[0]), len(range_[1]) _ldb.leveldb_approximate_sizes(self._db.ref, len(ranges), start_keys, start_lens, end_keys, end_lens, sizes) return list(sizes)
Example #11
Source File: windows.py From mayhem with BSD 3-Clause "New" or "Revised" License | 6 votes |
def allocate_null_page(size=0x1000): address = ctypes.c_void_p(1) if platform.architecture()[0] == '64bit': page_size = ctypes.c_uint64() else: page_size = ctypes.c_uint32() page_size.value = size result = m_ntdll.NtAllocateVirtualMemory( -1, ctypes.byref(address), 0, ctypes.byref(page_size), flags('MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN'), flags('PAGE_EXECUTE_READWRITE') ) return result == 0
Example #12
Source File: darwin.py From goreviewpartner with GNU General Public License v3.0 | 6 votes |
def _set_restypes(self): # type: () -> None """ Functions return type. """ self.core.CGGetActiveDisplayList.restype = ctypes.c_int32 self.core.CGDisplayBounds.restype = CGRect self.core.CGRectStandardize.restype = CGRect self.core.CGRectUnion.restype = CGRect self.core.CGDisplayRotation.restype = ctypes.c_float self.core.CGWindowListCreateImage.restype = ctypes.c_void_p self.core.CGImageGetWidth.restype = ctypes.c_size_t self.core.CGImageGetHeight.restype = ctypes.c_size_t self.core.CGImageGetDataProvider.restype = ctypes.c_void_p self.core.CGDataProviderCopyData.restype = ctypes.c_void_p self.core.CFDataGetBytePtr.restype = ctypes.c_void_p self.core.CFDataGetLength.restype = ctypes.c_uint64 self.core.CGImageGetBytesPerRow.restype = ctypes.c_size_t self.core.CGImageGetBitsPerPixel.restype = ctypes.c_size_t self.core.CGDataProviderRelease.restype = ctypes.c_void_p self.core.CFRelease.restype = ctypes.c_void_p
Example #13
Source File: utils.py From debin with Apache License 2.0 | 6 votes |
def adapt_int_width(n, width, signed=True): n = int(n) if width == 1: result = n elif width == 2: result = n elif width == 4: result = ctypes.c_int8(n).value if signed else ctypes.c_uint8(n).value elif width == 8: result = ctypes.c_int8(n).value if signed else ctypes.c_uint8(n).value elif width == 16: result = ctypes.c_int16(n).value if signed else ctypes.c_uint16(n).value elif width == 32: result = ctypes.c_int32(n).value if signed else ctypes.c_uint32(n).value elif width == 64: result = ctypes.c_int64(n).value if signed else ctypes.c_uint64(n).value else: result = n return result
Example #14
Source File: dbginterface.py From LKD with BSD 3-Clause "New" or "Revised" License | 6 votes |
def write_physical_memory(self, addr, data): """Write data to a given physical address :param addr: The Symbol to write to :type addr: Symbol :param size: The Data to write :type size: str or ctypes.Structure :returns: the size written -- :class:`int` """ try: # ctypes structure size = ctypes.sizeof(data) buffer = ctypes.byref(data) except TypeError: # buffer size = len(data) buffer = data written = ULONG(0) self.DebugDataSpaces.WritePhysical(c_uint64(addr), buffer, size, byref(written)) return written.value
Example #15
Source File: psrdada.py From bifrost with BSD 3-Clause "New" or "Revised" License | 5 votes |
def open(self): nbyte = ctypes.c_uint64() #print '>ipcbuf_get_next_read' ptr = _dada.ipcbuf_get_next_read(self.buf, nbyte) nbyte = nbyte.value block_id = 0 return ptr, nbyte, block_id
Example #16
Source File: ramcloud.py From dragonflow with Apache License 2.0 | 5 votes |
def ping(self, serviceLocator, nonce, nanoseconds): result = ctypes.c_uint64() s = so.rc_ping(self.client, serviceLocator, nonce, nanoseconds, ctypes.byref(result)) self.handle_error(s) return result
Example #17
Source File: test_nifpga.py From nifpga-python with MIT License | 5 votes |
def raise_an_exception(): """ A helper for NiFpgaStatusExceptionTest """ session = ctypes.c_int32(0x0000beef) fifo = ctypes.c_uint32(0x0000f1f0) data = ctypes.c_uint64(0x0000da7a) number_of_elements = ctypes.c_size_t(0x100) timeout_ms = ctypes.c_size_t(0x200) elements_remaining = ctypes.c_size_t(0x300) bogus_string_argument = ctypes.c_char_p(b"I am a string") exception = nifpga.FifoTimeoutError( function_name="Dummy Function Name", argument_names=["session", "fifo", "data", "number of elements", "timeout ms", "elements remaining", "a bogus string argument"], function_args=(session, fifo, data, number_of_elements, timeout_ms, elements_remaining, bogus_string_argument)) raise exception
Example #18
Source File: utilities.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def calcHash(self, buf): #buf = b"\x61\x24\x7f\xbf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" buf = list(bytearray(buf)) #print buf num_bytes = len(buf) array_type = ctypes.c_ubyte * num_bytes data = self._hash_lib.compute_hash(array_type(*buf), ctypes.c_uint32(num_bytes)); #print data return ctypes.c_uint64(data).value
Example #19
Source File: additional_api.py From reapy with MIT License | 5 votes |
def packp(t, v): m = re.match('^\((\w+\*|HWND)\)0x([0-9A-F]+)$', str(v)) if (m != None): (_t, _v) = m.groups() if (_t == t or t == 'void*'): a = int(_v[:8], 16) b = int(_v[8:], 16); p = ct.c_uint64((a << 32) | b).value # if (RPR_ValidatePtr(p,t)): # return p return p return 0
Example #20
Source File: nifpga.py From nifpga-python with MIT License | 5 votes |
def _return_ctype(self): """ Returns the associated ctype of a given property type. """ _propertyType_ctype = { FifoPropertyType.I32: ctypes.c_int32, FifoPropertyType.U32: ctypes.c_uint32, FifoPropertyType.I64: ctypes.c_int64, FifoPropertyType.U64: ctypes.c_uint64, FifoPropertyType.Ptr: ctypes.c_void_p } return _propertyType_ctype[self]
Example #21
Source File: ramcloud.py From dragonflow with Apache License 2.0 | 5 votes |
def get_table_id(self, name): handle = ctypes.c_uint64() s = so.rc_getTableId(self.client, name, ctypes.byref(handle)) self.handle_error(s) return handle.value
Example #22
Source File: ramcloud.py From dragonflow with Apache License 2.0 | 5 votes |
def delete_rr(self, table_id, id, reject_rules): got_version = ctypes.c_uint64() self.hook() s = so.rc_remove(self.client, table_id, get_key(id), get_keyLength(id), ctypes.byref(reject_rules), ctypes.byref(got_version)) self.handle_error(s, got_version.value) return got_version.value
Example #23
Source File: additional_api.py From reapy with MIT License | 5 votes |
def ValidatePtr2(p0, p1, p2): a = _RPR._ft['ValidatePtr2'] f = ct.CFUNCTYPE(ct.c_byte, ct.c_uint64, ct.c_uint64, ct.c_char_p)(a) project = _RPR.rpr_packp('ReaProject*', p0) pointer = ct.c_uint64(p1) name = _RPR.rpr_packsc(p2) return f(project, pointer, name)
Example #24
Source File: osx.py From luci-py with Apache License 2.0 | 5 votes |
def get_physical_ram(): """Returns the amount of installed RAM in Mb, rounded to the nearest number. """ CTL_HW = 6 HW_MEMSIZE = 24 result = ctypes.c_uint64(0) _sysctl(CTL_HW, HW_MEMSIZE, result) return int(round(result.value / 1024. / 1024.))
Example #25
Source File: io.py From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 | 5 votes |
def getindex(self): index_size = ctypes.c_uint64(0) index_data = ctypes.POINTER(ctypes.c_uint64)() check_call(_LIB.MXDataIterGetIndex(self.handle, ctypes.byref(index_data), ctypes.byref(index_size))) if index_size.value: address = ctypes.addressof(index_data.contents) dbuffer = (ctypes.c_uint64* index_size.value).from_address(address) np_index = np.frombuffer(dbuffer, dtype=np.uint64) return np_index.copy() else: return None
Example #26
Source File: _sendfile.py From Flask-P2P with MIT License | 5 votes |
def sendfile(fdout, fdin, offset, nbytes): if sys.platform == 'darwin': _sendfile.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint64), ctypes.c_voidp, ctypes.c_int] _nbytes = ctypes.c_uint64(nbytes) result = _sendfile(fdin, fdout, offset, _nbytes, None, 0) if result == -1: e = ctypes.get_errno() if e == errno.EAGAIN and _nbytes.value is not None: return _nbytes.value raise OSError(e, os.strerror(e)) return _nbytes.value elif sys.platform in ('freebsd', 'dragonfly',): _sendfile.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_uint64, ctypes.c_uint64, ctypes.c_voidp, ctypes.POINTER(ctypes.c_uint64), ctypes.c_int] _sbytes = ctypes.c_uint64() result = _sendfile(fdin, fdout, offset, nbytes, None, _sbytes, 0) if result == -1: e = ctypes.get_errno() if e == errno.EAGAIN and _sbytes.value is not None: return _sbytes.value raise OSError(e, os.strerror(e)) return _sbytes.value else: _sendfile.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.POINTER(ctypes.c_uint64), ctypes.c_size_t] _offset = ctypes.c_uint64(offset) sent = _sendfile(fdout, fdin, _offset, nbytes) if sent == -1: e = ctypes.get_errno() raise OSError(e, os.strerror(e)) return sent
Example #27
Source File: io.py From mxnet-lambda with Apache License 2.0 | 5 votes |
def getindex(self): index_size = ctypes.c_uint64(0) index_data = ctypes.POINTER(ctypes.c_uint64)() check_call(_LIB.MXDataIterGetIndex(self.handle, ctypes.byref(index_data), ctypes.byref(index_size))) if index_size.value: address = ctypes.addressof(index_data.contents) dbuffer = (ctypes.c_uint64* index_size.value).from_address(address) np_index = np.frombuffer(dbuffer, dtype=np.uint64) return np_index.copy() else: return None
Example #28
Source File: io.py From SNIPER-mxnet with Apache License 2.0 | 5 votes |
def getindex(self): index_size = ctypes.c_uint64(0) index_data = ctypes.POINTER(ctypes.c_uint64)() check_call(_LIB.MXDataIterGetIndex(self.handle, ctypes.byref(index_data), ctypes.byref(index_size))) if index_size.value: address = ctypes.addressof(index_data.contents) dbuffer = (ctypes.c_uint64* index_size.value).from_address(address) np_index = np.frombuffer(dbuffer, dtype=np.uint64) return np_index.copy() else: return None
Example #29
Source File: instruction.py From Zvm with Apache License 2.0 | 5 votes |
def execute(self, frame): val2 = frame.operand_stack.pop_long() val1 = frame.operand_stack.pop_long() s = val2 & 0x3f val = ctypes.c_uint64(val1).value res = ctypes.c_int64(val >> s).value frame.operand_stack.push_int(res)
Example #30
Source File: atapt.py From atapt with MIT License | 5 votes |
def doSgio(self): fd = os.open(self.dev, os.O_RDWR) startTime = time.time() io_result = libc.ioctl(fd, SG_IO, ctypes.c_uint64(ctypes.addressof(self.sgio))) os.close(fd) if io_result != 0: raise sgioFalied("fcntl.ioctl falied") self.duration = (time.time() - startTime) * 1000