Skip to content

Instantly share code, notes, and snippets.

@t1hq
Last active July 10, 2023 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t1hq/bfeefc48332b0df8c27f145b56590e12 to your computer and use it in GitHub Desktop.
Save t1hq/bfeefc48332b0df8c27f145b56590e12 to your computer and use it in GitHub Desktop.
lsp appid catagory hash calculation demo
[package]
name = "wctest"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
wchar = "*"
use wchar::{wch, wchar_t};
fn main() {
const PATH: &[wchar_t] = wch!(":\\WINDOWS\\SYSTEM32\\SVCHOST.EXE");
let mut sum: u32 = 0;
for &w in PATH {
sum = sum.wrapping_mul(0x25).wrapping_add(w as u32);
}
let mul = sum.wrapping_mul(0x12b9b0a5);
let m = mul >> 0x1f;
let h = mul ^ m - m;
println!("hash: {:08X}", h % 0x3b9aca07);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment