Changeset 252 for trunk/python
- Timestamp:
- 05/08/11 13:33:49 (14 years ago)
- Location:
- trunk/python/pyregfi
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/pyregfi/__init__.py
r233 r252 174 174 i = 0 175 175 s = chars_pointer[i] 176 while s != None:176 while s: 177 177 ret_val.append(s.decode('utf-8', 'replace')) 178 178 i += 1 … … 180 180 181 181 return ret_val 182 182 183 183 184 … … 316 317 raise Exception("Could not create _GenericList; key is NULL." 317 318 + "Current log:\n" + getLogMessages()) 318 319 if not regfi.regfi_reference_record(key._hive.file, key._base): 319 320 base = regfi.regfi_reference_record(key._hive.file, key._base) 321 if not base: 320 322 raise Exception("Could not create _GenericList; memory error." 321 323 + "Current log:\n" + getLogMessages()) 322 self._key_base = key._base324 self._key_base = cast(base, type(key._base)) 323 325 self._length = self._fetch_num(self._key_base) 324 326 self._hive = key._hive … … 461 463 ret_val = super(Key, self).__getattr__(name) 462 464 463 if ret_val == None:465 if not ret_val: 464 466 ret_val = self.name_raw 465 467 else: … … 624 626 ret_val = super(Value, self).__getattr__(name) 625 627 if name == "name": 626 if ret_val == None:628 if not ret_val: 627 629 ret_val = self.name_raw 628 630 else: … … 984 986 return ret_val 985 987 986 987 988 ## Traverse downward multiple levels 988 989 # … … 996 997 997 998 self._lock.acquire() 998 result = regfi.regfi_iterator_ walk_path(self._iter, cpath)999 result = regfi.regfi_iterator_descend(self._iter, cpath) 999 1000 self._lock.release() 1000 1001 if not result: 1001 1002 # XXX: Use non-generic exception 1002 1003 raise Exception('Could not locate path.\n'+getLogMessages()) 1004 1005 ## Obtains a list of the current key's ancestry 1006 # 1007 # @return A list of all parent keys starting with the root Key and ending 1008 # with the current Key 1009 def ancestry(self): 1010 self._lock.acquire() 1011 result = regfi.regfi_iterator_ancestry(self._iter) 1012 self._lock.release() 1013 1014 ret_val = [] 1015 i = 0 1016 k = result[i] 1017 while k: 1018 k = cast(regfi.regfi_reference_record(self._hive.file, k), POINTER(REGFI_NK)) 1019 ret_val.append(Key(self._hive, k)) 1020 i += 1 1021 k = result[i] 1022 1023 regfi.regfi_free_record(self._hive.file, result) 1024 return ret_val 1025 1026 ## Obtains the current path of the iterator 1027 # 1028 # @return A list of key names starting with the root up to and 1029 # including the current key 1030 # 1031 def current_path(self): 1032 ancestry = self.ancestry() 1033 return [str(a.name) for a in ancestry] 1003 1034 1004 1035 -
trunk/python/pyregfi/structures.py
r233 r252 20 20 21 21 REGFI_DATA_TYPE = c_uint32 22 22 REGFI_NTTIME = c_uint64 23 23 24 24 # Prototype everything first so we don't have to worry about reference order 25 class REGFI_NTTIME(Structure):26 pass27 28 25 class REGFI_VK(Structure): 29 26 pass … … 97 94 read_cb_type = CB_FACTORY(c_int64, POINTER(REGFI_RAW_FILE), POINTER(c_char), c_size_t, use_errno=True) 98 95 99 100 REGFI_NTTIME._fields_ = [('low', c_uint32),101 ('high', c_uint32)]102 96 103 97 REGFI_VK._fields_ = [('offset', c_uint32), … … 253 247 254 248 regfi.regfi_reference_record.argtypes = [POINTER(REGFI_FILE), c_void_p] 255 regfi.regfi_reference_record.restype = c_ bool249 regfi.regfi_reference_record.restype = c_void_p 256 250 257 251 regfi.regfi_fetch_num_subkeys.argtypes = [POINTER(REGFI_NK)] … … 307 301 regfi.regfi_iterator_to_root.restype = c_bool 308 302 309 regfi.regfi_iterator_ walk_path.argtypes = [POINTER(REGFI_ITERATOR), POINTER(c_char_p)]310 regfi.regfi_iterator_ walk_path.restype = c_bool303 regfi.regfi_iterator_descend.argtypes = [POINTER(REGFI_ITERATOR), POINTER(c_char_p)] 304 regfi.regfi_iterator_descend.restype = c_bool 311 305 312 306 regfi.regfi_iterator_cur_key.argtypes = [POINTER(REGFI_ITERATOR)] … … 337 331 regfi.regfi_iterator_find_value.restype = c_bool 338 332 333 regfi.regfi_iterator_ancestry.argtypes = [POINTER(REGFI_ITERATOR)] 334 regfi.regfi_iterator_ancestry.restype = POINTER(POINTER(REGFI_NK)) 339 335 340 336 regfi.regfi_init.argtypes = []
Note: See TracChangeset
for help on using the changeset viewer.