Skip to content

Instantly share code, notes, and snippets.

View kennykerr's full-sized avatar

Kenny Kerr kennykerr

View GitHub Profile
D:\git\scratch10>type src\main.rs
use windows_sys::{core::*, Win32::System::LibraryLoader::*};
fn main() {
unsafe {
let module = LoadLibraryExW(
w!("api-ms-win-core-com-l1-1-3.dll"),
core::ptr::null_mut(),
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS,
);
use windows_core::*;
#[interface("1bd72b4b-8d05-44c6-8909-da3e0e91afa0")]
unsafe trait IDebug: IUnknown {
fn debug_carrot(&self, carrot: Ref<ICarrot>) -> Result<()>;
fn debug_pear(&self, pear: Ref<IPear>) -> Result<()>;
}
#[interface("3bde3f9e-4d7c-4d5f-8322-4b226e0e1b91")]
unsafe trait ICarrot: IUnknown {
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,
},
},
};