summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock71
-rw-r--r--Cargo.toml22
-rw-r--r--LICENSE36
-rw-r--r--README.md20
-rw-r--r--src/lib.rs30
-rw-r--r--src/sppcs.rs130
-rw-r--r--src/win32.rs29
7 files changed, 140 insertions, 198 deletions
diff --git a/Cargo.lock b/Cargo.lock
index dca3cca..11403ad 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,73 +4,4 @@ version = 3
[[package]]
name = "shook"
-version = "0.1.0"
-dependencies = [
- "windows-sys",
-]
-
-[[package]]
-name = "windows-sys"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
-dependencies = [
- "windows-targets",
-]
-
-[[package]]
-name = "windows-targets"
-version = "0.52.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b"
-dependencies = [
- "windows_aarch64_gnullvm",
- "windows_aarch64_msvc",
- "windows_i686_gnu",
- "windows_i686_msvc",
- "windows_x86_64_gnu",
- "windows_x86_64_gnullvm",
- "windows_x86_64_msvc",
-]
-
-[[package]]
-name = "windows_aarch64_gnullvm"
-version = "0.52.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9"
-
-[[package]]
-name = "windows_aarch64_msvc"
-version = "0.52.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675"
-
-[[package]]
-name = "windows_i686_gnu"
-version = "0.52.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3"
-
-[[package]]
-name = "windows_i686_msvc"
-version = "0.52.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02"
-
-[[package]]
-name = "windows_x86_64_gnu"
-version = "0.52.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03"
-
-[[package]]
-name = "windows_x86_64_gnullvm"
-version = "0.52.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177"
-
-[[package]]
-name = "windows_x86_64_msvc"
-version = "0.52.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8"
+version = "0.1.1"
diff --git a/Cargo.toml b/Cargo.toml
index 5226e18..4f2819f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,21 +1,27 @@
[package]
+edition = "2021"
+rust-version = "1.77.1"
name = "shook"
-version = "0.1.0"
+version = "0.1.1"
description = "A rust implementation of ohook"
-repository = "https://github.com/massgravel/ohook-rs"
+keywords = [
+ "activator",
+ "office",
+ "ohook",
+]
+categories = [
+ "no-std",
+ "no-std::no-alloc",
+]
license = "MIT"
-edition = "2021"
-rust-version = "1.77.1"
+repository = "https://github.com/massgravel/ohook-rs"
[lib]
crate-type = ["cdylib"]
-[dependencies]
-windows-sys = "0.52"
-
[profile.dev]
-lto = true
opt-level = 1
+lto = true
panic = "abort"
[profile.release]
diff --git a/LICENSE b/LICENSE
index 36d788f..4b127b5 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,18 +1,18 @@
-Copyright 2023-2024 asdcorp, Microsoft Corporation
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the “Software”), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+Copyright 2023-2024 asdcorp, Microsoft Corporation
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the “Software”), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
index a04c81a..d173a0d 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
-# ohook.rs
-
-A rewrite of [ohook](https://github.com/asdcorp/ohook) in Rust for decreased size, easier building, and better reproducibility. For more information on ohook check the original repo.
-
-## Building
-Rust 1.77.1 and [Visual Studio Build Tools 2022 LTSC 17.6](https://download.visualstudio.microsoft.com/download/pr/a851fc84-7739-4b67-a7da-2c8564e30b38/b4133f16d790c3ee7325fff80c47094d94dff44b426b86db9013b200bb669ce2/vs_BuildTools.exe) running on Windows is required if you want to build binaries bit-for-bit identical to the release. To build x64, run `cargo build --release`, and for x86 run `cargo build --release --target i686-pc-windows-msvc`.
-
-## License
-
-The project is licensed under the terms of the MIT License.
+# ohook.rs
+
+A rewrite of [ohook](https://github.com/asdcorp/ohook) in Rust for decreased size, easier building, and better reproducibility. For more information on ohook check the original repo.
+
+## Building
+Rust 1.77.1 and [Visual Studio Build Tools 2022 LTSC 17.6](https://download.visualstudio.microsoft.com/download/pr/a851fc84-7739-4b67-a7da-2c8564e30b38/b4133f16d790c3ee7325fff80c47094d94dff44b426b86db9013b200bb669ce2/vs_BuildTools.exe) running on Windows is required if you want to build binaries bit-for-bit identical to the release. To build x64, run `cargo build --release`, and for x86 run `cargo build --release --target i686-pc-windows-msvc`.
+
+## License
+
+The project is licensed under the terms of the MIT License.
diff --git a/src/lib.rs b/src/lib.rs
index fdead5b..634d623 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,46 +4,46 @@ mod sppcs;
mod win32;
use core::{ffi::c_void, ptr::null_mut};
-use win32::{LocalFree, StrStrNIW, SL_LICENSING_STATUS};
-use win32::{SLGetLicensingStatusInformation, SLGetProductSkuInformation};
-
-use windows_sys::{
- core::{GUID, PCWSTR},
- w,
+use win32::{
+ Guid, LocalFree, SLGetLicensingStatusInformation, SLGetProductSkuInformation, StrStrNIW,
+ SL_LICENSING_STATUS,
};
-unsafe fn is_grace_period_product(hslc: *const c_void, pproductskuid: *const GUID) -> bool {
+const GRACE: [u16; 6] = [0x47, 0x72, 0x61, 0x63, 0x65, 0x00];
+const NAME: [u16; 5] = [0x4e, 0x61, 0x6d, 0x65, 0x00];
+
+unsafe fn is_grace_period_product(hslc: *const c_void, pproductskuid: *const Guid) -> bool {
let mut p_buffer = null_mut();
let mut cb_size = 0;
if SLGetProductSkuInformation(
hslc,
pproductskuid,
- w!("Name"),
+ NAME.as_ptr(),
null_mut(),
&mut cb_size,
&mut p_buffer,
) != 0
{
- LocalFree(p_buffer as *mut c_void);
+ LocalFree(p_buffer.cast());
return false;
}
- if !StrStrNIW(p_buffer as *const u16, w!("Grace"), cb_size).is_null() {
- LocalFree(p_buffer as *mut c_void);
+ if !StrStrNIW(p_buffer.cast(), GRACE.as_ptr(), cb_size).is_null() {
+ LocalFree(p_buffer.cast());
return true;
}
- LocalFree(p_buffer as *mut c_void);
+ LocalFree(p_buffer.cast());
false
}
#[no_mangle]
unsafe extern "system" fn SLGetLicensingStatusInformationHook(
hslc: *const c_void,
- pappid: *const GUID,
- pproductskuid: *const GUID,
- pwszrightname: PCWSTR,
+ pappid: *const Guid,
+ pproductskuid: *const Guid,
+ pwszrightname: *const u16,
pnstatuscount: *mut u32,
pplicensingstatus: *mut *mut SL_LICENSING_STATUS,
) -> i32 {
diff --git a/src/sppcs.rs b/src/sppcs.rs
index 4b4a1f6..28a7025 100644
--- a/src/sppcs.rs
+++ b/src/sppcs.rs
@@ -1,132 +1,132 @@
#![allow(non_snake_case)]
#[no_mangle]
-fn SLCallServer() {}
+extern "system" fn SLCallServer() {}
#[no_mangle]
-fn SLpAuthenticateGenuineTicketResponse() {}
+extern "system" fn SLpAuthenticateGenuineTicketResponse() {}
#[no_mangle]
-fn SLpBeginGenuineTicketTransaction() {}
+extern "system" fn SLpBeginGenuineTicketTransaction() {}
#[no_mangle]
-fn SLpClearActivationInProgress() {}
+extern "system" fn SLpClearActivationInProgress() {}
#[no_mangle]
-fn SLpDepositDownlevelGenuineTicket() {}
+extern "system" fn SLpDepositDownlevelGenuineTicket() {}
#[no_mangle]
-fn SLpDepositTokenActivationResponse() {}
+extern "system" fn SLpDepositTokenActivationResponse() {}
#[no_mangle]
-fn SLpGenerateTokenActivationChallenge() {}
+extern "system" fn SLpGenerateTokenActivationChallenge() {}
#[no_mangle]
-fn SLpGetGenuineBlob() {}
+extern "system" fn SLpGetGenuineBlob() {}
#[no_mangle]
-fn SLpGetGenuineLocal() {}
+extern "system" fn SLpGetGenuineLocal() {}
#[no_mangle]
-fn SLpGetLicenseAcquisitionInfo() {}
+extern "system" fn SLpGetLicenseAcquisitionInfo() {}
#[no_mangle]
-fn SLpGetMSPidInformation() {}
+extern "system" fn SLpGetMSPidInformation() {}
#[no_mangle]
-fn SLpGetMachineUGUID() {}
+extern "system" fn SLpGetMachineUGUID() {}
#[no_mangle]
-fn SLpGetTokenActivationGrantInfo() {}
+extern "system" fn SLpGetTokenActivationGrantInfo() {}
#[no_mangle]
-fn SLpIAActivateProduct() {}
+extern "system" fn SLpIAActivateProduct() {}
#[no_mangle]
-fn SLpIsCurrentInstalledProductKeyDefaultKey() {}
+extern "system" fn SLpIsCurrentInstalledProductKeyDefaultKey() {}
#[no_mangle]
-fn SLpProcessVMPipeMessage() {}
+extern "system" fn SLpProcessVMPipeMessage() {}
#[no_mangle]
-fn SLpSetActivationInProgress() {}
+extern "system" fn SLpSetActivationInProgress() {}
#[no_mangle]
-fn SLpTriggerServiceWorker() {}
+extern "system" fn SLpTriggerServiceWorker() {}
#[no_mangle]
-fn SLpVLActivateProduct() {}
+extern "system" fn SLpVLActivateProduct() {}
#[no_mangle]
-fn SLClose() {}
+extern "system" fn SLClose() {}
#[no_mangle]
-fn SLConsumeRight() {}
+extern "system" fn SLConsumeRight() {}
#[no_mangle]
-fn SLDepositMigrationBlob() {}
+extern "system" fn SLDepositMigrationBlob() {}
#[no_mangle]
-fn SLDepositOfflineConfirmationId() {}
+extern "system" fn SLDepositOfflineConfirmationId() {}
#[no_mangle]
-fn SLDepositOfflineConfirmationIdEx() {}
+extern "system" fn SLDepositOfflineConfirmationIdEx() {}
#[no_mangle]
-fn SLDepositStoreToken() {}
+extern "system" fn SLDepositStoreToken() {}
#[no_mangle]
-fn SLFireEvent() {}
+extern "system" fn SLFireEvent() {}
#[no_mangle]
-fn SLGatherMigrationBlob() {}
+extern "system" fn SLGatherMigrationBlob() {}
#[no_mangle]
-fn SLGatherMigrationBlobEx() {}
+extern "system" fn SLGatherMigrationBlobEx() {}
#[no_mangle]
-fn SLGenerateOfflineInstallationId() {}
+extern "system" fn SLGenerateOfflineInstallationId() {}
#[no_mangle]
-fn SLGenerateOfflineInstallationIdEx() {}
+extern "system" fn SLGenerateOfflineInstallationIdEx() {}
#[no_mangle]
-fn SLGetActiveLicenseInfo() {}
+extern "system" fn SLGetActiveLicenseInfo() {}
#[no_mangle]
-fn SLGetApplicationInformation() {}
+extern "system" fn SLGetApplicationInformation() {}
#[no_mangle]
-fn SLGetApplicationPolicy() {}
+extern "system" fn SLGetApplicationPolicy() {}
#[no_mangle]
-fn SLGetAuthenticationResult() {}
+extern "system" fn SLGetAuthenticationResult() {}
#[no_mangle]
-fn SLGetEncryptedPIDEx() {}
+extern "system" fn SLGetEncryptedPIDEx() {}
#[no_mangle]
-fn SLGetGenuineInformation() {}
+extern "system" fn SLGetGenuineInformation() {}
#[no_mangle]
-fn SLGetInstalledProductKeyIds() {}
+extern "system" fn SLGetInstalledProductKeyIds() {}
#[no_mangle]
-fn SLGetLicense() {}
+extern "system" fn SLGetLicense() {}
#[no_mangle]
-fn SLGetLicenseFileId() {}
+extern "system" fn SLGetLicenseFileId() {}
#[no_mangle]
-fn SLGetLicenseInformation() {}
+extern "system" fn SLGetLicenseInformation() {}
#[no_mangle]
-fn SLGetPKeyId() {}
+extern "system" fn SLGetPKeyId() {}
#[no_mangle]
-fn SLGetPKeyInformation() {}
+extern "system" fn SLGetPKeyInformation() {}
#[no_mangle]
-fn SLGetPolicyInformation() {}
+extern "system" fn SLGetPolicyInformation() {}
#[no_mangle]
-fn SLGetPolicyInformationDWORD() {}
+extern "system" fn SLGetPolicyInformationDWORD() {}
#[no_mangle]
-fn SLGetSLIDList() {}
+extern "system" fn SLGetSLIDList() {}
#[no_mangle]
-fn SLGetServiceInformation() {}
+extern "system" fn SLGetServiceInformation() {}
#[no_mangle]
-fn SLInstallLicense() {}
+extern "system" fn SLInstallLicense() {}
#[no_mangle]
-fn SLInstallProofOfPurchase() {}
+extern "system" fn SLInstallProofOfPurchase() {}
#[no_mangle]
-fn SLInstallProofOfPurchaseEx() {}
+extern "system" fn SLInstallProofOfPurchaseEx() {}
#[no_mangle]
-fn SLIsGenuineLocalEx() {}
+extern "system" fn SLIsGenuineLocalEx() {}
#[no_mangle]
-fn SLLoadApplicationPolicies() {}
+extern "system" fn SLLoadApplicationPolicies() {}
#[no_mangle]
-fn SLOpen() {}
+extern "system" fn SLOpen() {}
#[no_mangle]
-fn SLPersistApplicationPolicies() {}
+extern "system" fn SLPersistApplicationPolicies() {}
#[no_mangle]
-fn SLPersistRTSPayloadOverride() {}
+extern "system" fn SLPersistRTSPayloadOverride() {}
#[no_mangle]
-fn SLReArm() {}
+extern "system" fn SLReArm() {}
#[no_mangle]
-fn SLRegisterEvent() {}
+extern "system" fn SLRegisterEvent() {}
#[no_mangle]
-fn SLRegisterPlugin() {}
+extern "system" fn SLRegisterPlugin() {}
#[no_mangle]
-fn SLSetAuthenticationData() {}
+extern "system" fn SLSetAuthenticationData() {}
#[no_mangle]
-fn SLSetCurrentProductKey() {}
+extern "system" fn SLSetCurrentProductKey() {}
#[no_mangle]
-fn SLSetGenuineInformation() {}
+extern "system" fn SLSetGenuineInformation() {}
#[no_mangle]
-fn SLUninstallLicense() {}
+extern "system" fn SLUninstallLicense() {}
#[no_mangle]
-fn SLUninstallProofOfPurchase() {}
+extern "system" fn SLUninstallProofOfPurchase() {}
#[no_mangle]
-fn SLUnloadApplicationPolicies() {}
+extern "system" fn SLUnloadApplicationPolicies() {}
#[no_mangle]
-fn SLUnregisterEvent() {}
+extern "system" fn SLUnregisterEvent() {}
#[no_mangle]
-fn SLUnregisterPlugin() {}
+extern "system" fn SLUnregisterPlugin() {}
diff --git a/src/win32.rs b/src/win32.rs
index 65995a3..8a5e2de 100644
--- a/src/win32.rs
+++ b/src/win32.rs
@@ -1,11 +1,20 @@
+// Mostly copied from windows-sys
+
use core::ffi::c_void;
-use windows_sys::core::{GUID, PCWSTR};
+
+#[repr(C)]
+pub struct Guid {
+ pub data1: u32,
+ pub data2: u16,
+ pub data3: u16,
+ pub data4: [u8; 8],
+}
#[allow(non_snake_case)]
#[allow(non_camel_case_types)]
#[repr(C)]
pub struct SL_LICENSING_STATUS {
- pub SkuId: GUID,
+ pub SkuId: Guid,
pub eStatus: i32,
pub dwGraceTime: u32,
pub dwTotalGraceDays: u32,
@@ -21,9 +30,9 @@ pub struct SL_LICENSING_STATUS {
extern "system" {
pub fn SLGetLicensingStatusInformation(
hslc: *const c_void,
- pappid: *const GUID,
- pproductskuid: *const GUID,
- pwszrightname: PCWSTR,
+ pappid: *const Guid,
+ pproductskuid: *const Guid,
+ pwszrightname: *const u16,
pnstatuscount: *mut u32,
pplicensingstatus: *mut *mut SL_LICENSING_STATUS,
) -> i32;
@@ -37,8 +46,8 @@ extern "system" {
extern "system" {
pub fn SLGetProductSkuInformation(
hslc: *const c_void,
- pproductskuid: *const GUID,
- pwszvaluename: PCWSTR,
+ pproductskuid: *const Guid,
+ pwszvaluename: *const u16,
pedatatype: *mut u32,
pcbvalue: *mut u32,
ppbvalue: *mut *mut u8,
@@ -64,9 +73,5 @@ extern "system" {
)]
#[cfg_attr(not(target_arch = "x86"), link(name = "SHLWAPI", kind = "raw-dylib"))]
extern "system" {
- pub fn StrStrNIW(
- pszfirst: ::windows_sys::core::PCWSTR,
- pszsrch: ::windows_sys::core::PCWSTR,
- cchmax: u32,
- ) -> ::windows_sys::core::PWSTR;
+ pub fn StrStrNIW(pszfirst: *const u16, pszsrch: *const u16, cchmax: u32) -> *mut u16;
}