Skip to content

Commit 3b3d702

Browse files
committedSep 26, 2014
1 parent a52eaaa commit 3b3d702

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
extern crate libc;
2+
use libc::{c_void, LPVOID, DWORD};
3+
use libc::types::os::arch::extra::LPWSTR;
4+
5+
extern "system" {
6+
fn FormatMessageW(flags: DWORD,
7+
lpSrc: LPVOID,
8+
msgId: DWORD,
9+
langId: DWORD,
10+
buf: LPWSTR,
11+
nsize: DWORD,
12+
args: *const c_void)
13+
-> DWORD;
14+
}
15+
16+
fn test() {
17+
let mut buf: [u16, ..50] = [0, ..50];
18+
let ret = unsafe {
19+
FormatMessageW(0x1000, 0 as *mut c_void, 1, 0x400,
20+
buf.as_mut_ptr(), buf.len() as u32, 0 as *const c_void)
21+
};
22+
// On some 32-bit Windowses (Win7-8 at least) this will fail with segmented
23+
// stacks taking control of pvArbitrary
24+
assert!(ret != 0);
25+
}
26+
fn main() {
27+
test()
28+
}

0 commit comments

Comments
 (0)