diff options
author | Rob Mensching <rob@firegiant.com> | 2022-08-29 13:13:43 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-08-29 16:03:27 -0700 |
commit | a5f672ec734df2bbc7559e5192f6c10d273215e1 (patch) | |
tree | 24b5c892e1dd029169eaaef722db021930544b8c /src | |
parent | 3e0e54aff605da9c5ec6c02f7e83d5e816c857a2 (diff) | |
download | wix-a5f672ec734df2bbc7559e5192f6c10d273215e1.tar.gz wix-a5f672ec734df2bbc7559e5192f6c10d273215e1.tar.bz2 wix-a5f672ec734df2bbc7559e5192f6c10d273215e1.zip |
Use IntPtr for pointers to handles
This is arguably more correct than raw uints.
Diffstat (limited to 'src')
-rw-r--r-- | src/wix/WixToolset.Core.Native/Msi/Database.cs | 2 | ||||
-rw-r--r-- | src/wix/WixToolset.Core.Native/Msi/MsiException.cs | 4 | ||||
-rw-r--r-- | src/wix/WixToolset.Core.Native/Msi/MsiHandle.cs | 8 | ||||
-rw-r--r-- | src/wix/WixToolset.Core.Native/Msi/MsiInterop.cs | 60 | ||||
-rw-r--r-- | src/wix/WixToolset.Core.Native/Msi/Record.cs | 4 | ||||
-rw-r--r-- | src/wix/WixToolset.Core.Native/Msi/Session.cs | 4 | ||||
-rw-r--r-- | src/wix/WixToolset.Core.Native/Msi/SummaryInformation.cs | 6 | ||||
-rw-r--r-- | src/wix/WixToolset.Core.Native/Msi/View.cs | 2 |
8 files changed, 44 insertions, 46 deletions
diff --git a/src/wix/WixToolset.Core.Native/Msi/Database.cs b/src/wix/WixToolset.Core.Native/Msi/Database.cs index b9c5c35b..18e5066d 100644 --- a/src/wix/WixToolset.Core.Native/Msi/Database.cs +++ b/src/wix/WixToolset.Core.Native/Msi/Database.cs | |||
@@ -20,7 +20,7 @@ namespace WixToolset.Core.Native.Msi | |||
20 | /// <param name="type">Persist mode to use when opening the database.</param> | 20 | /// <param name="type">Persist mode to use when opening the database.</param> |
21 | public Database(string path, OpenDatabase type) | 21 | public Database(string path, OpenDatabase type) |
22 | { | 22 | { |
23 | var error = MsiInterop.MsiOpenDatabase(path, new IntPtr((int)type), out var handle); | 23 | var error = MsiInterop.MsiOpenDatabase(path, (IntPtr)type, out var handle); |
24 | if (0 != error) | 24 | if (0 != error) |
25 | { | 25 | { |
26 | throw new MsiException(error); | 26 | throw new MsiException(error); |
diff --git a/src/wix/WixToolset.Core.Native/Msi/MsiException.cs b/src/wix/WixToolset.Core.Native/Msi/MsiException.cs index 07c83d81..218d2a7c 100644 --- a/src/wix/WixToolset.Core.Native/Msi/MsiException.cs +++ b/src/wix/WixToolset.Core.Native/Msi/MsiException.cs | |||
@@ -17,8 +17,8 @@ namespace WixToolset.Core.Native.Msi | |||
17 | /// <param name="error">The error code from the MsiXxx() function call.</param> | 17 | /// <param name="error">The error code from the MsiXxx() function call.</param> |
18 | public MsiException(int error) : base(error) | 18 | public MsiException(int error) : base(error) |
19 | { | 19 | { |
20 | uint handle = MsiInterop.MsiGetLastErrorRecord(); | 20 | IntPtr handle = MsiInterop.MsiGetLastErrorRecord(); |
21 | if (0 != handle) | 21 | if (IntPtr.Zero != handle) |
22 | { | 22 | { |
23 | using (Record record = new Record(handle)) | 23 | using (Record record = new Record(handle)) |
24 | { | 24 | { |
diff --git a/src/wix/WixToolset.Core.Native/Msi/MsiHandle.cs b/src/wix/WixToolset.Core.Native/Msi/MsiHandle.cs index dc2ce605..0bfd555c 100644 --- a/src/wix/WixToolset.Core.Native/Msi/MsiHandle.cs +++ b/src/wix/WixToolset.Core.Native/Msi/MsiHandle.cs | |||
@@ -15,7 +15,7 @@ namespace WixToolset.Core.Native.Msi | |||
15 | public abstract class MsiHandle : IDisposable | 15 | public abstract class MsiHandle : IDisposable |
16 | { | 16 | { |
17 | private bool disposed; | 17 | private bool disposed; |
18 | private uint handle; | 18 | private IntPtr handle; |
19 | private int owningThread; | 19 | private int owningThread; |
20 | #if DEBUG | 20 | #if DEBUG |
21 | private string creationStack; | 21 | private string creationStack; |
@@ -33,7 +33,7 @@ namespace WixToolset.Core.Native.Msi | |||
33 | /// Gets or sets the MSI handle. | 33 | /// Gets or sets the MSI handle. |
34 | /// </summary> | 34 | /// </summary> |
35 | /// <value>The MSI handle.</value> | 35 | /// <value>The MSI handle.</value> |
36 | internal uint Handle | 36 | internal IntPtr Handle |
37 | { | 37 | { |
38 | get | 38 | get |
39 | { | 39 | { |
@@ -85,7 +85,7 @@ namespace WixToolset.Core.Native.Msi | |||
85 | { | 85 | { |
86 | if (!this.disposed) | 86 | if (!this.disposed) |
87 | { | 87 | { |
88 | if (0 != this.handle) | 88 | if (IntPtr.Zero != this.handle) |
89 | { | 89 | { |
90 | if (Thread.CurrentThread.ManagedThreadId == this.owningThread) | 90 | if (Thread.CurrentThread.ManagedThreadId == this.owningThread) |
91 | { | 91 | { |
@@ -94,7 +94,7 @@ namespace WixToolset.Core.Native.Msi | |||
94 | { | 94 | { |
95 | throw new Win32Exception(error); | 95 | throw new Win32Exception(error); |
96 | } | 96 | } |
97 | this.handle = 0; | 97 | this.handle = IntPtr.Zero; |
98 | } | 98 | } |
99 | else | 99 | else |
100 | { | 100 | { |
diff --git a/src/wix/WixToolset.Core.Native/Msi/MsiInterop.cs b/src/wix/WixToolset.Core.Native/Msi/MsiInterop.cs index 11ac4094..4df28ed6 100644 --- a/src/wix/WixToolset.Core.Native/Msi/MsiInterop.cs +++ b/src/wix/WixToolset.Core.Native/Msi/MsiInterop.cs | |||
@@ -56,7 +56,7 @@ namespace WixToolset.Core.Native.Msi | |||
56 | /// <param name="database">Handle to a database.</param> | 56 | /// <param name="database">Handle to a database.</param> |
57 | /// <returns>Error code.</returns> | 57 | /// <returns>Error code.</returns> |
58 | [DllImport("msi.dll", EntryPoint = "MsiCloseHandle", CharSet = CharSet.Unicode, ExactSpelling = true)] | 58 | [DllImport("msi.dll", EntryPoint = "MsiCloseHandle", CharSet = CharSet.Unicode, ExactSpelling = true)] |
59 | internal static extern int MsiCloseHandle(uint database); | 59 | internal static extern int MsiCloseHandle(IntPtr database); |
60 | 60 | ||
61 | /// <summary> | 61 | /// <summary> |
62 | /// PInvoke of MsiCreateRecord | 62 | /// PInvoke of MsiCreateRecord |
@@ -64,7 +64,7 @@ namespace WixToolset.Core.Native.Msi | |||
64 | /// <param name="parameters">Count of columns in the record.</param> | 64 | /// <param name="parameters">Count of columns in the record.</param> |
65 | /// <returns>Handle referencing the record.</returns> | 65 | /// <returns>Handle referencing the record.</returns> |
66 | [DllImport("msi.dll", EntryPoint = "MsiCreateRecord", CharSet = CharSet.Unicode, ExactSpelling = true)] | 66 | [DllImport("msi.dll", EntryPoint = "MsiCreateRecord", CharSet = CharSet.Unicode, ExactSpelling = true)] |
67 | internal static extern uint MsiCreateRecord(int parameters); | 67 | internal static extern IntPtr MsiCreateRecord(int parameters); |
68 | 68 | ||
69 | /// <summary> | 69 | /// <summary> |
70 | /// Creates summary information of an existing transform to include validation and error conditions. | 70 | /// Creates summary information of an existing transform to include validation and error conditions. |
@@ -76,7 +76,7 @@ namespace WixToolset.Core.Native.Msi | |||
76 | /// <param name="validations">Specifies the properties to be validated to verify that the transform can be applied to the database.</param> | 76 | /// <param name="validations">Specifies the properties to be validated to verify that the transform can be applied to the database.</param> |
77 | /// <returns>Error code.</returns> | 77 | /// <returns>Error code.</returns> |
78 | [DllImport("msi.dll", EntryPoint = "MsiCreateTransformSummaryInfoW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 78 | [DllImport("msi.dll", EntryPoint = "MsiCreateTransformSummaryInfoW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
79 | internal static extern int MsiCreateTransformSummaryInfo(uint database, uint referenceDatabase, string transformFile, TransformErrorConditions errorConditions, TransformValidations validations); | 79 | internal static extern int MsiCreateTransformSummaryInfo(IntPtr database, IntPtr referenceDatabase, string transformFile, TransformErrorConditions errorConditions, TransformValidations validations); |
80 | 80 | ||
81 | /// <summary> | 81 | /// <summary> |
82 | /// Applies a transform to a database. | 82 | /// Applies a transform to a database. |
@@ -86,7 +86,7 @@ namespace WixToolset.Core.Native.Msi | |||
86 | /// <param name="errorConditions">Error conditions that should be suppressed.</param> | 86 | /// <param name="errorConditions">Error conditions that should be suppressed.</param> |
87 | /// <returns>Error code.</returns> | 87 | /// <returns>Error code.</returns> |
88 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseApplyTransformW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 88 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseApplyTransformW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
89 | internal static extern int MsiDatabaseApplyTransform(uint database, string transformFile, TransformErrorConditions errorConditions); | 89 | internal static extern int MsiDatabaseApplyTransform(IntPtr database, string transformFile, TransformErrorConditions errorConditions); |
90 | 90 | ||
91 | /// <summary> | 91 | /// <summary> |
92 | /// PInvoke of MsiDatabaseCommit. | 92 | /// PInvoke of MsiDatabaseCommit. |
@@ -94,7 +94,7 @@ namespace WixToolset.Core.Native.Msi | |||
94 | /// <param name="database">Handle to a databse.</param> | 94 | /// <param name="database">Handle to a databse.</param> |
95 | /// <returns>Error code.</returns> | 95 | /// <returns>Error code.</returns> |
96 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseCommit", CharSet = CharSet.Unicode, ExactSpelling = true)] | 96 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseCommit", CharSet = CharSet.Unicode, ExactSpelling = true)] |
97 | internal static extern int MsiDatabaseCommit(uint database); | 97 | internal static extern int MsiDatabaseCommit(IntPtr database); |
98 | 98 | ||
99 | /// <summary> | 99 | /// <summary> |
100 | /// PInvoke of MsiDatabaseExportW. | 100 | /// PInvoke of MsiDatabaseExportW. |
@@ -105,7 +105,7 @@ namespace WixToolset.Core.Native.Msi | |||
105 | /// <param name="fileName">File name.</param> | 105 | /// <param name="fileName">File name.</param> |
106 | /// <returns>Error code.</returns> | 106 | /// <returns>Error code.</returns> |
107 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseExportW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 107 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseExportW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
108 | internal static extern int MsiDatabaseExport(uint database, string tableName, string folderPath, string fileName); | 108 | internal static extern int MsiDatabaseExport(IntPtr database, string tableName, string folderPath, string fileName); |
109 | 109 | ||
110 | /// <summary> | 110 | /// <summary> |
111 | /// Generates a transform file of differences between two databases. | 111 | /// Generates a transform file of differences between two databases. |
@@ -120,7 +120,7 @@ namespace WixToolset.Core.Native.Msi | |||
120 | /// <param name="reserved2">This is a reserved argument and must be set to 0.</param> | 120 | /// <param name="reserved2">This is a reserved argument and must be set to 0.</param> |
121 | /// <returns>Error code.</returns> | 121 | /// <returns>Error code.</returns> |
122 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseGenerateTransformW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 122 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseGenerateTransformW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
123 | internal static extern int MsiDatabaseGenerateTransform(uint database, uint databaseReference, string transformFile, int reserved1, int reserved2); | 123 | internal static extern int MsiDatabaseGenerateTransform(IntPtr database, IntPtr databaseReference, string transformFile, int reserved1, int reserved2); |
124 | 124 | ||
125 | /// <summary> | 125 | /// <summary> |
126 | /// PInvoke of MsiDatabaseImportW. | 126 | /// PInvoke of MsiDatabaseImportW. |
@@ -130,7 +130,7 @@ namespace WixToolset.Core.Native.Msi | |||
130 | /// <param name="fileName">File name.</param> | 130 | /// <param name="fileName">File name.</param> |
131 | /// <returns>Error code.</returns> | 131 | /// <returns>Error code.</returns> |
132 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseImportW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 132 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseImportW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
133 | internal static extern int MsiDatabaseImport(uint database, string folderPath, string fileName); | 133 | internal static extern int MsiDatabaseImport(IntPtr database, string folderPath, string fileName); |
134 | 134 | ||
135 | /// <summary> | 135 | /// <summary> |
136 | /// PInvoke of MsiDatabaseMergeW. | 136 | /// PInvoke of MsiDatabaseMergeW. |
@@ -140,7 +140,7 @@ namespace WixToolset.Core.Native.Msi | |||
140 | /// <param name="tableName">The name of the table to receive merge conflict information.</param> | 140 | /// <param name="tableName">The name of the table to receive merge conflict information.</param> |
141 | /// <returns>Error code.</returns> | 141 | /// <returns>Error code.</returns> |
142 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseMergeW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 142 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseMergeW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
143 | internal static extern int MsiDatabaseMerge(uint database, uint databaseMerge, string tableName); | 143 | internal static extern int MsiDatabaseMerge(IntPtr database, IntPtr databaseMerge, string tableName); |
144 | 144 | ||
145 | /// <summary> | 145 | /// <summary> |
146 | /// PInvoke of MsiDatabaseOpenViewW. | 146 | /// PInvoke of MsiDatabaseOpenViewW. |
@@ -150,7 +150,7 @@ namespace WixToolset.Core.Native.Msi | |||
150 | /// <param name="view">View handle.</param> | 150 | /// <param name="view">View handle.</param> |
151 | /// <returns>Error code.</returns> | 151 | /// <returns>Error code.</returns> |
152 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseOpenViewW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 152 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseOpenViewW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
153 | internal static extern int MsiDatabaseOpenView(uint database, string query, out uint view); | 153 | internal static extern int MsiDatabaseOpenView(IntPtr database, string query, out IntPtr view); |
154 | 154 | ||
155 | /// <summary> | 155 | /// <summary> |
156 | /// PInvoke of MsiExtractPatchXMLDataW. | 156 | /// PInvoke of MsiExtractPatchXMLDataW. |
@@ -190,7 +190,7 @@ namespace WixToolset.Core.Native.Msi | |||
190 | /// </summary> | 190 | /// </summary> |
191 | /// <returns>Handle to error record if one exists.</returns> | 191 | /// <returns>Handle to error record if one exists.</returns> |
192 | [DllImport("msi.dll", EntryPoint = "MsiGetLastErrorRecord", CharSet = CharSet.Unicode, ExactSpelling = true)] | 192 | [DllImport("msi.dll", EntryPoint = "MsiGetLastErrorRecord", CharSet = CharSet.Unicode, ExactSpelling = true)] |
193 | internal static extern uint MsiGetLastErrorRecord(); | 193 | internal static extern IntPtr MsiGetLastErrorRecord(); |
194 | 194 | ||
195 | /// <summary> | 195 | /// <summary> |
196 | /// PInvoke of MsiDatabaseGetPrimaryKeysW. | 196 | /// PInvoke of MsiDatabaseGetPrimaryKeysW. |
@@ -200,7 +200,7 @@ namespace WixToolset.Core.Native.Msi | |||
200 | /// <param name="record">Handle to receive resulting record.</param> | 200 | /// <param name="record">Handle to receive resulting record.</param> |
201 | /// <returns>Error code.</returns> | 201 | /// <returns>Error code.</returns> |
202 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseGetPrimaryKeysW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 202 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseGetPrimaryKeysW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
203 | internal static extern int MsiDatabaseGetPrimaryKeys(uint database, string tableName, out uint record); | 203 | internal static extern int MsiDatabaseGetPrimaryKeys(IntPtr database, string tableName, out IntPtr record); |
204 | 204 | ||
205 | /// <summary> | 205 | /// <summary> |
206 | /// PInvoke of MsiDoActionW. | 206 | /// PInvoke of MsiDoActionW. |
@@ -210,7 +210,7 @@ namespace WixToolset.Core.Native.Msi | |||
210 | /// <param name="action">Specifies the action to execute.</param> | 210 | /// <param name="action">Specifies the action to execute.</param> |
211 | /// <returns>Error code.</returns> | 211 | /// <returns>Error code.</returns> |
212 | [DllImport("msi.dll", EntryPoint = "MsiDoActionW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 212 | [DllImport("msi.dll", EntryPoint = "MsiDoActionW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
213 | internal static extern int MsiDoAction(uint product, string action); | 213 | internal static extern int MsiDoAction(IntPtr product, string action); |
214 | 214 | ||
215 | /// <summary> | 215 | /// <summary> |
216 | /// PInvoke of MsiGetSummaryInformationW. Can use either database handle or database path as input. | 216 | /// PInvoke of MsiGetSummaryInformationW. Can use either database handle or database path as input. |
@@ -221,7 +221,7 @@ namespace WixToolset.Core.Native.Msi | |||
221 | /// <param name="summaryInfo">Handle to summary information.</param> | 221 | /// <param name="summaryInfo">Handle to summary information.</param> |
222 | /// <returns>Error code.</returns> | 222 | /// <returns>Error code.</returns> |
223 | [DllImport("msi.dll", EntryPoint = "MsiGetSummaryInformationW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 223 | [DllImport("msi.dll", EntryPoint = "MsiGetSummaryInformationW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
224 | internal static extern int MsiGetSummaryInformation(uint database, string databasePath, uint updateCount, ref uint summaryInfo); | 224 | internal static extern int MsiGetSummaryInformation(IntPtr database, string databasePath, uint updateCount, ref IntPtr summaryInfo); |
225 | 225 | ||
226 | /// <summary> | 226 | /// <summary> |
227 | /// PInvoke of MsiDatabaseIsTablePersitentW. | 227 | /// PInvoke of MsiDatabaseIsTablePersitentW. |
@@ -230,7 +230,7 @@ namespace WixToolset.Core.Native.Msi | |||
230 | /// <param name="tableName">Table name.</param> | 230 | /// <param name="tableName">Table name.</param> |
231 | /// <returns>MSICONDITION</returns> | 231 | /// <returns>MSICONDITION</returns> |
232 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseIsTablePersistentW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 232 | [DllImport("msi.dll", EntryPoint = "MsiDatabaseIsTablePersistentW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
233 | internal static extern int MsiDatabaseIsTablePersistent(uint database, string tableName); | 233 | internal static extern int MsiDatabaseIsTablePersistent(IntPtr database, string tableName); |
234 | 234 | ||
235 | /// <summary> | 235 | /// <summary> |
236 | /// PInvoke of MsiOpenDatabaseW. | 236 | /// PInvoke of MsiOpenDatabaseW. |
@@ -240,7 +240,7 @@ namespace WixToolset.Core.Native.Msi | |||
240 | /// <param name="database">Handle to database.</param> | 240 | /// <param name="database">Handle to database.</param> |
241 | /// <returns>Error code.</returns> | 241 | /// <returns>Error code.</returns> |
242 | [DllImport("msi.dll", EntryPoint = "MsiOpenDatabaseW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 242 | [DllImport("msi.dll", EntryPoint = "MsiOpenDatabaseW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
243 | internal static extern int MsiOpenDatabase(string databasePath, IntPtr persist, out uint database); | 243 | internal static extern int MsiOpenDatabase(string databasePath, IntPtr persist, out IntPtr database); |
244 | 244 | ||
245 | /// <summary> | 245 | /// <summary> |
246 | /// PInvoke of MsiOpenPackageW. | 246 | /// PInvoke of MsiOpenPackageW. |
@@ -249,7 +249,7 @@ namespace WixToolset.Core.Native.Msi | |||
249 | /// <param name="product">A pointer to a variable that receives the product handle.</param> | 249 | /// <param name="product">A pointer to a variable that receives the product handle.</param> |
250 | /// <returns>Error code.</returns> | 250 | /// <returns>Error code.</returns> |
251 | [DllImport("msi.dll", EntryPoint = "MsiOpenPackageW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 251 | [DllImport("msi.dll", EntryPoint = "MsiOpenPackageW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
252 | internal static extern int MsiOpenPackage(string packagePath, out uint product); | 252 | internal static extern int MsiOpenPackage(string packagePath, out IntPtr product); |
253 | 253 | ||
254 | /// <summary> | 254 | /// <summary> |
255 | /// PInvoke of MsiRecordIsNull. | 255 | /// PInvoke of MsiRecordIsNull. |
@@ -258,7 +258,7 @@ namespace WixToolset.Core.Native.Msi | |||
258 | /// <param name="field">Index of field to check for null value.</param> | 258 | /// <param name="field">Index of field to check for null value.</param> |
259 | /// <returns>true if the field is null, false if not, and an error code for any error.</returns> | 259 | /// <returns>true if the field is null, false if not, and an error code for any error.</returns> |
260 | [DllImport("msi.dll", EntryPoint = "MsiRecordIsNull", CharSet = CharSet.Unicode, ExactSpelling = true)] | 260 | [DllImport("msi.dll", EntryPoint = "MsiRecordIsNull", CharSet = CharSet.Unicode, ExactSpelling = true)] |
261 | internal static extern int MsiRecordIsNull(uint record, int field); | 261 | internal static extern int MsiRecordIsNull(IntPtr record, int field); |
262 | 262 | ||
263 | /// <summary> | 263 | /// <summary> |
264 | /// PInvoke of MsiRecordGetInteger. | 264 | /// PInvoke of MsiRecordGetInteger. |
@@ -267,7 +267,7 @@ namespace WixToolset.Core.Native.Msi | |||
267 | /// <param name="field">Index of field to retrieve integer from.</param> | 267 | /// <param name="field">Index of field to retrieve integer from.</param> |
268 | /// <returns>Integer value.</returns> | 268 | /// <returns>Integer value.</returns> |
269 | [DllImport("msi.dll", EntryPoint = "MsiRecordGetInteger", CharSet = CharSet.Unicode, ExactSpelling = true)] | 269 | [DllImport("msi.dll", EntryPoint = "MsiRecordGetInteger", CharSet = CharSet.Unicode, ExactSpelling = true)] |
270 | internal static extern int MsiRecordGetInteger(uint record, int field); | 270 | internal static extern int MsiRecordGetInteger(IntPtr record, int field); |
271 | 271 | ||
272 | /// <summary> | 272 | /// <summary> |
273 | /// PInvoke of MsiRectordSetInteger. | 273 | /// PInvoke of MsiRectordSetInteger. |
@@ -277,7 +277,7 @@ namespace WixToolset.Core.Native.Msi | |||
277 | /// <param name="value">Value to set field to.</param> | 277 | /// <param name="value">Value to set field to.</param> |
278 | /// <returns>Error code.</returns> | 278 | /// <returns>Error code.</returns> |
279 | [DllImport("msi.dll", EntryPoint = "MsiRecordSetInteger", CharSet = CharSet.Unicode, ExactSpelling = true)] | 279 | [DllImport("msi.dll", EntryPoint = "MsiRecordSetInteger", CharSet = CharSet.Unicode, ExactSpelling = true)] |
280 | internal static extern int MsiRecordSetInteger(uint record, int field, int value); | 280 | internal static extern int MsiRecordSetInteger(IntPtr record, int field, int value); |
281 | 281 | ||
282 | /// <summary> | 282 | /// <summary> |
283 | /// PInvoke of MsiRecordGetStringW. | 283 | /// PInvoke of MsiRecordGetStringW. |
@@ -288,7 +288,7 @@ namespace WixToolset.Core.Native.Msi | |||
288 | /// <param name="valueBufSize">Size of buffer.</param> | 288 | /// <param name="valueBufSize">Size of buffer.</param> |
289 | /// <returns>Error code.</returns> | 289 | /// <returns>Error code.</returns> |
290 | [DllImport("msi.dll", EntryPoint = "MsiRecordGetStringW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 290 | [DllImport("msi.dll", EntryPoint = "MsiRecordGetStringW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
291 | internal static extern int MsiRecordGetString(uint record, int field, StringBuilder valueBuf, ref int valueBufSize); | 291 | internal static extern int MsiRecordGetString(IntPtr record, int field, StringBuilder valueBuf, ref int valueBufSize); |
292 | 292 | ||
293 | /// <summary> | 293 | /// <summary> |
294 | /// PInvoke of MsiRecordSetStringW. | 294 | /// PInvoke of MsiRecordSetStringW. |
@@ -298,7 +298,7 @@ namespace WixToolset.Core.Native.Msi | |||
298 | /// <param name="value">String value.</param> | 298 | /// <param name="value">String value.</param> |
299 | /// <returns>Error code.</returns> | 299 | /// <returns>Error code.</returns> |
300 | [DllImport("msi.dll", EntryPoint = "MsiRecordSetStringW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 300 | [DllImport("msi.dll", EntryPoint = "MsiRecordSetStringW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
301 | internal static extern int MsiRecordSetString(uint record, int field, string value); | 301 | internal static extern int MsiRecordSetString(IntPtr record, int field, string value); |
302 | 302 | ||
303 | /// <summary> | 303 | /// <summary> |
304 | /// PInvoke of MsiRecordSetStreamW. | 304 | /// PInvoke of MsiRecordSetStreamW. |
@@ -308,7 +308,7 @@ namespace WixToolset.Core.Native.Msi | |||
308 | /// <param name="filePath">Path to file to set stream value to.</param> | 308 | /// <param name="filePath">Path to file to set stream value to.</param> |
309 | /// <returns>Error code.</returns> | 309 | /// <returns>Error code.</returns> |
310 | [DllImport("msi.dll", EntryPoint = "MsiRecordSetStreamW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 310 | [DllImport("msi.dll", EntryPoint = "MsiRecordSetStreamW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
311 | internal static extern int MsiRecordSetStream(uint record, int field, string filePath); | 311 | internal static extern int MsiRecordSetStream(IntPtr record, int field, string filePath); |
312 | 312 | ||
313 | /// <summary> | 313 | /// <summary> |
314 | /// PInvoke of MsiRecordReadStreamW. | 314 | /// PInvoke of MsiRecordReadStreamW. |
@@ -319,7 +319,7 @@ namespace WixToolset.Core.Native.Msi | |||
319 | /// <param name="dataBufSize">Size of data buffer.</param> | 319 | /// <param name="dataBufSize">Size of data buffer.</param> |
320 | /// <returns>Error code.</returns> | 320 | /// <returns>Error code.</returns> |
321 | [DllImport("msi.dll", EntryPoint = "MsiRecordReadStream", CharSet = CharSet.Unicode, ExactSpelling = true)] | 321 | [DllImport("msi.dll", EntryPoint = "MsiRecordReadStream", CharSet = CharSet.Unicode, ExactSpelling = true)] |
322 | internal static extern int MsiRecordReadStream(uint record, int field, byte[] dataBuf, ref int dataBufSize); | 322 | internal static extern int MsiRecordReadStream(IntPtr record, int field, byte[] dataBuf, ref int dataBufSize); |
323 | 323 | ||
324 | /// <summary> | 324 | /// <summary> |
325 | /// PInvoke of MsiRecordGetFieldCount. | 325 | /// PInvoke of MsiRecordGetFieldCount. |
@@ -327,7 +327,7 @@ namespace WixToolset.Core.Native.Msi | |||
327 | /// <param name="record">MSI Record handle.</param> | 327 | /// <param name="record">MSI Record handle.</param> |
328 | /// <returns>Count of fields in the record.</returns> | 328 | /// <returns>Count of fields in the record.</returns> |
329 | [DllImport("msi.dll", EntryPoint = "MsiRecordGetFieldCount", CharSet = CharSet.Unicode, ExactSpelling = true)] | 329 | [DllImport("msi.dll", EntryPoint = "MsiRecordGetFieldCount", CharSet = CharSet.Unicode, ExactSpelling = true)] |
330 | internal static extern int MsiRecordGetFieldCount(uint record); | 330 | internal static extern int MsiRecordGetFieldCount(IntPtr record); |
331 | 331 | ||
332 | /// <summary> | 332 | /// <summary> |
333 | /// PInvoke of MsiSetExternalUIW. | 333 | /// PInvoke of MsiSetExternalUIW. |
@@ -365,7 +365,7 @@ namespace WixToolset.Core.Native.Msi | |||
365 | /// <param name="stringValueBufSize">Size of string buffer.</param> | 365 | /// <param name="stringValueBufSize">Size of string buffer.</param> |
366 | /// <returns>Error code.</returns> | 366 | /// <returns>Error code.</returns> |
367 | [DllImport("msi.dll", EntryPoint = "MsiSummaryInfoGetPropertyW", CharSet = CharSet.Unicode, ExactSpelling = true)] | 367 | [DllImport("msi.dll", EntryPoint = "MsiSummaryInfoGetPropertyW", CharSet = CharSet.Unicode, ExactSpelling = true)] |
368 | internal static extern int MsiSummaryInfoGetProperty(uint summaryInfo, int property, out uint dataType, out int integerValue, ref System.Runtime.InteropServices.ComTypes.FILETIME fileTimeValue, StringBuilder stringValueBuf, ref int stringValueBufSize); | 368 | internal static extern int MsiSummaryInfoGetProperty(IntPtr summaryInfo, int property, out uint dataType, out int integerValue, ref System.Runtime.InteropServices.ComTypes.FILETIME fileTimeValue, StringBuilder stringValueBuf, ref int stringValueBufSize); |
369 | 369 | ||
370 | /// <summary> | 370 | /// <summary> |
371 | /// PInvoke of MsiViewGetColumnInfo. | 371 | /// PInvoke of MsiViewGetColumnInfo. |
@@ -375,7 +375,7 @@ namespace WixToolset.Core.Native.Msi | |||
375 | /// <param name="record">Handle for returned record.</param> | 375 | /// <param name="record">Handle for returned record.</param> |
376 | /// <returns>Error code.</returns> | 376 | /// <returns>Error code.</returns> |
377 | [DllImport("msi.dll", EntryPoint = "MsiViewGetColumnInfo", CharSet = CharSet.Unicode, ExactSpelling = true)] | 377 | [DllImport("msi.dll", EntryPoint = "MsiViewGetColumnInfo", CharSet = CharSet.Unicode, ExactSpelling = true)] |
378 | internal static extern int MsiViewGetColumnInfo(uint view, int columnInfo, out uint record); | 378 | internal static extern int MsiViewGetColumnInfo(IntPtr view, int columnInfo, out IntPtr record); |
379 | 379 | ||
380 | /// <summary> | 380 | /// <summary> |
381 | /// PInvoke of MsiViewExecute. | 381 | /// PInvoke of MsiViewExecute. |
@@ -384,7 +384,7 @@ namespace WixToolset.Core.Native.Msi | |||
384 | /// <param name="record">Handle to a record that supplies the parameters for the view.</param> | 384 | /// <param name="record">Handle to a record that supplies the parameters for the view.</param> |
385 | /// <returns>Error code.</returns> | 385 | /// <returns>Error code.</returns> |
386 | [DllImport("msi.dll", EntryPoint = "MsiViewExecute", CharSet = CharSet.Unicode, ExactSpelling = true)] | 386 | [DllImport("msi.dll", EntryPoint = "MsiViewExecute", CharSet = CharSet.Unicode, ExactSpelling = true)] |
387 | internal static extern int MsiViewExecute(uint view, uint record); | 387 | internal static extern int MsiViewExecute(IntPtr view, IntPtr record); |
388 | 388 | ||
389 | /// <summary> | 389 | /// <summary> |
390 | /// PInvoke of MsiViewFetch. | 390 | /// PInvoke of MsiViewFetch. |
@@ -393,7 +393,7 @@ namespace WixToolset.Core.Native.Msi | |||
393 | /// <param name="record">Handle to receive record info.</param> | 393 | /// <param name="record">Handle to receive record info.</param> |
394 | /// <returns>Error code.</returns> | 394 | /// <returns>Error code.</returns> |
395 | [DllImport("msi.dll", EntryPoint = "MsiViewFetch", CharSet = CharSet.Unicode, ExactSpelling = true)] | 395 | [DllImport("msi.dll", EntryPoint = "MsiViewFetch", CharSet = CharSet.Unicode, ExactSpelling = true)] |
396 | internal static extern int MsiViewFetch(uint view, out uint record); | 396 | internal static extern int MsiViewFetch(IntPtr view, out IntPtr record); |
397 | 397 | ||
398 | /// <summary> | 398 | /// <summary> |
399 | /// PInvoke of MsiViewModify. | 399 | /// PInvoke of MsiViewModify. |
@@ -403,6 +403,6 @@ namespace WixToolset.Core.Native.Msi | |||
403 | /// <param name="record">Handle of record.</param> | 403 | /// <param name="record">Handle of record.</param> |
404 | /// <returns>Error code.</returns> | 404 | /// <returns>Error code.</returns> |
405 | [DllImport("msi.dll", EntryPoint = "MsiViewModify", CharSet = CharSet.Unicode, ExactSpelling = true)] | 405 | [DllImport("msi.dll", EntryPoint = "MsiViewModify", CharSet = CharSet.Unicode, ExactSpelling = true)] |
406 | internal static extern int MsiViewModify(uint view, int modifyMode, uint record); | 406 | internal static extern int MsiViewModify(IntPtr view, int modifyMode, IntPtr record); |
407 | } | 407 | } |
408 | } | 408 | } |
diff --git a/src/wix/WixToolset.Core.Native/Msi/Record.cs b/src/wix/WixToolset.Core.Native/Msi/Record.cs index c25e76e2..9a201fa6 100644 --- a/src/wix/WixToolset.Core.Native/Msi/Record.cs +++ b/src/wix/WixToolset.Core.Native/Msi/Record.cs | |||
@@ -18,7 +18,7 @@ namespace WixToolset.Core.Native.Msi | |||
18 | public Record(int fieldCount) | 18 | public Record(int fieldCount) |
19 | { | 19 | { |
20 | this.Handle = MsiInterop.MsiCreateRecord(fieldCount); | 20 | this.Handle = MsiInterop.MsiCreateRecord(fieldCount); |
21 | if (0 == this.Handle) | 21 | if (IntPtr.Zero == this.Handle) |
22 | { | 22 | { |
23 | throw new OutOfMemoryException(); | 23 | throw new OutOfMemoryException(); |
24 | } | 24 | } |
@@ -28,7 +28,7 @@ namespace WixToolset.Core.Native.Msi | |||
28 | /// Creates a record from a handle. | 28 | /// Creates a record from a handle. |
29 | /// </summary> | 29 | /// </summary> |
30 | /// <param name="handle">Handle to create record from.</param> | 30 | /// <param name="handle">Handle to create record from.</param> |
31 | internal Record(uint handle) | 31 | internal Record(IntPtr handle) |
32 | { | 32 | { |
33 | this.Handle = handle; | 33 | this.Handle = handle; |
34 | } | 34 | } |
diff --git a/src/wix/WixToolset.Core.Native/Msi/Session.cs b/src/wix/WixToolset.Core.Native/Msi/Session.cs index 743fb2be..ae9cb0ba 100644 --- a/src/wix/WixToolset.Core.Native/Msi/Session.cs +++ b/src/wix/WixToolset.Core.Native/Msi/Session.cs | |||
@@ -2,8 +2,6 @@ | |||
2 | 2 | ||
3 | namespace WixToolset.Core.Native.Msi | 3 | namespace WixToolset.Core.Native.Msi |
4 | { | 4 | { |
5 | using System.Globalization; | ||
6 | |||
7 | /// <summary> | 5 | /// <summary> |
8 | /// Controls the installation process. | 6 | /// Controls the installation process. |
9 | /// </summary> | 7 | /// </summary> |
@@ -15,7 +13,7 @@ namespace WixToolset.Core.Native.Msi | |||
15 | /// <param name="database">The database to open.</param> | 13 | /// <param name="database">The database to open.</param> |
16 | public Session(Database database) | 14 | public Session(Database database) |
17 | { | 15 | { |
18 | var packagePath = "#" + database.Handle.ToString(CultureInfo.InvariantCulture); | 16 | var packagePath = "#" + database.Handle; |
19 | 17 | ||
20 | var error = MsiInterop.MsiOpenPackage(packagePath, out var handle); | 18 | var error = MsiInterop.MsiOpenPackage(packagePath, out var handle); |
21 | if (0 != error) | 19 | if (0 != error) |
diff --git a/src/wix/WixToolset.Core.Native/Msi/SummaryInformation.cs b/src/wix/WixToolset.Core.Native/Msi/SummaryInformation.cs index da629df2..3b3dea0f 100644 --- a/src/wix/WixToolset.Core.Native/Msi/SummaryInformation.cs +++ b/src/wix/WixToolset.Core.Native/Msi/SummaryInformation.cs | |||
@@ -200,7 +200,7 @@ namespace WixToolset.Core.Native.Msi | |||
200 | throw new ArgumentNullException(nameof(db)); | 200 | throw new ArgumentNullException(nameof(db)); |
201 | } | 201 | } |
202 | 202 | ||
203 | uint handle = 0; | 203 | var handle = IntPtr.Zero; |
204 | var error = MsiInterop.MsiGetSummaryInformation(db.Handle, null, 0, ref handle); | 204 | var error = MsiInterop.MsiGetSummaryInformation(db.Handle, null, 0, ref handle); |
205 | if (0 != error) | 205 | if (0 != error) |
206 | { | 206 | { |
@@ -220,8 +220,8 @@ namespace WixToolset.Core.Native.Msi | |||
220 | throw new ArgumentNullException(nameof(databaseFile)); | 220 | throw new ArgumentNullException(nameof(databaseFile)); |
221 | } | 221 | } |
222 | 222 | ||
223 | uint handle = 0; | 223 | var handle = IntPtr.Zero; |
224 | var error = MsiInterop.MsiGetSummaryInformation(0, databaseFile, 0, ref handle); | 224 | var error = MsiInterop.MsiGetSummaryInformation(IntPtr.Zero, databaseFile, 0, ref handle); |
225 | if (0 != error) | 225 | if (0 != error) |
226 | { | 226 | { |
227 | throw new MsiException(error); | 227 | throw new MsiException(error); |
diff --git a/src/wix/WixToolset.Core.Native/Msi/View.cs b/src/wix/WixToolset.Core.Native/Msi/View.cs index 6305a9de..f255190c 100644 --- a/src/wix/WixToolset.Core.Native/Msi/View.cs +++ b/src/wix/WixToolset.Core.Native/Msi/View.cs | |||
@@ -58,7 +58,7 @@ namespace WixToolset.Core.Native.Msi | |||
58 | /// <param name="record">Record containing parameters to be substituded into the view.</param> | 58 | /// <param name="record">Record containing parameters to be substituded into the view.</param> |
59 | public void Execute(Record record) | 59 | public void Execute(Record record) |
60 | { | 60 | { |
61 | var error = MsiInterop.MsiViewExecute(this.Handle, null == record ? 0 : record.Handle); | 61 | var error = MsiInterop.MsiViewExecute(this.Handle, null == record ? IntPtr.Zero : record.Handle); |
62 | if (0 != error) | 62 | if (0 != error) |
63 | { | 63 | { |
64 | throw new MsiException(error); | 64 | throw new MsiException(error); |