Leaked source code of windows server 2003
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.

284 lines
6.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation
  6. //
  7. // File: devmgr.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef __DEVMGR_H_
  11. #define __DEVMGR_H_
  12. #pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <windows.h>
  17. #include <windowsx.h>
  18. #include <tchar.h>
  19. #include <new.h>
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <prsht.h>
  23. #include <prshtp.h>
  24. #include <commctrl.h>
  25. #include <shellapi.h>
  26. #include <shlwapi.h>
  27. #include <shlapip.h>
  28. #include <ole2.h>
  29. #include <mmc.h>
  30. #include <objsel.h>
  31. #include <htmlhelp.h>
  32. #include <winioctl.h>
  33. #include <strsafe.h>
  34. #include <shfusion.h>
  35. extern "C" {
  36. #include <commdlg.h>
  37. #include <cfgmgr32.h>
  38. #include <setupapi.h>
  39. #include <spapip.h>
  40. #include <sputils.h>
  41. #include <regstr.h>
  42. #include <shimdb.h>
  43. }
  44. #pragma warning( default : 4201 )
  45. #define ARRAYLEN(array) (sizeof(array) / sizeof(array[0]))
  46. typedef enum tagCookieType
  47. {
  48. COOKIE_TYPE_SCOPEITEM_DEVMGR = 0,
  49. COOKIE_TYPE_RESULTITEM_RESOURCE_IRQ,
  50. COOKIE_TYPE_RESULTITEM_RESOURCE_DMA,
  51. COOKIE_TYPE_RESULTITEM_RESOURCE_IO,
  52. COOKIE_TYPE_RESULTITEM_RESOURCE_MEMORY,
  53. COOKIE_TYPE_RESULTITEM_COMPUTER,
  54. COOKIE_TYPE_RESULTITEM_DEVICE,
  55. COOKIE_TYPE_RESULTITEM_CLASS,
  56. COOKIE_TYPE_RESULTITEM_RESTYPE,
  57. COOKIE_TYPE_UNKNOWN
  58. } COOKIE_TYPE, *PCOOKIE_TYPE;
  59. #define COOKIE_FLAGS_EXPANDED 0x00000001
  60. const int TOTAL_COOKIE_TYPES = COOKIE_TYPE_RESULTITEM_RESTYPE - COOKIE_TYPE_SCOPEITEM_DEVMGR + 1;
  61. const int NODETYPE_FIRST = (int)COOKIE_TYPE_SCOPEITEM_DEVMGR;
  62. const int NODETYPE_LAST = (int)COOKIE_TYPE_RESULTITEM_RESTYPE;
  63. typedef struct tagNodeInfo {
  64. COOKIE_TYPE ct;
  65. int idsName;
  66. int idsFormat;
  67. GUID Guid;
  68. TCHAR* GuidString;
  69. } NODEINFO, *PNODEINFO;
  70. //
  71. // Device manager needs to keep track of the largest problem code that it
  72. // currently knows about. Using the NUM_CM_PROB defined in cfg.h is a bad
  73. // idea because if more problem codes are added that device manager doesn't
  74. // know about it will cause us to overrun the end of the CMPROBLEM_INFO array.
  75. //
  76. // Note that the +2 are for
  77. // 1) the working case (0 index in the array)
  78. // 2) the unknown problem case (last problem + 1 index in the array)
  79. //
  80. #define DEVMGR_NUM_CM_PROB 0x34
  81. #if DEVMGR_NUM_CM_PROB != (NUM_CM_PROB + 1)
  82. #error Update DEVMGR_NUM_CM_PROB and update tswizard.cpp and globals.cpp.
  83. #endif
  84. #define PIF_CODE_EMBEDDED 0x01
  85. typedef struct tagProblemInfo {
  86. int StringId;
  87. DWORD Flags;
  88. } PROBLEMINFO, *PPROBLEMINFO;
  89. typedef struct tagInternalData {
  90. DATA_OBJECT_TYPES dot;
  91. COOKIE_TYPE ct;
  92. MMC_COOKIE cookie;
  93. } INTERNAL_DATA, *PINTERNAL_DATA;
  94. typedef enum tagPropertyChangeType
  95. {
  96. PCT_STARTUP_INFODATA = 0,
  97. PCT_DEVICE,
  98. PCT_CLASS
  99. } PROPERTY_CHANGE_TYPE, *PPROPERTY_CHANGE_TYPE;
  100. typedef struct tagPropertyChangeInfo
  101. {
  102. PROPERTY_CHANGE_TYPE Type;
  103. BYTE InfoData[1];
  104. } PROPERTY_CHANGE_INFO, *PPROPERTY_CHANGE_INFO;
  105. typedef struct tagStartupInfoData
  106. {
  107. DWORD Size;
  108. COOKIE_TYPE ct;
  109. TCHAR MachineName[MAX_PATH + 3];
  110. } STARTUP_INFODATA, *PSTARTUP_INFODATA;
  111. typedef enum tagdmQuerySiblingCode
  112. {
  113. QSC_TO_FOREGROUND = 0,
  114. QSC_PROPERTY_CHANGED,
  115. } DMQUERYSIBLINGCODE, *PDMQUERYSIBLINGCODE;
  116. //
  117. // private header files
  118. //
  119. #include "..\inc\tvintf.h"
  120. #include "resource.h"
  121. #include "prndlg.h"
  122. #include "globals.h"
  123. #include "utils.h"
  124. #include "ccookie.h"
  125. #include "machine.h"
  126. #include "compdata.h"
  127. #include "componet.h"
  128. #include "cnode.h"
  129. #include "cfolder.h"
  130. #include "dataobj.h"
  131. BOOL InitGlobals(HINSTANCE hInstance);
  132. extern LPCTSTR DEVMGR_DEVICEID_SWITCH;
  133. extern LPCTSTR DEVMGR_MACHINENAME_SWITCH;
  134. extern LPCTSTR DEVMGR_COMMAND_SWITCH;
  135. void * __cdecl operator new(size_t size);
  136. void __cdecl operator delete(void *ptr);
  137. __cdecl _purecall(void);
  138. STDAPI
  139. DllRegisterServer();
  140. STDAPI
  141. DllUnregisterServer();
  142. STDAPI
  143. DllCanUnloadNow();
  144. STDAPI
  145. DllGetClassObject(REFCLSID rclsid, REFIID iid, void** ppv);
  146. //
  147. // CDMCommandLine class defination
  148. //
  149. class CDMCommandLine : public CCommandLine
  150. {
  151. public:
  152. CDMCommandLine() : m_WaitForDeviceId(FALSE),
  153. m_WaitForMachineName(FALSE),
  154. m_WaitForCommand(FALSE)
  155. {}
  156. virtual void ParseParam(LPCTSTR lpszParam, BOOL bFlag)
  157. {
  158. if (bFlag)
  159. {
  160. if (!lstrcmpi(DEVMGR_DEVICEID_SWITCH, lpszParam)) {
  161. m_WaitForDeviceId = TRUE;
  162. } else if (!lstrcmpi(DEVMGR_MACHINENAME_SWITCH, lpszParam)) {
  163. m_WaitForMachineName = TRUE;
  164. } else if (!lstrcmpi(DEVMGR_COMMAND_SWITCH, lpszParam)) {
  165. m_WaitForCommand = TRUE;
  166. }
  167. } else {
  168. if (m_WaitForDeviceId) {
  169. m_strDeviceId = lpszParam;
  170. m_WaitForDeviceId = FALSE;
  171. } else if (m_WaitForMachineName) {
  172. m_strMachineName = lpszParam;
  173. m_WaitForMachineName = FALSE;
  174. } else if (m_WaitForCommand) {
  175. m_strCommand = lpszParam;
  176. m_WaitForCommand = FALSE;
  177. }
  178. }
  179. }
  180. LPCTSTR GetDeviceId()
  181. {
  182. return m_strDeviceId.IsEmpty() ? NULL : (LPCTSTR)m_strDeviceId;
  183. }
  184. LPCTSTR GetMachineName()
  185. {
  186. return m_strMachineName.IsEmpty() ? NULL : (LPCTSTR)m_strMachineName;
  187. }
  188. LPCTSTR GetCommand()
  189. {
  190. return m_strCommand.IsEmpty() ? NULL : (LPCTSTR)m_strCommand;
  191. }
  192. private:
  193. String m_strDeviceId;
  194. String m_strMachineName;
  195. String m_strCommand;
  196. BOOL m_WaitForDeviceId;
  197. BOOL m_WaitForMachineName;
  198. BOOL m_WaitForCommand;
  199. };
  200. class CNotifyRebootRequest
  201. {
  202. public:
  203. CNotifyRebootRequest() : Ref(1), m_hWnd(NULL), m_RestartFlags(0), m_StringId(0)
  204. {}
  205. CNotifyRebootRequest(HWND hWnd, DWORD RestartFlags, UINT StringId) : Ref(1)
  206. {
  207. m_hWnd = hWnd;
  208. m_RestartFlags = RestartFlags;
  209. m_StringId = StringId;
  210. }
  211. ~CNotifyRebootRequest()
  212. {
  213. }
  214. long AddRef()
  215. {
  216. Ref++;
  217. return Ref;
  218. }
  219. long Release()
  220. {
  221. ASSERT(Ref);
  222. if (!(--Ref))
  223. {
  224. delete this;
  225. return 0;
  226. }
  227. return Ref;
  228. }
  229. HWND m_hWnd;
  230. DWORD m_RestartFlags;
  231. UINT m_StringId;
  232. private:
  233. long Ref;
  234. };
  235. #endif