dumpres.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. /*
  2. * Copyright 1998 Bertho A. Stultiens (BS)
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * 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
  17. */
  18. #include "config.h"
  19. #include <assert.h>
  20. #include <stdio.h>
  21. #include <ctype.h>
  22. #include "wrc.h"
  23. #include "dumpres.h"
  24. /*
  25. *****************************************************************************
  26. * Function : get_typename
  27. * Syntax : char *get_typename(resource_t* r)
  28. * Input :
  29. * r - Resource description
  30. * Output : A pointer to a string representing the resource type
  31. * Description :
  32. * Remarks :
  33. *****************************************************************************
  34. */
  35. const char *get_typename(const resource_t* r)
  36. {
  37. switch(r->type){
  38. case res_acc: return "ACCELERATOR";
  39. case res_bmp: return "BITMAP";
  40. case res_cur: return "CURSOR";
  41. case res_curg: return "GROUP_CURSOR";
  42. case res_dlg: return "DIALOG";
  43. case res_fnt: return "FONT";
  44. case res_ico: return "ICON";
  45. case res_icog: return "GROUP_ICON";
  46. case res_men: return "MENU";
  47. case res_rdt: return "RCDATA";
  48. case res_stt: return "STRINGTABLE";
  49. case res_usr: return "UserResource";
  50. case res_msg: return "MESSAGETABLE";
  51. case res_ver: return "VERSIONINFO";
  52. case res_dlginit: return "DLGINIT";
  53. case res_toolbar: return "TOOLBAR";
  54. case res_anicur: return "CURSOR (animated)";
  55. case res_aniico: return "ICON (animated)";
  56. default: return "Unknown";
  57. }
  58. }
  59. /*
  60. *****************************************************************************
  61. * Function : strncpyWtoA
  62. * Syntax : char *strncpyWtoA(char *cs, short *ws, int maxlen)
  63. * Input :
  64. * cs - Pointer to buffer to receive result
  65. * ws - Source wide-string
  66. * maxlen - Max chars to copy
  67. * Output : 'cs'
  68. * Description : Copy a unicode string to ascii. Copying stops after the
  69. * first occurring '\0' or when maxlen-1 chars are copied. The
  70. * String is always nul terminated.
  71. * Remarks : No codepage translation is done.
  72. *****************************************************************************
  73. */
  74. static char *strncpyWtoA(char *cs, const WCHAR *ws, int maxlen)
  75. {
  76. char *cptr = cs;
  77. const WCHAR *wsMax = ws + maxlen - 1;
  78. while(*ws && ws < wsMax)
  79. {
  80. if(*ws > 255)
  81. fprintf(stderr, "***Warning: Unicode string contains non-printable chars***\n");
  82. *cptr++ = (char)*ws++;
  83. }
  84. *cptr = '\0';
  85. return cs;
  86. }
  87. /*
  88. *****************************************************************************
  89. * Function : print_string
  90. * Syntax : void print_string(string_t *str)
  91. * Input :
  92. * Output :
  93. * Description :
  94. * Remarks :
  95. *****************************************************************************
  96. */
  97. static void print_string(const string_t *str)
  98. {
  99. char buffer[512];
  100. if(!str)
  101. printf("<none>");
  102. else if(str->type == str_char)
  103. printf("\"%s\"", str->str.cstr);
  104. else
  105. {
  106. strncpyWtoA(buffer, str->str.wstr, sizeof(buffer));
  107. printf("L\"%s\"", buffer);
  108. }
  109. }
  110. /*
  111. *****************************************************************************
  112. * Function : get_nameid_str
  113. * Syntax : const char *get_nameid_str(const name_id_t *n)
  114. * Input :
  115. * n - nameid to convert to text
  116. * Output : A pointer to the name.
  117. * Description :
  118. * Remarks : Not reentrant because of static buffer
  119. *****************************************************************************
  120. */
  121. const char *get_nameid_str(const name_id_t *n)
  122. {
  123. static char buffer[256];
  124. if(!n)
  125. return "<none>";
  126. if(n->type == name_ord)
  127. {
  128. sprintf(buffer, "%d", n->name.i_name);
  129. return buffer;
  130. }
  131. else if(n->type == name_str)
  132. {
  133. if(n->name.s_name->type == str_char)
  134. return n->name.s_name->str.cstr;
  135. else
  136. {
  137. strncpyWtoA(buffer, n->name.s_name->str.wstr, sizeof(buffer));
  138. return buffer;
  139. }
  140. }
  141. else
  142. return "Hoooo, report this: wrong type in nameid";
  143. }
  144. /*
  145. *****************************************************************************
  146. * Function : dump_memopt
  147. * Syntax : void dump_memopt(DWORD memopt)
  148. * Input :
  149. * memopt - flag bits of the options set
  150. * Output :
  151. * Description :
  152. * Remarks :
  153. *****************************************************************************
  154. */
  155. static void dump_memopt(DWORD memopt)
  156. {
  157. printf("Memory/load options: ");
  158. if(memopt & 0x0040)
  159. printf("PRELOAD ");
  160. else
  161. printf("LOADONCALL ");
  162. if(memopt & 0x0010)
  163. printf("MOVEABLE ");
  164. else
  165. printf("FIXED ");
  166. if(memopt & 0x0020)
  167. printf("PURE ");
  168. else
  169. printf("IMPURE ");
  170. if(memopt & 0x1000)
  171. printf("DISCARDABLE");
  172. printf("\n");
  173. }
  174. /*
  175. *****************************************************************************
  176. * Function : dump_lvc
  177. * Syntax : void dump_lvc(const lvc_t *l)
  178. * Input :
  179. * l - pointer to lvc structure
  180. * Output :
  181. * Description : Dump language, version and characteristics
  182. * Remarks :
  183. *****************************************************************************
  184. */
  185. static void dump_lvc(const lvc_t *l)
  186. {
  187. if(l->language)
  188. printf("LANGUAGE %04x, %04x\n", l->language->id, l->language->sub);
  189. else
  190. printf("LANGUAGE <not set>\n");
  191. if(l->version)
  192. printf("VERSION %08x\n", *(l->version));
  193. else
  194. printf("VERSION <not set>\n");
  195. if(l->characts)
  196. printf("CHARACTERISTICS %08x\n", *(l->characts));
  197. else
  198. printf("CHARACTERISTICS <not set>\n");
  199. }
  200. /*
  201. *****************************************************************************
  202. * Function : dump_raw_data
  203. * Syntax : void dump_raw_data(const raw_data_t *d)
  204. * Input :
  205. * d - Raw data descriptor
  206. * Output :
  207. * Description :
  208. * Remarks :
  209. *****************************************************************************
  210. */
  211. static void dump_raw_data(const raw_data_t *d)
  212. {
  213. unsigned int n;
  214. int i;
  215. int j;
  216. if(!d)
  217. {
  218. printf("<none>");
  219. return;
  220. }
  221. printf("Rawdata size: %d\n", d->size);
  222. if(debuglevel < 2)
  223. return;
  224. for(n = 0; n < d->size; n++)
  225. {
  226. if((n % 16) == 0)
  227. {
  228. if(n)
  229. {
  230. printf("- ");
  231. for(i = 0; i < 16; i++)
  232. printf("%c", isprint(d->data[n-16+i] & 0xff) ? d->data[n-16+i] : '.');
  233. printf("\n%08x: ", n);
  234. }
  235. else
  236. printf("%08x: ", n);
  237. }
  238. printf("%02x ", d->data[n] & 0xff);
  239. }
  240. printf("- ");
  241. j = d->size % 16;
  242. if(!j)
  243. j = 16;
  244. for(i = 0; i < j; i++)
  245. printf("%c", isprint(d->data[n-j+i] & 0xff) ? d->data[n-j+i] : '.');
  246. printf("\n");
  247. }
  248. /*
  249. *****************************************************************************
  250. * Function : dump_accelerator
  251. * Syntax : void dump_accelerator(const accelerator_t *acc)
  252. * Input :
  253. * acc - Accelerator resource descriptor
  254. * Output : nop
  255. * Description :
  256. * Remarks :
  257. *****************************************************************************
  258. */
  259. static void dump_accelerator(const accelerator_t *acc)
  260. {
  261. event_t *ev = acc->events;
  262. dump_memopt(acc->memopt);
  263. dump_lvc(&(acc->lvc));
  264. printf("Events: %s\n", ev ? "" : "<none>");
  265. while(ev)
  266. {
  267. printf("Key=");
  268. if(isprint(ev->key))
  269. printf("\"%c\"", ev->key);
  270. else if(iscntrl(ev->key))
  271. printf("\"^%c\"", ev->key +'@');
  272. else
  273. printf("\\x%02x", ev->key & 0xff);
  274. printf(" Id=%d flags=%04x\n", ev->id, ev->flags);
  275. ev = ev->next;
  276. }
  277. }
  278. /*
  279. *****************************************************************************
  280. * Function : dump_cursor
  281. * Syntax : void dump_cursor(const cursor_t *cur)
  282. * Input :
  283. * cur - Cursor resource descriptor
  284. * Output : nop
  285. * Description :
  286. * Remarks :
  287. *****************************************************************************
  288. */
  289. static void dump_cursor(const cursor_t *cur)
  290. {
  291. printf("Id: %d\n", cur->id);
  292. printf("Width: %d\n", cur->width);
  293. printf("Height: %d\n", cur->height);
  294. printf("X Hotspot: %d\n", cur->xhot);
  295. printf("Y Hotspot: %d\n", cur->yhot);
  296. dump_raw_data(cur->data);
  297. }
  298. /*
  299. *****************************************************************************
  300. * Function : dump_cursor_group
  301. * Syntax : void dump_cursor_group(const cursor_group_t *cur)
  302. * Input :
  303. * cur - Cursor group resource descriptor
  304. * Output : nop
  305. * Description :
  306. * Remarks :
  307. *****************************************************************************
  308. */
  309. static void dump_cursor_group(const cursor_group_t *curg)
  310. {
  311. dump_memopt(curg->memopt);
  312. printf("There are %d cursors in this group\n", curg->ncursor);
  313. }
  314. /*
  315. *****************************************************************************
  316. * Function : dump_icon
  317. * Syntax : void dump_icon(const icon_t *ico)
  318. * Input :
  319. * ico - Icon resource descriptor
  320. * Output : nop
  321. * Description :
  322. * Remarks :
  323. *****************************************************************************
  324. */
  325. static void dump_icon(const icon_t *ico)
  326. {
  327. printf("Id: %d\n", ico->id);
  328. printf("Width: %d\n", ico->width);
  329. printf("Height: %d\n", ico->height);
  330. printf("NColor: %d\n", ico->nclr);
  331. printf("NPlanes: %d\n", ico->planes);
  332. printf("NBits: %d\n", ico->bits);
  333. dump_raw_data(ico->data);
  334. }
  335. /*
  336. *****************************************************************************
  337. * Function : dump_icon_group
  338. * Syntax : void dump_icon_group(const icon_group_t *ico)
  339. * Input :
  340. * ico - Icon group resource descriptor
  341. * Output : nop
  342. * Description :
  343. * Remarks :
  344. *****************************************************************************
  345. */
  346. static void dump_icon_group(const icon_group_t *icog)
  347. {
  348. dump_memopt(icog->memopt);
  349. printf("There are %d icons in this group\n", icog->nicon);
  350. }
  351. /*
  352. *****************************************************************************
  353. * Function : dump_ani_curico
  354. * Syntax : void dump_ani_curico(const ani_curico_t *ani)
  355. * Input :
  356. * ani - Animated object resource descriptor
  357. * Output : nop
  358. * Description :
  359. * Remarks :
  360. *****************************************************************************
  361. */
  362. static void dump_ani_curico(const ani_curico_t *ani)
  363. {
  364. dump_memopt(ani->memopt);
  365. dump_lvc(&ani->data->lvc);
  366. dump_raw_data(ani->data);
  367. }
  368. /*
  369. *****************************************************************************
  370. * Function : dump_font
  371. * Syntax : void dump_font(const font_t *fnt)
  372. * Input :
  373. * fnt - Font resource descriptor
  374. * Output : nop
  375. * Description :
  376. * Remarks :
  377. *****************************************************************************
  378. */
  379. static void dump_font(const font_t *fnt)
  380. {
  381. dump_memopt(fnt->memopt);
  382. dump_lvc(&(fnt->data->lvc));
  383. dump_raw_data(fnt->data);
  384. }
  385. /*
  386. *****************************************************************************
  387. * Function : dump_bitmap
  388. * Syntax : void dump_bitmap(const bitmap_t *bmp)
  389. * Input :
  390. * bmp - Bitmap resource descriptor
  391. * Output : nop
  392. * Description :
  393. * Remarks :
  394. *****************************************************************************
  395. */
  396. static void dump_bitmap(const bitmap_t *bmp)
  397. {
  398. dump_memopt(bmp->memopt);
  399. dump_lvc(&(bmp->data->lvc));
  400. dump_raw_data(bmp->data);
  401. }
  402. /*
  403. *****************************************************************************
  404. * Function : dump_rcdata
  405. * Syntax : void dump_rcdata(const rcdata_t *rdt)
  406. * Input :
  407. * rdt - RCData resource descriptor
  408. * Output : nop
  409. * Description :
  410. * Remarks :
  411. *****************************************************************************
  412. */
  413. static void dump_rcdata(const rcdata_t *rdt)
  414. {
  415. dump_memopt(rdt->memopt);
  416. dump_lvc(&(rdt->data->lvc));
  417. dump_raw_data(rdt->data);
  418. }
  419. /*
  420. *****************************************************************************
  421. * Function : dump_user
  422. * Syntax : void dump_user(const user_t *usr)
  423. * Input :
  424. * usr - User resource descriptor
  425. * Output : nop
  426. * Description :
  427. * Remarks :
  428. *****************************************************************************
  429. */
  430. static void dump_user(const user_t *usr)
  431. {
  432. dump_memopt(usr->memopt);
  433. dump_lvc(&(usr->data->lvc));
  434. printf("Class %s\n", get_nameid_str(usr->type));
  435. dump_raw_data(usr->data);
  436. }
  437. /*
  438. *****************************************************************************
  439. * Function : dump_messagetable
  440. * Syntax : void dump_messagetable(const messagetable_t *msg)
  441. * Input :
  442. * msg - Messagetable resource descriptor
  443. * Output : nop
  444. * Description :
  445. * Remarks :
  446. *****************************************************************************
  447. */
  448. static void dump_messagetable(const messagetable_t *msg)
  449. {
  450. dump_memopt(msg->memopt);
  451. dump_lvc(&(msg->data->lvc));
  452. dump_raw_data(msg->data);
  453. }
  454. /*
  455. *****************************************************************************
  456. * Function : dump_stringtable
  457. * Syntax : void dump_stringtable(const stringtable_t *stt)
  458. * Input :
  459. * stt - Stringtable resource descriptor
  460. * Output : nop
  461. * Description :
  462. * Remarks :
  463. *****************************************************************************
  464. */
  465. static void dump_stringtable(const stringtable_t *stt)
  466. {
  467. int i;
  468. for(; stt; stt = stt->next)
  469. {
  470. printf("{\n");
  471. dump_memopt(stt->memopt);
  472. dump_lvc(&(stt->lvc));
  473. for(i = 0; i < stt->nentries; i++)
  474. {
  475. printf("Id=%-5d (%d) ", stt->idbase+i, stt->entries[i].id);
  476. if(stt->entries[i].str)
  477. print_string(stt->entries[i].str);
  478. else
  479. printf("<none>");
  480. printf("\n");
  481. }
  482. printf("}\n");
  483. }
  484. }
  485. /*
  486. *****************************************************************************
  487. * Function : dump_control
  488. * Syntax : void dump_control(const control_t *ctrl)
  489. * Input :
  490. * ctrl - Control resource descriptor
  491. * Output :
  492. * Description :
  493. * Remarks :
  494. *****************************************************************************
  495. */
  496. static void dump_control(const control_t *ctrl)
  497. {
  498. printf("Control {\n\tClass: %s\n", get_nameid_str(ctrl->ctlclass));
  499. printf("\tText: "); get_nameid_str(ctrl->title); printf("\n");
  500. printf("\tId: %d\n", ctrl->id);
  501. printf("\tx, y, w, h: %d, %d, %d, %d\n", ctrl->x, ctrl->y, ctrl->width, ctrl->height);
  502. if(ctrl->gotstyle)
  503. {
  504. assert(ctrl->style != NULL);
  505. assert(ctrl->style->and_mask == 0);
  506. printf("\tStyle: %08x\n", ctrl->style->or_mask);
  507. }
  508. if(ctrl->gotexstyle)
  509. {
  510. assert(ctrl->exstyle != NULL);
  511. assert(ctrl->exstyle->and_mask == 0);
  512. printf("\tExStyle: %08x\n", ctrl->exstyle->or_mask);
  513. }
  514. if(ctrl->gothelpid)
  515. printf("\tHelpid: %d\n", ctrl->helpid);
  516. if(ctrl->extra)
  517. {
  518. printf("\t");
  519. dump_raw_data(ctrl->extra);
  520. }
  521. printf("}\n");
  522. }
  523. /*
  524. *****************************************************************************
  525. * Function : dump_dialog
  526. * Syntax : void dump_dialog(const dialog_t *dlg)
  527. * Input :
  528. * dlg - Dialog resource descriptor
  529. * Output :
  530. * Description :
  531. * Remarks :
  532. *****************************************************************************
  533. */
  534. static void dump_dialog(const dialog_t *dlg)
  535. {
  536. control_t *c = dlg->controls;
  537. dump_memopt(dlg->memopt);
  538. dump_lvc(&(dlg->lvc));
  539. printf("x, y, w, h: %d, %d, %d, %d\n", dlg->x, dlg->y, dlg->width, dlg->height);
  540. if(dlg->gotstyle)
  541. {
  542. assert(dlg->style != NULL);
  543. assert(dlg->style->and_mask == 0);
  544. printf("Style: %08x\n", dlg->style->or_mask);
  545. }
  546. if(dlg->gotexstyle)
  547. {
  548. assert(dlg->exstyle != NULL);
  549. assert(dlg->exstyle->and_mask == 0);
  550. printf("ExStyle: %08x\n", dlg->exstyle->or_mask);
  551. }
  552. printf("Menu: %s\n", get_nameid_str(dlg->menu));
  553. printf("Class: %s\n", get_nameid_str(dlg->dlgclass));
  554. printf("Title: "); print_string(dlg->title); printf("\n");
  555. printf("Font: ");
  556. if(!dlg->font)
  557. printf("<none>\n");
  558. else
  559. {
  560. printf("%d, ", dlg->font->size);
  561. print_string(dlg->font->name);
  562. printf("\n");
  563. }
  564. while(c)
  565. {
  566. dump_control(c);
  567. c = c->next;
  568. }
  569. }
  570. /*
  571. *****************************************************************************
  572. * Function : dump_menu_item
  573. * Syntax : void dump_menu_item(const menuex_item_t *item)
  574. * Input :
  575. * Output :
  576. * Description :
  577. * Remarks :
  578. *****************************************************************************
  579. */
  580. static void dump_menu_item(const menu_item_t *item)
  581. {
  582. while(item)
  583. {
  584. if(item->popup)
  585. {
  586. printf("POPUP ");
  587. print_string(item->name);
  588. if(item->gotid)
  589. printf(", Id=%d", item->id);
  590. if(item->gottype)
  591. printf(", Type=%d", item->type);
  592. if(item->gotstate)
  593. printf(", State=%08x", item->state);
  594. if(item->gothelpid)
  595. printf(", HelpId=%d", item->helpid);
  596. printf("\n");
  597. dump_menu_item(item->popup);
  598. }
  599. else
  600. {
  601. printf("MENUITEM ");
  602. if(item->name)
  603. {
  604. print_string(item->name);
  605. if(item->gotid)
  606. printf(", Id=%d", item->id);
  607. if(item->gottype)
  608. printf(", Type=%d", item->type);
  609. if(item->gotstate)
  610. printf(", State=%08x", item->state);
  611. if(item->gothelpid)
  612. printf(", HelpId=%d", item->helpid);
  613. }
  614. else
  615. printf("SEPARATOR");
  616. printf("\n");
  617. }
  618. item = item->next;
  619. }
  620. }
  621. /*
  622. *****************************************************************************
  623. * Function : dump_menu
  624. * Syntax : void dump_menu(const menu_t *men)
  625. * Input :
  626. * men - Menu resource descriptor
  627. * Output :
  628. * Description :
  629. * Remarks :
  630. *****************************************************************************
  631. */
  632. static void dump_menu(const menu_t *men)
  633. {
  634. dump_memopt(men->memopt);
  635. dump_lvc(&(men->lvc));
  636. dump_menu_item(men->items);
  637. }
  638. /*
  639. *****************************************************************************
  640. * Function : dump_ver_value
  641. * Syntax : void dump_ver_value(const ver_value_t *val)
  642. * Input :
  643. * Output :
  644. * Description :
  645. * Remarks :
  646. *****************************************************************************
  647. */
  648. static void dump_ver_block(const ver_block_t *); /* Forward ref */
  649. static void dump_ver_value(const ver_value_t *val)
  650. {
  651. if(val->type == val_str)
  652. {
  653. printf("VALUE ");
  654. print_string(val->key);
  655. printf(" ");
  656. print_string(val->value.str);
  657. printf("\n");
  658. }
  659. else if(val->type == val_words)
  660. {
  661. int i;
  662. printf("VALUE");
  663. print_string(val->key);
  664. for(i = 0; i < val->value.words->nwords; i++)
  665. printf(" %04x", val->value.words->words[i]);
  666. printf("\n");
  667. }
  668. else if(val->type == val_block)
  669. {
  670. dump_ver_block(val->value.block);
  671. }
  672. }
  673. /*
  674. *****************************************************************************
  675. * Function : dump_ver_block
  676. * Syntax : void dump_ver_block(const ver_block_t *blk)
  677. * Input :
  678. * Output :
  679. * Description :
  680. * Remarks :
  681. *****************************************************************************
  682. */
  683. static void dump_ver_block(const ver_block_t *blk)
  684. {
  685. const ver_value_t *val = blk->values;
  686. printf("BLOCK ");
  687. print_string(blk->name);
  688. printf("\n{\n");
  689. while(val)
  690. {
  691. dump_ver_value(val);
  692. val = val->next;
  693. }
  694. printf("}\n");
  695. }
  696. /*
  697. *****************************************************************************
  698. * Function : dump_versioninfo
  699. * Syntax : void dump_versioninfo(const versioninfo_t *ver)
  700. * Input :
  701. * ver - Versioninfo resource descriptor
  702. * Output :
  703. * Description :
  704. * Remarks :
  705. *****************************************************************************
  706. */
  707. static void dump_versioninfo(const versioninfo_t *ver)
  708. {
  709. const ver_block_t *blk = ver->blocks;
  710. dump_lvc(&(ver->lvc));
  711. if(ver->gotit.fv)
  712. printf("FILEVERSION %04x, %04x, %04x, %04x\n",
  713. ver->filever_maj1,
  714. ver->filever_maj2,
  715. ver->filever_min1,
  716. ver->filever_min2);
  717. if(ver->gotit.pv)
  718. printf("PRODUCTVERSION %04x, %04x, %04x, %04x\n",
  719. ver->prodver_maj1,
  720. ver->prodver_maj2,
  721. ver->prodver_min1,
  722. ver->prodver_min2);
  723. if(ver->gotit.fo)
  724. printf("FILEOS %08x\n", ver->fileos);
  725. if(ver->gotit.ff)
  726. printf("FILEFLAGS %08x\n", ver->fileflags);
  727. if(ver->gotit.ffm)
  728. printf("FILEFLAGSMASK %08x\n", ver->fileflagsmask);
  729. if(ver->gotit.ft)
  730. printf("FILETYPE %08x\n", ver->filetype);
  731. if(ver->gotit.fst)
  732. printf("FILESUBTYPE %08x\n", ver->filesubtype);
  733. while(blk)
  734. {
  735. dump_ver_block(blk);
  736. blk = blk->next;
  737. }
  738. }
  739. /*
  740. *****************************************************************************
  741. * Function : dump_toolbar_item
  742. * Syntax : void dump_toolbar_item(const toolbar_item_t *item)
  743. * Input :
  744. * Output :
  745. * Description :
  746. * Remarks :
  747. *****************************************************************************
  748. */
  749. static void dump_toolbar_items(const toolbar_item_t *items)
  750. {
  751. while(items)
  752. {
  753. if(items->id)
  754. printf(" BUTTON %d", items->id );
  755. else
  756. printf(" SEPARATOR");
  757. printf("\n");
  758. items = items->next;
  759. }
  760. }
  761. /*
  762. *****************************************************************************
  763. * Function : dump_toolbar
  764. * Syntax : void dump_toolbar(const toolbar_t *toolbar)
  765. * Input :
  766. * toolbar - Toolbar resource descriptor
  767. * Output :
  768. * Description :
  769. * Remarks :
  770. *****************************************************************************
  771. */
  772. static void dump_toolbar(const toolbar_t *toolbar)
  773. {
  774. dump_memopt(toolbar->memopt);
  775. dump_lvc(&(toolbar->lvc));
  776. dump_toolbar_items(toolbar->items);
  777. }
  778. /*
  779. *****************************************************************************
  780. * Function : dump_dlginit
  781. * Syntax : void dump_dlginit(const dlginit_t *dit)
  782. * Input :
  783. * dit - DlgInit resource descriptor
  784. * Output :
  785. * Description :
  786. * Remarks :
  787. *****************************************************************************
  788. */
  789. static void dump_dlginit(const dlginit_t *dit)
  790. {
  791. dump_memopt(dit->memopt);
  792. dump_lvc(&(dit->data->lvc));
  793. dump_raw_data(dit->data);
  794. }
  795. /*
  796. *****************************************************************************
  797. * Function : dump_resources
  798. * Syntax : void dump_resources(const resource_t *top)
  799. * Input :
  800. * top - Top of the resource tree
  801. * Output :
  802. * nop
  803. * Description : Dump the parsed resource-tree to stdout
  804. * Remarks :
  805. *****************************************************************************
  806. */
  807. void dump_resources(const resource_t *top)
  808. {
  809. printf("Internal resource-tree dump:\n");
  810. while(top)
  811. {
  812. printf("Resource: %s\nId: %s\n",
  813. get_typename(top),
  814. get_nameid_str(top->name));
  815. switch(top->type)
  816. {
  817. case res_acc:
  818. dump_accelerator(top->res.acc);
  819. break;
  820. case res_bmp:
  821. dump_bitmap(top->res.bmp);
  822. break;
  823. case res_cur:
  824. dump_cursor(top->res.cur);
  825. break;
  826. case res_curg:
  827. dump_cursor_group(top->res.curg);
  828. break;
  829. case res_dlg:
  830. dump_dialog(top->res.dlg);
  831. break;
  832. case res_fnt:
  833. dump_font(top->res.fnt);
  834. break;
  835. case res_icog:
  836. dump_icon_group(top->res.icog);
  837. break;
  838. case res_ico:
  839. dump_icon(top->res.ico);
  840. break;
  841. case res_men:
  842. dump_menu(top->res.men);
  843. break;
  844. case res_rdt:
  845. dump_rcdata(top->res.rdt);
  846. break;
  847. case res_stt:
  848. dump_stringtable(top->res.stt);
  849. break;
  850. case res_usr:
  851. dump_user(top->res.usr);
  852. break;
  853. case res_msg:
  854. dump_messagetable(top->res.msg);
  855. break;
  856. case res_ver:
  857. dump_versioninfo(top->res.ver);
  858. break;
  859. case res_dlginit:
  860. dump_dlginit(top->res.dlgi);
  861. break;
  862. case res_toolbar:
  863. dump_toolbar(top->res.tbt);
  864. break;
  865. case res_anicur:
  866. case res_aniico:
  867. dump_ani_curico(top->res.ani);
  868. break;
  869. default:
  870. printf("Report this: Unknown resource type parsed %08x\n", top->type);
  871. }
  872. printf("\n");
  873. top = top->next;
  874. }
  875. }