Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #![crate_type = "dylib"]
  2. #![feature(libc)]
  3.  
  4. extern crate libc;
  5. extern crate user32;
  6.  
  7. use std::ffi::CString;
  8.  
  9. #[no_mangle]
  10. #[allow(unused, non_snake_case)]
  11. pub extern "C" fn GetAdaptersInfo(pAdapterInfo: *mut libc::c_void, pOutBufLen: *mut libc::c_ulong) -> libc::c_ulong {
  12. 0
  13. }
  14.  
  15. #[no_mangle]
  16. #[allow(unused, non_snake_case)]
  17. pub extern "stdcall" fn DllMain(module: u32, reason_for_call: u32, reserved: *mut libc::c_void) {
  18. match reason_for_call {
  19. 0 => { // DLL_PROCESS_DETACH
  20. ()
  21. },
  22. 1 => { // DLL_PROCESS_ATTACH
  23. let message = CString::new("Hello!").unwrap();
  24. unsafe {
  25. user32::MessageBoxA(std::ptr::null_mut(), message.as_ptr(), message.as_ptr(), 0);
  26. }
  27. },
  28. 2 => { // DLL_THREAD_ATTACH
  29. ()
  30. },
  31. 3 => { // DLL_THREAD_DETACH
  32. ()
  33. },
  34. _ => () // who gives a shit
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement