NativeMethods.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. //------------------------------------------------------------------------------
  2. // <copyright file="NativeMethods.cs" company="Microsoft">
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. // </copyright>
  5. //------------------------------------------------------------------------------
  6. using System;
  7. using System.Diagnostics.CodeAnalysis;
  8. using System.Runtime.InteropServices;
  9. namespace Experimental.System.Messaging.Interop
  10. {
  11. [ComVisible(false)]
  12. internal static class NativeMethods
  13. {
  14. //Message Acknowledge constants.
  15. public const int ACKNOWLEDGE_NEGATIVE_ARRIVAL = 0x04;
  16. public const int ACKNOWLEDGE_NEGATIVE_RECEIVE = 0x08;
  17. public const int ACKNOWLEDGE_NONE = 0x00;
  18. public const int ACKNOWLEDGE_POSITIVE_ARRIVAL = 0x01;
  19. public const int ACKNOWLEDGE_POSITIVE_RECEIVE = 0x02;
  20. public const int ACKNOWLEDGE_FULL_REACH_QUEUE = ACKNOWLEDGE_NEGATIVE_ARRIVAL |
  21. ACKNOWLEDGE_POSITIVE_ARRIVAL;
  22. public const int ACKNOWLEDGE_FULL_RECEIVE = ACKNOWLEDGE_NEGATIVE_ARRIVAL |
  23. ACKNOWLEDGE_NEGATIVE_RECEIVE | ACKNOWLEDGE_POSITIVE_RECEIVE;
  24. public const int ACKNOWLEDGE_NOTACKNOWLEDGE_REACH_QUEUE = ACKNOWLEDGE_NEGATIVE_ARRIVAL;
  25. public const int ACKNOWLEDGE_NOTACKNOWLEDGE_RECEIVE = ACKNOWLEDGE_NEGATIVE_ARRIVAL |
  26. ACKNOWLEDGE_NEGATIVE_RECEIVE;
  27. // Algorithm classes.
  28. private const int ALG_CLASS_DATA_ENCRYPT = (3 << 13);
  29. private const int ALG_CLASS_HASH = (4 << 13);
  30. // Hash sub ids.
  31. private const int ALG_SID_MD2 = 1;
  32. private const int ALG_SID_MD4 = 2;
  33. private const int ALG_SID_MD5 = 3;
  34. private const int ALG_SID_SHA = 4;
  35. private const int ALG_SID_MAC = 5;
  36. private const int ALG_SID_SHA256 = 12; // 0xC
  37. private const int ALG_SID_SHA384 = 13; // 0xD
  38. private const int ALG_SID_SHA512 = 14; // 0xE
  39. private const int ALG_SID_RIPEMD = 6;
  40. private const int ALG_SID_RIPEMD160 = 7;
  41. private const int ALG_SID_SSL3SHAMD5 = 8;
  42. // RC2 sub-ids.
  43. private const int ALG_SID_RC2 = 2;
  44. private const int ALG_SID_RC4 = 1;
  45. // Algorithm types.
  46. private const int ALG_TYPE_ANY = 0;
  47. private const int ALG_TYPE_BLOCK = (3 << 9);
  48. private const int ALG_TYPE_STREAM = (4 << 9);
  49. // Algorithm identifier definitions.
  50. public const int CALG_MD2 = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD2);
  51. public const int CALG_MD4 = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD4);
  52. public const int CALG_MD5 = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD5);
  53. public const int CALG_SHA = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA);
  54. public const int CALG_MAC = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MAC);
  55. public const int CALG_SHA256 = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA256);
  56. public const int CALG_SHA384 = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA384);
  57. public const int CALG_SHA512 = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA512);
  58. public const int CALG_RC2 = (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_RC2);
  59. public const int CALG_RC4 = (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_RC4);
  60. //Stream constants
  61. public const int LOCK_WRITE = 0x1;
  62. public const int LOCK_EXCLUSIVE = 0x2;
  63. public const int LOCK_ONLYONCE = 0x4;
  64. public const int STATFLAG_DEFAULT = 0x0;
  65. public const int STATFLAG_NONAME = 0x1;
  66. public const int STATFLAG_NOOPEN = 0x2;
  67. public const int STGC_DEFAULT = 0x0;
  68. public const int STGC_OVERWRITE = 0x1;
  69. public const int STGC_ONLYIFCURRENT = 0x2;
  70. public const int STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 0x4;
  71. public const int STREAM_SEEK_SET = 0x0;
  72. public const int STREAM_SEEK_CUR = 0x1;
  73. public const int STREAM_SEEK_END = 0x2;
  74. public const int E_UNEXPECTED = unchecked((int)0x8000FFFF);
  75. public const int E_NOTIMPL = unchecked((int)0x80004001);
  76. public const int E_OUTOFMEMORY = unchecked((int)0x8007000E);
  77. public const int E_INVALIDARG = unchecked((int)0x80070057);
  78. public const int E_NOINTERFACE = unchecked((int)0x80004002);
  79. public const int E_POINTER = unchecked((int)0x80004003);
  80. public const int E_HANDLE = unchecked((int)0x80070006);
  81. public const int E_ABORT = unchecked((int)0x80004004);
  82. public const int E_FAIL = unchecked((int)0x80004005);
  83. public static Guid IID_IUnknown = new Guid("{00000000-0000-0000-C000-000000000046}");
  84. //Management Properties constants.
  85. public const int MANAGEMENT_BASE = 0;
  86. public const int MANAGEMENT_ACTIVEQUEUES = (MANAGEMENT_BASE + 1); /* VT_LPWSTR | VT_VECTOR */
  87. public const int MANAGEMENT_PRIVATEQ = (MANAGEMENT_BASE + 2); /* VT_LPWSTR | VT_VECTOR */
  88. public const int MANAGEMENT_DSSERVER = (MANAGEMENT_BASE + 3); /* VT_LPWSTR */
  89. public const int MANAGEMENT_CONNECTED = (MANAGEMENT_BASE + 4); /* VT_LPWSTR */
  90. public const int MANAGEMENT_TYPE = (MANAGEMENT_BASE + 5); /* VT_LPWSTR */
  91. //Machine Properties constants.
  92. public const int MACHINE_BASE = 200;
  93. public const int MACHINE_SITE_ID = MACHINE_BASE + 1; /* VT_CLSID */
  94. public const int MACHINE_ID = MACHINE_BASE + 2; /* VT_CLSID */
  95. public const int MACHINE_PATHNAME = MACHINE_BASE + 3; /* VT_LPWSTR */
  96. public const int MACHINE_CONNECTION = MACHINE_BASE + 4; /* VT_LPWSTR|VT_VECTOR */
  97. public const int MACHINE_ENCRYPTION_PK = MACHINE_BASE + 5; /* VT_BLOB */
  98. //Max constants.
  99. public const int MAX_MESSAGE_ID_SIZE = 20;
  100. public const int MAX_LABEL_LEN = 124;
  101. //Message Authentication level constants.
  102. public const int MESSAGE_AUTHENTICATION_LEVEL_NONE = 0;
  103. public const int MESSAGE_AUTHENTICATION_LEVEL_ALWAYS = 1;
  104. public const int MESSAGE_AUTHENTICATION_LEVEL_MSMQ10 = 2;
  105. public const int MESSAGE_AUTHENTICATION_LEVEL_MSMQ20 = 4;
  106. //Message Class constants
  107. public const int MESSAGE_CLASS_ACCESS_DENIED = (1 << 15) | 0x04;
  108. public const int MESSAGE_CLASS_BAD_DESTINATION_QUEUE = (1 << 15);
  109. public const int MESSAGE_CLASS_BAD_ENCRYPTION = (1 << 15) | 0x07;
  110. public const int MESSAGE_CLASS_BAD_SIGNATURE = (1 << 15) | 0x06;
  111. public const int MESSAGE_CLASS_COULD_NOT_ENCRYPT = (1 << 15) | 0x08;
  112. public const int MESSAGE_CLASS_HOP_COUNT_EXCEEDED = (1 << 15) | 0x05;
  113. public const int MESSAGE_CLASS_NORMAL = 0x00;
  114. public const int MESSAGE_CLASS_NOT_TRANSACTIONAL_QUEUE = (1 << 15) | 0x09;
  115. public const int MESSAGE_CLASS_NOT_TRANSACTIONAL_MESSAGE = (1 << 15) | 0x0A;
  116. public const int MESSAGE_CLASS_PURGED = (1 << 15) | 0x01;
  117. public const int MESSAGE_CLASS_QUEUE_DELETED = (1 << 15) | (1 << 14);
  118. public const int MESSAGE_CLASS_QUEUE_EXCEED_QUOTA = (1 << 15) | 0x03;
  119. public const int MESSAGE_CLASS_QUEUE_PURGED = (1 << 15) | (1 << 14) | 0x01;
  120. public const int MESSAGE_CLASS_REACH_QUEUE = 0x02;
  121. public const int MESSAGE_CLASS_REACH_QUEUE_TIMEOUT = (1 << 15) | 0x02;
  122. public const int MESSAGE_CLASS_RECEIVE = (1 << 14);
  123. public const int MESSAGE_CLASS_RECEIVE_TIMEOUT = (1 << 15) | (1 << 14) | 0x02;
  124. public const int MESSAGE_CLASS_REPORT = 0x01;
  125. //Message Delivery constants.
  126. public const int MESSAGE_DELIVERY_EXPRESS = 0;
  127. public const int MESSAGE_DELIVERY_RECOVERABLE = 1;
  128. //Message Journal constants.
  129. public const int MESSAGE_JOURNAL_NONE = 0;
  130. public const int MESSAGE_JOURNAL_DEADLETTER = 1;
  131. public const int MESSAGE_JOURNAL_JOURNAL = 2;
  132. //Message Privacy Level constants.
  133. public const int MESSAGE_PRIVACY_LEVEL_NONE = 0;
  134. public const int MESSAGE_PRIVACY_LEVEL_BODY = 1;
  135. //Message PropertyId constants.
  136. public const int MESSAGE_PROPID_BASE = 0;
  137. public const int MESSAGE_PROPID_ACKNOWLEDGE = (MESSAGE_PROPID_BASE + 6); /* VT_UI1 */
  138. public const int MESSAGE_PROPID_ADMIN_QUEUE = (MESSAGE_PROPID_BASE + 17); /* VT_LPWSTR */
  139. public const int MESSAGE_PROPID_ADMIN_QUEUE_LEN = (MESSAGE_PROPID_BASE + 18); /* VT_UI4 */
  140. public const int MESSAGE_PROPID_APPSPECIFIC = (MESSAGE_PROPID_BASE + 8); /* VT_UI4 */
  141. public const int MESSAGE_PROPID_ARRIVEDTIME = (MESSAGE_PROPID_BASE + 32); /* VT_UI4 */
  142. public const int MESSAGE_PROPID_AUTHENTICATED = (MESSAGE_PROPID_BASE + 25); /* VT_UI1 */
  143. public const int MESSAGE_PROPID_AUTH_LEVEL = (MESSAGE_PROPID_BASE + 24); /* VT_UI4 */
  144. public const int MESSAGE_PROPID_BODY = (MESSAGE_PROPID_BASE + 9); /* VT_UI1|VT_VECTOR */
  145. public const int MESSAGE_PROPID_BODY_SIZE = (MESSAGE_PROPID_BASE + 10); /* VT_UI4 */
  146. public const int MESSAGE_PROPID_BODY_TYPE = (MESSAGE_PROPID_BASE + 42); /* VT_UI4 */
  147. public const int MESSAGE_PROPID_CLASS = (MESSAGE_PROPID_BASE + 1); /* VT_UI2 */
  148. public const int MESSAGE_PROPID_CONNECTOR_TYPE = (MESSAGE_PROPID_BASE + 38); /* VT_CLSID */
  149. public const int MESSAGE_PROPID_CORRELATIONID = (MESSAGE_PROPID_BASE + 3); /* VT_UI1|VT_VECTOR */
  150. public const int MESSAGE_PROPID_DELIVERY = (MESSAGE_PROPID_BASE + 5); /* VT_UI1 */
  151. public const int MESSAGE_PROPID_DEST_QUEUE = (MESSAGE_PROPID_BASE + 33); /* VT_LPWSTR */
  152. public const int MESSAGE_PROPID_DEST_QUEUE_LEN = (MESSAGE_PROPID_BASE + 34); /* VT_UI4 */
  153. public const int MESSAGE_PROPID_DEST_SYMM_KEY = (MESSAGE_PROPID_BASE + 43); /* VT_UI1|VT_VECTOR */
  154. public const int MESSAGE_PROPID_DEST_SYMM_KEY_LEN = (MESSAGE_PROPID_BASE + 44); /* VT_UI4 */
  155. public const int MESSAGE_PROPID_ENCRYPTION_ALG = (MESSAGE_PROPID_BASE + 27); /* VT_UI4 */
  156. public const int MESSAGE_PROPID_EXTENSION = (MESSAGE_PROPID_BASE + 35); /* VT_UI1|VT_VECTOR */
  157. public const int MESSAGE_PROPID_EXTENSION_LEN = (MESSAGE_PROPID_BASE + 36); /* VT_UI4 */
  158. public const int MESSAGE_PROPID_FIRST_IN_XACT = (MESSAGE_PROPID_BASE + 50); /* VT_UI1 */
  159. public const int MESSAGE_PROPID_HASH_ALG = (MESSAGE_PROPID_BASE + 26); /* VT_UI4 */
  160. public const int MESSAGE_PROPID_JOURNAL = (MESSAGE_PROPID_BASE + 7); /* VT_UI1 */
  161. public const int MESSAGE_PROPID_LABEL = (MESSAGE_PROPID_BASE + 11); /* VT_LPWSTR */
  162. public const int MESSAGE_PROPID_LABEL_LEN = (MESSAGE_PROPID_BASE + 12); /* VT_UI4 */
  163. public const int MESSAGE_PROPID_LAST_IN_XACT = (MESSAGE_PROPID_BASE + 51); /* VT_UI1 */
  164. public const int MESSAGE_PROPID_MSGID = (MESSAGE_PROPID_BASE + 2); /* VT_UI1|VT_VECTOR */
  165. public const int MESSAGE_PROPID_PRIORITY = (MESSAGE_PROPID_BASE + 4); /* VT_UI1 */
  166. public const int MESSAGE_PROPID_PRIV_LEVEL = (MESSAGE_PROPID_BASE + 23); /* VT_UI4 */
  167. public const int MESSAGE_PROPID_PROV_NAME = (MESSAGE_PROPID_BASE + 48); /* VT_LPWSTR */
  168. public const int MESSAGE_PROPID_PROV_NAME_LEN = (MESSAGE_PROPID_BASE + 49); /* VT_UI4 */
  169. public const int MESSAGE_PROPID_PROV_TYPE = (MESSAGE_PROPID_BASE + 47); /* VT_UI4 */
  170. public const int MESSAGE_PROPID_RESP_QUEUE = (MESSAGE_PROPID_BASE + 15); /* VT_LPWSTR */
  171. public const int MESSAGE_PROPID_RESP_QUEUE_LEN = (MESSAGE_PROPID_BASE + 16); /* VT_UI4 */
  172. public const int MESSAGE_PROPID_SECURITY_CONTEXT = (MESSAGE_PROPID_BASE + 37); /* VT_UI4 */
  173. public const int MESSAGE_PROPID_SENDERID = (MESSAGE_PROPID_BASE + 20); /* VT_UI1|VT_VECTOR */
  174. public const int MESSAGE_PROPID_SENDERID_LEN = (MESSAGE_PROPID_BASE + 21); /* VT_UI4 */
  175. public const int MESSAGE_PROPID_SENDERID_TYPE = (MESSAGE_PROPID_BASE + 22); /* VT_UI4 */
  176. public const int MESSAGE_PROPID_SENDER_CERT = (MESSAGE_PROPID_BASE + 28); /* VT_UI1|VT_VECTOR */
  177. public const int MESSAGE_PROPID_SENDER_CERT_LEN = (MESSAGE_PROPID_BASE + 29); /* VT_UI4 */
  178. public const int MESSAGE_PROPID_SENTTIME = (MESSAGE_PROPID_BASE + 31); /* VT_UI4 */
  179. public const int MESSAGE_PROPID_SIGNATURE = (MESSAGE_PROPID_BASE + 45); /* VT_UI1|VT_VECTOR */
  180. public const int MESSAGE_PROPID_SIGNATURE_LEN = (MESSAGE_PROPID_BASE + 46); /* VT_UI4 */
  181. public const int MESSAGE_PROPID_SRC_MACHINE_ID = (MESSAGE_PROPID_BASE + 30); /* VT_CLSID */
  182. public const int MESSAGE_PROPID_TIME_TO_BE_RECEIVED = (MESSAGE_PROPID_BASE + 14); /* VT_UI4 */
  183. public const int MESSAGE_PROPID_TIME_TO_REACH_QUEUE = (MESSAGE_PROPID_BASE + 13); /* VT_UI4 */
  184. public const int MESSAGE_PROPID_TRACE = (MESSAGE_PROPID_BASE + 41); /* VT_UI1 */
  185. public const int MESSAGE_PROPID_VERSION = (MESSAGE_PROPID_BASE + 19); /* VT_UI4 */
  186. public const int MESSAGE_PROPID_XACT_STATUS_QUEUE = (MESSAGE_PROPID_BASE + 39); /* VT_LPWSTR */
  187. public const int MESSAGE_PROPID_XACT_STATUS_QUEUE_LEN = (MESSAGE_PROPID_BASE + 40); /* VT_UI4 */
  188. public const int MESSAGE_PROPID_XACTID = (MESSAGE_PROPID_BASE + 52); /* VT_UI1|VT_VECTOR */
  189. public const int MESSAGE_PROPID_LOOKUPID = (MESSAGE_PROPID_BASE + 60); /* VT_UI8 */
  190. //Message SenderId types
  191. public const int MESSAGE_SENDERID_TYPE_NONE = 0;
  192. public const int MESSAGE_SENDERID_TYPE_SID = 1;
  193. //Message Trace constants.
  194. public const int MESSAGE_TRACE_NONE = 0;
  195. public const int MESSAGE_TRACE_SEND_ROUTE_TO_REPORT_QUEUE = 1;
  196. // Chryptographic Provider Types
  197. public const int PROV_RSA_FULL = 1;
  198. public const int PROV_RSA_SIG = 2;
  199. public const int PROV_DSS = 3;
  200. public const int PROV_FORTEZZA = 4;
  201. public const int PROV_MS_EXCHANGE = 5;
  202. public const int PROV_SSL = 6;
  203. public const int PROV_STT_MER = 7;
  204. public const int PROV_STT_ACQ = 8;
  205. public const int PROV_STT_BRND = 9;
  206. public const int PROV_STT_ROOT = 10;
  207. public const int PROV_STT_ISS = 11;
  208. //Queue Access constants.
  209. public const int QUEUE_ACCESS_RECEIVE = 1;
  210. public const int QUEUE_ACCESS_SEND = 2;
  211. public const int QUEUE_ACCESS_PEEK = 32;
  212. public const int QUEUE_ACCESS_ADMIN = 128;
  213. //Queue Action constants
  214. public const int QUEUE_ACTION_RECEIVE = 0x00000000;
  215. public const int QUEUE_ACTION_PEEK_CURRENT = unchecked((int)0x80000000);
  216. public const int QUEUE_ACTION_PEEK_NEXT = unchecked((int)0x80000001);
  217. //Lookup Action constants
  218. internal const int LOOKUP_PEEK_MASK = 0x40000010;
  219. internal const int LOOKUP_RECEIVE_MASK = 0x40000020;
  220. //Queue Authenticate constants.
  221. public const int QUEUE_AUTHENTICATE_NONE = 0;
  222. public const int QUEUE_AUTHENTICATE_AUTHENTICATE = 1;
  223. //Queue Journal constants.
  224. public const int QUEUE_JOURNAL_NONE = 0;
  225. public const int QUEUE_JOURNAL_JOURNAL = 1;
  226. //Queue Privacy level constants
  227. public const int QUEUE_PRIVACY_LEVEL_NONE = 0;
  228. public const int QUEUE_PRIVACY_LEVEL_OPTIONAL = 1;
  229. public const int QUEUE_PRIVACY_LEVEL_BODY = 2;
  230. //Queue PropertyId constants.
  231. public const int QUEUE_PROPID_BASE = 100;
  232. public const int QUEUE_PROPID_INSTANCE = QUEUE_PROPID_BASE + 1; /* VT_CLSID */
  233. public const int QUEUE_PROPID_TYPE = QUEUE_PROPID_BASE + 2; /* VT_CLSID */
  234. public const int QUEUE_PROPID_PATHNAME = QUEUE_PROPID_BASE + 3; /* VT_LPWSTR */
  235. public const int QUEUE_PROPID_JOURNAL = QUEUE_PROPID_BASE + 4; /* VT_UI1 */
  236. public const int QUEUE_PROPID_QUOTA = QUEUE_PROPID_BASE + 5; /* VT_UI4 */
  237. public const int QUEUE_PROPID_BASEPRIORITY = QUEUE_PROPID_BASE + 6; /* VT_I2 */
  238. public const int QUEUE_PROPID_JOURNAL_QUOTA = QUEUE_PROPID_BASE + 7; /* VT_UI4 */
  239. public const int QUEUE_PROPID_LABEL = QUEUE_PROPID_BASE + 8; /* VT_LPWSTR */
  240. public const int QUEUE_PROPID_CREATE_TIME = QUEUE_PROPID_BASE + 9; /* VT_I4 */
  241. public const int QUEUE_PROPID_MODIFY_TIME = QUEUE_PROPID_BASE + 10; /* VT_I4 */
  242. public const int QUEUE_PROPID_AUTHENTICATE = QUEUE_PROPID_BASE + 11; /* VT_UI1 */
  243. public const int QUEUE_PROPID_PRIV_LEVEL = QUEUE_PROPID_BASE + 12; /* VT_UI4 */
  244. public const int QUEUE_PROPID_TRANSACTION = QUEUE_PROPID_BASE + 13; /* VT_UI1 */
  245. //public const int QUEUE_PROPID_PATHNAME_DNS = QUEUE_PROPID_BASE + 24; /* VT_LPWSTR */
  246. public const int QUEUE_PROPID_MULTICAST_ADDRESS = QUEUE_PROPID_BASE + 25; /* VT_LPWSTR /
  247. //public const int QUEUE_PROPID_ADS_PATH = QUEUE_PROPID_BASE + 26; //needed to add queue to DL /* VT_LPWSTR */
  248. //Queue Shared Mode constants.
  249. public const int QUEUE_SHARED_MODE_DENY_NONE = 0;
  250. public const int QUEUE_SHARED_MODE_DENY_RECEIVE = 1;
  251. //Queue Transaction constants.
  252. public const int QUEUE_TRANSACTION_NONE = 0;
  253. public const int QUEUE_TRANSACTION_MTS = 1;
  254. public const int QUEUE_TRANSACTION_XA = 2;
  255. public const int QUEUE_TRANSACTION_SINGLE = 3;
  256. //Queue Transactional Mode constants.
  257. public const int QUEUE_TRANSACTIONAL_NONE = 0;
  258. public const int QUEUE_TRANSACTIONAL_TRANSACTIONAL = 1;
  259. //Security constants
  260. public const int MQ_ERROR_SECURITY_DESCRIPTOR_TOO_SMALL = unchecked((int)0xc00e0023);
  261. public const int MQ_OK = 0;
  262. public const int TRUSTEE_IS_SID = 0;
  263. public const int TRUSTEE_IS_NAME = 1;
  264. public const int TRUSTEE_IS_USER = 1;
  265. public const int TRUSTEE_IS_GROUP = 2;
  266. public const int TRUSTEE_IS_DOMAIN = 3;
  267. public const int TRUSTEE_IS_ALIAS = 4;
  268. public const int TRUSTEE_IS_WELL_KNOWN_GROUP = 5;
  269. public const int DACL_SECURITY_INFORMATION = 4;
  270. public const int GRANT_ACCESS = 1;
  271. public const int SET_ACCESS = 2;
  272. public const int DENY_ACCESS = 3;
  273. public const int REVOKE_ACCESS = 4;
  274. public const int NO_MULTIPLE_TRUSTEE = 0;
  275. public const int ERROR_SUCCESS = 0;
  276. public const int SECURITY_DESCRIPTOR_REVISION = 1;
  277. // This call is here because we don't want to invent a separate MessageQueuePermission
  278. // for this call, and there's no suitable existing permission.
  279. [DllImport(ExternDll.Mqrt, EntryPoint = "MQGetSecurityContextEx", CharSet = CharSet.Unicode)]
  280. private static extern int IntMQGetSecurityContextEx(IntPtr lpCertBuffer, int dwCertBufferLength, out SecurityContextHandle phSecurityContext);
  281. public static int MQGetSecurityContextEx(out SecurityContextHandle securityContext)
  282. {
  283. try
  284. {
  285. return IntMQGetSecurityContextEx(IntPtr.Zero, 0, out securityContext);
  286. }
  287. catch (DllNotFoundException)
  288. {
  289. throw new InvalidOperationException(Res.GetString(Res.MSMQNotInstalled));
  290. }
  291. }
  292. [DllImport(ExternDll.Ole32, PreserveSig = false)]
  293. [return: MarshalAs(UnmanagedType.Interface)]
  294. public static extern object OleLoadFromStream(IStream stream, [In] ref Guid iid);
  295. [DllImport(ExternDll.Ole32, PreserveSig = false)]
  296. public static extern void OleSaveToStream(IPersistStream persistStream, IStream stream);
  297. [StructLayout(LayoutKind.Sequential)]
  298. public class SECURITY_DESCRIPTOR
  299. {
  300. public byte revision = 0;
  301. public byte size = 0;
  302. public short control = 0;
  303. [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
  304. public IntPtr owner = (IntPtr)0;
  305. [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
  306. public IntPtr Group = (IntPtr)0;
  307. [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
  308. public IntPtr Sacl = (IntPtr)0;
  309. [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
  310. public IntPtr Dacl = (IntPtr)0;
  311. }
  312. [StructLayout(LayoutKind.Sequential)]
  313. public struct ExplicitAccess
  314. {
  315. public int grfAccessPermissions;
  316. public int grfAccessMode;
  317. public int grfInheritance;
  318. [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
  319. public IntPtr pMultipleTrustees;
  320. public int MultipleTrusteeOperation;
  321. public int TrusteeForm;
  322. public int TrusteeType;
  323. [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
  324. public IntPtr data;
  325. }
  326. }
  327. }