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.

578 lines
8.5 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include <nturtl.h>
  4. #include <windows.h>
  5. #include <ole2.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <ntiologc.h>
  9. //
  10. // This tool will generate MOF definitions for the event to eventlog
  11. // subscriptions for MCA events/eventlogs
  12. //
  13. CHAR Buffer[2*8192];
  14. ULONG FilePrintVaList(
  15. HANDLE FileHandle,
  16. CHAR *Format,
  17. va_list pArg
  18. )
  19. {
  20. ULONG Size, Written;
  21. ULONG Status;
  22. Size = _vsnprintf(Buffer, sizeof(Buffer), Format, pArg);
  23. if (WriteFile(FileHandle,
  24. Buffer,
  25. Size,
  26. &Written,
  27. NULL))
  28. {
  29. Status = ERROR_SUCCESS;
  30. } else {
  31. Status = GetLastError();
  32. }
  33. return(Status);
  34. }
  35. ULONG FilePrint(
  36. HANDLE FileHandle,
  37. char *Format,
  38. ...
  39. )
  40. {
  41. ULONG Status;
  42. va_list pArg;
  43. va_start(pArg, Format);
  44. Status = FilePrintVaList(FileHandle, Format, pArg);
  45. return(Status);
  46. }
  47. typedef struct
  48. {
  49. char *CodeName;
  50. ULONG Code;
  51. char *Class;
  52. ULONG InsertCount;
  53. char *Insert2;
  54. char *Insert3;
  55. char *Insert4;
  56. } tab, *ptab;
  57. tab TabList[] =
  58. {
  59. {
  60. "MCA_WARNING_CACHE",
  61. MCA_WARNING_CACHE,
  62. "MSMCAEvent_CPUError",
  63. 1,
  64. "%level%",
  65. "N/A",
  66. "N/A"
  67. },
  68. {
  69. "MCA_ERROR_CACHE",
  70. MCA_ERROR_CACHE,
  71. "MSMCAEvent_CPUError",
  72. 1,
  73. "%level%",
  74. "N/A",
  75. "N/A"
  76. },
  77. {
  78. "MCA_WARNING_TLB",
  79. MCA_WARNING_TLB,
  80. "MSMCAEvent_CPUError",
  81. 1,
  82. "%level%",
  83. "N/A",
  84. "N/A"
  85. },
  86. {
  87. "MCA_ERROR_TLB",
  88. MCA_ERROR_TLB,
  89. "MSMCAEvent_CPUError",
  90. 1,
  91. "%level%",
  92. "N/A",
  93. "N/A"
  94. },
  95. {
  96. "MCA_WARNING_CPU_BUS",
  97. MCA_WARNING_CPU_BUS,
  98. "MSMCAEvent_CPUError",
  99. 0,
  100. "N/A",
  101. "N/A",
  102. "N/A"
  103. },
  104. {
  105. "MCA_ERROR_CPU_BUS",
  106. MCA_ERROR_CPU_BUS,
  107. "MSMCAEvent_CPUError",
  108. 0,
  109. "N/A",
  110. "N/A",
  111. "N/A"
  112. },
  113. {
  114. "MCA_WARNING_REGISTER_FILE",
  115. MCA_WARNING_REGISTER_FILE,
  116. "MSMCAEvent_CPUError",
  117. 0,
  118. "N/A",
  119. "N/A",
  120. "N/A"
  121. },
  122. {
  123. "MCA_ERROR_REGISTER_FILE",
  124. MCA_ERROR_REGISTER_FILE,
  125. "MSMCAEvent_CPUError",
  126. 0,
  127. "N/A",
  128. "N/A",
  129. "N/A"
  130. },
  131. {
  132. "MCA_WARNING_MAS",
  133. MCA_WARNING_MAS,
  134. "MSMCAEvent_CPUError",
  135. 0,
  136. "N/A",
  137. "N/A",
  138. "N/A"
  139. },
  140. {
  141. "MCA_ERROR_MAS",
  142. MCA_ERROR_MAS,
  143. "MSMCAEvent_CPUError",
  144. 0,
  145. "N/A",
  146. "N/A",
  147. "N/A"
  148. },
  149. {
  150. "MCA_WARNING_MEM_UNKNOWN",
  151. MCA_WARNING_MEM_UNKNOWN,
  152. "MSMCAEvent_MemoryError",
  153. 0,
  154. "N/A",
  155. "N/A",
  156. "N/A"
  157. },
  158. {
  159. "MCA_ERROR_MEM_UNKNOWN",
  160. MCA_ERROR_MEM_UNKNOWN,
  161. "MSMCAEvent_MemoryError",
  162. 0,
  163. "N/A",
  164. "N/A",
  165. "N/A"
  166. },
  167. {
  168. "MCA_WARNING_MEM_1_2",
  169. MCA_WARNING_MEM_1_2,
  170. "MSMCAEvent_MemoryError",
  171. 1,
  172. "%MEM_PHYSICAL_ADDR%",
  173. "N/A",
  174. "N/A"
  175. },
  176. {
  177. "MCA_ERROR_MEM_1_2",
  178. MCA_ERROR_MEM_1_2,
  179. "MSMCAEvent_MemoryError",
  180. 1,
  181. "%MEM_PHYSICAL_ADDR%",
  182. "N/A",
  183. "N/A"
  184. },
  185. {
  186. "MCA_WARNING_MEM_1_2_5",
  187. MCA_WARNING_MEM_1_2_5,
  188. "MSMCAEvent_MemoryError",
  189. 2,
  190. "%MEM_PHYSICAL_ADDR%",
  191. "%MEM_MODULE%",
  192. "N/A"
  193. },
  194. {
  195. "MCA_ERROR_MEM_1_2_5",
  196. MCA_ERROR_MEM_1_2_5,
  197. "MSMCAEvent_MemoryError",
  198. 2,
  199. "%MEM_PHYSICAL_ADDR%",
  200. "%MEM_MODULE%",
  201. "N/A"
  202. },
  203. {
  204. "MCA_WARNING_MEM_1_2_5_4",
  205. MCA_WARNING_MEM_1_2_5_4,
  206. "MSMCAEvent_MemoryError",
  207. 3,
  208. "%MEM_PHYSICAL_ADDR%",
  209. "%MEM_MODULE%",
  210. "%MEM_CARD%"
  211. },
  212. {
  213. "MCA_ERROR_MEM_1_2_5_4",
  214. MCA_ERROR_MEM_1_2_5_4,
  215. "MSMCAEvent_MemoryError",
  216. 3,
  217. "%MEM_PHYSICAL_ADDR%",
  218. "%MEM_MODULE%",
  219. "%MEM_CARD%"
  220. },
  221. {
  222. "MCA_WARNING_SYSTEM_EVENT",
  223. MCA_WARNING_SYSTEM_EVENT,
  224. "MSMCAEvent_SystemEventError",
  225. 0,
  226. "N/A",
  227. "N/A",
  228. "N/A"
  229. },
  230. {
  231. "MCA_ERROR_SYSTEM_EVENT",
  232. MCA_ERROR_SYSTEM_EVENT,
  233. "MSMCAEvent_SystemEventError",
  234. 0,
  235. "N/A",
  236. "N/A",
  237. "N/A"
  238. },
  239. {
  240. "MCA_WARNING_PCI_BUS_PARITY",
  241. MCA_WARNING_PCI_BUS_PARITY,
  242. "MSMCAEvent_PCIBusError",
  243. 3,
  244. "%PCI_BUS_CMD%",
  245. "%PCI_BUS_ADDRESS%",
  246. "%PCI_BUS_ID_BusNumber%"
  247. },
  248. {
  249. "MCA_ERROR_PCI_BUS_PARITY",
  250. MCA_ERROR_PCI_BUS_PARITY,
  251. "MSMCAEvent_PCIBusError",
  252. 3,
  253. "%PCI_BUS_CMD%",
  254. "%PCI_BUS_ADDRESS%",
  255. "%PCI_BUS_ID_BusNumber%"
  256. },
  257. {
  258. "MCA_WARNING_PCI_BUS_PARITY_NO_INFO",
  259. MCA_WARNING_PCI_BUS_PARITY_NO_INFO,
  260. "MSMCAEvent_PCIBusError",
  261. 0,
  262. "N/A",
  263. "N/A",
  264. "N/A"
  265. },
  266. {
  267. "MCA_ERROR_PCI_BUS_PARITY_NO_INFO",
  268. MCA_ERROR_PCI_BUS_PARITY_NO_INFO,
  269. "MSMCAEvent_PCIBusError",
  270. 0,
  271. "N/A",
  272. "N/A",
  273. "N/A"
  274. },
  275. {
  276. "MCA_WARNING_PCI_BUS_SERR",
  277. MCA_WARNING_PCI_BUS_SERR,
  278. "MSMCAEvent_PCIBusError",
  279. 3,
  280. "%PCI_BUS_CMD%",
  281. "%PCI_BUS_ADDRESS%",
  282. "%PCI_BUS_ID_BusNumber%"
  283. },
  284. {
  285. "MCA_ERROR_PCI_BUS_SERR",
  286. MCA_ERROR_PCI_BUS_SERR,
  287. "MSMCAEvent_PCIBusError",
  288. 3,
  289. "%PCI_BUS_CMD%",
  290. "%PCI_BUS_ADDRESS%",
  291. "%PCI_BUS_ID_BusNumber%"
  292. },
  293. {
  294. "MCA_WARNING_PCI_BUS_SERR_NO_INFO",
  295. MCA_WARNING_PCI_BUS_SERR_NO_INFO,
  296. "MSMCAEvent_PCIBusError",
  297. 0,
  298. "N/A",
  299. "N/A",
  300. "N/A"
  301. },
  302. {
  303. "MCA_ERROR_PCI_BUS_SERR_NO_INFO",
  304. MCA_ERROR_PCI_BUS_SERR_NO_INFO,
  305. "MSMCAEvent_PCIBusError",
  306. 0,
  307. "N/A",
  308. "N/A",
  309. "N/A"
  310. },
  311. {
  312. "MCA_WARNING_PCI_BUS_MASTER_ABORT",
  313. MCA_WARNING_PCI_BUS_MASTER_ABORT,
  314. "MSMCAEvent_PCIBusError",
  315. 3,
  316. "%PCI_BUS_CMD%",
  317. "%PCI_BUS_ADDRESS%",
  318. "%PCI_BUS_ID_BusNumber%"
  319. },
  320. {
  321. "MCA_ERROR_PCI_BUS_MASTER_ABORT",
  322. MCA_ERROR_PCI_BUS_MASTER_ABORT,
  323. "MSMCAEvent_PCIBusError",
  324. 3,
  325. "%PCI_BUS_CMD%",
  326. "%PCI_BUS_ADDRESS%",
  327. "%PCI_BUS_ID_BusNumber%"
  328. },
  329. {
  330. "MCA_WARNING_PCI_BUS_MASTER_ABORT_NO_INFO",
  331. MCA_WARNING_PCI_BUS_MASTER_ABORT_NO_INFO,
  332. "MSMCAEvent_PCIBusError",
  333. 0,
  334. "N/A",
  335. "N/A",
  336. "N/A"
  337. },
  338. {
  339. "MCA_ERROR_PCI_BUS_MASTER_ABORT_NO_INFO",
  340. MCA_ERROR_PCI_BUS_MASTER_ABORT_NO_INFO,
  341. "MSMCAEvent_PCIBusError",
  342. 0,
  343. "N/A",
  344. "N/A",
  345. "N/A"
  346. },
  347. {
  348. "MCA_WARNING_PCI_BUS_TIMEOUT",
  349. MCA_WARNING_PCI_BUS_TIMEOUT,
  350. "MSMCAEvent_PCIBusError",
  351. 3,
  352. "%PCI_BUS_CMD%",
  353. "%PCI_BUS_ADDRESS%",
  354. "%PCI_BUS_ID_BusNumber%"
  355. },
  356. {
  357. "MCA_ERROR_PCI_BUS_TIMEOUT",
  358. MCA_ERROR_PCI_BUS_TIMEOUT,
  359. "MSMCAEvent_PCIBusError",
  360. 3,
  361. "%PCI_BUS_CMD%",
  362. "%PCI_BUS_ADDRESS%",
  363. "%PCI_BUS_ID_BusNumber%"
  364. },
  365. {
  366. "MCA_WARNING_PCI_BUS_TIMEOUT_NO_INFO",
  367. MCA_WARNING_PCI_BUS_TIMEOUT_NO_INFO,
  368. "MSMCAEvent_PCIBusError",
  369. 0,
  370. "N/A",
  371. "N/A",
  372. "N/A"
  373. },
  374. {
  375. "MCA_ERROR_PCI_BUS_TIMEOUT_NO_INFO",
  376. MCA_ERROR_PCI_BUS_TIMEOUT_NO_INFO,
  377. "MSMCAEvent_PCIBusError",
  378. 0,
  379. "N/A",
  380. "N/A",
  381. "N/A"
  382. },
  383. {
  384. "MCA_WARNING_PCI_BUS_UNKNOWN",
  385. MCA_WARNING_PCI_BUS_UNKNOWN,
  386. "MSMCAEvent_PCIBusError",
  387. 0,
  388. "N/A",
  389. "N/A",
  390. "N/A"
  391. },
  392. {
  393. "MCA_ERROR_PCI_BUS_UNKNOWN",
  394. MCA_ERROR_PCI_BUS_UNKNOWN,
  395. "MSMCAEvent_PCIBusError",
  396. 0,
  397. "N/A",
  398. "N/A",
  399. "N/A"
  400. },
  401. {
  402. "MCA_WARNING_PCI_DEVICE",
  403. MCA_WARNING_PCI_DEVICE,
  404. "MSMCAEvent_PCIComponentError",
  405. 0,
  406. "N/A",
  407. "N/A",
  408. "N/A"
  409. },
  410. {
  411. "MCA_ERROR_PCI_DEVICE",
  412. MCA_ERROR_PCI_DEVICE,
  413. "MSMCAEvent_PCIComponentError",
  414. 0,
  415. "N/A",
  416. "N/A",
  417. "N/A"
  418. },
  419. {
  420. "MCA_WARNING_SMBIOS",
  421. MCA_WARNING_SMBIOS,
  422. "MSMCAEvent_SMBIOSError",
  423. 2,
  424. "%SMBIOS_EVENT_TYPE%",
  425. "N/A",
  426. "N/A"
  427. },
  428. {
  429. "MCA_ERROR_SMBIOS",
  430. MCA_ERROR_SMBIOS,
  431. "MSMCAEvent_SMBIOSError",
  432. 1,
  433. "%SMBIOS_EVENT_TYPE%",
  434. "N/A",
  435. "N/A"
  436. },
  437. {
  438. "MCA_WARNING_PLATFORM_SPECIFIC",
  439. MCA_WARNING_PLATFORM_SPECIFIC,
  440. "MSMCAEvent_PlatformSpecificError",
  441. 0,
  442. "N/A",
  443. "N/A",
  444. "N/A"
  445. },
  446. {
  447. "MCA_ERROR_PLATFORM_SPECIFIC",
  448. MCA_ERROR_PLATFORM_SPECIFIC,
  449. "MSMCAEvent_PlatformSpecificError",
  450. 0,
  451. "N/A",
  452. "N/A",
  453. "N/A"
  454. },
  455. {
  456. "MCA_WARNING_UNKNOWN",
  457. MCA_WARNING_UNKNOWN,
  458. "MSMCAEvent_Unknown",
  459. 0,
  460. "N/A",
  461. "N/A",
  462. "N/A"
  463. },
  464. {
  465. "MCA_ERROR_UNKNOWN",
  466. MCA_ERROR_UNKNOWN,
  467. "MSMCAEvent_Unknown",
  468. 0,
  469. "N/A",
  470. "N/A",
  471. "N/A"
  472. }
  473. };
  474. #define TabSize (sizeof(TabList) / sizeof(tab))
  475. int _cdecl main(int argc, char *argv[])
  476. {
  477. HANDLE TemplateHandle;
  478. ULONG i;
  479. TemplateHandle = CreateFile(argv[1],
  480. GENERIC_WRITE,
  481. 0,
  482. NULL,
  483. CREATE_ALWAYS,
  484. FILE_ATTRIBUTE_NORMAL,
  485. NULL);
  486. if ((TemplateHandle == NULL) || (TemplateHandle == INVALID_HANDLE_VALUE))
  487. {
  488. return(GetLastError());
  489. }
  490. for (i = 0; i < (TabSize); i++)
  491. {
  492. FilePrint(TemplateHandle,
  493. "DEFINE_EVENT_TO_EVENTLOG_SUBSCRIPTION(\n"
  494. " MCA%d,\n"
  495. " \"MCA%d\",\n"
  496. " %u, // %s \n"
  497. " \"select * from %s where type = %u\",\n"
  498. " \"WMIxWDM\",\n"
  499. " \"RawRecord\",\n"
  500. " %d, \"%%Cpu%%\", \"%%AdditionalErrors%%\", \"%s\", \"%s\", \"%s\")\n\n",
  501. i,
  502. i,
  503. TabList[i].Code, TabList[i].CodeName,
  504. TabList[i].Class, TabList[i].Code,
  505. TabList[i].InsertCount+2, TabList[i].Insert2,
  506. TabList[i].Insert3,
  507. TabList[i].Insert4);
  508. }
  509. CloseHandle(TemplateHandle);
  510. return(0);
  511. }