Changeset 216


Ignore:
Timestamp:
03/28/11 23:54:37 (13 years ago)
Author:
tim
Message:

added a new testcase to the smoketest for data attributes
fixed data naming issues in pyregfi

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • test/pyregfi-smoketest.py

    r215 r216  
    3131# Gathers various (meaningless) statistics to exercise simple attribute access
    3232# and to hopefully smoke out any bugs that can be identified by changing stats
    33 def iterTally(hive):
     33def iterTallyNames(hive):
    3434    key_count = 0
    3535    key_lens = 0
     
    7777
    7878
     79# Uses the HiveIterator to walk all keys
     80# Gathers various (meaningless) statistics about data/data_raw attributes
     81def iterTallyData(hive):
     82    data_stat = 0.0
     83    dataraw_stat = 0.0
     84   
     85    for k in hive:
     86        for v in k.values:
     87            d = v.data
     88            if d == None:
     89                data_stat += 0.1
     90            elif hasattr(d, "__len__"):
     91                data_stat += len(d)
     92            else:
     93                data_stat += d/2.0**64
     94
     95            d = v.data_raw
     96            if d == None:
     97                dataraw_stat += 0.1
     98            else:
     99                dataraw_stat += len(d)
     100
     101    print("  Data stat: %f" % data_stat)
     102    print("  Raw data stat: %f" % dataraw_stat)
     103
     104
     105
    79106if len(sys.argv) < 2:
    80107    usage()
     
    82109
    83110
    84 tests = [("iterTally",iterTally),("iterParentWalk",iterParentWalk),]
     111#tests = [("iterTallyNames",iterTallyNames),("iterParentWalk",iterParentWalk),]
     112tests = [("iterTallyData",iterTallyData),]
    85113
    86114files = []
  • trunk/python/pyregfi/__init__.py

    r215 r216  
    249249            name = create_string_buffer(bytes(name))
    250250
    251         if self._find_element(self._hive.file, self._key.base, name, byref(index)):
     251        if self._find_element(self._hive.file, self._key._base, name, byref(index)):
    252252            return self._constructor(self._hive,
    253253                                     self._get_element(self._hive.file,
    254                                                        self._key.base,
     254                                                       self._key._base,
    255255                                                       index))
    256256        raise KeyError('')
     
    343343        ret_val = None
    344344        if name == "data":
    345             data_p = regfi.regfi_fetch_data(self._hive.file, self.base)
     345            data_p = regfi.regfi_fetch_data(self._hive.file, self._base)
    346346            try:
    347347                data_struct = data_p.contents
     
    373373        elif name == "data_raw":
    374374            # XXX: should we load the data without interpretation instead?
    375             data_p = regfi.regfi_fetch_data(self._hive.file, self.base)
     375            data_p = regfi.regfi_fetch_data(self._hive.file, self._base)
    376376            try:
    377377                data_struct = data_p.contents
     
    381381            ret_val = _buffer2bytearray(data_struct.raw,
    382382                                        data_struct.size)
    383             regfi.regfi_free_record(data_p)           
     383            regfi.regfi_free_record(data_p)
    384384           
    385385        else:
Note: See TracChangeset for help on using the changeset viewer.