Skip to content

Commit 8591604

Browse files
authored
Add TimeOfLastHeartbeatFailure modification
1 parent f5a0ed2 commit 8591604

File tree

5 files changed

+95
-63
lines changed

5 files changed

+95
-63
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
OPT=-Os -Wall
22
CFLAGS=-fno-ident
3-
LDFLAGS=-L. -nostartfiles -nostdlib -lkernel32 -lshlwapi -Wl,--exclude-all-symbols,--enable-stdcall-fixup,--dynamicbase,--nxcompat,--subsystem,windows:6.0
3+
LDFLAGS=-L. -nostartfiles -nostdlib -lkernel32 -lshlwapi -ladvapi32 -Wl,--exclude-all-symbols,--enable-stdcall-fixup,--dynamicbase,--nxcompat,--subsystem,windows:6.0
44

55
PREFIX32=C:/mingw32/bin/
66
PREFIX64=C:/mingw64/bin/
77

8-
CC32=gcc -Wl,-e_dll_main -municode
9-
CC64=gcc -Wl,-edll_main -municode
8+
CC32=gcc -Wl,-e_DllMain -municode
9+
CC64=gcc -Wl,-eDllMain -municode
1010

1111
all: sppc32.dll sppc64.dll
1212

readme.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@ mklink "%programfiles%\Microsoft Office\root\vfs\System\sppcs.dll" "%windir%\Sys
1818
copy /y sppc64.dll "%programfiles%\Microsoft Office\root\vfs\System\sppc.dll"
1919
```
2020

21-
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:
22-
```
23-
0.0.0.0 ols.officeapps.live.com
24-
```
25-
26-
4. Install a blank key for the edition you want to use.
21+
3. Install a blank key for the edition you want to use.
2722

2823
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.
2924

@@ -57,8 +52,8 @@ With this method, a correct license for the installed edition is used, meaning e
5752

5853
There are also other issues with installing license files from other editions but we won't be bothering with them.
5954

60-
### Why do some editions require the hosts file modification?
61-
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.
55+
### Why is the value of TimeOfLastHeartbeatFailure changed to some date in the future?
56+
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.
6257

6358
### Does this enable 1TB of storage on OneDrive?
6459
No.

sl.h

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef OHOOKSL_H
2+
#define OHOOKSL_H
3+
4+
typedef GUID SLID;
5+
typedef void *HSLC;
6+
7+
typedef struct {
8+
SLID SkuId;
9+
DWORD eStatus;
10+
DWORD dwGraceTime;
11+
DWORD dwTotalGraceDays;
12+
HRESULT hrReason;
13+
UINT64 qwValidityExpiration;
14+
} SL_LICENSING_STATUS;
15+
16+
typedef enum {
17+
SL_DATA_NONE = REG_NONE,
18+
SL_DATA_SZ = REG_SZ,
19+
SL_DATA_DWORD = REG_DWORD,
20+
SL_DATA_BINARY = REG_BINARY,
21+
SL_DATA_MULTI_SZ,
22+
SL_DATA_SUM = 100
23+
} SLDATATYPE;
24+
25+
HRESULT WINAPI SLGetLicensingStatusInformation(
26+
HSLC hSLC,
27+
SLID *pAppID,
28+
SLID *pProductSkuId,
29+
PWSTR pwszRightName,
30+
UINT *pnStatusCount,
31+
SL_LICENSING_STATUS **ppLicensingStatus
32+
);
33+
34+
HRESULT WINAPI SLGetProductSkuInformation(
35+
HSLC hSLC,
36+
const SLID *pProductSkuId,
37+
PCWSTR pwszValueName,
38+
SLDATATYPE *peDataType,
39+
UINT *pcbValue,
40+
PBYTE *ppbValue
41+
);
42+
43+
#endif

sppc.c

+42-48
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,11 @@
11
#define _WIN32_WINNT _WIN32_WINNT_WIN10
22
#include <windows.h>
33
#include <shlwapi.h>
4+
#include "sl.h"
45

5-
typedef GUID SLID;
6-
typedef void *HSLC;
7-
8-
typedef struct {
9-
SLID SkuId;
10-
DWORD eStatus;
11-
DWORD dwGraceTime;
12-
DWORD dwTotalGraceDays;
13-
HRESULT hrReason;
14-
UINT64 qwValidityExpiration;
15-
} SL_LICENSING_STATUS;
16-
17-
typedef enum {
18-
SL_DATA_NONE = REG_NONE,
19-
SL_DATA_SZ = REG_SZ,
20-
SL_DATA_DWORD = REG_DWORD,
21-
SL_DATA_BINARY = REG_BINARY,
22-
SL_DATA_MULTI_SZ,
23-
SL_DATA_SUM = 100
24-
} SLDATATYPE;
25-
26-
HRESULT WINAPI SLGetLicensingStatusInformation(
27-
HSLC hSLC,
28-
SLID *pAppID,
29-
SLID *pProductSkuId,
30-
PWSTR pwszRightName,
31-
UINT *pnStatusCount,
32-
SL_LICENSING_STATUS **ppLicensingStatus
33-
);
34-
35-
HRESULT WINAPI SLGetProductSkuInformation(
36-
HSLC hSLC,
37-
const SLID *pProductSkuId,
38-
PCWSTR pwszValueName,
39-
SLDATATYPE *peDataType,
40-
UINT *pcbValue,
41-
PBYTE *ppbValue
42-
);
43-
44-
BOOL APIENTRY WINAPI dll_main(
45-
HINSTANCE hinstDLL,
46-
DWORD fdwReason,
47-
LPVOID lpvReserved
48-
) {
49-
return TRUE;
50-
}
6+
BOOL bIsHeartbeatRegistryModified = FALSE;
517

52-
BOOL check_for_grace(HSLC hSLC, SLID *pProductSkuId) {
8+
BOOL IsGracePeriodProduct(HSLC hSLC, SLID *pProductSkuId) {
539
PBYTE pBuffer = 0;
5410
UINT cbSize = 0;
5511

@@ -67,6 +23,31 @@ BOOL check_for_grace(HSLC hSLC, SLID *pProductSkuId) {
6723
return FALSE;
6824
}
6925

26+
VOID ModifyHeartbeatRegistry() {
27+
HKEY hKey = 0;
28+
29+
LSTATUS lStatus = RegOpenKeyExW(
30+
HKEY_CURRENT_USER,
31+
L"Software\\Microsoft\\Office\\16.0",
32+
0,
33+
KEY_ALL_ACCESS,
34+
&hKey
35+
);
36+
37+
if(lStatus != ERROR_SUCCESS) return;
38+
39+
RegSetKeyValueW(
40+
hKey,
41+
L"Common\\Licensing\\Resiliency",
42+
L"TimeOfLastHeartbeatFailure",
43+
REG_SZ,
44+
L"2040-01-01T00:00:00Z",
45+
42
46+
);
47+
48+
RegCloseKey(hKey);
49+
}
50+
7051
HRESULT WINAPI SLGetLicensingStatusInformationHook(
7152
HSLC hSLC,
7253
SLID *pAppID,
@@ -89,7 +70,7 @@ HRESULT WINAPI SLGetLicensingStatusInformationHook(
8970

9071
for(int i = 0; i < *pnStatusCount; i++) {
9172
if((*ppLicensingStatus+i)->eStatus == 0) continue;
92-
if(check_for_grace(hSLC, &((*ppLicensingStatus+i)->SkuId))) continue;
73+
if(IsGracePeriodProduct(hSLC, &((*ppLicensingStatus+i)->SkuId))) continue;
9374

9475
(*ppLicensingStatus+i)->eStatus = 1;
9576
(*ppLicensingStatus+i)->dwGraceTime = 0;
@@ -98,5 +79,18 @@ HRESULT WINAPI SLGetLicensingStatusInformationHook(
9879
(*ppLicensingStatus+i)->qwValidityExpiration = 0;
9980
}
10081

82+
if(!bIsHeartbeatRegistryModified) {
83+
ModifyHeartbeatRegistry();
84+
bIsHeartbeatRegistryModified = TRUE;
85+
}
86+
10187
return hResult;
10288
}
89+
90+
BOOL APIENTRY WINAPI DllMain(
91+
HINSTANCE hinstDLL,
92+
DWORD fdwReason,
93+
LPVOID lpvReserved
94+
) {
95+
return TRUE;
96+
}

sppc.rc

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1 VERSIONINFO
2-
FILEVERSION 0,3,0,0
3-
PRODUCTVERSION 0,3,0,0
2+
FILEVERSION 0,4,0,0
3+
PRODUCTVERSION 0,4,0,0
44
FILEOS 0x40004L
55
FILETYPE 0x2L
66
BEGIN
@@ -10,12 +10,12 @@ BEGIN
1010
BEGIN
1111
VALUE "CompanyName", "Anomalous Software Deterioration Corporation"
1212
VALUE "FileDescription", "ohook SPPC"
13-
VALUE "FileVersion", "0.3.0.0"
13+
VALUE "FileVersion", "0.4.0.0"
1414
VALUE "InternalName", "sppc"
1515
VALUE "LegalCopyright", "© 2023 Anomalous Software Deterioration Corporation"
1616
VALUE "OriginalFilename", "sppc.dll"
1717
VALUE "ProductName", "ohook"
18-
VALUE "ProductVersion", "0.3.0.0"
18+
VALUE "ProductVersion", "0.4.0.0"
1919
END
2020
END
2121

0 commit comments

Comments
 (0)