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.

1534 lines
50 KiB

  1. /*++
  2. Copyright (c) 1998-2000 Microsoft Corporation
  3. Module Name :
  4. rdrdr.h
  5. Abstract:
  6. Type definitions for the Rdp redirector protocol
  7. Revision History:
  8. --*/
  9. #ifndef _RDPDR_
  10. #define _RDPDR_
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif // __cplusplus
  14. //
  15. // Turn off compiler padding of structures
  16. // Save previous packing style if 32-bit build.
  17. //
  18. #ifdef OS_WIN16
  19. #pragma pack (1)
  20. #else
  21. #pragma pack (push, drpack, 1)
  22. #endif
  23. //
  24. // version info.
  25. //
  26. #define RDPDR_MAJOR_VERSION 1
  27. #define RDPDR_MINOR_VERSION 5
  28. //
  29. // version comparison macro
  30. //
  31. #define COMPARE_VERSION(Minor1, Major1, Minor2, Major2) \
  32. (((LONG)MAKELONG(Minor1, Major1)) - ((LONG)MAKELONG(Minor2, Major2)))
  33. #define RDPDR_MAJOR_VERSION_PORTS 1
  34. #define RDPDR_MINOR_VERSION_PORTS 5
  35. #define RDPDR_MAJOR_VERSION_DRIVE 1
  36. #define RDPDR_MINOR_VERSION_DRIVE 5
  37. //
  38. // NULL Client Device ID.
  39. //
  40. #define RDPDR_INVALIDDEVICEID (ULONG)-1
  41. //
  42. // This string precedes the session id number in the file name path when
  43. // a user-mode component opens us for device management.
  44. //
  45. #define RDPDYN_SESSIONIDSTRING L"\\session"
  46. //
  47. // Device Names for RDPDR Device Manager Control Device
  48. //
  49. // NT Names
  50. #define RDPDRDVMGR_DEVICE_PATH_A "\\Device\\RdpDrDvMgr"
  51. #define RDPDRDVMGR_DEVICE_PATH_U L"\\Device\\RdpDrDvMgr"
  52. #define RDPDRDVMGR_DEVICE_PATH_A_LENGTH sizeof(RDPDRDVMGR_DEVICE_PATH_A)
  53. #define RDPDRDVMGR_DEVICE_PATH_U_LENGTH sizeof(RDPDRDVMGR_DEVICE_PATH_U)
  54. // Win32 Names
  55. #define RDPDRDVMGR_W32DEVICE_NAME_A "RdpDrDvMgr"
  56. #define RDPDRDVMGR_W32DEVICE_NAME_U L"RdpDrDvMgr"
  57. #define RDPDRDVMGR_W32DEVICE_PATH_A "\\DosDevices\\RdpDrDvMgr"
  58. #define RDPDRDVMGR_W32DEVICE_PATH_U L"\\DosDevices\\RdpDrDvMgr"
  59. #define RDPDRDVMGR_W32DEVICE_PATH_A_LENGTH sizeof(RDPDRDVMGR_W32DEVICE_PATH_A)
  60. #define RDPDRDVMGR_W32DEVICE_PATH_U_LENGTH sizeof(RDPDRDVMGR_W32DEVICE_PATH_U)
  61. // Maximum number of characters in a ULONG -> STRING conversion.
  62. #define RDPDRMAXULONGSTRING 16 // Big enough for a 32-bit int.
  63. #define RDPDRMAXDOSNAMELEN 16
  64. //
  65. // Maximum number of characters (not bytes!) in a reference string.
  66. //
  67. #define RDPDRMAXREFSTRINGLEN \
  68. (RDPDRMAXDOSNAMELEN + RDPDRMAXULONGSTRING + RDPDR_MAX_COMPUTER_NAME_LENGTH + 5 + RDPDRMAXDOSNAMELEN + 1)
  69. // DosDeviceName + Session ID + computer name + delimiters + preferred dos name + terminator
  70. //
  71. // Maximum number of characters in a NT device name string
  72. //
  73. #define RDPDRMAXNTDEVICENAMEGLEN \
  74. ((sizeof(RDPDR_PORT_DEVICE_NAME_U) / sizeof(WCHAR)) + RDPDRMAXREFSTRINGLEN + 1)
  75. // NT Device name + Reference string + terminator null
  76. //
  77. // Dr Network Provider Dll Name
  78. //
  79. #define RDPDR_PROVIDER_NAME_U L"Microsoft Terminal Services"
  80. #define RDPDR_PROVIDER_NAME_A "Microsoft Terminal Services"
  81. // The following constant defines the length of the above name.
  82. #define RDPDR_PROVIDER_NAME_U_LENGTH (sizeof(RDPDR_PROVIDER_NAME_U))
  83. #define RDPDR_PROVIDER_NAME_A_LENGTH (sizeof(RDPDR_PROVIDER_NAME_A))
  84. //
  85. // RDPDR Device Manager Event Codes for IOCTL Responses from Server
  86. //
  87. // Message Code Corresponding Message Meaning
  88. // ---------------------------------------------------------------------------
  89. // RDPDREVT_PRINTERANNOUNCE RDPDR_PRINTERDEVICE_SUB New printer device.
  90. // RDPDREVT_BUFFERTOOSMALL RDPDR_BUFFERTOOSMALL IOCTL output buffer
  91. // is too small.
  92. // RDPDREVT_PORTANNOUNCE RDPDR_PORTDEVICE_SUB New redirect port
  93. // device.
  94. // RDPDREVT_REMOVEDEVICE RDPDR_REMOVEDEVICE A client-side device
  95. // has been removed.
  96. // RDPDREVT_SESSIONDISCONNECT NONE Client has disconnected
  97. // from the session.
  98. // RDPDREVT_DRIVEANNOUNCE RDPDR_DRIVEDEVICE_SUB New redirected drive
  99. // device
  100. //
  101. // Message Codes
  102. #define RDPDREVT_BASE 0
  103. #define RDPDREVT_PRINTERANNOUNCE RDPDREVT_BASE + 1
  104. #define RDPDREVT_BUFFERTOOSMALL RDPDREVT_BASE + 2
  105. #define RDPDREVT_REMOVEDEVICE RDPDREVT_BASE + 3
  106. #define RDPDREVT_PORTANNOUNCE RDPDREVT_BASE + 4
  107. #define RDPDREVT_SESSIONDISCONNECT RDPDREVT_BASE + 5
  108. #define RDPDREVT_DRIVEANNOUNCE RDPDREVT_BASE + 6
  109. //
  110. // Device Manager IOCTL's
  111. //
  112. // IOCTL Input Buffer Output Message Code
  113. // (Above-Defined Buffer Follows
  114. // Header in Driver-Response)
  115. // ----------------------------------------------------------------------------
  116. // IOCTL_RDPDR_GETNEXTDEVMGMTEVENT NONE RDPDREVT_PRINTERANNOUNCE
  117. // RDPDREVT_BUFFERTOOSMALL
  118. // IOCTL_RDPDR_DBGADDNEWPRINTER NONE NONE
  119. // IOCTL_RDPDR_CLIENTMSG opaque data NONE
  120. // intended for
  121. // session's
  122. // corresponding
  123. // client.
  124. //
  125. #define IOCTL_RDPDR_GETNEXTDEVMGMTEVENT \
  126. CTL_CODE(FILE_DEVICE_UNKNOWN, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
  127. #ifdef DBG
  128. #define IOCTL_RDPDR_DBGADDNEWPRINTER \
  129. CTL_CODE(FILE_DEVICE_UNKNOWN, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
  130. #endif
  131. #define IOCTL_RDPDR_CLIENTMSG \
  132. CTL_CODE(FILE_DEVICE_UNKNOWN, 0x803, METHOD_BUFFERED, FILE_ANY_ACCESS)
  133. //
  134. // TS Printer Port Defines
  135. //
  136. #define RDPDRPRT_BASEPORTNAME L"TS" // TS Port Base Name
  137. #define RDPDR_PORTNAMEDIGITS 6 // This value must match JobyL's value for USB
  138. // max port number.
  139. #define RDPDR_PORTNAMEDIGITSTOPAD 3 // We pad the first 3 to make things line
  140. // up nicely in UI up to port 999
  141. #define RDPDR_MAXPORTNAMELEN \
  142. (((sizeof(RDPDRPRT_BASEPORTNAME)-sizeof(WCHAR))/sizeof(WCHAR)) \
  143. + RDPDR_PORTNAMEDIGITS + 1) // In characters, including the terminator.
  144. //
  145. // Driver name and ioctls
  146. //
  147. #define RDPDR_DEVICE_NAME_A "\\Device\\RdpDr"
  148. #define RDPDR_DEVICE_NAME_U L"\\Device\\RdpDr"
  149. #define RDPDR_DEVICE_NAME_A_LENGTH sizeof(RDPDR_DEVICE_NAME_A)
  150. #define RDPDR_DEVICE_NAME_U_LENGTH sizeof(RDPDR_DEVICE_NAME_U)
  151. #define RDPDR_PORT_DEVICE_NAME_A "\\Device\\RdpDrPort"
  152. #define RDPDR_PORT_DEVICE_NAME_U L"\\Device\\RdpDrPort"
  153. #define RDPDR_PORT_DEVICE_NAME_A_LENGTH sizeof(RDPDR_PORT_DEVICE_NAME_A)
  154. #define RDPDR_PORT_DEVICE_NAME_U_LENGTH sizeof(RDPDR_PORT_DEVICE_NAME_U)
  155. #define FSCTL_DR_START CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, \
  156. 100, METHOD_BUFFERED, FILE_ANY_ACCESS)
  157. #define FSCTL_DR_STOP CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, \
  158. 101, METHOD_BUFFERED, FILE_ANY_ACCESS)
  159. #define FSCTL_DR_DELETE_CONNECTION CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, \
  160. 102, METHOD_BUFFERED, FILE_ANY_ACCESS)
  161. #define FSCTL_DR_GET_CONNECTION_INFO CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, \
  162. 103, METHOD_NEITHER, FILE_ANY_ACCESS)
  163. #define FSCTL_DR_ENUMERATE_CONNECTIONS CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, \
  164. 104, METHOD_NEITHER, FILE_ANY_ACCESS)
  165. #define FSCTL_DR_ENUMERATE_SHARES CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, \
  166. 105, METHOD_NEITHER, FILE_ANY_ACCESS)
  167. #define FSCTL_DR_ENUMERATE_SERVERS CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, \
  168. 106, METHOD_NEITHER, FILE_ANY_ACCESS)
  169. //
  170. // Channel Name
  171. //
  172. #define DR_CHANNEL_NAME "RDPDR"
  173. //
  174. // Smartcard Name
  175. //
  176. #define DR_SMARTCARD_SUBSYSTEM "SCARD"
  177. //
  178. // Smartcard Name
  179. //
  180. #define DR_SMARTCARD_FILEID 1
  181. //
  182. // Component Ids
  183. //
  184. #define RDPDR_CTYP_CORE 0x4472 /* 'Dr' */
  185. #define RDPDR_CTYP_PRN 0x5052 /* 'PR' */
  186. //
  187. // Core Packet Ids
  188. //
  189. #define DR_CORE_SERVER_ANNOUNCE 0x496E /* 'In' */
  190. #define DR_CORE_CLIENTID_CONFIRM 0x4343 /* 'CC' */
  191. #define DR_CORE_CLIENT_NAME 0x434E /* 'CN' */
  192. #define DR_CORE_DEVICE_ANNOUNCE 0x6461 /* 'da' */
  193. #define DR_CORE_DEVICELIST_ANNOUNCE 0x4441 /* 'DA' */
  194. #define DR_CORE_DEVICELIST_REPLY 0x4452 /* 'DR' */
  195. #define DR_CORE_DEVICE_REPLY 0x6472 /* 'dr' */
  196. #define DR_CORE_DEVICE_IOREQUEST 0x4952 /* 'IR' */
  197. #define DR_CORE_DEVICE_IOCOMPLETION 0x4943 /* 'IC' */
  198. #define DR_CORE_SERVER_CAPABILITY 0x5350 /* 'SP' */
  199. #define DR_CORE_CLIENT_CAPABILITY 0x4350 /* 'CP' */
  200. #define DR_CORE_DEVICE_REMOVE 0x646D /* 'dm' */
  201. #define DR_CORE_DEVICELIST_REMOVE 0x444D /* 'DM' */
  202. #define DR_CORE_CLIENT_DISPLAY_NAME 0x444E /* 'DN' */
  203. #define DR_PRN_CACHE_DATA 0x5043 /* 'PC' */
  204. //
  205. // Protocol header
  206. //
  207. typedef struct tagRDPDR_HEADER {
  208. SHORT Component;
  209. SHORT PacketId;
  210. } RDPDR_HEADER, *PRDPDR_HEADER;
  211. #ifdef __cplusplus
  212. inline
  213. BOOL
  214. IsValidHeader(
  215. PVOID pData
  216. )
  217. {
  218. PRDPDR_HEADER pRdpdrHeader;
  219. pRdpdrHeader = (PRDPDR_HEADER)pData;
  220. if( (pRdpdrHeader != NULL) &&
  221. ((pRdpdrHeader->Component == RDPDR_CTYP_CORE) ||
  222. (pRdpdrHeader->Component == RDPDR_CTYP_PRN)) ) {
  223. SHORT sPacketId;
  224. sPacketId = pRdpdrHeader->PacketId;
  225. if( (sPacketId == DR_CORE_SERVER_ANNOUNCE ) ||
  226. (sPacketId == DR_CORE_CLIENTID_CONFIRM ) ||
  227. (sPacketId == DR_CORE_CLIENT_NAME ) ||
  228. (sPacketId == DR_CORE_DEVICE_ANNOUNCE ) ||
  229. (sPacketId == DR_CORE_DEVICELIST_ANNOUNCE) ||
  230. (sPacketId == DR_CORE_DEVICELIST_REPLY ) ||
  231. (sPacketId == DR_CORE_DEVICE_REPLY ) ||
  232. (sPacketId == DR_CORE_DEVICE_IOREQUEST ) ||
  233. (sPacketId == DR_CORE_DEVICE_IOCOMPLETION) ||
  234. (sPacketId == DR_PRN_CACHE_DATA ) ||
  235. (sPacketId == DR_CORE_SERVER_CAPABILITY ) ||
  236. (sPacketId == DR_CORE_CLIENT_CAPABILITY ) ||
  237. (sPacketId == DR_CORE_DEVICE_REMOVE ) ||
  238. (sPacketId == DR_CORE_DEVICELIST_REMOVE ) ||
  239. (sPacketId == DR_CORE_CLIENT_DISPLAY_NAME)) {
  240. return( TRUE );
  241. }
  242. }
  243. return( FALSE );
  244. }
  245. #endif // __cplusplus
  246. //
  247. // RDPDR capability PDUs
  248. //
  249. // This is used during the client/server connection time to determine what
  250. // the client and server are capable of doing
  251. //
  252. typedef struct tagRDPDR_CAPABILITY_SET_HEADER
  253. {
  254. RDPDR_HEADER Header;
  255. UINT16 numberCapabilities;
  256. UINT16 pad1;
  257. } RDPDR_CAPABILITY_SET_HEADER, *PRDPDR_CAPABILITY_SET_HEADER;
  258. typedef struct tagRDPDR_CAPABILITY_HEADER
  259. {
  260. UINT16 capabilityType;
  261. UINT16 capabilityLength;
  262. UINT32 version;
  263. } RDPDR_CAPABILITY_HEADER, *PRDPDR_CAPABILITY_HEADER;
  264. #define RDPDR_GENERAL_CAPABILITY_TYPE 0x1
  265. #define RDPDR_PRINT_CAPABILITY_TYPE 0x2
  266. #define RDPDR_PORT_CAPABILITY_TYPE 0x3
  267. #define RDPDR_FS_CAPABILITY_TYPE 0x4
  268. #define RDPDR_SMARTCARD_CAPABILITY_TYPE 0x5
  269. //
  270. // RDPDR general capability
  271. //
  272. typedef struct tagRDPDR_GENERAL_CAPABILITY
  273. {
  274. UINT16 capabilityType;
  275. UINT16 capabilityLength;
  276. UINT32 version;
  277. #define RDPDR_GENERAL_CAPABILITY_VERSION_01 0x1
  278. UINT32 osType;
  279. #define RDPDR_OS_TYPE_UNKNOWN 0x0
  280. #define RDPDR_OS_TYPE_WIN9X 0x1
  281. #define RDPDR_OS_TYPE_WINNT 0x2
  282. UINT32 osVersion;
  283. // For windows platforms, the high word is the major version
  284. // The low word is the minor version
  285. UINT16 protocolMajorVersion;
  286. UINT16 protocolMinorVersion;
  287. UINT32 ioCode1;
  288. #define RDPDR_IRP_MJ_CREATE 0x0001
  289. #define RDPDR_IRP_MJ_CLEANUP 0x0002
  290. #define RDPDR_IRP_MJ_CLOSE 0x0004
  291. #define RDPDR_IRP_MJ_READ 0x0008
  292. #define RDPDR_IRP_MJ_WRITE 0x0010
  293. #define RDPDR_IRP_MJ_FLUSH_BUFFERS 0x0020
  294. #define RDPDR_IRP_MJ_SHUTDOWN 0x0040
  295. #define RDPDR_IRP_MJ_DEVICE_CONTROL 0x0080
  296. #define RDPDR_IRP_MJ_QUERY_VOLUME_INFORMATION 0x0100
  297. #define RDPDR_IRP_MJ_SET_VOLUME_INFORMATION 0x0200
  298. #define RDPDR_IRP_MJ_QUERY_INFORMATION 0x0400
  299. #define RDPDR_IRP_MJ_SET_INFORMATION 0x0800
  300. #define RDPDR_IRP_MJ_DIRECTORY_CONTROL 0x1000
  301. #define RDPDR_IRP_MJ_LOCK_CONTROL 0x2000
  302. #define RDPDR_IRP_MJ_QUERY_SECURITY 0x4000
  303. #define RDPDR_IRP_MJ_SET_SECURITY 0x8000
  304. UINT32 ioCode2;
  305. UINT32 extendedPDU;
  306. #define RDPDR_DEVICE_REMOVE_PDUS 0x0001
  307. #define RDPDR_CLIENT_DISPLAY_NAME_PDU 0x0002
  308. UINT32 extraFlags1;
  309. UINT32 extraFlags2;
  310. } RDPDR_GENERAL_CAPABILITY, *PRDPDR_GENERAL_CAPABILITY;
  311. //
  312. // RDPDR printing capability
  313. //
  314. typedef struct tagRDPDR_PRINT_CAPABILITY
  315. {
  316. UINT16 capabilityType;
  317. UINT16 capabilityLength;
  318. UINT32 version;
  319. #define RDPDR_PRINT_CAPABILITY_VERSION_01 0x1
  320. } RDPDR_PRINT_CAPABILITY, *PRDPDR_PRINT_CAPABILITY;
  321. //
  322. // RDPDR port capability
  323. //
  324. typedef struct tagRDPDR_PORT_CAPABILITY
  325. {
  326. UINT16 capabilityType;
  327. UINT16 capabilityLength;
  328. UINT32 version;
  329. #define RDPDR_PORT_CAPABILITY_VERSION_01 0x1
  330. } RDPDR_PORT_CAPABILITY, *PRDPDR_PORT_CAPABILITY;
  331. //
  332. // RDPDR file system capability
  333. //
  334. typedef struct tagRDPDR_FS_CAPABILITY
  335. {
  336. UINT16 capabilityType;
  337. UINT16 capabilityLength;
  338. UINT32 version;
  339. #define RDPDR_FS_CAPABILITY_VERSION_01 0x1
  340. } RDPDR_FS_CAPABILITY, *PRDPDR_FS_CAPABILITY;
  341. //
  342. // RDPDR smart card subsystem capability
  343. //
  344. typedef struct tagRDPDR_SMARTCARD_CAPABILITY
  345. {
  346. UINT16 capabilityType;
  347. UINT16 capabilityLength;
  348. UINT32 version;
  349. #define RDPDR_SMARTCARD_CAPABILITY_VERSION_01 0x1
  350. } RDPDR_SMARTCARD_CAPABILITY, *PRDPDR_SMARTCARD_CAPABILITY;
  351. typedef struct tagRDPDR_VERSION {
  352. SHORT Major;
  353. SHORT Minor;
  354. } RDPDR_VERSION, *PRDPDR_VERSION;
  355. //
  356. // Device types
  357. //
  358. #define RDPDR_DTYP_SERIAL 0x00000001
  359. #define RDPDR_DTYP_PARALLEL 0x00000002
  360. #define RDPDR_DRYP_PRINTPORT 0x00000010
  361. #define RDPDR_DTYP_PRINT 0x00000004
  362. #define RDPDR_DTYP_FILESYSTEM 0x00000008
  363. #define RDPDR_DTYP_SMARTCARD 0x00000020
  364. //
  365. // RDPDR_SERVER_ANNOUNCE
  366. //
  367. // Sent by the Server to establish communications and provide a client Id
  368. //
  369. typedef struct tagRDPDR_SERVER_ANNOUNCE
  370. {
  371. ULONG ClientId; // Unique client identifier.
  372. } RDPDR_SERVER_ANNOUNCE, *PRDPDR_SERVER_ANNOUNCE;
  373. typedef struct tagRDPDR_SERVER_ANNOUNCE_PACKET
  374. {
  375. RDPDR_HEADER Header;
  376. RDPDR_VERSION VersionInfo; // Server version Info.
  377. RDPDR_SERVER_ANNOUNCE ServerAnnounce;
  378. } RDPDR_SERVER_ANNOUNCE_PACKET, *PRDPDR_SERVER_ANNOUNCE_PACKET;
  379. //
  380. // RDPDR_CLIENTID_CONFIRM
  381. //
  382. // Sent by the client to confirm the client id or propose reusing a
  383. // pre-existing client Id. If the client sends acceptance the ID from the
  384. // RDPDR_SERVER_ANNOUNCE, that's the end of it.
  385. // If the client proposes a different id, the server will send a
  386. // RPPDR_CLIENTID_CONFIRM back to either insist on the original clientId or
  387. // accept the client provided one.
  388. //
  389. typedef struct tagRDPDR_CLIENTID_CONFIRM
  390. {
  391. ULONG ClientId; // Unique client identifier.
  392. } RDPDR_CLIENTID_CONFIRM, *PRDPDR_CLIENTID_CONFIRM;
  393. typedef struct tagRDPDR_CLIENT_CONFIRM_PACKET
  394. {
  395. RDPDR_HEADER Header;
  396. RDPDR_VERSION VersionInfo; // Client version Info.
  397. RDPDR_CLIENTID_CONFIRM ClientConfirm;
  398. } RDPDR_CLIENT_CONFIRM_PACKET, *PRDPDR_CLIENT_CONFIRM_PACKET;
  399. #ifndef MAX_COMPUTERNAME_LENGTH
  400. #define MAX_COMPUTERNAME_LENGTH 15 // From winbase.h
  401. #endif // MAX_COMPUTERNAME_LENGTH
  402. #define RDPDR_MAX_COMPUTER_NAME_LENGTH (MAX_COMPUTERNAME_LENGTH + 1)
  403. #define RDPDR_MAX_DOSNAMELEN 16
  404. typedef struct tagRDPDR_CLIENT_NAME
  405. {
  406. ULONG Unicode:1; // flag to indicate the computer name is unicode or
  407. // ansi.
  408. ULONG CodePage; // code page of the ansi string.
  409. ULONG ComputerNameLen;// length of the computer name in bytes that
  410. // follows this structures.
  411. //
  412. // computer name follows.
  413. //
  414. } RDPDR_CLIENT_NAME, *PRDPDR_CLIENT_NAME;
  415. typedef struct tagRDPDR_CLIENT_NAME_PACKET
  416. {
  417. RDPDR_HEADER Header;
  418. RDPDR_CLIENT_NAME Name;
  419. } RDPDR_CLIENT_NAME_PACKET, *PRDPDR_CLIENT_NAME_PACKET;
  420. #define RDPDR_MAX_CLIENT_DISPLAY_NAME 64
  421. typedef struct tagRDPDR_CLIENT_DISPLAY_NAME
  422. {
  423. BYTE ComputerDisplayNameLen;
  424. //
  425. // computer display name follows
  426. //
  427. } RDPDR_CLIENT_DISPLAY_NAME, *PRDPDR_CLIENT_DISPLAY_NAME;
  428. typedef struct tagRDPDR_CLIENT_DISPLAY_NAME_PACKET
  429. {
  430. RDPDR_HEADER Header;
  431. RDPDR_CLIENT_DISPLAY_NAME Name;
  432. } RDPDR_CLIENT_DISPLAY_NAME_PACKET, *PRDPDR_CLIENT_DISPLAY_NAME_PACKET;
  433. //
  434. // RDPDR_DEVICE_ANNOUNCE
  435. //
  436. // Sent by the client to indicate a device is available
  437. //
  438. #define PREFERRED_DOS_NAME_SIZE 8
  439. typedef struct tagRDPDR_DEVICE_ANNOUNCE
  440. {
  441. ULONG DeviceType; // Type of device, as listed above
  442. ULONG DeviceId; // An id to refer the device later
  443. UCHAR PreferredDosName[PREFERRED_DOS_NAME_SIZE]; // Preferred device name COM99:\null
  444. // Long enough?
  445. ULONG DeviceDataLength; // Length of Type specific data (follows)
  446. } RDPDR_DEVICE_ANNOUNCE, *PRDPDR_DEVICE_ANNOUNCE;
  447. typedef struct tagRDPDR_DEVICE_ANNOUNCE_PACKET
  448. {
  449. RDPDR_HEADER Header;
  450. RDPDR_DEVICE_ANNOUNCE DeviceAnnounce;
  451. } RDPDR_DEVICE_ANNOUNCE_PACKET, *PRDPDR_DEVICE_ANNOUNCE_PACKET;
  452. //
  453. // RDPDR_DEVICELIST_ANNOUNCE
  454. //
  455. // Sent by the client to indicate a number of devices are available
  456. //
  457. typedef struct tagRDPDR_DEVICELIST_ANNOUNCE
  458. {
  459. ULONG DeviceCount; // Number of devices
  460. // DeviceCount RDPDR_DEVICE_ANNOUNCE structures follows
  461. } RDPDR_DEVICELIST_ANNOUNCE, *PRDPDR_DEVICELIST_ANNOUNCE;
  462. typedef struct tagRDPDR_DEVICELIST_ANNOUNCE_PACKET
  463. {
  464. RDPDR_HEADER Header;
  465. RDPDR_DEVICELIST_ANNOUNCE DeviceListAnnounce;
  466. RDPDR_DEVICE_ANNOUNCE DeviceAnnounce;
  467. } RDPDR_DEVICELIST_ANNOUNCE_PACKET, *PRDPDR_DEVICELIST_ANNOUNCE_PACKET;
  468. #define DR_FIRSTDEVICEANNOUNCE(DeviceListPacket) \
  469. (&((PRDPDR_DEVICELIST_ANNOUNCE_PACKET)(DeviceListPacket))->DeviceAnnounce)
  470. #define DR_NEXTDEVICEANNOUNCE(DeviceAnnounce) \
  471. (PRDPDR_DEVICE_ANNOUNCE) \
  472. ((((PUCHAR)(DeviceAnnounce)) + sizeof(RDPDR_DEVICE_ANNOUNCE) + \
  473. ((DeviceAnnounce)->DeviceDataLength)))
  474. #define DR_CHECK_DEVICEDATALEN(DeviceAnnounce, DeviceSub) \
  475. (DeviceAnnounce->DeviceDataLength <= (sizeof(DeviceSub) - sizeof(*DeviceAnnounce)))
  476. //
  477. // RDPDR_DEVICE_REMOVE
  478. //
  479. // Sent by the client to indicate a device to be removed
  480. //
  481. typedef struct tagRDPDR_DEVICE_REMOVE
  482. {
  483. ULONG DeviceId; // An id to refer the device later
  484. } RDPDR_DEVICE_REMOVE, *PRDPDR_DEVICE_REMOVE;
  485. typedef struct tagRDPDR_DEVICE_REMOVE_PACKET
  486. {
  487. RDPDR_HEADER Header;
  488. RDPDR_DEVICE_REMOVE DeviceRemove;
  489. } RDPDR_DEVICE_REMOVE_PACKET, *PRDPDR_DEVICE_REMOVE_PACKET;
  490. //
  491. // RDPDR_DEVICELIST_REMOVE
  492. //
  493. // Sent by the client to indicate a number of devices are to be removed
  494. //
  495. typedef struct tagRDPDR_DEVICELIST_REMOVE
  496. {
  497. ULONG DeviceCount; // Number of devices
  498. // DeviceCount RDPDR_DEVICE_REMOVE structures follows
  499. } RDPDR_DEVICELIST_REMOVE, *PRDPDR_DEVICELIST_REMOVE;
  500. typedef struct tagRDPDR_DEVICELIST_REMOVE_PACKET
  501. {
  502. RDPDR_HEADER Header;
  503. RDPDR_DEVICELIST_REMOVE DeviceListRemove;
  504. RDPDR_DEVICE_REMOVE DeviceRemove;
  505. } RDPDR_DEVICELIST_REMOVE_PACKET, *PRDPDR_DEVICELIST_REMOVE_PACKET;
  506. #define DR_FIRSTDEVICEREMOVE(DeviceListPacket) \
  507. (&((PRDPDR_DEVICELIST_REMOVE_PACKET)(DeviceListPacket))->DeviceRemove)
  508. #define DR_NEXTDEVICEREMOVE(DeviceRemove) \
  509. (PRDPDR_DEVICE_REMOVE) \
  510. ((((PUCHAR)(DeviceRemove)) + sizeof(RDPDR_DEVICE_REMOVE)))
  511. #define RDPDR_DEVICE_REPLY_SUCCESS 0x00000000 // Accepted device
  512. #define RDPDR_DEVICE_REPLY_REJECTED 0x00000001 // Generic will not use
  513. //
  514. // RDPDR_DEVICE_REPLY
  515. //
  516. // Sent by the server to indicate whether a device will be used
  517. //
  518. typedef struct tagRDPDR_DEVICE_REPLY
  519. {
  520. ULONG DeviceId; // Id supplied in RDPDR_DEVICE_ANNOUNCE
  521. ULONG ResultCode; // Success or reason code
  522. } RDPDR_DEVICE_REPLY, *PRDPDR_DEVICE_REPLY;
  523. typedef struct tagRDPDR_DEVICE_REPLY_PACKET
  524. {
  525. RDPDR_HEADER Header;
  526. RDPDR_DEVICE_REPLY DeviceReply;
  527. } RDPDR_DEVICE_REPLY_PACKET, *PRDPDR_DEVICE_REPLY_PACKET;
  528. //
  529. // RDPDR_DEVICELIST_REPLY
  530. //
  531. // Sent by the server to indicate which devices will be used
  532. //
  533. typedef struct tagRDPDR_DEVICELIST_REPLY
  534. {
  535. ULONG DeviceCount; // Number of devices
  536. // DeviceReplies follow
  537. } RDPDR_DEVICELIST_REPLY, *PRDPDR_DEVICELIST_REPLY;
  538. typedef struct tagRDPDR_DEVICELIST_REPLY_PACKET
  539. {
  540. RDPDR_HEADER Header;
  541. RDPDR_DEVICELIST_REPLY DeviceListReply;
  542. RDPDR_DEVICE_REPLY DeviceReply;
  543. } RDPDR_DEVICELIST_REPLY_PACKET_PACKET,
  544. *PRDPDR_DEVICELIST_REPLY_PACKET_PACKET;
  545. //
  546. // RDPDR_UPDATE_DEVICEINFO
  547. //
  548. // Sent by the server to update information about the device, for example
  549. // if the user does configuration on it.
  550. //
  551. typedef struct tagRDPDR_UPDATE_DEVICEINFO
  552. {
  553. ULONG DeviceId; // Relevant device
  554. ULONG DeviceDataLength; // Length of type specific data (follows)
  555. } RDPDR_UPDATE_DEVICEINFO, *PRDPDR_UPDATE_DEVICEINFO;
  556. typedef struct tagRDPDR_UPDATE_DEVICEINFO_PACKET
  557. {
  558. RDPDR_HEADER Header;
  559. RDPDR_UPDATE_DEVICEINFO DeviceUpdate;
  560. UCHAR Data;
  561. } RDPDR_UPDATE_DEVICEINFO_PACKET, *PRDPDR_UPDATE_DEVICEINFO_PACKET;
  562. //
  563. // Define the file create disposition values
  564. // These are defined in ntioapi.h
  565. //
  566. #define FILE_SUPERSEDE 0x00000000
  567. #define FILE_OPEN 0x00000001
  568. #define FILE_CREATE 0x00000002
  569. #define FILE_OPEN_IF 0x00000003
  570. #define FILE_OVERWRITE 0x00000004
  571. #define FILE_OVERWRITE_IF 0x00000005
  572. #define FILE_MAXIMUM_DISPOSITION 0x00000005
  573. //
  574. // Define the I/O status information return values for NtCreateFile/NtOpenFile
  575. // These are defined in ntioapi.h
  576. //
  577. #define FILE_SUPERSEDED 0x00000000
  578. #define FILE_OPENED 0x00000001
  579. #define FILE_CREATED 0x00000002
  580. #define FILE_OVERWRITTEN 0x00000003
  581. #define FILE_EXISTS 0x00000004
  582. #define FILE_DOES_NOT_EXIST 0x00000005
  583. //
  584. // Define the file create/open option flags
  585. // Also defined in ntioapi.h
  586. //
  587. #define FILE_DIRECTORY_FILE 0x00000001
  588. #define FILE_WRITE_THROUGH 0x00000002
  589. #define FILE_SEQUENTIAL_ONLY 0x00000004
  590. #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
  591. #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
  592. #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
  593. #define FILE_NON_DIRECTORY_FILE 0x00000040
  594. #define FILE_CREATE_TREE_CONNECTION 0x00000080
  595. #define FILE_COMPLETE_IF_OPLOCKED 0x00000100
  596. #define FILE_NO_EA_KNOWLEDGE 0x00000200
  597. #define FILE_OPEN_FOR_RECOVERY 0x00000400
  598. #define FILE_RANDOM_ACCESS 0x00000800
  599. #define FILE_DELETE_ON_CLOSE 0x00001000
  600. #define FILE_OPEN_BY_FILE_ID 0x00002000
  601. #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
  602. #define FILE_NO_COMPRESSION 0x00008000
  603. #define FILE_RESERVE_OPFILTER 0x00100000
  604. #define FILE_OPEN_REPARSE_POINT 0x00200000
  605. #define FILE_OPEN_NO_RECALL 0x00400000
  606. #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
  607. #define FILE_COPY_STRUCTURED_STORAGE 0x00000041
  608. #define FILE_STRUCTURED_STORAGE 0x00000441
  609. #define FILE_VALID_OPTION_FLAGS 0x00ffffff
  610. //
  611. // Define the file system information class
  612. // Server can query the client file system with
  613. // each of these information class.
  614. // These are defined in ntioapi.h
  615. //
  616. typedef enum _RDPFSINFOCLASS {
  617. RdpFsVolumeInformation = 1,
  618. RdpFsLabelInformation, // 2
  619. RdpFsSizeInformation, // 3
  620. RdpFsDeviceInformation, // 4
  621. RdpFsAttributeInformation, // 5
  622. RdpFsControlInformation, // 6
  623. RdpFsFullSizeInformation, // 7
  624. RdpFsObjectIdInformation, // 8
  625. RdpFsMaximumInformation
  626. } RDP_FS_INFORMATION_CLASS, *PRDP_FS_INFORMATION_CLASS;
  627. //
  628. // This is the maximum length for the file system volume
  629. // information structures
  630. // (not including variable file length)
  631. // Need to update this value if there is update to the file
  632. // system volume information structures
  633. //
  634. #define RDP_FILE_VOLUME_INFO_MAXLENGTH 32
  635. //
  636. // Define file system information classes
  637. //
  638. typedef struct _RDP_FILE_FS_LABEL_INFORMATION {
  639. ULONG VolumeLabelLength;
  640. WCHAR VolumeLabel[1];
  641. } RDP_FILE_FS_LABEL_INFORMATION;
  642. typedef UNALIGNED RDP_FILE_FS_LABEL_INFORMATION * PRDP_FILE_FS_LABEL_INFORMATION;
  643. typedef struct _RDP_FILE_FS_VOLUME_INFORMATION {
  644. LARGE_INTEGER VolumeCreationTime;
  645. ULONG VolumeSerialNumber;
  646. ULONG VolumeLabelLength;
  647. BYTE SupportsObjects;
  648. WCHAR VolumeLabel[1];
  649. } RDP_FILE_FS_VOLUME_INFORMATION;
  650. typedef UNALIGNED RDP_FILE_FS_VOLUME_INFORMATION * PRDP_FILE_FS_VOLUME_INFORMATION;
  651. typedef struct _RDP_FILE_FS_SIZE_INFORMATION {
  652. LARGE_INTEGER TotalAllocationUnits;
  653. LARGE_INTEGER AvailableAllocationUnits;
  654. ULONG SectorsPerAllocationUnit;
  655. ULONG BytesPerSector;
  656. } RDP_FILE_FS_SIZE_INFORMATION;
  657. typedef UNALIGNED RDP_FILE_FS_SIZE_INFORMATION * PRDP_FILE_FS_SIZE_INFORMATION;
  658. typedef struct _RDP_FILE_FS_FULL_SIZE_INFORMATION {
  659. LARGE_INTEGER TotalAllocationUnits;
  660. LARGE_INTEGER CallerAvailableAllocationUnits;
  661. LARGE_INTEGER ActualAvailableAllocationUnits;
  662. ULONG SectorsPerAllocationUnit;
  663. ULONG BytesPerSector;
  664. } RDP_FILE_FS_FULL_SIZE_INFORMATION;
  665. typedef UNALIGNED RDP_FILE_FS_FULL_SIZE_INFORMATION * PRDP_FILE_FS_FULL_SIZE_INFORMATION;
  666. typedef struct _RDP_FILE_FS_ATTRIBUTE_INFORMATION {
  667. ULONG FileSystemAttributes;
  668. LONG MaximumComponentNameLength;
  669. ULONG FileSystemNameLength;
  670. WCHAR FileSystemName[1];
  671. } RDP_FILE_FS_ATTRIBUTE_INFORMATION;
  672. typedef UNALIGNED RDP_FILE_FS_ATTRIBUTE_INFORMATION * PRDP_FILE_FS_ATTRIBUTE_INFORMATION;
  673. //
  674. // Define the file information class
  675. // Server can query the client file with
  676. // each of these information class.
  677. // These are defined in ntioapi.h
  678. //
  679. typedef enum _RDP_FILE_INFORMATION_CLASS {
  680. RdpFileDirectoryInformation = 1,
  681. RdpFileFullDirectoryInformation, // 2
  682. RdpFileBothDirectoryInformation, // 3
  683. RdpFileBasicInformation, // 4
  684. RdpFileStandardInformation, // 5
  685. RdpFileInternalInformation, // 6
  686. RdpFileEaInformation, // 7
  687. RdpFileAccessInformation, // 8
  688. RdpFileNameInformation, // 9
  689. RdpFileRenameInformation, // 10
  690. RdpFileLinkInformation, // 11
  691. RdpFileNamesInformation, // 12
  692. RdpFileDispositionInformation, // 13
  693. RdpFilePositionInformation, // 14
  694. RdpFileFullEaInformation, // 15
  695. RdpFileModeInformation, // 16
  696. RdpFileAlignmentInformation, // 17
  697. RdpFileAllInformation, // 18
  698. RdpFileAllocationInformation, // 19
  699. RdpFileEndOfFileInformation, // 20
  700. RdpFileAlternateNameInformation, // 21
  701. RdpFileStreamInformation, // 22
  702. RdpFilePipeInformation, // 23
  703. RdpFilePipeLocalInformation, // 24
  704. RdpFilePipeRemoteInformation, // 25
  705. RdpFileMailslotQueryInformation, // 26
  706. RdpFileMailslotSetInformation, // 27
  707. RdpFileCompressionInformation, // 28
  708. RdpFileObjectIdInformation, // 29
  709. RdpFileCompletionInformation, // 30
  710. RdpFileMoveClusterInformation, // 31
  711. RdpFileQuotaInformation, // 32
  712. RdpFileReparsePointInformation, // 33
  713. RdpFileNetworkOpenInformation, // 34
  714. RdpFileAttributeTagInformation, // 35
  715. RdpFileTrackingInformation, // 36
  716. RdpFileMaximumInformation
  717. } RDP_FILE_INFORMATION_CLASS, *PRDP_FILE_INFORMATION_CLASS;
  718. //
  719. // This is the maximum length for the file information structures
  720. // (not including variable file length)
  721. // Need to update this value if there is update to the file
  722. // information structures
  723. //
  724. #define RDP_FILE_INFORMATION_MAXLENGTH 36
  725. //
  726. // Define file information classes
  727. //
  728. typedef struct _RDP_FILE_BASIC_INFORMATION {
  729. LARGE_INTEGER CreationTime;
  730. LARGE_INTEGER LastAccessTime;
  731. LARGE_INTEGER LastWriteTime;
  732. LARGE_INTEGER ChangeTime;
  733. ULONG FileAttributes;
  734. } RDP_FILE_BASIC_INFORMATION;
  735. typedef UNALIGNED RDP_FILE_BASIC_INFORMATION * PRDP_FILE_BASIC_INFORMATION;
  736. typedef struct _RDP_FILE_STANDARD_INFORMATION {
  737. LARGE_INTEGER AllocationSize;
  738. LARGE_INTEGER EndOfFile;
  739. ULONG NumberOfLinks;
  740. BOOLEAN DeletePending;
  741. BOOLEAN Directory;
  742. } RDP_FILE_STANDARD_INFORMATION;
  743. typedef UNALIGNED RDP_FILE_STANDARD_INFORMATION * PRDP_FILE_STANDARD_INFORMATION;
  744. typedef struct _RDP_FILE_ATTRIBUTE_TAG_INFORMATION {
  745. ULONG FileAttributes;
  746. ULONG ReparseTag;
  747. } RDP_FILE_ATTRIBUTE_TAG_INFORMATION;
  748. typedef UNALIGNED RDP_FILE_ATTRIBUTE_TAG_INFORMATION * PRDP_FILE_ATTRIBUTE_TAG_INFORMATION;
  749. typedef struct _RDP_FILE_INTERNAL_INFORMATION {
  750. LARGE_INTEGER IndexNumber;
  751. } RDP_FILE_INTERNAL_INFORMATION;
  752. typedef UNALIGNED RDP_FILE_INTERNAL_INFORMATION * PRDP_FILE_INTERNAL_INFORMATION;
  753. typedef struct _RDP_FILE_RENAME_INFORMATION {
  754. BOOLEAN ReplaceIfExists;
  755. BOOLEAN RootDirectory; // Specify if the FileName contains the root directory
  756. ULONG FileNameLength;
  757. WCHAR FileName[1];
  758. } RDP_FILE_RENAME_INFORMATION;
  759. typedef RDP_FILE_RENAME_INFORMATION * PRDP_FILE_RENAME_INFORMATION;
  760. //
  761. // This is the maximum length for any directory information structure
  762. // (not including variable file length)
  763. // Need to update this macro if there is update to the directory
  764. // information structure
  765. //
  766. #define RDP_FILE_DIRECTORY_INFO_MAXLENGTH 96
  767. typedef struct _RDP_FILE_DIRECTORY_INFORMATION {
  768. ULONG NextEntryOffset;
  769. ULONG FileIndex;
  770. LARGE_INTEGER CreationTime;
  771. LARGE_INTEGER LastAccessTime;
  772. LARGE_INTEGER LastWriteTime;
  773. LARGE_INTEGER ChangeTime;
  774. LARGE_INTEGER EndOfFile;
  775. LARGE_INTEGER AllocationSize;
  776. ULONG FileAttributes;
  777. ULONG FileNameLength;
  778. WCHAR FileName[1];
  779. } RDP_FILE_DIRECTORY_INFORMATION;
  780. typedef UNALIGNED RDP_FILE_DIRECTORY_INFORMATION * PRDP_FILE_DIRECTORY_INFORMATION;
  781. typedef struct _RDP_FILE_FULL_DIR_INFORMATION {
  782. ULONG NextEntryOffset;
  783. ULONG FileIndex;
  784. LARGE_INTEGER CreationTime;
  785. LARGE_INTEGER LastAccessTime;
  786. LARGE_INTEGER LastWriteTime;
  787. LARGE_INTEGER ChangeTime;
  788. LARGE_INTEGER EndOfFile;
  789. LARGE_INTEGER AllocationSize;
  790. ULONG FileAttributes;
  791. ULONG FileNameLength;
  792. ULONG EaSize;
  793. WCHAR FileName[1];
  794. } RDP_FILE_FULL_DIR_INFORMATION;
  795. typedef UNALIGNED RDP_FILE_FULL_DIR_INFORMATION *PRDP_FILE_FULL_DIR_INFORMATION;
  796. typedef struct _RDP_FILE_BOTH_DIR_INFORMATION {
  797. ULONG NextEntryOffset;
  798. ULONG FileIndex;
  799. LARGE_INTEGER CreationTime;
  800. LARGE_INTEGER LastAccessTime;
  801. LARGE_INTEGER LastWriteTime;
  802. LARGE_INTEGER ChangeTime;
  803. LARGE_INTEGER EndOfFile;
  804. LARGE_INTEGER AllocationSize;
  805. ULONG FileAttributes;
  806. ULONG FileNameLength;
  807. ULONG EaSize;
  808. CHAR ShortNameLength;
  809. WCHAR ShortName[12];
  810. WCHAR FileName[1];
  811. } RDP_FILE_BOTH_DIR_INFORMATION;
  812. typedef UNALIGNED RDP_FILE_BOTH_DIR_INFORMATION *PRDP_FILE_BOTH_DIR_INFORMATION;
  813. typedef struct _RDP_FILE_NAMES_INFORMATION {
  814. ULONG NextEntryOffset;
  815. ULONG FileIndex;
  816. ULONG FileNameLength;
  817. WCHAR FileName[1];
  818. } RDP_FILE_NAMES_INFORMATION;
  819. typedef UNALIGNED RDP_FILE_NAMES_INFORMATION * PRDP_FILE_NAMES_INFORMATION;
  820. typedef struct _RDP_FILE_END_OF_FILE_INFORMATION {
  821. LARGE_INTEGER EndOfFile;
  822. } RDP_FILE_END_OF_FILE_INFORMATION;
  823. typedef UNALIGNED RDP_FILE_END_OF_FILE_INFORMATION * PRDP_FILE_END_OF_FILE_INFORMATION;
  824. //
  825. // File I/O Operation
  826. // This is defined in mrx.h
  827. //
  828. typedef enum _RDP_LOWIO_OPS {
  829. RDP_LOWIO_OP_READ=0,
  830. RDP_LOWIO_OP_WRITE,
  831. RDP_LOWIO_OP_SHAREDLOCK,
  832. RDP_LOWIO_OP_EXCLUSIVELOCK,
  833. RDP_LOWIO_OP_UNLOCK,
  834. RDP_LOWIO_OP_UNLOCK_MULTIPLE,
  835. //LOWIO_OP_UNLOCKALLBYKEY,
  836. RDP_LOWIO_OP_FSCTL,
  837. RDP_LOWIO_OP_IOCTL,
  838. RDP_LOWIO_OP_NOTIFY_CHANGE_DIRECTORY,
  839. RDP_LOWIO_OP_CLEAROUT,
  840. RDP_LOWIO_OP_MAXIMUM
  841. } RDP_LOWIO_OPS;
  842. //
  843. // File locking information
  844. //
  845. typedef struct _RDP_LOCK_INFO {
  846. LONG LengthLow; // Number of bytes to lock
  847. LONG LengthHigh;
  848. LONG OffsetLow;
  849. LONG OffsetHigh; // Byte offset where lock starts
  850. } RDP_LOCK_INFO;
  851. typedef UNALIGNED RDP_LOCK_INFO *PRDP_LOCK_INFO;
  852. //
  853. // Lock flags
  854. //
  855. #define SL_FAIL_IMMEDIATELY 0x01
  856. #define SL_EXCLUSIVE_LOCK 0x02
  857. typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
  858. //
  859. // RDPDR_DEVICE_IOREQUEST
  860. //
  861. // Sent by the server to get an IO Request processed on a device
  862. //
  863. // IRP_MJ_CREATE
  864. // IRP_MJ_CLEANUP
  865. // IRP_MJ_CLOSE
  866. // IRP_MJ_READ
  867. // IRP_MJ_WRITE
  868. // IRP_MJ_FLUSH_BUFFERS
  869. // IRP_MJ_SHUTDOWN
  870. // IRP_MJ_DEVICE_CONTROL
  871. // IRP_MJ_INTERNAL_DEVICE_CONTROL
  872. //
  873. // The specific IOCTLs for serial DEVICE_CONTROL calls are:
  874. //
  875. // <split these in to sent and handled locally?>
  876. // IOCTL_SERIAL_SET_BAUD_RATE
  877. // IOCTL_SERIAL_GET_BAUD_RATE
  878. // IOCTL_SERIAL_SET_LINE_CONTROL
  879. // IOCTL_SERIAL_GET_LINE_CONTROL
  880. // IOCTL_SERIAL_SET_TIMEOUTS
  881. // IOCTL_SERIAL_GET_TIMEOUTS
  882. // IOCTL_SERIAL_SET_CHARS
  883. // IOCTL_SERIAL_GET_CHARS
  884. // IOCTL_SERIAL_SET_DTR
  885. // IOCTL_SERIAL_CLR_DTR
  886. // IOCTL_SERIAL_RESET_DEVICE
  887. // IOCTL_SERIAL_SET_RTS
  888. // IOCTL_SERIAL_CLR_RTS
  889. // IOCTL_SERIAL_SET_XOFF
  890. // IOCTL_SERIAL_SET_XON
  891. // IOCTL_SERIAL_SET_BREAK_ON
  892. // IOCTL_SERIAL_SET_BREAK_OFF
  893. // IOCTL_SERIAL_SET_QUEUE_SIZE
  894. // IOCTL_SERIAL_GET_WAIT_MASK
  895. // IOCTL_SERIAL_SET_WAIT_MASK
  896. // IOCTL_SERIAL_WAIT_ON_MASK
  897. // IOCTL_SERIAL_IMMEDIATE_CHAR
  898. // IOCTL_SERIAL_PURGE
  899. // IOCTL_SERIAL_GET_HANDFLOW
  900. // IOCTL_SERIAL_SET_HANDFLOW
  901. // IOCTL_SERIAL_GET_MODEMSTATUS
  902. // IOCTL_SERIAL_GET_DTRRTS
  903. // IOCTL_SERIAL_GET_COMMSTATUS
  904. // IOCTL_SERIAL_GET_PROPERTIES
  905. // IOCTL_SERIAL_XOFF_COUNTER
  906. // IOCTL_SERIAL_LSRMST_INSERT
  907. // IOCTL_SERIAL_CONFIG_SIZE
  908. // IOCTL_SERIAL_GET_STATS
  909. // IOCTL_SERIAL_CLEAR_STATS
  910. //
  911. // The specific IOCTLs for parallel DEVICE_CONTROL calls are:
  912. //
  913. // For IRP_MJ_DEVICE_CONTROL:
  914. // IOCTL_PAR_QUERY_INFORMATION
  915. // IOCTL_PAR_SET_INFORMATION
  916. // IOCTL_PAR_QUERY_DEVICE_ID
  917. // IOCTL_PAR_QUERY_DEVICE_ID_SIZE
  918. // IOCTL_SERIAL_GET_TIMEOUTS
  919. // IOCTL_SERIAL_SET_TIMEOUTS
  920. //
  921. // For IRP_MJ_INTERNAL_DEVICE_CONTROL:
  922. // IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO
  923. // IOCTL_INTERNAL_PARALLEL_PORT_ALLOCATE
  924. // IOCTL_INTERNAL_PARALLEL_CONNECT_INTERRUPT
  925. // IOCTL_INTERNAL_PARALLEL_DISCONNECT_INTERRUPT
  926. //
  927. //
  928. typedef struct tagRDPDR_DEVICE_IOREQUEST
  929. {
  930. ULONG DeviceId; // Id used in DeviceAnnounce
  931. ULONG FileId; // Id for file on the device
  932. ULONG CompletionId; // Id to return completion status
  933. ULONG MajorFunction; // The IRP_MJ_XXX request
  934. ULONG MinorFunction; // The subfunction of above, usually for SCSI
  935. //
  936. // The following Parameters depend on the IRP_MJ_XXX that is set
  937. // in MajorFunction.
  938. //
  939. union {
  940. // IRP_MJ_CREATE
  941. struct {
  942. ACCESS_MASK DesiredAccess;
  943. LARGE_INTEGER AllocationSize;
  944. ULONG FileAttributes;
  945. ULONG ShareAccess;
  946. ULONG Disposition;
  947. ULONG CreateOptions;
  948. ULONG PathLength;
  949. // PathLength Bytes follow
  950. } Create;
  951. // IRP_MJ_CLEANUP
  952. // Sent, no structure
  953. // IRP_MJ_CLOSE
  954. // Sent, no structure
  955. // IRP_MJ_READ
  956. struct {
  957. ULONG Length; // Number of UCHARs to read
  958. LONG OffsetLow; // Byte offset where read starts
  959. LONG OffsetHigh; // offset is defined from the beginning of the file
  960. // Length Bytes follow
  961. } Read;
  962. // IRP_MJ_WRITE
  963. struct {
  964. ULONG Length; // Number of UCHARs to write
  965. LONG OffsetLow; // Byte offset where write starts
  966. LONG OffsetHigh; // offset is defined from the beginning of the file
  967. // Length Bytes follow
  968. } Write;
  969. // IRP_MJ_FLUSH_BUFFERS
  970. // Sent, no structure
  971. // IRP_MJ_SHUTDOWN
  972. // Not sent, no structure
  973. // IRP_MJ_DEVICE_CONTROL, IRP_MJ_INTERNAL_DEVICE_CONTROL
  974. // IRP_MJ_FILE_SYSTEM_CONTROL is collapsed into device control
  975. // on the client side
  976. struct {
  977. ULONG OutputBufferLength;
  978. ULONG InputBufferLength;
  979. ULONG IoControlCode; // IOCTL_XXX
  980. // InputBufferLength Bytes follow
  981. } DeviceIoControl;
  982. // IRP_MJ_QUERY_VOLUME_INFORMATION
  983. struct {
  984. RDP_FS_INFORMATION_CLASS FsInformationClass;
  985. ULONG Length; // length of query buffer
  986. } QueryVolume;
  987. // IRP_MJ_SET_VOLUME_INFORMATION
  988. struct {
  989. RDP_FS_INFORMATION_CLASS FsInformationClass;
  990. ULONG Length;
  991. //Length Bytes follow
  992. } SetVolume;
  993. // IRP_MJ_QUERY_INFORMATION
  994. struct {
  995. RDP_FILE_INFORMATION_CLASS FileInformationClass;
  996. ULONG Length; // length of query buffer
  997. } QueryFile;
  998. // IRP_MJ_SET_INFORMATION
  999. struct {
  1000. RDP_FILE_INFORMATION_CLASS FileInformationClass;
  1001. ULONG Length;
  1002. //Length Bytes follow
  1003. } SetFile;
  1004. // IRP_MJ_QUERY_SECURITY
  1005. struct {
  1006. SECURITY_INFORMATION SecurityInformation;
  1007. ULONG Length; // length of query buffer
  1008. } QuerySd;
  1009. // IRP_MJ_SET_SECURITY
  1010. struct {
  1011. SECURITY_INFORMATION SecurityInformation;
  1012. ULONG Length;
  1013. } SetSd;
  1014. // IRP_MJ_DIRECTORY_CONTROL
  1015. struct {
  1016. RDP_FILE_INFORMATION_CLASS FileInformationClass;
  1017. BOOLEAN InitialQuery;
  1018. ULONG PathLength;
  1019. ULONG Length; // length of query buffer
  1020. // PathLength Bytes follow
  1021. } QueryDir;
  1022. // IRP_MJ_DIRECTORY_CONTROL
  1023. struct {
  1024. BOOLEAN WatchTree;
  1025. ULONG CompletionFilter;
  1026. ULONG Length;
  1027. } NotifyChangeDir;
  1028. // IRP_MJ_LOCK_CONTROL
  1029. struct {
  1030. ULONG Operation;
  1031. ULONG Flags;
  1032. ULONG NumLocks;
  1033. // LockInfo List follow
  1034. } Locks;
  1035. } Parameters;
  1036. } RDPDR_DEVICE_IOREQUEST, *PRDPDR_DEVICE_IOREQUEST;
  1037. typedef struct tagRDPDR_IOREQUEST_PACKET
  1038. {
  1039. RDPDR_HEADER Header;
  1040. RDPDR_DEVICE_IOREQUEST IoRequest;
  1041. } RDPDR_IOREQUEST_PACKET, *PRDPDR_IOREQUEST_PACKET;
  1042. //
  1043. // RDPDR_DEVICE_IOCOMPLETION
  1044. //
  1045. // Sent by the client to indicate an I/O operation has completed
  1046. //
  1047. typedef struct tagRDPDR_DEVICE_IOCOMPLETION
  1048. {
  1049. ULONG DeviceId; // Given a CompletionId, is this necessary?
  1050. ULONG CompletionId; // Completion Id supplied by the request
  1051. ULONG IoStatus; // Status code
  1052. //
  1053. // The following Parameters depend on the IRP_MJ_XXX that was set
  1054. // in the MajorFunction element of the original request.
  1055. //
  1056. union {
  1057. // IRP_MJ_CREATE
  1058. struct {
  1059. ULONG FileId; // File to refer to in future IO operations
  1060. UCHAR Information; // Create/Open return information
  1061. } Create;
  1062. // Sent, no structure
  1063. // IRP_MJ_CLEANUP
  1064. // Sent, no structure
  1065. // IRP_MJ_CLOSE
  1066. // Sent, no structure
  1067. // IRP_MJ_READ
  1068. struct {
  1069. ULONG Length; // Number of UCHARs that were read
  1070. UCHAR Buffer[1]; // UCHARs that were read
  1071. } Read;
  1072. // IRP_MJ_WRITE
  1073. struct {
  1074. ULONG Length; // Number of UCHARs that were written
  1075. } Write;
  1076. // IRP_MJ_FLUSH_BUFFERS
  1077. // Sent, no structure
  1078. // IRP_MJ_SHUTDOWN
  1079. // Not sent, no structure
  1080. // IRP_MJ_DEVICE_CONTROL, IRP_MJ_INTERNAL_DEVICE_CONTROL
  1081. // IRP_MJ_FILE_SYSTEM_CONTROL is collapsed into device control
  1082. // on the client side
  1083. struct {
  1084. ULONG OutputBufferLength;
  1085. UCHAR OutputBuffer[1]; // Depends on IOCTL_XXX
  1086. } DeviceIoControl;
  1087. // IRP_MJ_QUERY_VOLUME_INFORMATION
  1088. struct {
  1089. ULONG Length;
  1090. UCHAR Buffer[1];
  1091. } QueryVolume;
  1092. // IRP_MJ_SET_VOLUME_INFORMATION
  1093. struct {
  1094. ULONG Length;
  1095. } SetVolume;
  1096. // IRP_MJ_QUERY_INFORMATION
  1097. struct {
  1098. ULONG Length;
  1099. UCHAR Buffer[1];
  1100. } QueryFile;
  1101. // IRP_MJ_SET_INFORMATION
  1102. struct {
  1103. ULONG Length;
  1104. } SetFile;
  1105. // IRP_MJ_DIRECTORY_CONTROL
  1106. struct {
  1107. ULONG Length;
  1108. UCHAR Buffer[1];
  1109. } QueryDir;
  1110. // IRP_MJ_QUERY_SECURITY
  1111. struct {
  1112. ULONG Length;
  1113. UCHAR Buffer[1];
  1114. } QuerySd;
  1115. // IRP_MJ_SET_SECURITY
  1116. struct {
  1117. ULONG Length;
  1118. } SetSd;
  1119. // IRP_MJ_LOCK_CONTROL
  1120. // Sent, no structure
  1121. } Parameters;
  1122. } RDPDR_DEVICE_IOCOMPLETION, *PRDPDR_DEVICE_IOCOMPLETION;
  1123. typedef struct tagRDPDR_IOCOMPLETION_PACKET
  1124. {
  1125. RDPDR_HEADER Header;
  1126. RDPDR_DEVICE_IOCOMPLETION IoCompletion;
  1127. } RDPDR_IOCOMPLETION_PACKET, *PRDPDR_IOCOMPLETION_PACKET;
  1128. //
  1129. // RDPDRDVMGR Event Header
  1130. //
  1131. // This header prefixes all device management events.
  1132. //
  1133. typedef struct tagRDPDRDVMGR_EVENTHEADER
  1134. {
  1135. ULONG EventType; // Event-Type Field
  1136. ULONG EventLength; // Event-Length Field
  1137. } RDPDRDVMGR_EVENTHEADER, *PRDPDRDVMGR_EVENTHEADER;
  1138. //
  1139. // Buffer Too-Small Event
  1140. //
  1141. typedef struct tagRDPDR_BUFFERTOOSMALL
  1142. {
  1143. ULONG RequiredSize; // Required Size for Request to Succeed.
  1144. } RDPDR_BUFFERTOOSMALL, *PRDPDR_BUFFERTOOSMALL;
  1145. //
  1146. // This information is sent to the server from the client.
  1147. //
  1148. // It contains information about a client-attached printing device and
  1149. // is included with the RDPDR_DEVICE_ANNOUNCE struct ... following the
  1150. // rest of the RDPDR_DEVICE_ANNOUNCE struct fields.
  1151. //
  1152. typedef struct tagRDPDR_PRINTERDEVICE_ANNOUNCE
  1153. {
  1154. ULONG Flags; // Contain the flag bits defined below
  1155. //
  1156. ULONG CodePage; // Ansi code page to use to convert the
  1157. // ansi string to unicode.
  1158. ULONG PnPNameLen; // Length (in bytes) of PnP wide-character name
  1159. // that was discovered by the client.
  1160. ULONG DriverLen; // Length (in bytes) of driver wide-character
  1161. // name that was discovered by the client.
  1162. ULONG PrinterNameLen; // Length (in bytes) of printer wide-character
  1163. // name that was discovered by the client.
  1164. ULONG CachedFieldsLen; // This is simply printer-associated binary
  1165. // data that is stashed away on the client
  1166. // machine for the server. Note that this
  1167. // data is specific to the server that
  1168. // cached the data.
  1169. // The actual fields corresponding to the above field lengths follow this
  1170. // struct in the order that the field lengths appear in this typedef.
  1171. } RDPDR_PRINTERDEVICE_ANNOUNCE, *PRDPDR_PRINTERDEVICE_ANNOUNCE;
  1172. // RDPDR_PRINTERDEVICE_ANNOUNCE structure contains ansi strings
  1173. #define RDPDR_PRINTER_ANNOUNCE_FLAG_ANSI 0x1
  1174. // The printer being announced is the default printer on the client.
  1175. #define RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER 0x2
  1176. // The printer being announced is a network printer
  1177. #define RDPDR_PRINTER_ANNOUNCE_FLAG_NETWORKPRINTER 0x4
  1178. // The printer being announced is a TS redirected printer
  1179. // It means that the printer name has been rebuilt by the client
  1180. // and the name is based on the original server/client/printer names
  1181. // (the printer is going to be nested or is nested at the nth level).
  1182. #define RDPDR_PRINTER_ANNOUNCE_FLAG_TSPRINTER 0x8
  1183. #define DEVICERDR_PRINT_SERVER_NAME TEXT("PrintServerName")
  1184. #define DEVICERDR_CLIENT_NAME TEXT("ClientName")
  1185. #define DEVICERDR_PRINTER_NAME TEXT("PrinterName")
  1186. //
  1187. // cache data printer events.
  1188. //
  1189. #define RDPDR_ADD_PRINTER_EVENT 0x1
  1190. #define RDPDR_UPDATE_PRINTER_EVENT 0x2
  1191. #define RDPDR_DELETE_PRINTER_EVENT 0x3
  1192. #define RDPDR_RENAME_PRINTER_EVENT 0x4
  1193. typedef struct tagRDPDR_PRINTER_CACHEDATA_PACKET
  1194. {
  1195. RDPDR_HEADER Header;
  1196. ULONG EventId;
  1197. //
  1198. // data structure that corresponds to the EventID will follow.
  1199. // Ex: for AddPrinter Event RDPDR_PRINTER_ADD_CACHEDATA will follow.
  1200. //
  1201. } RDPDR_PRINTER_CACHEDATA_PACKET, *PRDPDR_PRINTER_CACHEDATA_PACKET;
  1202. //
  1203. // RDPDR_PRINTER_ADD_CACHEDATA
  1204. //
  1205. // This structure is sent to the client from the server, when a new printer
  1206. // queue is manually added to the user session.
  1207. //
  1208. //
  1209. typedef struct tagRDPDR_PRINTER_ADD_CACHEDATA
  1210. {
  1211. UCHAR PortDosName[PREFERRED_DOS_NAME_SIZE];
  1212. // port name in ANSI format.
  1213. ULONG PnPNameLen; // Length (in bytes) of PnP wide-character name
  1214. // that was discovered by the client.
  1215. ULONG DriverLen; // Length (in bytes) of driver wide-character
  1216. // name that was discovered by the client.
  1217. ULONG PrinterNameLen; // Length (in bytes) of printer wide-character
  1218. // name that was discovered by the client.
  1219. ULONG CachedFieldsLen; // This is simply printer-associated binary
  1220. // data that is stashed away on the client
  1221. // machine for the server. Note that this
  1222. // data is specific to the server that
  1223. // cached the data.
  1224. // variable length data will follow.
  1225. } RDPDR_PRINTER_ADD_CACHEDATA, *PRDPDR_PRINTER_ADD_CACHEDATA;
  1226. //
  1227. // RDPDR_PRINTER_DELETE_CACHEDATA
  1228. //
  1229. // This structure is sent to the client from the server, when a printer
  1230. // queue is manually deleted from the user session.
  1231. //
  1232. //
  1233. typedef struct tagRDPDR_PRINTER_DELETE_CACHEDATA
  1234. {
  1235. ULONG PrinterNameLen; // Length (in bytes) of printer wide-character
  1236. // name.
  1237. // string data will follow.
  1238. } RDPDR_PRINTER_DELETE_CACHEDATA, *PRDPDR_PRINTER_DELETE_CACHEDATA;
  1239. //
  1240. // RDPDR_PRINTER_RENAME_CACHEDATA
  1241. //
  1242. // This structure is sent to the client from the server, when a printer
  1243. // queue is manually renamed from the user session.
  1244. //
  1245. //
  1246. typedef struct tagRDPDR_PRINTER_RENAME_CACHEDATA
  1247. {
  1248. ULONG OldPrinterNameLen; // Length (in bytes) of printer
  1249. // wide-character name.
  1250. ULONG NewPrinterNameLen; // Length (in bytes) of printer
  1251. // wide-character name.
  1252. // string data will follow.
  1253. } RDPDR_PRINTER_RENAME_CACHEDATA, *PRDPDR_PRINTER_RENAME_CACHEDATA;
  1254. //
  1255. // RDPDR_PRINTER_UPDATE_CACHEDATA
  1256. //
  1257. // This structure is sent to the client from the server, when the printer
  1258. // configuration is modified.
  1259. //
  1260. //
  1261. typedef struct tagRDPDR_PRINTER_UPDATE_CACHEDATA
  1262. {
  1263. ULONG PrinterNameLen; // Length (in bytes) of printer wide-character
  1264. // name.
  1265. ULONG ConfigDataLen; // Length of the cache data that will
  1266. // follow the printer name.
  1267. // string data will follow.
  1268. } RDPDR_PRINTER_UPDATE_CACHEDATA, *PRDPDR_PRINTER_UPDATE_CACHEDATA;
  1269. //
  1270. // Printer device "subclass" of RDPDR_DEVICE_ANNOUNCE.
  1271. // This message is sent from the kernel-mode "dr" to the user-mode
  1272. // "dr" so the user-mode "dr" can install a printer.
  1273. //
  1274. typedef struct tagRDPDR_PRINTERDEVICE_SUB
  1275. {
  1276. WCHAR portName[RDPDR_MAXPORTNAMELEN];
  1277. WCHAR clientName[RDPDR_MAX_COMPUTER_NAME_LENGTH];
  1278. RDPDR_DEVICE_ANNOUNCE deviceFields;
  1279. RDPDR_PRINTERDEVICE_ANNOUNCE clientPrinterFields;
  1280. } RDPDR_PRINTERDEVICE_SUB, *PRDPDR_PRINTERDEVICE_SUB;
  1281. //
  1282. // Drive device "subclass" of RDPDR_DEVICE_ANNOUNCE.
  1283. // This message is sent from the kernel-mode "dr" to the user-mode
  1284. // "dr" so the user-mode "dr" can create a UNC connection.
  1285. //
  1286. typedef struct tagRDPDR_DRIVEDEVICE_SUB
  1287. {
  1288. WCHAR driveName[RDPDR_MAXPORTNAMELEN];
  1289. WCHAR clientName[RDPDR_MAX_COMPUTER_NAME_LENGTH];
  1290. RDPDR_DEVICE_ANNOUNCE deviceFields;
  1291. WCHAR clientDisplayName[RDPDR_MAX_CLIENT_DISPLAY_NAME];
  1292. } RDPDR_DRIVEDEVICE_SUB, *PRDPDR_DRIVEDEVICE_SUB;
  1293. //
  1294. // Indicate to the user-mode component that a device has been removed.
  1295. //
  1296. typedef struct tagRDPDR_REMOVEDEVICE
  1297. {
  1298. ULONG deviceID;
  1299. } RDPDR_REMOVEDEVICE, *PRDPDR_REMOVEDEVICE;
  1300. //
  1301. // Port device "subclass" of RDPDR_DEVICE_ANNOUNCE. This message is
  1302. // sent from the kernel-mode "dr" to the user-mode "dr" so the user-mode
  1303. // "dr" can install a port.
  1304. //
  1305. typedef struct tagRDPDR_PORTDEVICE_SUB
  1306. {
  1307. WCHAR portName[RDPDR_MAXPORTNAMELEN];
  1308. WCHAR devicePath[RDPDRMAXNTDEVICENAMEGLEN];
  1309. RDPDR_DEVICE_ANNOUNCE deviceFields;
  1310. } RDPDR_PORTDEVICE_SUB, *PRDPDR_PORTDEVICE_SUB;
  1311. //
  1312. // Restore packing style (previous for 32-bit, default for 16-bit).
  1313. //
  1314. #ifdef OS_WIN16
  1315. #pragma pack ()
  1316. #else
  1317. #pragma pack (pop, drpack)
  1318. #endif
  1319. #ifdef __cplusplus
  1320. }
  1321. #endif // __cplusplus
  1322. #endif // RDPDR