Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MSIHANDLE parameter modification in Rust 1.78.0+ #33

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ impl Database {
/// [SQL string](https://docs.microsoft.com/windows/win32/msi/sql-syntax).
pub fn open_view(&self, sql: &str) -> Result<View> {
unsafe {
let h = ffi::MSIHANDLE::null();
let mut h = ffi::MSIHANDLE::null();
let sql = CString::new(sql)?;
let ret = ffi::MsiDatabaseOpenView(*self.h, sql.as_ptr(), &h);
let ret = ffi::MsiDatabaseOpenView(*self.h, sql.as_ptr(), &mut h);
if ret != ffi::ERROR_SUCCESS {
return Err(
Error::from_last_error_record().unwrap_or_else(|| Error::from_error_code(ret))
Expand All @@ -34,9 +34,9 @@ impl Database {
/// The field count of the record is the count of primary key columns.
pub fn primary_keys(&self, table: &str) -> Result<Record> {
unsafe {
let h = ffi::MSIHANDLE::null();
let mut h = ffi::MSIHANDLE::null();
let table = CString::new(table)?;
let ret = ffi::MsiDatabaseGetPrimaryKeys(*self.h, table.as_ptr(), &h);
let ret = ffi::MsiDatabaseGetPrimaryKeys(*self.h, table.as_ptr(), &mut h);
if ret != ffi::ERROR_SUCCESS {
return Err(Error::from_error_code(ret));
}
Expand Down
10 changes: 7 additions & 3 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ extern "C" {
pub fn MsiDatabaseGetPrimaryKeys(
hDatabase: MSIHANDLE,
szTableName: LPCSTR,
hRecord: &MSIHANDLE,
hRecord: &mut MSIHANDLE,
) -> u32;

#[link_name = "MsiDatabaseOpenViewA"]
pub fn MsiDatabaseOpenView(hDatabase: MSIHANDLE, szQuery: LPCSTR, phView: &MSIHANDLE) -> u32;
pub fn MsiDatabaseOpenView(
hDatabase: MSIHANDLE,
szQuery: LPCSTR,
phView: &mut MSIHANDLE,
) -> u32;

#[link_name = "MsiDoActionA"]
pub fn MsiDoAction(hInstall: MSIHANDLE, szAction: LPCSTR) -> u32;
Expand Down Expand Up @@ -99,7 +103,7 @@ extern "C" {

pub fn MsiViewExecute(hView: MSIHANDLE, hRecord: MSIHANDLE) -> u32;

pub fn MsiViewFetch(hView: MSIHANDLE, phRecord: &MSIHANDLE) -> u32;
pub fn MsiViewFetch(hView: MSIHANDLE, phRecord: &mut MSIHANDLE) -> u32;

pub fn MsiViewModify(hView: MSIHANDLE, eModifyMode: ModifyMode, hRecord: MSIHANDLE) -> u32;
}
Expand Down
4 changes: 2 additions & 2 deletions src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ impl Iterator for View {

fn next(&mut self) -> Option<Self::Item> {
unsafe {
let h = ffi::MSIHANDLE::null();
ffi::MsiViewFetch(*self.h, &h);
let mut h = ffi::MSIHANDLE::null();
ffi::MsiViewFetch(*self.h, &mut h);

if h.is_null() {
return None;
Expand Down
Loading