Skip to content

Commit 5b08c8f

Browse files
authored
Merge pull request Wind4#38 from rouben/master
vlmcsd-1113-2020-03-28-Hotbird64
2 parents ce1dfa1 + e599080 commit 5b08c8f

25 files changed

+2530
-2291
lines changed

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ help:
225225
@echo " DNS_PARSER=internal Use $(BASE_CLIENT_NAME) internal DNS parsing routines. No effect on MingW (native Windows)."
226226
@echo ""
227227
@echo "Other useful CFLAGS"
228+
@echo " -DNO_COMPILER_UAA Do not use compiler support for byte swapping and unaligned access"
228229
@echo " -DFULL_INTERNAL_DATA Embed full internal KMS data in $(BASE_PROGRAM_NAME)."
229230
@echo " -DSUPPORT_WINE Add code that the Windows version of $(BASE_PROGRAM_NAME) runs on Wine if MSRPC=1"
230231
@echo " -D_PEDANTIC Report rare error/warning conditions instead of silently ignoring them."
231-
@echo " -DINCLUDE_BETAS Include SKU / activation IDs for obsolete beta/preview products."
232232
@echo " -DFD_SETSIZE=<x> Allow <x> -L statements in $(BASE_PROGRAM_NAME) (default: 64 on Windows, 1024 on most Unixes)."
233233

etc/vlmcsd.kmd

530 Bytes
Binary file not shown.

man/vlmcsd-floppy.7

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.mso www.tmac
2-
.TH "VLMCSD-FLOPPY" 7 "May 2017" "Hotbird64" "KMS Activation Manual"
2+
.TH "VLMCSD-FLOPPY" 7 "February 2019" "Hotbird64" "KMS Activation Manual"
33
.LO 8
44

55
.SH NAME
@@ -107,6 +107,9 @@ Defines the ePID that is used for Office 2016 activations. If you ommit this par
107107
.IP "\fBOFFICE2016=\fIepid\fR"
108108
Defines the ePID that is used for Office 2016 activations. If you ommit this parameter, \fBvlmcsd\fR(8) generates a random ePID when it is started.
109109

110+
.IP "\fBOFFICE2019=\fIepid\fR"
111+
Defines the ePID that is used for Office 2019 activations. If you ommit this parameter, \fBvlmcsd\fR(8) generates a random ePID when it is started.
112+
110113
.IP "\fBWINCHINAGOV=\fIepid\fR"
111114
Defines the ePID that is used for Windows China Government Edition activations (Enterprise G/GN). If you ommit this parameter, \fBvlmcsd\fR(8) generates a random ePID when it is started.
112115

man/vlmcsd.8

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.mso www.tmac
2-
.TH VLMCSD 8 "October 2018" "Hotbird64" "KMS Activation Manual"
2+
.TH VLMCSD 8 "February 2019" "Hotbird64" "KMS Activation Manual"
33
.LO 8
44

55
.SH NAME
@@ -312,9 +312,9 @@ Signaling is not available in the native Windows version and in the Cygwin versi
312312
\fBvlmcsd\fR compiles and runs on Linux, Windows (no Cygwin required but explicitly supported), Mac OS X, FreeBSD, NetBSD, OpenBSD, Dragonfly BSD, Minix, Solaris, OpenIndiana, Android and iOS. Other POSIX or unixoid OSses may work with unmodified sources or may require minor porting efforts.
313313

314314
.SH SUPPORTED PRODUCTS
315-
\fBvlmcsd\fR can answer activation requests for the following products: Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10 (up to 1703), Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server 2016, Office 2010, Project 2010, Visio 2010, Office 2013, Project 2013, Visio 2013, Office 2016, Project 2016, Visio 2016. Newer products may work as long as the KMS protocol does not change. A complete list of fully supported products can be obtained using the \fB-x\fR option of \fBvlmcs\fR(1).
315+
\fBvlmcsd\fR can answer activation requests for the following products: Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10 (up to 1809), Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server 2016, Office 2010, Project 2010, Visio 2010, Office 2013, Project 2013, Visio 2013, Office 2016, Project 2016, Visio 2016, Office 2019, Project 2019, Visio 2019. Newer products may work as long as the KMS protocol does not change. A complete list of fully supported products can be obtained using the \fB-x\fR option of \fBvlmcs\fR(1).
316316
.PP
317-
Office, Project and Visio must be volume license versions.
317+
Windows Vista, Windows 7, Office, Project and Visio must be volume license versions.
318318

