Rust

redpill me on winapi crate. do i have to spam unsafe in order to compile readprocessmemory, findwindow etc?

Mike Stoklasa's Worst Fan Shirt $21.68

Tip Your Landlord Shirt $21.68

Mike Stoklasa's Worst Fan Shirt $21.68

  1. 1 month ago
    Anonymous

    crates that wrap c libraries do so explicitly so that you don't need to frick with unsafe blocks yourself, although in cases like this the lifetimes are actually fudged.

    • 1 month ago
      Anonymous

      YES
      >Why is there no documentation on how to use anything?
      >This crate is nothing more than raw bindings to Windows API. If you wish to know how to use the various functionality in Windows API, you can look up the various items on MSDN which is full of detailed documentation.
      I wouldn't use it, it says it's hand-converted, and the last update was 3 years ago, of course it will probably still work since windows doesn't really change the win32 api

      There are windows and windows-sys crates that are autogenerated from windows headers and maintained by microsoft themselves.
      These are slightly higher more than just pure FFI bindings (eg. some functions take a generic IntoParam<WINTYPE> instead of just WINTYPE or if you can pass a null they take Option<*mut WINTYPE> instead of *mut WINTYPE), but still mostly unsafe

      winapi is just an FFI crate
      It's basically 100% unsafe

      • 1 month ago
        Anonymous

        >YES
        >Why is there no documentation on how to use anything?
        >This crate is nothing more than raw bindings to Windows API. If you wish to know how to use the various functionality in Windows API, you can look up the various items on MSDN which is full of detailed documentation.
        >I wouldn't use it, it says it's hand-converted, and the last update was 3 years ago, of course it will probably still work since windows doesn't really change the win32 api
        >
        >There are windows and windows-sys crates that are autogenerated from windows headers and maintained by microsoft themselves.
        >These are slightly higher more than just pure FFI bindings (eg. some functions take a generic IntoParam<WINTYPE> instead of just WINTYPE or if you can pass a null they take Option<*mut WINTYPE> instead of *mut WINTYPE), but still mostly unsafe
        >
        >winapi is just an FFI crate
        >It's basically 100% unsafe

        Windows and windows-sys are also two different beasts with sys being faster but more unsafe.

        I do hate the thousands of different *PARAMS/*CSTR that can't be easily cast.

      • 1 month ago
        Anonymous

        >Option<*mut WINTYPE>
        Nut raw pointers in Rust are nullable, why wrap it in Option?
        It should be Option<NonNull<WINTYPE>>, that way it has the exact same memory layout as *mut WINTYPE.
        https://github.com/microsoft/windows-rs/issues?q=is%3Aissue+nonnull+is%3Aclosed
        what a dumb fricking moron the author is

        • 1 month ago
          Anonymous

          newtype of NonNull with #[repr(transparent)] will get Option optimized too, maybe they're using that IDK

          • 1 month ago
            Anonymous

            >maybe they're using that
            no
            >IDK
            then why post, dumb moron?

      • 1 month ago
        Anonymous

        This one is generated from Win32 metadata and maintained by Microsoft.
        https://github.com/microsoft/windows-rs

        • 1 month ago
          Anonymous

          lmao they have to unsafe the whole thing.
          use windows::{
          core::*, Win32::Foundation::*, Win32::Graphics::Gdi::ValidateRect,
          Win32::System::LibraryLoader::GetModuleHandleA, Win32::UI::WindowsAndMessaging::*,
          };

          fn main() -> Result<()> {
          unsafe {
          let instance = GetModuleHandleA(None)?;
          debug_assert!(instance.0 != 0);

          let window_class = s!("window");

          let wc = WNDCLASSA {
          hCursor: LoadCursorW(None, IDC_ARROW)?,
          hInstance: instance.into(),
          lpszClassName: window_class,

          style: CS_HREDRAW | CS_VREDRAW,
          lpfnWndProc: Some(wndproc),
          ..Default::default()
          };

          let atom = RegisterClassA(&wc);
          debug_assert!(atom != 0);

          CreateWindowExA(
          WINDOW_EX_STYLE::default(),
          window_class,
          s!("This is a sample window"),
          WS_OVERLAPPEDWINDOW | WS_VISIBLE,
          CW_USEDEFAULT,
          CW_USEDEFAULT,
          CW_USEDEFAULT,
          CW_USEDEFAULT,
          None,
          None,
          instance,
          None,
          );

          let mut message = MSG::default();

          while GetMessageA(&mut message, None, 0, 0).into() {
          DispatchMessageA(&message);
          }

          Ok(())
          }
          }

          extern "system" fn wndproc(window: HWND, message: u32, wparam: WPARAM, lparam: LPARAM) -> LRESULT {
          unsafe {
          match message {
          WM_PAINT => {
          println!("WM_PAINT");
          _ = ValidateRect(window, None);
          LRESULT(0)
          }
          WM_DESTROY => {
          println!("WM_DESTROY");
          PostQuitMessage(0);
          LRESULT(0)
          }
          _ => DefWindowProcA(window, message, wparam, lparam),
          }
          }
          }

  2. 1 month ago
    Anonymous

    I don't want to see anything child fully clothe them with gloves and footwear at all times and not even the eyes, put sunglasses on them sommabitches.

  3. 1 month ago
    Anonymous

    rust is like using a condom
    you don't want to do that
    it feels just weird and artificial
    you want full skin contact, full impregnation
    you want C

    • 1 month ago
      Anonymous

      I like to feel what my system is doing.

  4. 1 month ago
    Anonymous

    winapi is outdated, use windows crate

    https://crates.io/crates/windows

    Has actually ALL of the definitions and no holes unlike winapi

  5. 1 month ago
    Anonymous

    Writing software in rust means that the DoD will use it for their systems. Every line of code you write supports the nation of Israel.

    • 1 month ago
      Anonymous

      >Every line of code you write supports the killing of "Palestinian" "people".
      based

      • 1 month ago
        Anonymous

        Except, once israel is done killing them they will turn around and cause another wave of immigration into Europe and north America. Every line of code you write gets you one stop closer to white erasure.

        • 1 month ago
          Anonymous

          >Every line of code you write gets you one stop closer to "white" erasure.
          based

          • 1 month ago
            Anonymous

            >Europe is "white"
            Rust is fully of brownoids

  6. 1 month ago
    Anonymous

    wtf why did you copy my post

    • 1 month ago
      Anonymous

      skill issue

  7. 1 month ago
    Anonymous

    >readprocessmemory, findwindow
    stop writing malware

    • 1 month ago
      99318454

      a man provides. and he does it even when he's not appreciated, respected, or even loved. he simply bears up and does it.

Your email address will not be published. Required fields are marked *