Skip to content

Commit c61fc9a

Browse files
committed
hresult constant
1 parent ab4d702 commit c61fc9a

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

crates/libmwemu/src/constants.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ pub const ERROR_BUFFER_OVERFLOW: u64 = 0x6f;
4343
pub const ERROR_INVALID_PARAMETER: u64 = 0x57;
4444
pub const ERROR_INSUFFICIENT_BUFFER: u64 = 0x7a;
4545

46+
47+
pub const HRESULT_E_INVALID_ARG: u64 = 0x80070057;
48+
/*
49+
* HRESULT STRUCTURE:
50+
* 0x8 -> severity: error
51+
* 0x007 -> facility: FACILITY_WIN32
52+
* 0x0057 -> ERROR_INVALID_PARAMETER
53+
*/
54+
4655
pub const CP_UTF7: u64 = 65000;
4756
pub const CP_UTF8: u64 = 65001;
4857

crates/libmwemu/src/winapi/winapi64/ntdll.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -986,10 +986,8 @@ fn NtReadFile(emu: &mut emu::Emu) {
986986

987987
emu.maps.memset(buff, 0x90, len);
988988

989-
// TODO: fix path duplication!!!!
990-
if filename == "\\??\\c:\\cwd\\c:\\cwd\\version.dll" {
991-
let local_path = "/tmp/version2.dll";
992-
let mut file = File::open(local_path).unwrap();
989+
if filename == "\\??\\c:\\cwd" {
990+
let mut file = File::open(&emu.filename).unwrap();
993991
file.seek(SeekFrom::Start(file_offset));
994992
let mut file_buffer = vec![0u8; len];
995993
let bytes_read = file.read(&mut file_buffer).unwrap();
@@ -1013,6 +1011,8 @@ fn NtReadFile(emu: &mut emu::Emu) {
10131011
panic!("TODO: read {}", filename);
10141012
}
10151013

1014+
1015+
10161016
emu.regs_mut().rax = constants::STATUS_SUCCESS;
10171017
}
10181018

crates/libmwemu/src/winapi/winapi64/oleaut32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ fn VariantClear(emu: &mut emu::Emu) {
298298
// Basic validation
299299
if pvarg == 0 || !emu.maps.is_mapped(pvarg) {
300300
log_red!(emu, "VariantClear: Invalid pvarg pointer");
301-
emu.regs_mut().rax = 0x80070057; // E_INVALIDARG
301+
emu.regs_mut().rax = constants::HRESULT_E_INVALID_ARG;
302302
return;
303303
}
304304

0 commit comments

Comments
 (0)