svn commit: samba r6438 - in trunk/source: include registry utils
jerry at samba.org
jerry at samba.org
Sat Apr 23 02:01:41 GMT 2005
Author: jerry
Date: 2005-04-23 02:01:41 +0000 (Sat, 23 Apr 2005)
New Revision: 6438
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6438
Log:
handle vk records whose data offset cross an hbin block boundary.
add values to 'net rpc registry dump' (example):
[$$$PROTO.HIV\Control Panel\Appearance]
"Current" = (REG_SZ) Plum (high color)
"RecentFourCharsets" = (REG_BINARY) 0000000000000000
"CustomColors" = (REG_BINARY) ffffff0ffffff0ffffff0fffff
Modified:
trunk/source/include/regfio.h
trunk/source/registry/regfio.c
trunk/source/utils/net_rpc_registry.c
Changeset:
Modified: trunk/source/include/regfio.h
===================================================================
--- trunk/source/include/regfio.h 2005-04-22 22:44:44 UTC (rev 6437)
+++ trunk/source/include/regfio.h 2005-04-23 02:01:41 UTC (rev 6438)
@@ -40,7 +40,7 @@
/* Flags for the vk records */
#define VK_FLAG_NAME_PRESENT 0x0001
-#define VK_DATA_IN_OFFSET 0x10000000
+#define VK_DATA_IN_OFFSET 0x80000000
/* NK record macros */
Modified: trunk/source/registry/regfio.c
===================================================================
--- trunk/source/registry/regfio.c 2005-04-22 22:44:44 UTC (rev 6437)
+++ trunk/source/registry/regfio.c 2005-04-23 02:01:41 UTC (rev 6438)
@@ -59,6 +59,17 @@
{
int bytes_read, returned;
char *buffer;
+ SMB_STRUCT_STAT sbuf;
+
+ /* check for end of file */
+
+ if ( sys_fstat( file->fd, &sbuf ) ) {
+ DEBUG(0,("read_block: stat() failed! (%s)\n", strerror(errno)));
+ return -1;
+ }
+
+ if ( (size_t)file_offset >= sbuf.st_size )
+ return -1;
/* if block_size == 0, we are parsnig HBIN records and need
to read some of the header to get the block_size from there */
@@ -311,13 +322,13 @@
hbin->file_off = offset;
if ( read_block( file, &hbin->ps, offset, 0 ) == -1 )
- return False;
+ return NULL;
if ( !prs_hbin_block( "hbin", &hbin->ps, 0, hbin ) )
- return False;
+ return NULL;
if ( !prs_set_offset( &hbin->ps, file->data_offset+HBIN_HDR_SIZE ) )
- return False;
+ return NULL;
return hbin;
}
@@ -424,10 +435,11 @@
/*******************************************************************
*******************************************************************/
-static BOOL prs_vk_rec( const char *desc, prs_struct *ps, int depth, REGF_VK_REC *vk )
+static BOOL hbin_prs_vk_rec( const char *desc, REGF_HBIN *hbin, int depth, REGF_VK_REC *vk, REGF_FILE *file )
{
uint32 offset;
uint16 name_length;
+ prs_struct *ps = &hbin->ps;
prs_debug(ps, depth, desc, "prs_vk_rec");
depth++;
@@ -467,13 +479,23 @@
/* the data is stored in the offset if the size <= 4 */
- if ( vk->data_size & VK_DATA_IN_OFFSET ) {
+ if ( !(vk->data_size & VK_DATA_IN_OFFSET) ) {
+ REGF_HBIN *hblock = hbin;
+
if ( !(vk->data = PRS_ALLOC_MEM( ps, uint8, vk->data_size) ) )
return False;
- if ( !(prs_set_offset( ps, vk->data_off+HBIN_HDR_SIZE )) )
+
+ /* this data can be in another hbin */
+ if ( !hbin_contains_offset( hbin, vk->data_off ) ) {
+ if ( !(hblock = lookup_hbin_block( file, vk->data_off )) )
+ return False;
+ }
+ if ( !(prs_set_offset( &hblock->ps, (vk->data_off+HBIN_HDR_SIZE-hblock->first_hbin_off) )) )
return False;
- if ( !prs_uint8s( charmode, "data", ps, depth, vk->data, vk->data_size) )
+ if ( !prs_uint8s( charmode, "data", &hblock->ps, depth, vk->data, vk->data_size) )
return False;
+ if ( hblock != hbin )
+ prs_mem_free( &hblock->ps );
}
else {
if ( !(vk->data = PRS_ALLOC_MEM( ps, uint8, 4 ) ) )
@@ -532,7 +554,7 @@
new_offset = nk->values[i].hbin_off + HBIN_HDR_SIZE - sub_hbin->first_hbin_off;
if ( !prs_set_offset( &sub_hbin->ps, new_offset ) )
return False;
- if ( !prs_vk_rec( "vk_rec", &sub_hbin->ps, depth, &nk->values[i] ) )
+ if ( !hbin_prs_vk_rec( "vk_rec", sub_hbin, depth, &nk->values[i], file ) )
return False;
}
Modified: trunk/source/utils/net_rpc_registry.c
===================================================================
--- trunk/source/utils/net_rpc_registry.c 2005-04-22 22:44:44 UTC (rev 6437)
+++ trunk/source/utils/net_rpc_registry.c 2005-04-23 02:01:41 UTC (rev 6438)
@@ -36,6 +36,9 @@
case REG_MULTI_SZ:
fstrcpy( string, "REG_MULTI_SZ" );
break;
+ case REG_EXPAND_SZ:
+ fstrcpy( string, "REG_EXPAND_SZ" );
+ break;
case REG_DWORD:
fstrcpy( string, "REG_DWORD" );
break;
@@ -43,7 +46,7 @@
fstrcpy( string, "REG_BINARY" );
break;
default:
- fstrcpy( string, "UNKNOWN" );
+ fstr_sprintf( string, "UNKNOWN [%d]", type );
}
return string;
@@ -258,6 +261,50 @@
/********************************************************************
********************************************************************/
+static void dump_values( REGF_NK_REC *nk )
+{
+ int i, j;
+ pstring data_str;
+ uint32 data_size, data;
+
+ for ( i=0; i<nk->num_values; i++ ) {
+ d_printf( "\"%s\" = ", nk->values[i].valuename ? nk->values[i].valuename : "(default)" );
+ d_printf( "(%s) ", dump_regval_type( nk->values[i].type ) );
+
+ data_size = nk->values[i].data_size & ~VK_DATA_IN_OFFSET;
+ switch ( nk->values[i].type ) {
+ case REG_SZ:
+ rpcstr_pull( data_str, nk->values[i].data, sizeof(data_str), -1, STR_TERMINATE );
+ d_printf( "%s", data_str );
+ break;
+ case REG_MULTI_SZ:
+ case REG_EXPAND_SZ:
+ for ( j=0; j<data_size; j++ ) {
+ d_printf( "%c", nk->values[i].data[j] );
+ }
+ break;
+ case REG_DWORD:
+ data = IVAL( nk->values[i].data, 0 );
+ d_printf("0x%x", data );
+ break;
+ case REG_BINARY:
+ for ( j=0; j<data_size; j++ ) {
+ d_printf( "%x", nk->values[i].data[j] );
+ }
+ break;
+ default:
+ d_printf("unknown");
+ break;
+ }
+
+ d_printf( "\n" );
+ }
+
+}
+
+/********************************************************************
+********************************************************************/
+
static BOOL dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *parent )
{
REGF_NK_REC *key;
@@ -267,7 +314,9 @@
while ( (key = regfio_fetch_subkey( file, nk )) ) {
pstr_sprintf( regpath, "%s\\%s", parent, key->keyname );
- d_printf("processed key [%s]\n", regpath );
+ d_printf("[%s]\n", regpath );
+ dump_values( key );
+ d_printf("\n");
dump_registry_tree( file, key, regpath );
}
@@ -297,7 +346,9 @@
/* get the root of the registry file */
nk = regfio_rootkey( registry );
- d_printf("processed key [%s]\n", nk->keyname);
+ d_printf("[%s]\n", nk->keyname);
+ dump_values( nk );
+ d_printf("\n");
dump_registry_tree( registry, nk, nk->keyname );
More information about the samba-cvs
mailing list