Skip to content

Commit 0baea37

Browse files
committed
shim some Windows functions
1 parent 9802549 commit 0baea37

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/fn_call.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,25 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx> for EvalContext<'a, 'mir, '
622622
self.write_ptr(dest, addr, dest_ty)?;
623623
}
624624

625+
// Windows ABI
626+
"AddVectoredExceptionHandler" => {
627+
// any non zero value works for the stdlib. This is just used for stackoverflows anyway
628+
self.write_scalar(dest, Scalar::from_u128(1), dest_ty)?;
629+
},
630+
"GetModuleHandleW" |
631+
"GetProcAddress" |
632+
"InitializeCriticalSection" |
633+
"EnterCriticalSection" |
634+
"LeaveCriticalSection" |
635+
"SetLastError" => {
636+
// pretend these do not exist/nothing happened, by returning zero
637+
self.write_scalar(dest, Scalar::from_u128(0), dest_ty)?;
638+
},
639+
"GetLastError" => {
640+
// this is c::ERROR_CALL_NOT_IMPLEMENTED
641+
self.write_scalar(dest, Scalar::from_u128(120), dest_ty)?;
642+
},
643+
625644
_ => {
626645
return err!(Unimplemented(
627646
format!("can't call C ABI function: {}", link_name),
@@ -728,6 +747,7 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx> for EvalContext<'a, 'mir, '
728747
let bool = self.tcx.types.bool;
729748
self.write_scalar(dest, Scalar::from_bool(false), bool)?;
730749
}
750+
731751
_ => return err!(NoMirFor(path)),
732752
}
733753

0 commit comments

Comments
 (0)