summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs30
-rw-r--r--src/sppcs.rs130
-rw-r--r--src/win32.rs29
3 files changed, 97 insertions, 92 deletions
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;
}