UnsafeNativeMethods.cs 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291
  1. //------------------------------------------------------------------------------
  2. // <copyright file="UnsafeNativeMethods.cs" company="Microsoft">
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. // </copyright>
  5. // <owner current="true" primary="true">Microsoft</owner>
  6. // <owner current="true" primary="false">Microsoft</owner>
  7. // <owner current="true" primary="false">Microsoft</owner>
  8. //------------------------------------------------------------------------------
  9. using System;
  10. #if !NO_ODBC
  11. using System.Data.Odbc;
  12. #endif
  13. using System.Runtime.CompilerServices;
  14. using System.Runtime.InteropServices;
  15. using System.Security;
  16. using System.Security.Permissions;
  17. using System.Text;
  18. using System.Runtime.ConstrainedExecution;
  19. using System.Runtime.Versioning;
  20. namespace System.Data.Common {
  21. [SuppressUnmanagedCodeSecurityAttribute()]
  22. internal static class UnsafeNativeMethods {
  23. #if !NO_ODBC
  24. //
  25. // ODBC32
  26. //
  27. [DllImport(ExternDll.Odbc32)]
  28. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
  29. [ResourceExposure(ResourceScope.None)]
  30. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLAllocHandle(
  31. /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType,
  32. /*SQLHANDLE*/IntPtr InputHandle,
  33. /*SQLHANDLE* */out IntPtr OutputHandle);
  34. [DllImport(ExternDll.Odbc32)]
  35. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
  36. [ResourceExposure(ResourceScope.None)]
  37. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLAllocHandle(
  38. /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType,
  39. /*SQLHANDLE*/OdbcHandle InputHandle,
  40. /*SQLHANDLE* */out IntPtr OutputHandle);
  41. [DllImport(ExternDll.Odbc32)]
  42. [ResourceExposure(ResourceScope.None)]
  43. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLBindCol(
  44. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  45. /*SQLUSMALLINT*/UInt16 ColumnNumber,
  46. /*SQLSMALLINT*/ODBC32.SQL_C TargetType,
  47. /*SQLPOINTER*/HandleRef TargetValue,
  48. /*SQLLEN*/IntPtr BufferLength,
  49. /*SQLLEN* */IntPtr StrLen_or_Ind);
  50. [DllImport(ExternDll.Odbc32)]
  51. [ResourceExposure(ResourceScope.None)]
  52. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLBindCol(
  53. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  54. /*SQLUSMALLINT*/UInt16 ColumnNumber,
  55. /*SQLSMALLINT*/ODBC32.SQL_C TargetType,
  56. /*SQLPOINTER*/IntPtr TargetValue,
  57. /*SQLLEN*/IntPtr BufferLength,
  58. /*SQLLEN* */IntPtr StrLen_or_Ind);
  59. [DllImport(ExternDll.Odbc32)]
  60. [ResourceExposure(ResourceScope.None)]
  61. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLBindParameter(
  62. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  63. /*SQLUSMALLINT*/UInt16 ParameterNumber,
  64. /*SQLSMALLINT*/Int16 ParamDirection,
  65. /*SQLSMALLINT*/ODBC32.SQL_C SQLCType,
  66. /*SQLSMALLINT*/Int16 SQLType,
  67. /*SQLULEN*/IntPtr cbColDef,
  68. /*SQLSMALLINT*/IntPtr ibScale,
  69. /*SQLPOINTER*/HandleRef rgbValue,
  70. /*SQLLEN*/IntPtr BufferLength,
  71. /*SQLLEN* */HandleRef StrLen_or_Ind);
  72. [DllImport(ExternDll.Odbc32)]
  73. [ResourceExposure(ResourceScope.None)]
  74. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLCancel(
  75. /*SQLHSTMT*/OdbcStatementHandle StatementHandle);
  76. [DllImport(ExternDll.Odbc32)]
  77. [ResourceExposure(ResourceScope.None)]
  78. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLCloseCursor(
  79. /*SQLHSTMT*/OdbcStatementHandle StatementHandle);
  80. [DllImport(ExternDll.Odbc32)]
  81. [ResourceExposure(ResourceScope.None)]
  82. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLColAttributeW (
  83. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  84. /*SQLUSMALLINT*/Int16 ColumnNumber,
  85. /*SQLUSMALLINT*/Int16 FieldIdentifier,
  86. /*SQLPOINTER*/CNativeBuffer CharacterAttribute,
  87. /*SQLSMALLINT*/Int16 BufferLength,
  88. /*SQLSMALLINT* */out Int16 StringLength,
  89. /*SQLPOINTER*/out IntPtr NumericAttribute);
  90. // note: in sql.h this is defined differently for the 64Bit platform.
  91. // However, for us the code is not different for SQLPOINTER or SQLLEN ...
  92. // frome sql.h:
  93. // #ifdef _WIN64
  94. // SQLRETURN SQL_API SQLColAttribute (SQLHSTMT StatementHandle,
  95. // SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
  96. // SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
  97. // SQLSMALLINT *StringLength, SQLLEN *NumericAttribute);
  98. // #else
  99. // SQLRETURN SQL_API SQLColAttribute (SQLHSTMT StatementHandle,
  100. // SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
  101. // SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
  102. // SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute);
  103. // #endif
  104. [DllImport(ExternDll.Odbc32)]
  105. [ResourceExposure(ResourceScope.None)]
  106. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLColumnsW (
  107. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  108. [In, MarshalAs(UnmanagedType.LPWStr)]
  109. /*SQLCHAR* */string CatalogName,
  110. /*SQLSMALLINT*/Int16 NameLen1,
  111. [In, MarshalAs(UnmanagedType.LPWStr)]
  112. /*SQLCHAR* */string SchemaName,
  113. /*SQLSMALLINT*/Int16 NameLen2,
  114. [In, MarshalAs(UnmanagedType.LPWStr)]
  115. /*SQLCHAR* */string TableName,
  116. /*SQLSMALLINT*/Int16 NameLen3,
  117. [In, MarshalAs(UnmanagedType.LPWStr)]
  118. /*SQLCHAR* */string ColumnName,
  119. /*SQLSMALLINT*/Int16 NameLen4);
  120. [DllImport(ExternDll.Odbc32)]
  121. [ResourceExposure(ResourceScope.None)]
  122. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
  123. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLDisconnect(
  124. /*SQLHDBC*/IntPtr ConnectionHandle);
  125. [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)]
  126. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
  127. [ResourceExposure(ResourceScope.None)]
  128. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLDriverConnectW(
  129. /*SQLHDBC*/OdbcConnectionHandle hdbc,
  130. /*SQLHWND*/IntPtr hwnd,
  131. [In, MarshalAs(UnmanagedType.LPWStr)]
  132. /*SQLCHAR* */string connectionstring,
  133. /*SQLSMALLINT*/Int16 cbConnectionstring,
  134. /*SQLCHAR* */IntPtr connectionstringout,
  135. /*SQLSMALLINT*/Int16 cbConnectionstringoutMax,
  136. /*SQLSMALLINT* */out Int16 cbConnectionstringout,
  137. /*SQLUSMALLINT*/Int16 fDriverCompletion);
  138. [DllImport(ExternDll.Odbc32)]
  139. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
  140. [ResourceExposure(ResourceScope.None)]
  141. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLEndTran(
  142. /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType,
  143. /*SQLHANDLE*/IntPtr Handle,
  144. /*SQLSMALLINT*/Int16 CompletionType);
  145. [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)]
  146. [ResourceExposure(ResourceScope.None)]
  147. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLExecDirectW(
  148. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  149. [In, MarshalAs(UnmanagedType.LPWStr)]
  150. /*SQLCHAR* */string StatementText,
  151. /*SQLINTEGER*/Int32 TextLength);
  152. [DllImport(ExternDll.Odbc32)]
  153. [ResourceExposure(ResourceScope.None)]
  154. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLExecute(
  155. /*SQLHSTMT*/OdbcStatementHandle StatementHandle);
  156. [DllImport(ExternDll.Odbc32)]
  157. [ResourceExposure(ResourceScope.None)]
  158. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLFetch(
  159. /*SQLHSTMT*/OdbcStatementHandle StatementHandle);
  160. [DllImport(ExternDll.Odbc32)]
  161. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
  162. [ResourceExposure(ResourceScope.None)]
  163. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLFreeHandle(
  164. /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType,
  165. /*SQLHSTMT*/IntPtr StatementHandle);
  166. [DllImport(ExternDll.Odbc32)]
  167. [ResourceExposure(ResourceScope.None)]
  168. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLFreeStmt(
  169. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  170. /*SQLUSMALLINT*/ODBC32.STMT Option);
  171. [DllImport(ExternDll.Odbc32)]
  172. [ResourceExposure(ResourceScope.None)]
  173. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetConnectAttrW(
  174. /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle,
  175. /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute,
  176. /*SQLPOINTER*/byte[] Value,
  177. /*SQLINTEGER*/Int32 BufferLength,
  178. /*SQLINTEGER* */out Int32 StringLength);
  179. [DllImport(ExternDll.Odbc32)]
  180. [ResourceExposure(ResourceScope.None)]
  181. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetData(
  182. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  183. /*SQLUSMALLINT*/UInt16 ColumnNumber,
  184. /*SQLSMALLINT*/ODBC32.SQL_C TargetType,
  185. /*SQLPOINTER*/CNativeBuffer TargetValue,
  186. /*SQLLEN*/IntPtr BufferLength, // sql.h differs from MSDN
  187. /*SQLLEN* */out IntPtr StrLen_or_Ind);
  188. [DllImport(ExternDll.Odbc32)]
  189. [ResourceExposure(ResourceScope.None)]
  190. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetDescFieldW (
  191. /*SQLHSTMT*/OdbcDescriptorHandle StatementHandle,
  192. /*SQLUSMALLINT*/Int16 RecNumber,
  193. /*SQLUSMALLINT*/ODBC32.SQL_DESC FieldIdentifier,
  194. /*SQLPOINTER*/CNativeBuffer ValuePointer,
  195. /*SQLINTEGER*/Int32 BufferLength,
  196. /*SQLINTEGER* */out Int32 StringLength);
  197. [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)]
  198. [ResourceExposure(ResourceScope.None)]
  199. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetDiagRecW(
  200. /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType,
  201. /*SQLHANDLE*/OdbcHandle Handle,
  202. /*SQLSMALLINT*/Int16 RecNumber,
  203. /*SQLCHAR* */ StringBuilder rchState,
  204. /*SQLINTEGER* */out Int32 NativeError,
  205. /*SQLCHAR* */StringBuilder MessageText,
  206. /*SQLSMALLINT*/Int16 BufferLength,
  207. /*SQLSMALLINT* */out Int16 TextLength);
  208. [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)]
  209. [ResourceExposure(ResourceScope.None)]
  210. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetDiagFieldW(
  211. /*SQLSMALLINT*/ ODBC32.SQL_HANDLE HandleType,
  212. /*SQLHANDLE*/ OdbcHandle Handle,
  213. /*SQLSMALLINT*/ Int16 RecNumber,
  214. /*SQLSMALLINT*/ Int16 DiagIdentifier,
  215. [MarshalAs(UnmanagedType.LPWStr)]
  216. /*SQLPOINTER*/ StringBuilder rchState,
  217. /*SQLSMALLINT*/ Int16 BufferLength,
  218. /*SQLSMALLINT* */ out Int16 StringLength);
  219. [DllImport(ExternDll.Odbc32)]
  220. [ResourceExposure(ResourceScope.None)]
  221. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetFunctions(
  222. /*SQLHBDC*/OdbcConnectionHandle hdbc,
  223. /*SQLUSMALLINT*/ODBC32.SQL_API fFunction,
  224. /*SQLUSMALLINT* */out Int16 pfExists);
  225. [DllImport(ExternDll.Odbc32)]
  226. [ResourceExposure(ResourceScope.None)]
  227. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetInfoW(
  228. /*SQLHBDC*/OdbcConnectionHandle hdbc,
  229. /*SQLUSMALLINT*/ODBC32.SQL_INFO fInfoType,
  230. /*SQLPOINTER*/byte[] rgbInfoValue,
  231. /*SQLSMALLINT*/Int16 cbInfoValueMax,
  232. /*SQLSMALLINT* */out Int16 pcbInfoValue);
  233. [DllImport(ExternDll.Odbc32)]
  234. [ResourceExposure(ResourceScope.None)]
  235. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetInfoW(
  236. /*SQLHBDC*/OdbcConnectionHandle hdbc,
  237. /*SQLUSMALLINT*/ODBC32.SQL_INFO fInfoType,
  238. /*SQLPOINTER*/byte[] rgbInfoValue,
  239. /*SQLSMALLINT*/Int16 cbInfoValueMax,
  240. /*SQLSMALLINT* */IntPtr pcbInfoValue);
  241. [DllImport(ExternDll.Odbc32)]
  242. [ResourceExposure(ResourceScope.None)]
  243. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetStmtAttrW(
  244. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  245. /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute,
  246. /*SQLPOINTER*/out IntPtr Value,
  247. /*SQLINTEGER*/Int32 BufferLength,
  248. /*SQLINTEGER*/out Int32 StringLength);
  249. [DllImport(ExternDll.Odbc32)]
  250. [ResourceExposure(ResourceScope.None)]
  251. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetTypeInfo(
  252. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  253. /*SQLSMALLINT*/Int16 fSqlType);
  254. [DllImport(ExternDll.Odbc32)]
  255. [ResourceExposure(ResourceScope.None)]
  256. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLMoreResults(
  257. /*SQLHSTMT*/OdbcStatementHandle StatementHandle);
  258. [DllImport(ExternDll.Odbc32)]
  259. [ResourceExposure(ResourceScope.None)]
  260. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLNumResultCols(
  261. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  262. /*SQLSMALLINT* */out Int16 ColumnCount);
  263. [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)]
  264. [ResourceExposure(ResourceScope.None)]
  265. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLPrepareW(
  266. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  267. [In, MarshalAs(UnmanagedType.LPWStr)]
  268. /*SQLCHAR* */string StatementText,
  269. /*SQLINTEGER*/Int32 TextLength);
  270. [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)]
  271. [ResourceExposure(ResourceScope.None)]
  272. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLPrimaryKeysW (
  273. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  274. [In, MarshalAs(UnmanagedType.LPWStr)]
  275. /*SQLCHAR* */string CatalogName,
  276. /*SQLSMALLINT*/Int16 NameLen1,
  277. [In, MarshalAs(UnmanagedType.LPWStr)]
  278. /*SQLCHAR* */ string SchemaName,
  279. /*SQLSMALLINT*/Int16 NameLen2,
  280. [In, MarshalAs(UnmanagedType.LPWStr)]
  281. /*SQLCHAR* */string TableName,
  282. /*SQLSMALLINT*/Int16 NameLen3);
  283. [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)]
  284. [ResourceExposure(ResourceScope.None)]
  285. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLProcedureColumnsW (
  286. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  287. [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string CatalogName,
  288. /*SQLSMALLINT*/Int16 NameLen1,
  289. [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string SchemaName,
  290. /*SQLSMALLINT*/Int16 NameLen2,
  291. [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string ProcName,
  292. /*SQLSMALLINT*/Int16 NameLen3,
  293. [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string ColumnName,
  294. /*SQLSMALLINT*/Int16 NameLen4);
  295. [DllImport(ExternDll.Odbc32)]
  296. [ResourceExposure(ResourceScope.None)]
  297. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLProceduresW (
  298. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  299. [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string CatalogName,
  300. /*SQLSMALLINT*/Int16 NameLen1,
  301. [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string SchemaName,
  302. /*SQLSMALLINT*/Int16 NameLen2,
  303. [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string ProcName,
  304. /*SQLSMALLINT*/Int16 NameLen3);
  305. [DllImport(ExternDll.Odbc32)]
  306. [ResourceExposure(ResourceScope.None)]
  307. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLRowCount(
  308. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  309. /*SQLLEN* */out IntPtr RowCount);
  310. [DllImport(ExternDll.Odbc32)]
  311. [ResourceExposure(ResourceScope.None)]
  312. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetConnectAttrW(
  313. /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle,
  314. /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute,
  315. /*SQLPOINTER*/System.Transactions.IDtcTransaction Value,
  316. /*SQLINTEGER*/Int32 StringLength);
  317. [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)]
  318. [ResourceExposure(ResourceScope.None)]
  319. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetConnectAttrW(
  320. /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle,
  321. /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute,
  322. /*SQLPOINTER*/string Value,
  323. /*SQLINTEGER*/Int32 StringLength);
  324. [DllImport(ExternDll.Odbc32)]
  325. [ResourceExposure(ResourceScope.None)]
  326. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetConnectAttrW(
  327. /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle,
  328. /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute,
  329. /*SQLPOINTER*/IntPtr Value,
  330. /*SQLINTEGER*/Int32 StringLength);
  331. [DllImport(ExternDll.Odbc32)]
  332. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
  333. [ResourceExposure(ResourceScope.None)]
  334. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetConnectAttrW( // used only for AutoCommitOn
  335. /*SQLHBDC*/IntPtr ConnectionHandle,
  336. /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute,
  337. /*SQLPOINTER*/IntPtr Value,
  338. /*SQLINTEGER*/Int32 StringLength);
  339. [DllImport(ExternDll.Odbc32)]
  340. [ResourceExposure(ResourceScope.None)]
  341. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetDescFieldW (
  342. /*SQLHSTMT*/OdbcDescriptorHandle StatementHandle,
  343. /*SQLSMALLINT*/Int16 ColumnNumber,
  344. /*SQLSMALLINT*/ODBC32.SQL_DESC FieldIdentifier,
  345. /*SQLPOINTER*/HandleRef CharacterAttribute,
  346. /*SQLINTEGER*/Int32 BufferLength);
  347. [DllImport(ExternDll.Odbc32)]
  348. [ResourceExposure(ResourceScope.None)]
  349. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetDescFieldW (
  350. /*SQLHSTMT*/OdbcDescriptorHandle StatementHandle,
  351. /*SQLSMALLINT*/Int16 ColumnNumber,
  352. /*SQLSMALLINT*/ODBC32.SQL_DESC FieldIdentifier,
  353. /*SQLPOINTER*/IntPtr CharacterAttribute,
  354. /*SQLINTEGER*/Int32 BufferLength);
  355. [DllImport(ExternDll.Odbc32)]
  356. // user can set SQL_ATTR_CONNECTION_POOLING attribute with envHandle = null, this attribute is process-level attribute
  357. [ResourceExposure(ResourceScope.Process)]
  358. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetEnvAttr(
  359. /*SQLHENV*/OdbcEnvironmentHandle EnvironmentHandle,
  360. /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute,
  361. /*SQLPOINTER*/IntPtr Value,
  362. /*SQLINTEGER*/ODBC32.SQL_IS StringLength);
  363. [DllImport(ExternDll.Odbc32)]
  364. [ResourceExposure(ResourceScope.None)]
  365. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetStmtAttrW(
  366. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  367. /*SQLINTEGER*/Int32 Attribute,
  368. /*SQLPOINTER*/IntPtr Value,
  369. /*SQLINTEGER*/Int32 StringLength);
  370. [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)]
  371. [ResourceExposure(ResourceScope.None)]
  372. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSpecialColumnsW (
  373. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  374. /*SQLUSMALLINT*/ODBC32.SQL_SPECIALCOLS IdentifierType,
  375. [In, MarshalAs(UnmanagedType.LPWStr)]
  376. /*SQLCHAR* */string CatalogName,
  377. /*SQLSMALLINT*/Int16 NameLen1,
  378. [In, MarshalAs(UnmanagedType.LPWStr)]
  379. /*SQLCHAR* */string SchemaName,
  380. /*SQLSMALLINT*/Int16 NameLen2,
  381. [In, MarshalAs(UnmanagedType.LPWStr)]
  382. /*SQLCHAR* */string TableName,
  383. /*SQLSMALLINT*/Int16 NameLen3,
  384. /*SQLUSMALLINT*/ODBC32.SQL_SCOPE Scope,
  385. /*SQLUSMALLINT*/ ODBC32.SQL_NULLABILITY Nullable);
  386. [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)]
  387. [ResourceExposure(ResourceScope.None)]
  388. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLStatisticsW (
  389. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  390. [In, MarshalAs(UnmanagedType.LPWStr)]
  391. /*SQLCHAR* */string CatalogName,
  392. /*SQLSMALLINT*/Int16 NameLen1,
  393. [In, MarshalAs(UnmanagedType.LPWStr)]
  394. /*SQLCHAR* */string SchemaName,
  395. /*SQLSMALLINT*/Int16 NameLen2,
  396. [In, MarshalAs(UnmanagedType.LPWStr)]
  397. /*SQLCHAR* */string TableName,
  398. /*SQLSMALLINT*/Int16 NameLen3,
  399. /*SQLUSMALLINT*/Int16 Unique,
  400. /*SQLUSMALLINT*/Int16 Reserved);
  401. [DllImport(ExternDll.Odbc32)]
  402. [ResourceExposure(ResourceScope.None)]
  403. static internal extern /*SQLRETURN*/ODBC32.RetCode SQLTablesW (
  404. /*SQLHSTMT*/OdbcStatementHandle StatementHandle,
  405. [In, MarshalAs(UnmanagedType.LPWStr)]
  406. /*SQLCHAR* */string CatalogName,
  407. /*SQLSMALLINT*/Int16 NameLen1,
  408. [In, MarshalAs(UnmanagedType.LPWStr)]
  409. /*SQLCHAR* */string SchemaName,
  410. /*SQLSMALLINT*/Int16 NameLen2,
  411. [In, MarshalAs(UnmanagedType.LPWStr)]
  412. /*SQLCHAR* */string TableName,
  413. /*SQLSMALLINT*/Int16 NameLen3,
  414. [In, MarshalAs(UnmanagedType.LPWStr)]
  415. /*SQLCHAR* */string TableType,
  416. /*SQLSMALLINT*/Int16 NameLen4);
  417. #endif
  418. #if !NO_OLEDB
  419. //
  420. // Oleaut32
  421. //
  422. [DllImport(ExternDll.Oleaut32, CharSet=CharSet.Unicode, PreserveSig=true)]
  423. [ResourceExposure(ResourceScope.None)]
  424. static internal extern System.Data.OleDb.OleDbHResult GetErrorInfo(
  425. [In] Int32 dwReserved,
  426. [Out, MarshalAs(UnmanagedType.Interface)] out IErrorInfo ppIErrorInfo);
  427. [Guid("00000567-0000-0010-8000-00AA006D2EA4"), InterfaceType(ComInterfaceType.InterfaceIsDual), ComImport, SuppressUnmanagedCodeSecurity]
  428. internal interface ADORecordConstruction {
  429. [return:MarshalAs(UnmanagedType.Interface)] object get_Row ();
  430. //void put_Row(
  431. // [In, MarshalAs(UnmanagedType.Interface)] object pRow);
  432. //void put_ParentRow(
  433. // [In, MarshalAs(UnmanagedType.Interface)]object pRow);
  434. }
  435. [Guid("00000283-0000-0010-8000-00AA006D2EA4"), InterfaceType(ComInterfaceType.InterfaceIsDual), ComImport, SuppressUnmanagedCodeSecurity]
  436. internal interface ADORecordsetConstruction {
  437. [return:MarshalAs(UnmanagedType.Interface)] object get_Rowset();
  438. [ Obsolete("not used", true)] void put_Rowset (/*deleted parameters signature*/);
  439. /*[return:MarshalAs(UnmanagedType.SysInt)]*/ IntPtr get_Chapter();
  440. //[[PreserveSig]
  441. //iint put_Chapter (
  442. // [In]
  443. // IntPtr pcRefCount);
  444. //[[PreserveSig]
  445. //iint get_RowPosition (
  446. // [Out, MarshalAs(UnmanagedType.Interface)]
  447. // out object ppRowPos);
  448. //[[PreserveSig]
  449. //iint put_RowPosition (
  450. // [In, MarshalAs(UnmanagedType.Interface)]
  451. // object pRowPos);
  452. }
  453. [Guid("0000050E-0000-0010-8000-00AA006D2EA4"), InterfaceType(ComInterfaceType.InterfaceIsDual), ComImport, SuppressUnmanagedCodeSecurity]
  454. internal interface Recordset15 {
  455. [ Obsolete("not used", true)] void get_Properties(/*deleted parameters signature*/);
  456. [ Obsolete("not used", true)] void get_AbsolutePosition(/*deleted parameters signature*/);
  457. [ Obsolete("not used", true)] void put_AbsolutePosition(/*deleted parameters signature*/);
  458. [ Obsolete("not used", true)] void putref_ActiveConnection(/*deleted parameters signature*/);
  459. [ Obsolete("not used", true)] void put_ActiveConnection(/*deleted parameters signature*/);
  460. /*[return:MarshalAs(UnmanagedType.Variant)]*/object get_ActiveConnection();
  461. [ Obsolete("not used", true)] void get_BOF(/*deleted parameters signature*/);
  462. [ Obsolete("not used", true)] void get_Bookmark(/*deleted parameters signature*/);
  463. [ Obsolete("not used", true)] void put_Bookmark(/*deleted parameters signature*/);
  464. [ Obsolete("not used", true)] void get_CacheSize(/*deleted parameters signature*/);
  465. [ Obsolete("not used", true)] void put_CacheSize(/*deleted parameters signature*/);
  466. [ Obsolete("not used", true)] void get_CursorType(/*deleted parameters signature*/);
  467. [ Obsolete("not used", true)] void put_CursorType(/*deleted parameters signature*/);
  468. [ Obsolete("not used", true)] void get_EOF(/*deleted parameters signature*/);
  469. [ Obsolete("not used", true)] void get_Fields(/*deleted parameters signature*/);
  470. [ Obsolete("not used", true)] void get_LockType(/*deleted parameters signature*/);
  471. [ Obsolete("not used", true)] void put_LockType(/*deleted parameters signature*/);
  472. [ Obsolete("not used", true)] void get_MaxRecords(/*deleted parameters signature*/);
  473. [ Obsolete("not used", true)] void put_MaxRecords(/*deleted parameters signature*/);
  474. [ Obsolete("not used", true)] void get_RecordCount(/*deleted parameters signature*/);
  475. [ Obsolete("not used", true)] void putref_Source(/*deleted parameters signature*/);
  476. [ Obsolete("not used", true)] void put_Source(/*deleted parameters signature*/);
  477. [ Obsolete("not used", true)] void get_Source(/*deleted parameters signature*/);
  478. [ Obsolete("not used", true)] void AddNew(/*deleted parameters signature*/);
  479. [ Obsolete("not used", true)] void CancelUpdate(/*deleted parameters signature*/);
  480. [PreserveSig] System.Data.OleDb.OleDbHResult Close();
  481. [ Obsolete("not used", true)] void Delete(/*deleted parameters signature*/);
  482. [ Obsolete("not used", true)] void GetRows(/*deleted parameters signature*/);
  483. [ Obsolete("not used", true)] void Move(/*deleted parameters signature*/);
  484. [ Obsolete("not used", true)] void MoveNext();
  485. [ Obsolete("not used", true)] void MovePrevious();
  486. [ Obsolete("not used", true)] void MoveFirst();
  487. [ Obsolete("not used", true)] void MoveLast();
  488. [ Obsolete("not used", true)] void Open(/*deleted parameters signature*/);
  489. [ Obsolete("not used", true)] void Requery(/*deleted parameters signature*/);
  490. [ Obsolete("not used", true)] void _xResync(/*deleted parameters signature*/);
  491. [ Obsolete("not used", true)] void Update(/*deleted parameters signature*/);
  492. [ Obsolete("not used", true)] void get_AbsolutePage(/*deleted parameters signature*/);
  493. [ Obsolete("not used", true)] void put_AbsolutePage(/*deleted parameters signature*/);
  494. [ Obsolete("not used", true)] void get_EditMode(/*deleted parameters signature*/);
  495. [ Obsolete("not used", true)] void get_Filter(/*deleted parameters signature*/);
  496. [ Obsolete("not used", true)] void put_Filter(/*deleted parameters signature*/);
  497. [ Obsolete("not used", true)] void get_PageCount(/*deleted parameters signature*/);
  498. [ Obsolete("not used", true)] void get_PageSize(/*deleted parameters signature*/);
  499. [ Obsolete("not used", true)] void put_PageSize(/*deleted parameters signature*/);
  500. [ Obsolete("not used", true)] void get_Sort(/*deleted parameters signature*/);
  501. [ Obsolete("not used", true)] void put_Sort(/*deleted parameters signature*/);
  502. [ Obsolete("not used", true)] void get_Status(/*deleted parameters signature*/);
  503. [ Obsolete("not used", true)] void get_State(/*deleted parameters signature*/);
  504. [ Obsolete("not used", true)] void _xClone(/*deleted parameters signature*/);
  505. [ Obsolete("not used", true)] void UpdateBatch(/*deleted parameters signature*/);
  506. [ Obsolete("not used", true)] void CancelBatch(/*deleted parameters signature*/);
  507. [ Obsolete("not used", true)] void get_CursorLocation(/*deleted parameters signature*/);
  508. [ Obsolete("not used", true)] void put_CursorLocation(/*deleted parameters signature*/);
  509. [PreserveSig] System.Data.OleDb.OleDbHResult NextRecordset(
  510. [Out]out object RecordsAffected,
  511. [Out, MarshalAs(UnmanagedType.Interface)] out object ppiRs);
  512. //[ Obsolete("not used", true)] void Supports(/*deleted parameters signature*/);
  513. //[ Obsolete("not used", true)] void get_Collect(/*deleted parameters signature*/);
  514. //[ Obsolete("not used", true)] void put_Collect(/*deleted parameters signature*/);
  515. //[ Obsolete("not used", true)] void get_MarshalOptions(/*deleted parameters signature*/);
  516. //[ Obsolete("not used", true)] void put_MarshalOptions(/*deleted parameters signature*/);
  517. //[ Obsolete("not used", true)] void Find(/*deleted parameters signature*/);
  518. }
  519. [Guid("00000562-0000-0010-8000-00AA006D2EA4"), InterfaceType(ComInterfaceType.InterfaceIsDual), ComImport, SuppressUnmanagedCodeSecurity]
  520. internal interface _ADORecord {
  521. [ Obsolete("not used", true)] void get_Properties(/*deleted parameters signature*/);
  522. /*[return:MarshalAs(UnmanagedType.Variant)]*/object get_ActiveConnection();
  523. [ Obsolete("not used", true)] void put_ActiveConnection(/*deleted parameters signature*/);
  524. [ Obsolete("not used", true)] void putref_ActiveConnection(/*deleted parameters signature*/);
  525. [ Obsolete("not used", true)] void get_State(/*deleted parameters signature*/);
  526. [ Obsolete("not used", true)] void get_Source(/*deleted parameters signature*/);
  527. [ Obsolete("not used", true)] void put_Source(/*deleted parameters signature*/);
  528. [ Obsolete("not used", true)] void putref_Source(/*deleted parameters signature*/);
  529. [ Obsolete("not used", true)] void get_Mode(/*deleted parameters signature*/);
  530. [ Obsolete("not used", true)] void put_Mode(/*deleted parameters signature*/);
  531. [ Obsolete("not used", true)] void get_ParentURL(/*deleted parameters signature*/);
  532. [ Obsolete("not used", true)] void MoveRecord(/*deleted parameters signature*/);
  533. [ Obsolete("not used", true)] void CopyRecord(/*deleted parameters signature*/);
  534. [ Obsolete("not used", true)] void DeleteRecord(/*deleted parameters signature*/);
  535. [ Obsolete("not used", true)] void Open(/*deleted parameters signature*/);
  536. [PreserveSig] System.Data.OleDb.OleDbHResult Close();
  537. //[ Obsolete("not used", true)] void get_Fields(/*deleted parameters signature*/);
  538. //[ Obsolete("not used", true)] void get_RecordType(/*deleted parameters signature*/);
  539. //[ Obsolete("not used", true)] void GetChildren(/*deleted parameters signature*/);
  540. //[ Obsolete("not used", true)] void Cancel();
  541. }
  542. /*
  543. typedef ULONGLONG DBLENGTH;
  544. // Offset within a rowset
  545. typedef LONGLONG DBROWOFFSET;
  546. // Number of rows
  547. typedef LONGLONG DBROWCOUNT;
  548. typedef ULONGLONG DBCOUNTITEM;
  549. // Ordinal (column number, etc.)
  550. typedef ULONGLONG DBORDINAL;
  551. typedef LONGLONG DB_LORDINAL;
  552. // Bookmarks
  553. typedef ULONGLONG DBBKMARK;
  554. // Offset in the buffer
  555. typedef ULONGLONG DBBYTEOFFSET;
  556. // Reference count of each row/accessor handle
  557. typedef ULONG DBREFCOUNT;
  558. // Parameters
  559. typedef ULONGLONG DB_UPARAMS;
  560. typedef LONGLONG DB_LPARAMS;
  561. // hash values corresponding to the elements (bookmarks)
  562. typedef DWORDLONG DBHASHVALUE;
  563. // For reserve
  564. typedef DWORDLONG DB_DWRESERVE;
  565. typedef LONGLONG DB_LRESERVE;
  566. typedef ULONGLONG DB_URESERVE;
  567. */
  568. [ComImport, Guid("0C733A8C-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), SuppressUnmanagedCodeSecurity]
  569. internal interface IAccessor {
  570. [ Obsolete("not used", true)] void AddRefAccessor(/*deleted parameters signature*/);
  571. /*[local]
  572. HRESULT CreateAccessor(
  573. [in] DBACCESSORFLAGS dwAccessorFlags,
  574. [in] DBCOUNTITEM cBindings,
  575. [in, size_is(cBindings)] const DBBINDING rgBindings[],
  576. [in] DBLENGTH cbRowSize,
  577. [out] HACCESSOR * phAccessor,
  578. [out, size_is(cBindings)] DBBINDSTATUS rgStatus[]
  579. );*/
  580. [PreserveSig] System.Data.OleDb.OleDbHResult CreateAccessor(
  581. [In] int dwAccessorFlags,
  582. [In] IntPtr cBindings,
  583. [In] /*tagDBBINDING[]*/SafeHandle rgBindings,
  584. [In] IntPtr cbRowSize,
  585. [Out] out IntPtr phAccessor,
  586. [In, Out, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.I4)] int[] rgStatus);
  587. [ Obsolete("not used", true)] void GetBindings(/*deleted parameters signature*/);
  588. /*[local]
  589. HRESULT ReleaseAccessor(
  590. [in] HACCESSOR hAccessor,
  591. [in, out, unique] DBREFCOUNT * pcRefCount
  592. );*/
  593. [PreserveSig] System.Data.OleDb.OleDbHResult ReleaseAccessor(
  594. [In] IntPtr hAccessor,
  595. [Out] out int pcRefCount);
  596. }
  597. [Guid("0C733A93-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  598. internal interface IChapteredRowset {
  599. [ Obsolete("not used", true)] void AddRefChapter(/*deleted parameters signature*/);
  600. /*[local]
  601. HRESULT ReleaseChapter(
  602. [in] HCHAPTER hChapter,
  603. [out] DBREFCOUNT * pcRefCount
  604. );*/
  605. [PreserveSig, ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] System.Data.OleDb.OleDbHResult ReleaseChapter(
  606. [In] IntPtr hChapter,
  607. [Out] out int pcRefCount);
  608. }
  609. [Guid("0C733A11-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  610. internal interface IColumnsInfo {
  611. /*[local]
  612. HRESULT GetColumnInfo(
  613. [in, out] DBORDINAL * pcColumns,
  614. [out, size_is(,(ULONG)*pcColumns)] DBCOLUMNINFO ** prgInfo,
  615. [out] OLECHAR ** ppStringsBuffer
  616. );*/
  617. [PreserveSig] System.Data.OleDb.OleDbHResult GetColumnInfo(
  618. [Out] out IntPtr pcColumns,
  619. [Out] out IntPtr prgInfo,
  620. [Out] out IntPtr ppStringsBuffer);
  621. //[PreserveSig]
  622. //int MapColumnIDs(/* deleted parameters*/);
  623. }
  624. [Guid("0C733A10-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  625. internal interface IColumnsRowset {
  626. /*[local]
  627. HRESULT GetAvailableColumns(
  628. [in, out] DBORDINAL * pcOptColumns,
  629. [out, size_is(,(ULONG)*pcOptColumns)] DBID ** prgOptColumns
  630. );*/
  631. [PreserveSig] System.Data.OleDb.OleDbHResult GetAvailableColumns(
  632. [Out] out IntPtr pcOptColumns,
  633. [Out] out IntPtr prgOptColumns);
  634. /*[local]
  635. HRESULT GetColumnsRowset(
  636. [in] IUnknown * pUnkOuter,
  637. [in] DBORDINAL cOptColumns,
  638. [in, size_is((ULONG)cOptColumns)] const DBID rgOptColumns[],
  639. [in] REFIID riid,
  640. [in] ULONG cPropertySets,
  641. [in, out, size_is((ULONG)cPropertySets)] DBPROPSET rgPropertySets[],
  642. [out, iid_is(riid)] IUnknown ** ppColRowset
  643. );*/
  644. [PreserveSig] System.Data.OleDb.OleDbHResult GetColumnsRowset(
  645. [In] IntPtr pUnkOuter,
  646. [In] IntPtr cOptColumns,
  647. [In] SafeHandle rgOptColumns,
  648. [In] ref Guid riid,
  649. [In] int cPropertySets,
  650. [In] IntPtr rgPropertySets,
  651. [Out, MarshalAs(UnmanagedType.Interface)] out IRowset ppColRowset);
  652. }
  653. [Guid("0C733A26-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  654. internal interface ICommandPrepare {
  655. /*[local]
  656. HRESULT Prepare(
  657. [in] ULONG cExpectedRuns
  658. );*/
  659. [PreserveSig] System.Data.OleDb.OleDbHResult Prepare(
  660. [In] int cExpectedRuns);
  661. //[PreserveSig]
  662. //int Unprepare();
  663. }
  664. [Guid("0C733A79-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  665. internal interface ICommandProperties {
  666. /*[local]
  667. HRESULT GetProperties(
  668. [in] const ULONG cPropertyIDSets,
  669. [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[],
  670. [in, out] ULONG * pcPropertySets,
  671. [out, size_is(,*pcPropertySets)] DBPROPSET ** prgPropertySets
  672. );*/
  673. [PreserveSig] System.Data.OleDb.OleDbHResult GetProperties(
  674. [In] int cPropertyIDSets,
  675. [In] SafeHandle rgPropertyIDSets,
  676. [Out] out int pcPropertySets,
  677. [Out] out IntPtr prgPropertySets);
  678. /*[local]
  679. HRESULT SetProperties(
  680. [in] ULONG cPropertySets,
  681. [in, out, unique, size_is(cPropertySets)] DBPROPSET rgPropertySets[]
  682. );*/
  683. [PreserveSig] System.Data.OleDb.OleDbHResult SetProperties(
  684. [In] int cPropertySets,
  685. [In] SafeHandle rgPropertySets);
  686. }
  687. [Guid("0C733A27-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  688. internal interface ICommandText {
  689. /*[local]
  690. HRESULT Cancel(
  691. );*/
  692. [PreserveSig] System.Data.OleDb.OleDbHResult Cancel();
  693. /*[local]
  694. HRESULT Execute(
  695. [in] IUnknown * pUnkOuter,
  696. [in] REFIID riid,
  697. [in, out] DBPARAMS * pParams,
  698. [out] DBROWCOUNT * pcRowsAffected,
  699. [out, iid_is(riid)] IUnknown ** ppRowset
  700. );*/
  701. [PreserveSig] System.Data.OleDb.OleDbHResult Execute(
  702. [In] IntPtr pUnkOuter,
  703. [In] ref Guid riid,
  704. [In] System.Data.OleDb.tagDBPARAMS pDBParams,
  705. [Out] out IntPtr pcRowsAffected,
  706. [Out, MarshalAs(UnmanagedType.Interface)] out object ppRowset);
  707. [ Obsolete("not used", true)] void GetDBSession(/*deleted parameter signature*/);
  708. [ Obsolete("not used", true)] void GetCommandText(/*deleted parameter signature*/);
  709. /*[local]
  710. HRESULT SetCommandText(
  711. [in] REFGUID rguidDialect,
  712. [in, unique] LPCOLESTR pwszCommand
  713. );*/
  714. [PreserveSig] System.Data.OleDb.OleDbHResult SetCommandText(
  715. [In] ref Guid rguidDialect,
  716. [In, MarshalAs(UnmanagedType.LPWStr)] string pwszCommand);
  717. }
  718. [Guid("0C733A64-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  719. internal interface ICommandWithParameters {
  720. [ Obsolete("not used", true)] void GetParameterInfo(/*deleted parameters signature*/);
  721. [ Obsolete("not used", true)] void MapParameterNames(/*deleted parameter signature*/);
  722. /*[local]
  723. HRESULT SetParameterInfo(
  724. [in] DB_UPARAMS cParams,
  725. [in, unique, size_is((ULONG)cParams)] const DB_UPARAMS rgParamOrdinals[],
  726. [in, unique, size_is((ULONG)cParams)] const DBPARAMBINDINFO rgParamBindInfo[]
  727. );*/
  728. [PreserveSig] System.Data.OleDb.OleDbHResult SetParameterInfo(
  729. [In] IntPtr cParams,
  730. [In, MarshalAs(UnmanagedType.LPArray)] IntPtr[] rgParamOrdinals,
  731. [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.Struct)] System.Data.OleDb.tagDBPARAMBINDINFO[] rgParamBindInfo);
  732. }
  733. [Guid("2206CCB1-19C1-11D1-89E0-00C04FD7A829"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  734. internal interface IDataInitialize {
  735. }
  736. [Guid("0C733A89-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  737. internal interface IDBInfo {
  738. /*[local]
  739. HRESULT GetKeywords(
  740. [out] LPOLESTR * ppwszKeywords
  741. );*/
  742. [PreserveSig] System.Data.OleDb.OleDbHResult GetKeywords(
  743. [Out, MarshalAs(UnmanagedType.LPWStr)] out string ppwszKeywords);
  744. /*[local]
  745. HRESULT GetLiteralInfo(
  746. [in] ULONG cLiterals,
  747. [in, size_is(cLiterals)] const DBLITERAL rgLiterals[],
  748. [in, out] ULONG * pcLiteralInfo,
  749. [out, size_is(,*pcLiteralInfo)] DBLITERALINFO ** prgLiteralInfo,
  750. [out] OLECHAR ** ppCharBuffer
  751. );*/
  752. [PreserveSig] System.Data.OleDb.OleDbHResult GetLiteralInfo(
  753. [In] int cLiterals,
  754. [In, MarshalAs(UnmanagedType.LPArray)] int[] rgLiterals,
  755. [Out] out int pcLiteralInfo,
  756. [Out] out IntPtr prgLiteralInfo,
  757. [Out] out IntPtr ppCharBuffer);
  758. }
  759. [Guid("0C733A8A-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  760. internal interface IDBProperties {
  761. /*[local]
  762. HRESULT GetProperties(
  763. [in] const ULONG cPropertyIDSets,
  764. [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[],
  765. [in, out] ULONG * pcPropertySets,
  766. [out, size_is(,*pcPropertySets)] DBPROPSET ** prgPropertySets
  767. );*/
  768. [PreserveSig] System.Data.OleDb.OleDbHResult GetProperties(
  769. [In] int cPropertyIDSets,
  770. [In] SafeHandle rgPropertyIDSets,
  771. [Out] out int pcPropertySets,
  772. [Out] out IntPtr prgPropertySets);
  773. [PreserveSig] System.Data.OleDb.OleDbHResult GetPropertyInfo(
  774. [In] int cPropertyIDSets,
  775. [In] SafeHandle rgPropertyIDSets,
  776. [Out] out int pcPropertySets,
  777. [Out] out IntPtr prgPropertyInfoSets,
  778. [Out] out IntPtr ppDescBuffer);
  779. [PreserveSig] System.Data.OleDb.OleDbHResult SetProperties(
  780. [In] int cPropertySets,
  781. [In] SafeHandle rgPropertySets);
  782. }
  783. [Guid("0C733A7B-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  784. internal interface IDBSchemaRowset {
  785. /*[local]
  786. HRESULT GetRowset(
  787. [in] IUnknown * pUnkOuter,
  788. [in] REFGUID rguidSchema,
  789. [in] ULONG cRestrictions,
  790. [in, size_is(cRestrictions)] const VARIANT rgRestrictions[],
  791. [in] REFIID riid,
  792. [in] ULONG cPropertySets,
  793. [in, out, unique, size_is(cPropertySets)] DBPROPSET rgPropertySets[],
  794. [out, iid_is(riid)] IUnknown ** ppRowset
  795. );*/
  796. [PreserveSig] System.Data.OleDb.OleDbHResult GetRowset(
  797. [In] IntPtr pUnkOuter,
  798. [In] ref Guid rguidSchema,
  799. [In] int cRestrictions,
  800. [In, MarshalAs(UnmanagedType.LPArray)] object[] rgRestrictions,
  801. [In] ref Guid riid,
  802. [In] int cPropertySets,
  803. [In] IntPtr rgPropertySets,
  804. [Out, MarshalAs(UnmanagedType.Interface)] out IRowset ppRowset);
  805. /*[local]
  806. HRESULT GetSchemas(
  807. [in, out] ULONG * pcSchemas,
  808. [out, size_is(,*pcSchemas)] GUID ** prgSchemas,
  809. [out, size_is(,*pcSchemas)] ULONG ** prgRestrictionSupport
  810. );*/
  811. [PreserveSig] System.Data.OleDb.OleDbHResult GetSchemas(
  812. [Out] out int pcSchemas,
  813. [Out] out IntPtr rguidSchema,
  814. [Out] out IntPtr prgRestrictionSupport);
  815. }
  816. [Guid("1CF2B120-547D-101B-8E65-08002B2BD119"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  817. internal interface IErrorInfo {
  818. [ Obsolete("not used", true)] void GetGUID(/*deleted parameter signature*/);
  819. [PreserveSig] System.Data.OleDb.OleDbHResult GetSource(
  820. [Out, MarshalAs(UnmanagedType.BStr)] out string pBstrSource);
  821. [PreserveSig] System.Data.OleDb.OleDbHResult GetDescription(
  822. [Out, MarshalAs(UnmanagedType.BStr)] out string pBstrDescription);
  823. //[ Obsolete("not used", true)] void GetHelpFile(/*deleted parameter signature*/);
  824. //[ Obsolete("not used", true)] void GetHelpContext(/*deleted parameter signature*/);
  825. }
  826. #if false
  827. MIDL_INTERFACE("1CF2B120-547D-101B-8E65-08002B2BD119")
  828. IErrorInfo : public IUnknown
  829. virtual HRESULT STDMETHODCALLTYPE GetGUID(
  830. /* [out] */ GUID *pGUID) = 0;
  831. virtual HRESULT STDMETHODCALLTYPE GetSource(
  832. /* [out] */ BSTR *pBstrSource) = 0;
  833. virtual HRESULT STDMETHODCALLTYPE GetDescription(
  834. /* [out] */ BSTR *pBstrDescription) = 0;
  835. virtual HRESULT STDMETHODCALLTYPE GetHelpFile(
  836. /* [out] */ BSTR *pBstrHelpFile) = 0;
  837. virtual HRESULT STDMETHODCALLTYPE GetHelpContext(
  838. /* [out] */ DWORD *pdwHelpContext) = 0;
  839. #endif
  840. [Guid("0C733A67-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  841. internal interface IErrorRecords {
  842. [ Obsolete("not used", true)] void AddErrorRecord(/*deleted parameter signature*/);
  843. [ Obsolete("not used", true)] void GetBasicErrorInfo(/*deleted parameter signature*/);
  844. [PreserveSig] System.Data.OleDb.OleDbHResult GetCustomErrorObject( // may return E_NOINTERFACE when asking for IID_ISQLErrorInfo
  845. [In] Int32 ulRecordNum,
  846. [In] ref Guid riid,
  847. [Out, MarshalAs(UnmanagedType.Interface)] out ISQLErrorInfo ppObject);
  848. [return:MarshalAs(UnmanagedType.Interface)] IErrorInfo GetErrorInfo(
  849. [In] Int32 ulRecordNum,
  850. [In] Int32 lcid);
  851. [ Obsolete("not used", true)] void GetErrorParameters(/*deleted parameter signature*/);
  852. Int32 GetRecordCount();
  853. }
  854. #if false
  855. MIDL_INTERFACE("0c733a67-2a1c-11ce-ade5-00aa0044773d")
  856. IErrorRecords : public IUnknown
  857. virtual /* [local] */ HRESULT STDMETHODCALLTYPE AddErrorRecord(
  858. /* [in] */ ERRORINFO *pErrorInfo,
  859. /* [in] */ DWORD dwLookupID,
  860. /* [in] */ DISPPARAMS *pdispparams,
  861. /* [in] */ IUnknown *punkCustomError,
  862. /* [in] */ DWORD dwDynamicErrorID) = 0;
  863. virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetBasicErrorInfo(
  864. /* [in] */ ULONG ulRecordNum,
  865. /* [out] */ ERRORINFO *pErrorInfo) = 0;
  866. virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetCustomErrorObject(
  867. /* [in] */ ULONG ulRecordNum,
  868. /* [in] */ REFIID riid,
  869. /* [iid_is][out] */ IUnknown **ppObject) = 0;
  870. virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetErrorInfo(
  871. /* [in] */ ULONG ulRecordNum,
  872. /* [in] */ LCID lcid,
  873. /* [out] */ IErrorInfo **ppErrorInfo) = 0;
  874. virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetErrorParameters(
  875. /* [in] */ ULONG ulRecordNum,
  876. /* [out] */ DISPPARAMS *pdispparams) = 0;
  877. virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetRecordCount(
  878. /* [out] */ ULONG *pcRecords) = 0;
  879. #endif
  880. [Guid("0C733A90-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  881. internal interface IMultipleResults {
  882. /*[local]
  883. HRESULT GetResult(
  884. [in] IUnknown * pUnkOuter,
  885. [in] DBRESULTFLAG lResultFlag,
  886. [in] REFIID riid,
  887. [out] DBROWCOUNT * pcRowsAffected,
  888. [out, iid_is(riid)] IUnknown ** ppRowset
  889. );*/
  890. [PreserveSig] System.Data.OleDb.OleDbHResult GetResult(
  891. [In] IntPtr pUnkOuter,
  892. [In] IntPtr lResultFlag,
  893. [In] ref Guid riid,
  894. [Out] out IntPtr pcRowsAffected,
  895. [Out, MarshalAs(UnmanagedType.Interface)] out object ppRowset);
  896. }
  897. #if false
  898. enum DBRESULTFLAGENUM {
  899. DBRESULTFLAG_DEFAULT = 0,
  900. DBRESULTFLAG_ROWSET = 1,
  901. DBRESULTFLAG_ROW = 2
  902. }
  903. MIDL_INTERFACE("0c733a90-2a1c-11ce-ade5-00aa0044773d")
  904. IMultipleResults : public IUnknown
  905. virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetResult(
  906. /* [in] */ IUnknown *pUnkOuter,
  907. /* [in] */ DBRESULTFLAG lResultFlag,
  908. /* [in] */ REFIID riid,
  909. /* [out] */ DBROWCOUNT *pcRowsAffected,
  910. /* [iid_is][out] */ IUnknown **ppRowset) = 0;
  911. #endif
  912. [Guid("0C733A69-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  913. internal interface IOpenRowset {
  914. [PreserveSig] System.Data.OleDb.OleDbHResult OpenRowset(
  915. [In] IntPtr pUnkOuter,
  916. [In] System.Data.OleDb.tagDBID pTableID,
  917. [In] IntPtr pIndexID,
  918. [In] ref Guid riid,
  919. [In] int cPropertySets,
  920. [In] IntPtr rgPropertySets,
  921. [Out, MarshalAs(UnmanagedType.Interface)] out object ppRowset);
  922. }
  923. [Guid("0C733AB4-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  924. internal interface IRow {
  925. [PreserveSig] System.Data.OleDb.OleDbHResult GetColumns(
  926. [In] IntPtr cColumns,
  927. [In, Out, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.Struct)] System.Data.OleDb.tagDBCOLUMNACCESS[] rgColumns);
  928. //[ Obsolete("not used", true)] void GetSourceRowset(/*deleted parameter signature*/);
  929. //[ Obsolete("not used", true)] void Open(/*deleted parameter signature*/);
  930. }
  931. [Guid("0C733A7C-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  932. internal interface IRowset {
  933. [ Obsolete("not used", true)] void AddRefRows(/*deleted parameter signature*/);
  934. /*HRESULT GetData(
  935. [in] HROW hRow,
  936. [in] HACCESSOR hAccessor,
  937. [out] void * pData
  938. );*/
  939. [PreserveSig] System.Data.OleDb.OleDbHResult GetData(
  940. [In] IntPtr hRow,
  941. [In] IntPtr hAccessor,
  942. [In] IntPtr pData);
  943. /*HRESULT GetNextRows(
  944. [in] HCHAPTER hReserved,
  945. [in] DBROWOFFSET lRowsOffset,
  946. [in] DBROWCOUNT cRows,
  947. [out] DBCOUNTITEM * pcRowsObtained,
  948. [out, size_is(,cRows)] HROW ** prghRows
  949. );*/
  950. [PreserveSig] System.Data.OleDb.OleDbHResult GetNextRows(
  951. [In] IntPtr hChapter,
  952. [In] IntPtr lRowsOffset,
  953. [In] IntPtr cRows,
  954. [Out] out IntPtr pcRowsObtained,
  955. [In] ref IntPtr pprghRows);
  956. /*HRESULT ReleaseRows(
  957. [in] DBCOUNTITEM cRows,
  958. [in, size_is(cRows)] const HROW rghRows[],
  959. [in, size_is(cRows)] DBROWOPTIONS rgRowOptions[],
  960. [out, size_is(cRows)] DBREFCOUNT rgRefCounts[],
  961. [out, size_is(cRows)] DBROWSTATUS rgRowStatus[]
  962. );*/
  963. [PreserveSig] System.Data.OleDb.OleDbHResult ReleaseRows(
  964. [In] IntPtr cRows,
  965. [In] SafeHandle rghRows,
  966. [In/*, MarshalAs(UnmanagedType.LPArray)*/] IntPtr/*int[]*/ rgRowOptions,
  967. [In/*, Out, MarshalAs(UnmanagedType.LPArray)*/] IntPtr/*int[]*/ rgRefCounts,
  968. [In/*, Out, MarshalAs(UnmanagedType.LPArray)*/] IntPtr/*int[]*/ rgRowStatus);
  969. [ Obsolete("not used", true)] void RestartPosition(/*deleted parameter signature*/);
  970. }
  971. [Guid("0C733A55-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  972. internal interface IRowsetInfo {
  973. /*[local]
  974. HRESULT GetProperties(
  975. [in] const ULONG cPropertyIDSets,
  976. [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[],
  977. [in, out] ULONG * pcPropertySets,
  978. [out, size_is(,*pcPropertySets)] DBPROPSET ** prgPropertySets
  979. );*/
  980. [PreserveSig] System.Data.OleDb.OleDbHResult GetProperties(
  981. [In] int cPropertyIDSets,
  982. [In] SafeHandle rgPropertyIDSets,
  983. [Out] out int pcPropertySets,
  984. [Out] out IntPtr prgPropertySets);
  985. [PreserveSig] System.Data.OleDb.OleDbHResult GetReferencedRowset(
  986. [In] IntPtr iOrdinal,
  987. [In] ref Guid riid,
  988. [Out, MarshalAs(UnmanagedType.Interface)] out IRowset ppRowset);
  989. //[PreserveSig]
  990. //int GetSpecification(/*deleted parameter signature*/);
  991. }
  992. [Guid("0C733A74-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  993. internal interface ISQLErrorInfo {
  994. [return:MarshalAs(UnmanagedType.I4)] Int32 GetSQLInfo(
  995. [Out, MarshalAs(UnmanagedType.BStr)] out String pbstrSQLState);
  996. }
  997. [Guid("0C733A5F-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
  998. internal interface ITransactionLocal {
  999. [ Obsolete("not used", true)] void Commit(/*deleted parameter signature*/);
  1000. [ Obsolete("not used", true)] void Abort(/*deleted parameter signature*/);
  1001. [ Obsolete("not used", true)] void GetTransactionInfo(/*deleted parameter signature*/);
  1002. [ Obsolete("not used", true)] void GetOptionsObject(/*deleted parameter signature*/);
  1003. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
  1004. [PreserveSig] System.Data.OleDb.OleDbHResult StartTransaction(
  1005. [In] int isoLevel,
  1006. [In] int isoFlags,
  1007. [In] IntPtr pOtherOptions,
  1008. [Out] out int pulTransactionLevel);
  1009. }
  1010. // we wrap the vtable entry which is just a function pointer as a delegate
  1011. // since code (unlike data) doesn't move around within the process, it is safe to cache the delegate
  1012. // we do not expect native to change its vtable entry at run-time (especially since these are free-threaded objects)
  1013. // however to be extra safe double check the function pointer is the same as the cached delegate
  1014. // whenever we encounter a new instance of the data
  1015. // dangerous delegate around IUnknown::QueryInterface (0th vtable entry)
  1016. [System.Security.SuppressUnmanagedCodeSecurityAttribute()]
  1017. internal delegate int IUnknownQueryInterface(
  1018. IntPtr pThis,
  1019. ref Guid riid,
  1020. ref IntPtr ppInterface);
  1021. // dangerous delegate around IDataInitialize::GetDataSource (4th vtable entry)
  1022. [System.Security.SuppressUnmanagedCodeSecurityAttribute()]
  1023. internal delegate System.Data.OleDb.OleDbHResult IDataInitializeGetDataSource(
  1024. IntPtr pThis, // first parameter is always the 'this' value, must use use result from QI
  1025. IntPtr pUnkOuter,
  1026. int dwClsCtx,
  1027. [MarshalAs(UnmanagedType.LPWStr)] string pwszInitializationString,
  1028. ref Guid riid,
  1029. ref System.Data.OleDb.DataSourceWrapper ppDataSource);
  1030. // dangerous wrapper around IDBInitialize::Initialize (4th vtable entry)
  1031. [System.Security.SuppressUnmanagedCodeSecurityAttribute()]
  1032. internal delegate System.Data.OleDb.OleDbHResult IDBInitializeInitialize(
  1033. IntPtr pThis); // first parameter is always the 'this' value, must use use result from QI
  1034. // dangerous wrapper around IDBCreateSession::CreateSession (4th vtable entry)
  1035. [System.Security.SuppressUnmanagedCodeSecurityAttribute()]
  1036. internal delegate System.Data.OleDb.OleDbHResult IDBCreateSessionCreateSession(
  1037. IntPtr pThis, // first parameter is always the 'this' value, must use use result from QI
  1038. IntPtr pUnkOuter,
  1039. ref Guid riid,
  1040. ref System.Data.OleDb.SessionWrapper ppDBSession);
  1041. // dangerous wrapper around IDBCreateCommand::CreateCommand (4th vtable entry)
  1042. [System.Security.SuppressUnmanagedCodeSecurityAttribute()]
  1043. internal delegate System.Data.OleDb.OleDbHResult IDBCreateCommandCreateCommand(
  1044. IntPtr pThis, // first parameter is always the 'this' value, must use use result from QI
  1045. IntPtr pUnkOuter,
  1046. ref Guid riid,
  1047. [MarshalAs(UnmanagedType.Interface)] ref object ppCommand);
  1048. #endif
  1049. //
  1050. // Advapi32.dll Integrated security functions
  1051. //
  1052. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
  1053. internal struct Trustee {
  1054. internal IntPtr _pMultipleTrustee; // PTRUSTEE
  1055. internal int _MultipleTrusteeOperation; // MULTIPLE_TRUSTEE_OPERATION
  1056. internal int _TrusteeForm; // TRUSTEE_FORM
  1057. internal int _TrusteeType; // TRUSTEE_TYPE
  1058. [MarshalAs(UnmanagedType.LPTStr)]
  1059. internal string _name;
  1060. internal Trustee(string name) {
  1061. _pMultipleTrustee = IntPtr.Zero;
  1062. _MultipleTrusteeOperation = 0; // NO_MULTIPLE_TRUSTEE
  1063. _TrusteeForm = 1; // TRUSTEE_IS_NAME
  1064. _TrusteeType = 1; // TRUSTEE_IS_USER
  1065. _name = name;
  1066. }
  1067. }
  1068. [DllImport(ExternDll.Advapi32, CharSet=CharSet.Unicode)]
  1069. [ResourceExposure(ResourceScope.None)]
  1070. static internal extern uint GetEffectiveRightsFromAclW (byte[] pAcl, ref Trustee pTrustee, out uint pAccessMask);
  1071. [DllImport(ExternDll.Advapi32, SetLastError=true)]
  1072. [ResourceExposure(ResourceScope.None)]
  1073. [return:MarshalAs(UnmanagedType.Bool)]
  1074. static internal extern bool CheckTokenMembership (IntPtr tokenHandle, byte[] sidToCheck, out bool isMember);
  1075. [DllImport(ExternDll.Advapi32, SetLastError=true)]
  1076. [ResourceExposure(ResourceScope.None)]
  1077. [return:MarshalAs(UnmanagedType.Bool)]
  1078. static internal extern bool ConvertSidToStringSidW(IntPtr sid, out IntPtr stringSid);
  1079. [DllImport(ExternDll.Advapi32, EntryPoint="CreateWellKnownSid", SetLastError=true, CharSet=CharSet.Unicode)]
  1080. [ResourceExposure(ResourceScope.None)]
  1081. static internal extern int CreateWellKnownSid(
  1082. int sidType,
  1083. byte[] domainSid,
  1084. [Out] byte[] resultSid,
  1085. ref uint resultSidLength );
  1086. [DllImport(ExternDll.Advapi32, SetLastError=true)]
  1087. [ResourceExposure(ResourceScope.None)]
  1088. [return:MarshalAs(UnmanagedType.Bool)]
  1089. static internal extern bool GetTokenInformation(IntPtr tokenHandle, uint token_class, IntPtr tokenStruct, uint tokenInformationLength, ref uint tokenString);
  1090. [DllImport(ExternDll.Kernel32, CharSet=CharSet.Unicode)]
  1091. [ResourceExposure(ResourceScope.None)]
  1092. internal static extern int lstrlenW(IntPtr ptr);
  1093. /* For debugging purposes...
  1094. [DllImport(ExternDll.Advapi32)]
  1095. [return:MarshalAs(UnmanagedType.I4)]
  1096. static internal extern int GetLengthSid(IntPtr sid1);
  1097. */
  1098. }
  1099. }