Skip to content

Commit

Permalink
Add TimeOfLastHeartbeatFailure modification
Browse files Browse the repository at this point in the history
  • Loading branch information
nekoppai committed Oct 7, 2023
1 parent f5a0ed2 commit 8591604
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 63 deletions.
6 changes: 3 additions & 3 deletions 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

Expand Down
11 changes: 3 additions & 8 deletions readme.md
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down
43 changes: 43 additions & 0 deletions 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
90 changes: 42 additions & 48 deletions sppc.c
@@ -1,55 +1,11 @@
#define _WIN32_WINNT _WIN32_WINNT_WIN10
#include <windows.h>
#include <shlwapi.h>
#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;

Expand All @@ -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,
Expand All @@ -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;
Expand All @@ -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;
}
8 changes: 4 additions & 4 deletions 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
Expand All @@ -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

Expand Down

0 comments on commit 8591604

Please sign in to comment.