teamy-mft 0.7.1

TeamDman's Master File Table CLI and library for NTFS.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use tracing::debug;
use windows::Win32::Foundation::HWND;
use windows::Win32::UI::WindowsAndMessaging::DispatchMessageW;
use windows::Win32::UI::WindowsAndMessaging::GetMessageW;
use windows::Win32::UI::WindowsAndMessaging::MSG;
use windows::Win32::UI::WindowsAndMessaging::TranslateMessage;

/// Pump the message loop for the given window handle, or all windows if None is provided.
pub fn run_message_loop(hwnd: Option<HWND>) -> eyre::Result<()> {
    let mut msg = MSG::default();
    debug!("Starting message loop");
    while unsafe { GetMessageW(&mut msg, hwnd, 0, 0) }.into() {
        let _ = unsafe { TranslateMessage(&msg) };
        unsafe { DispatchMessageW(&msg) };
    }
    Ok(())
}