dumpres.c 25.4 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1
/*
2
 * Copyright 1998 Bertho A. Stultiens (BS)
Alexandre Julliard's avatar
Alexandre Julliard committed
3
 *
4 5 6 7
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
Alexandre Julliard's avatar
Alexandre Julliard committed
8
 *
9 10 11 12 13 14 15
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Alexandre Julliard's avatar
Alexandre Julliard committed
17 18
 */

19 20
#include "config.h"

21
#include <assert.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#include <stdio.h>
#include <ctype.h>

#include "wrc.h"
#include "dumpres.h"

/*
 *****************************************************************************
 * Function	: get_typename
 * Syntax	: char *get_typename(resource_t* r)
 * Input	:
 *	r	- Resource description
 * Output	: A pointer to a string representing the resource type
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
39
const char *get_typename(const resource_t* r)
Alexandre Julliard's avatar
Alexandre Julliard committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
{
	switch(r->type){
	case res_acc:	return "ACCELERATOR";
	case res_bmp:	return "BITMAP";
	case res_cur:	return "CURSOR";
	case res_curg:	return "GROUP_CURSOR";
	case res_dlg:	return "DIALOG";
	case res_dlgex:	return "DIALOGEX";
	case res_fnt:	return "FONT";
	case res_ico:	return "ICON";
	case res_icog:	return "GROUP_ICON";
	case res_men:	return "MENU";
	case res_menex:	return "MENUEX";
	case res_rdt:	return "RCDATA";
	case res_stt:	return "STRINGTABLE";
	case res_usr:   return "UserResource";
	case res_msg:	return "MESSAGETABLE";
	case res_ver:	return "VERSIONINFO";
58
	case res_dlginit: return "DLGINIT";
59
	case res_toolbar: return "TOOLBAR";
60 61
	case res_anicur:  return "CURSOR (animated)";
	case res_aniico:  return "ICON (animated)";
Alexandre Julliard's avatar
Alexandre Julliard committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75
	default: 	return "Unknown";
	}
}

/*
 *****************************************************************************
 * Function	: strncpyWtoA
 * Syntax	: char *strncpyWtoA(char *cs, short *ws, int maxlen)
 * Input	:
 *	cs	- Pointer to buffer to receive result
 *	ws	- Source wide-string
 *	maxlen	- Max chars to copy
 * Output	: 'cs'
 * Description	: Copy a unicode string to ascii. Copying stops after the
Andreas Mohr's avatar
Andreas Mohr committed
76
 *		  first occurring '\0' or when maxlen-1 chars are copied. The
Alexandre Julliard's avatar
Alexandre Julliard committed
77 78 79 80
 *		  String is always nul terminated.
 * Remarks	: No codepage translation is done.
 *****************************************************************************
*/
81
static char *strncpyWtoA(char *cs, const WCHAR *ws, int maxlen)
Alexandre Julliard's avatar
Alexandre Julliard committed
82 83
{
	char *cptr = cs;
84
	const WCHAR *wsMax = ws + maxlen - 1;
85
	while(*ws && ws < wsMax)
Alexandre Julliard's avatar
Alexandre Julliard committed
86
	{
87
		if(*ws > 255)
88
			fprintf(stderr, "***Warning: Unicode string contains non-printable chars***\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
		*cptr++ = (char)*ws++;
	}
	*cptr = '\0';
	return cs;
}

/*
 *****************************************************************************
 * Function	: print_string
 * Syntax	: void print_string(string_t *str)
 * Input	:
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
105
static void print_string(const string_t *str)
Alexandre Julliard's avatar
Alexandre Julliard committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
{
	char buffer[512];
	if(!str)
		printf("<none>");
	else if(str->type == str_char)
		printf("\"%s\"", str->str.cstr);
	else
	{
		strncpyWtoA(buffer, str->str.wstr, sizeof(buffer));
		printf("L\"%s\"", buffer);
	}
}

/*
 *****************************************************************************
 * Function	: get_nameid_str
122
 * Syntax	: const char *get_nameid_str(const name_id_t *n)
Alexandre Julliard's avatar
Alexandre Julliard committed
123 124 125 126 127 128 129
 * Input	:
 *	n	- nameid to convert to text
 * Output	: A pointer to the name.
 * Description	:
 * Remarks	: Not reentrant because of static buffer
 *****************************************************************************
*/
130
const char *get_nameid_str(const name_id_t *n)
Alexandre Julliard's avatar
Alexandre Julliard committed
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
{
	static char buffer[256];

	if(!n)
		return "<none>";

	if(n->type == name_ord)
	{
		sprintf(buffer, "%d", n->name.i_name);
		return buffer;
	}
	else if(n->type == name_str)
	{
		if(n->name.s_name->type == str_char)
			return n->name.s_name->str.cstr;
		else
		{
			strncpyWtoA(buffer, n->name.s_name->str.wstr, sizeof(buffer));
			return buffer;
		}
	}
	else
		return "Hoooo, report this: wrong type in nameid";
}

/*
 *****************************************************************************
 * Function	: dump_memopt
 * Syntax	: void dump_memopt(DWORD memopt)
 * Input	:
 *	memopt	- flag bits of the options set
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
167
static void dump_memopt(DWORD memopt)
Alexandre Julliard's avatar
Alexandre Julliard committed
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
{
	printf("Memory/load options: ");
	if(memopt & 0x0040)
		printf("PRELOAD ");
	else
		printf("LOADONCALL ");
	if(memopt & 0x0010)
		printf("MOVEABLE ");
	else
		printf("FIXED ");
	if(memopt & 0x0020)
		printf("PURE ");
	else
		printf("IMPURE ");
	if(memopt & 0x1000)
		printf("DISCARDABLE");
	printf("\n");
}

/*
 *****************************************************************************
 * Function	: dump_lvc
190
 * Syntax	: void dump_lvc(const lvc_t *l)
Alexandre Julliard's avatar
Alexandre Julliard committed
191 192 193 194 195 196 197
 * Input	:
 *	l	- pointer to lvc structure
 * Output	:
 * Description	: Dump language, version and characteristics
 * Remarks	:
 *****************************************************************************
*/
198
static void dump_lvc(const lvc_t *l)
Alexandre Julliard's avatar
Alexandre Julliard committed
199 200 201 202 203 204 205
{
	if(l->language)
		printf("LANGUAGE %04x, %04x\n", l->language->id, l->language->sub);
	else
		printf("LANGUAGE <not set>\n");

	if(l->version)
206
		printf("VERSION %08x\n", *(l->version));
Alexandre Julliard's avatar
Alexandre Julliard committed
207 208 209 210
	else
		printf("VERSION <not set>\n");

	if(l->characts)
211
		printf("CHARACTERISTICS %08x\n", *(l->characts));
Alexandre Julliard's avatar
Alexandre Julliard committed
212 213 214 215 216 217 218
	else
		printf("CHARACTERISTICS <not set>\n");
}

/*
 *****************************************************************************
 * Function	: dump_raw_data
219
 * Syntax	: void dump_raw_data(const raw_data_t *d)
Alexandre Julliard's avatar
Alexandre Julliard committed
220 221 222 223 224 225 226
 * Input	:
 *	d	- Raw data descriptor
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
227
static void dump_raw_data(const raw_data_t *d)
Alexandre Julliard's avatar
Alexandre Julliard committed
228
{
229
	unsigned int n;
Alexandre Julliard's avatar
Alexandre Julliard committed
230 231 232 233 234 235 236 237 238 239 240 241 242 243
	int i;
	int j;

	if(!d)
	{
		printf("<none>");
		return;
	}
	printf("Rawdata size: %d\n", d->size);
	if(debuglevel < 2)
		return;

	for(n = 0; n < d->size; n++)
	{
244
		if((n % 16) == 0)
245
                {
Alexandre Julliard's avatar
Alexandre Julliard committed
246 247 248 249
			if(n)
			{
				printf("- ");
				for(i = 0; i < 16; i++)
250
					printf("%c", isprint(d->data[n-16+i] & 0xff) ? d->data[n-16+i] : '.');
Alexandre Julliard's avatar
Alexandre Julliard committed
251 252 253 254
				printf("\n%08x: ", n);
			}
			else
				printf("%08x: ", n);
255
                }
Alexandre Julliard's avatar
Alexandre Julliard committed
256 257 258 259 260 261 262
		printf("%02x ", d->data[n] & 0xff);
	}
	printf("- ");
	j = d->size % 16;
	if(!j)
		j = 16;
	for(i = 0; i < j; i++)
263
		printf("%c", isprint(d->data[n-j+i] & 0xff) ? d->data[n-j+i] : '.');
Alexandre Julliard's avatar
Alexandre Julliard committed
264 265 266 267 268 269
	printf("\n");
}

/*
 *****************************************************************************
 * Function	: dump_accelerator
270
 * Syntax	: void dump_accelerator(const accelerator_t *acc)
Alexandre Julliard's avatar
Alexandre Julliard committed
271 272 273 274 275 276 277
 * Input	:
 *	acc	- Accelerator resource descriptor
 * Output	: nop
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
278
static void dump_accelerator(const accelerator_t *acc)
Alexandre Julliard's avatar
Alexandre Julliard committed
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
{
	event_t *ev = acc->events;

	dump_memopt(acc->memopt);
	dump_lvc(&(acc->lvc));

	printf("Events: %s\n", ev ? "" : "<none>");
	while(ev)
	{
		printf("Key=");
		if(isprint(ev->key))
			printf("\"%c\"", ev->key);
		else if(iscntrl(ev->key))
			printf("\"^%c\"", ev->key +'@');
		else
			printf("\\x%02x", ev->key & 0xff);

		printf(" Id=%d flags=%04x\n", ev->id, ev->flags);
		ev = ev->next;
	}
}

/*
 *****************************************************************************
 * Function	: dump_cursor
304
 * Syntax	: void dump_cursor(const cursor_t *cur)
Alexandre Julliard's avatar
Alexandre Julliard committed
305 306 307 308 309 310 311
 * Input	:
 *	cur	- Cursor resource descriptor
 * Output	: nop
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
312
static void dump_cursor(const cursor_t *cur)
Alexandre Julliard's avatar
Alexandre Julliard committed
313 314 315 316 317 318 319 320 321 322 323 324
{
	printf("Id: %d\n", cur->id);
	printf("Width: %d\n", cur->width);
	printf("Height: %d\n", cur->height);
	printf("X Hotspot: %d\n", cur->xhot);
	printf("Y Hotspot: %d\n", cur->yhot);
	dump_raw_data(cur->data);
}

/*
 *****************************************************************************
 * Function	: dump_cursor_group
325
 * Syntax	: void dump_cursor_group(const cursor_group_t *cur)
Alexandre Julliard's avatar
Alexandre Julliard committed
326 327 328 329 330 331 332
 * Input	:
 *	cur	- Cursor group resource descriptor
 * Output	: nop
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
333
static void dump_cursor_group(const cursor_group_t *curg)
Alexandre Julliard's avatar
Alexandre Julliard committed
334 335 336 337 338 339 340 341
{
	dump_memopt(curg->memopt);
	printf("There are %d cursors in this group\n", curg->ncursor);
}

/*
 *****************************************************************************
 * Function	: dump_icon
342
 * Syntax	: void dump_icon(const icon_t *ico)
Alexandre Julliard's avatar
Alexandre Julliard committed
343 344 345 346 347 348 349
 * Input	:
 *	ico	- Icon resource descriptor
 * Output	: nop
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
350
static void dump_icon(const icon_t *ico)
Alexandre Julliard's avatar
Alexandre Julliard committed
351 352 353 354 355 356 357 358 359 360 361 362 363
{
	printf("Id: %d\n", ico->id);
	printf("Width: %d\n", ico->width);
	printf("Height: %d\n", ico->height);
	printf("NColor: %d\n", ico->nclr);
	printf("NPlanes: %d\n", ico->planes);
	printf("NBits: %d\n", ico->bits);
	dump_raw_data(ico->data);
}

/*
 *****************************************************************************
 * Function	: dump_icon_group
364
 * Syntax	: void dump_icon_group(const icon_group_t *ico)
Alexandre Julliard's avatar
Alexandre Julliard committed
365 366 367 368 369 370 371
 * Input	:
 *	ico	- Icon group resource descriptor
 * Output	: nop
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
372
static void dump_icon_group(const icon_group_t *icog)
Alexandre Julliard's avatar
Alexandre Julliard committed
373 374 375 376 377
{
	dump_memopt(icog->memopt);
	printf("There are %d icons in this group\n", icog->nicon);
}

378 379 380
/*
 *****************************************************************************
 * Function	: dump_ani_curico
381
 * Syntax	: void dump_ani_curico(const ani_curico_t *ani)
382 383 384 385 386 387 388
 * Input	:
 *	ani	- Animated object resource descriptor
 * Output	: nop
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
389
static void dump_ani_curico(const ani_curico_t *ani)
390 391 392 393 394 395
{
	dump_memopt(ani->memopt);
	dump_lvc(&ani->data->lvc);
	dump_raw_data(ani->data);
}

Alexandre Julliard's avatar
Alexandre Julliard committed
396 397 398
/*
 *****************************************************************************
 * Function	: dump_font
399
 * Syntax	: void dump_font(const font_t *fnt)
Alexandre Julliard's avatar
Alexandre Julliard committed
400 401 402 403 404 405 406
 * Input	:
 *	fnt	- Font resource descriptor
 * Output	: nop
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
407
static void dump_font(const font_t *fnt)
Alexandre Julliard's avatar
Alexandre Julliard committed
408 409
{
	dump_memopt(fnt->memopt);
410
	dump_lvc(&(fnt->data->lvc));
Alexandre Julliard's avatar
Alexandre Julliard committed
411 412 413 414 415 416
	dump_raw_data(fnt->data);
}

/*
 *****************************************************************************
 * Function	: dump_bitmap
417
 * Syntax	: void dump_bitmap(const bitmap_t *bmp)
Alexandre Julliard's avatar
Alexandre Julliard committed
418 419 420 421 422 423 424
 * Input	:
 *	bmp	- Bitmap resource descriptor
 * Output	: nop
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
425
static void dump_bitmap(const bitmap_t *bmp)
Alexandre Julliard's avatar
Alexandre Julliard committed
426 427
{
	dump_memopt(bmp->memopt);
428
	dump_lvc(&(bmp->data->lvc));
Alexandre Julliard's avatar
Alexandre Julliard committed
429 430 431 432 433 434
	dump_raw_data(bmp->data);
}

/*
 *****************************************************************************
 * Function	: dump_rcdata
435
 * Syntax	: void dump_rcdata(const rcdata_t *rdt)
Alexandre Julliard's avatar
Alexandre Julliard committed
436 437 438 439 440 441 442
 * Input	:
 *	rdt	- RCData resource descriptor
 * Output	: nop
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
443
static void dump_rcdata(const rcdata_t *rdt)
Alexandre Julliard's avatar
Alexandre Julliard committed
444 445
{
	dump_memopt(rdt->memopt);
446
	dump_lvc(&(rdt->data->lvc));
Alexandre Julliard's avatar
Alexandre Julliard committed
447 448 449 450 451 452
	dump_raw_data(rdt->data);
}

/*
 *****************************************************************************
 * Function	: dump_user
453
 * Syntax	: void dump_user(const user_t *usr)
Alexandre Julliard's avatar
Alexandre Julliard committed
454 455 456 457 458 459 460
 * Input	:
 *	usr	- User resource descriptor
 * Output	: nop
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
461
static void dump_user(const user_t *usr)
Alexandre Julliard's avatar
Alexandre Julliard committed
462 463
{
	dump_memopt(usr->memopt);
464
	dump_lvc(&(usr->data->lvc));
Alexandre Julliard's avatar
Alexandre Julliard committed
465 466 467 468 469 470 471
	printf("Class %s\n", get_nameid_str(usr->type));
	dump_raw_data(usr->data);
}

/*
 *****************************************************************************
 * Function	: dump_messagetable
472
 * Syntax	: void dump_messagetable(const messagetable_t *msg)
Alexandre Julliard's avatar
Alexandre Julliard committed
473 474 475 476 477 478 479
 * Input	:
 *	msg	- Messagetable resource descriptor
 * Output	: nop
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
480
static void dump_messagetable(const messagetable_t *msg)
Alexandre Julliard's avatar
Alexandre Julliard committed
481
{
482
	dump_memopt(msg->memopt);
483
	dump_lvc(&(msg->data->lvc));
Alexandre Julliard's avatar
Alexandre Julliard committed
484 485 486 487 488 489
	dump_raw_data(msg->data);
}

/*
 *****************************************************************************
 * Function	: dump_stringtable
490
 * Syntax	: void dump_stringtable(const stringtable_t *stt)
Alexandre Julliard's avatar
Alexandre Julliard committed
491 492 493 494 495 496 497
 * Input	:
 *	stt	- Stringtable resource descriptor
 * Output	: nop
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
498
static void dump_stringtable(const stringtable_t *stt)
Alexandre Julliard's avatar
Alexandre Julliard committed
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
{
	int i;
	for(; stt; stt = stt->next)
	{
		printf("{\n");
		dump_memopt(stt->memopt);
		dump_lvc(&(stt->lvc));
		for(i = 0; i < stt->nentries; i++)
		{
			printf("Id=%-5d (%d) ", stt->idbase+i, stt->entries[i].id);
			if(stt->entries[i].str)
				print_string(stt->entries[i].str);
			else
				printf("<none>");
			printf("\n");
		}
		printf("}\n");
	}
}

/*
 *****************************************************************************
 * Function	: dump_control
522
 * Syntax	: void dump_control(const control_t *ctrl)
Alexandre Julliard's avatar
Alexandre Julliard committed
523 524 525 526 527 528 529
 * Input	:
 *	ctrl	- Control resource descriptor
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
530
static void dump_control(const control_t *ctrl)
Alexandre Julliard's avatar
Alexandre Julliard committed
531 532
{
	printf("Control {\n\tClass: %s\n", get_nameid_str(ctrl->ctlclass));
533
	printf("\tText: "); get_nameid_str(ctrl->title); printf("\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
534 535 536
	printf("\tId: %d\n", ctrl->id);
	printf("\tx, y, w, h: %d, %d, %d, %d\n", ctrl->x, ctrl->y, ctrl->width, ctrl->height);
	if(ctrl->gotstyle)
537 538 539
	{
		assert(ctrl->style != NULL);
		assert(ctrl->style->and_mask == 0);
540
		printf("\tStyle: %08x\n", ctrl->style->or_mask);
541
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
542
	if(ctrl->gotexstyle)
543 544 545
	{
		assert(ctrl->exstyle != NULL);
		assert(ctrl->exstyle->and_mask == 0);
546
		printf("\tExStyle: %08x\n", ctrl->exstyle->or_mask);
547
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
548
	if(ctrl->gothelpid)
549
		printf("\tHelpid: %d\n", ctrl->helpid);
Alexandre Julliard's avatar
Alexandre Julliard committed
550 551 552 553 554 555 556 557 558 559 560
	if(ctrl->extra)
	{
		printf("\t");
		dump_raw_data(ctrl->extra);
	}
	printf("}\n");
}

/*
 *****************************************************************************
 * Function	: dump_dialog
561
 * Syntax	: void dump_dialog(const dialog_t *dlg)
Alexandre Julliard's avatar
Alexandre Julliard committed
562 563 564 565 566 567 568
 * Input	:
 *	dlg	- Dialog resource descriptor
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
569
static void dump_dialog(const dialog_t *dlg)
Alexandre Julliard's avatar
Alexandre Julliard committed
570 571 572 573 574 575 576
{
	control_t *c = dlg->controls;

	dump_memopt(dlg->memopt);
	dump_lvc(&(dlg->lvc));
	printf("x, y, w, h: %d, %d, %d, %d\n", dlg->x, dlg->y, dlg->width, dlg->height);
	if(dlg->gotstyle)
577 578 579
	{
		assert(dlg->style != NULL);
		assert(dlg->style->and_mask == 0);
580
		printf("Style: %08x\n", dlg->style->or_mask);
581

582
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
583
	if(dlg->gotexstyle)
584 585 586
	{
		assert(dlg->exstyle != NULL);
		assert(dlg->exstyle->and_mask == 0);
587
		printf("ExStyle: %08x\n", dlg->exstyle->or_mask);
588
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610
	printf("Menu: %s\n", get_nameid_str(dlg->menu));
	printf("Class: %s\n", get_nameid_str(dlg->dlgclass));
	printf("Title: "); print_string(dlg->title); printf("\n");
	printf("Font: ");
	if(!dlg->font)
		printf("<none>\n");
	else
	{
		printf("%d, ", dlg->font->size);
		print_string(dlg->font->name);
		printf("\n");
	}
	while(c)
	{
		dump_control(c);
		c = c->next;
	}
}

/*
 *****************************************************************************
 * Function	: dump_dialogex
611
 * Syntax	: void dump_dialogex(const dialogex_t *dlgex)
Alexandre Julliard's avatar
Alexandre Julliard committed
612 613 614 615 616 617 618
 * Input	:
 *	dlgex	- DialogEx resource descriptor
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
619
static void dump_dialogex(const dialogex_t *dlgex)
Alexandre Julliard's avatar
Alexandre Julliard committed
620
{
621
	const control_t *c = dlgex->controls;
Alexandre Julliard's avatar
Alexandre Julliard committed
622 623 624 625 626

	dump_memopt(dlgex->memopt);
	dump_lvc(&(dlgex->lvc));
	printf("x, y, w, h: %d, %d, %d, %d\n", dlgex->x, dlgex->y, dlgex->width, dlgex->height);
	if(dlgex->gotstyle)
627 628 629
	{
		assert(dlgex->style != NULL);
		assert(dlgex->style->and_mask == 0);
630
		printf("Style: %08x\n", dlgex->style->or_mask);
631
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
632
	if(dlgex->gotexstyle)
633 634 635
	{
		assert(dlgex->exstyle != NULL);
		assert(dlgex->exstyle->and_mask == 0);
636
		printf("ExStyle: %08x\n", dlgex->exstyle->or_mask);
637
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
638
	if(dlgex->gothelpid)
639
		printf("Helpid: %d\n", dlgex->helpid);
Alexandre Julliard's avatar
Alexandre Julliard committed
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
	printf("Menu: %s\n", get_nameid_str(dlgex->menu));
	printf("Class: %s\n", get_nameid_str(dlgex->dlgclass));
	printf("Title: "); print_string(dlgex->title); printf("\n");
	printf("Font: ");
	if(!dlgex->font)
		printf("<none>\n");
	else
	{
		printf("%d, ", dlgex->font->size);
		print_string(dlgex->font->name);
		printf(", %d, %d\n", dlgex->font->weight, dlgex->font->italic);
	}
	while(c)
	{
		dump_control(c);
		c = c->next;
	}
}

/*
 *****************************************************************************
 * Function	: dump_menu_item
662
 * Syntax	: void dump_menu_item(const menu_item_t *item)
Alexandre Julliard's avatar
Alexandre Julliard committed
663 664 665 666 667 668
 * Input	:
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
669
static void dump_menu_item(const menu_item_t *item)
Alexandre Julliard's avatar
Alexandre Julliard committed
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685
{
	while(item)
	{
		if(item->popup)
		{
			printf("POPUP ");
			print_string(item->name);
			printf("\n");
			dump_menu_item(item->popup);
		}
		else
		{
			printf("MENUITEM ");
			if(item->name)
			{
				print_string(item->name);
686
				printf(", %d, %08x", item->id, item->state);
Alexandre Julliard's avatar
Alexandre Julliard committed
687 688 689 690 691 692 693 694 695 696 697 698
			}
			else
				printf("SEPARATOR");
			printf("\n");
		}
		item = item->next;
	}
}

/*
 *****************************************************************************
 * Function	: dump_menu
699
 * Syntax	: void dump_menu(const menu_t *men)
Alexandre Julliard's avatar
Alexandre Julliard committed
700 701 702 703 704 705 706
 * Input	:
 *	men	- Menu resource descriptor
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
707
static void dump_menu(const menu_t *men)
Alexandre Julliard's avatar
Alexandre Julliard committed
708 709 710 711 712 713 714 715 716
{
	dump_memopt(men->memopt);
	dump_lvc(&(men->lvc));
	dump_menu_item(men->items);
}

/*
 *****************************************************************************
 * Function	: dump_menuex_item
717
 * Syntax	: void dump_menuex_item(const menuex_item_t *item)
Alexandre Julliard's avatar
Alexandre Julliard committed
718 719 720 721 722 723
 * Input	:
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
724
static void dump_menuex_item(const menuex_item_t *item)
Alexandre Julliard's avatar
Alexandre Julliard committed
725 726 727 728 729 730 731 732 733 734
{
	while(item)
	{
		if(item->popup)
		{
			printf("POPUP ");
			print_string(item->name);
			if(item->gotid)
				printf(", Id=%d", item->id);
			if(item->gottype)
735
				printf(", Type=%d", item->type);
Alexandre Julliard's avatar
Alexandre Julliard committed
736
			if(item->gotstate)
737
				printf(", State=%08x", item->state);
Alexandre Julliard's avatar
Alexandre Julliard committed
738 739 740 741 742 743 744 745 746 747 748 749 750 751
			if(item->gothelpid)
				printf(", HelpId=%d", item->helpid);
			printf("\n");
			dump_menuex_item(item->popup);
		}
		else
		{
			printf("MENUITEM ");
			if(item->name)
			{
				print_string(item->name);
				if(item->gotid)
					printf(", Id=%d", item->id);
				if(item->gottype)
752
					printf(", Type=%d", item->type);
Alexandre Julliard's avatar
Alexandre Julliard committed
753
				if(item->gotstate)
754
					printf(", State=%08x", item->state);
Alexandre Julliard's avatar
Alexandre Julliard committed
755 756 757 758 759 760 761 762 763 764 765 766 767 768
				if(item->gothelpid)
					printf(", HelpId=%d", item->helpid);
			}
			else
				printf("SEPARATOR");
			printf("\n");
		}
		item = item->next;
	}
}

/*
 *****************************************************************************
 * Function	: dump_menuex
769
 * Syntax	: void dump_menuex(const menuex_t *menex)
Alexandre Julliard's avatar
Alexandre Julliard committed
770 771 772 773 774 775 776
 * Input	:
 *	menex	- MenuEx resource descriptor
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
777
static void dump_menuex(const menuex_t *menex)
Alexandre Julliard's avatar
Alexandre Julliard committed
778 779 780 781 782 783 784 785 786
{
	dump_memopt(menex->memopt);
	dump_lvc(&(menex->lvc));
	dump_menuex_item(menex->items);
}

/*
 *****************************************************************************
 * Function	: dump_ver_value
787
 * Syntax	: void dump_ver_value(const ver_value_t *val)
Alexandre Julliard's avatar
Alexandre Julliard committed
788 789 790 791 792 793
 * Input	:
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
794
static void dump_ver_block(const ver_block_t *);	/* Forward ref */
795

796
static void dump_ver_value(const ver_value_t *val)
Alexandre Julliard's avatar
Alexandre Julliard committed
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823
{
	if(val->type == val_str)
	{
		printf("VALUE ");
		print_string(val->key);
		printf(" ");
		print_string(val->value.str);
		printf("\n");
	}
	else if(val->type == val_words)
	{
		int i;
		printf("VALUE");
		print_string(val->key);
		for(i = 0; i < val->value.words->nwords; i++)
			printf(" %04x", val->value.words->words[i]);
		printf("\n");
	}
	else if(val->type == val_block)
	{
		dump_ver_block(val->value.block);
	}
}

/*
 *****************************************************************************
 * Function	: dump_ver_block
824
 * Syntax	: void dump_ver_block(const ver_block_t *blk)
Alexandre Julliard's avatar
Alexandre Julliard committed
825 826 827 828 829 830
 * Input	:
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
831
static void dump_ver_block(const ver_block_t *blk)
Alexandre Julliard's avatar
Alexandre Julliard committed
832
{
833
	const ver_value_t *val = blk->values;
Alexandre Julliard's avatar
Alexandre Julliard committed
834 835 836 837 838 839 840 841 842 843 844 845 846 847
	printf("BLOCK ");
	print_string(blk->name);
	printf("\n{\n");
	while(val)
	{
		dump_ver_value(val);
		val = val->next;
	}
	printf("}\n");
}

/*
 *****************************************************************************
 * Function	: dump_versioninfo
848
 * Syntax	: void dump_versioninfo(const versioninfo_t *ver)
Alexandre Julliard's avatar
Alexandre Julliard committed
849 850 851 852 853 854 855
 * Input	:
 *	ver	- Versioninfo resource descriptor
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
856
static void dump_versioninfo(const versioninfo_t *ver)
Alexandre Julliard's avatar
Alexandre Julliard committed
857
{
858
	const ver_block_t *blk = ver->blocks;
Alexandre Julliard's avatar
Alexandre Julliard committed
859

860 861
	dump_lvc(&(ver->lvc));

Alexandre Julliard's avatar
Alexandre Julliard committed
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890
	if(ver->gotit.fv)
		printf("FILEVERSION %04x, %04x, %04x, %04x\n",
			ver->filever_maj1,
			ver->filever_maj2,
			ver->filever_min1,
			ver->filever_min2);
	if(ver->gotit.pv)
		printf("PRODUCTVERSION %04x, %04x, %04x, %04x\n",
			ver->prodver_maj1,
			ver->prodver_maj2,
			ver->prodver_min1,
			ver->prodver_min2);
	if(ver->gotit.fo)
		printf("FILEOS %08x\n", ver->fileos);
	if(ver->gotit.ff)
		printf("FILEFLAGS %08x\n", ver->fileflags);
	if(ver->gotit.ffm)
		printf("FILEFLAGSMASK %08x\n", ver->fileflagsmask);
	if(ver->gotit.ft)
		printf("FILETYPE %08x\n", ver->filetype);
	if(ver->gotit.fst)
		printf("FILESUBTYPE %08x\n", ver->filesubtype);
	while(blk)
	{
		dump_ver_block(blk);
		blk = blk->next;
	}
}

891 892 893
/*
 *****************************************************************************
 * Function	: dump_toolbar_item
894
 * Syntax	: void dump_toolbar_item(const toolbar_item_t *item)
895 896 897 898 899 900
 * Input	:
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
901
static void dump_toolbar_items(const toolbar_item_t *items)
902 903 904 905 906 907 908 909 910
{
	while(items)
	{
	        if(items->id)
			printf("   BUTTON %d", items->id );
		else
	      		printf("   SEPARATOR");

		printf("\n");
911

912 913 914 915 916 917 918
		items = items->next;
	}
}

/*
 *****************************************************************************
 * Function	: dump_toolbar
919
 * Syntax	: void dump_toolbar(const toolbar_t *toolbar)
920 921 922 923 924 925 926
 * Input	:
 *	toolbar	- Toolbar resource descriptor
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
927
static void dump_toolbar(const toolbar_t *toolbar)
928 929 930 931 932 933
{
	dump_memopt(toolbar->memopt);
	dump_lvc(&(toolbar->lvc));
	dump_toolbar_items(toolbar->items);
}

934 935 936
/*
 *****************************************************************************
 * Function	: dump_dlginit
937
 * Syntax	: void dump_dlginit(const dlginit_t *dit)
938 939 940 941 942 943 944
 * Input	:
 *	dit	- DlgInit resource descriptor
 * Output	:
 * Description	:
 * Remarks	:
 *****************************************************************************
*/
945
static void dump_dlginit(const dlginit_t *dit)
946 947
{
	dump_memopt(dit->memopt);
948
	dump_lvc(&(dit->data->lvc));
949 950 951
	dump_raw_data(dit->data);
}

Alexandre Julliard's avatar
Alexandre Julliard committed
952 953 954
/*
 *****************************************************************************
 * Function	: dump_resources
955
 * Syntax	: void dump_resources(const resource_t *top)
Alexandre Julliard's avatar
Alexandre Julliard committed
956 957 958 959 960 961 962 963
 * Input	:
 *	top	- Top of the resource tree
 * Output	:
 *	nop
 * Description	: Dump the parsed resource-tree to stdout
 * Remarks	:
 *****************************************************************************
*/
964
void dump_resources(const resource_t *top)
Alexandre Julliard's avatar
Alexandre Julliard committed
965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021
{
	printf("Internal resource-tree dump:\n");
	while(top)
	{
		printf("Resource: %s\nId: %s\n",
		       get_typename(top),
		       get_nameid_str(top->name));
		switch(top->type)
		{
		case res_acc:
			dump_accelerator(top->res.acc);
			break;
		case res_bmp:
			dump_bitmap(top->res.bmp);
			break;
		case res_cur:
			dump_cursor(top->res.cur);
			break;
		case res_curg:
			dump_cursor_group(top->res.curg);
			break;
		case res_dlg:
			dump_dialog(top->res.dlg);
			break;
		case res_dlgex:
			dump_dialogex(top->res.dlgex);
			break;
		case res_fnt:
			dump_font(top->res.fnt);
			break;
		case res_icog:
			dump_icon_group(top->res.icog);
			break;
		case res_ico:
			dump_icon(top->res.ico);
			break;
		case res_men:
			dump_menu(top->res.men);
			break;
		case res_menex:
			dump_menuex(top->res.menex);
			break;
		case res_rdt:
			dump_rcdata(top->res.rdt);
			break;
		case res_stt:
			dump_stringtable(top->res.stt);
			break;
		case res_usr:
			dump_user(top->res.usr);
			break;
		case res_msg:
			dump_messagetable(top->res.msg);
			break;
		case res_ver:
			dump_versioninfo(top->res.ver);
			break;
1022 1023 1024
		case res_dlginit:
			dump_dlginit(top->res.dlgi);
			break;
1025 1026 1027
		case res_toolbar:
			dump_toolbar(top->res.tbt);
			break;
1028 1029 1030 1031
		case res_anicur:
		case res_aniico:
			dump_ani_curico(top->res.ani);
			break;
Alexandre Julliard's avatar
Alexandre Julliard committed
1032 1033 1034 1035 1036 1037 1038
		default:
			printf("Report this: Unknown resource type parsed %08x\n", top->type);
		}
		printf("\n");
		top = top->next;
	}
}