Skip to content

Instantly share code, notes, and snippets.

View kennykerr's full-sized avatar

Kenny Kerr kennykerr

View GitHub Profile
use windows::{core::*, Win32::Storage::FileSystem::*};
fn search_path(filename: &str) -> Result<String> {
let filename = &HSTRING::from(filename);
let len = unsafe { SearchPathW(None, filename, None, None, None) };
if len == 0 {
return Err(Error::from_win32());
}
use windows::core::*;
use windows::Win32::System::Com::*;
use windows::Win32::UI::Accessibility::*;
use windows::Win32::UI::WindowsAndMessaging::*;
fn main() -> Result<()> {
unsafe {
let mut acc: Option<IAccessible> = None;
AccessibleObjectFromWindow(
GetDesktopWindow(),
[dependencies.windows]
version = "0.52"
features = [
"Win32_Foundation",
"Win32_System_LibraryLoader",
]
@kennykerr
kennykerr / Cargo.toml
Last active November 14, 2023 15:51
RtlGetVersion
[dependencies.windows]
version = "0.51"
features = ["Win32_Foundation", "Win32_System_SystemInformation", "Wdk_System_SystemServices"]
#include "pch.h"
using namespace winrt;
using namespace Windows::Foundation;
IAsyncAction Sample()
{
throw winrt::hresult_invalid_argument(L"yolo");
}
#![allow(non_snake_case)]
use windows::{core::*, Win32::Foundation::*};
#[interface("17f409a1-f79d-45f6-962d-9db106cb7727")]
unsafe trait ICompositor: IUnknown {
unsafe fn CreateVisual(&self, value: u32, visual: *mut Option<IVisual>) -> HRESULT;
unsafe fn RenderVisual(&self, visual: std::mem::ManuallyDrop<Option<IVisual>>) -> HRESULT;
}
#[interface("34e49797-1302-4ad6-8975-dd7c5b286e72")]
[dependencies.windows]
version = "0.51"
features = [
"implement",
"Win32_Foundation",
]
use windows::{
core::HSTRING,
w,
Win32::{
System::Com::CoInitialize,
UI::Shell::{
Common::ITEMIDLIST, ILCreateFromPathW, SHCreateShellItemArray, SIGDN_FILESYSPATH,
},
},
};
1. ACCEPT_SECURITY_CONTEXT_FN
Windows.Wdk.Storage.FileSystem
Windows.Win32.Security.Authentication.Identity
2. ACCESS_ALLOWED_ACE
Windows.Wdk.Storage.FileSystem
Windows.Win32.Security
3. ACCESS_ALLOWED_ACE_TYPE
Windows.Wdk.Storage.FileSystem
Windows.Win32.System.SystemServices
4. ACCESS_ALLOWED_CALLBACK_ACE_TYPE
use windows_metadata::reader::*;
fn main() {
let files = File::with_default(&[]).unwrap();
let reader = &Reader::new(&files);
let mut collisions = std::collections::BTreeMap::<(&str, bool), Vec<&str>>::new();
for namespace in reader.namespaces() {
if namespace.starts_with("Windows.Wdk") {
continue;