6 #define CONFIG "config.h"
10 #define EXTERNAL dllexport
12 #define DLLVERSION 0x30000
15 #include "shared_globals.h"
24 #include <netinet/in.h>
27 static int_fast8_t IsServerStarted
= FALSE
;
30 EXTERNC
__declspec(EXTERNAL
) DWORD __cdecl SendActivationRequest
32 const char* const hostname
,
34 RESPONSE
* baseResponse
,
35 const REQUEST
* const baseRequest
,
36 RESPONSE_RESULT
* result
, BYTE
*hwid
39 return !0; // not yet implemented
43 EXTERNC
__declspec(EXTERNAL
) DWORD __cdecl
StartKmsServer(const int port
, RequestCallback_t requestCallback
)
45 char listenAddress
[64];
47 if (IsServerStarted
) return !0;
51 // Windows Sockets must be initialized
55 if ((error
= WSAStartup(0x0202, &wsadata
)))
62 CreateResponseBase
= requestCallback
;
65 int_fast8_t haveIPv4
= FALSE
;
66 int_fast8_t haveIPv6
= FALSE
;
68 if (checkProtocolStack(AF_INET
)) { haveIPv4
= TRUE
; maxsockets
++; }
69 if (checkProtocolStack(AF_INET6
)) { haveIPv6
= TRUE
; maxsockets
++; }
71 if(!maxsockets
) return !0;
73 SocketList
= (SOCKET
*)vlmcsd_malloc(sizeof(SOCKET
) * (size_t)maxsockets
);
78 snprintf(listenAddress
, 64, "0.0.0.0:%u", (unsigned int)port
);
79 addListeningSocket(listenAddress
);
84 snprintf(listenAddress
, 64, "[::]:%u", (unsigned int)port
);
85 addListeningSocket(listenAddress
);
94 IsServerStarted
= TRUE
;
98 IsServerStarted
= FALSE
;
103 EXTERNC
__declspec(EXTERNAL
) DWORD __cdecl
StopKmsServer()
105 if (!IsServerStarted
) return !0;
107 closeAllListeningSockets();
108 if (SocketList
) free(SocketList
);
113 EXTERNC
__declspec(EXTERNAL
) int __cdecl
GetLibKmsVersion()