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.

1539 lines
52 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. typedef struct _RDP_FILE_ALLOCATION_INFORMATION {
  825. LARGE_INTEGER AllocationSize;
  826. } RDP_FILE_ALLOCATION_INFORMATION;
  827. typedef UNALIGNED RDP_FILE_ALLOCATION_INFORMATION * PRDP_FILE_ALLOCATION_INFORMATION;
  828. //
  829. // File I/O Operation
  830. // This is defined in mrx.h
  831. //
  832. typedef enum _RDP_LOWIO_OPS {
  833. RDP_LOWIO_OP_READ=0,
  834. RDP_LOWIO_OP_WRITE,
  835. RDP_LOWIO_OP_SHAREDLOCK,
  836. RDP_LOWIO_OP_EXCLUSIVELOCK,
  837. RDP_LOWIO_OP_UNLOCK,
  838. RDP_LOWIO_OP_UNLOCK_MULTIPLE,
  839. //LOWIO_OP_UNLOCKALLBYKEY,
  840. RDP_LOWIO_OP_FSCTL,
  841. RDP_LOWIO_OP_IOCTL,
  842. RDP_LOWIO_OP_NOTIFY_CHANGE_DIRECTORY,
  843. RDP_LOWIO_OP_CLEAROUT,
  844. RDP_LOWIO_OP_MAXIMUM
  845. } RDP_LOWIO_OPS;
  846. //
  847. // File locking information
  848. //
  849. typedef struct _RDP_LOCK_INFO {
  850. LONG LengthLow; // Number of bytes to lock
  851. LONG LengthHigh;
  852. LONG OffsetLow;
  853. LONG OffsetHigh; // Byte offset where lock starts
  854. } RDP_LOCK_INFO;
  855. typedef UNALIGNED RDP_LOCK_INFO *PRDP_LOCK_INFO;
  856. //
  857. // Lock flags
  858. //
  859. #define SL_FAIL_IMMEDIATELY 0x01
  860. #define SL_EXCLUSIVE_LOCK 0x02
  861. typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
  862. //
  863. // RDPDR_DEVICE_IOREQUEST
  864. //
  865. // Sent by the server to get an IO Request processed on a device
  866. //
  867. // IRP_MJ_CREATE
  868. // IRP_MJ_CLEANUP
  869. // IRP_MJ_CLOSE
  870. // IRP_MJ_READ
  871. // IRP_MJ_WRITE
  872. // IRP_MJ_FLUSH_BUFFERS
  873. // IRP_MJ_SHUTDOWN
  874. // IRP_MJ_DEVICE_CONTROL
  875. // IRP_MJ_INTERNAL_DEVICE_CONTROL
  876. //
  877. // The specific IOCTLs for serial DEVICE_CONTROL calls are:
  878. //
  879. // <split these in to sent and handled locally?>
  880. // IOCTL_SERIAL_SET_BAUD_RATE
  881. // IOCTL_SERIAL_GET_BAUD_RATE
  882. // IOCTL_SERIAL_SET_LINE_CONTROL
  883. // IOCTL_SERIAL_GET_LINE_CONTROL
  884. // IOCTL_SERIAL_SET_TIMEOUTS
  885. // IOCTL_SERIAL_GET_TIMEOUTS
  886. // IOCTL_SERIAL_SET_CHARS
  887. // IOCTL_SERIAL_GET_CHARS
  888. // IOCTL_SERIAL_SET_DTR
  889. // IOCTL_SERIAL_CLR_DTR
  890. // IOCTL_SERIAL_RESET_DEVICE
  891. // IOCTL_SERIAL_SET_RTS
  892. // IOCTL_SERIAL_CLR_RTS
  893. // IOCTL_SERIAL_SET_XOFF
  894. // IOCTL_SERIAL_SET_XON
  895. // IOCTL_SERIAL_SET_BREAK_ON
  896. // IOCTL_SERIAL_SET_BREAK_OFF
  897. // IOCTL_SERIAL_SET_QUEUE_SIZE
  898. // IOCTL_SERIAL_GET_WAIT_MASK
  899. // IOCTL_SERIAL_SET_WAIT_MASK
  900. // IOCTL_SERIAL_WAIT_ON_MASK
  901. // IOCTL_SERIAL_IMMEDIATE_CHAR
  902. // IOCTL_SERIAL_PURGE
  903. // IOCTL_SERIAL_GET_HANDFLOW
  904. // IOCTL_SERIAL_SET_HANDFLOW
  905. // IOCTL_SERIAL_GET_MODEMSTATUS
  906. // IOCTL_SERIAL_GET_DTRRTS
  907. // IOCTL_SERIAL_GET_COMMSTATUS
  908. // IOCTL_SERIAL_GET_PROPERTIES
  909. // IOCTL_SERIAL_XOFF_COUNTER
  910. // IOCTL_SERIAL_LSRMST_INSERT
  911. // IOCTL_SERIAL_CONFIG_SIZE
  912. // IOCTL_SERIAL_GET_STATS
  913. // IOCTL_SERIAL_CLEAR_STATS
  914. //
  915. // The specific IOCTLs for parallel DEVICE_CONTROL calls are:
  916. //
  917. // For IRP_MJ_DEVICE_CONTROL:
  918. // IOCTL_PAR_QUERY_INFORMATION
  919. // IOCTL_PAR_SET_INFORMATION
  920. // IOCTL_PAR_QUERY_DEVICE_ID
  921. // IOCTL_PAR_QUERY_DEVICE_ID_SIZE
  922. // IOCTL_SERIAL_GET_TIMEOUTS
  923. // IOCTL_SERIAL_SET_TIMEOUTS
  924. //
  925. // For IRP_MJ_INTERNAL_DEVICE_CONTROL:
  926. // IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO
  927. // IOCTL_INTERNAL_PARALLEL_PORT_ALLOCATE
  928. // IOCTL_INTERNAL_PARALLEL_CONNECT_INTERRUPT
  929. // IOCTL_INTERNAL_PARALLEL_DISCONNECT_INTERRUPT
  930. //
  931. //
  932. typedef struct tagRDPDR_DEVICE_IOREQUEST
  933. {
  934. ULONG DeviceId; // Id used in DeviceAnnounce
  935. ULONG FileId; // Id for file on the device
  936. ULONG CompletionId; // Id to return completion status
  937. ULONG MajorFunction; // The IRP_MJ_XXX request
  938. ULONG MinorFunction; // The subfunction of above, usually for SCSI
  939. //
  940. // The following Parameters depend on the IRP_MJ_XXX that is set
  941. // in MajorFunction.
  942. //
  943. union {
  944. // IRP_MJ_CREATE
  945. struct {
  946. ACCESS_MASK DesiredAccess;
  947. LARGE_INTEGER AllocationSize;
  948. ULONG FileAttributes;
  949. ULONG ShareAccess;
  950. ULONG Disposition;
  951. ULONG CreateOptions;
  952. ULONG PathLength;
  953. // PathLength Bytes follow
  954. } Create;
  955. // IRP_MJ_CLEANUP
  956. // Sent, no structure
  957. // IRP_MJ_CLOSE
  958. // Sent, no structure
  959. // IRP_MJ_READ
  960. struct {
  961. ULONG Length; // Number of UCHARs to read
  962. LONG OffsetLow; // Byte offset where read starts
  963. LONG OffsetHigh; // offset is defined from the beginning of the file
  964. // Length Bytes follow
  965. } Read;
  966. // IRP_MJ_WRITE
  967. struct {
  968. ULONG Length; // Number of UCHARs to write
  969. LONG OffsetLow; // Byte offset where write starts
  970. LONG OffsetHigh; // offset is defined from the beginning of the file
  971. // Length Bytes follow
  972. } Write;
  973. // IRP_MJ_FLUSH_BUFFERS
  974. // Sent, no structure
  975. // IRP_MJ_SHUTDOWN
  976. // Not sent, no structure
  977. // IRP_MJ_DEVICE_CONTROL, IRP_MJ_INTERNAL_DEVICE_CONTROL
  978. // IRP_MJ_FILE_SYSTEM_CONTROL is collapsed into device control
  979. // on the client side
  980. struct {
  981. ULONG OutputBufferLength;
  982. ULONG InputBufferLength;
  983. ULONG IoControlCode; // IOCTL_XXX
  984. // InputBufferLength Bytes follow
  985. } DeviceIoControl;
  986. // IRP_MJ_QUERY_VOLUME_INFORMATION
  987. struct {
  988. RDP_FS_INFORMATION_CLASS FsInformationClass;
  989. ULONG Length; // length of query buffer
  990. } QueryVolume;
  991. // IRP_MJ_SET_VOLUME_INFORMATION
  992. struct {
  993. RDP_FS_INFORMATION_CLASS FsInformationClass;
  994. ULONG Length;
  995. //Length Bytes follow
  996. } SetVolume;
  997. // IRP_MJ_QUERY_INFORMATION
  998. struct {
  999. RDP_FILE_INFORMATION_CLASS FileInformationClass;
  1000. ULONG Length; // length of query buffer
  1001. } QueryFile;
  1002. // IRP_MJ_SET_INFORMATION
  1003. struct {
  1004. RDP_FILE_INFORMATION_CLASS FileInformationClass;
  1005. ULONG Length;
  1006. //Length Bytes follow
  1007. } SetFile;
  1008. // IRP_MJ_QUERY_SECURITY
  1009. struct {
  1010. SECURITY_INFORMATION SecurityInformation;
  1011. ULONG Length; // length of query buffer
  1012. } QuerySd;
  1013. // IRP_MJ_SET_SECURITY
  1014. struct {
  1015. SECURITY_INFORMATION SecurityInformation;
  1016. ULONG Length;
  1017. } SetSd;
  1018. // IRP_MJ_DIRECTORY_CONTROL
  1019. struct {
  1020. RDP_FILE_INFORMATION_CLASS FileInformationClass;
  1021. BOOLEAN InitialQuery;
  1022. ULONG PathLength;
  1023. ULONG Length; // length of query buffer
  1024. // PathLength Bytes follow
  1025. } QueryDir;
  1026. // IRP_MJ_DIRECTORY_CONTROL
  1027. struct {
  1028. BOOLEAN WatchTree;
  1029. ULONG CompletionFilter;
  1030. ULONG Length;
  1031. } NotifyChangeDir;
  1032. // IRP_MJ_LOCK_CONTROL
  1033. struct {
  1034. ULONG Operation;
  1035. ULONG Flags;
  1036. ULONG NumLocks;
  1037. // LockInfo List follow
  1038. } Locks;
  1039. } Parameters;
  1040. } RDPDR_DEVICE_IOREQUEST, *PRDPDR_DEVICE_IOREQUEST;
  1041. typedef struct tagRDPDR_IOREQUEST_PACKET
  1042. {
  1043. RDPDR_HEADER Header;
  1044. RDPDR_DEVICE_IOREQUEST IoRequest;
  1045. } RDPDR_IOREQUEST_PACKET, *PRDPDR_IOREQUEST_PACKET;
  1046. //
  1047. // RDPDR_DEVICE_IOCOMPLETION
  1048. //
  1049. // Sent by the client to indicate an I/O operation has completed
  1050. //
  1051. typedef struct tagRDPDR_DEVICE_IOCOMPLETION
  1052. {
  1053. ULONG DeviceId; // Given a CompletionId, is this necessary?
  1054. ULONG CompletionId; // Completion Id supplied by the request
  1055. ULONG IoStatus; // Status code
  1056. //
  1057. // The following Parameters depend on the IRP_MJ_XXX that was set
  1058. // in the MajorFunction element of the original request.
  1059. //
  1060. union {
  1061. // IRP_MJ_CREATE
  1062. struct {
  1063. ULONG FileId; // File to refer to in future IO operations
  1064. UCHAR Information; // Create/Open return information
  1065. } Create;
  1066. // Sent, no structure
  1067. // IRP_MJ_CLEANUP
  1068. // Sent, no structure
  1069. // IRP_MJ_CLOSE
  1070. // Sent, no structure
  1071. // IRP_MJ_READ
  1072. struct {
  1073. ULONG Length; // Number of UCHARs that were read
  1074. UCHAR Buffer[1]; // UCHARs that were read
  1075. } Read;
  1076. // IRP_MJ_WRITE
  1077. struct {
  1078. ULONG Length; // Number of UCHARs that were written
  1079. } Write;
  1080. // IRP_MJ_FLUSH_BUFFERS
  1081. // Sent, no structure
  1082. // IRP_MJ_SHUTDOWN
  1083. // Not sent, no structure
  1084. // IRP_MJ_DEVICE_CONTROL, IRP_MJ_INTERNAL_DEVICE_CONTROL
  1085. // IRP_MJ_FILE_SYSTEM_CONTROL is collapsed into device control
  1086. // on the client side
  1087. struct {
  1088. ULONG OutputBufferLength;
  1089. UCHAR OutputBuffer[1]; // Depends on IOCTL_XXX
  1090. } DeviceIoControl;
  1091. // IRP_MJ_QUERY_VOLUME_INFORMATION
  1092. struct {
  1093. ULONG Length;
  1094. UCHAR Buffer[1];
  1095. } QueryVolume;
  1096. // IRP_MJ_SET_VOLUME_INFORMATION
  1097. struct {
  1098. ULONG Length;
  1099. } SetVolume;
  1100. // IRP_MJ_QUERY_INFORMATION
  1101. struct {
  1102. ULONG Length;
  1103. UCHAR Buffer[1];
  1104. } QueryFile;
  1105. // IRP_MJ_SET_INFORMATION
  1106. struct {
  1107. ULONG Length;
  1108. } SetFile;
  1109. // IRP_MJ_DIRECTORY_CONTROL
  1110. struct {
  1111. ULONG Length;
  1112. UCHAR Buffer[1];
  1113. } QueryDir;
  1114. // IRP_MJ_QUERY_SECURITY
  1115. struct {
  1116. ULONG Length;
  1117. UCHAR Buffer[1];
  1118. } QuerySd;
  1119. // IRP_MJ_SET_SECURITY
  1120. struct {
  1121. ULONG Length;
  1122. } SetSd;
  1123. // IRP_MJ_LOCK_CONTROL
  1124. // Sent, no structure
  1125. } Parameters;
  1126. } RDPDR_DEVICE_IOCOMPLETION, *PRDPDR_DEVICE_IOCOMPLETION;
  1127. typedef struct tagRDPDR_IOCOMPLETION_PACKET
  1128. {
  1129. RDPDR_HEADER Header;
  1130. RDPDR_DEVICE_IOCOMPLETION IoCompletion;
  1131. } RDPDR_IOCOMPLETION_PACKET, *PRDPDR_IOCOMPLETION_PACKET;
  1132. //
  1133. // RDPDRDVMGR Event Header
  1134. //
  1135. // This header prefixes all device management events.
  1136. //
  1137. typedef struct tagRDPDRDVMGR_EVENTHEADER
  1138. {
  1139. ULONG EventType; // Event-Type Field
  1140. ULONG EventLength; // Event-Length Field
  1141. } RDPDRDVMGR_EVENTHEADER, *PRDPDRDVMGR_EVENTHEADER;
  1142. //
  1143. // Buffer Too-Small Event
  1144. //
  1145. typedef struct tagRDPDR_BUFFERTOOSMALL
  1146. {
  1147. ULONG RequiredSize; // Required Size for Request to Succeed.
  1148. } RDPDR_BUFFERTOOSMALL, *PRDPDR_BUFFERTOOSMALL;
  1149. //
  1150. // This information is sent to the server from the client.
  1151. //
  1152. // It contains information about a client-attached printing device and
  1153. // is included with the RDPDR_DEVICE_ANNOUNCE struct ... following the
  1154. // rest of the RDPDR_DEVICE_ANNOUNCE struct fields.
  1155. //
  1156. typedef struct tagRDPDR_PRINTERDEVICE_ANNOUNCE
  1157. {
  1158. ULONG Flags; // Contain the flag bits defined below
  1159. //
  1160. ULONG CodePage; // Ansi code page to use to convert the
  1161. // ansi string to unicode.
  1162. ULONG PnPNameLen; // Length (in bytes) of PnP wide-character name
  1163. // that was discovered by the client.
  1164. ULONG DriverLen; // Length (in bytes) of driver wide-character
  1165. // name that was discovered by the client.
  1166. ULONG PrinterNameLen; // Length (in bytes) of printer wide-character
  1167. // name that was discovered by the client.
  1168. ULONG CachedFieldsLen; // This is simply printer-associated binary
  1169. // data that is stashed away on the client
  1170. // machine for the server. Note that this
  1171. // data is specific to the server that
  1172. // cached the data.
  1173. // The actual fields corresponding to the above field lengths follow this
  1174. // struct in the order that the field lengths appear in this typedef.
  1175. } RDPDR_PRINTERDEVICE_ANNOUNCE, *PRDPDR_PRINTERDEVICE_ANNOUNCE;
  1176. // RDPDR_PRINTERDEVICE_ANNOUNCE structure contains ansi strings
  1177. #define RDPDR_PRINTER_ANNOUNCE_FLAG_ANSI 0x1
  1178. // The printer being announced is the default printer on the client.
  1179. #define RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER 0x2
  1180. // The printer being announced is a network printer
  1181. #define RDPDR_PRINTER_ANNOUNCE_FLAG_NETWORKPRINTER 0x4
  1182. // The printer being announced is a TS redirected printer
  1183. // It means that the printer name has been rebuilt by the client
  1184. // and the name is based on the original server/client/printer names
  1185. // (the printer is going to be nested or is nested at the nth level).
  1186. #define RDPDR_PRINTER_ANNOUNCE_FLAG_TSPRINTER 0x8
  1187. #define DEVICERDR_PRINT_SERVER_NAME TEXT("PrintServerName")
  1188. #define DEVICERDR_CLIENT_NAME TEXT("ClientName")
  1189. #define DEVICERDR_PRINTER_NAME TEXT("PrinterName")
  1190. //
  1191. // cache data printer events.
  1192. //
  1193. #define RDPDR_ADD_PRINTER_EVENT 0x1
  1194. #define RDPDR_UPDATE_PRINTER_EVENT 0x2
  1195. #define RDPDR_DELETE_PRINTER_EVENT 0x3
  1196. #define RDPDR_RENAME_PRINTER_EVENT 0x4
  1197. typedef struct tagRDPDR_PRINTER_CACHEDATA_PACKET
  1198. {
  1199. RDPDR_HEADER Header;
  1200. ULONG EventId;
  1201. //
  1202. // data structure that corresponds to the EventID will follow.
  1203. // Ex: for AddPrinter Event RDPDR_PRINTER_ADD_CACHEDATA will follow.
  1204. //
  1205. } RDPDR_PRINTER_CACHEDATA_PACKET, *PRDPDR_PRINTER_CACHEDATA_PACKET;
  1206. //
  1207. // RDPDR_PRINTER_ADD_CACHEDATA
  1208. //
  1209. // This structure is sent to the client from the server, when a new printer
  1210. // queue is manually added to the user session.
  1211. //
  1212. //
  1213. typedef struct tagRDPDR_PRINTER_ADD_CACHEDATA
  1214. {
  1215. UCHAR PortDosName[PREFERRED_DOS_NAME_SIZE];
  1216. // port name in ANSI format.
  1217. ULONG PnPNameLen; // Length (in bytes) of PnP wide-character name
  1218. // that was discovered by the client.
  1219. ULONG DriverLen; // Length (in bytes) of driver wide-character
  1220. // name that was discovered by the client.
  1221. ULONG PrinterNameLen; // Length (in bytes) of printer wide-character
  1222. // name that was discovered by the client.
  1223. ULONG CachedFieldsLen; // This is simply printer-associated binary
  1224. // data that is stashed away on the client
  1225. // machine for the server. Note that this
  1226. // data is specific to the server that
  1227. // cached the data.
  1228. // variable length data will follow.
  1229. } RDPDR_PRINTER_ADD_CACHEDATA, *PRDPDR_PRINTER_ADD_CACHEDATA;
  1230. //
  1231. // RDPDR_PRINTER_DELETE_CACHEDATA
  1232. //
  1233. // This structure is sent to the client from the server, when a printer
  1234. // queue is manually deleted from the user session.
  1235. //
  1236. //
  1237. typedef struct tagRDPDR_PRINTER_DELETE_CACHEDATA
  1238. {
  1239. ULONG PrinterNameLen; // Length (in bytes) of printer wide-character
  1240. // name.
  1241. // string data will follow.
  1242. } RDPDR_PRINTER_DELETE_CACHEDATA, *PRDPDR_PRINTER_DELETE_CACHEDATA;
  1243. //
  1244. // RDPDR_PRINTER_RENAME_CACHEDATA
  1245. //
  1246. // This structure is sent to the client from the server, when a printer
  1247. // queue is manually renamed from the user session.
  1248. //
  1249. //
  1250. typedef struct tagRDPDR_PRINTER_RENAME_CACHEDATA
  1251. {
  1252. ULONG OldPrinterNameLen; // Length (in bytes) of printer
  1253. // wide-character name.
  1254. ULONG NewPrinterNameLen; // Length (in bytes) of printer
  1255. // wide-character name.
  1256. // string data will follow.
  1257. } RDPDR_PRINTER_RENAME_CACHEDATA, *PRDPDR_PRINTER_RENAME_CACHEDATA;
  1258. //
  1259. // RDPDR_PRINTER_UPDATE_CACHEDATA
  1260. //
  1261. // This structure is sent to the client from the server, when the printer
  1262. // configuration is modified.
  1263. //
  1264. //
  1265. typedef struct tagRDPDR_PRINTER_UPDATE_CACHEDATA
  1266. {
  1267. ULONG PrinterNameLen; // Length (in bytes) of printer wide-character
  1268. // name.
  1269. ULONG ConfigDataLen; // Length of the cache data that will
  1270. // follow the printer name.
  1271. // string data will follow.
  1272. } RDPDR_PRINTER_UPDATE_CACHEDATA, *PRDPDR_PRINTER_UPDATE_CACHEDATA;
  1273. //
  1274. // Printer device "subclass" of RDPDR_DEVICE_ANNOUNCE.
  1275. // This message is sent from the kernel-mode "dr" to the user-mode
  1276. // "dr" so the user-mode "dr" can install a printer.
  1277. //
  1278. typedef struct tagRDPDR_PRINTERDEVICE_SUB
  1279. {
  1280. WCHAR portName[RDPDR_MAXPORTNAMELEN];
  1281. WCHAR clientName[RDPDR_MAX_COMPUTER_NAME_LENGTH];
  1282. RDPDR_DEVICE_ANNOUNCE deviceFields;
  1283. RDPDR_PRINTERDEVICE_ANNOUNCE clientPrinterFields;
  1284. } RDPDR_PRINTERDEVICE_SUB, *PRDPDR_PRINTERDEVICE_SUB;
  1285. //
  1286. // Drive device "subclass" of RDPDR_DEVICE_ANNOUNCE.
  1287. // This message is sent from the kernel-mode "dr" to the user-mode
  1288. // "dr" so the user-mode "dr" can create a UNC connection.
  1289. //
  1290. typedef struct tagRDPDR_DRIVEDEVICE_SUB
  1291. {
  1292. WCHAR driveName[RDPDR_MAXPORTNAMELEN];
  1293. WCHAR clientName[RDPDR_MAX_COMPUTER_NAME_LENGTH];
  1294. RDPDR_DEVICE_ANNOUNCE deviceFields;
  1295. WCHAR clientDisplayName[RDPDR_MAX_CLIENT_DISPLAY_NAME];
  1296. } RDPDR_DRIVEDEVICE_SUB, *PRDPDR_DRIVEDEVICE_SUB;
  1297. //
  1298. // Indicate to the user-mode component that a device has been removed.
  1299. //
  1300. typedef struct tagRDPDR_REMOVEDEVICE
  1301. {
  1302. ULONG deviceID;
  1303. } RDPDR_REMOVEDEVICE, *PRDPDR_REMOVEDEVICE;
  1304. //
  1305. // Port device "subclass" of RDPDR_DEVICE_ANNOUNCE. This message is
  1306. // sent from the kernel-mode "dr" to the user-mode "dr" so the user-mode
  1307. // "dr" can install a port.
  1308. //
  1309. typedef struct tagRDPDR_PORTDEVICE_SUB
  1310. {
  1311. WCHAR portName[RDPDR_MAXPORTNAMELEN];
  1312. WCHAR devicePath[RDPDRMAXNTDEVICENAMEGLEN];
  1313. RDPDR_DEVICE_ANNOUNCE deviceFields;
  1314. } RDPDR_PORTDEVICE_SUB, *PRDPDR_PORTDEVICE_SUB;
  1315. //
  1316. // Restore packing style (previous for 32-bit, default for 16-bit).
  1317. //
  1318. #ifdef OS_WIN16
  1319. #pragma pack ()
  1320. #else
  1321. #pragma pack (pop, drpack)
  1322. #endif
  1323. #ifdef __cplusplus
  1324. }
  1325. #endif // __cplusplus
  1326. #endif // RDPDR