Rev | Line | |
---|
[204] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | import sys |
---|
| 4 | from pyregfi.structures import * |
---|
| 5 | |
---|
| 6 | import ctypes |
---|
| 7 | import ctypes.util |
---|
| 8 | from ctypes import c_char,c_char_p,c_int,POINTER |
---|
| 9 | |
---|
| 10 | regfi = ctypes.CDLL(ctypes.util.find_library('regfi'), use_errno=True) |
---|
| 11 | |
---|
| 12 | |
---|
| 13 | regfi.regfi_alloc.argtypes = [c_int] |
---|
| 14 | regfi.regfi_alloc.restype = POINTER(REGFI_FILE) |
---|
| 15 | |
---|
| 16 | regfi.regfi_alloc_cb.argtypes = [POINTER(REGFI_RAW_FILE)] |
---|
| 17 | regfi.regfi_alloc_cb.restype = POINTER(REGFI_FILE) |
---|
| 18 | |
---|
| 19 | regfi.regfi_log_get_str.argtypes = [] |
---|
| 20 | regfi.regfi_log_get_str.restype = c_char_p |
---|
| 21 | |
---|
| 22 | regfi.regfi_init.argtypes = [] |
---|
| 23 | regfi.regfi_init.restype = None |
---|
| 24 | regfi.regfi_init() |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | class Hive(ctypes.Structure): |
---|
| 28 | |
---|
| 29 | file = None |
---|
| 30 | raw_file = None |
---|
| 31 | |
---|
| 32 | def __init__(self, fh): |
---|
| 33 | |
---|
| 34 | if hasattr(fh, 'fileno') and 1==0: |
---|
| 35 | self.file = regfi.regfi_alloc(fh.fileno()) |
---|
| 36 | else: |
---|
| 37 | self.raw_file = structures.REGFI_RAW_FILE() |
---|
| 38 | self.raw_file.fh = fh |
---|
| 39 | self.raw_file.seek = seek_cb_type(self.raw_file.cb_seek) |
---|
| 40 | self.raw_file.read = read_cb_type(self.raw_file.cb_read) |
---|
| 41 | self.file = regfi.regfi_alloc_cb(self.raw_file) |
---|
| 42 | print(regfi.regfi_log_get_str()) |
---|
| 43 | |
---|
| 44 | def __getattr__(self, name): |
---|
| 45 | return getattr(self.file.contents, name) |
---|
| 46 | |
---|
| 47 | def test(self): |
---|
| 48 | print(self.magic) |
---|
| 49 | print(self.sequence1) |
---|
| 50 | print(self.sequence2) |
---|
| 51 | |
---|
Note: See
TracBrowser
for help on using the repository browser.