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.

203 lines
4.7 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Revision History:
  4. --*/
  5. #include "stdafx.h"
  6. #include "wmihlp.h"
  7. void PrintHeader(WNODE_HEADER Header, CString & output)
  8. {
  9. SYSTEMTIME sysTime;
  10. FILETIME fileTime;
  11. FILETIME localFileTime;
  12. CString tmp;
  13. // Convert the file time
  14. //
  15. fileTime.dwLowDateTime = Header.TimeStamp.LowPart;
  16. fileTime.dwHighDateTime = Header.TimeStamp.HighPart;
  17. FileTimeToLocalFileTime(&fileTime,
  18. &localFileTime );
  19. FileTimeToSystemTime(&localFileTime,
  20. &sysTime);
  21. // Print the info
  22. //
  23. tmp.Format(_T("Buffer Size: 0x%x\r\n")
  24. _T("Provider Id: 0x%x\r\n")
  25. _T("Version : %u\r\n")
  26. _T("Linkage : 0x%x\r\n")
  27. _T("Time Stamp : %u:%02u %u\\%u\\%u\r\n")
  28. _T("Guid : 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\r\n")
  29. _T("Flags : 0x%02x\r\n"),
  30. Header.BufferSize,
  31. Header.ProviderId,
  32. Header.Version,
  33. Header.Linkage,
  34. sysTime.wHour,
  35. sysTime.wMinute,
  36. sysTime.wMonth,
  37. sysTime.wDay,
  38. sysTime.wYear,
  39. Header.Guid.Data1,
  40. Header.Guid.Data2,
  41. Header.Guid.Data3,
  42. Header.Guid.Data4[0],
  43. Header.Guid.Data4[1],
  44. Header.Guid.Data4[2],
  45. Header.Guid.Data4[3],
  46. Header.Guid.Data4[4],
  47. Header.Guid.Data4[5],
  48. Header.Guid.Data4[6],
  49. Header.Guid.Data4[7],
  50. Header.Flags );
  51. // Print readable flags
  52. //
  53. if (Header.Flags & WNODE_FLAG_ALL_DATA)
  54. {
  55. output += _T("WNODE_FLAG_ALL_DATA\r\n");
  56. }
  57. if (Header.Flags & WNODE_FLAG_SINGLE_INSTANCE)
  58. {
  59. output += _T("WNODE_FLAG_SINGLE_INSTANCE\r\n");
  60. }
  61. if (Header.Flags & WNODE_FLAG_SINGLE_ITEM)
  62. {
  63. output += _T("WNODE_FLAG_SINGLE_ITEM\r\n");
  64. }
  65. if (Header.Flags & WNODE_FLAG_EVENT_ITEM)
  66. {
  67. output += _T("WNODE_FLAG_EVENT_ITEM\r\n");
  68. }
  69. if (Header.Flags & WNODE_FLAG_FIXED_INSTANCE_SIZE)
  70. {
  71. output += _T("WNODE_FLAG_FIXED_INSTANCE_SIZE\r\n");
  72. }
  73. if (Header.Flags & WNODE_FLAG_TOO_SMALL)
  74. {
  75. output += _T("WNODE_FLAG_TOO_SMALL\r\n");
  76. }
  77. if (Header.Flags & WNODE_FLAG_INSTANCES_SAME)
  78. {
  79. output += _T("WNODE_FLAG_INSTANCES_SAME\r\n");
  80. }
  81. if (Header.Flags & WNODE_FLAG_INTERNAL)
  82. {
  83. output += _T("WNODE_FLAG_INTERNAL\r\n");
  84. }
  85. if (Header.Flags & WNODE_FLAG_USE_TIMESTAMP)
  86. {
  87. output += _T("WNODE_FLAG_USE_TIMESTAMP\r\n");
  88. }
  89. if (Header.Flags & WNODE_FLAG_TRACED_GUID)
  90. {
  91. output += _T("WNODE_FLAG_TRACED_GUID\r\n");
  92. }
  93. if (Header.Flags & WNODE_FLAG_EVENT_REFERENCE)
  94. {
  95. output += _T("WNODE_FLAG_EVENT_REFERENCE\r\n");
  96. }
  97. if (Header.Flags & WNODE_FLAG_ANSI_INSTANCENAMES)
  98. {
  99. output += _T("WNODE_FLAG_ANSI_INSTANCENAMES\r\n");
  100. }
  101. if (Header.Flags & WNODE_FLAG_METHOD_ITEM)
  102. {
  103. output += _T("WNODE_FLAG_METHOD_ITEM\r\n");
  104. }
  105. if (Header.Flags & WNODE_FLAG_PDO_INSTANCE_NAMES)
  106. {
  107. output += _T("WNODE_FLAG_PDO_INSTANCE_NAMES\r\n");
  108. }
  109. output += _T("\r\n");
  110. }
  111. VOID
  112. PrintCountedString(
  113. LPTSTR lpString,
  114. CString & output
  115. )
  116. {
  117. SHORT usNameLength;
  118. LPTSTR lpStringPlusNull;
  119. usNameLength = * (USHORT *) lpString;
  120. lpStringPlusNull = (LPTSTR) new TCHAR[usNameLength + sizeof(TCHAR)];
  121. if (lpStringPlusNull != NULL) {
  122. lpString = (LPTSTR) ((PBYTE)lpString + sizeof(USHORT));
  123. if (MyIsTextUnicode(lpString)) {
  124. usNameLength /= 2;
  125. }
  126. _tcsncpy( lpStringPlusNull, lpString, usNameLength );
  127. _tcscpy( lpStringPlusNull + usNameLength, __T("") );
  128. output += lpStringPlusNull;
  129. // _tprintf(__T("%s\n"), lpStringPlusNull);
  130. delete[] lpStringPlusNull;
  131. }
  132. }
  133. BOOL MyIsTextUnicode(PVOID string)
  134. {
  135. if (*((USHORT*)string) <= 0xff)
  136. {
  137. return TRUE;
  138. }
  139. else
  140. {
  141. return FALSE;
  142. }
  143. }
  144. BOOL ValidHexText(CWnd *parent, const CString &txt, LPDWORD lpData, UINT line)
  145. {
  146. int i, len;
  147. TCHAR *stop;
  148. CString msg;
  149. if ((len = txt.GetLength()) > 8) {
  150. parent->MessageBox(_T("Must enter a value of 8 or less characters!"));
  151. return FALSE;
  152. }
  153. for (i = 0; i < len; i++) {
  154. if (!_istxdigit(txt[i])) {
  155. if (line == -1)
  156. msg.Format(_T("All digits must be hex! (digit #%d isn't)"), i+1);
  157. else
  158. msg.Format(_T("All digits must be hex!\n(digit #%d on line #%d isn't)"), i+1, line);
  159. parent->MessageBox(msg);
  160. return FALSE;
  161. }
  162. }
  163. *lpData = (DWORD) _tcstol(txt, &stop, 16);
  164. return TRUE;
  165. }