319319
.SH FILES
320320
.IP "\fBvlmcsd.ini\fR(5)"

src/endian.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "endian.h"
77

88
#if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) \
9-
&& defined(BS16) && defined(BS32) && defined(BS64)
9+
&& defined(BS16) && defined(BS32) && defined(BS64) && !defined(NO_COMPILER_UAA)
1010

1111
#else // ! defined(__BYTE_ORDER)
1212

@@ -136,8 +136,12 @@ unsigned short GET_UAA16LE(void *p, unsigned int i)
136136
(unsigned short)_p[ 0 ] |
137137
(unsigned short)_p[ 1 ] << 8;
138138
}
139+
#endif
139140

140141

142+
#if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) \
143+
&& defined(BS16) && defined(BS32) && defined(BS64)
144+
#else
141145
unsigned short BE16(unsigned short x)
142146
{
143147
return GET_UAA16BE(&x, 0);

src/endian.h

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
//
1010
// Unaligned access
1111
//
12+
13+
#if !defined(NO_COMPILER_UAA)
1214
#define UAA16(p, i) (((PACKED16*)p)->val[i])
1315
#define UAA32(p, i) (((PACKED32*)p)->val[i])
1416
#define UAA64(p, i) (((PACKED64*)p)->val[i])
15-
16-
#define UA64(p) UAA64(p, 0)
17-
#define UA32(p) UAA32(p, 0)
18-
#define UA16(p) UAA16(p, 0)
17+
#endif
1918

2019
//
2120
//Byteswap: Use compiler support if available
2221
//
22+
#ifndef NO_COMPILER_UAA
2323
#ifdef __has_builtin // Clang supports this
2424

2525
#if __has_builtin(__builtin_bswap16)
@@ -56,6 +56,7 @@
5656
#endif // GNU C > 4.7
5757
#endif // __GNUC__ > 4
5858
#endif // __GNUC__
59+
#endif // NO_COMPILER_UAA
5960

6061
//
6162
// Byteorder
@@ -198,6 +199,10 @@
198199
#define __BE64(x) BS64(x)
199200
#define __LE64(x) (x)
200201

202+
#define PUT_UA16(p, v) PUT_UA16LE(p, v)
203+
#define PUT_UA32(p, v) PUT_UA32LE(p, v)
204+
#define PUT_UA64(p, v) PUT_UA64LE(p, v)
205+
201206
#else // __BYTE_ORDER == __BIG_ENDIAN
202207

203208
#define __BE16(x) (x)
@@ -207,8 +212,38 @@
207212
#define __BE64(x) (x)
208213
#define __LE64(x) BS64(x)
209214

215+
#define PUT_UA16(p, v) PUT_UA16BE(p, v)
216+
#define PUT_UA32(p, v) PUT_UA32BE(p, v)
217+
#define PUT_UA64(p, v) PUT_UA64BE(p, v)
218+
210219
#endif // __BYTE_ORDER
211220

221+
#define BE16(x) __BE16(x)
222+
#define LE16(x) __LE16(x)
223+
#define BE32(x) __BE32(x)
224+
#define LE32(x) __LE32(x)
225+
#define BE64(x) __BE64(x)
226+
#define LE64(x) __LE64(x)
227+
228+
#else
229+
230+
extern unsigned short BE16(unsigned short x);
231+
232+
extern unsigned short LE16(unsigned short x);
233+
234+
extern unsigned int BE32(unsigned int x);
235+
236+
extern unsigned int LE32(unsigned int x);
237+
238+
extern unsigned long long BE64(unsigned long long x);
239+
240+
extern unsigned long long LE64(unsigned long long x);
241+
242+
#endif // defined(__BYTE_ORDER)
243+
244+
#if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) \
245+
&& defined(BS16) && defined(BS32) && defined(BS64) &&!defined(NO_COMPILER_UAA)
246+
212247
#define PUT_UAA64BE(p, v, i) ( UAA64(p, i) = __BE64(v) )
213248
#define PUT_UAA32BE(p, v, i) ( UAA32(p, i) = __BE32(v) )
214249
#define PUT_UAA16BE(p, v, i) ( UAA16(p, i) = __BE16(v) )
@@ -225,56 +260,37 @@
225260
#define GET_UAA32LE(p, i) __LE32(UAA32(p, i))
226261
#define GET_UAA16LE(p, i) __LE16(UAA16(p, i))
227262

228-
#define BE16(x) __BE16(x)
229-
#define LE16(x) __LE16(x)
230-
#define BE32(x) __BE32(x)
231-
#define LE32(x) __LE32(x)
232-
#define BE64(x) __BE64(x)
233-
#define LE64(x) __LE64(x)
234263

235264
#else // ! defined(__BYTE_ORDER)
236265

237-
extern void PUT_UAA64BE(void *p, unsigned long long v, unsigned int i);
266+
extern void PUT_UAA64BE(void* p, unsigned long long v, unsigned int i);
238267

239-
extern void PUT_UAA32BE(void *p, unsigned int v, unsigned int i);
268+
extern void PUT_UAA32BE(void* p, unsigned int v, unsigned int i);
240269

241-
extern void PUT_UAA16BE(void *p, unsigned short v, unsigned int i);
270+
extern void PUT_UAA16BE(void* p, unsigned short v, unsigned int i);
242271

243272

244-
extern void PUT_UAA64LE(void *p, unsigned long long v, unsigned int i);
273+
extern void PUT_UAA64LE(void* p, unsigned long long v, unsigned int i);
245274

246-
extern void PUT_UAA32LE(void *p, unsigned int v, unsigned int i);
275+
extern void PUT_UAA32LE(void* p, unsigned int v, unsigned int i);
247276

248-
extern void PUT_UAA16LE(void *p, unsigned short v, unsigned int i);
277+
extern void PUT_UAA16LE(void* p, unsigned short v, unsigned int i);
249278

250279

251-
extern unsigned long long GET_UAA64BE(void *p, unsigned int i);
280+
extern unsigned long long GET_UAA64BE(void* p, unsigned int i);
252281

253-
extern unsigned int GET_UAA32BE(void *p, unsigned int i);
282+
extern unsigned int GET_UAA32BE(void* p, unsigned int i);
254283

255-
extern unsigned short GET_UAA16BE(void *p, unsigned int i);
284+
extern unsigned short GET_UAA16BE(void* p, unsigned int i);
256285

257286

258-
extern unsigned long long GET_UAA64LE(void *p, unsigned int i);
287+
extern unsigned long long GET_UAA64LE(void* p, unsigned int i);
259288

260-
extern unsigned int GET_UAA32LE(void *p, unsigned int i);
289+
extern unsigned int GET_UAA32LE(void* p, unsigned int i);
261290

262-
extern unsigned short GET_UAA16LE(void *p, unsigned int i);
263-
264-
265-
extern unsigned short BE16(unsigned short x);
266-
267-
extern unsigned short LE16(unsigned short x);
268-
269-
extern unsigned int BE32(unsigned int x);
270-
271-
extern unsigned int LE32(unsigned int x);
272-
273-
extern unsigned long long BE64(unsigned long long x);
274-
275-
extern unsigned long long LE64(unsigned long long x);
291+
extern unsigned short GET_UAA16LE(void* p, unsigned int i);
292+
#endif
276293

277-
#endif // defined(__BYTE_ORDER)
278294

279295

280296
#define PUT_UA64BE(p, v) PUT_UAA64BE(p, v, 0)

src/helpers.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,14 +434,14 @@ __pure BOOL getArgumentBool(int_fast8_t *result, const char *const argument)
434434
#ifndef NO_EXTERNAL_DATA
435435
__noreturn static void dataFileReadError()
436436
{
437-
int error = errno;
437+
const int error = errno;
438438
errorout("Fatal: Could not read %s: %s\n", fn_data, strerror(error));
439439
exit(error);
440440
}
441441

442442
__noreturn static void dataFileFormatError()
443443
{
444-
errorout("Fatal: %s is not a KMS data file\n", fn_data);
444+
errorout("Fatal: %s is not a KMS data file version 2.x\n", fn_data);
445445
exit(VLMCSD_EINVAL);
446446
}
447447
#endif // NO_EXTERNAL_DATA
@@ -526,7 +526,7 @@ static void getDefaultDataFile()
526526
getExeName();
527527
strncpy(fileName, fn_exe, MAX_PATH);
528528
PathRemoveFileSpec(fileName);
529-
strncat(fileName, "\\vlmcsd.kmd", MAX_PATH);
529+
strncat(fileName, "\\vlmcsd.kmd", MAX_PATH - 11);
530530
fn_data = vlmcsd_strdup(fileName);
531531
}
532532
#else // !_WIN32
@@ -588,12 +588,12 @@ void loadKmsData()
588588
KmsData = (PVlmcsdHeader_t)vlmcsd_malloc(size);
589589
if (fseek(file, 0, SEEK_SET)) dataFileReadError();
590590

