diff --git a/Makefile b/Makefile index 891111d..838d293 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ OPT=-Os -Wall CFLAGS=-fno-ident -LDFLAGS=-L. -nostartfiles -nostdlib -lkernel32 -lshlwapi -Wl,--exclude-all-symbols,--enable-stdcall-fixup,--dynamicbase,--nxcompat,--subsystem,windows:6.0 +LDFLAGS=-L. -nostartfiles -nostdlib -lkernel32 -lshlwapi -ladvapi32 -Wl,--exclude-all-symbols,--enable-stdcall-fixup,--dynamicbase,--nxcompat,--subsystem,windows:6.0 PREFIX32=C:/mingw32/bin/ PREFIX64=C:/mingw64/bin/ -CC32=gcc -Wl,-e_dll_main -municode -CC64=gcc -Wl,-edll_main -municode +CC32=gcc -Wl,-e_DllMain -municode +CC64=gcc -Wl,-eDllMain -municode all: sppc32.dll sppc64.dll diff --git a/readme.md b/readme.md index 7534c96..99971c1 100644 --- a/readme.md +++ b/readme.md @@ -18,12 +18,7 @@ mklink "%programfiles%\Microsoft Office\root\vfs\System\sppcs.dll" "%windir%\Sys copy /y sppc64.dll "%programfiles%\Microsoft Office\root\vfs\System\sppc.dll" ``` -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. +3. 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. @@ -57,8 +52,8 @@ 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 do some editions require the hosts file modification? -After the license check, these 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. Blocking access to the service prevents Office from being told the truth. +### 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. ### Does this enable 1TB of storage on OneDrive? No. diff --git a/sl.h b/sl.h new file mode 100644 index 0000000..939cc11 --- /dev/null +++ b/sl.h @@ -0,0 +1,43 @@ +#ifndef OHOOKSL_H +#define OHOOKSL_H + +typedef GUID SLID; +typedef void *HSLC; + +typedef struct { + SLID SkuId; + DWORD 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, + SLID *pProductSkuId, + PWSTR pwszRightName, + UINT *pnStatusCount, + SL_LICENSING_STATUS **ppLicensingStatus +); + +HRESULT WINAPI SLGetProductSkuInformation( + HSLC hSLC, + const SLID *pProductSkuId, + PCWSTR pwszValueName, + SLDATATYPE *peDataType, + UINT *pcbValue, + PBYTE *ppbValue +); + +#endif diff --git a/sppc.c b/sppc.c index 6548de3..86d685e 100644 --- a/sppc.c +++ b/sppc.c @@ -1,55 +1,11 @@ #define _WIN32_WINNT _WIN32_WINNT_WIN10 #include #include +#include "sl.h" -typedef GUID SLID; -typedef void *HSLC; - -typedef struct { - SLID SkuId; - DWORD 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, - SLID *pProductSkuId, - PWSTR pwszRightName, - UINT *pnStatusCount, - SL_LICENSING_STATUS **ppLicensingStatus -); - -HRESULT WINAPI SLGetProductSkuInformation( - HSLC hSLC, - const SLID *pProductSkuId, - PCWSTR pwszValueName, - SLDATATYPE *peDataType, - UINT *pcbValue, - PBYTE *ppbValue -); - -BOOL APIENTRY WINAPI dll_main( - HINSTANCE hinstDLL, - DWORD fdwReason, - LPVOID lpvReserved -) { - return TRUE; -} +BOOL bIsHeartbeatRegistryModified = FALSE; -BOOL check_for_grace(HSLC hSLC, SLID *pProductSkuId) { +BOOL IsGracePeriodProduct(HSLC hSLC, SLID *pProductSkuId) { PBYTE pBuffer = 0; UINT cbSize = 0; @@ -67,6 +23,31 @@ BOOL check_for_grace(HSLC hSLC, SLID *pProductSkuId) { return FALSE; } +VOID ModifyHeartbeatRegistry() { + HKEY hKey = 0; + + LSTATUS lStatus = RegOpenKeyExW( + HKEY_CURRENT_USER, + L"Software\\Microsoft\\Office\\16.0", + 0, + KEY_ALL_ACCESS, + &hKey + ); + + if(lStatus != ERROR_SUCCESS) return; + + RegSetKeyValueW( + hKey, + L"Common\\Licensing\\Resiliency", + L"TimeOfLastHeartbeatFailure", + REG_SZ, + L"2040-01-01T00:00:00Z", + 42 + ); + + RegCloseKey(hKey); +} + HRESULT WINAPI SLGetLicensingStatusInformationHook( HSLC hSLC, SLID *pAppID, @@ -89,7 +70,7 @@ HRESULT WINAPI SLGetLicensingStatusInformationHook( for(int i = 0; i < *pnStatusCount; i++) { if((*ppLicensingStatus+i)->eStatus == 0) continue; - if(check_for_grace(hSLC, &((*ppLicensingStatus+i)->SkuId))) continue; + if(IsGracePeriodProduct(hSLC, &((*ppLicensingStatus+i)->SkuId))) continue; (*ppLicensingStatus+i)->eStatus = 1; (*ppLicensingStatus+i)->dwGraceTime = 0; @@ -98,5 +79,18 @@ HRESULT WINAPI SLGetLicensingStatusInformationHook( (*ppLicensingStatus+i)->qwValidityExpiration = 0; } + if(!bIsHeartbeatRegistryModified) { + ModifyHeartbeatRegistry(); + bIsHeartbeatRegistryModified = TRUE; + } + return hResult; } + +BOOL APIENTRY WINAPI DllMain( + HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved +) { + return TRUE; +} diff --git a/sppc.rc b/sppc.rc index e157fed..891c42c 100644 --- a/sppc.rc +++ b/sppc.rc @@ -1,6 +1,6 @@ 1 VERSIONINFO -FILEVERSION 0,3,0,0 -PRODUCTVERSION 0,3,0,0 +FILEVERSION 0,4,0,0 +PRODUCTVERSION 0,4,0,0 FILEOS 0x40004L FILETYPE 0x2L BEGIN @@ -10,12 +10,12 @@ BEGIN BEGIN VALUE "CompanyName", "Anomalous Software Deterioration Corporation" VALUE "FileDescription", "ohook SPPC" - VALUE "FileVersion", "0.3.0.0" + VALUE "FileVersion", "0.4.0.0" VALUE "InternalName", "sppc" VALUE "LegalCopyright", "© 2023 Anomalous Software Deterioration Corporation" VALUE "OriginalFilename", "sppc.dll" VALUE "ProductName", "ohook" - VALUE "ProductVersion", "0.3.0.0" + VALUE "ProductVersion", "0.4.0.0" END END