Exemplo n.º 1
0
#u16  DLL_SPEC token_obj_get_id(const struct token_obj *);
DLL.token_obj_get_id.argtypes = [ctypes.POINTER(Token)]
DLL.token_obj_get_id.restype = ctypes.c_uint16

#int  DLL_SPEC token_obj_get_type(const struct token_obj *);
DLL.token_obj_get_type.argtypes = [ctypes.POINTER(Token)]
DLL.token_obj_get_type.restype = ctypes.c_int

#bool  DLL_SPEC token_obj_is_bool(const struct token_obj *);
DLL.token_obj_is_bool.argtypes = [ctypes.POINTER(Token)]
DLL.token_obj_is_bool.restype = ctypes.c_bool

#bool  DLL_SPEC token_obj_is_active(const struct token_obj *);
DLL.token_obj_is_active.argtypes = [ctypes.POINTER(Token)]
DLL.token_obj_is_active.restype = ctypes.c_int
DLL.token_obj_is_active.errcheck = errorOnNegativeFN(
    lambda r, f, a: TokenManipulationFailure(_obj_strerror(a[0])))

#int  DLL_SPEC token_obj_activate(const struct token_obj *);
DLL.token_obj_activate.argtypes = [ctypes.POINTER(Token)]
DLL.token_obj_activate.restype = ctypes.c_int
DLL.token_obj_activate.errcheck = errorOnNegativeFN(
    lambda r, f, a: TokenManipulationFailure(_obj_strerror(a[0])))

#bool  DLL_SPEC token_obj_is_string(const struct token_obj *);
DLL.token_obj_is_string.argtypes = [ctypes.POINTER(Token)]
DLL.token_obj_is_string.restype = ctypes.c_bool

decorate(traceLog())


def customFree(result, func, args):
Exemplo n.º 2
0
#u8 DLL_SPEC smbios_struct_get_type(const struct smbios_struct *);
DLL.smbios_struct_get_type.argtypes = [ ctypes.POINTER(SmbiosStructure) ]
DLL.smbios_struct_get_type.restype = ctypes.c_uint8

#u8 DLL_SPEC smbios_struct_get_length(const struct smbios_struct *);
DLL.smbios_struct_get_length.argtypes = [ ctypes.POINTER(SmbiosStructure) ]
DLL.smbios_struct_get_length.restype = ctypes.c_uint8

#u16 DLL_SPEC smbios_struct_get_handle(const struct smbios_struct *);
DLL.smbios_struct_get_handle.argtypes = [ ctypes.POINTER(SmbiosStructure) ]
DLL.smbios_struct_get_handle.restype = ctypes.c_uint16

#const char * DLL_SPEC smbios_struct_get_string_from_offset(const struct smbios_struct *s, u8 offset);
DLL.smbios_struct_get_string_from_offset.argtypes = [ ctypes.POINTER(SmbiosStructure), ctypes.c_uint8 ]
DLL.smbios_struct_get_string_from_offset.restype = ctypes.c_char_p
DLL.smbios_struct_get_string_from_offset.errcheck = errorOnNullPtrFN(lambda r,f,a: exceptions.IndexError( _("String from offset %d doesnt exist") % a[1]))

#const char * DLL_SPEC smbios_struct_get_string_number(const struct smbios_struct *s, u8 which);
DLL.smbios_struct_get_string_number.argtypes = [ ctypes.POINTER(SmbiosStructure), ctypes.c_uint8 ]
DLL.smbios_struct_get_string_number.restype = ctypes.c_char_p
DLL.smbios_struct_get_string_number.errcheck = errorOnNullPtrFN(lambda r,f,a: exceptions.IndexError( _("String number %d doesnt exist") % a[1]))

#int DLL_SPEC smbios_struct_get_data(const struct smbios_struct *s, void *dest, u8 offset, size_t len);
DLL.smbios_struct_get_data.argtypes = [ ctypes.POINTER(SmbiosStructure), ctypes.c_void_p, ctypes.c_uint8, ctypes.c_size_t ]
DLL.smbios_struct_get_data.restype = ctypes.c_int
DLL.smbios_struct_get_data.errcheck = errorOnNegativeFN(lambda r,f,a: exceptions.IndexError( _("Tried to get data past the end of the structure.") ))