591-
size_t bytesRead = fread(KmsData, 1, size, file);
591+
const size_t bytesRead = fread(KmsData, 1, size, file);
592592
if ((long)bytesRead != size) dataFileReadError();
593593
fclose(file);
594594

595595
# if !defined(NO_LOG) && !defined(NO_SOCKETS)
596-
if (!InetdMode) logger("Read KMS data file version %u.%u %s\n", (unsigned int)KmsData->MajorVer, (unsigned int)KmsData->MinorVer, fn_data);
596+
if (!InetdMode) logger("Read KMS data file version %u.%u %s\n", (unsigned int)LE16(KmsData->MajorVer), (unsigned int)LE16(KmsData->MinorVer), fn_data);
597597
# endif // NO_LOG
598598
}
599599
}
@@ -610,6 +610,7 @@ void loadKmsData()
610610
KmsData->AppItemCount = LE32(KmsData->AppItemCount);
611611
KmsData->KmsItemCount = LE32(KmsData->KmsItemCount);
612612
KmsData->SkuItemCount = LE32(KmsData->SkuItemCount);
613+
KmsData->HostBuildCount = LE32(KmsData->HostBuildCount);
613614

614615
uint32_t i;
615616

@@ -625,6 +626,7 @@ void loadKmsData()
625626
{
626627
PCsvlkData_t csvlkData = &KmsData->CsvlkData[i];
627628
csvlkData->EPid = (char*)KmsData + LE64(csvlkData->EPidOffset);
629+
csvlkData->ReleaseDate = LE64(csvlkData->ReleaseDate);
628630
# ifndef UNSAFE_DATA_LOAD
629631
if (csvlkData->EPid > (char*)KmsData + size) dataFileFormatError();
630632
# endif // UNSAFE_DATA_LOAD
@@ -636,12 +638,25 @@ void loadKmsData()
636638
# endif // NO_RANDOM_EPID
637639
}
638640

