Changeset 225
- Timestamp:
- 04/05/11 11:17:41 (14 years ago)
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
SConstruct
r222 r225 33 33 34 34 win32_cmds=''' 35 rm -rf .release && mkdir -p .release/%s 35 rm -rf .release && mkdir -p .release/%s/python/pyregfi 36 36 cp %s/src/*.exe .release/%s 37 38 cp %s/pyregfi-distutils.py .release/%s/setup.py 39 cp %s/python/pyregfi/*.py .release/%s/python/pyregfi 40 37 41 cp win32/libiconv/bin/*.dll win32/libpthreads/bin/*.dll win32/libtalloc/bin/*.dll trunk/lib/*.dll .release/%s 38 42 cd .release && zip -r %s.zip %s … … 113 117 [input_prefix+'src/reglookup-recover.c']+extra_obj) 114 118 115 ret_val += win32_cmds % (t_base,input_prefix, 119 ret_val += win32_cmds % (t_base,input_prefix,t_base,input_prefix, 120 t_base,input_prefix, 116 121 t_base,t_base,t_base,t_base,t_base) 117 122 -
test/pyregfi-smoketest.py
r224 r225 3 3 import sys 4 4 import gc 5 import io 5 6 import time 6 7 import pyregfi 8 7 9 8 10 def usage(): … … 15 17 # Gathers various (meaningless) statistics to exercise simple attribute access 16 18 # and to hopefully smoke out any bugs that can be identified by changing stats 17 def iterTallyNames(hive ):19 def iterTallyNames(hive, fh): 18 20 key_count = 0 19 21 key_lens = 0 … … 60 62 # to find the same key again, verifying it is the same. This test is currently 61 63 # very slow because no key caching is used. 62 def iterParentWalk(hive ):64 def iterParentWalk(hive, fh): 63 65 i = 1 64 66 for k in hive: … … 77 79 # Uses the HiveIterator to walk all keys 78 80 # Gathers various (meaningless) statistics about data/data_raw attributes 79 def iterTallyData(hive ):81 def iterTallyData(hive, fh): 80 82 data_stat = 0.0 81 83 dataraw_stat = 0.0 … … 127 129 # list dictionary access. Also builds nonsensical statistics as an excuse 128 130 # to access various base structure attributes. 129 def recurseKeyTally(hive ):131 def recurseKeyTally(hive, fh): 130 132 checkValues(hive.root) 131 133 recurseTree(hive.root, checkValues) … … 135 137 136 138 # Iterates hive gathering stats about security and classname records 137 def iterFetchRelated(hive ):139 def iterFetchRelated(hive, fh): 138 140 security_stat = 0.0 139 141 classname_stat = 0.0 … … 157 159 158 160 159 def iterIterWalk(hive ):161 def iterIterWalk(hive, fh): 160 162 sk_stat = 0.0 161 163 v_stat = 0.0 … … 183 185 184 186 185 187 def iterCallbackIO(hive, fh): 188 fh.seek(0) 189 new_fh = io.BytesIO(fh.read()) 190 new_hive = pyregfi.Hive(new_fh) 191 for k in new_hive: 192 pass 193 194 186 195 if len(sys.argv) < 2: 187 196 usage() … … 196 205 ("iterIterWalk",iterIterWalk),] 197 206 198 tests = [("iter IterWalk",iterIterWalk),]207 tests = [("iterCallbackIO",iterCallbackIO),] 199 208 200 209 … … 211 220 tstr = "'%s' on '%s'" % (tname,hname) 212 221 print("##BEGIN %s:" % tstr) 213 t(hive )222 t(hive, fh) 214 223 print("##END %s; runtime=%f; messages:" % (tstr, time.time() - teststart)) 215 224 print(pyregfi.GetLogMessages()) -
trunk/SConstruct
r212 r225 1 1 import sys 2 2 import os 3 #import distutils.sysconfig4 3 5 #cflags = '-std=gnu99 -pedantic -Wall' 6 cflags = '-std=gnu99 -pedantic -Wall -fvisibility=hidden -ggdb' 7 4 cflags = '-std=gnu99 -pedantic -Wall -D_FILE_OFFSET_BITS=64 -fvisibility=hidden' 5 cflags += ' -ggdb' 8 6 9 7 lib_src = ['lib/regfi.c', -
trunk/lib/regfi.c
r224 r225 612 612 do 613 613 { 614 rret = file_cb->read(file_cb, buf + rsize, *length - rsize); 614 rret = file_cb->read(file_cb, 615 buf + rsize, 616 *length - rsize); 615 617 if(rret > 0) 616 618 rsize += rret; -
trunk/python/pyregfi/__init__.py
r224 r225 95 95 import sys 96 96 import time 97 import weakref98 97 from pyregfi.structures import * 99 98 … … 635 634 pass 636 635 636 fh.seek(0) 637 637 self.raw_file = structures.REGFI_RAW_FILE() 638 638 self.raw_file.fh = fh 639 639 self.raw_file.seek = seek_cb_type(self.raw_file.cb_seek) 640 640 self.raw_file.read = read_cb_type(self.raw_file.cb_read) 641 self.file = regfi.regfi_alloc_cb(self.raw_file, REGFI_ENCODING_UTF8) 642 641 self.file = regfi.regfi_alloc_cb(pointer(self.raw_file), REGFI_ENCODING_UTF8) 642 if not self.file: 643 # XXX: switch to non-generic exception 644 raise Exception("Could not open registry file. Current log:\n" 645 + GetLogMessages()) 643 646 644 647 def __getattr__(self, name): -
trunk/python/pyregfi/structures.py
r224 r225 82 82 83 83 84 # XXX: how can we know for sure the size of off_t and size_t? 85 seek_cb_type = CFUNCTYPE(c_int64, POINTER(REGFI_RAW_FILE), c_uint64, c_int, use_errno=True) 86 read_cb_type = CFUNCTYPE(c_int64, POINTER(REGFI_RAW_FILE), POINTER(c_char), c_uint64, use_errno=True) 84 # Load libregfi according to platform 85 regfi = None 86 if hasattr(ctypes, 'windll'): 87 #regfi = ctypes.windll.libregfi 88 regfi = ctypes.WinDLL('libregfi.dll', use_errno=True) 89 CB_FACTORY = ctypes.WINFUNCTYPE 90 else: 91 regfi = ctypes.CDLL(ctypes.util.find_library('regfi'), use_errno=True) 92 CB_FACTORY = ctypes.CFUNCTYPE 93 94 # XXX: how can we know for sure the size of off_t? 95 # -D_FILE_OFFSET_BITS=64 might help, need to research this 96 # Also, may need to use something like ctypes_configure 97 #seek_cb_type = CB_FACTORY(c_int64, POINTER(REGFI_RAW_FILE), c_uint64, c_int, use_errno=True) 98 seek_cb_type = CB_FACTORY(c_int64, POINTER(REGFI_RAW_FILE), c_uint64, c_int) 99 #read_cb_type = CB_FACTORY(c_int64, POINTER(REGFI_RAW_FILE), POINTER(c_char), c_size_t, use_errno=True) 100 read_cb_type = CB_FACTORY(c_int64, POINTER(REGFI_RAW_FILE), POINTER(c_char), c_size_t) 87 101 88 102 … … 217 231 218 232 219 # Load libregfi and define function prototypes 220 regfi = ctypes.CDLL(ctypes.util.find_library('regfi'), use_errno=True) 221 233 # Define function prototypes 222 234 regfi.regfi_alloc.argtypes = [c_int, REGFI_ENCODING] 223 235 regfi.regfi_alloc.restype = POINTER(REGFI_FILE)
Note: See TracChangeset
for help on using the changeset viewer.