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.

159 lines
3.8 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. typedef struct _InfoLevelRecord
  5. {
  6. char *pszInfoLevel;
  7. char *pszSectionName;
  8. char *pszDescription;
  9. } InfoLevelRecord;
  10. InfoLevelRecord ilrArray[] =
  11. {
  12. { "cairole", "Cairole Infolevels","Compobj layer" },
  13. { "DD", "Cairole Infolevels","Drag & Drop" },
  14. { "heap", "Cairole Infolevels","Heap trace output" },
  15. { "hk", "Cairole Infolevels","Hook layer" },
  16. { "intr","Cairole Infolevels","1.0/2.0 interop layer" },
  17. { "le", "Cairole Infolevels", "Linking and embedding" },
  18. { "mnk", "Cairole Infolevels", "Moniker tracing" },
  19. { "msf", "Cairole Infolevels", "Upper layer storage" },
  20. { "ol", "Cairole Infolevels", "Lower layer storage" },
  21. { "ref", "Cairole Infolevels", "CSafeRef class (Cairo)" },
  22. { "scm", "Cairole Infolevels", "OLE service" },
  23. { "Stack", "Cairole Infolevels", "Stack switching (Win95)" },
  24. { "StackOn", "Cairole Infolevels", "Stack switching enable (boolean,Win95)" },
  25. { "prop", "Cairole Infolevels", "Storage property interfaces" },
  26. { "api", "Cairole Infolevels","CompApi trace" },
  27. { "breakoninit", "Olethk32","Break on initialization (boolean)" },
  28. { "InfoLevel", "Olethk32","16/32 thunk layer (32-bit side)" },
  29. { "ole2", "Olethk16","16/32 thunk layer: ole2.dll" },
  30. { "stg", "Olethk16","16/32 thunk layer: storage.dll" },
  31. { "comp", "Olethk16","16/32 thunk layer: compobj.dll" },
  32. { NULL, NULL }
  33. };
  34. typedef struct _AttrRecord
  35. {
  36. char *pszAttr;
  37. char *pszSectionName;
  38. char *pszDescription;
  39. } AttrRecord;
  40. AttrRecord arArray[] =
  41. {
  42. { "DebugScreen", "Cairole Infolevels","Debugger Screen (Yes|No)" },
  43. { "LogFile", "Cairole Infolevels","LogFile (\"<name>\"|\"\")" },
  44. { NULL, NULL}
  45. };
  46. char * LookupILSection (char * pszInfoLevel)
  47. {
  48. InfoLevelRecord *pr;
  49. for ( pr = ilrArray ; pr->pszInfoLevel != NULL ; pr++)
  50. {
  51. if (_stricmp(pr->pszInfoLevel,pszInfoLevel) == 0)
  52. {
  53. break;
  54. }
  55. }
  56. return pr->pszSectionName;
  57. }
  58. void DumpInfoLevelRecords()
  59. {
  60. InfoLevelRecord *pr;
  61. printf("%20s %-12s Currently\n","Section Name","Name");
  62. for ( pr = ilrArray ; pr->pszInfoLevel != NULL ; pr++)
  63. {
  64. printf("%20s %-12s (%08x) %s\n",
  65. pr->pszSectionName,
  66. pr->pszInfoLevel,
  67. GetProfileInt(pr->pszSectionName,pr->pszInfoLevel,0),
  68. pr->pszDescription);
  69. }
  70. }
  71. char * LookupASection (char * pszAttr)
  72. {
  73. AttrRecord *pr;
  74. for ( pr = arArray ; pr->pszAttr != NULL ; pr++)
  75. {
  76. if (_stricmp(pr->pszAttr,pszAttr) == 0)
  77. {
  78. break;
  79. }
  80. }
  81. return pr->pszSectionName;
  82. }
  83. void DumpAttrRecords()
  84. {
  85. AttrRecord *pr;
  86. char buffer[256];
  87. printf("%20s %-12s Currently\n","Section Name","Name");
  88. for ( pr = arArray ; pr->pszAttr != NULL ; pr++)
  89. {
  90. GetProfileString(pr->pszSectionName,pr->pszAttr, "", buffer, sizeof(buffer));
  91. printf("%20s %-12s (%s) %s\n",
  92. pr->pszSectionName,
  93. pr->pszAttr,
  94. buffer,
  95. pr->pszDescription);
  96. }
  97. }
  98. void Usage(char *pszProgName)
  99. {
  100. printf("Usage:\n\t%s <infolevel name> 0x<hexvalue>\tOR\n\t%s <attribute> <value>\n", pszProgName, pszProgName);
  101. printf("\nKnown infolevels are as follows\n\n");
  102. DumpInfoLevelRecords();
  103. printf("\nKnown attributes are as follows\n\n");
  104. DumpAttrRecords();
  105. }
  106. void _cdecl main(int argc, char *argv[])
  107. {
  108. //
  109. // The command line specifies the infolevel, followed by the
  110. // value. There are a known set of infolevels.
  111. //
  112. //
  113. if (argc != 3)
  114. {
  115. Usage(argv[0]);
  116. return;
  117. }
  118. char *pszSectionName = LookupILSection(argv[1]);
  119. if (pszSectionName == NULL)
  120. {
  121. pszSectionName = LookupASection(argv[1]);
  122. }
  123. if (pszSectionName == NULL)
  124. {
  125. printf("Don't recognize %s as an infolevel or attribute\n",argv[1]);
  126. Usage(argv[0]);
  127. return;
  128. }
  129. if(!WriteProfileString(pszSectionName,argv[1],argv[2]))
  130. {
  131. printf("Error: WriteProfileString returns false\n");
  132. printf("GetLastError returns %x\n",GetLastError());
  133. }
  134. }