├── clipc32.def ├── clipc64.def ├── slc64.def ├── slc32.def ├── Makefile ├── LICENSE ├── readme.md ├── clic.h └── clic.c /clipc32.def: -------------------------------------------------------------------------------- 1 | LIBRARY "CLIPC.dll" 2 | EXPORTS 3 | ClipGetSubscriptionStatus@4 4 | -------------------------------------------------------------------------------- /clipc64.def: -------------------------------------------------------------------------------- 1 | LIBRARY "CLIPC.dll" 2 | EXPORTS 3 | ClipGetSubscriptionStatus 4 | -------------------------------------------------------------------------------- /slc64.def: -------------------------------------------------------------------------------- 1 | LIBRARY "SLC.dll" 2 | EXPORTS 3 | SLGetWindowsInformation 4 | SLGetWindowsInformationDWORD 5 | SLIsWindowsGenuineLocal 6 | -------------------------------------------------------------------------------- /slc32.def: -------------------------------------------------------------------------------- 1 | LIBRARY "SLC.dll" 2 | EXPORTS 3 | SLGetWindowsInformation@16 4 | SLGetWindowsInformationDWORD@8 5 | SLIsWindowsGenuineLocal@4 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | OPT=-Os -Wall 2 | CFLAGS=-fno-ident -nostdlib 3 | LDFLAGS=-L. -lucrt -lkernel32 -lole32 -Wl,--exclude-all-symbols,--enable-stdcall-fixup,--dynamicbase,--nxcompat,--subsystem,console:6.0 4 | 5 | PREFIX32=C:/mingw32/bin/ 6 | PREFIX64=C:/mingw64/bin/ 7 | 8 | CC32=gcc -Wl,-e_wWinMain -municode 9 | CC64=gcc -Wl,-ewWinMain -municode 10 | 11 | all: clic32.exe clic64.exe 12 | 13 | clic32.exe: clic.c libclipc32.a libslc32.a 14 | $(PREFIX32)$(CC32) $(OPT) $< -o $@ $(CFLAGS) $(LDFLAGS) -lslc32 -lclipc32 15 | strip -s $@ 16 | 17 | clic64.exe: clic.c libclipc64.a libslc64.a 18 | $(PREFIX64)$(CC64) $(OPT) $< -o $@ $(CFLAGS) $(LDFLAGS) -lslc64 -lclipc64 19 | strip -s $@ 20 | 21 | libslc32.a: 22 | $(PREFIX32)dlltool -k -dslc32.def -llibslc32.a 23 | 24 | libslc64.a: 25 | $(PREFIX64)dlltool -k -dslc64.def -llibslc64.a 26 | 27 | libclipc32.a: 28 | $(PREFIX32)dlltool -k -dclipc32.def -llibclipc32.a 29 | 30 | libclipc64.a: 31 | $(PREFIX64)dlltool -k -dclipc64.def -llibclipc64.a 32 | 33 | clean: 34 | rm -f *.exe *.a 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2023 asdcorp 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the “Software”), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | clic 2 | ==== 3 | 4 | A simple tool to read the activation and subscription status of Windows. 5 | 6 | Usage 7 | ----- 8 | 9 | Run clic using the command prompt. 10 | 11 | Values documentation 12 | -------------------- 13 | 14 | |Value name|Meaning| 15 | |----------|-------| 16 | | ruleId | Software Protection Platform Rule ID | 17 | | AppId | Software Protection Platform Application ID | 18 | | SkuId | Software Protection Platform SKU ID | 19 | | LastNotificationId | Last Software Protection Platform Notification | 20 | | GraceEndDate | Grace period/volume activation expiration | 21 | | LicenseState | Current state of the license | 22 | | LicenseExpirationDate | Time-based license expiration | 23 | | LastConsumptionReason | Reason of last license installation | 24 | | KernelTimebombDate | Expiration of prerelease Windows version | 25 | | PartialProductKey | Last 5 characters of the product key | 26 | | ProductKeyType | Channel of the product key | 27 | | volumeActivationOrder | Order of the volume activation | 28 | | uxDifferentiator | User Experience Differentiator | 29 | | LastActivationHResult | Error code of a last activation attempt | 30 | | DigitalLicense | Is the machine activated using a digital license | 31 | | SubscriptionSupportedEdition | Can subscriptions be used on the current edition | 32 | | SubscriptionEnabled | Is the subscription enabled | 33 | | SubscriptionSku | Edition ID of the subscription edition | 34 | | SubscriptionState | State of the subscription (`1` = Active, `2` = Not active) | 35 | | IsWindowsGenuine | Is the copy of Windows correctly licensed | 36 | 37 | License 38 | ------- 39 | The project is licensed under the terms of the MIT License. 40 | -------------------------------------------------------------------------------- /clic.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIC_H 2 | #define CLIC_H 3 | 4 | typedef enum _tagSLDATATYPE { 5 | SL_DATA_NONE = REG_NONE, 6 | SL_DATA_SZ = REG_SZ, 7 | SL_DATA_DWORD = REG_DWORD, 8 | SL_DATA_BINARY = REG_BINARY, 9 | SL_DATA_MULTI_SZ, 10 | SL_DATA_SUM = 100 11 | } SLDATATYPE; 12 | 13 | typedef struct _tagIEditionUpgradeManagerVtbl { 14 | HRESULT (WINAPI *QueryInterface)( 15 | VOID *pThis, 16 | const IID *riid, 17 | void **ppvObject 18 | ); 19 | 20 | ULONG (WINAPI *AddRef)( 21 | VOID *pThis 22 | ); 23 | 24 | ULONG (WINAPI *Release)( 25 | VOID *pThis 26 | ); 27 | 28 | HRESULT (WINAPI *InitializeWindow)( 29 | VOID *pThis, 30 | OLE_HANDLE parentWindow 31 | ); 32 | 33 | HRESULT (WINAPI *UpdateOperatingSystem)( 34 | VOID *pThis, 35 | LPWSTR lpwszContentId, 36 | DWORD dwAsync 37 | ); 38 | 39 | HRESULT (WINAPI *ShowProductKeyUI)( 40 | VOID *pThis, 41 | DWORD dwAsync 42 | ); 43 | 44 | HRESULT (WINAPI *UpdateOperatingSystemWithParams)( 45 | VOID *pThis, 46 | LPWSTR lpwszPKey, 47 | BOOL bReboot, 48 | BOOL bShowUI, 49 | BOOL bShowPrompt, 50 | BOOL bCommandLine, 51 | DWORD dwAsync 52 | ); 53 | 54 | HRESULT (WINAPI *AcquireModernLicenseForWindows)( 55 | VOID *pThis, 56 | DWORD dwAsync, 57 | DWORD *pdwReturnCode 58 | ); 59 | 60 | HRESULT (WINAPI *AcquireModernLicenseWithPreviousId)( 61 | VOID *pThis, 62 | LPWSTR lpwszPreviousId, 63 | DWORD *pdwReturnCode 64 | ); 65 | } IEditionUpgradeManagerVtbl; 66 | 67 | typedef struct _tagIEditionUpgradeManager { 68 | IEditionUpgradeManagerVtbl *lpVtbl; 69 | } IEditionUpgradeManager; 70 | 71 | typedef struct _tagSUBSCRIPTIONSTATUS { 72 | DWORD dwEnabled; 73 | DWORD dwSku; 74 | DWORD dwState; 75 | } SUBSCRIPTIONSTATUS; 76 | 77 | HRESULT WINAPI ClipGetSubscriptionStatus( 78 | SUBSCRIPTIONSTATUS **ppStatus 79 | ); 80 | 81 | HRESULT WINAPI SLGetWindowsInformation( 82 | PCWSTR pwszValueName, 83 | SLDATATYPE *peDataType, 84 | UINT *pcbValue, 85 | PBYTE *ppbValue 86 | ); 87 | 88 | HRESULT WINAPI SLGetWindowsInformationDWORD( 89 | PCWSTR pwszValueName, 90 | DWORD *pdwValue 91 | ); 92 | 93 | HRESULT WINAPI SLIsWindowsGenuineLocal( 94 | DWORD *dwGenuine 95 | ); 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /clic.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "clic.h" 6 | 7 | #define BoolToWStr(bVal) ((bVal) ? L"TRUE" : L"FALSE") 8 | 9 | BOOL InitializeDigitalLicenseCheck(IEditionUpgradeManager **m_IEditionUpgradeManager) { 10 | GUID guidEditionUpgradeManager = { 11 | 0x17CCA47D, 0xDAE5, 0x4E4A, 12 | {0xAC, 0x42, 0xCC, 0x54, 0xE2, 0x8F, 0x33, 0x4A} 13 | }; 14 | 15 | GUID guidIEditionUpgradeManager = { 16 | 0xF2DCB80D, 0x0670, 0x44BC, 17 | {0x90, 0x02, 0xCD, 0x18, 0x68, 0x87, 0x30, 0xAF} 18 | }; 19 | 20 | if(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)) 21 | return FALSE; 22 | 23 | if(CoCreateInstance( 24 | &guidEditionUpgradeManager, 25 | 0, 26 | CLSCTX_INPROC_SERVER, 27 | &guidIEditionUpgradeManager, 28 | (PVOID*)m_IEditionUpgradeManager 29 | )) { 30 | return FALSE; 31 | } 32 | 33 | return TRUE; 34 | } 35 | 36 | BOOL PrintStateData() { 37 | PWSTR pwszStateData = 0; 38 | UINT cbSize = 0; 39 | 40 | if(SLGetWindowsInformation( 41 | L"Security-SPP-Action-StateData", 42 | NULL, 43 | &cbSize, 44 | (PBYTE*)&pwszStateData 45 | )) { 46 | return FALSE; 47 | } 48 | 49 | for(INT i = 0; i < (cbSize / 2); i++) { 50 | if(pwszStateData[i] == L';') 51 | pwszStateData[i] = L'\n'; 52 | } 53 | 54 | wprintf(L"%ws\n", pwszStateData); 55 | 56 | LocalFree(pwszStateData); 57 | return TRUE; 58 | } 59 | 60 | BOOL PrintLastActivationHRresult() { 61 | PDWORD pdwLastHResult = 0; 62 | UINT cbSize = 0; 63 | 64 | if(SLGetWindowsInformation( 65 | L"Security-SPP-LastWindowsActivationHResult", 66 | NULL, 67 | &cbSize, 68 | (PBYTE*)&pdwLastHResult 69 | )) { 70 | return FALSE; 71 | } 72 | 73 | wprintf(L"LastActivationHResult=0x%08x\n", *pdwLastHResult); 74 | 75 | LocalFree(pdwLastHResult); 76 | return TRUE; 77 | } 78 | 79 | BOOL PrintDigitalLicenseStatus() { 80 | IEditionUpgradeManager *m_IEditionUpgradeManager; 81 | DWORD dwReturnCode = 0; 82 | BOOL bDigitalLicense = FALSE; 83 | 84 | if(!InitializeDigitalLicenseCheck(&m_IEditionUpgradeManager)) 85 | return FALSE; 86 | 87 | if(m_IEditionUpgradeManager->lpVtbl->AcquireModernLicenseForWindows( 88 | m_IEditionUpgradeManager, 89 | 1, 90 | &dwReturnCode 91 | )) { 92 | return FALSE; 93 | } 94 | 95 | bDigitalLicense = (dwReturnCode != 1 && dwReturnCode <= INT_MAX); 96 | wprintf(L"DigitalLicense=%ws\n", BoolToWStr(bDigitalLicense)); 97 | 98 | return TRUE; 99 | } 100 | 101 | BOOL PrintSubscriptionStatus() { 102 | SUBSCRIPTIONSTATUS *pStatus; 103 | DWORD dwSupported = 0; 104 | 105 | if(SLGetWindowsInformationDWORD(L"ConsumeAddonPolicySet", &dwSupported)) 106 | return FALSE; 107 | 108 | wprintf(L"SubscriptionSupportedEdition=%ws\n", BoolToWStr(dwSupported)); 109 | 110 | if(ClipGetSubscriptionStatus(&pStatus)) 111 | return FALSE; 112 | 113 | wprintf(L"SubscriptionEnabled=%ws\n", BoolToWStr(pStatus->dwEnabled)); 114 | 115 | if(pStatus->dwEnabled == 0) { 116 | LocalFree(pStatus); 117 | return TRUE; 118 | } 119 | 120 | wprintf(L"SubscriptionSku=%d\n", pStatus->dwSku); 121 | wprintf(L"SubscriptionState=%d\n", pStatus->dwState); 122 | 123 | LocalFree(pStatus); 124 | return TRUE; 125 | } 126 | 127 | BOOL PrintIsWindowsGenuine() { 128 | DWORD dwGenuine = 0; 129 | PCWSTR ppwszGenuineStates[] = { 130 | L"SL_GEN_STATE_IS_GENUINE", 131 | L"SL_GEN_STATE_INVALID_LICENSE", 132 | L"SL_GEN_STATE_TAMPERED", 133 | L"SL_GEN_STATE_OFFLINE", 134 | L"SL_GEN_STATE_LAST" 135 | }; 136 | 137 | if(SLIsWindowsGenuineLocal(&dwGenuine)) 138 | return FALSE; 139 | 140 | if(dwGenuine < 5) { 141 | wprintf(L"IsWindowsGenuine=%ws\n", ppwszGenuineStates[dwGenuine]); 142 | } else { 143 | wprintf(L"IsWindowsGenuine=%d\n", dwGenuine); 144 | } 145 | 146 | return TRUE; 147 | } 148 | 149 | int WINAPI wWinMain( 150 | HINSTANCE hInstance, 151 | HINSTANCE hPrevInstance, 152 | PWSTR pCmdLine, 153 | int nCmdShow 154 | ) { 155 | BOOL bError = FALSE; 156 | 157 | if(!PrintStateData()) 158 | bError = TRUE; 159 | 160 | if(!PrintLastActivationHRresult()) 161 | bError = TRUE; 162 | 163 | if(!PrintDigitalLicenseStatus()) 164 | bError = TRUE; 165 | 166 | if(!PrintSubscriptionStatus()) 167 | bError = TRUE; 168 | 169 | if(!PrintIsWindowsGenuine()) 170 | bError = TRUE; 171 | 172 | exit(bError); 173 | } 174 | --------------------------------------------------------------------------------