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.

349 lines
6.1 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. stistub.c
  5. Abstract:
  6. Routines which use RPC to pass arguments to/from server while enclosed in SEH frame
  7. Environment:
  8. User Mode -Win32
  9. Author:
  10. Vlad Sadovsky (vlads) 26-Jan-1997
  11. Revision History:
  12. 26-Jan-1997 VladS created
  13. --*/
  14. /*
  15. #include "wia.h"
  16. #include <stilog.h>
  17. #include <stiregi.h>
  18. #include <sti.h>
  19. #include <stierr.h>
  20. #include <stiusd.h>
  21. #include "stipriv.h"
  22. #include "debug.h"
  23. */
  24. #include "sticomm.h"
  25. #include <stiapi.h>
  26. #include <apiutil.h>
  27. #include <stirpc.h>
  28. DWORD
  29. WINAPI
  30. RpcStiApiGetVersion(
  31. IN LPCWSTR pszServer,
  32. IN DWORD dwReserved,
  33. OUT LPDWORD lpdwVersion
  34. )
  35. {
  36. DWORD status;
  37. RpcTryExcept {
  38. status = R_StiApiGetVersion(NULL,
  39. dwReserved,
  40. lpdwVersion);
  41. }
  42. RpcExcept (1) {
  43. status = RpcExceptionCode();
  44. }
  45. RpcEndExcept
  46. return status;
  47. }
  48. DWORD
  49. WINAPI
  50. RpcStiApiOpenDevice(
  51. IN LPCWSTR pszServer,
  52. IN LPCWSTR pdeviceName,
  53. IN DWORD dwMode,
  54. IN DWORD dwAccessRequired,
  55. IN DWORD dwProcessId,
  56. OUT HANDLE *pHandle
  57. )
  58. {
  59. DWORD status;
  60. RpcTryExcept {
  61. status = R_StiApiOpenDevice(NULL,
  62. pdeviceName,
  63. dwMode,
  64. dwAccessRequired,
  65. dwProcessId,
  66. pHandle
  67. );
  68. }
  69. RpcExcept (1) {
  70. status = RpcExceptionCode();
  71. }
  72. RpcEndExcept
  73. return status;
  74. }
  75. DWORD
  76. WINAPI
  77. RpcStiApiCloseDevice(
  78. IN LPCWSTR pszServer,
  79. IN HANDLE hDevice
  80. )
  81. {
  82. DWORD status;
  83. RpcTryExcept {
  84. status = R_StiApiCloseDevice(NULL,hDevice );
  85. }
  86. RpcExcept (1) {
  87. status = RpcExceptionCode();
  88. }
  89. RpcEndExcept
  90. return status;
  91. }
  92. DWORD
  93. WINAPI
  94. RpcStiApiSubscribe(
  95. IN STI_DEVICE_HANDLE hDevice,
  96. IN LPSTISUBSCRIBE lpSubScribe
  97. )
  98. {
  99. DWORD status;
  100. LOCAL_SUBSCRIBE_CONTAINER sLocalContainer;
  101. ZeroMemory(&sLocalContainer,sizeof(LOCAL_SUBSCRIBE_CONTAINER));
  102. RpcTryExcept {
  103. sLocalContainer.dwSize = sizeof(LOCAL_SUBSCRIBE_CONTAINER);
  104. sLocalContainer.dwFlags = lpSubScribe->dwFlags;
  105. if (lpSubScribe->dwFlags & STI_SUBSCRIBE_FLAG_WINDOW) {
  106. sLocalContainer.upLocalWindowHandle = (UINT_PTR)lpSubScribe->hWndNotify;
  107. sLocalContainer.uiNotificationMessage = lpSubScribe->uiNotificationMessage;
  108. }
  109. else {
  110. sLocalContainer.upLocalEventHandle = (UINT_PTR)lpSubScribe->hEvent;
  111. }
  112. status = R_StiApiSubscribe(hDevice,&sLocalContainer);
  113. }
  114. RpcExcept (1) {
  115. status = RpcExceptionCode();
  116. }
  117. RpcEndExcept
  118. return status;
  119. }
  120. DWORD
  121. WINAPI
  122. RpcStiApiGetLastNotificationData(
  123. IN STI_DEVICE_HANDLE hDevice,
  124. OUT LPSTINOTIFY lpNotify
  125. )
  126. {
  127. DWORD status;
  128. DWORD cbNeeded;
  129. RpcTryExcept {
  130. status = R_StiApiGetLastNotificationData(hDevice,
  131. (LPBYTE)lpNotify,
  132. lpNotify->dwSize,
  133. &cbNeeded
  134. );
  135. }
  136. RpcExcept (1) {
  137. status = RpcExceptionCode();
  138. }
  139. RpcEndExcept
  140. return status;
  141. }
  142. DWORD
  143. WINAPI
  144. RpcStiApiUnSubscribe(
  145. IN STI_DEVICE_HANDLE hDevice
  146. )
  147. {
  148. DWORD status;
  149. RpcTryExcept {
  150. status = R_StiApiUnSubscribe(hDevice);
  151. }
  152. RpcExcept (1) {
  153. status = RpcExceptionCode();
  154. }
  155. RpcEndExcept
  156. return status;
  157. }
  158. DWORD
  159. WINAPI
  160. RpcStiApiEnableHwNotifications(
  161. IN LPCWSTR pszServer,
  162. IN LPCWSTR pdeviceName,
  163. IN BOOL bNewState
  164. )
  165. {
  166. DWORD status;
  167. RpcTryExcept {
  168. status = R_StiApiEnableHwNotifications(NULL,
  169. pdeviceName,
  170. bNewState
  171. );
  172. }
  173. RpcExcept (1) {
  174. status = RpcExceptionCode();
  175. }
  176. RpcEndExcept
  177. return status;
  178. }
  179. DWORD
  180. WINAPI
  181. RpcStiApiGetHwNotificationState(
  182. IN LPCWSTR pszServer,
  183. IN LPCWSTR pdeviceName,
  184. OUT LPDWORD pState
  185. )
  186. {
  187. DWORD status;
  188. RpcTryExcept {
  189. status = R_StiApiGetHwNotificationState(NULL,
  190. pdeviceName,
  191. pState
  192. );
  193. }
  194. RpcExcept (1) {
  195. status = RpcExceptionCode();
  196. }
  197. RpcEndExcept
  198. return status;
  199. }
  200. DWORD
  201. WINAPI
  202. RpcStiApiLaunchApplication(
  203. IN LPCWSTR pszServer,
  204. IN LPCWSTR pdeviceName,
  205. IN LPCWSTR pAppName,
  206. IN LPSTINOTIFY pStiNotify
  207. )
  208. {
  209. DWORD status;
  210. RpcTryExcept {
  211. status = R_StiApiLaunchApplication(NULL,
  212. pdeviceName,
  213. pAppName,
  214. pStiNotify
  215. );
  216. }
  217. RpcExcept (1) {
  218. status = RpcExceptionCode();
  219. }
  220. RpcEndExcept
  221. return status;
  222. }
  223. DWORD
  224. WINAPI
  225. RpcStiApiLockDevice(
  226. IN LPCWSTR pdeviceName,
  227. IN DWORD dwWait,
  228. IN BOOL bInServerProcess
  229. )
  230. {
  231. DWORD status;
  232. RpcTryExcept {
  233. status = R_StiApiLockDevice(NULL,
  234. pdeviceName,
  235. dwWait,
  236. FALSE,
  237. GetCurrentThreadId());
  238. }
  239. RpcExcept (1) {
  240. status = RpcExceptionCode();
  241. }
  242. RpcEndExcept
  243. return status;
  244. }
  245. DWORD
  246. WINAPI
  247. RpcStiApiUnlockDevice(
  248. IN LPCWSTR pdeviceName,
  249. IN BOOL bInServerProcess
  250. )
  251. {
  252. DWORD status;
  253. RpcTryExcept {
  254. status = R_StiApiUnlockDevice(NULL,
  255. pdeviceName,
  256. FALSE,
  257. GetCurrentThreadId());
  258. }
  259. RpcExcept (1) {
  260. status = RpcExceptionCode();
  261. }
  262. RpcEndExcept
  263. return status;
  264. }