Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nekoppai authored Aug 9, 2023
0 parents commit 76f55c5
Show file tree
Hide file tree
Showing 8 changed files with 288 additions and 0 deletions.
18 changes: 18 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copyright 2023 asdcorp

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
OPT=-Os -Wall
CFLAGS=-fno-ident -fno-stack-check -fno-stack-protector
LDFLAGS=-L. -nostartfiles -nostdlib -lucrt -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

all: sppc32.dll sppc64.dll

sppc32.dll: sppc.c sppc32.res.o libsppcs32.a
$(PREFIX32)$(CC32) $(OPT) $< sppc.def sppc32.res.o -shared -o $@ $(CFLAGS) $(LDFLAGS) -lsppcs32
strip -s $@

sppc64.dll: sppc.c sppc64.res.o libsppcs64.a
$(PREFIX64)$(CC64) $(OPT) $< sppc.def sppc64.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 $< $@

libsppcs32.a:
$(PREFIX32)dlltool -k -dsppcs32.def -llibsppcs32.a

libsppcs64.a:
$(PREFIX64)dlltool -k -dsppcs64.def -llibsppcs64.a

clean:
rm -f *.dll *.res.o *.a
68 changes: 68 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
ohook
=====
An universal Office "activation" hook with main focus of enabling full functionality of subscription editions.

This project is released mainly for our partners. We won't be directly providing any kind support for users.

Installation
------------
Example steps for 64-bit C2R Office running on a 64-bit version of Windows:

1. Create a symlink of the system `sppc.dll` in the Office C2R `System` directory as `sppcs.dll`:
```
mklink "%programfiles%\Microsoft Office\root\vfs\System\sppcs.dll" "%windir%\System32\sppc.dll"
```

