Changeset 205 for trunk/python/pyregfi/structures.py
- Timestamp:
- 08/23/10 11:51:56 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/pyregfi/structures.py
r204 r205 6 6 import ctypes 7 7 import ctypes.util 8 from ctypes import c_char,c_int,c_uint8,c_uint16,c_uint32,c_uint64,c_int64,POINTER,c_void_p,c_char_p 9 10 11 class REGFI_RAW_FILE(ctypes.Structure): 8 from ctypes import * 9 10 # XXX: can we always be sure enums are this size? 11 REGFI_ENCODING = c_uint32 12 REGFI_DATA_TYPE = c_uint32 13 14 15 # Prototype everything first so we don't have to worry about reference order 16 class REGFI_NTTIME(Structure): 17 pass 18 19 class REGFI_VK(Structure): 20 pass 21 22 class REGFI_SK(Structure): 23 pass 24 25 class REGFI_SUBKEY_LIST(Structure): 26 pass 27 28 class REGFI_VALUE_LIST(Structure): 29 pass 30 31 class REGFI_CLASSNAME(Structure): 32 pass 33 34 class REGFI_DATA(Structure): 35 pass 36 37 class REGFI_NK(Structure): 38 pass 39 40 class REGFI_ITERATOR(Structure): 41 pass 42 43 class REGFI_FILE(Structure): 44 pass 45 46 class REGFI_RAW_FILE(Structure): 12 47 fh = None 13 48 … … 18 53 traceback.print_exc() 19 54 # XXX: os.EX_IOERR may not be available on Windoze 20 ctypes.set_errno(os.EX_IOERR)55 set_errno(os.EX_IOERR) 21 56 return -1 22 57 … … 28 63 # XXX: anyway to do a readinto() here? 29 64 tmp = self.fh.read(count) 30 ctypes.memmove(buf,tmp,len(tmp))65 memmove(buf,tmp,len(tmp)) 31 66 32 67 except Exception: 33 68 traceback.print_exc() 34 69 # XXX: os.EX_IOERR may not be available on Windoze 35 ctypes.set_errno(os.EX_IOERR)70 set_errno(os.EX_IOERR) 36 71 return -1 37 72 return len(tmp) 38 73 39 74 40 41 75 # XXX: how can we know for sure the size of off_t and size_t? 42 seek_cb_type = ctypes.CFUNCTYPE(c_int64, POINTER(REGFI_RAW_FILE), c_uint64, c_int, use_errno=True) 43 read_cb_type = ctypes.CFUNCTYPE(c_int64, POINTER(REGFI_RAW_FILE), POINTER(c_char), c_uint64, use_errno=True) 76 seek_cb_type = CFUNCTYPE(c_int64, POINTER(REGFI_RAW_FILE), c_uint64, c_int, use_errno=True) 77 read_cb_type = CFUNCTYPE(c_int64, POINTER(REGFI_RAW_FILE), POINTER(c_char), c_uint64, use_errno=True) 78 79 80 REGFI_NTTIME._fields_ = [('low', c_uint32), 81 ('high', c_uint32)] 82 83 REGFI_VK._fields_ = [('offset', c_uint32), 84 ('cell_size', c_uint32), 85 ('valuename', c_char_p), 86 ('valuename_raw', POINTER(c_char)), 87 ('name_length', c_uint16), 88 ('hbin_off', c_uint32), 89 ('data_size', c_uint32), 90 ('data_off', c_uint32), 91 ('type', REGFI_DATA_TYPE), 92 ('magic', c_char * 2), 93 ('flags', c_uint16), 94 ('unknown1', c_uint16), 95 ('data_in_offset', c_bool), 96 ] 97 98 99 REGFI_SK._fields_ = [('offset', c_uint32), 100 ('cell_size', c_uint32), 101 ('sec_desc', c_void_p), #XXX 102 ('hbin_off', c_uint32), 103 ('prev_sk_off', c_uint32), 104 ('next_sk_off', c_uint32), 105 ('ref_count', c_uint32), 106 ('desc_size', c_uint32), 107 ('unknown_tag', c_uint16), 108 ('magic', c_char * 2), 109 ] 110 111 112 REGFI_NK._fields_ = [('offset', c_uint32), 113 ('cell_size', c_uint32), 114 ('values', POINTER(REGFI_VALUE_LIST)), 115 ('subkeys', POINTER(REGFI_SUBKEY_LIST)), 116 ('flags', c_uint16), 117 ('magic', c_char * 2), 118 ('mtime', REGFI_NTTIME), 119 ('name_length', c_uint16), 120 ('classname_length', c_uint16), 121 ('keyname', c_char_p), 122 ('keyname_raw', POINTER(c_char)), 123 ('parent_off', c_uint32), 124 ('classname_off', c_uint32), 125 ('max_bytes_subkeyname', c_uint32), 126 ('max_bytes_subkeyclassname', c_uint32), 127 ('max_bytes_valuename', c_uint32), 128 ('max_bytes_value', c_uint32), 129 ('unknown1', c_uint32), 130 ('unknown2', c_uint32), 131 ('unknown3', c_uint32), 132 ('unk_index', c_uint32), 133 ('num_subkeys', c_uint32), 134 ('subkeys_off', c_uint32), 135 ('num_values', c_uint32), 136 ('values_off', c_uint32), 137 ('sk_off', c_uint32), 138 ] 139 140 141 REGFI_SUBKEY_LIST._fields_ = [('offset', c_uint32), 142 ('cell_size', c_uint32), 143 ('num_children', c_uint32), 144 ('num_keys', c_uint32), 145 ('elements', c_void_p), 146 ('magic', c_char * 2), 147 ('recursive_type', c_bool), 148 ] 149 150 151 REGFI_VALUE_LIST._fields_ = [('offset', c_uint32), 152 ('cell_size', c_uint32), 153 ('num_children', c_uint32), 154 ('num_values', c_uint32), 155 ('elements', c_void_p), 156 ] 157 158 REGFI_CLASSNAME._fields_ = [('offset', c_uint32), 159 ('interpreted', c_char_p), 160 ('raw', POINTER(c_char)), 161 ('size', c_uint16), 162 ] 163 164 165 class REGFI_DATA__interpreted(Union): 166 _fields_ = [('none',POINTER(c_char)), 167 ('string', c_char_p), 168 ('expand_string', c_char_p), 169 ('binary',POINTER(c_char)), 170 ('dword', c_uint32), 171 ('dword_be', c_uint32), 172 ('link', c_char_p), 173 ('multiple_string', POINTER(c_char_p)), 174 ('qword', c_uint64), 175 ('resource_list',POINTER(c_char)), 176 ('full_resource_descriptor',POINTER(c_char)), 177 ('resource_requirements_list',POINTER(c_char)), 178 ] 179 REGFI_DATA._fields_ = [('offset', c_uint32), 180 ('type', REGFI_DATA_TYPE), 181 ('size', c_uint32), 182 ('raw', POINTER(c_char)), 183 ('interpreted_size', c_uint32), 184 ('interpreted', REGFI_DATA__interpreted), 185 ] 186 187 188 REGFI_FILE._fields_ = [('magic', c_char * 4), 189 ('sequence1', c_uint32), 190 ('sequence2', c_uint32), 191 ('mtime', REGFI_NTTIME), 192 ('major_version', c_uint32), 193 ('minor_version', c_uint32), 194 ('type', c_uint32), 195 ('format', c_uint32), 196 ('root_cell', c_uint32), 197 ('last_block', c_uint32), 198 ('cluster', c_uint32), 199 ] 44 200 45 201 … … 50 206 ('state', c_void_p), 51 207 ] 52 53 54 class REGFI_FILE(ctypes.Structure):55 _fields_ = [('magic', c_char * 4),56 ('sequence1', c_uint32),57 ('sequence2', c_uint32),58 ('mtime', c_uint64),59 ('major_version', c_uint32),60 ('minor_version', c_uint32),61 ('type', c_uint32),62 ('format', c_uint32),63 ('root_cell', c_uint32),64 ('last_block', c_uint32),65 ('cluster', c_uint32),66 ]67 68 69
Note: See TracChangeset
for help on using the changeset viewer.