Changeset 213 for trunk/python
- Timestamp:
- 03/25/11 11:48:27 (14 years ago)
- Location:
- trunk/python/pyregfi
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/pyregfi/__init__.py
r212 r213 15 15 16 16 17 regfi.regfi_alloc.argtypes = [c_int ]17 regfi.regfi_alloc.argtypes = [c_int, REGFI_ENCODING] 18 18 regfi.regfi_alloc.restype = POINTER(REGFI_FILE) 19 19 20 regfi.regfi_alloc_cb.argtypes = [POINTER(REGFI_RAW_FILE) ]20 regfi.regfi_alloc_cb.argtypes = [POINTER(REGFI_RAW_FILE), REGFI_ENCODING] 21 21 regfi.regfi_alloc_cb.restype = POINTER(REGFI_FILE) 22 22 … … 140 140 s = chars_pointer[i] 141 141 while s != None: 142 ret_val.append(s.decode('utf-8' ))142 ret_val.append(s.decode('utf-8', 'replace')) 143 143 i += 1 144 144 s = chars_pointer[i] … … 150 150 # access to base structures 151 151 class _StructureWrapper(object): 152 153 152 hive = None 154 153 base = None … … 161 160 def __del__(self): 162 161 regfi.regfi_free_record(self.base) 162 hive = None 163 163 164 164 def __getattr__(self, name): … … 205 205 self.length = self.fetch_num(key.base) 206 206 207 def __del__(self): 208 self.key = None 209 207 210 def __len__(self): 208 211 return self.length … … 274 277 ret_val = self.name_raw 275 278 else: 276 ret_val = ret_val.decode('utf-8' )279 ret_val = ret_val.decode('utf-8', 'replace') 277 280 278 281 elif name == "name_raw": … … 307 310 elif data_struct.type in (REG_SZ, REG_EXPAND_SZ, REG_LINK): 308 311 # Unicode strings 309 ret_val = data_struct.interpreted.string.decode('utf-8' )312 ret_val = data_struct.interpreted.string.decode('utf-8', 'replace') 310 313 elif data_struct.type in (REG_DWORD, REG_DWORD_BE): 311 314 # 32 bit integers … … 343 346 ret_val = self.name_raw 344 347 else: 345 ret_val = ret_val.decode('utf-8' )348 ret_val = ret_val.decode('utf-8', 'replace') 346 349 347 350 elif name == "name_raw": … … 370 373 try: 371 374 if hasattr(fh, 'fileno'): 372 self.file = regfi.regfi_alloc(fh.fileno() )375 self.file = regfi.regfi_alloc(fh.fileno(), REGFI_ENCODING_UTF8) 373 376 return 374 377 except: … … 379 382 self.raw_file.seek = seek_cb_type(self.raw_file.cb_seek) 380 383 self.raw_file.read = read_cb_type(self.raw_file.cb_read) 381 self.file = regfi.regfi_alloc_cb(self.raw_file )384 self.file = regfi.regfi_alloc_cb(self.raw_file, REGFI_ENCODING_UTF8) 382 385 383 386 def __getattr__(self, name): … … 387 390 regfi.regfi_free(self.file) 388 391 if self.raw_file != None: 389 regfi.regfi_free(self.file) 390 392 self.raw_file = None 391 393 392 394 def __iter__(self): … … 421 423 422 424 def __init__(self, hive): 423 # REGFI_ENCODING_UTF8==1 424 self.iter = regfi.regfi_iterator_new(hive.file, 1) 425 self.iter = regfi.regfi_iterator_new(hive.file, REGFI_ENCODING_UTF8) 425 426 if self.iter == None: 426 427 raise Exception("Could not create iterator. Current log:\n" … … 432 433 433 434 def __del__(self): 434 regfi.regfi_iterator_free(self.iter) 435 regfi.regfi_iterator_free(self.iter) 435 436 436 437 def __iter__(self): … … 440 441 def __next__(self): 441 442 if self.iteration_root == None: 442 self.iteration_root = self.current_key() 443 self.iteration_root = self.current_key() 443 444 elif not regfi.regfi_iterator_down(self.iter): 444 445 up_ret = regfi.regfi_iterator_up(self.iter) -
trunk/python/pyregfi/structures.py
r209 r213 10 10 # XXX: can we always be sure enums are this size? 11 11 REGFI_ENCODING = c_uint32 12 REGFI_ENCODING_UTF8 = 1 13 12 14 REGFI_DATA_TYPE = c_uint32 13 15
Note: See TracChangeset
for help on using the changeset viewer.