long parself( struct hive *h, char *t, unsigned long off ) { nk_hdr *n; lf_hdr *l; hashrecord *hr; long res; int i; hr = (hashrecord*) malloc(sizeof(hashrecord)); n = (nk_hdr*) malloc(sizeof(nk_hdr)); l = (lf_hdr*) malloc(sizeof(lf_hdr)); l = read_lf(l, h, off ); #ifdef DEBUG printf("off = %x, key_num = %d ", off, l->key_num); #endif for( i = 0; i < l->key_num; i++ ){ hr = read_hr(hr, l->hr, i); n = read_nk(n, h, hr->nk_offset + 0x1000 ); #ifdef DEBUG printf("/ i=%d/%d, keyname = %x, nk_offset = %x\n", i, l->key_num, hr->keyname, hr->nk_offset); printf("//t = %s, keyname = %s, len = %d\n", t, strndup(n->key_name, n->name_len), n->name_len); #endif if( !memcmp( t, n->key_name, n->name_len ) && (strlen(t) == n->name_len)) { res = hr->nk_offset; free(n); free(l); return res; } } free(n); free(l); return -1; }
int _RegEnumKey( struct hive *h, nk_hdr *nr, int index, char *name, int *namelen ) { lf_hdr *lf; nk_hdr *nk; hashrecord *hr; lf = (lf_hdr*) malloc(sizeof(lf_hdr)); nk = (nk_hdr*) malloc(sizeof(nk_hdr)); hr = (hashrecord*) malloc(sizeof(hashrecord)); #ifdef DEBUG printf("subkey_num = %d\n", nr->subkey_num); #endif if( index < nr->subkey_num ) { lf = read_lf(lf, h, nr->lf_off + 0x1000 ); hr = read_hr(hr, lf->hr, index); nk = read_nk(nk, h, hr->nk_offset + 0x1000 ); memcpy( name, nk->key_name, min( *namelen, nk->name_len ) ); name[ min( *namelen, nk->name_len ) ] = 0; *namelen = nk->name_len; free(lf); return ( (index + 1) < nr->subkey_num ) ? (index + 1) : -1; } free(lf); return -1; }
struct rlib_report_output_array * read_roa(gchar **ptr) { gint32 *type; struct rlib_report_output_array *roa = g_new0(struct rlib_report_output_array, 1); roa->count = 0; roa->data = NULL; type = (gint32 *)*ptr; if(*type == RLIB_FILE_ROA) { *ptr += sizeof(gint32); roa->xml_page.xml = (xmlChar *)read_xml_str(ptr); while(1) { type = (gint32 *)*ptr; *ptr += sizeof(gint32); if(*type == RLIB_FILE_ROA+1) break; roa->data = g_realloc(roa->data, sizeof(struct rlib_report_output_array *) * (roa->count + 1)); if(*type == RLIB_REPORT_PRESENTATION_DATA_IMAGE) roa->data[roa->count++] = report_output_new(RLIB_REPORT_PRESENTATION_DATA_IMAGE, read_image(ptr)); else if(*type == RLIB_REPORT_PRESENTATION_DATA_HR) roa->data[roa->count++] = report_output_new(RLIB_REPORT_PRESENTATION_DATA_HR, read_hr(ptr)); else if(*type == RLIB_REPORT_PRESENTATION_DATA_LINE) roa->data[roa->count++] = report_output_new(RLIB_REPORT_PRESENTATION_DATA_LINE, read_line(ptr)); } return roa; } return NULL; }