From 65282ba05ae561505d589dd652c0159c6cc1a11e Mon Sep 17 00:00:00 2001 From: nekoppai <109633131+nekoppai@users.noreply.github.com> Date: Tue, 12 Mar 2024 12:27:45 +0000 Subject: [PATCH] Move TimeOfLastHeartbeatFailure changes to ohook+ --- Makefile | 16 +++++++++++++++- readme.md | 20 ++++++++++++++++---- sl.h | 30 +++++++++++++++++++----------- sppc.c | 15 ++++++++++++--- sppc.rc | 20 +++++++++++++------- 5 files changed, 75 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 838d293..382e1ef 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ PREFIX64=C:/mingw64/bin/ CC32=gcc -Wl,-e_DllMain -municode CC64=gcc -Wl,-eDllMain -municode -all: sppc32.dll sppc64.dll +all: sppc32.dll sppc64.dll sppcplus32.dll sppcplus64.dll sppc32.dll: sppc.c sppc32.res.o libsppcs32.a $(PREFIX32)$(CC32) $(OPT) $< sppc.def sppc32.res.o -shared -o $@ $(CFLAGS) $(LDFLAGS) -lsppcs32 @@ -18,12 +18,26 @@ sppc64.dll: sppc.c sppc64.res.o libsppcs64.a $(PREFIX64)$(CC64) $(OPT) $< sppc.def sppc64.res.o -shared -o $@ $(CFLAGS) $(LDFLAGS) -lsppcs64 strip -s $@ +sppcplus32.dll: sppc.c sppcplus32.res.o libsppcs32.a + $(PREFIX32)$(CC32) -DPLUS_BUILD $(OPT) $< sppc.def sppcplus32.res.o -shared -o $@ $(CFLAGS) $(LDFLAGS) -lsppcs32 + strip -s $@ + +sppcplus64.dll: sppc.c sppcplus64.res.o libsppcs64.a + $(PREFIX64)$(CC64) -DPLUS_BUILD $(OPT) $< sppc.def sppcplus64.res.o -shared -o $@ $(CFLAGS) $(LDFLAGS) -lsppcs64 + strip -s $@ + sppc32.res.o: sppc.rc $(PREFIX32)windres --codepage=65001 $< $@ sppc64.res.o: sppc.rc $(PREFIX64)windres --codepage=65001 $< $@ +sppcplus32.res.o: sppc.rc + $(PREFIX32)windres --codepage=65001 -DPLUS_BUILD $< $@ + +sppcplus64.res.o: sppc.rc + $(PREFIX64)windres --codepage=65001 -DPLUS_BUILD $< $@ + libsppcs32.a: $(PREFIX32)dlltool -k -dsppcs32.def -llibsppcs32.a diff --git a/readme.md b/readme.md index 99971c1..97a22d5 100644 --- a/readme.md +++ b/readme.md @@ -18,7 +18,12 @@ mklink "%programfiles%\Microsoft Office\root\vfs\System\sppcs.dll" "%windir%\Sys copy /y sppc64.dll "%programfiles%\Microsoft Office\root\vfs\System\sppc.dll" ``` -3. Install a blank key for the edition you want to use. +3. (optional) In case of some Office editions which show "There was a problem checking this device's license status" banner, you may need to add the following to the `hosts` file: +``` +0.0.0.0 ols.officeapps.live.com +``` + +4. Install a blank key for the edition you want to use. Please note these steps are an example and are based on our internal tests. As stated before, no direct support will be provided for usage of this method. You should use one of the solutions provided by [our **authorized** partners](https://massgrave.dev/ohook.html) and direct your support queries to them. @@ -52,12 +57,19 @@ With this method, a correct license for the installed edition is used, meaning e There are also other issues with installing license files from other editions but we won't be bothering with them. -### Why is the value of TimeOfLastHeartbeatFailure changed to some date in the future? -After the license check, some Office editions make a request to the `ols.officeapps.live.com` service to retrieve an expiration date of user's subscription. This is done in order to evaluate should the local license be renewed. Since the service replies there is no subscription associated with the device, a notification is shown. Setting TimeOfLastHeartbeatFailure to some date in the future prevents Office from doing this check. +### Why is the modification of TimeOfLastHeartbeatFailure or the hosts file required in some cases? +After the license check, some Office editions make a request to the `ols.officeapps.live.com` service to retrieve an expiration date of user's subscription. This is done in order to evaluate should the local license be renewed. Since the service replies there is no subscription associated with the device, a notification is shown. Setting TimeOfLastHeartbeatFailure to some date in the future or modifying the hosts file prevents Office from doing this check. -### Does this enable 1TB of storage on OneDrive? +### Will this enable 1TB of storage on OneDrive, Python in Excel or some other online feature? No. +### ohook vs ohook+ +A regular ohook build provides only a basic functionality of hooking up a licensing state response from the system. + +A "plus" build of ohook, in addition to the functionality of regular ohook, modifies the TimeOfLastHeartbeatFailure value in the registry to prevent an online subscription check. + +Generally, it is recommended to use a regular build of ohook, as it is much less invasive to the system and less likely to be falsely detected by an antivirus software. + License ------- The project is licensed under the terms of the MIT License. diff --git a/sl.h b/sl.h index 939cc11..86527ed 100644 --- a/sl.h +++ b/sl.h @@ -4,24 +4,32 @@ typedef GUID SLID; typedef void *HSLC; -typedef struct { +typedef enum _tagSLDATATYPE { + SL_DATA_NONE = REG_NONE, + SL_DATA_SZ = REG_SZ, + SL_DATA_DWORD = REG_DWORD, + SL_DATA_BINARY = REG_BINARY, + SL_DATA_MULTI_SZ = REG_MULTI_SZ, + SL_DATA_SUM = 100, +} SLDATATYPE; + +typedef enum _tagSLLICENSINGSTATUS { + SL_LICENSING_STATUS_UNLICENSED, + SL_LICENSING_STATUS_LICENSED, + SL_LICENSING_STATUS_IN_GRACE_PERIOD, + SL_LICENSING_STATUS_NOTIFICATION, + SL_LICENSING_STATUS_LAST +} SLLICENSINGSTATUS; + +typedef struct _tagSL_LICENSING_STATUS { SLID SkuId; - DWORD eStatus; + SLLICENSINGSTATUS eStatus; DWORD dwGraceTime; DWORD dwTotalGraceDays; HRESULT hrReason; UINT64 qwValidityExpiration; } SL_LICENSING_STATUS; -typedef enum { - SL_DATA_NONE = REG_NONE, - SL_DATA_SZ = REG_SZ, - SL_DATA_DWORD = REG_DWORD, - SL_DATA_BINARY = REG_BINARY, - SL_DATA_MULTI_SZ, - SL_DATA_SUM = 100 -} SLDATATYPE; - HRESULT WINAPI SLGetLicensingStatusInformation( HSLC hSLC, SLID *pAppID, diff --git a/sppc.c b/sppc.c index 86d685e..5ba7b5c 100644 --- a/sppc.c +++ b/sppc.c @@ -3,7 +3,9 @@ #include #include "sl.h" +#ifdef PLUS_BUILD BOOL bIsHeartbeatRegistryModified = FALSE; +#endif BOOL IsGracePeriodProduct(HSLC hSLC, SLID *pProductSkuId) { PBYTE pBuffer = 0; @@ -23,6 +25,7 @@ BOOL IsGracePeriodProduct(HSLC hSLC, SLID *pProductSkuId) { return FALSE; } +#ifdef PLUS_BUILD VOID ModifyHeartbeatRegistry() { HKEY hKey = 0; @@ -47,6 +50,7 @@ VOID ModifyHeartbeatRegistry() { RegCloseKey(hKey); } +#endif HRESULT WINAPI SLGetLicensingStatusInformationHook( HSLC hSLC, @@ -69,20 +73,25 @@ HRESULT WINAPI SLGetLicensingStatusInformationHook( return hResult; for(int i = 0; i < *pnStatusCount; i++) { - if((*ppLicensingStatus+i)->eStatus == 0) continue; - if(IsGracePeriodProduct(hSLC, &((*ppLicensingStatus+i)->SkuId))) continue; + if((*ppLicensingStatus+i)->eStatus == SL_LICENSING_STATUS_UNLICENSED) + continue; - (*ppLicensingStatus+i)->eStatus = 1; + if(IsGracePeriodProduct(hSLC, &((*ppLicensingStatus+i)->SkuId))) + continue; + + (*ppLicensingStatus+i)->eStatus = SL_LICENSING_STATUS_LICENSED; (*ppLicensingStatus+i)->dwGraceTime = 0; (*ppLicensingStatus+i)->dwTotalGraceDays = 0; (*ppLicensingStatus+i)->hrReason = 0; (*ppLicensingStatus+i)->qwValidityExpiration = 0; } +#ifdef PLUS_BUILD if(!bIsHeartbeatRegistryModified) { ModifyHeartbeatRegistry(); bIsHeartbeatRegistryModified = TRUE; } +#endif return hResult; } diff --git a/sppc.rc b/sppc.rc index 891c42c..b1107f5 100644 --- a/sppc.rc +++ b/sppc.rc @@ -1,6 +1,12 @@ +#ifdef PLUS_BUILD + #define PRODNAME "ohook+" +#else + #define PRODNAME "ohook" +#endif + 1 VERSIONINFO -FILEVERSION 0,4,0,0 -PRODUCTVERSION 0,4,0,0 +FILEVERSION 0,5,0,0 +PRODUCTVERSION 0,5,0,0 FILEOS 0x40004L FILETYPE 0x2L BEGIN @@ -9,13 +15,13 @@ BEGIN BLOCK "040904E4" BEGIN VALUE "CompanyName", "Anomalous Software Deterioration Corporation" - VALUE "FileDescription", "ohook SPPC" - VALUE "FileVersion", "0.4.0.0" + VALUE "FileDescription", PRODNAME " SPPC" + VALUE "FileVersion", "0.5.0.0" VALUE "InternalName", "sppc" - VALUE "LegalCopyright", "© 2023 Anomalous Software Deterioration Corporation" + VALUE "LegalCopyright", "© 2024 Anomalous Software Deterioration Corporation" VALUE "OriginalFilename", "sppc.dll" - VALUE "ProductName", "ohook" - VALUE "ProductVersion", "0.4.0.0" + VALUE "ProductName", PRODNAME + VALUE "ProductVersion", "0.5.0.0" END END