Exemplo n.º 3
0
    return Exception(DLL.memory_obj_strerror(obj))

#struct memory_access_obj *memory_obj_factory(int flags, ...);
# dont define argtypes because this is a varargs function...
#DLL.memory_obj_factory.argtypes = [ctypes.c_int, ]
DLL.memory_obj_factory.restype = ctypes.POINTER(_MemoryAccess)
DLL.memory_obj_factory.errcheck = errorOnNullPtrFN(lambda r,f,a: _strerror(r))

#void memory_obj_free(struct memory_access_obj *);
DLL.memory_obj_free.argtypes = [ ctypes.POINTER(_MemoryAccess) ]
DLL.memory_obj_free.restype = None

#int  memory_obj_read(const struct memory_access_obj *, void *buffer, u64 offset, size_t length);
DLL.memory_obj_read.argtypes = [ ctypes.POINTER(_MemoryAccess), ctypes.c_void_p, ctypes.c_uint64, ctypes.c_size_t ]
DLL.memory_obj_read.restype = ctypes.c_int
DLL.memory_obj_read.errcheck = errorOnNegativeFN(lambda r,f,a: _strerror(a[0]))

#int  memory_obj_write(const struct memory_access_obj *, void *buffer, u64 offset, size_t length);
DLL.memory_obj_write.argtypes = [ ctypes.POINTER(_MemoryAccess), ctypes.c_void_p, ctypes.c_uint64, ctypes.c_size_t ]
DLL.memory_obj_write.restype = ctypes.c_int
DLL.memory_obj_write.errcheck = errorOnNegativeFN(lambda r,f,a: _strerror(a[0]))

#s64  memory_obj_search(const struct memory_access_obj *, const char *pat, size_t patlen, u64 start, u64 end, u64 stride);
DLL.memory_obj_search.argtypes = [ ctypes.POINTER(_MemoryAccess), ctypes.c_char_p, ctypes.c_size_t, ctypes.c_uint64, ctypes.c_uint64, ctypes.c_uint64 ]
DLL.memory_obj_search.restype = ctypes.c_int64
DLL.memory_obj_search.errcheck = errorOnNegativeFN(lambda r,f,a: _strerror(a[0]))

#void  memory_obj_suggest_leave_open(struct memory_access_obj *);
DLL.memory_obj_suggest_leave_open.argtypes = [ ctypes.POINTER(_MemoryAccess), ]
DLL.memory_obj_suggest_leave_open.restype = None
Exemplo n.º 4
0
_mk_simple_sysinfo_str_fn("get_property_ownership_tag")

decorate(traceLog())


def set_service_tag(newtag, pass_ascii=None, pass_scancode=None):
    return DLL.sysinfo_set_service_tag(newtag, pass_ascii, pass_scancode)


__all__.append("set_service_tag")

DLL.sysinfo_set_asset_tag.argtypes = [
    ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p
]
DLL.sysinfo_set_asset_tag.restype = ctypes.c_int
DLL.sysinfo_set_asset_tag.errcheck = errorOnNegativeFN(
    lambda r, f, a: _strerror())
decorate(traceLog())


def set_asset_tag(newtag, pass_ascii=None, pass_scancode=None):
    return DLL.sysinfo_set_asset_tag(newtag, pass_ascii, pass_scancode)


__all__.append("set_asset_tag")

DLL.sysinfo_set_property_ownership_tag.argtypes = [
    ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p
]
DLL.sysinfo_set_property_ownership_tag.restype = ctypes.c_int
DLL.sysinfo_set_property_ownership_tag.errcheck = errorOnNegativeFN(
    lambda r, f, a: _strerror())
Exemplo n.º 5
0
_mk_simple_sysinfo_str_fn("get_system_name")
_mk_simple_sysinfo_str_fn("get_vendor_name")
_mk_simple_sysinfo_str_fn("get_bios_version")
_mk_simple_sysinfo_str_fn("get_asset_tag")
_mk_simple_sysinfo_str_fn("get_service_tag")
_mk_simple_sysinfo_str_fn("get_property_ownership_tag")

decorate(traceLog())
def set_service_tag(newtag, pass_ascii=None, pass_scancode=None):
    return DLL.sysinfo_set_service_tag(newtag, pass_ascii, pass_scancode)
