Made request tracing more robust against bogus lengths.

This commit is contained in:
Alexandre Julliard 2000-04-04 19:33:27 +00:00
parent f35cdc8e4b
commit ef88637f5b
13 changed files with 111 additions and 93 deletions

View File

@ -277,5 +277,6 @@ DECL_HANDLER(find_atom)
/* get global atom name */ /* get global atom name */
DECL_HANDLER(get_atom_name) DECL_HANDLER(get_atom_name)
{ {
req->name[0] = 0;
req->count = get_atom_name( global_table, req->atom, req->name ); req->count = get_atom_name( global_table, req->atom, req->name );
} }

View File

@ -439,7 +439,7 @@ DECL_HANDLER(open_console)
/* set info about a console (output only) */ /* set info about a console (output only) */
DECL_HANDLER(set_console_info) DECL_HANDLER(set_console_info)
{ {
size_t len = get_req_strlen( req->title ); size_t len = get_req_strlen( req, req->title );
set_console_info( req->handle, req, req->title, len ); set_console_info( req->handle, req, req->title, len );
} }
@ -447,13 +447,14 @@ DECL_HANDLER(set_console_info)
DECL_HANDLER(get_console_info) DECL_HANDLER(get_console_info)
{ {
struct screen_buffer *console; struct screen_buffer *console;
req->title[0] = 0;
if ((console = (struct screen_buffer *)get_handle_obj( current->process, req->handle, if ((console = (struct screen_buffer *)get_handle_obj( current->process, req->handle,
GENERIC_READ, &screen_buffer_ops ))) GENERIC_READ, &screen_buffer_ops )))
{ {
req->cursor_size = console->cursor_size; req->cursor_size = console->cursor_size;
req->cursor_visible = console->cursor_visible; req->cursor_visible = console->cursor_visible;
req->pid = console->pid; req->pid = console->pid;
strcpy( req->title, console->title ? console->title : "" ); if (console->title) strcpy( req->title, console->title );
release_object( console ); release_object( console );
} }
} }
@ -496,7 +497,7 @@ DECL_HANDLER(set_console_mode)
/* add input records to a console input queue */ /* add input records to a console input queue */
DECL_HANDLER(write_console_input) DECL_HANDLER(write_console_input)
{ {
int max = get_req_size( req + 1, sizeof(INPUT_RECORD) ); int max = get_req_size( req, req + 1, sizeof(INPUT_RECORD) );
int count = req->count; int count = req->count;
if (count > max) count = max; if (count > max) count = max;
@ -506,7 +507,7 @@ DECL_HANDLER(write_console_input)
/* fetch input records from a console input queue */ /* fetch input records from a console input queue */
DECL_HANDLER(read_console_input) DECL_HANDLER(read_console_input)
{ {
int max = get_req_size( req + 1, sizeof(INPUT_RECORD) ); int max = get_req_size( req, req + 1, sizeof(INPUT_RECORD) );
req->read = read_console_input( req->handle, req->count, (INPUT_RECORD *)(req + 1), req->read = read_console_input( req->handle, req->count, (INPUT_RECORD *)(req + 1),
max, req->flush ); max, req->flush );
} }

View File

@ -114,7 +114,7 @@ static int event_satisfied( struct object *obj, struct thread *thread )
/* create an event */ /* create an event */
DECL_HANDLER(create_event) DECL_HANDLER(create_event)
{ {
size_t len = get_req_strlenW( req->name ); size_t len = get_req_strlenW( req, req->name );
struct event *event; struct event *event;
req->handle = -1; req->handle = -1;
@ -128,7 +128,7 @@ DECL_HANDLER(create_event)
/* open a handle to an event */ /* open a handle to an event */
DECL_HANDLER(open_event) DECL_HANDLER(open_event)
{ {
size_t len = get_req_strlenW( req->name ); size_t len = get_req_strlenW( req, req->name );
req->handle = open_object( req->name, len, &event_ops, req->access, req->inherit ); req->handle = open_object( req->name, len, &event_ops, req->access, req->inherit );
} }

View File

@ -450,7 +450,7 @@ static int file_unlock( struct file *file, int offset_high, int offset_low,
/* create a file */ /* create a file */
DECL_HANDLER(create_file) DECL_HANDLER(create_file)
{ {
size_t len = get_req_strlen( req->name ); size_t len = get_req_strlen( req, req->name );
struct file *file; struct file *file;
req->handle = -1; req->handle = -1;

View File

@ -160,7 +160,7 @@ int get_page_size(void)
/* create a file mapping */ /* create a file mapping */
DECL_HANDLER(create_mapping) DECL_HANDLER(create_mapping)
{ {
size_t len = get_req_strlenW( req->name ); size_t len = get_req_strlenW( req, req->name );
struct object *obj; struct object *obj;
req->handle = -1; req->handle = -1;
@ -177,7 +177,7 @@ DECL_HANDLER(create_mapping)
/* open a handle to a mapping */ /* open a handle to a mapping */
DECL_HANDLER(open_mapping) DECL_HANDLER(open_mapping)
{ {
size_t len = get_req_strlenW( req->name ); size_t len = get_req_strlenW( req, req->name );
req->handle = open_object( req->name, len, &mapping_ops, req->access, req->inherit ); req->handle = open_object( req->name, len, &mapping_ops, req->access, req->inherit );
} }

View File

@ -139,7 +139,7 @@ static void mutex_destroy( struct object *obj )
/* create a mutex */ /* create a mutex */
DECL_HANDLER(create_mutex) DECL_HANDLER(create_mutex)
{ {
size_t len = get_req_strlenW( req->name ); size_t len = get_req_strlenW( req, req->name );
struct mutex *mutex; struct mutex *mutex;
req->handle = -1; req->handle = -1;
@ -153,7 +153,7 @@ DECL_HANDLER(create_mutex)
/* open a handle to a mutex */ /* open a handle to a mutex */
DECL_HANDLER(open_mutex) DECL_HANDLER(open_mutex)
{ {
size_t len = get_req_strlenW( req->name ); size_t len = get_req_strlenW( req, req->name );
req->handle = open_object( req->name, len, &mutex_ops, req->access, req->inherit ); req->handle = open_object( req->name, len, &mutex_ops, req->access, req->inherit );
} }

View File

@ -578,7 +578,7 @@ struct process_snapshot *process_snap( int *count )
/* create a new process */ /* create a new process */
DECL_HANDLER(new_process) DECL_HANDLER(new_process)
{ {
size_t len = get_req_strlen( req->cmdline ); size_t len = get_req_strlen( req, req->cmdline );
struct thread *thread; struct thread *thread;
int sock[2]; int sock[2];
@ -722,7 +722,7 @@ DECL_HANDLER(read_process_memory)
if ((process = get_process_from_handle( req->handle, PROCESS_VM_READ ))) if ((process = get_process_from_handle( req->handle, PROCESS_VM_READ )))
{ {
read_process_memory( process, req->addr, req->len, read_process_memory( process, req->addr, req->len,
get_req_size( req->data, sizeof(int) ), req->data ); get_req_size( req, req->data, sizeof(int) ), req->data );
release_object( process ); release_object( process );
} }
} }
@ -734,7 +734,8 @@ DECL_HANDLER(write_process_memory)
if ((process = get_process_from_handle( req->handle, PROCESS_VM_WRITE ))) if ((process = get_process_from_handle( req->handle, PROCESS_VM_WRITE )))
{ {
write_process_memory( process, req->addr, req->len, get_req_size( req->data, sizeof(int) ), write_process_memory( process, req->addr, req->len,
get_req_size( req, req->data, sizeof(int) ),
req->first_mask, req->last_mask, req->data ); req->first_mask, req->last_mask, req->data );
release_object( process ); release_object( process );
} }

View File

@ -308,10 +308,10 @@ static WCHAR *get_path_token( const WCHAR *initpath, size_t maxlen )
} }
/* duplicate a Unicode string from the request buffer */ /* duplicate a Unicode string from the request buffer */
static WCHAR *req_strdupW( const WCHAR *str ) static WCHAR *req_strdupW( const void *req, const WCHAR *str )
{ {
WCHAR *name; WCHAR *name;
size_t len = get_req_strlenW( str ); size_t len = get_req_strlenW( req, str );
if ((name = mem_alloc( (len + 1) * sizeof(WCHAR) )) != NULL) if ((name = mem_alloc( (len + 1) * sizeof(WCHAR) )) != NULL)
{ {
memcpy( name, str, len * sizeof(WCHAR) ); memcpy( name, str, len * sizeof(WCHAR) );
@ -741,7 +741,6 @@ static void get_value( struct key *key, WCHAR *name, int *type, int *len, void *
else else
{ {
*type = -1; *type = -1;
*len = 0;
set_error( STATUS_OBJECT_NAME_NOT_FOUND ); set_error( STATUS_OBJECT_NAME_NOT_FOUND );
} }
} }
@ -751,12 +750,7 @@ static void enum_value( struct key *key, int i, WCHAR *name, int *type, int *len
{ {
struct key_value *value; struct key_value *value;
if (i < 0 || i > key->last_value) if (i < 0 || i > key->last_value) set_error( STATUS_NO_MORE_ENTRIES );
{
name[0] = 0;
*len = 0;
set_error( STATUS_NO_MORE_ENTRIES );
}
else else
{ {
value = &key->values[i]; value = &key->values[i];
@ -1378,7 +1372,7 @@ DECL_HANDLER(create_key)
req->hkey = -1; req->hkey = -1;
if ((parent = get_hkey_obj( req->parent, KEY_CREATE_SUB_KEY ))) if ((parent = get_hkey_obj( req->parent, KEY_CREATE_SUB_KEY )))
{ {
if ((class = req_strdupW( req->class ))) if ((class = req_strdupW( req, req->class )))
{ {
if ((key = create_key( parent, req->name, sizeof(req->name), class, req->options, if ((key = create_key( parent, req->name, sizeof(req->name), class, req->options,
req->modif, &req->created ))) req->modif, &req->created )))
@ -1436,6 +1430,7 @@ DECL_HANDLER(enum_key)
{ {
struct key *key; struct key *key;
req->name[0] = req->class[0] = 0;
if ((key = get_hkey_obj( req->hkey, KEY_ENUMERATE_SUB_KEYS ))) if ((key = get_hkey_obj( req->hkey, KEY_ENUMERATE_SUB_KEYS )))
{ {
enum_key( key, req->index, req->name, req->class, &req->modif ); enum_key( key, req->index, req->name, req->class, &req->modif );
@ -1448,6 +1443,7 @@ DECL_HANDLER(query_key_info)
{ {
struct key *key; struct key *key;
req->name[0] = req->class[0] = 0;
if ((key = get_hkey_obj( req->hkey, KEY_QUERY_VALUE ))) if ((key = get_hkey_obj( req->hkey, KEY_QUERY_VALUE )))
{ {
query_key( key, req ); query_key( key, req );
@ -1459,7 +1455,7 @@ DECL_HANDLER(query_key_info)
DECL_HANDLER(set_key_value) DECL_HANDLER(set_key_value)
{ {
struct key *key; struct key *key;
int max = get_req_size( req->data, sizeof(req->data[0]) ); int max = get_req_size( req, req->data, sizeof(req->data[0]) );
int datalen = req->len; int datalen = req->len;
if (datalen > max) if (datalen > max)
{ {
@ -1478,6 +1474,7 @@ DECL_HANDLER(get_key_value)
{ {
struct key *key; struct key *key;
req->len = 0;
if ((key = get_hkey_obj( req->hkey, KEY_QUERY_VALUE ))) if ((key = get_hkey_obj( req->hkey, KEY_QUERY_VALUE )))
{ {
get_value( key, copy_path( req->name ), &req->type, &req->len, req->data ); get_value( key, copy_path( req->name ), &req->type, &req->len, req->data );
@ -1490,6 +1487,8 @@ DECL_HANDLER(enum_key_value)
{ {
struct key *key; struct key *key;
req->len = 0;
req->name[0] = 0;
if ((key = get_hkey_obj( req->hkey, KEY_QUERY_VALUE ))) if ((key = get_hkey_obj( req->hkey, KEY_QUERY_VALUE )))
{ {
enum_value( key, req->index, req->name, &req->type, &req->len, req->data ); enum_value( key, req->index, req->name, &req->type, &req->len, req->data );
@ -1505,7 +1504,7 @@ DECL_HANDLER(delete_key_value)
if ((key = get_hkey_obj( req->hkey, KEY_SET_VALUE ))) if ((key = get_hkey_obj( req->hkey, KEY_SET_VALUE )))
{ {
if ((name = req_strdupW( req->name ))) if ((name = req_strdupW( req, req->name )))
{ {
delete_value( key, name ); delete_value( key, name );
free( name ); free( name );

View File

@ -46,24 +46,24 @@ static inline void *get_req_ptr( struct thread *thread )
} }
/* get the remaining size in the request buffer for object of a given size */ /* get the remaining size in the request buffer for object of a given size */
static inline int get_req_size( const void *ptr, size_t typesize ) static inline int get_req_size( const void *req, const void *ptr, size_t typesize )
{ {
return ((char *)current->buffer + MAX_REQUEST_LENGTH - (char *)ptr) / typesize; return ((char *)req + MAX_REQUEST_LENGTH - (char *)ptr) / typesize;
} }
/* get the length of a request string, without going past the end of the request */ /* get the length of a request string, without going past the end of the request */
static inline size_t get_req_strlen( const char *str ) static inline size_t get_req_strlen( const void *req, const char *str )
{ {
const char *p = str; const char *p = str;
while (*p && (p < (char *)current->buffer + MAX_REQUEST_LENGTH - 1)) p++; while (*p && (p < (char *)req + MAX_REQUEST_LENGTH - 1)) p++;
return p - str; return p - str;
} }
/* same as above for Unicode */ /* same as above for Unicode */
static inline size_t get_req_strlenW( const WCHAR *str ) static inline size_t get_req_strlenW( const void *req, const WCHAR *str )
{ {
const WCHAR *p = str; const WCHAR *p = str;
while (*p && ((char *)p < (char *)current->buffer + MAX_REQUEST_LENGTH - 2)) p++; while (*p && (p < (WCHAR *)req + MAX_REQUEST_LENGTH/sizeof(WCHAR) - 1)) p++;
return p - str; return p - str;
} }

View File

@ -122,7 +122,7 @@ static int semaphore_satisfied( struct object *obj, struct thread *thread )
/* create a semaphore */ /* create a semaphore */
DECL_HANDLER(create_semaphore) DECL_HANDLER(create_semaphore)
{ {
size_t len = get_req_strlenW( req->name ); size_t len = get_req_strlenW( req, req->name );
struct semaphore *sem; struct semaphore *sem;
req->handle = -1; req->handle = -1;
@ -136,7 +136,7 @@ DECL_HANDLER(create_semaphore)
/* open a handle to a semaphore */ /* open a handle to a semaphore */
DECL_HANDLER(open_semaphore) DECL_HANDLER(open_semaphore)
{ {
size_t len = get_req_strlenW( req->name ); size_t len = get_req_strlenW( req, req->name );
req->handle = open_object( req->name, len, &semaphore_ops, req->access, req->inherit ); req->handle = open_object( req->name, len, &semaphore_ops, req->access, req->inherit );
} }

View File

@ -164,7 +164,7 @@ static void timer_destroy( struct object *obj )
/* create a timer */ /* create a timer */
DECL_HANDLER(create_timer) DECL_HANDLER(create_timer)
{ {
size_t len = get_req_strlenW( req->name ); size_t len = get_req_strlenW( req, req->name );
struct timer *timer; struct timer *timer;
req->handle = -1; req->handle = -1;
@ -178,7 +178,7 @@ DECL_HANDLER(create_timer)
/* open a handle to a timer */ /* open a handle to a timer */
DECL_HANDLER(open_timer) DECL_HANDLER(open_timer)
{ {
size_t len = get_req_strlenW( req->name ); size_t len = get_req_strlenW( req, req->name );
req->handle = open_object( req->name, len, &timer_ops, req->access, req->inherit ); req->handle = open_object( req->name, len, &timer_ops, req->access, req->inherit );
} }

View File

@ -19,7 +19,7 @@
static void dump_ints( const int *ptr, int len ) static void dump_ints( const int *ptr, int len )
{ {
fputc( '{', stderr ); fputc( '{', stderr );
while (len) while (len > 0)
{ {
fprintf( stderr, "%d", *ptr++ ); fprintf( stderr, "%d", *ptr++ );
if (--len) fputc( ',', stderr ); if (--len) fputc( ',', stderr );
@ -30,7 +30,7 @@ static void dump_ints( const int *ptr, int len )
static void dump_uints( const int *ptr, int len ) static void dump_uints( const int *ptr, int len )
{ {
fputc( '{', stderr ); fputc( '{', stderr );
while (len) while (len > 0)
{ {
fprintf( stderr, "%08x", *ptr++ ); fprintf( stderr, "%08x", *ptr++ );
if (--len) fputc( ',', stderr ); if (--len) fputc( ',', stderr );
@ -41,7 +41,7 @@ static void dump_uints( const int *ptr, int len )
static void dump_bytes( const unsigned char *ptr, int len ) static void dump_bytes( const unsigned char *ptr, int len )
{ {
fputc( '{', stderr ); fputc( '{', stderr );
while (len) while (len > 0)
{ {
fprintf( stderr, "%02x", *ptr++ ); fprintf( stderr, "%02x", *ptr++ );
if (--len) fputc( ',', stderr ); if (--len) fputc( ',', stderr );
@ -49,19 +49,26 @@ static void dump_bytes( const unsigned char *ptr, int len )
fputc( '}', stderr ); fputc( '}', stderr );
} }
static void dump_unicode_string( const WCHAR *str ) static void dump_string( const void *req, const char *str )
{ {
int len = get_req_strlen( req, str );
fprintf( stderr, "\"%.*s\"", len, str );
}
static void dump_unicode_string( const void *req, const WCHAR *str )
{
size_t len = get_req_strlenW( req, str );
fprintf( stderr, "L\"" ); fprintf( stderr, "L\"" );
dump_strW( str, strlenW(str), stderr, "\"\"" ); dump_strW( str, len, stderr, "\"\"" );
fputc( '\"', stderr ); fputc( '\"', stderr );
} }
static void dump_path_t( const path_t *path ) static void dump_path_t( const void *req, const path_t *path )
{ {
dump_unicode_string( *path ); dump_unicode_string( req, *path );
} }
static void dump_context( const CONTEXT *context ) static void dump_context( const void *req, const CONTEXT *context )
{ {
#ifdef __i386__ #ifdef __i386__
fprintf( stderr, "{flags=%08lx,eax=%08lx,ebx=%08lx,ecx=%08lx,edx=%08lx,esi=%08lx,edi=%08lx," fprintf( stderr, "{flags=%08lx,eax=%08lx,ebx=%08lx,ecx=%08lx,edx=%08lx,esi=%08lx,edi=%08lx,"
@ -79,7 +86,7 @@ static void dump_context( const CONTEXT *context )
#endif #endif
} }
static void dump_exc_record( const EXCEPTION_RECORD *rec ) static void dump_exc_record( const void *req, const EXCEPTION_RECORD *rec )
{ {
int i; int i;
fprintf( stderr, "{code=%lx,flags=%lx,rec=%p,addr=%p,params={", fprintf( stderr, "{code=%lx,flags=%lx,rec=%p,addr=%p,params={",
@ -93,13 +100,13 @@ static void dump_exc_record( const EXCEPTION_RECORD *rec )
fputc( '}', stderr ); fputc( '}', stderr );
} }
static void dump_debug_event_t( const debug_event_t *event ) static void dump_debug_event_t( const void *req, const debug_event_t *event )
{ {
switch(event->code) switch(event->code)
{ {
case EXCEPTION_DEBUG_EVENT: case EXCEPTION_DEBUG_EVENT:
fprintf( stderr, "{exception," ); fprintf( stderr, "{exception," );
dump_exc_record( &event->info.exception.record ); dump_exc_record( req, &event->info.exception.record );
fprintf( stderr, ",first=%d}", event->info.exception.first ); fprintf( stderr, ",first=%d}", event->info.exception.first );
break; break;
case CREATE_THREAD_DEBUG_EVENT: case CREATE_THREAD_DEBUG_EVENT:
@ -154,7 +161,8 @@ static void dump_debug_event_t( const debug_event_t *event )
static void dump_varargs_select_request( const struct select_request *req ) static void dump_varargs_select_request( const struct select_request *req )
{ {
dump_ints( req->handles, req->count ); int count = min( req->count, get_req_size( req, req->handles, sizeof(int) ));
dump_ints( req->handles, count );
} }
static void dump_varargs_get_apcs_reply( const struct get_apcs_request *req ) static void dump_varargs_get_apcs_reply( const struct get_apcs_request *req )
@ -172,29 +180,32 @@ static void dump_varargs_get_socket_event_reply( const struct get_socket_event_r
static void dump_varargs_read_process_memory_reply( const struct read_process_memory_request *req ) static void dump_varargs_read_process_memory_reply( const struct read_process_memory_request *req )
{ {
int count = min( req->len, get_req_size( req->data, sizeof(int) ) ); int count = min( req->len, get_req_size( req, req->data, sizeof(int) ));
dump_bytes( (unsigned char *)req->data, count * sizeof(int) ); dump_bytes( (unsigned char *)req->data, count * sizeof(int) );
} }
static void dump_varargs_write_process_memory_request( const struct write_process_memory_request *req ) static void dump_varargs_write_process_memory_request( const struct write_process_memory_request *req )
{ {
int count = min( req->len, get_req_size( req->data, sizeof(int) ) ); int count = min( req->len, get_req_size( req, req->data, sizeof(int) ));
dump_bytes( (unsigned char *)req->data, count * sizeof(int) ); dump_bytes( (unsigned char *)req->data, count * sizeof(int) );
} }
static void dump_varargs_set_key_value_request( const struct set_key_value_request *req ) static void dump_varargs_set_key_value_request( const struct set_key_value_request *req )
{ {
dump_bytes( req->data, req->len ); int count = min( req->len, get_req_size( req, req->data, 1 ));
dump_bytes( req->data, count );
} }
static void dump_varargs_get_key_value_reply( const struct get_key_value_request *req ) static void dump_varargs_get_key_value_reply( const struct get_key_value_request *req )
{ {
dump_bytes( req->data, req->len ); int count = min( req->len, get_req_size( req, req->data, 1 ));
dump_bytes( req->data, count );
} }
static void dump_varargs_enum_key_value_reply( const struct enum_key_value_request *req ) static void dump_varargs_enum_key_value_reply( const struct enum_key_value_request *req )
{ {
dump_bytes( req->data, req->len ); int count = min( req->len, get_req_size( req, req->data, 1 ));
dump_bytes( req->data, count );
} }
typedef void (*dump_func)( const void *req ); typedef void (*dump_func)( const void *req );
@ -216,7 +227,8 @@ static void dump_new_process_request( const struct new_process_request *req )
fprintf( stderr, " event=%d,", req->event ); fprintf( stderr, " event=%d,", req->event );
fprintf( stderr, " cmd_show=%d,", req->cmd_show ); fprintf( stderr, " cmd_show=%d,", req->cmd_show );
fprintf( stderr, " env_ptr=%p,", req->env_ptr ); fprintf( stderr, " env_ptr=%p,", req->env_ptr );
fprintf( stderr, " cmdline=\"%s\"", req->cmdline ); fprintf( stderr, " cmdline=" );
dump_string( req, req->cmdline );
} }
static void dump_new_process_reply( const struct new_process_request *req ) static void dump_new_process_reply( const struct new_process_request *req )
@ -259,7 +271,8 @@ static void dump_init_process_reply( const struct init_process_request *req )
fprintf( stderr, " hstderr=%d,", req->hstderr ); fprintf( stderr, " hstderr=%d,", req->hstderr );
fprintf( stderr, " cmd_show=%d,", req->cmd_show ); fprintf( stderr, " cmd_show=%d,", req->cmd_show );
fprintf( stderr, " env_ptr=%p,", req->env_ptr ); fprintf( stderr, " env_ptr=%p,", req->env_ptr );
fprintf( stderr, " cmdline=\"%s\"", req->cmdline ); fprintf( stderr, " cmdline=" );
dump_string( req, req->cmdline );
} }
static void dump_init_process_done_request( const struct init_process_done_request *req ) static void dump_init_process_done_request( const struct init_process_done_request *req )
@ -481,7 +494,7 @@ static void dump_create_event_request( const struct create_event_request *req )
fprintf( stderr, " initial_state=%d,", req->initial_state ); fprintf( stderr, " initial_state=%d,", req->initial_state );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static void dump_create_event_reply( const struct create_event_request *req ) static void dump_create_event_reply( const struct create_event_request *req )
@ -500,7 +513,7 @@ static void dump_open_event_request( const struct open_event_request *req )
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static void dump_open_event_reply( const struct open_event_request *req ) static void dump_open_event_reply( const struct open_event_request *req )
@ -513,7 +526,7 @@ static void dump_create_mutex_request( const struct create_mutex_request *req )
fprintf( stderr, " owned=%d,", req->owned ); fprintf( stderr, " owned=%d,", req->owned );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static void dump_create_mutex_reply( const struct create_mutex_request *req ) static void dump_create_mutex_reply( const struct create_mutex_request *req )
@ -531,7 +544,7 @@ static void dump_open_mutex_request( const struct open_mutex_request *req )
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static void dump_open_mutex_reply( const struct open_mutex_request *req ) static void dump_open_mutex_reply( const struct open_mutex_request *req )
@ -545,7 +558,7 @@ static void dump_create_semaphore_request( const struct create_semaphore_request
fprintf( stderr, " max=%08x,", req->max ); fprintf( stderr, " max=%08x,", req->max );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static void dump_create_semaphore_reply( const struct create_semaphore_request *req ) static void dump_create_semaphore_reply( const struct create_semaphore_request *req )
@ -569,7 +582,7 @@ static void dump_open_semaphore_request( const struct open_semaphore_request *re
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static void dump_open_semaphore_reply( const struct open_semaphore_request *req ) static void dump_open_semaphore_reply( const struct open_semaphore_request *req )
@ -584,7 +597,8 @@ static void dump_create_file_request( const struct create_file_request *req )
fprintf( stderr, " sharing=%08x,", req->sharing ); fprintf( stderr, " sharing=%08x,", req->sharing );
fprintf( stderr, " create=%d,", req->create ); fprintf( stderr, " create=%d,", req->create );
fprintf( stderr, " attrs=%08x,", req->attrs ); fprintf( stderr, " attrs=%08x,", req->attrs );
fprintf( stderr, " name=\"%s\"", req->name ); fprintf( stderr, " name=" );
dump_string( req, req->name );
} }
static void dump_create_file_reply( const struct create_file_request *req ) static void dump_create_file_reply( const struct create_file_request *req )
@ -807,7 +821,8 @@ static void dump_set_console_info_request( const struct set_console_info_request
fprintf( stderr, " mask=%d,", req->mask ); fprintf( stderr, " mask=%d,", req->mask );
fprintf( stderr, " cursor_size=%d,", req->cursor_size ); fprintf( stderr, " cursor_size=%d,", req->cursor_size );
fprintf( stderr, " cursor_visible=%d,", req->cursor_visible ); fprintf( stderr, " cursor_visible=%d,", req->cursor_visible );
fprintf( stderr, " title=\"%s\"", req->title ); fprintf( stderr, " title=" );
dump_string( req, req->title );
} }
static void dump_get_console_info_request( const struct get_console_info_request *req ) static void dump_get_console_info_request( const struct get_console_info_request *req )
@ -820,7 +835,8 @@ static void dump_get_console_info_reply( const struct get_console_info_request *
fprintf( stderr, " cursor_size=%d,", req->cursor_size ); fprintf( stderr, " cursor_size=%d,", req->cursor_size );
fprintf( stderr, " cursor_visible=%d,", req->cursor_visible ); fprintf( stderr, " cursor_visible=%d,", req->cursor_visible );
fprintf( stderr, " pid=%d,", req->pid ); fprintf( stderr, " pid=%d,", req->pid );
fprintf( stderr, " title=\"%s\"", req->title ); fprintf( stderr, " title=" );
dump_string( req, req->title );
} }
static void dump_write_console_input_request( const struct write_console_input_request *req ) static void dump_write_console_input_request( const struct write_console_input_request *req )
@ -865,7 +881,7 @@ static void dump_create_mapping_request( const struct create_mapping_request *re
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " file_handle=%d,", req->file_handle ); fprintf( stderr, " file_handle=%d,", req->file_handle );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static void dump_create_mapping_reply( const struct create_mapping_request *req ) static void dump_create_mapping_reply( const struct create_mapping_request *req )
@ -878,7 +894,7 @@ static void dump_open_mapping_request( const struct open_mapping_request *req )
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static void dump_open_mapping_reply( const struct open_mapping_request *req ) static void dump_open_mapping_reply( const struct open_mapping_request *req )
@ -944,17 +960,17 @@ static void dump_wait_debug_event_reply( const struct wait_debug_event_request *
fprintf( stderr, " pid=%p,", req->pid ); fprintf( stderr, " pid=%p,", req->pid );
fprintf( stderr, " tid=%p,", req->tid ); fprintf( stderr, " tid=%p,", req->tid );
fprintf( stderr, " event=" ); fprintf( stderr, " event=" );
dump_debug_event_t( &req->event ); dump_debug_event_t( req, &req->event );
} }
static void dump_exception_event_request( const struct exception_event_request *req ) static void dump_exception_event_request( const struct exception_event_request *req )
{ {
fprintf( stderr, " record=" ); fprintf( stderr, " record=" );
dump_exc_record( &req->record ); dump_exc_record( req, &req->record );
fprintf( stderr, "," ); fprintf( stderr, "," );
fprintf( stderr, " first=%d,", req->first ); fprintf( stderr, " first=%d,", req->first );
fprintf( stderr, " context=" ); fprintf( stderr, " context=" );
dump_context( &req->context ); dump_context( req, &req->context );
} }
static void dump_exception_event_reply( const struct exception_event_request *req ) static void dump_exception_event_reply( const struct exception_event_request *req )
@ -1012,10 +1028,10 @@ static void dump_create_key_request( const struct create_key_request *req )
fprintf( stderr, " options=%08x,", req->options ); fprintf( stderr, " options=%08x,", req->options );
fprintf( stderr, " modif=%ld,", req->modif ); fprintf( stderr, " modif=%ld,", req->modif );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_path_t( &req->name ); dump_path_t( req, &req->name );
fprintf( stderr, "," ); fprintf( stderr, "," );
fprintf( stderr, " class=" ); fprintf( stderr, " class=" );
dump_unicode_string( req->class ); dump_unicode_string( req, req->class );
} }
static void dump_create_key_reply( const struct create_key_request *req ) static void dump_create_key_reply( const struct create_key_request *req )
@ -1029,7 +1045,7 @@ static void dump_open_key_request( const struct open_key_request *req )
fprintf( stderr, " parent=%d,", req->parent ); fprintf( stderr, " parent=%d,", req->parent );
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_path_t( &req->name ); dump_path_t( req, &req->name );
} }
static void dump_open_key_reply( const struct open_key_request *req ) static void dump_open_key_reply( const struct open_key_request *req )
@ -1041,7 +1057,7 @@ static void dump_delete_key_request( const struct delete_key_request *req )
{ {
fprintf( stderr, " hkey=%d,", req->hkey ); fprintf( stderr, " hkey=%d,", req->hkey );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_path_t( &req->name ); dump_path_t( req, &req->name );
} }
static void dump_close_key_request( const struct close_key_request *req ) static void dump_close_key_request( const struct close_key_request *req )
@ -1059,10 +1075,10 @@ static void dump_enum_key_reply( const struct enum_key_request *req )
{ {
fprintf( stderr, " modif=%ld,", req->modif ); fprintf( stderr, " modif=%ld,", req->modif );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_path_t( &req->name ); dump_path_t( req, &req->name );
fprintf( stderr, "," ); fprintf( stderr, "," );
fprintf( stderr, " class=" ); fprintf( stderr, " class=" );
dump_unicode_string( req->class ); dump_unicode_string( req, req->class );
} }
static void dump_query_key_info_request( const struct query_key_info_request *req ) static void dump_query_key_info_request( const struct query_key_info_request *req )
@ -1080,10 +1096,10 @@ static void dump_query_key_info_reply( const struct query_key_info_request *req
fprintf( stderr, " max_data=%d,", req->max_data ); fprintf( stderr, " max_data=%d,", req->max_data );
fprintf( stderr, " modif=%ld,", req->modif ); fprintf( stderr, " modif=%ld,", req->modif );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_path_t( &req->name ); dump_path_t( req, &req->name );
fprintf( stderr, "," ); fprintf( stderr, "," );
fprintf( stderr, " class=" ); fprintf( stderr, " class=" );
dump_unicode_string( req->class ); dump_unicode_string( req, req->class );
} }
static void dump_set_key_value_request( const struct set_key_value_request *req ) static void dump_set_key_value_request( const struct set_key_value_request *req )
@ -1092,7 +1108,7 @@ static void dump_set_key_value_request( const struct set_key_value_request *req
fprintf( stderr, " type=%d,", req->type ); fprintf( stderr, " type=%d,", req->type );
fprintf( stderr, " len=%d,", req->len ); fprintf( stderr, " len=%d,", req->len );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_path_t( &req->name ); dump_path_t( req, &req->name );
fprintf( stderr, "," ); fprintf( stderr, "," );
fprintf( stderr, " data=" ); fprintf( stderr, " data=" );
dump_varargs_set_key_value_request( req ); dump_varargs_set_key_value_request( req );
@ -1102,7 +1118,7 @@ static void dump_get_key_value_request( const struct get_key_value_request *req
{ {
fprintf( stderr, " hkey=%d,", req->hkey ); fprintf( stderr, " hkey=%d,", req->hkey );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static void dump_get_key_value_reply( const struct get_key_value_request *req ) static void dump_get_key_value_reply( const struct get_key_value_request *req )
@ -1124,7 +1140,7 @@ static void dump_enum_key_value_reply( const struct enum_key_value_request *req
fprintf( stderr, " type=%d,", req->type ); fprintf( stderr, " type=%d,", req->type );
fprintf( stderr, " len=%d,", req->len ); fprintf( stderr, " len=%d,", req->len );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_path_t( &req->name ); dump_path_t( req, &req->name );
fprintf( stderr, "," ); fprintf( stderr, "," );
fprintf( stderr, " data=" ); fprintf( stderr, " data=" );
dump_varargs_enum_key_value_reply( req ); dump_varargs_enum_key_value_reply( req );
@ -1134,7 +1150,7 @@ static void dump_delete_key_value_request( const struct delete_key_value_request
{ {
fprintf( stderr, " hkey=%d,", req->hkey ); fprintf( stderr, " hkey=%d,", req->hkey );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_path_t( &req->name ); dump_path_t( req, &req->name );
} }
static void dump_load_registry_request( const struct load_registry_request *req ) static void dump_load_registry_request( const struct load_registry_request *req )
@ -1142,7 +1158,7 @@ static void dump_load_registry_request( const struct load_registry_request *req
fprintf( stderr, " hkey=%d,", req->hkey ); fprintf( stderr, " hkey=%d,", req->hkey );
fprintf( stderr, " file=%d,", req->file ); fprintf( stderr, " file=%d,", req->file );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_path_t( &req->name ); dump_path_t( req, &req->name );
} }
static void dump_save_registry_request( const struct save_registry_request *req ) static void dump_save_registry_request( const struct save_registry_request *req )
@ -1163,7 +1179,7 @@ static void dump_create_timer_request( const struct create_timer_request *req )
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " manual=%d,", req->manual ); fprintf( stderr, " manual=%d,", req->manual );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static void dump_create_timer_reply( const struct create_timer_request *req ) static void dump_create_timer_reply( const struct create_timer_request *req )
@ -1176,7 +1192,7 @@ static void dump_open_timer_request( const struct open_timer_request *req )
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static void dump_open_timer_reply( const struct open_timer_request *req ) static void dump_open_timer_reply( const struct open_timer_request *req )
@ -1208,7 +1224,7 @@ static void dump_get_thread_context_request( const struct get_thread_context_req
static void dump_get_thread_context_reply( const struct get_thread_context_request *req ) static void dump_get_thread_context_reply( const struct get_thread_context_request *req )
{ {
fprintf( stderr, " context=" ); fprintf( stderr, " context=" );
dump_context( &req->context ); dump_context( req, &req->context );
} }
static void dump_set_thread_context_request( const struct set_thread_context_request *req ) static void dump_set_thread_context_request( const struct set_thread_context_request *req )
@ -1216,7 +1232,7 @@ static void dump_set_thread_context_request( const struct set_thread_context_req
fprintf( stderr, " handle=%d,", req->handle ); fprintf( stderr, " handle=%d,", req->handle );
fprintf( stderr, " flags=%08x,", req->flags ); fprintf( stderr, " flags=%08x,", req->flags );
fprintf( stderr, " context=" ); fprintf( stderr, " context=" );
dump_context( &req->context ); dump_context( req, &req->context );
} }
static void dump_get_selector_entry_request( const struct get_selector_entry_request *req ) static void dump_get_selector_entry_request( const struct get_selector_entry_request *req )
@ -1235,7 +1251,7 @@ static void dump_get_selector_entry_reply( const struct get_selector_entry_reque
static void dump_add_atom_request( const struct add_atom_request *req ) static void dump_add_atom_request( const struct add_atom_request *req )
{ {
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static void dump_add_atom_reply( const struct add_atom_request *req ) static void dump_add_atom_reply( const struct add_atom_request *req )
@ -1251,7 +1267,7 @@ static void dump_delete_atom_request( const struct delete_atom_request *req )
static void dump_find_atom_request( const struct find_atom_request *req ) static void dump_find_atom_request( const struct find_atom_request *req )
{ {
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static void dump_find_atom_reply( const struct find_atom_request *req ) static void dump_find_atom_reply( const struct find_atom_request *req )
@ -1268,7 +1284,7 @@ static void dump_get_atom_name_reply( const struct get_atom_name_request *req )
{ {
fprintf( stderr, " count=%d,", req->count ); fprintf( stderr, " count=%d,", req->count );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req->name ); dump_unicode_string( req, req->name );
} }
static const dump_func req_dumpers[REQ_NB_REQUESTS] = { static const dump_func req_dumpers[REQ_NB_REQUESTS] = {

View File

@ -19,8 +19,8 @@
"debug_event_t" => "&dump_debug_event_t", "debug_event_t" => "&dump_debug_event_t",
"CONTEXT" => "&dump_context", "CONTEXT" => "&dump_context",
"EXCEPTION_RECORD" => "&dump_exc_record", "EXCEPTION_RECORD" => "&dump_exc_record",
"char[1]" => "\\\"%s\\\"", "char[1]" => "&dump_string",
"WCHAR[1]" => "&dump_unicode_string" "WCHAR[1]" => "&dump_unicode_string"
); );
my @requests = (); my @requests = ();
@ -139,8 +139,8 @@ sub DO_DUMP_FUNC
{ {
my $func = $1; my $func = $1;
push @trace_lines, " fprintf( stderr, \" $var=\" );\n"; push @trace_lines, " fprintf( stderr, \" $var=\" );\n";
if ($type =~ /[1]/) { push @trace_lines, " $func( req->$var );\n"; } if ($type =~ /[1]/) { push @trace_lines, " $func( req, req->$var );\n"; }
else { push @trace_lines, " $func( &req->$var );\n"; } else { push @trace_lines, " $func( req, &req->$var );\n"; }
push @trace_lines, " fprintf( stderr, \",\" );\n" if ($#_ > 0); push @trace_lines, " fprintf( stderr, \",\" );\n" if ($#_ > 0);
} }
else else