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.

456 lines
7.0 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. stiexe.h
  5. Abstract:
  6. Main header file
  7. Author:
  8. Vlad Sadovsky (vlads) 10-Jan-1997
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. 26-Jan-1997 VladS created
  13. 30-Sep-1997 VladS Added SCM glue layer
  14. 13-Apr-1999 VladS merged with WIA service code
  15. --*/
  16. //{{AFX_INSERT_LOCATION}}
  17. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  18. //
  19. // Additional ATL headers
  20. //
  21. #define IS_32
  22. #include <dbt.h>
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. #include <cfgmgr32.h>
  27. #include "stipriv.h"
  28. #ifdef __cplusplus
  29. };
  30. #endif
  31. #ifdef DEFINE_GLOBAL_VARIABLES
  32. #include <initguid.h>
  33. #endif
  34. #include <rpcasync.h>
  35. #include <stistr.h>
  36. #include "enum.h"
  37. #include "wiamindr.h"
  38. #include "globals.h"
  39. #include "stismsg.h"
  40. #include "resource.h"
  41. #include "sched.h"
  42. #include "util.h"
  43. #include "stismsg.h"
  44. #include "drvwrap.h"
  45. #include "device.h"
  46. #include "stiapi.h"
  47. #include "wiapriv.h"
  48. #include "wiaprivd.h"
  49. #include "wiadevman.h"
  50. #include "helpers.h"
  51. #include "wiasvc.h"
  52. #include "stirpc.h"
  53. //
  54. // StiRT helper functions
  55. //
  56. typedef LPVOID PV, *PPV;
  57. #ifdef __cplusplus
  58. extern "C" {
  59. #endif
  60. extern STDMETHODIMP StiPrivateGetDeviceInfoHelperW(
  61. LPWSTR pwszDeviceName,
  62. LPVOID *ppBuffer
  63. );
  64. extern STDMETHODIMP StiCreateHelper(
  65. HINSTANCE hinst,
  66. DWORD dwVer,
  67. LPVOID *ppvObj,
  68. LPUNKNOWN punkOuter,
  69. REFIID riid
  70. );
  71. extern STDMETHODIMP NewDeviceControl(
  72. DWORD dwDeviceType,
  73. DWORD dwMode,
  74. LPCWSTR pwszPortName,
  75. DWORD dwFlags,
  76. PSTIDEVICECONTROL *ppDevCtl);
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. //
  81. // RPC server helper functions
  82. //
  83. RPC_STATUS
  84. StopRpcServerListen(
  85. VOID
  86. );
  87. RPC_STATUS
  88. StartRpcServerListen(
  89. VOID);
  90. extern SERVICE_TABLE_ENTRY ServiceDispatchTable[];
  91. //
  92. // Service controller glue layer
  93. //
  94. DWORD
  95. StiServiceInstall(
  96. LPTSTR lpszUserName,
  97. LPTSTR lpszUserPassword
  98. );
  99. DWORD
  100. StiServiceRemove(
  101. VOID
  102. );
  103. BOOL
  104. RegisterServiceControlHandler(
  105. );
  106. VOID
  107. WINAPI
  108. StiServiceMain(
  109. IN DWORD argc,
  110. IN LPTSTR *argv
  111. );
  112. HWND
  113. CreateServiceWindow(
  114. VOID
  115. );
  116. LRESULT
  117. CALLBACK
  118. StiSvcWinProc(
  119. HWND hwnd,
  120. UINT uMsg,
  121. WPARAM wParam,
  122. LPARAM lParam
  123. );
  124. VOID
  125. WINAPI
  126. StiServiceMain(
  127. IN DWORD argc,
  128. IN LPTSTR *argv
  129. );
  130. VOID
  131. StiServiceStop(
  132. VOID
  133. );
  134. VOID
  135. StiServicePause(
  136. VOID
  137. );
  138. VOID
  139. StiServiceResume(
  140. VOID
  141. );
  142. DWORD
  143. WINAPI
  144. UpdateServiceStatus(
  145. IN DWORD dwState,
  146. IN DWORD dwWin32ExitCode,
  147. IN DWORD dwWaitHint );
  148. DWORD
  149. StiServiceInitialize(
  150. VOID
  151. );
  152. BOOL
  153. VisualizeServer(
  154. BOOL fVisualize
  155. );
  156. //
  157. // Message worker functions
  158. //
  159. DWORD
  160. StiWnd_OnPowerControlMessage(
  161. HWND hwnd,
  162. DWORD dwPowerEvent,
  163. LPARAM lParam
  164. );
  165. LRESULT
  166. StiWnd_OnDeviceChangeMessage(
  167. HWND hwnd,
  168. UINT DeviceEvent,
  169. LPARAM lParam
  170. );
  171. VOID
  172. WINAPI
  173. StiMessageCallback(
  174. VOID *pArg
  175. );
  176. LRESULT
  177. StiSendMessage(
  178. HWND hWnd,
  179. UINT Msg,
  180. WPARAM wParam,
  181. LPARAM lParam
  182. );
  183. BOOL
  184. StiPostMessage(
  185. HWND hWnd,
  186. UINT Msg,
  187. WPARAM wParam,
  188. LPARAM lParam
  189. );
  190. //
  191. // UI and debugging
  192. //
  193. BOOL
  194. SizeDiff(
  195. HWND hWnd,
  196. UINT wMsgID,
  197. WPARAM wParam,
  198. LPARAM lParam
  199. );
  200. BOOL
  201. HScroll(
  202. HWND hWnd,
  203. UINT wMsgID,
  204. WPARAM wParam,
  205. LPARAM lParam
  206. );
  207. BOOL
  208. VScroll(
  209. HWND hWnd,
  210. UINT wMsgID,
  211. WPARAM wParam,
  212. LPARAM lParam
  213. );
  214. void
  215. __cdecl
  216. StiMonWndDisplayOutput(
  217. LPTSTR pString,
  218. ...
  219. );
  220. void
  221. __cdecl
  222. vStiMonWndDisplayOutput(
  223. LPTSTR pString,
  224. va_list arglist
  225. );
  226. #ifdef SHOWMONUI
  227. #define STIMONWPRINTF StiMonWndDisplayOutput
  228. #else
  229. // Nb: Following definition is needed to avoid compiler complaining
  230. // about empty function name in expression. In retail builds using this macro
  231. // will cause string parameters not appear in executable
  232. //
  233. #define STIMONWPRINTF 1?(void)0 : (void)
  234. #endif
  235. //
  236. // Tracing function
  237. //
  238. void
  239. WINAPI
  240. StiLogTrace(
  241. DWORD dwType,
  242. LPTSTR lpszMessage,
  243. ...
  244. );
  245. void
  246. WINAPI
  247. StiLogTrace(
  248. DWORD dwType,
  249. DWORD idMessage,
  250. ...
  251. );
  252. //
  253. // Utils
  254. //
  255. BOOL
  256. IsStillImagePnPMessage(
  257. PDEV_BROADCAST_HDR pDev
  258. );
  259. //
  260. // WIA device manager initialization actions, for use with InitWiaDevMan.
  261. //
  262. typedef enum _WIA_SERVICE_INIT_ACTION {
  263. WiaInitialize = 0,
  264. WiaRegister,
  265. WiaUnregister,
  266. WiaUninitialize
  267. } WIA_SERVICE_INIT_ACTION, *PWIA_SERVICE_INIT_ACTION;
  268. //
  269. // WIA entry points called by the STI service.
  270. //
  271. HRESULT DispatchWiaMsg(MSG*);
  272. HRESULT ProcessWiaMsg(HWND, UINT, WPARAM, LPARAM);
  273. HRESULT InitWiaDevMan(WIA_SERVICE_INIT_ACTION);
  274. HRESULT NotifyWiaDeviceEvent(LPWSTR, const GUID*, PBYTE, ULONG, DWORD);
  275. HRESULT StartLOGClassFactories();
  276. //
  277. // STI entry points in wiaservc.dll, called by the WIA device manager.
  278. //
  279. HRESULT WiaUpdateDeviceInfo();
  280. class STI_MESSAGE : public IUnknown
  281. {
  282. public:
  283. //
  284. // IUnknown methods needed for Scheduler thread
  285. //
  286. HRESULT _stdcall QueryInterface(
  287. REFIID iid,
  288. void **ppvObject)
  289. {
  290. return E_NOTIMPL;
  291. };
  292. ULONG _stdcall AddRef()
  293. {
  294. InterlockedIncrement(&m_cRef);
  295. return m_cRef;
  296. };
  297. ULONG _stdcall Release()
  298. {
  299. LONG lRef = InterlockedDecrement(&m_cRef);
  300. if (lRef < 1) {
  301. delete this;
  302. lRef = 0;;
  303. }
  304. return lRef;
  305. };
  306. STI_MESSAGE(UINT uMsg,
  307. WPARAM wParam,
  308. LPARAM lParam
  309. )
  310. {
  311. m_uMsg = uMsg;
  312. m_wParam = wParam;
  313. m_lParam = lParam;
  314. m_cRef = 0;
  315. };
  316. ~STI_MESSAGE()
  317. {
  318. }
  319. public:
  320. LONG m_cRef;
  321. UINT m_uMsg;
  322. WPARAM m_wParam;
  323. LPARAM m_lParam;
  324. };
  325. //
  326. // Macros
  327. //
  328. #ifndef USE_WINDOWS_MESSAGING
  329. #undef SendMessage
  330. #undef PostMessage
  331. #define SendMessage StiSendMessage
  332. #define PostMessage StiPostMessage
  333. #endif
  334. //
  335. // Shutdown event
  336. //
  337. extern HANDLE hShutdownEvent;
  338. //
  339. // Array of non Image device interfaces we listen on
  340. //
  341. #define NOTIFICATION_GUIDS_NUM 16
  342. extern const GUID g_pguidDeviceNotificationsGuidArray[];
  343. //
  344. // Array of initialized notificaiton sinks for non Image interfaces
  345. //
  346. extern HDEVNOTIFY g_phDeviceNotificationsSinkArray[NOTIFICATION_GUIDS_NUM];
  347. typedef struct WIAEVENTRPCSTRUCT {
  348. RPC_ASYNC_STATE * pAsync;
  349. WIA_ASYNC_EVENT_NOTIFY_DATA * pEvent;
  350. CRITICAL_SECTION cs;
  351. } WIAEVENTRPCSTRUCT;
  352. extern WIAEVENTRPCSTRUCT g_RpcEvent;