-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.rs
17 lines (15 loc) · 804 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use winapi::um::winbase::CreateNamedPipeA;
use winapi::um::winnt::{HANDLE,LPCSTR};
use winapi::um::namedpipeapi::ConnectNamedPipe;
use winapi::um::fileapi::WriteFile;
use winapi::um::winbase::{PIPE_ACCESS_DUPLEX,PIPE_TYPE_MESSAGE};
use std::ptr::null_mut;
fn main() {
let mut bytes_written : u32 = 0;
let message = "RUST IS GOOD FOR OFFSEC\0" ;
let pipe_name : LPCSTR = "\\\\.\\pipe\\rusttestpipe\0".as_ptr() as *const i8;
let server_pipe : HANDLE = unsafe {CreateNamedPipeA(pipe_name,PIPE_ACCESS_DUPLEX,PIPE_TYPE_MESSAGE,1,2048,2048,0,null_mut())};
unsafe {ConnectNamedPipe(server_pipe,null_mut())};
println!("Sending message to Pipe");
unsafe {WriteFile(server_pipe,message.as_ptr() as *const winapi::ctypes::c_void,message.len() as u32,&mut bytes_written,null_mut())};
}