Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.2 KiB

  1. /*****************************************************************************
  2. *
  3. * packchk.cpp
  4. *
  5. * Tool-like thing that lets you check that you didn't mess up any
  6. * structure packing.
  7. *
  8. *****************************************************************************/
  9. #define STRICT
  10. #include <windows.h>
  11. /* Header file hacks */
  12. #include <wininet.h> /* needed by shlobj to get all structures defined */
  13. #include <oaidl.h> /* needed by shlwapip to get all structures defined */
  14. typedef BYTE ADJUSTINFO; /* hack for comctrlp.h - Win16-only structure */
  15. typedef BYTE EDITMENU; /* hack for commdlg.h - MAC-only structure */
  16. #define UXCTRL_VERSION 0x0100 /* Get all the new UXCTRL structures */
  17. #include "packchk1.inc"
  18. typedef struct PACKTABLE {
  19. LPCSTR pszHeader;
  20. LPCSTR pszName;
  21. UINT cb;
  22. } PACKTABLE;
  23. #define _(S) { H, #S, sizeof(S) },
  24. const PACKTABLE c_rgpt[] = {
  25. #include "packchk2.inc"
  26. };
  27. #define cpt (sizeof(c_rgpt)/sizeof(c_rgpt[0]))
  28. int PASCAL
  29. IWinMain(HINSTANCE hinst, LPCTSTR ptszCmdLine)
  30. {
  31. int i;
  32. for (i = 0; i < cpt; i++) {
  33. char szBuf[1024];
  34. int cch;
  35. cch = wsprintf(szBuf, "%s,%s,%d\r\n",
  36. c_rgpt[i].pszHeader,
  37. c_rgpt[i].pszName, c_rgpt[i].cb);
  38. _lwrite(PtrToLong(GetStdHandle(STD_OUTPUT_HANDLE)), szBuf, cch);
  39. }
  40. return 0;
  41. }
  42. EXTERN_C void PASCAL
  43. Entry(void)
  44. {
  45. LPCTSTR ptszCmdLine = GetCommandLine();
  46. if (*ptszCmdLine == '"') {
  47. /*
  48. * Scan, and skip over, subsequent characters until
  49. * another double-quote or a null is encountered.
  50. */
  51. while (*(ptszCmdLine = CharNext(ptszCmdLine)) && *ptszCmdLine != '"');
  52. /*
  53. * If we stopped on a double-quote (usual case), skip
  54. * over it.
  55. */
  56. if (*ptszCmdLine == '"') ptszCmdLine = CharNext(ptszCmdLine);
  57. } else {
  58. while (*ptszCmdLine > ' ') ptszCmdLine = CharNext(ptszCmdLine);
  59. }
  60. /*
  61. * Skip past any white space preceding the second token.
  62. */
  63. while (*ptszCmdLine && *ptszCmdLine <= ' ') ptszCmdLine = CharNext(ptszCmdLine);
  64. ExitProcess(IWinMain(GetModuleHandle(0), ptszCmdLine));
  65. }