Skip to content

Commit

Permalink
Move TimeOfLastHeartbeatFailure changes to ohook+
Browse files Browse the repository at this point in the history
  • Loading branch information
nekoppai authored Mar 12, 2024
1 parent 8591604 commit 65282ba
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 26 deletions.
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
20 changes: 16 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
30 changes: 19 additions & 11 deletions sl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 12 additions & 3 deletions sppc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#include <shlwapi.h>
#include "sl.h"

#ifdef PLUS_BUILD
BOOL bIsHeartbeatRegistryModified = FALSE;
#endif

BOOL IsGracePeriodProduct(HSLC hSLC, SLID *pProductSkuId) {
PBYTE pBuffer = 0;
Expand All @@ -23,6 +25,7 @@ BOOL IsGracePeriodProduct(HSLC hSLC, SLID *pProductSkuId) {
return FALSE;
}

#ifdef PLUS_BUILD
VOID ModifyHeartbeatRegistry() {
HKEY hKey = 0;

Expand All @@ -47,6 +50,7 @@ VOID ModifyHeartbeatRegistry() {

RegCloseKey(hKey);
}
#endif

HRESULT WINAPI SLGetLicensingStatusInformationHook(
HSLC hSLC,
Expand All @@ -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;
}
Expand Down
20 changes: 13 additions & 7 deletions sppc.rc
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down

0 comments on commit 65282ba

Please sign in to comment.