__all__.append("set_service_tag")

DLL.sysinfo_set_asset_tag.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p]
DLL.sysinfo_set_asset_tag.restype = ctypes.c_int
DLL.sysinfo_set_asset_tag.errcheck=errorOnNegativeFN(lambda r,f,a: _strerror())
decorate(traceLog())
def set_asset_tag(newtag, pass_ascii=None, pass_scancode=None):
    return DLL.sysinfo_set_asset_tag(newtag, pass_ascii, pass_scancode)
__all__.append("set_asset_tag")

DLL.sysinfo_set_property_ownership_tag.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p]
DLL.sysinfo_set_property_ownership_tag.restype = ctypes.c_int
DLL.sysinfo_set_property_ownership_tag.errcheck=errorOnNegativeFN(lambda r,f,a: _strerror())
decorate(traceLog())
def set_property_ownership_tag(newtag, pass_ascii=None, pass_scancode=None):
    return DLL.sysinfo_set_property_ownership_tag(newtag, pass_ascii, pass_scancode)
__all__.append("set_property_ownership_tag")

if __name__ == "__main__":
    exitRet = 0
Exemplo n.º 6
0
#DLL.cmos_obj_factory.argtypes = [ctypes.c_int, ]
DLL.cmos_obj_factory.restype = ctypes.POINTER(_CmosAccess)
DLL.cmos_obj_factory.errcheck = errorOnNullPtrFN(lambda r, f, a: _strerror(r))

#void   cmos_obj_free(struct cmos_access_obj *);
DLL.cmos_obj_free.argtypes = [ctypes.POINTER(_CmosAccess)]
DLL.cmos_obj_free.restype = None

#int     cmos_obj_read_byte(const struct cmos_access_obj *, u8 *byte, u32 indexPort, u32 dataPort, u32 offset);
DLL.cmos_obj_read_byte.argtypes = [
    ctypes.POINTER(_CmosAccess),
    ctypes.POINTER(ctypes.c_uint8), ctypes.c_uint32, ctypes.c_uint32,
    ctypes.c_uint32
]
DLL.cmos_obj_read_byte.restype = ctypes.c_int
DLL.cmos_obj_read_byte.errcheck = errorOnNegativeFN(_strerror)

#int    cmos_obj_write_byte(const struct cmos_access_obj *, u8 byte,  u32 indexPort, u32 dataPort, u32 offset);
DLL.cmos_obj_write_byte.argtypes = [
    ctypes.POINTER(_CmosAccess), ctypes.c_uint8, ctypes.c_uint32,
    ctypes.c_uint32, ctypes.c_uint32
]
DLL.cmos_obj_write_byte.restype = ctypes.c_int
DLL.cmos_obj_write_byte.errcheck = errorOnNegativeFN(_strerror)

#// useful for checksums, etc
#typedef int (*cmos_write_callback)(const struct cmos_access_obj *, bool, void *);
WRITE_CALLBACK = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.POINTER(_CmosAccess),
                                  ctypes.c_bool, ctypes.c_void_p)
FREE_CALLBACK = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
Exemplo n.º 7
0
DLL.smbios_struct_get_handle.argtypes = [ctypes.POINTER(SmbiosStructure)]
DLL.smbios_struct_get_handle.restype = ctypes.c_uint16

#const char * DLL_SPEC smbios_struct_get_string_from_offset(const struct smbios_struct *s, u8 offset);
DLL.smbios_struct_get_string_from_offset.argtypes = [
    ctypes.POINTER(SmbiosStructure), ctypes.c_uint8
]
DLL.smbios_struct_get_string_from_offset.restype = ctypes.c_char_p
DLL.smbios_struct_get_string_from_offset.errcheck = errorOnNullPtrFN(
    lambda r, f, a: exceptions.IndexError(
        _("String from offset %d doesnt exist") % a[1]))

#const char * DLL_SPEC smbios_struct_get_string_number(const struct smbios_struct *s, u8 which);
DLL.smbios_struct_get_string_number.argtypes = [
    ctypes.POINTER(SmbiosStructure), ctypes.c_uint8
]
DLL.smbios_struct_get_string_number.restype = ctypes.c_char_p
DLL.smbios_struct_get_string_number.errcheck = errorOnNullPtrFN(
    lambda r, f, a: exceptions.IndexError(
        _("String number %d doesnt exist") % a[1]))

