Changeset 198 for trunk/python2/regfi
- Timestamp:
- 05/31/10 15:20:34 (15 years ago)
- Location:
- trunk/python2/regfi
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python2/regfi/class.c
r196 r198 33 33 // allocated therefore: 34 34 35 inlinevoid Object_init(Object this) {35 void Object_init(Object this) { 36 36 this->__class__ = &__Object; 37 37 this->__super__ = NULL; 38 } ;38 } 39 39 40 40 struct Object_t __Object = { … … 56 56 return 0; 57 57 }; 58 } ;58 } 59 59 60 60 void unimplemented(Object self) { 61 61 printf("%s contains unimplemented functions.. is it an abstract class?\n", NAMEOF(self)); 62 62 abort(); 63 } ;63 } -
trunk/python2/regfi/error.c
r196 r198 22 22 void error_dest(void *slot) { 23 23 if(slot) talloc_free(slot); 24 } ;24 } 25 25 26 26 void *raise_errors(enum _error_type t, char *reason, ...) { … … 42 42 43 43 return NULL; 44 } ;44 } 45 45 46 46 static int error_subsystem_initialised=0; … … 70 70 71 71 return type; 72 } ;72 } 73 73 74 74 /** Initialise the error subsystem */ … … 82 82 abort(); 83 83 }; 84 } ;84 } -
trunk/python2/regfi/pyregfi.h
r196 r198 19 19 struct ValueIterator_t; 20 20 21 BIND_STRUCT(REGFI_NK_REC) ;22 BIND_STRUCT(REGFI_VK_REC) ;23 BIND_STRUCT(REGFI_DATA) ;21 BIND_STRUCT(REGFI_NK_REC) 22 BIND_STRUCT(REGFI_VK_REC) 23 BIND_STRUCT(REGFI_DATA) 24 24 25 25 /** This is the base class for data objects */ 26 26 CLASS(RawData, Object) 27 REGFI_DATA *data;28 REGFI_VK_REC *rec;27 const REGFI_DATA *data; 28 const REGFI_VK_REC *rec; 29 29 30 RawData METHOD(RawData, Con, REGFI_DATA *data, REGFI_VK_REC *record);30 RawData METHOD(RawData, Con, REGFI_DATA *data, REGFI_VK_REC *record); 31 31 32 32 /** Return the raw buffer as a string. By default we only return -
trunk/python2/regfi/regfi.c
r196 r198 18 18 19 19 return 0; 20 } ;20 } 21 21 22 22 static RegistryFile RegistryFile_Con(RegistryFile self, char *filename) { … … 25 25 RaiseError(EIOError, "Unable to open %s", filename); 26 26 goto error; 27 } ;27 } 28 28 29 29 self->reg = regfi_alloc(self->fd); 30 30 31 31 if(!self->reg) { 32 RaiseError(ERuntimeError, "REGFI Error: %s", regfi_log_get_str()); 33 goto error; 34 }; 32 /*RaiseError(ERuntimeError, "REGFI Error: %s", regfi_log_get_str());*/ 33 /*char* e = regfi_log_get_str();*/ 34 /*fprintf(stderr, "%p\n", e);*/ 35 goto error; 36 } 35 37 36 38 talloc_set_destructor((void *)self, RegistryFile_dest); … … 40 42 talloc_free(self); 41 43 return NULL; 42 } ;44 } 43 45 44 46 static KeyIterator RegistryFile_get_key(RegistryFile self, char **path, REGFI_ENCODING encoding) { 45 47 return CONSTRUCT(KeyIterator, KeyIterator, Con, NULL, self, path, encoding); 46 } ;48 } 47 49 48 50 … … 58 60 if(this->next_item) { 59 61 regfi_free_record(this->next_item); 60 } ;61 62 return 0; 63 } ;62 } 63 64 return 0; 65 } 64 66 65 67 static KeyIterator KeyIterator_Con(KeyIterator self, RegistryFile file, char **path, … … 70 72 RaiseError(ERuntimeError, "Error: %s", regfi_log_get_str()); 71 73 goto error; 72 } ;74 } 73 75 74 76 talloc_set_destructor((void*)self, KeyIterator_dest); … … 79 81 RaiseError(ERuntimeError, "Unable to walk down key path"); 80 82 goto error; 81 } ;82 } ;83 } 84 } 83 85 84 86 // Get the first key in the list … … 88 90 error: 89 91 return NULL; 90 } ;92 } 91 93 92 94 static void KeyIterator__iter__(KeyIterator self) { … … 96 98 97 99 self->next_item = regfi_iterator_first_subkey(self->iter); 98 } ;99 100 static REGFI_NK_REC *KeyIterator_next(KeyIterator self) {101 const REGFI_NK_REC 100 } 101 102 static const REGFI_NK_REC* KeyIterator_next(KeyIterator self) { 103 const REGFI_NK_REC* result; 102 104 103 105 if(!self->next_item) return NULL; … … 108 110 109 111 return result; 110 } ;112 } 111 113 112 114 static ValueIterator KeyIterator_list_values(KeyIterator self) { 113 115 return CONSTRUCT(ValueIterator, ValueIterator, Con, NULL, self); 114 } ;116 } 115 117 116 118 VIRTUAL(KeyIterator, Object) { … … 127 129 128 130 return 0; 129 } ;131 } 130 132 131 133 static ValueIterator ValueIterator_Con(ValueIterator self, KeyIterator key) { … … 139 141 140 142 return self; 141 } ;143 } 142 144 143 145 static void ValueIterator__iter__(ValueIterator self) { … … 145 147 146 148 self->next_item = regfi_iterator_first_value(self->iter); 147 } ;149 } 148 150 149 151 static RawData ValueIterator_iternext(ValueIterator self) { 150 152 RawData result; 151 REGFI_DATA *data;152 REGFI_VK_REC *rec = (REGFI_VK_REC *)self->next_item;153 const REGFI_DATA *data; 154 const REGFI_VK_REC *rec = self->next_item; 153 155 154 156 if(!rec) return NULL; … … 158 160 RaiseError(ERuntimeError, "Unable to fetch data: %s", regfi_log_get_str()); 159 161 goto error; 160 } ;162 } 161 163 162 164 switch(self->next_item->type) { … … 174 176 result = (RawData)CONSTRUCT(RawData, RawData, Con, NULL, data, rec); 175 177 break; 176 } ;178 } 177 179 178 180 … … 188 190 talloc_free(self); 189 191 return NULL; 190 } ;192 } 191 193 192 194 VIRTUAL(ValueIterator, Object) { … … 208 210 209 211 return 0; 210 } ;212 } 211 213 212 214 static RawData RawData_Con(RawData self, REGFI_DATA *data, REGFI_VK_REC *record) { … … 217 219 218 220 return self; 219 } ;221 } 220 222 221 223 static int RawData_get_value(RawData self, char *buff, int len) { … … 225 227 226 228 return available_to_read; 227 } ;229 } 228 230 229 231 VIRTUAL(RawData, Object) { … … 232 234 } END_VIRTUAL 233 235 234 static char *DataString_get_value(DataString self) {236 static char* DataString_get_value(DataString self) { 235 237 RawData this = (RawData)self; 236 238 237 return this->data->interpreted.string;238 } ;239 return (char*)this->data->interpreted.string; 240 } 239 241 240 242 VIRTUAL(DataString, RawData) { … … 246 248 247 249 return this->data->interpreted.dword; 248 } ;250 } 249 251 250 252 VIRTUAL(DWORDData, RawData) { … … 255 257 INIT_CLASS(RegistryFile); 256 258 257 } ;259 }
Note: See TracChangeset
for help on using the changeset viewer.