641+
for (i = 0; i < (uint32_t)KmsData->HostBuildCount; i++)
642+
{
643+
PHostBuild_t hostBuild = &KmsData->HostBuildList[i];
644+
hostBuild->BuildNumber = LE32(hostBuild->BuildNumber);
645+
hostBuild->Flags = LE32(hostBuild->Flags);
646+
hostBuild->PlatformId = LE32(hostBuild->PlatformId);
647+
hostBuild->ReleaseDate = LE64(hostBuild->ReleaseDate);
648+
hostBuild->DisplayName = (char*)KmsData + LE64(hostBuild->DisplayNameOffset);
649+
# ifndef UNSAFE_DATA_LOAD
650+
if (hostBuild->DisplayName > (char*)KmsData + size) dataFileFormatError();
651+
# endif // UNSAFE_DATA_LOAD
652+
}
653+
639654
const uint32_t totalItemCount = KmsData->AppItemCount + KmsData->KmsItemCount + KmsData->SkuItemCount;
640655

641656
# ifndef NO_EXTERNAL_DATA
642657
if (
643658
memcmp(KmsData->Magic, "KMD", sizeof(KmsData->Magic)) ||
644-
KmsData->MajorVer != 1
659+
KmsData->MajorVer != 2
645660
# ifndef UNSAFE_DATA_LOAD
646661
||
647662
sizeof(VlmcsdHeader_t) + totalItemCount * sizeof(VlmcsdData_t) >= ((uint64_t)size)

0 commit comments

Comments
 (0)