#int DLL_SPEC smbios_struct_get_data(const struct smbios_struct *s, void *dest, u8 offset, size_t len);
DLL.smbios_struct_get_data.argtypes = [
    ctypes.POINTER(SmbiosStructure), ctypes.c_void_p, ctypes.c_uint8,
    ctypes.c_size_t
]
DLL.smbios_struct_get_data.restype = ctypes.c_int
DLL.smbios_struct_get_data.errcheck = errorOnNegativeFN(
    lambda r, f, a: exceptions.IndexError(
        _("Tried to get data past the end of the structure.")))
Exemplo n.º 8
0
#DLL.memory_obj_factory.argtypes = [ctypes.c_int, ]
DLL.memory_obj_factory.restype = ctypes.POINTER(_MemoryAccess)
DLL.memory_obj_factory.errcheck = errorOnNullPtrFN(
    lambda r, f, a: _strerror(r))

#void memory_obj_free(struct memory_access_obj *);
DLL.memory_obj_free.argtypes = [ctypes.POINTER(_MemoryAccess)]
DLL.memory_obj_free.restype = None

#int  memory_obj_read(const struct memory_access_obj *, void *buffer, u64 offset, size_t length);
DLL.memory_obj_read.argtypes = [
    ctypes.POINTER(_MemoryAccess), ctypes.c_void_p, ctypes.c_uint64,
    ctypes.c_size_t
]
DLL.memory_obj_read.restype = ctypes.c_int
DLL.memory_obj_read.errcheck = errorOnNegativeFN(
    lambda r, f, a: _strerror(a[0]))

#int  memory_obj_write(const struct memory_access_obj *, void *buffer, u64 offset, size_t length);
DLL.memory_obj_write.argtypes = [
    ctypes.POINTER(_MemoryAccess), ctypes.c_void_p, ctypes.c_uint64,
    ctypes.c_size_t
]
DLL.memory_obj_write.restype = ctypes.c_int
DLL.memory_obj_write.errcheck = errorOnNegativeFN(
    lambda r, f, a: _strerror(a[0]))

#s64  memory_obj_search(const struct memory_access_obj *, const char *pat, size_t patlen, u64 start, u64 end, u64 stride);
DLL.memory_obj_search.argtypes = [
    ctypes.POINTER(_MemoryAccess), ctypes.c_char_p, ctypes.c_size_t,
    ctypes.c_uint64, ctypes.c_uint64, ctypes.c_uint64
]
Exemplo n.º 9
0

# define type that can be used for arg/res:  u32 arg[4]
array_4_u32 = ctypes.c_int32 * 4

# define strerror first so we can use it in error checking other functions.
DLL.dell_smi_strerror.argtypes = [ ]
DLL.dell_smi_strerror.restype = ctypes.c_char_p
decorate(traceLog())
def _strerror():
    return DLL.dell_smi_strerror()

#void dell_simple_ci_smi(u16 smiClass, u16 select, const u32 args[4], u32 res[4]);
DLL.dell_simple_ci_smi.argtypes = [ctypes.c_uint16, ctypes.c_uint16, array_4_u32, array_4_u32]
DLL.dell_simple_ci_smi.restype = ctypes.c_int
DLL.dell_simple_ci_smi.errcheck = errorOnNegativeFN(lambda r,f,a: SMIExecutionError(_strerror()))
decorate(traceLog())
def simple_ci_smi(smiClass, select, *args):
    arg = array_4_u32(*args)
    res = array_4_u32(0, 0, 0, 0)
    DLL.dell_simple_ci_smi(smiClass, select, arg, res)
    return [ i for i in res ]
__all__.append("simple_ci_smi")

#int dell_smi_read_nv_storage         (u32 location, u32 *minValue, u32 *maxValue);
DLL.dell_smi_read_nv_storage.errcheck = errorOnNegativeFN(lambda r,f,a: SMIExecutionError(_strerror()))
DLL.dell_smi_read_nv_storage.restype = ctypes.c_int
DLL.dell_smi_read_nv_storage.argtypes = [
        ctypes.c_uint32,
        ctypes.POINTER(ctypes.c_uint32),
        ctypes.POINTER(ctypes.c_uint32),