libkms-test.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "libkms.h"
  5. #include "kms.h"
  6. #include "endian.h"
  7. static const char ePID[] = { 'T', 0, 'E', 0, 'S', 0, 'T', 0, 0, 0 };
  8. __stdcall BOOL KmsCallBack(const REQUEST *const baseRequest, RESPONSE *const baseResponse, BYTE *const hwId, const char* const ipstr)
  9. {
  10. printf("libvlmcs-test.c: Entered KmsCallBack for client %s\n", ipstr);
  11. memcpy(&baseResponse->CMID, &baseRequest->CMID, sizeof(GUID));
  12. memcpy(&baseResponse->ClientTime, &baseRequest->ClientTime, sizeof(FILETIME));
  13. memcpy(&baseResponse->KmsPID, ePID, sizeof(ePID));
  14. baseResponse->Version = baseRequest->Version;
  15. baseResponse->Count = LE32(LE32(baseRequest->N_Policy) << 1);
  16. baseResponse->PIDSize = sizeof(ePID);
  17. baseResponse->VLActivationInterval = LE32(120);
  18. baseResponse->VLRenewalInterval = LE32(10080);
  19. if (hwId && baseResponse->MajorVer > 5) memcpy(hwId, "\x01\x02\x03\x04\x05\x06\x07\x08", 8);
  20. return TRUE;
  21. }
  22. int main(int argc, char** argv)
  23. {
  24. int version = GetLibKmsVersion();
  25. if (version < 0x30001)
  26. {
  27. fprintf(stderr, "KMS library version %u.%u or greater required\n", (unsigned int)(version >> 16), (unsigned int)(version & 0xffff));
  28. }
  29. printf("%s: Program start\n", GetEmulatorVersion());
  30. StartKmsServer(1688, KmsCallBack);
  31. return 0;
  32. }