From c401fd3d4d2c9ac0ec6599315477eff9479b8474 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 29 Nov 2012 14:17:39 +0100 Subject: reading the string pool should be endian-friendly --- libmsi/string.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'libmsi/string.c') diff --git a/libmsi/string.c b/libmsi/string.c index 6914eb2..fdbce59 100644 --- a/libmsi/string.c +++ b/libmsi/string.c @@ -479,7 +479,7 @@ string_table *msi_load_string_table( IStorage *stg, unsigned *bytes_per_strref ) { string_table *st = NULL; char *data = NULL; - uint16_t *pool = NULL; + uint8_t *pool = NULL; unsigned r, datasize = 0, poolsize = 0, codepage; unsigned i, count, offset, len, n, refs; @@ -490,50 +490,47 @@ string_table *msi_load_string_table( IStorage *stg, unsigned *bytes_per_strref ) if( r != ERROR_SUCCESS) goto end; - if ( (poolsize > 4) && (pool[1] & 0x8000) ) + if ( (poolsize > 4) && (pool[3] & 0x80) ) *bytes_per_strref = LONG_STR_BYTES; else *bytes_per_strref = sizeof(uint16_t); - count = poolsize/4; + /* All data is little-endian. */ if( poolsize > 4 ) - codepage = pool[0] | ( (pool[1] & ~0x8000) << 16 ); + codepage = pool[0] | (pool[1] << 8) | (pool[2] << 16) | ((pool[3] & ~0x80) << 24); else codepage = CP_ACP; + + count = poolsize/4; st = init_stringtable( count, codepage ); if (!st) goto end; offset = 0; - n = 1; i = 1; - while( i datasize ) @@ -545,7 +542,6 @@ string_table *msi_load_string_table( IStorage *stg, unsigned *bytes_per_strref ) r = msi_addstring( st, n, data+offset, len, refs, StringPersistent ); if( r != n ) ERR("Failed to add string %d\n", n ); - n++; offset += len; } -- cgit