2. Copy the hook library as `sppc.dll` to the Office C2R `System` directory
```
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. Make sure to check using `slmgr.vbs -dlv all` that the `Grace` license for Office has `Unlicensed` status, otherwise it may interfere. You may fix this with `slmgr.vbs -upk ACTIVATION_ID`.

Please note these steps are an example. 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 and direct your support queries to them.

Blank keys
----------
The table contains keys for probably the most needed editions.

|Edition|Marketing Name|Key|
|-------|--------------|---|
|O365HomePrem|Microsoft 365|`NBBBB-BBBBB-BBBBB-BBBBG-234RY`|
|O365ProPlus|Microsoft 365 Apps for enterprise|`NBBBB-BBBBB-BBBBB-BBBCF-PPK9C`|

How does this even work?
------------------------
As some would say, "It's trivial."

* The `sppc.dll` copied to the `System` directory in the Office is used instead of the system library.

* The only real license check is done during the startup of the Office applications using the `SLGetLicensingStatusInformation` function.

* The `SLGetLicensingStatusInformation` function can be easily hooked to lie about the activation status.

FAQ
---
### Why not just use a subscription edition with Mondo licenses?
This will be probably the most frequently asked question.

While Mondo 2016 licenses allow all the Office applications to work and support KMS activation, these are only partially updated for newer versions of Office. Thus, the product policy provided by these licenses lack some of the policies found in licenses for newer versions. Since Office product policy mainly consist of entries like `office-UUID`, there is no way to verify which features may not work.

With this method, a correct license for the installed edition is used, meaning every feature should work as intended.

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.

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

License
-------
The project is licensed under the terms of the MIT License.
64 changes: 64 additions & 0 deletions sppc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#define _WIN32_WINNT _WIN32_WINNT_WIN10
#include <windows.h>

typedef GUID SLID;
typedef void *HSLC;

typedef struct {
SLID SkuId;
DWORD eStatus;
DWORD dwGraceTime;
DWORD dwTotalGraceDays;
HRESULT hrReason;
UINT64 qwValidityExpiration;
} SL_LICENSING_STATUS;

HRESULT WINAPI SLGetLicensingStatusInformation(
HSLC hSLC,
SLID *pAppID,
SLID *pProductSkuId,
PWSTR pwszRightName,
UINT *pnStatusCount,
SL_LICENSING_STATUS **ppLicensingStatus
);

BOOL APIENTRY WINAPI dll_main(
HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved
) {
return TRUE;
}

HRESULT WINAPI SLGetLicensingStatusInformationHook(
HSLC hSLC,
SLID *pAppID,
SLID *pProductSkuId,
PWSTR pwszRightName,
UINT *pnStatusCount,
SL_LICENSING_STATUS **ppLicensingStatus
) {
HRESULT hResult = SLGetLicensingStatusInformation(
hSLC,
pAppID,
pProductSkuId,
pwszRightName,
pnStatusCount,
ppLicensingStatus
);

if(hResult != S_OK)
return hResult;

for(int i = 0; i < *pnStatusCount; i++) {
if((*ppLicensingStatus+i)->eStatus == 0) continue;

(*ppLicensingStatus+i)->eStatus = 1;
(*ppLicensingStatus+i)->dwGraceTime = 0;
(*ppLicensingStatus+i)->dwTotalGraceDays = 0;
(*ppLicensingStatus+i)->hrReason = 0;
(*ppLicensingStatus+i)->qwValidityExpiration = 0;
}

return hResult;
}
72 changes: 72 additions & 0 deletions sppc.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
LIBRARY sppc.dll
EXPORTS
;hooked function
SLGetLicensingStatusInformation = SLGetLicensingStatusInformationHook

;everything else
SLCallServer = SPPCS.SLCallServer
SLpAuthenticateGenuineTicketResponse = SPPCS.SLpAuthenticateGenuineTicketResponse
SLpBeginGenuineTicketTransaction = SPPCS.SLpBeginGenuineTicketTransaction
SLpClearActivationInProgress = SPPCS.SLpClearActivationInProgress
SLpDepositDownlevelGenuineTicket = SPPCS.SLpDepositDownlevelGenuineTicket
SLpDepositTokenActivationResponse = SPPCS.SLpDepositTokenActivationResponse
SLpGenerateTokenActivationChallenge = SPPCS.SLpGenerateTokenActivationChallenge
SLpGetGenuineBlob = SPPCS.SLpGetGenuineBlob
SLpGetGenuineLocal = SPPCS.SLpGetGenuineLocal
SLpGetLicenseAcquisitionInfo = SPPCS.SLpGetLicenseAcquisitionInfo
SLpGetMSPidInformation = SPPCS.SLpGetMSPidInformation
SLpGetMachineUGUID = SPPCS.SLpGetMachineUGUID
SLpGetTokenActivationGrantInfo = SPPCS.SLpGetTokenActivationGrantInfo
SLpIAActivateProduct = SPPCS.SLpIAActivateProduct
SLpIsCurrentInstalledProductKeyDefaultKey = SPPCS.SLpIsCurrentInstalledProductKeyDefaultKey
SLpProcessVMPipeMessage = SPPCS.SLpProcessVMPipeMessage
SLpSetActivationInProgress = SPPCS.SLpSetActivationInProgress
SLpTriggerServiceWorker = SPPCS.SLpTriggerServiceWorker
SLpVLActivateProduct = SPPCS.SLpVLActivateProduct
SLClose = SPPCS.SLClose
SLConsumeRight = SPPCS.SLConsumeRight
SLDepositMigrationBlob = SPPCS.SLDepositMigrationBlob
SLDepositOfflineConfirmationId = SPPCS.SLDepositOfflineConfirmationId
SLDepositOfflineConfirmationIdEx = SPPCS.SLDepositOfflineConfirmationIdEx
SLDepositStoreToken = SPPCS.SLDepositStoreToken
SLFireEvent = SPPCS.SLFireEvent
SLGatherMigrationBlob = SPPCS.SLGatherMigrationBlob
SLGatherMigrationBlobEx = SPPCS.SLGatherMigrationBlobEx
SLGenerateOfflineInstallationId = SPPCS.SLGenerateOfflineInstallationId
SLGenerateOfflineInstallationIdEx = SPPCS.SLGenerateOfflineInstallationIdEx
SLGetActiveLicenseInfo = SPPCS.SLGetActiveLicenseInfo
SLGetApplicationInformation = SPPCS.SLGetApplicationInformation
SLGetApplicationPolicy = SPPCS.SLGetApplicationPolicy
SLGetAuthenticationResult = SPPCS.SLGetAuthenticationResult
SLGetEncryptedPIDEx = SPPCS.SLGetEncryptedPIDEx
SLGetGenuineInformation = SPPCS.SLGetGenuineInformation
SLGetInstalledProductKeyIds = SPPCS.SLGetInstalledProductKeyIds
SLGetLicense = SPPCS.SLGetLicense
SLGetLicenseFileId = SPPCS.SLGetLicenseFileId
SLGetLicenseInformation = SPPCS.SLGetLicenseInformation
SLGetPKeyId = SPPCS.SLGetPKeyId
SLGetPKeyInformation = SPPCS.SLGetPKeyInformation
SLGetPolicyInformation = SPPCS.SLGetPolicyInformation
SLGetPolicyInformationDWORD = SPPCS.SLGetPolicyInformationDWORD
SLGetProductSkuInformation = SPPCS.SLGetProductSkuInformation
SLGetSLIDList = SPPCS.SLGetSLIDList
SLGetServiceInformation = SPPCS.SLGetServiceInformation
SLInstallLicense = SPPCS.SLInstallLicense
SLInstallProofOfPurchase = SPPCS.SLInstallProofOfPurchase
SLInstallProofOfPurchaseEx = SPPCS.SLInstallProofOfPurchaseEx
SLIsGenuineLocalEx = SPPCS.SLIsGenuineLocalEx
SLLoadApplicationPolicies = SPPCS.SLLoadApplicationPolicies
SLOpen = SPPCS.SLOpen
SLPersistApplicationPolicies = SPPCS.SLPersistApplicationPolicies
SLPersistRTSPayloadOverride = SPPCS.SLPersistRTSPayloadOverride
SLReArm = SPPCS.SLReArm
SLRegisterEvent = SPPCS.SLRegisterEvent
SLRegisterPlugin = SPPCS.SLRegisterPlugin
SLSetAuthenticationData = SPPCS.SLSetAuthenticationData
SLSetCurrentProductKey = SPPCS.SLSetCurrentProductKey
SLSetGenuineInformation = SPPCS.SLSetGenuineInformation
SLUninstallLicense = SPPCS.SLUninstallLicense
SLUninstallProofOfPurchase = SPPCS.SLUninstallProofOfPurchase
SLUnloadApplicationPolicies = SPPCS.SLUnloadApplicationPolicies
SLUnregisterEvent = SPPCS.SLUnregisterEvent
SLUnregisterPlugin = SPPCS.SLUnregisterPlugin
26 changes: 26 additions & 0 deletions sppc.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
1 VERSIONINFO
FILEVERSION 0,1,0,0
PRODUCTVERSION 0,1,0,0
FILEOS 0x40004L
FILETYPE 0x2L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "Anomalous Software Deterioration Corporation"
VALUE "FileDescription", "ohook SPPC"
VALUE "FileVersion", "0.1.0.0"
VALUE "InternalName", "sppc"
VALUE "LegalCopyright", "© 2023 Anomalous Software Deterioration Corporation"
VALUE "OriginalFilename", "sppc.dll"
VALUE "ProductName", "ohook"
VALUE "ProductVersion", "0.1.0.0"
END
END

BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
3 changes: 3 additions & 0 deletions sppcs32.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LIBRARY sppcs.dll
EXPORTS
SLGetLicensingStatusInformation@24
3 changes: 3 additions & 0 deletions sppcs64.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LIBRARY sppcs.dll
EXPORTS
SLGetLicensingStatusInformation

0 comments on commit 76f55c5

Please sign in to comment.