From: Hans Leidekker hans@codeweavers.com
--- tools/widl/metadata.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/tools/widl/metadata.c b/tools/widl/metadata.c index 264b0a2c8bb..92900fbf3c2 100644 --- a/tools/widl/metadata.c +++ b/tools/widl/metadata.c @@ -227,7 +227,7 @@ static struct buffer UINT allocated; /* allocated size in bytes */ UINT count; /* number of entries written */ BYTE *ptr; -} strings, strings_idx, userstrings, userstrings_idx, blobs, blobs_idx; +} strings, strings_idx, userstrings, userstrings_idx, blobs, blobs_idx, guids;
static void *grow_buffer( struct buffer *buf, UINT size ) { @@ -399,6 +399,14 @@ static UINT add_blob( const BYTE *blob, UINT size ) return offset; }
+static UINT add_guid( const GUID *guid ) +{ + grow_buffer( &guids, sizeof(*guid) ); + memcpy( guids.ptr + guids.offset, guid, sizeof(*guid) ); + guids.offset += sizeof(*guid); + return ++guids.count; +} + static void add_bytes( struct buffer *buf, const BYTE *data, UINT size ) { grow_buffer( buf, size ); @@ -406,14 +414,25 @@ static void add_bytes( struct buffer *buf, const BYTE *data, UINT size ) buf->offset += size; }
+static void generate_guid( GUID *guid ) +{ + int fd = open( "/dev/urandom", O_RDONLY ); + if (fd != -1) read( fd, guid, sizeof(*guid) ); + close( fd ); +} + static void build_table_stream( const statement_list_t *stmts ) { static const USHORT space = 0x20; + GUID guid;
add_string( "" ); add_userstring( NULL, 0 ); add_userstring( &space, sizeof(space) ); add_blob( NULL, 0 ); + + generate_guid( &guid ); + add_guid( &guid ); }
static void build_streams( const statement_list_t *stmts ) @@ -441,6 +460,9 @@ static void build_streams( const statement_list_t *stmts ) streams[STREAM_BLOB].data_size = blobs.offset; streams[STREAM_BLOB].data = blobs.ptr;
+ streams[STREAM_GUID].data_size = guids.offset; + streams[STREAM_GUID].data = guids.ptr; + for (i = 0; i < STREAM_MAX; i++) { if (!streams[i].data_size) continue;