mirror of
https://github.com/Wind4/vlmcsd.git
synced 2026-05-26 20:21:22 +02:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 032d201234 | |||
| 9099d5aa69 | |||
| 8d3bfb8d55 | |||
| f72621f166 | |||
| c479a67c2c | |||
| 1c86f7a6bf | |||
| 1af203d2a8 |
+687
@@ -0,0 +1,687 @@
|
|||||||
|
################################################################################
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
|
||||||
|
PROGRAM_NAME ?= vlmcsd
|
||||||
|
CLIENT_NAME ?= vlmcs
|
||||||
|
MULTI_NAME ?= vlmcsdmulti
|
||||||
|
OBJ_NAME ?= libkms-static.o
|
||||||
|
A_NAME ?= libkms.a
|
||||||
|
CONFIG ?= config.h
|
||||||
|
COMPILER_LANGUAGE ?= c
|
||||||
|
|
||||||
|
# crypto library to use for standard algos, could save ~1-2kb ;)
|
||||||
|
# can be either 'openssl', 'polarssl' or anything other for internal impl
|
||||||
|
CRYPTO ?= internal
|
||||||
|
|
||||||
|
# use DNS_PARSER=internal if your OS doesn't supply the DNS parser routines
|
||||||
|
DNS_PARSER ?= OS
|
||||||
|
|
||||||
|
# You should supply your own version string here
|
||||||
|
|
||||||
|
VLMCSD_VERSION ?= $(shell test -d .svn && echo svn`svnversion`)
|
||||||
|
|
||||||
|
FEATURES ?= full
|
||||||
|
VERBOSE ?= NO
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
CC ?= gcc
|
||||||
|
TARGETPLATFORM := $(shell LANG=en_US.UTF-8 $(CC) -v 2>&1 | grep '^Target: ' | cut -f 2 -d ' ')
|
||||||
|
|
||||||
|
ifneq (,$(findstring darwin,$(TARGETPLATFORM)))
|
||||||
|
DARWIN := 1
|
||||||
|
UNIX := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring android,$(TARGETPLATFORM)))
|
||||||
|
ANDROID := 1
|
||||||
|
UNIX := 1
|
||||||
|
ELF := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring minix,$(TARGETPLATFORM)))
|
||||||
|
MINIX := 1
|
||||||
|
UNIX := 1
|
||||||
|
ELF := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring mingw,$(TARGETPLATFORM)))
|
||||||
|
MINGW := 1
|
||||||
|
WIN := 1
|
||||||
|
PE := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring cygwin,$(TARGETPLATFORM)))
|
||||||
|
CYGWIN := 1
|
||||||
|
WIN := 1
|
||||||
|
PE := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring cygnus,$(TARGETPLATFORM)))
|
||||||
|
CYGWIN := 1
|
||||||
|
WIN := 1
|
||||||
|
PE := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring freebsd,$(TARGETPLATFORM)))
|
||||||
|
FREEBSD := 1
|
||||||
|
UNIX := 1
|
||||||
|
BSD := 1
|
||||||
|
ELF := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring netbsd,$(TARGETPLATFORM)))
|
||||||
|
NETBSD := 1
|
||||||
|
UNIX := 1
|
||||||
|
BSD := 1
|
||||||
|
ELF := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring openbsd,$(TARGETPLATFORM)))
|
||||||
|
OPENBSD := 1
|
||||||
|
UNIX := 1
|
||||||
|
BSD := 1
|
||||||
|
ELF := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring solaris,$(TARGETPLATFORM)))
|
||||||
|
SOLARIS := 1
|
||||||
|
UNIX := 1
|
||||||
|
ELF := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring linux,$(TARGETPLATFORM)))
|
||||||
|
LINUX := 1
|
||||||
|
UNIX := 1
|
||||||
|
ELF := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring gnu,$(TARGETPLATFORM)))
|
||||||
|
ifeq (,$(findstring linux,$(TARGETPLATFORM)))
|
||||||
|
UNIX := 1
|
||||||
|
HURD := 1
|
||||||
|
ELF := 1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CYGWIN),1)
|
||||||
|
DLL_NAME ?= cygkms.dll
|
||||||
|
else ifeq ($(WIN),1)
|
||||||
|
DLL_NAME ?= libkms.dll
|
||||||
|
else ifeq ($(DARWIN),1)
|
||||||
|
DLL_NAME ?= libkms.dylib
|
||||||
|
else
|
||||||
|
DLL_NAME ?= libkms.so
|
||||||
|
endif
|
||||||
|
|
||||||
|
BASECFLAGS = -DVLMCSD_COMPILER=\"$(notdir $(CC))\" -DVLMCSD_PLATFORM=\"$(TARGETPLATFORM)\" -DCONFIG=\"$(CONFIG)\" -DBUILD_TIME=$(shell date '+%s') -g -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections
|
||||||
|
BASELDFLAGS =
|
||||||
|
STRIPFLAGS =
|
||||||
|
CLIENTLDFLAGS =
|
||||||
|
SERVERLDFLAGS =
|
||||||
|
|
||||||
|
ifndef SAFE_MODE
|
||||||
|
BASECFLAGS += -fvisibility=hidden -pipe -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants
|
||||||
|
|
||||||
|
ifeq ($(ELF),1)
|
||||||
|
BASELDFLAGS += -Wl,-z,norelro
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring gcc,$(notdir $(CC))))
|
||||||
|
BASECFLAGS += -flto
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(NOLIBS),1)
|
||||||
|
NOLRESOLV=1
|
||||||
|
NOLPTHREAD=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(NOLIBS),1)
|
||||||
|
ifeq ($(MINGW),1)
|
||||||
|
BASELDFLAGS += -lws2_32 -liphlpapi
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(NO_DNS),1)
|
||||||
|
ifneq ($(ANDROID),1)
|
||||||
|
ifneq ($(NOLRESOLV),1)
|
||||||
|
|
||||||
|
ifeq ($(MINGW),1)
|
||||||
|
CLIENTLDFLAGS += -ldnsapi
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(LINUX),1)
|
||||||
|
CLIENTLDFLAGS += -lresolv
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(HURD),1)
|
||||||
|
CLIENTLDFLAGS += -lresolv
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(DARWIN),1)
|
||||||
|
CLIENTLDFLAGS += -lresolv
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CYGWIN),1)
|
||||||
|
DNS_PARSER := internal
|
||||||
|
CLIENTLDFLAGS += -lresolv
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OPENBSD),1)
|
||||||
|
DNS_PARSER := internal
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(SOLARIS),1)
|
||||||
|
CLIENTLDFLAGS += -lresolv
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
BASECFLAGS += -DNO_DNS
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(CAT),2)
|
||||||
|
BASECFLAGS += "-Wall"
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(DARWIN), 1)
|
||||||
|
STRIPFLAGS += -Wl,-S -Wl,-x
|
||||||
|
BASECFLAGS += -Wno-deprecated-declarations
|
||||||
|
else ifeq ($(shell uname), SunOS)
|
||||||
|
STRIPFLAGS += -s
|
||||||
|
ifeq ($(notdir $(LD_ALTEXEC)),gld)
|
||||||
|
BASELDFLAGS += -Wl,--gc-sections
|
||||||
|
endif
|
||||||
|
BASELDFLAGS += -lsocket
|
||||||
|
else
|
||||||
|
ifneq ($(CC),tcc)
|
||||||
|
BASELDFLAGS += -Wl,--gc-sections
|
||||||
|
endif
|
||||||
|
STRIPFLAGS += -s
|
||||||
|
endif
|
||||||
|
|
||||||
|
LIBRARY_CFLAGS = -DSIMPLE_SOCKETS -DNO_TIMEOUT -DNO_SIGHUP -DNO_CL_PIDS -DNO_EXTENDED_PRODUCT_LIST -DNO_BASIC_PRODUCT_LIST -DNO_LOG -DNO_RANDOM_EPID -DNO_INI_FILE -DNO_INI_FILE -DNO_HELP -DNO_CUSTOM_INTERVALS -DNO_PID_FILE -DNO_USER_SWITCH -DNO_VERBOSE_LOG -DNO_LIMIT -DNO_VERSION_INFORMATION -DNO_PRIVATE_IP_DETECT
|
||||||
|
|
||||||
|
ifeq ($(FEATURES), embedded)
|
||||||
|
BASECFLAGS += -DNO_HELP -DNO_USER_SWITCH -DNO_BASIC_PRODUCT_LIST -DNO_CUSTOM_INTERVALS -DNO_PID_FILE -DNO_VERBOSE_LOG -DNO_VERSION_INFORMATION
|
||||||
|
else ifeq ($(FEATURES), autostart)
|
||||||
|
BASECFLAGS += -DNO_HELP -DNO_VERSION_INFORMATION
|
||||||
|
else ifeq ($(FEATURES), minimum)
|
||||||
|
BASECFLAGS += $(LIBRARY_CFLAGS)
|
||||||
|
else ifeq ($(FEATURES), most)
|
||||||
|
BASECFLAGS += -DNO_SIGHUP -DNO_PID_FILE -DNO_LIMIT
|
||||||
|
else ifeq ($(FEATURES), inetd)
|
||||||
|
BASECFLAGS += -DNO_SIGHUP -DNO_SOCKETS -DNO_PID_FILE -DNO_LIMIT -DNO_VERSION_INFORMATION
|
||||||
|
else ifeq ($(FEATURES), fixedepids)
|
||||||
|
BASECFLAGS += -DNO_SIGHUP -DNO_CL_PIDS -DNO_RANDOM_EPID -DNO_INI_FILE
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef INI
|
||||||
|
BASECFLAGS += -DINI_FILE=\"$(INI)\"
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(NO_GETIFADDRS), 1)
|
||||||
|
BASECFLAGS += -DNO_GETIFADDRS
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(THREADS), 1)
|
||||||
|
BASECFLAGS += -DUSE_THREADS
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CHILD_HANDLER), 1)
|
||||||
|
BASECFLAGS += -DCHILD_HANDLER
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(NO_TIMEOUT), 1)
|
||||||
|
BASECFLAGS += -DNO_TIMEOUT
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef WINDOWS
|
||||||
|
BASECFLAGS += -DEPID_WINDOWS=\"$(WINDOWS)\"
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef OFFICE2010
|
||||||
|
BASECFLAGS += -DEPID_OFFICE2010=\"$(OFFICE2010)\"
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef OFFICE2013
|
||||||
|
BASECFLAGS += -DEPID_OFFICE2013=\"$(OFFICE2013)\"
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef HWID
|
||||||
|
BASECFLAGS += -DHWID=$(HWID)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef TERMINAL_WIDTH
|
||||||
|
BASECFLAGS += -DTERMINAL_FIXED_WIDTH=$(TERMINAL_WIDTH) -DDISPLAY_WIDTH=\"$(TERMINAL_WIDTH)\"
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(NOPROCFS), 1)
|
||||||
|
BASECFLAGS += -DNO_PROCFS
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(AUXV), 1)
|
||||||
|
BASECFLAGS += -DUSE_AUXV
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(ANDROID), 1)
|
||||||
|
ifneq ($(MINIX), 1)
|
||||||
|
ifneq ($(NOLPTHREAD), 1)
|
||||||
|
|
||||||
|
ifeq ($(THREADS), 1)
|
||||||
|
SERVERLDFLAGS += -lpthread
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq (,$(findstring NO_LIMIT,$(CFLAGS) $(BASECFLAGS)))
|
||||||
|
SERVERLDFLAGS += -lpthread
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(MULTI_NAME): BASECFLAGS += -DMULTI_CALL_BINARY=1
|
||||||
|
|
||||||
|
all: $(CLIENT_NAME) $(PROGRAM_NAME)
|
||||||
|
|
||||||
|
#ifdef CAT
|
||||||
|
allmulti: $(CLIENT_NAME) $(PROGRAM_NAME) $(MULTI_NAME)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ifneq ($(strip $(VLMCSD_VERSION)),)
|
||||||
|
BASECFLAGS += -DVERSION=\"$(VLMCSD_VERSION),\ built\ $(shell date -u '+%Y-%m-%d %H:%M:%S' | sed -e 's/ /\\ /g')\ UTC\"
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef CAT
|
||||||
|
BASECFLAGS += -DONE_FILE
|
||||||
|
endif
|
||||||
|
|
||||||
|
SRCS = crypto.c kms.c endian.c output.c shared_globals.c helpers.c
|
||||||
|
HEADERS = $(CONFIG) types.h rpc.h vlmcsd.h endian.h crypto.h kms.h network.h output.h shared_globals.h vlmcs.h helpers.h
|
||||||
|
DEPS = $(MULTI_SRCS:.c=.d)
|
||||||
|
|
||||||
|
VLMCSD_SRCS = vlmcsd.c $(SRCS)
|
||||||
|
VLMCSD_OBJS = $(VLMCSD_SRCS:.c=.o)
|
||||||
|
|
||||||
|
VLMCS_SRCS = vlmcs.c $(SRCS)
|
||||||
|
VLMCS_OBJS = $(VLMCS_SRCS:.c=.o)
|
||||||
|
|
||||||
|
MULTI_SRCS = vlmcsd.c vlmcs.c vlmcsdmulti.c $(SRCS)
|
||||||
|
MULTI_OBJS = $(SRCS:.c=.o) vlmcsd-m.o vlmcs-m.o vlmcsdmulti-m.o
|
||||||
|
|
||||||
|
DLL_SRCS = libkms.c vlmcs.c $(SRCS)
|
||||||
|
DLL_OBJS = $(DLL_SRCS:.c=-l.o)
|
||||||
|
|
||||||
|
PDFDOCS = vlmcs.1.pdf vlmcsd.7.pdf vlmcsd.8.pdf vlmcsdmulti.1.pdf vlmcsd.ini.5.pdf vlmcsd-floppy.7.pdf
|
||||||
|
HTMLDOCS = $(PDFDOCS:.pdf=.html)
|
||||||
|
UNIXDOCS = $(PDFDOCS:.pdf=.unix.txt)
|
||||||
|
DOSDOCS = $(PDFDOCS:.pdf=.dos.txt)
|
||||||
|
|
||||||
|
ifneq ($(NO_DNS),1)
|
||||||
|
|
||||||
|
VLMCS_SRCS += dns_srv.c
|
||||||
|
MULTI_SRCS += dns_srv.c
|
||||||
|
MULTI_OBJS += dns_srv.o
|
||||||
|
|
||||||
|
ifeq ($(DNS_PARSER),internal)
|
||||||
|
ifneq ($(MINGW),1)
|
||||||
|
VLMCS_SRCS += ns_parse.c ns_name.c
|
||||||
|
MULTI_SRCS += ns_parse.c ns_name.c
|
||||||
|
MULTI_OBJS += ns_parse.o ns_name.o
|
||||||
|
BASECFLAGS += "-DDNS_PARSER_INTERNAL"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(MSRPC),1)
|
||||||
|
VLMCSD_SRCS += msrpc-server.c
|
||||||
|
VLMCS_SRCS += msrpc-client.c
|
||||||
|
MULTI_SRCS += msrpc-server.c msrpc-client.c
|
||||||
|
MULTI_OBJS += msrpc-server-m.o msrpc-client-m.o
|
||||||
|
DLL_SRCS += msrpc-server.c
|
||||||
|
BASECFLAGS += -DUSE_MSRPC -Wno-unknown-pragmas
|
||||||
|
BASELDFLAGS += -lrpcrt4
|
||||||
|
else
|
||||||
|
SRCS += network.c rpc.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(GETIFADDRS),musl)
|
||||||
|
ifneq ($(NO_GETIFADDRS),1)
|
||||||
|
BASECFLAGS += -DGETIFADDRS_MUSL
|
||||||
|
VLMCSD_SRCS += getifaddrs-musl.c
|
||||||
|
MULTI_SRCS += getifaddrs-musl.c
|
||||||
|
VLMCS_SRCS += getifaddrs-musl.c
|
||||||
|
DLL_SRCS += getifaddrs-musl.c
|
||||||
|
MULTI_OBJS += getifaddrs-musl.o
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(ANDROID),1)
|
||||||
|
ifneq ($(NO_GETIFADDRS),1)
|
||||||
|
VLMCSD_SRCS += ifaddrs-android.c
|
||||||
|
MULTI_SRCS += ifaddrs-android.c
|
||||||
|
DLL_SRCS += ifaddrs-android.c
|
||||||
|
MULTI_OBJS += ifaddrs-android.o
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(WIN)" "1"
|
||||||
|
VLMCSD_SRCS += ntservice.c
|
||||||
|
MULTI_SRCS += ntservice.c
|
||||||
|
MULTI_OBJS += ntservice.o
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CRYPTO), openssl_with_aes)
|
||||||
|
BASECFLAGS += -D_CRYPTO_OPENSSL -D_USE_AES_FROM_OPENSSL
|
||||||
|
BASELDFLAGS += -lcrypto
|
||||||
|
SRCS += crypto_openssl.c
|
||||||
|
else ifeq ($(CRYPTO), openssl_with_aes_soft)
|
||||||
|
BASECFLAGS += -D_CRYPTO_OPENSSL -D_USE_AES_FROM_OPENSSL -D_OPENSSL_SOFTWARE
|
||||||
|
BASELDFLAGS += -lcrypto
|
||||||
|
SRCS += crypto_openssl.c
|
||||||
|
else ifeq ($(CRYPTO), openssl)
|
||||||
|
BASECFLAGS += -D_CRYPTO_OPENSSL
|
||||||
|
BASELDFLAGS += -lcrypto
|
||||||
|
SRCS += crypto_openssl.c
|
||||||
|
else ifeq ($(CRYPTO), polarssl)
|
||||||
|
BASECFLAGS += -D_CRYPTO_POLARSSL
|
||||||
|
BASELDFLAGS += -lpolarssl
|
||||||
|
else ifeq ($(CRYPTO), windows)
|
||||||
|
BASECFLAGS += -D_CRYPTO_WINDOWS
|
||||||
|
SRCS += crypto_windows.c
|
||||||
|
else
|
||||||
|
BASECFLAGS += -D_CRYPTO_INTERNAL
|
||||||
|
SRCS += crypto_internal.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(STRIP),0)
|
||||||
|
BASELDFLAGS += $(STRIPFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OPENSSL_HMAC),0)
|
||||||
|
BASECFLAGS += -D_OPENSSL_NO_HMAC
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(DEPENDENCIES),2)
|
||||||
|
BASECFLAGS += -MMD
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(VERBOSE),3)
|
||||||
|
COMPILER := $(shell printf "%-40s" $(notdir $(CC)))
|
||||||
|
ARCHIVER := $(shell printf "%-40s" $(notdir $(AR)))
|
||||||
|
endif
|
||||||
|
|
||||||
|
ARCMD := AR
|
||||||
|
|
||||||
|
ifdef CAT
|
||||||
|
LDCMD := CC/LD
|
||||||
|
else
|
||||||
|
LDCMD := LD
|
||||||
|
endif
|
||||||
|
|
||||||
|
-include $(MULTI_SRCS:.c=.d)
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
ifeq ($(VERBOSE),1)
|
||||||
|
$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -c $<
|
||||||
|
ifeq ($(DEPENDENCIES),1)
|
||||||
|
$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -MM -MF $*.d $<
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
@echo "$(COMPILER) CC $@ <- $<"
|
||||||
|
@$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -c $<
|
||||||
|
ifeq ($(DEPENDENCIES),1)
|
||||||
|
@echo "$(COMPILER) DEP $*.d <- $<"
|
||||||
|
@$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -MM -MF $*.d $<
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
%-m.o: %.c
|
||||||
|
ifeq ($(VERBOSE),1)
|
||||||
|
$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -o $@ -c $<
|
||||||
|
ifeq ($(DEPENDENCIES),1)
|
||||||
|
$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -MM -MF $*.d $<
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
@echo "$(COMPILER) CC $@ <- $<"
|
||||||
|
@$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -o $@ -c $<
|
||||||
|
ifeq ($(DEPENDENCIES),1)
|
||||||
|
@echo "$(COMPILER) DEP $*.d <- $<"
|
||||||
|
@$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -MM -MF $*.d $<
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
%-l.o: %.c
|
||||||
|
ifeq ($(VERBOSE),1)
|
||||||
|
$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -fvisibility=hidden -c -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC -o $@ -c $<
|
||||||
|
ifeq ($(DEPENDENCIES),1)
|
||||||
|
$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) $(SERVERLDFLAGS) -fvisibility=hidden -c -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC -MM -MF $*.d $<
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
@echo "$(COMPILER) CC $@ <- $<"
|
||||||
|
@$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) $(SERVERLDFLAGS) -fvisibility=hidden -c -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC -o $@ -c $<
|
||||||
|
ifeq ($(DEPENDENCIES),1)
|
||||||
|
@echo "$(COMPILER) DEP $*.d <- $<"
|
||||||
|
@$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) $(SERVERLDFLAGS) -fvisibility=hidden -c -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC -MM -MF $*.d $<
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
ifdef CAT
|
||||||
|
BUILDCOMMAND = cat $^ | $(CC) -x$(COMPILER_LANGUAGE) -o $@ -
|
||||||
|
VLMCSD_PREREQUISITES = $(VLMCSD_SRCS)
|
||||||
|
VLMCS_PREREQUISITES = $(VLMCS_SRCS)
|
||||||
|
MULTI_PREREQUISITES = $(MULTI_SRCS)
|
||||||
|
DLL_PREREQUISITES = $(DLL_SRCS)
|
||||||
|
OBJ_PREREQUISITES = $(DLL_SRCS)
|
||||||
|
else
|
||||||
|
BUILDCOMMAND = $(CC) -o $@ $^
|
||||||
|
VLMCSD_PREREQUISITES = $(VLMCSD_OBJS)
|
||||||
|
VLMCS_PREREQUISITES = $(VLMCS_OBJS)
|
||||||
|
MULTI_PREREQUISITES = $(MULTI_OBJS)
|
||||||
|
DLL_PREREQUISITES = $(DLL_OBJS)
|
||||||
|
OBJ_PREREQUISITES = $(DLL_OBJS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(VERBOSE),1)
|
||||||
|
BUILDCOMMANDPREFIX = +
|
||||||
|
else
|
||||||
|
BUILDCOMMANDPREFIX = +@
|
||||||
|
endif
|
||||||
|
|
||||||
|
INFOCOMMAND = +@echo "$(COMPILER) $(LDCMD) $@ <- $^"
|
||||||
|
ARINFOCOMMAND = +@echo "$(ARCHIVER) $(ARCMD) $@ <. $^"
|
||||||
|
|
||||||
|
VLMCSD_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(SERVERLDFLAGS)
|
||||||
|
VLMCS_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(CLIENTLDFLAGS)
|
||||||
|
MULTI_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(CLIENTLDFLAGS) $(SERVERLDFLAGS)
|
||||||
|
DLL_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(SERVERLDFLAGS) -fvisibility=hidden -shared -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC
|
||||||
|
OBJ_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(SERVERLDFLAGS) -fvisibility=hidden -c -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC
|
||||||
|
|
||||||
|
$(PROGRAM_NAME): $(VLMCSD_PREREQUISITES)
|
||||||
|
ifneq ($(VERBOSE),1)
|
||||||
|
$(INFOCOMMAND)
|
||||||
|
endif
|
||||||
|
$(VLMCSD_COMMAND)
|
||||||
|
|
||||||
|
$(CLIENT_NAME): $(VLMCS_PREREQUISITES)
|
||||||
|
ifneq ($(VERBOSE),1)
|
||||||
|
$(INFOCOMMAND)
|
||||||
|
endif
|
||||||
|
$(VLMCS_COMMAND)
|
||||||
|
|
||||||
|
$(MULTI_NAME): $(MULTI_PREREQUISITES)
|
||||||
|
ifneq ($(VERBOSE),1)
|
||||||
|
$(INFOCOMMAND)
|
||||||
|
endif
|
||||||
|
$(MULTI_COMMAND)
|
||||||
|
|
||||||
|
$(DLL_NAME): $(DLL_PREREQUISITES)
|
||||||
|
ifneq ($(VERBOSE),1)
|
||||||
|
$(INFOCOMMAND)
|
||||||
|
endif
|
||||||
|
$(DLL_COMMAND)
|
||||||
|
|
||||||
|
ifndef CAT
|
||||||
|
$(OBJ_NAME):
|
||||||
|
+@echo Cannot make $@ without CAT defined. Please create $(A_NAME)
|
||||||
|
else
|
||||||
|
$(OBJ_NAME): $(OBJ_PREREQUISITES)
|
||||||
|
ifneq ($(VERBOSE),1)
|
||||||
|
$(INFOCOMMAND)
|
||||||
|
endif
|
||||||
|
$(OBJ_COMMAND)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef CAT
|
||||||
|
$(A_NAME): $(OBJ_NAME)
|
||||||
|
else
|
||||||
|
$(A_NAME): BASECFLAGS += -fvisibility=hidden -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC
|
||||||
|
$(A_NAME): $(DLL_OBJS)
|
||||||
|
endif
|
||||||
|
ifneq ($(VERBOSE),1)
|
||||||
|
$(ARINFOCOMMAND)
|
||||||
|
endif
|
||||||
|
+@rm -f $@
|
||||||
|
$(BUILDCOMMANDPREFIX)$(AR) rcs $@ $^
|
||||||
|
|
||||||
|
%.pdf : %
|
||||||
|
ifeq ($(shell uname), Darwin)
|
||||||
|
groff -Tps -mandoc -c $< | pstopdf -i -o $@
|
||||||
|
else
|
||||||
|
groff -Tpdf -mandoc -c $< > $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
%.html : %
|
||||||
|
groff -Thtml -mandoc -c $< > $@
|
||||||
|
|
||||||
|
%.unix.txt : %
|
||||||
|
groff -P -c -Tutf8 -mandoc -c $< | col -bx > $@
|
||||||
|
|
||||||
|
%.dos.txt : %.unix.txt
|
||||||
|
# unix2dos -n $< $@
|
||||||
|
# sed -e 's/$$/\r/' $< > $@
|
||||||
|
awk 'sub("$$", "\r")' $< > $@
|
||||||
|
|
||||||
|
pdfdocs : $(PDFDOCS)
|
||||||
|
|
||||||
|
dosdocs : $(DOSDOCS)
|
||||||
|
|
||||||
|
unixdocs : $(UNIXDOCS)
|
||||||
|
|
||||||
|
htmldocs : $(HTMLDOCS)
|
||||||
|
|
||||||
|
alldocs : $(UNIXDOCS) $(HTMLDOCS) $(PDFDOCS) $(DOSDOCS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.d *_all.c libkms_all_*.c $(PROGRAM_NAME) $(MULTI_NAME) $(DLL_NAME) $(CLIENT_NAME) $(PDFDOCS) $(DOSDOCS) $(UNIXDOCS) $(HTMLDOCS) $(OBJ_NAME) $(A_NAME) *.a
|
||||||
|
|
||||||
|
dnsclean:
|
||||||
|
rm -f dns_srv.o
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo "Type"
|
||||||
|
@echo " ${MAKE} - to build $(PROGRAM_NAME) and $(CLIENT_NAME)"
|
||||||
|
@echo " ${MAKE} clean - to remove $(PROGRAM_NAME) and $(CLIENT_NAME)"
|
||||||
|
@echo " ${MAKE} help - to see this help"
|
||||||
|
@echo " ${MAKE} pdfdocs - Create PDF versions of the documentation (Requires groff with PDF support)."
|
||||||
|
@echo " ${MAKE} htmldocs - Create HTML versions of the documentation."
|
||||||
|
@echo " ${MAKE} unixdocs - Create Unix TXT versions of the documentation."
|
||||||
|
@echo " ${MAKE} dosdocs - Create DOS/Windows TXT versions of the documentation."
|
||||||
|
@echo " ${MAKE} alldocs - Create all versions of the documentation."
|
||||||
|
@echo " ${MAKE} -j <x> - Use <x> parallel tasks (SMP support) when compiling $(PROGRAM_NAME) and $(CLIENT_NAME)"
|
||||||
|
@echo ""
|
||||||
|
@echo " ${MAKE} $(PROGRAM_NAME) - to build the server only."
|
||||||
|
@echo " ${MAKE} $(CLIENT_NAME) - to build the client only."
|
||||||
|
@echo " ${MAKE} $(MULTI_NAME) - to build $(PROGRAM_NAME) and $(CLIENT_NAME) in a single multi-call binary"
|
||||||
|
@echo " ${MAKE} $(DLL_NAME) - to build the shared library $(DLL_NAME)"
|
||||||
|
@echo " ${MAKE} $(A_NAME) - to build the static library $(A_NAME)"
|
||||||
|
@echo ""
|
||||||
|
@echo "Options"
|
||||||
|
@echo " CONFIG=<x> Compile <x> as instead of config.h."
|
||||||
|
@echo " INI=<x> Compile $(PROGRAM_NAME) with default ini file <x>"
|
||||||
|
@echo " PROGRAM_NAME=<x> Use <x> as output file name for the KMS server. Defaults to vlmcsd."
|
||||||
|
@echo " CLIENT_NAME=<x> Use <x> as output file name for the KMS client. Defaults to vlmcs."
|
||||||
|
@echo " MULTI_NAME=<x> Use <x> as output file name for the multi-call binary. Defaults to vlmcsdmulti."
|
||||||
|
@echo " DEPENDENCIES=1 Create dependency files."
|
||||||
|
@echo " CRYPTO=openssl Use openssl for SHA256/HMAC calculations."
|
||||||
|
@echo " CRYPTO=openssl_with_aes EXPERIMENTAL: Use openssl for SHA256/HMAC and AES calculations (hardware, e.g. AES-NI on x86)."
|
||||||
|
@echo " CRYPTO=openssl_with_aes_soft EXPERIMENTAL: Use openssl for SHA256/HMAC and AES calculations (software)."
|
||||||
|
@echo " CRYPTO=polarssl Use polarssl instead of internal crypto code for SHA256/HMAC calculations."
|
||||||
|
@echo " CRYPTO=windows Use Windows CryptoAPI instead of internal crypto code for SHA256/HMAC calculations."
|
||||||
|
@echo " MSRPC=1 Use Microsoft RPC instead of vlmcsd's internal RPC. Only works with Windows and Cygwin targets."
|
||||||
|
@echo " CC=<x> Use compiler <x>. Supported compilers are gcc, icc, tcc and clang. Others may or may not work."
|
||||||
|
@echo " AR=<x> Use <x> instead of ar to build $(A_NAME). Set to gcc-ar if you want to use gcc's LTO feature."
|
||||||
|
@echo " COMPILER_LANGUAGE=<x> May be c or c++."
|
||||||
|
@echo " TERMINAL_WIDTH=<x> Assume a fixed terminal width of <x> columns. Use in case of problems only."
|
||||||
|
@echo " VLMCSD_VERSION=<x> Sets <x> as your version identifier. Defaults to \"private build\"."
|
||||||
|
@echo " CFLAGS=<x> Pass <x> as additional arguments to the compiler."
|
||||||
|
@echo " LDFLAGS=<x> Pass <x> as additional arguments to the linker."
|
||||||
|
@echo " PLATFORMFLAGS=<x> Pass <x> as additional arguments to the compiler and the linker."
|
||||||
|
@echo " BASECFLAGS=<x> Pass only <x> as arguments to the compiler (advanced users only)."
|
||||||
|
@echo " BASELDFLAGS=<x> Pass only <x> as arguments to the linker (advanced users only)."
|
||||||
|
@echo " STRIP=0 Don't strip debug information from $(PROGRAM_NAME) and $(CLIENT_NAME) (for developers)."
|
||||||
|
@echo " VERBOSE=1 Be verbose when making targets."
|
||||||
|
@echo " VERBOSE=3 Show name of compiler."
|
||||||
|
@echo " THREADS=1 Use threads instead of fork(). Automatically set for native Windows. Recommended for Cygwin."
|
||||||
|
@echo " WINDOWS=<x> Use <x> as the default ePID for Windows (when using $(PROGRAM_NAME) with -r 0)."
|
||||||
|
@echo " OFFICE2010=<x> Use <x> as the default ePID for Office2010 (when using $(PROGRAM_NAME) with -r 0)."
|
||||||
|
@echo " OFFICE2013=<x> Use <x> as the default ePID for Office2013 (when using $(PROGRAM_NAME) with -r 0)."
|
||||||
|
@echo " HWID=<x> Use <x> as the default HWID (when it can't be found in an ini file)."
|
||||||
|
@echo " FEATURES=full Compile $(PROGRAM_NAME) with all features (default)."
|
||||||
|
@echo " FEATURES=most Compile $(PROGRAM_NAME) without rarely used features."
|
||||||
|
@echo " FEATURES=embedded Compile $(PROGRAM_NAME) with typical features for embedded systems."
|
||||||
|
@echo " FEATURES=autostart Removes features typically not needed if you place $(PROGRAM_NAME) in an autostart script."
|
||||||
|
@echo " FEATURES=inetd Compile $(PROGRAM_NAME) for running through an internet superserver only."
|
||||||
|
@echo " FEATURES=minimum Compiles only basic features of $(PROGRAM_NAME)."
|
||||||
|
@echo " FEATURES=fixedepids $(PROGRAM_NAME) only uses bultin internal ePIDs."
|
||||||
|
@echo ""
|
||||||
|
@echo "Useful CFLAGS to save memory when running $(PROGRAM_NAME) on very small embedded devices (finer control than FEATURES=)"
|
||||||
|
@echo " -DNO_EXTENDED_PRODUCT_LIST Don't compile the detailed product list."
|
||||||
|
@echo " -DNO_BASIC_PRODUCT_LIST Don't compile the basic product list."
|
||||||
|
@echo " -DNO_VERBOSE_LOG Don't support verbose logging. Removes -v option."
|
||||||
|
@echo " -DNO_LOG Don't add support for logging. Implies -DNO_VERBOSE_LOG -DNO_EXTENDED_PRODUCT_LIST and -DNO_BASIC_PRODUCT_LIST."
|
||||||
|
@echo " -DNO_RANDOM_EPID Don't support random ePIDs."
|
||||||
|
@echo " -DNO_INI_FILE Don't support reading ePIDs/HWIDs from a file."
|
||||||
|
@echo " -DNO_PID_FILE Don't support writing a PID file. Removes -p option."
|
||||||
|
@echo " -DNO_USER_SWITCH Don't support changing uid/gid after program start. Removes -u and -g options."
|
||||||
|
@echo " -DNO_HELP Don't support command line help."
|
||||||
|
@echo " -DNO_CUSTOM_INTERVALS Don't support custom intervals for retry and refresh activation. Removes -A and -R options."
|
||||||
|
@echo " -DNO_FREEBIND Don't support binding to foreign IP addresses. Removes -F0 and -F1 options. Only affects FreeBSD and Linux."
|
||||||
|
@echo " -DSIMPLE_SOCKETS Compile $(PROGRAM_NAME) with basic socket support only. Removes -L option."
|
||||||
|
@echo " -DNO_SOCKETS Don't support standalone operation. Requires an internet superserver to start $(PROGRAM_NAME)."
|
||||||
|
@echo " -DNO_CL_PIDS Don't support specifying ePIDs and HwId from the command line in $(PROGRAM_NAME)."
|
||||||
|
@echo " -DNO_LIMIT Don't support limiting concurrent clients in $(PROGRAM_NAME)."
|
||||||
|
@echo " -DNO_SIGHUP Don't support SIGHUP handling in $(PROGRAM_NAME)."
|
||||||
|
@echo " -DNO_VERSION_INFORMATION Don't support displaying version information in $(PROGRAM_NAME) and $(CLIENT_NAME). Removes -V option."
|
||||||
|
@echo " -DNO_PRIVATE_IP_DETECT Don't support protection against clients with public IP addresses in $(PROGRAM_NAME)"
|
||||||
|
@echo ""
|
||||||
|
@echo "Troubleshooting options"
|
||||||
|
@echo " CAT=1 Combine all sources in a single in-memory file and compile directly to target."
|
||||||
|
@echo " NOPROCFS=1 Don't rely on a properly mounted proc filesystem in /proc."
|
||||||
|
@echo " AUXV=1 Use /proc/self/auxv (requires Linux with glibc >= 2.16 or musl.)"
|
||||||
|
@echo " NOLPTHREAD=1 Disable detection if -lpthread is required (for use with Android NDK)."
|
||||||
|
@echo " NOLRESOLV=1 Disable detection if -lresolv is required (for use with Android NDK)."
|
||||||
|
@echo " NOLIBS=1 Do not attempt to autodetect any library dependencies."
|
||||||
|
@echo " OPENSSL_HMAC=0 Compile for openssl versions that don't have HMAC support (required on some embedded devices)."
|
||||||
|
@echo " NO_TIMEOUT=1 Do not set timeouts for sockets (for systems that don't support it)."
|
||||||
|
@echo " CHILD_HANDLER=1 Install a handler for SIGCHLD (for systems that don't support SA_NOCLDWAIT)."
|
||||||
|
@echo " NO_DNS=1 Compile $(CLIENT_NAME) without support for detecting KMS servers via DNS."
|
||||||
|
@echo " NO_GETIFADDRS=1 Compile $(PROGRAM_NAME) without using getifaddrs()."
|
||||||
|
@echo " GETIFADDRS=musl Compile $(PROGRAM_NAME) with its own implementation of getifaddrs() based on musl."
|
||||||
|
@echo " DNS_PARSER=internal Use $(CLIENT_NAME) internal DNS parsing routines. No effect on MingW (native Windows)."
|
||||||
|
@echo ""
|
||||||
|
@echo "Other useful CFLAGS"
|
||||||
|
@echo " -DSUPPORT_WINE Add code that the Windows version of $(PROGRAM_NAME) runs on Wine if MSRPC=1"
|
||||||
|
@echo " -D_PEDANTIC Report rare error/warning conditions instead of silently ignoring them."
|
||||||
|
@echo " -DINCLUDE_BETAS Include SKU / activation IDs for obsolete beta/preview products."
|
||||||
|
@echo " -DFD_SETSIZE=<x> Allow <x> -L statements in $(PROGRAM_NAME) (default: 64 on Windows, 1024 on most Unixes)."
|
||||||
|
@echo " -flto Use link time optimization. Not supported by old compilers (gcc < 4.7). Use whenever supported."
|
||||||
|
@echo " -flto=jobserver Utilize all CPUs during link time optimization. Requires ${MAKE} -j <cpus>"
|
||||||
|
@echo " -fno-stack-protector No stack checking. Smaller binaries."
|
||||||
|
@echo " -pipe Use pipes instead of temporary files (faster compilation, extends the life of your SSD)."
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
[
|
||||||
|
uuid(51C82175-844E-4750-B0D8-EC255555BC06),
|
||||||
|
version(1.0),
|
||||||
|
]
|
||||||
|
interface KMSServer
|
||||||
|
{
|
||||||
|
int RequestActivation
|
||||||
|
(
|
||||||
|
[in] int requestSize,
|
||||||
|
[in, size_is(requestSize)] unsigned char* request,
|
||||||
|
[out] int* responseSize,
|
||||||
|
[out, size_is( , *responseSize)] unsigned char** response
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,278 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/* this ALWAYS GENERATED file contains the RPC client stubs */
|
||||||
|
|
||||||
|
|
||||||
|
/* File created by MIDL compiler version 8.00.0595 */
|
||||||
|
/* at Thu Oct 18 15:24:14 2012
|
||||||
|
*/
|
||||||
|
/* Compiler settings for KMSServer.idl:
|
||||||
|
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0595
|
||||||
|
protocol : dce , ms_ext, c_ext, robust
|
||||||
|
error checks: allocation ref bounds_check enum stub_data
|
||||||
|
VC __declspec() decoration level:
|
||||||
|
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
|
||||||
|
DECLSPEC_UUID(), MIDL_INTERFACE()
|
||||||
|
*/
|
||||||
|
/* @@MIDL_FILE_HEADING( ) */
|
||||||
|
|
||||||
|
#if !defined(_M_IA64) && !defined(_M_AMD64) && !defined(_ARM_)
|
||||||
|
|
||||||
|
|
||||||
|
#pragma warning( disable: 4049 ) /* more than 64k source lines */
|
||||||
|
#if _MSC_VER >= 1200
|
||||||
|
#pragma warning(push)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma warning( disable: 4211 ) /* redefine extern to static */
|
||||||
|
#pragma warning( disable: 4232 ) /* dllimport identity*/
|
||||||
|
#pragma warning( disable: 4024 ) /* array to pointer mapping*/
|
||||||
|
#pragma warning( disable: 4100 ) /* unreferenced arguments in x86 call */
|
||||||
|
|
||||||
|
#pragma optimize("", off )
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "KMSServer_h.h"
|
||||||
|
|
||||||
|
#define TYPE_FORMAT_STRING_SIZE 43
|
||||||
|
#define PROC_FORMAT_STRING_SIZE 59
|
||||||
|
#define EXPR_FORMAT_STRING_SIZE 1
|
||||||
|
#define TRANSMIT_AS_TABLE_SIZE 0
|
||||||
|
#define WIRE_MARSHAL_TABLE_SIZE 0
|
||||||
|
|
||||||
|
typedef struct _KMSServer_MIDL_TYPE_FORMAT_STRING
|
||||||
|
{
|
||||||
|
short Pad;
|
||||||
|
unsigned char Format[ TYPE_FORMAT_STRING_SIZE ];
|
||||||
|
} KMSServer_MIDL_TYPE_FORMAT_STRING;
|
||||||
|
|
||||||
|
typedef struct _KMSServer_MIDL_PROC_FORMAT_STRING
|
||||||
|
{
|
||||||
|
short Pad;
|
||||||
|
unsigned char Format[ PROC_FORMAT_STRING_SIZE ];
|
||||||
|
} KMSServer_MIDL_PROC_FORMAT_STRING;
|
||||||
|
|
||||||
|
typedef struct _KMSServer_MIDL_EXPR_FORMAT_STRING
|
||||||
|
{
|
||||||
|
long Pad;
|
||||||
|
unsigned char Format[ EXPR_FORMAT_STRING_SIZE ];
|
||||||
|
} KMSServer_MIDL_EXPR_FORMAT_STRING;
|
||||||
|
|
||||||
|
|
||||||
|
static const RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax =
|
||||||
|
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}};
|
||||||
|
|
||||||
|
|
||||||
|
extern const KMSServer_MIDL_TYPE_FORMAT_STRING KMSServer__MIDL_TypeFormatString;
|
||||||
|
extern const KMSServer_MIDL_PROC_FORMAT_STRING KMSServer__MIDL_ProcFormatString;
|
||||||
|
extern const KMSServer_MIDL_EXPR_FORMAT_STRING KMSServer__MIDL_ExprFormatString;
|
||||||
|
|
||||||
|
#define GENERIC_BINDING_TABLE_SIZE 0
|
||||||
|
|
||||||
|
|
||||||
|
/* Standard interface: KMSServer, ver. 1.0,
|
||||||
|
GUID={0x51C82175,0x844E,0x4750,{0xB0,0xD8,0xEC,0x25,0x55,0x55,0xBC,0x06}} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static const RPC_CLIENT_INTERFACE KMSServer___RpcClientInterface =
|
||||||
|
{
|
||||||
|
sizeof(RPC_CLIENT_INTERFACE),
|
||||||
|
{{0x51C82175,0x844E,0x4750,{0xB0,0xD8,0xEC,0x25,0x55,0x55,0xBC,0x06}},{1,0}},
|
||||||
|
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0x00000000
|
||||||
|
};
|
||||||
|
RPC_IF_HANDLE KMSServer_v1_0_c_ifspec = (RPC_IF_HANDLE)& KMSServer___RpcClientInterface;
|
||||||
|
|
||||||
|
extern const MIDL_STUB_DESC KMSServer_StubDesc;
|
||||||
|
|
||||||
|
static RPC_BINDING_HANDLE KMSServer__MIDL_AutoBindHandle;
|
||||||
|
|
||||||
|
|
||||||
|
int RequestActivation(
|
||||||
|
/* [in] */ handle_t IDL_handle,
|
||||||
|
/* [in] */ int requestSize,
|
||||||
|
/* [size_is][in] */ unsigned char *request,
|
||||||
|
/* [out] */ int *responseSize,
|
||||||
|
/* [size_is][size_is][out] */ unsigned char **response)
|
||||||
|
{
|
||||||
|
|
||||||
|
CLIENT_CALL_RETURN _RetVal;
|
||||||
|
|
||||||
|
_RetVal = NdrClientCall2(
|
||||||
|
( PMIDL_STUB_DESC )&KMSServer_StubDesc,
|
||||||
|
(PFORMAT_STRING) &KMSServer__MIDL_ProcFormatString.Format[0],
|
||||||
|
( unsigned char * )&IDL_handle);
|
||||||
|
return ( int )_RetVal.Simple;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(__RPC_WIN32__)
|
||||||
|
#error Invalid build platform for this stub.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !(TARGET_IS_NT50_OR_LATER)
|
||||||
|
#error You need Windows 2000 or later to run this stub because it uses these features:
|
||||||
|
#error /robust command line switch.
|
||||||
|
#error However, your C/C++ compilation flags indicate you intend to run this app on earlier systems.
|
||||||
|
#error This app will fail with the RPC_X_WRONG_STUB_VERSION error.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !MULTI_CALL_BINARY
|
||||||
|
/*static*/ const KMSServer_MIDL_PROC_FORMAT_STRING KMSServer__MIDL_ProcFormatString =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Procedure RequestActivation */
|
||||||
|
|
||||||
|
0x0, /* 0 */
|
||||||
|
0x48, /* Old Flags: */
|
||||||
|
/* 2 */ NdrFcLong( 0x0 ), /* 0 */
|
||||||
|
/* 6 */ NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
/* 8 */ NdrFcShort( 0x18 ), /* x86 Stack size/offset = 24 */
|
||||||
|
/* 10 */ 0x32, /* FC_BIND_PRIMITIVE */
|
||||||
|
0x0, /* 0 */
|
||||||
|
/* 12 */ NdrFcShort( 0x0 ), /* x86 Stack size/offset = 0 */
|
||||||
|
/* 14 */ NdrFcShort( 0x8 ), /* 8 */
|
||||||
|
/* 16 */ NdrFcShort( 0x24 ), /* 36 */
|
||||||
|
/* 18 */ 0x47, /* Oi2 Flags: srv must size, clt must size, has return, has ext, */
|
||||||
|
0x5, /* 5 */
|
||||||
|
/* 20 */ 0x8, /* 8 */
|
||||||
|
0x7, /* Ext Flags: new corr desc, clt corr check, srv corr check, */
|
||||||
|
/* 22 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 24 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 26 */ NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
|
||||||
|
/* Parameter IDL_handle */
|
||||||
|
|
||||||
|
/* 28 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */
|
||||||
|
/* 30 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
|
||||||
|
/* 32 */ 0x8, /* FC_LONG */
|
||||||
|
0x0, /* 0 */
|
||||||
|
|
||||||
|
/* Parameter requestSize */
|
||||||
|
|
||||||
|
/* 34 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */
|
||||||
|
/* 36 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
|
||||||
|
/* 38 */ NdrFcShort( 0x6 ), /* Type Offset=6 */
|
||||||
|
|
||||||
|
/* Parameter request */
|
||||||
|
|
||||||
|
/* 40 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
|
||||||
|
/* 42 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
|
||||||
|
/* 44 */ 0x8, /* FC_LONG */
|
||||||
|
0x0, /* 0 */
|
||||||
|
|
||||||
|
/* Parameter responseSize */
|
||||||
|
|
||||||
|
/* 46 */ NdrFcShort( 0x2013 ), /* Flags: must size, must free, out, srv alloc size=8 */
|
||||||
|
/* 48 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */
|
||||||
|
/* 50 */ NdrFcShort( 0x16 ), /* Type Offset=22 */
|
||||||
|
|
||||||
|
/* Parameter response */
|
||||||
|
|
||||||
|
/* 52 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
|
||||||
|
/* 54 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */
|
||||||
|
/* 56 */ 0x8, /* FC_LONG */
|
||||||
|
0x0, /* 0 */
|
||||||
|
|
||||||
|
0x0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const KMSServer_MIDL_TYPE_FORMAT_STRING KMSServer__MIDL_TypeFormatString =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
/* 2 */
|
||||||
|
0x11, 0x0, /* FC_RP */
|
||||||
|
/* 4 */ NdrFcShort( 0x2 ), /* Offset= 2 (6) */
|
||||||
|
/* 6 */
|
||||||
|
0x1b, /* FC_CARRAY */
|
||||||
|
0x0, /* 0 */
|
||||||
|
/* 8 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 10 */ 0x28, /* Corr desc: parameter, FC_LONG */
|
||||||
|
0x0, /* */
|
||||||
|
/* 12 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
|
||||||
|
/* 14 */ NdrFcShort( 0x1 ), /* Corr flags: early, */
|
||||||
|
/* 16 */ 0x2, /* FC_CHAR */
|
||||||
|
0x5b, /* FC_END */
|
||||||
|
/* 18 */
|
||||||
|
0x11, 0xc, /* FC_RP [alloced_on_stack] [simple_pointer] */
|
||||||
|
/* 20 */ 0x8, /* FC_LONG */
|
||||||
|
0x5c, /* FC_PAD */
|
||||||
|
/* 22 */
|
||||||
|
0x11, 0x14, /* FC_RP [alloced_on_stack] [pointer_deref] */
|
||||||
|
/* 24 */ NdrFcShort( 0x2 ), /* Offset= 2 (26) */
|
||||||
|
/* 26 */
|
||||||
|
0x12, 0x0, /* FC_UP */
|
||||||
|
/* 28 */ NdrFcShort( 0x2 ), /* Offset= 2 (30) */
|
||||||
|
/* 30 */
|
||||||
|
0x1b, /* FC_CARRAY */
|
||||||
|
0x0, /* 0 */
|
||||||
|
/* 32 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 34 */ 0x28, /* Corr desc: parameter, FC_LONG */
|
||||||
|
0x54, /* FC_DEREFERENCE */
|
||||||
|
/* 36 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
|
||||||
|
/* 38 */ NdrFcShort( 0x1 ), /* Corr flags: early, */
|
||||||
|
/* 40 */ 0x2, /* FC_CHAR */
|
||||||
|
0x5b, /* FC_END */
|
||||||
|
|
||||||
|
0x0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !MULTI_CALL_BINARY
|
||||||
|
|
||||||
|
static const unsigned short KMSServer_FormatStringOffsetTable[] =
|
||||||
|
{
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
//typedef void *(__RPC_API midl_user_allocate_t)(size_t);
|
||||||
|
typedef void *(__RPC_API *midl_allocate_t)(size_t);
|
||||||
|
|
||||||
|
#if !MULTI_CALL_BINARY
|
||||||
|
/*static*/ const MIDL_STUB_DESC KMSServer_StubDesc =
|
||||||
|
{
|
||||||
|
(void *)& KMSServer___RpcClientInterface,
|
||||||
|
(midl_allocate_t)MIDL_user_allocate,
|
||||||
|
MIDL_user_free,
|
||||||
|
&KMSServer__MIDL_AutoBindHandle,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
KMSServer__MIDL_TypeFormatString.Format,
|
||||||
|
1, /* -error bounds_check flag */
|
||||||
|
0x50002, /* Ndr library version */
|
||||||
|
0,
|
||||||
|
0x8000253, /* MIDL Version 8.0.595 */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0, /* notify & notify_flag routine table */
|
||||||
|
0x1, /* MIDL flag */
|
||||||
|
0, /* cs routines */
|
||||||
|
0, /* proxy/server info */
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !MULTI_CALL_BINARY
|
||||||
|
|
||||||
|
#pragma optimize("", on )
|
||||||
|
#if _MSC_VER >= 1200
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !defined(_M_IA64) && !defined(_M_AMD64) && !defined(_ARM_) */
|
||||||
|
|
||||||
@@ -0,0 +1,731 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/* this ALWAYS GENERATED file contains the RPC client stubs */
|
||||||
|
|
||||||
|
|
||||||
|
/* File created by MIDL compiler version 8.00.0603 */
|
||||||
|
/* at Fri Feb 20 04:17:07 2015
|
||||||
|
* modified by Hotbird64 to work with MingW-w64 and gcc
|
||||||
|
*/
|
||||||
|
/* Compiler settings for KMSServer.idl:
|
||||||
|
Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.00.0603
|
||||||
|
protocol : all , ms_ext, c_ext, robust
|
||||||
|
error checks: allocation ref bounds_check enum stub_data
|
||||||
|
VC __declspec() decoration level:
|
||||||
|
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
|
||||||
|
DECLSPEC_UUID(), MIDL_INTERFACE()
|
||||||
|
*/
|
||||||
|
/* @@MIDL_FILE_HEADING( ) */
|
||||||
|
|
||||||
|
#if defined(_M_AMD64)
|
||||||
|
|
||||||
|
|
||||||
|
#pragma warning( disable: 4049 ) /* more than 64k source lines */
|
||||||
|
#if _MSC_VER >= 1200
|
||||||
|
#pragma warning(push)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma warning( disable: 4211 ) /* redefine extern to static */
|
||||||
|
#pragma warning( disable: 4232 ) /* dllimport identity*/
|
||||||
|
#pragma warning( disable: 4024 ) /* array to pointer mapping*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "KMSServer_h.h"
|
||||||
|
|
||||||
|
#define TYPE_FORMAT_STRING_SIZE 43
|
||||||
|
#define PROC_FORMAT_STRING_SIZE 61
|
||||||
|
#define EXPR_FORMAT_STRING_SIZE 1
|
||||||
|
#define TRANSMIT_AS_TABLE_SIZE 0
|
||||||
|
#define WIRE_MARSHAL_TABLE_SIZE 0
|
||||||
|
|
||||||
|
typedef struct _KMSServer_MIDL_TYPE_FORMAT_STRING
|
||||||
|
{
|
||||||
|
short Pad;
|
||||||
|
unsigned char Format[ TYPE_FORMAT_STRING_SIZE ];
|
||||||
|
} KMSServer_MIDL_TYPE_FORMAT_STRING;
|
||||||
|
|
||||||
|
typedef struct _KMSServer_MIDL_PROC_FORMAT_STRING
|
||||||
|
{
|
||||||
|
short Pad;
|
||||||
|
unsigned char Format[ PROC_FORMAT_STRING_SIZE ];
|
||||||
|
} KMSServer_MIDL_PROC_FORMAT_STRING;
|
||||||
|
|
||||||
|
typedef struct _KMSServer_MIDL_EXPR_FORMAT_STRING
|
||||||
|
{
|
||||||
|
long Pad;
|
||||||
|
unsigned char Format[ EXPR_FORMAT_STRING_SIZE ];
|
||||||
|
} KMSServer_MIDL_EXPR_FORMAT_STRING;
|
||||||
|
|
||||||
|
|
||||||
|
static const RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax =
|
||||||
|
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}};
|
||||||
|
|
||||||
|
static const RPC_SYNTAX_IDENTIFIER _NDR64_RpcTransferSyntax =
|
||||||
|
{{0x71710533,0xbeba,0x4937,{0x83,0x19,0xb5,0xdb,0xef,0x9c,0xcc,0x36}},{1,0}};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern const KMSServer_MIDL_TYPE_FORMAT_STRING KMSServer__MIDL_TypeFormatString;
|
||||||
|
extern const KMSServer_MIDL_PROC_FORMAT_STRING KMSServer__MIDL_ProcFormatString;
|
||||||
|
extern const KMSServer_MIDL_EXPR_FORMAT_STRING KMSServer__MIDL_ExprFormatString;
|
||||||
|
|
||||||
|
#define GENERIC_BINDING_TABLE_SIZE 0
|
||||||
|
|
||||||
|
|
||||||
|
/* Standard interface: KMSServer, ver. 1.0,
|
||||||
|
GUID={0x51C82175,0x844E,0x4750,{0xB0,0xD8,0xEC,0x25,0x55,0x55,0xBC,0x06}} */
|
||||||
|
|
||||||
|
extern const MIDL_STUBLESS_PROXY_INFO KMSServer_ProxyInfo;
|
||||||
|
|
||||||
|
|
||||||
|
static const RPC_CLIENT_INTERFACE KMSServer___RpcClientInterface =
|
||||||
|
{
|
||||||
|
sizeof(RPC_CLIENT_INTERFACE),
|
||||||
|
{{0x51C82175,0x844E,0x4750,{0xB0,0xD8,0xEC,0x25,0x55,0x55,0xBC,0x06}},{1,0}},
|
||||||
|
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
&KMSServer_ProxyInfo,
|
||||||
|
0x02000000
|
||||||
|
};
|
||||||
|
RPC_IF_HANDLE KMSServer_v1_0_c_ifspec = (RPC_IF_HANDLE)& KMSServer___RpcClientInterface;
|
||||||
|
|
||||||
|
extern const MIDL_STUB_DESC KMSServer_StubDesc;
|
||||||
|
|
||||||
|
static RPC_BINDING_HANDLE KMSServer__MIDL_AutoBindHandle;
|
||||||
|
|
||||||
|
|
||||||
|
int RequestActivation(
|
||||||
|
/* [in] */ handle_t IDL_handle,
|
||||||
|
/* [in] */ int requestSize,
|
||||||
|
/* [size_is][in] */ unsigned char *request,
|
||||||
|
/* [out] */ int *responseSize,
|
||||||
|
/* [size_is][size_is][out] */ unsigned char **response)
|
||||||
|
{
|
||||||
|
|
||||||
|
CLIENT_CALL_RETURN _RetVal;
|
||||||
|
|
||||||
|
_RetVal = NdrClientCall3(
|
||||||
|
( PMIDL_STUBLESS_PROXY_INFO )&KMSServer_ProxyInfo,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
IDL_handle,
|
||||||
|
requestSize,
|
||||||
|
request,
|
||||||
|
responseSize,
|
||||||
|
response);
|
||||||
|
return ( int )_RetVal.Simple;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(__RPC_WIN64__)
|
||||||
|
#error Invalid build platform for this stub.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !MULTI_CALL_BINARY
|
||||||
|
/*static*/ const KMSServer_MIDL_PROC_FORMAT_STRING KMSServer__MIDL_ProcFormatString =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Procedure RequestActivation */
|
||||||
|
|
||||||
|
0x0, /* 0 */
|
||||||
|
0x48, /* Old Flags: */
|
||||||
|
/* 2 */ NdrFcLong( 0x0 ), /* 0 */
|
||||||
|
/* 6 */ NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
/* 8 */ NdrFcShort( 0x30 ), /* X64 Stack size/offset = 48 */
|
||||||
|
/* 10 */ 0x32, /* FC_BIND_PRIMITIVE */
|
||||||
|
0x0, /* 0 */
|
||||||
|
/* 12 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */
|
||||||
|
/* 14 */ NdrFcShort( 0x8 ), /* 8 */
|
||||||
|
/* 16 */ NdrFcShort( 0x24 ), /* 36 */
|
||||||
|
/* 18 */ 0x47, /* Oi2 Flags: srv must size, clt must size, has return, has ext, */
|
||||||
|
0x5, /* 5 */
|
||||||
|
/* 20 */ 0xa, /* 10 */
|
||||||
|
0x7, /* Ext Flags: new corr desc, clt corr check, srv corr check, */
|
||||||
|
/* 22 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 24 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 26 */ NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
/* 28 */ NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
|
||||||
|
/* Parameter IDL_handle */
|
||||||
|
|
||||||
|
/* 30 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */
|
||||||
|
/* 32 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */
|
||||||
|
/* 34 */ 0x8, /* FC_LONG */
|
||||||
|
0x0, /* 0 */
|
||||||
|
|
||||||
|
/* Parameter requestSize */
|
||||||
|
|
||||||
|
/* 36 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */
|
||||||
|
/* 38 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */
|
||||||
|
/* 40 */ NdrFcShort( 0x6 ), /* Type Offset=6 */
|
||||||
|
|
||||||
|
/* Parameter request */
|
||||||
|
|
||||||
|
/* 42 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
|
||||||
|
/* 44 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */
|
||||||
|
/* 46 */ 0x8, /* FC_LONG */
|
||||||
|
0x0, /* 0 */
|
||||||
|
|
||||||
|
/* Parameter responseSize */
|
||||||
|
|
||||||
|
/* 48 */ NdrFcShort( 0x2013 ), /* Flags: must size, must free, out, srv alloc size=8 */
|
||||||
|
/* 50 */ NdrFcShort( 0x20 ), /* X64 Stack size/offset = 32 */
|
||||||
|
/* 52 */ NdrFcShort( 0x16 ), /* Type Offset=22 */
|
||||||
|
|
||||||
|
/* Parameter response */
|
||||||
|
|
||||||
|
/* 54 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
|
||||||
|
/* 56 */ NdrFcShort( 0x28 ), /* X64 Stack size/offset = 40 */
|
||||||
|
/* 58 */ 0x8, /* FC_LONG */
|
||||||
|
0x0, /* 0 */
|
||||||
|
|
||||||
|
0x0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const KMSServer_MIDL_TYPE_FORMAT_STRING KMSServer__MIDL_TypeFormatString =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
/* 2 */
|
||||||
|
0x11, 0x0, /* FC_RP */
|
||||||
|
/* 4 */ NdrFcShort( 0x2 ), /* Offset= 2 (6) */
|
||||||
|
/* 6 */
|
||||||
|
0x1b, /* FC_CARRAY */
|
||||||
|
0x0, /* 0 */
|
||||||
|
/* 8 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 10 */ 0x28, /* Corr desc: parameter, FC_LONG */
|
||||||
|
0x0, /* */
|
||||||
|
/* 12 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */
|
||||||
|
/* 14 */ NdrFcShort( 0x1 ), /* Corr flags: early, */
|
||||||
|
/* 16 */ 0x2, /* FC_CHAR */
|
||||||
|
0x5b, /* FC_END */
|
||||||
|
/* 18 */
|
||||||
|
0x11, 0xc, /* FC_RP [alloced_on_stack] [simple_pointer] */
|
||||||
|
/* 20 */ 0x8, /* FC_LONG */
|
||||||
|
0x5c, /* FC_PAD */
|
||||||
|
/* 22 */
|
||||||
|
0x11, 0x14, /* FC_RP [alloced_on_stack] [pointer_deref] */
|
||||||
|
/* 24 */ NdrFcShort( 0x2 ), /* Offset= 2 (26) */
|
||||||
|
/* 26 */
|
||||||
|
0x12, 0x0, /* FC_UP */
|
||||||
|
/* 28 */ NdrFcShort( 0x2 ), /* Offset= 2 (30) */
|
||||||
|
/* 30 */
|
||||||
|
0x1b, /* FC_CARRAY */
|
||||||
|
0x0, /* 0 */
|
||||||
|
/* 32 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 34 */ 0x28, /* Corr desc: parameter, FC_LONG */
|
||||||
|
0x54, /* FC_DEREFERENCE */
|
||||||
|
/* 36 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */
|
||||||
|
/* 38 */ NdrFcShort( 0x1 ), /* Corr flags: early, */
|
||||||
|
/* 40 */ 0x2, /* FC_CHAR */
|
||||||
|
0x5b, /* FC_END */
|
||||||
|
|
||||||
|
0x0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //!MULTI_CALL_BINARY
|
||||||
|
|
||||||
|
static const unsigned short KMSServer_FormatStringOffsetTable[] =
|
||||||
|
{
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* defined(_M_AMD64)*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* this ALWAYS GENERATED file contains the RPC client stubs */
|
||||||
|
|
||||||
|
|
||||||
|
/* File created by MIDL compiler version 8.00.0603 */
|
||||||
|
/* at Fri Feb 20 04:17:07 2015
|
||||||
|
*/
|
||||||
|
/* Compiler settings for KMSServer.idl:
|
||||||
|
Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.00.0603
|
||||||
|
protocol : all , ms_ext, c_ext, robust
|
||||||
|
error checks: allocation ref bounds_check enum stub_data
|
||||||
|
VC __declspec() decoration level:
|
||||||
|
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
|
||||||
|
DECLSPEC_UUID(), MIDL_INTERFACE()
|
||||||
|
*/
|
||||||
|
/* @@MIDL_FILE_HEADING( ) */
|
||||||
|
|
||||||
|
#if defined(_M_AMD64)
|
||||||
|
|
||||||
|
|
||||||
|
#pragma warning( disable: 4049 ) /* more than 64k source lines */
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(__RPC_WIN64__)
|
||||||
|
#error Invalid build platform for this stub.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "ndr64types.h"
|
||||||
|
#include "pshpack8.h"
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
NDR64_FORMAT_UINT32 frag1;
|
||||||
|
struct _NDR64_EXPR_OPERATOR frag2;
|
||||||
|
struct _NDR64_EXPR_VAR frag3;
|
||||||
|
}
|
||||||
|
__midl_frag13_t;
|
||||||
|
|
||||||
|
extern const __midl_frag13_t __midl_frag13;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
struct _NDR64_CONF_ARRAY_HEADER_FORMAT frag1;
|
||||||
|
struct _NDR64_ARRAY_ELEMENT_INFO frag2;
|
||||||
|
}
|
||||||
|
__midl_frag12_t;
|
||||||
|
extern const __midl_frag12_t __midl_frag12;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct _NDR64_POINTER_FORMAT
|
||||||
|
__midl_frag11_t;
|
||||||
|
extern const __midl_frag11_t __midl_frag11;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct _NDR64_POINTER_FORMAT
|
||||||
|
__midl_frag10_t;
|
||||||
|
extern const __midl_frag10_t __midl_frag10;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct _NDR64_POINTER_FORMAT
|
||||||
|
__midl_frag8_t;
|
||||||
|
extern const __midl_frag8_t __midl_frag8;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
NDR64_FORMAT_CHAR
|
||||||
|
__midl_frag7_t;
|
||||||
|
extern const __midl_frag7_t __midl_frag7;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
NDR64_FORMAT_UINT32 frag1;
|
||||||
|
struct _NDR64_EXPR_VAR frag2;
|
||||||
|
}
|
||||||
|
__midl_frag6_t;
|
||||||
|
extern const __midl_frag6_t __midl_frag6;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
struct _NDR64_CONF_ARRAY_HEADER_FORMAT frag1;
|
||||||
|
struct _NDR64_ARRAY_ELEMENT_INFO frag2;
|
||||||
|
}
|
||||||
|
__midl_frag5_t;
|
||||||
|
extern const __midl_frag5_t __midl_frag5;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct _NDR64_POINTER_FORMAT
|
||||||
|
__midl_frag4_t;
|
||||||
|
extern const __midl_frag4_t __midl_frag4;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
NDR64_FORMAT_CHAR
|
||||||
|
__midl_frag3_t;
|
||||||
|
extern const __midl_frag3_t __midl_frag3;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
struct _NDR64_PROC_FORMAT frag1;
|
||||||
|
struct _NDR64_BIND_AND_NOTIFY_EXTENSION frag2;
|
||||||
|
struct _NDR64_PARAM_FORMAT frag3;
|
||||||
|
struct _NDR64_PARAM_FORMAT frag4;
|
||||||
|
struct _NDR64_PARAM_FORMAT frag5;
|
||||||
|
struct _NDR64_PARAM_FORMAT frag6;
|
||||||
|
struct _NDR64_PARAM_FORMAT frag7;
|
||||||
|
}
|
||||||
|
__midl_frag2_t;
|
||||||
|
extern const __midl_frag2_t __midl_frag2;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
NDR64_FORMAT_UINT32
|
||||||
|
__midl_frag1_t;
|
||||||
|
extern const __midl_frag1_t __midl_frag1;
|
||||||
|
|
||||||
|
#if !MULTI_CALL_BINARY
|
||||||
|
/*static*/ const __midl_frag13_t __midl_frag13 =
|
||||||
|
{
|
||||||
|
/* */
|
||||||
|
(NDR64_UINT32) 1 /* 0x1 */,
|
||||||
|
{
|
||||||
|
/* struct _NDR64_EXPR_OPERATOR */
|
||||||
|
0x4, /* FC_EXPR_OPER */
|
||||||
|
0x5, /* OP_UNARY_INDIRECTION */
|
||||||
|
0x5, /* FC64_INT32 */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* struct _NDR64_EXPR_VAR */
|
||||||
|
0x3, /* FC_EXPR_VAR */
|
||||||
|
0x7, /* FC64_INT64 */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT32) 24 /* 0x18 */ /* Offset */
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag12_t __midl_frag12 =
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
0x41, /* FC64_CONF_ARRAY */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
},
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT32) 1 /* 0x1 */,
|
||||||
|
&__midl_frag13
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* struct _NDR64_ARRAY_ELEMENT_INFO */
|
||||||
|
(NDR64_UINT32) 1 /* 0x1 */,
|
||||||
|
&__midl_frag7
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag11_t __midl_frag11 =
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
0x21, /* FC64_UP */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
&__midl_frag12
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag10_t __midl_frag10 =
|
||||||
|
{
|
||||||
|
/* **char */
|
||||||
|
0x20, /* FC64_RP */
|
||||||
|
(NDR64_UINT8) 20 /* 0x14 */,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
&__midl_frag11
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag8_t __midl_frag8 =
|
||||||
|
{
|
||||||
|
/* *int */
|
||||||
|
0x20, /* FC64_RP */
|
||||||
|
(NDR64_UINT8) 12 /* 0xc */,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
&__midl_frag3
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag7_t __midl_frag7 =
|
||||||
|
0x10 /* FC64_CHAR */;
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag6_t __midl_frag6 =
|
||||||
|
{
|
||||||
|
/* */
|
||||||
|
(NDR64_UINT32) 1 /* 0x1 */,
|
||||||
|
{
|
||||||
|
/* struct _NDR64_EXPR_VAR */
|
||||||
|
0x3, /* FC_EXPR_VAR */
|
||||||
|
0x5, /* FC64_INT32 */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT32) 8 /* 0x8 */ /* Offset */
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag5_t __midl_frag5 =
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
0x41, /* FC64_CONF_ARRAY */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
},
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT32) 1 /* 0x1 */,
|
||||||
|
&__midl_frag6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* struct _NDR64_ARRAY_ELEMENT_INFO */
|
||||||
|
(NDR64_UINT32) 1 /* 0x1 */,
|
||||||
|
&__midl_frag7
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag4_t __midl_frag4 =
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
0x20, /* FC64_RP */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
&__midl_frag5
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag3_t __midl_frag3 =
|
||||||
|
0x5 /* FC64_INT32 */;
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag2_t __midl_frag2 =
|
||||||
|
{
|
||||||
|
/* RequestActivation */
|
||||||
|
{
|
||||||
|
/* RequestActivation */ /* procedure RequestActivation */
|
||||||
|
(NDR64_UINT32) 23986240 /* 0x16e0040 */, /* explicit handle */ /* IsIntrepreted, ServerMustSize, ClientMustSize, HasReturn, ServerCorrelation, ClientCorrelation, HasExtensions */
|
||||||
|
(NDR64_UINT32) 48 /* 0x30 */ , /* Stack size */
|
||||||
|
(NDR64_UINT32) 8 /* 0x8 */,
|
||||||
|
(NDR64_UINT32) 40 /* 0x28 */,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT16) 5 /* 0x5 */,
|
||||||
|
(NDR64_UINT16) 8 /* 0x8 */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* struct _NDR64_BIND_AND_NOTIFY_EXTENSION */
|
||||||
|
{
|
||||||
|
/* struct _NDR64_BIND_AND_NOTIFY_EXTENSION */
|
||||||
|
0x72, /* FC64_BIND_PRIMITIVE */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
0 /* 0x0 */, /* Stack offset */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */
|
||||||
|
},
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */ /* Notify index */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* requestSize */ /* parameter requestSize */
|
||||||
|
&__midl_frag3,
|
||||||
|
{
|
||||||
|
/* requestSize */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
0
|
||||||
|
}, /* [in], Basetype, ByValue */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
8 /* 0x8 */, /* Stack offset */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* request */ /* parameter request */
|
||||||
|
&__midl_frag5,
|
||||||
|
{
|
||||||
|
/* request */
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
0
|
||||||
|
}, /* MustSize, MustFree, [in], SimpleRef */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
16 /* 0x10 */, /* Stack offset */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* responseSize */ /* parameter responseSize */
|
||||||
|
&__midl_frag3,
|
||||||
|
{
|
||||||
|
/* responseSize */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
1
|
||||||
|
}, /* [out], Basetype, SimpleRef, UseCache */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
24 /* 0x18 */, /* Stack offset */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* response */ /* parameter response */
|
||||||
|
&__midl_frag10,
|
||||||
|
{
|
||||||
|
/* response */
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
1
|
||||||
|
}, /* MustSize, MustFree, [out], UseCache */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
32 /* 0x20 */, /* Stack offset */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* int */ /* parameter int */
|
||||||
|
&__midl_frag3,
|
||||||
|
{
|
||||||
|
/* int */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
0
|
||||||
|
}, /* [out], IsReturn, Basetype, ByValue */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
40 /* 0x28 */, /* Stack offset */
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag1_t __midl_frag1 =
|
||||||
|
(NDR64_UINT32) 0 /* 0x0 */;
|
||||||
|
|
||||||
|
#endif // !MULTI_CALL_BINARY
|
||||||
|
|
||||||
|
#include "poppack.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const FormatInfoRef KMSServer_Ndr64ProcTable[] =
|
||||||
|
{
|
||||||
|
&__midl_frag2
|
||||||
|
};
|
||||||
|
|
||||||
|
//typedef void *__RPC_USER MIDL_user_allocate_t(SIZE_T)
|
||||||
|
typedef void *(__RPC_API *midl_allocate_t)(size_t);
|
||||||
|
|
||||||
|
#if !MULTI_CALL_BINARY
|
||||||
|
/*static*/ const MIDL_STUB_DESC KMSServer_StubDesc =
|
||||||
|
{
|
||||||
|
(void *)& KMSServer___RpcClientInterface,
|
||||||
|
(midl_allocate_t)MIDL_user_allocate,
|
||||||
|
MIDL_user_free,
|
||||||
|
&KMSServer__MIDL_AutoBindHandle,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
KMSServer__MIDL_TypeFormatString.Format,
|
||||||
|
1, /* -error bounds_check flag */
|
||||||
|
0x60000, /* Ndr library version */
|
||||||
|
0,
|
||||||
|
0x800025b, /* MIDL Version 8.0.603 */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0, /* notify & notify_flag routine table */
|
||||||
|
0x2000001, /* MIDL flag */
|
||||||
|
0, /* cs routines */
|
||||||
|
(void *)& KMSServer_ProxyInfo, /* proxy/server info */
|
||||||
|
0
|
||||||
|
};
|
||||||
|
#endif // !MULTI_CALL_BINARY
|
||||||
|
|
||||||
|
static const MIDL_SYNTAX_INFO KMSServer_SyntaxInfo [ 2 ] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},
|
||||||
|
0,
|
||||||
|
KMSServer__MIDL_ProcFormatString.Format,
|
||||||
|
KMSServer_FormatStringOffsetTable,
|
||||||
|
KMSServer__MIDL_TypeFormatString.Format,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
}
|
||||||
|
,{
|
||||||
|
{{0x71710533,0xbeba,0x4937,{0x83,0x19,0xb5,0xdb,0xef,0x9c,0xcc,0x36}},{1,0}},
|
||||||
|
0,
|
||||||
|
0 ,
|
||||||
|
(unsigned short *) KMSServer_Ndr64ProcTable,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const MIDL_STUBLESS_PROXY_INFO KMSServer_ProxyInfo =
|
||||||
|
{
|
||||||
|
&KMSServer_StubDesc,
|
||||||
|
KMSServer__MIDL_ProcFormatString.Format,
|
||||||
|
KMSServer_FormatStringOffsetTable,
|
||||||
|
(RPC_SYNTAX_IDENTIFIER*)&_RpcTransferSyntax,
|
||||||
|
2,
|
||||||
|
(MIDL_SYNTAX_INFO*)KMSServer_SyntaxInfo
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1200
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* defined(_M_AMD64)*/
|
||||||
|
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
|
||||||
|
|
||||||
|
/* Modified by Hotbird64 for use with MingW and gcc */
|
||||||
|
|
||||||
|
|
||||||
|
/* File created by MIDL compiler version 8.00.0595 */
|
||||||
|
/* at Thu Oct 18 15:24:14 2012
|
||||||
|
*/
|
||||||
|
/* Compiler settings for KMSServer.idl:
|
||||||
|
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0595
|
||||||
|
protocol : dce , ms_ext, c_ext, robust
|
||||||
|
error checks: allocation ref bounds_check enum stub_data
|
||||||
|
VC __declspec() decoration level:
|
||||||
|
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
|
||||||
|
DECLSPEC_UUID(), MIDL_INTERFACE()
|
||||||
|
*/
|
||||||
|
/* @@MIDL_FILE_HEADING( ) */
|
||||||
|
|
||||||
|
#pragma warning( disable: 4049 ) /* more than 64k source lines */
|
||||||
|
|
||||||
|
|
||||||
|
/* verify that the <rpcndr.h> version is high enough to compile this file*/
|
||||||
|
#ifndef __REQUIRED_RPCNDR_H_VERSION__
|
||||||
|
#define __REQUIRED_RPCNDR_H_VERSION__ 475
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#include "rpc.h"
|
||||||
|
#include "rpcndr.h"
|
||||||
|
|
||||||
|
#ifndef __RPCNDR_H_VERSION__
|
||||||
|
#error this stub requires an updated version of <rpcndr.h>
|
||||||
|
#endif // __RPCNDR_H_VERSION__
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __KMSServer_h_h__
|
||||||
|
#define __KMSServer_h_h__
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Forward Declarations */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __KMSServer_INTERFACE_DEFINED__
|
||||||
|
#define __KMSServer_INTERFACE_DEFINED__
|
||||||
|
|
||||||
|
/* interface KMSServer */
|
||||||
|
/* [version][uuid] */
|
||||||
|
|
||||||
|
int RequestActivation(
|
||||||
|
/* [in] */ handle_t IDL_handle,
|
||||||
|
/* [in] */ int requestSize,
|
||||||
|
/* [size_is][in] */ unsigned char *request,
|
||||||
|
/* [out] */ int *responseSize,
|
||||||
|
/* [size_is][size_is][out] */ unsigned char **response);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern RPC_IF_HANDLE KMSServer_v1_0_c_ifspec;
|
||||||
|
extern RPC_IF_HANDLE KMSServer_v1_0_s_ifspec;
|
||||||
|
#endif /* __KMSServer_INTERFACE_DEFINED__ */
|
||||||
|
|
||||||
|
/* Additional Prototypes for ALL interfaces */
|
||||||
|
|
||||||
|
/* end of Additional Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,282 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/* this ALWAYS GENERATED file contains the RPC server stubs */
|
||||||
|
|
||||||
|
/* WARNING! manually edited by Hotbird64 to work with MingW */
|
||||||
|
|
||||||
|
/* File created by MIDL compiler version 8.00.0595 */
|
||||||
|
/* at Thu Oct 18 15:24:14 2012
|
||||||
|
*/
|
||||||
|
/* Compiler settings for KMSServer.idl:
|
||||||
|
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0595
|
||||||
|
protocol : dce , ms_ext, c_ext, robust
|
||||||
|
error checks: allocation ref bounds_check enum stub_data
|
||||||
|
VC __declspec() decoration level:
|
||||||
|
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
|
||||||
|
DECLSPEC_UUID(), MIDL_INTERFACE()
|
||||||
|
*/
|
||||||
|
/* @@MIDL_FILE_HEADING( ) */
|
||||||
|
|
||||||
|
#if !defined(_M_IA64) && !defined(_M_AMD64) && !defined(_ARM_)
|
||||||
|
|
||||||
|
|
||||||
|
#pragma warning( disable: 4049 ) /* more than 64k source lines */
|
||||||
|
#if _MSC_VER >= 1200
|
||||||
|
#pragma warning(push)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma warning( disable: 4211 ) /* redefine extern to static */
|
||||||
|
#pragma warning( disable: 4232 ) /* dllimport identity*/
|
||||||
|
#pragma warning( disable: 4024 ) /* array to pointer mapping*/
|
||||||
|
#pragma warning( disable: 4100 ) /* unreferenced arguments in x86 call */
|
||||||
|
|
||||||
|
#pragma optimize("", off )
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "KMSServer_h.h"
|
||||||
|
|
||||||
|
#define TYPE_FORMAT_STRING_SIZE 43
|
||||||
|
#define PROC_FORMAT_STRING_SIZE 59
|
||||||
|
#define EXPR_FORMAT_STRING_SIZE 1
|
||||||
|
#define TRANSMIT_AS_TABLE_SIZE 0
|
||||||
|
#define WIRE_MARSHAL_TABLE_SIZE 0
|
||||||
|
|
||||||
|
typedef struct _KMSServer_MIDL_TYPE_FORMAT_STRING
|
||||||
|
{
|
||||||
|
short Pad;
|
||||||
|
unsigned char Format[ TYPE_FORMAT_STRING_SIZE ];
|
||||||
|
} KMSServer_MIDL_TYPE_FORMAT_STRING;
|
||||||
|
|
||||||
|
typedef struct _KMSServer_MIDL_PROC_FORMAT_STRING
|
||||||
|
{
|
||||||
|
short Pad;
|
||||||
|
unsigned char Format[ PROC_FORMAT_STRING_SIZE ];
|
||||||
|
} KMSServer_MIDL_PROC_FORMAT_STRING;
|
||||||
|
|
||||||
|
typedef struct _KMSServer_MIDL_EXPR_FORMAT_STRING
|
||||||
|
{
|
||||||
|
long Pad;
|
||||||
|
unsigned char Format[ EXPR_FORMAT_STRING_SIZE ];
|
||||||
|
} KMSServer_MIDL_EXPR_FORMAT_STRING;
|
||||||
|
|
||||||
|
|
||||||
|
static const RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax =
|
||||||
|
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}};
|
||||||
|
|
||||||
|
extern const KMSServer_MIDL_TYPE_FORMAT_STRING KMSServer__MIDL_TypeFormatString;
|
||||||
|
extern const KMSServer_MIDL_PROC_FORMAT_STRING KMSServer__MIDL_ProcFormatString;
|
||||||
|
extern const KMSServer_MIDL_EXPR_FORMAT_STRING KMSServer__MIDL_ExprFormatString;
|
||||||
|
|
||||||
|
/* Standard interface: KMSServer, ver. 1.0,
|
||||||
|
GUID={0x51C82175,0x844E,0x4750,{0xB0,0xD8,0xEC,0x25,0x55,0x55,0xBC,0x06}} */
|
||||||
|
|
||||||
|
|
||||||
|
extern const MIDL_SERVER_INFO KMSServer_ServerInfo;
|
||||||
|
|
||||||
|
extern const RPC_DISPATCH_TABLE KMSServer_v1_0_DispatchTable;
|
||||||
|
|
||||||
|
int ProcessActivationRequest(
|
||||||
|
/* [in] */ handle_t IDL_handle,
|
||||||
|
/* [in] */ int requestSize,
|
||||||
|
/* [size_is][in] */ unsigned char *request,
|
||||||
|
/* [out] */ int *responseSize,
|
||||||
|
/* [size_is][size_is][out] */ unsigned char **response);
|
||||||
|
|
||||||
|
static const RPC_SERVER_INTERFACE KMSServer___RpcServerInterface =
|
||||||
|
{
|
||||||
|
sizeof(RPC_SERVER_INTERFACE),
|
||||||
|
{{0x51C82175,0x844E,0x4750,{0xB0,0xD8,0xEC,0x25,0x55,0x55,0xBC,0x06}},{1,0}},
|
||||||
|
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},
|
||||||
|
(RPC_DISPATCH_TABLE*)&KMSServer_v1_0_DispatchTable,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
&KMSServer_ServerInfo,
|
||||||
|
0x04000000
|
||||||
|
};
|
||||||
|
RPC_IF_HANDLE KMSServer_v1_0_s_ifspec = (RPC_IF_HANDLE)& KMSServer___RpcServerInterface;
|
||||||
|
|
||||||
|
extern const MIDL_STUB_DESC KMSServer_StubDesc;
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(__RPC_WIN32__)
|
||||||
|
#error Invalid build platform for this stub.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !(TARGET_IS_NT50_OR_LATER)
|
||||||
|
#error You need Windows 2000 or later to run this stub because it uses these features:
|
||||||
|
#error /robust command line switch.
|
||||||
|
#error However, your C/C++ compilation flags indicate you intend to run this app on earlier systems.
|
||||||
|
#error This app will fail with the RPC_X_WRONG_STUB_VERSION error.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const KMSServer_MIDL_PROC_FORMAT_STRING KMSServer__MIDL_ProcFormatString =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Procedure RequestActivation */
|
||||||
|
|
||||||
|
0x0, /* 0 */
|
||||||
|
0x48, /* Old Flags: */
|
||||||
|
/* 2 */ NdrFcLong( 0x0 ), /* 0 */
|
||||||
|
/* 6 */ NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
/* 8 */ NdrFcShort( 0x18 ), /* x86 Stack size/offset = 24 */
|
||||||
|
/* 10 */ 0x32, /* FC_BIND_PRIMITIVE */
|
||||||
|
0x0, /* 0 */
|
||||||
|
/* 12 */ NdrFcShort( 0x0 ), /* x86 Stack size/offset = 0 */
|
||||||
|
/* 14 */ NdrFcShort( 0x8 ), /* 8 */
|
||||||
|
/* 16 */ NdrFcShort( 0x24 ), /* 36 */
|
||||||
|
/* 18 */ 0x47, /* Oi2 Flags: srv must size, clt must size, has return, has ext, */
|
||||||
|
0x5, /* 5 */
|
||||||
|
/* 20 */ 0x8, /* 8 */
|
||||||
|
0x7, /* Ext Flags: new corr desc, clt corr check, srv corr check, */
|
||||||
|
/* 22 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 24 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 26 */ NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
|
||||||
|
/* Parameter IDL_handle */
|
||||||
|
|
||||||
|
/* 28 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */
|
||||||
|
/* 30 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
|
||||||
|
/* 32 */ 0x8, /* FC_LONG */
|
||||||
|
0x0, /* 0 */
|
||||||
|
|
||||||
|
/* Parameter requestSize */
|
||||||
|
|
||||||
|
/* 34 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */
|
||||||
|
/* 36 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
|
||||||
|
/* 38 */ NdrFcShort( 0x6 ), /* Type Offset=6 */
|
||||||
|
|
||||||
|
/* Parameter request */
|
||||||
|
|
||||||
|
/* 40 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
|
||||||
|
/* 42 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
|
||||||
|
/* 44 */ 0x8, /* FC_LONG */
|
||||||
|
0x0, /* 0 */
|
||||||
|
|
||||||
|
/* Parameter responseSize */
|
||||||
|
|
||||||
|
/* 46 */ NdrFcShort( 0x2013 ), /* Flags: must size, must free, out, srv alloc size=8 */
|
||||||
|
/* 48 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */
|
||||||
|
/* 50 */ NdrFcShort( 0x16 ), /* Type Offset=22 */
|
||||||
|
|
||||||
|
/* Parameter response */
|
||||||
|
|
||||||
|
/* 52 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
|
||||||
|
/* 54 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */
|
||||||
|
/* 56 */ 0x8, /* FC_LONG */
|
||||||
|
0x0, /* 0 */
|
||||||
|
|
||||||
|
0x0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const KMSServer_MIDL_TYPE_FORMAT_STRING KMSServer__MIDL_TypeFormatString =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
/* 2 */
|
||||||
|
0x11, 0x0, /* FC_RP */
|
||||||
|
/* 4 */ NdrFcShort( 0x2 ), /* Offset= 2 (6) */
|
||||||
|
/* 6 */
|
||||||
|
0x1b, /* FC_CARRAY */
|
||||||
|
0x0, /* 0 */
|
||||||
|
/* 8 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 10 */ 0x28, /* Corr desc: parameter, FC_LONG */
|
||||||
|
0x0, /* */
|
||||||
|
/* 12 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
|
||||||
|
/* 14 */ NdrFcShort( 0x1 ), /* Corr flags: early, */
|
||||||
|
/* 16 */ 0x2, /* FC_CHAR */
|
||||||
|
0x5b, /* FC_END */
|
||||||
|
/* 18 */
|
||||||
|
0x11, 0xc, /* FC_RP [alloced_on_stack] [simple_pointer] */
|
||||||
|
/* 20 */ 0x8, /* FC_LONG */
|
||||||
|
0x5c, /* FC_PAD */
|
||||||
|
/* 22 */
|
||||||
|
0x11, 0x14, /* FC_RP [alloced_on_stack] [pointer_deref] */
|
||||||
|
/* 24 */ NdrFcShort( 0x2 ), /* Offset= 2 (26) */
|
||||||
|
/* 26 */
|
||||||
|
0x12, 0x0, /* FC_UP */
|
||||||
|
/* 28 */ NdrFcShort( 0x2 ), /* Offset= 2 (30) */
|
||||||
|
/* 30 */
|
||||||
|
0x1b, /* FC_CARRAY */
|
||||||
|
0x0, /* 0 */
|
||||||
|
/* 32 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 34 */ 0x28, /* Corr desc: parameter, FC_LONG */
|
||||||
|
0x54, /* FC_DEREFERENCE */
|
||||||
|
/* 36 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
|
||||||
|
/* 38 */ NdrFcShort( 0x1 ), /* Corr flags: early, */
|
||||||
|
/* 40 */ 0x2, /* FC_CHAR */
|
||||||
|
0x5b, /* FC_END */
|
||||||
|
|
||||||
|
0x0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned short KMSServer_FormatStringOffsetTable[] =
|
||||||
|
{
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef void *(__RPC_API *midl_allocate_t)(size_t);
|
||||||
|
|
||||||
|
const MIDL_STUB_DESC KMSServer_StubDesc =
|
||||||
|
{
|
||||||
|
(void *)& KMSServer___RpcServerInterface,
|
||||||
|
(midl_allocate_t)MIDL_user_allocate,
|
||||||
|
MIDL_user_free,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
KMSServer__MIDL_TypeFormatString.Format,
|
||||||
|
1, /* -error bounds_check flag */
|
||||||
|
0x50002, /* Ndr library version */
|
||||||
|
0,
|
||||||
|
0x8000253, /* MIDL Version 8.0.595 */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0, /* notify & notify_flag routine table */
|
||||||
|
0x1, /* MIDL flag */
|
||||||
|
0, /* cs routines */
|
||||||
|
0, /* proxy/server info */
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static const RPC_DISPATCH_FUNCTION KMSServer_table[] =
|
||||||
|
{
|
||||||
|
NdrServerCall2,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
const RPC_DISPATCH_TABLE KMSServer_v1_0_DispatchTable =
|
||||||
|
{
|
||||||
|
1,
|
||||||
|
(RPC_DISPATCH_FUNCTION*)KMSServer_table
|
||||||
|
};
|
||||||
|
|
||||||
|
static const SERVER_ROUTINE KMSServer_ServerRoutineTable[] =
|
||||||
|
{
|
||||||
|
(SERVER_ROUTINE)ProcessActivationRequest
|
||||||
|
};
|
||||||
|
|
||||||
|
const MIDL_SERVER_INFO KMSServer_ServerInfo =
|
||||||
|
{
|
||||||
|
&KMSServer_StubDesc,
|
||||||
|
KMSServer_ServerRoutineTable,
|
||||||
|
KMSServer__MIDL_ProcFormatString.Format,
|
||||||
|
KMSServer_FormatStringOffsetTable,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0};
|
||||||
|
#pragma optimize("", on )
|
||||||
|
#if _MSC_VER >= 1200
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !defined(_M_IA64) && !defined(_M_AMD64) && !defined(_ARM_) */
|
||||||
|
|
||||||
@@ -0,0 +1,730 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/* this ALWAYS GENERATED file contains the RPC server stubs */
|
||||||
|
|
||||||
|
|
||||||
|
/* File created by MIDL compiler version 8.00.0603 */
|
||||||
|
/* at Fri Feb 20 04:17:07 2015
|
||||||
|
* Modified by Hotbird64 to work with gcc and MingW-w64
|
||||||
|
*/
|
||||||
|
/* Compiler settings for KMSServer.idl:
|
||||||
|
Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.00.0603
|
||||||
|
protocol : all , ms_ext, c_ext, robust
|
||||||
|
error checks: allocation ref bounds_check enum stub_data
|
||||||
|
VC __declspec() decoration level:
|
||||||
|
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
|
||||||
|
DECLSPEC_UUID(), MIDL_INTERFACE()
|
||||||
|
*/
|
||||||
|
/* @@MIDL_FILE_HEADING( ) */
|
||||||
|
|
||||||
|
#if defined(_M_AMD64)
|
||||||
|
|
||||||
|
int ProcessActivationRequest(
|
||||||
|
/* [in] */ handle_t IDL_handle,
|
||||||
|
/* [in] */ int requestSize,
|
||||||
|
/* [size_is][in] */ unsigned char *request,
|
||||||
|
/* [out] */ int *responseSize,
|
||||||
|
/* [size_is][size_is][out] */ unsigned char **response);
|
||||||
|
|
||||||
|
|
||||||
|
#pragma warning( disable: 4049 ) /* more than 64k source lines */
|
||||||
|
#if _MSC_VER >= 1200
|
||||||
|
#pragma warning(push)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma warning( disable: 4211 ) /* redefine extern to static */
|
||||||
|
#pragma warning( disable: 4232 ) /* dllimport identity*/
|
||||||
|
#pragma warning( disable: 4024 ) /* array to pointer mapping*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "KMSServer_h.h"
|
||||||
|
|
||||||
|
#define TYPE_FORMAT_STRING_SIZE 43
|
||||||
|
#define PROC_FORMAT_STRING_SIZE 61
|
||||||
|
#define EXPR_FORMAT_STRING_SIZE 1
|
||||||
|
#define TRANSMIT_AS_TABLE_SIZE 0
|
||||||
|
#define WIRE_MARSHAL_TABLE_SIZE 0
|
||||||
|
|
||||||
|
typedef struct _KMSServer_MIDL_TYPE_FORMAT_STRING
|
||||||
|
{
|
||||||
|
short Pad;
|
||||||
|
unsigned char Format[ TYPE_FORMAT_STRING_SIZE ];
|
||||||
|
} KMSServer_MIDL_TYPE_FORMAT_STRING;
|
||||||
|
|
||||||
|
typedef struct _KMSServer_MIDL_PROC_FORMAT_STRING
|
||||||
|
{
|
||||||
|
short Pad;
|
||||||
|
unsigned char Format[ PROC_FORMAT_STRING_SIZE ];
|
||||||
|
} KMSServer_MIDL_PROC_FORMAT_STRING;
|
||||||
|
|
||||||
|
typedef struct _KMSServer_MIDL_EXPR_FORMAT_STRING
|
||||||
|
{
|
||||||
|
long Pad;
|
||||||
|
unsigned char Format[ EXPR_FORMAT_STRING_SIZE ];
|
||||||
|
} KMSServer_MIDL_EXPR_FORMAT_STRING;
|
||||||
|
|
||||||
|
|
||||||
|
static const RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax =
|
||||||
|
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}};
|
||||||
|
|
||||||
|
static const RPC_SYNTAX_IDENTIFIER _NDR64_RpcTransferSyntax =
|
||||||
|
{{0x71710533,0xbeba,0x4937,{0x83,0x19,0xb5,0xdb,0xef,0x9c,0xcc,0x36}},{1,0}};
|
||||||
|
|
||||||
|
|
||||||
|
extern const KMSServer_MIDL_TYPE_FORMAT_STRING KMSServer__MIDL_TypeFormatString;
|
||||||
|
extern const KMSServer_MIDL_PROC_FORMAT_STRING KMSServer__MIDL_ProcFormatString;
|
||||||
|
extern const KMSServer_MIDL_EXPR_FORMAT_STRING KMSServer__MIDL_ExprFormatString;
|
||||||
|
|
||||||
|
/* Standard interface: KMSServer, ver. 1.0,
|
||||||
|
GUID={0x51C82175,0x844E,0x4750,{0xB0,0xD8,0xEC,0x25,0x55,0x55,0xBC,0x06}} */
|
||||||
|
|
||||||
|
|
||||||
|
extern const MIDL_SERVER_INFO KMSServer_ServerInfo;
|
||||||
|
|
||||||
|
extern const RPC_DISPATCH_TABLE KMSServer_v1_0_DispatchTable;
|
||||||
|
|
||||||
|
static const RPC_SERVER_INTERFACE KMSServer___RpcServerInterface =
|
||||||
|
{
|
||||||
|
sizeof(RPC_SERVER_INTERFACE),
|
||||||
|
{{0x51C82175,0x844E,0x4750,{0xB0,0xD8,0xEC,0x25,0x55,0x55,0xBC,0x06}},{1,0}},
|
||||||
|
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},
|
||||||
|
(RPC_DISPATCH_TABLE*)&KMSServer_v1_0_DispatchTable,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
&KMSServer_ServerInfo,
|
||||||
|
0x06000000
|
||||||
|
};
|
||||||
|
RPC_IF_HANDLE KMSServer_v1_0_s_ifspec = (RPC_IF_HANDLE)& KMSServer___RpcServerInterface;
|
||||||
|
|
||||||
|
extern const MIDL_STUB_DESC KMSServer_StubDesc;
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(__RPC_WIN64__)
|
||||||
|
#error Invalid build platform for this stub.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*static*/ const KMSServer_MIDL_PROC_FORMAT_STRING KMSServer__MIDL_ProcFormatString =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Procedure RequestActivation */
|
||||||
|
|
||||||
|
0x0, /* 0 */
|
||||||
|
0x48, /* Old Flags: */
|
||||||
|
/* 2 */ NdrFcLong( 0x0 ), /* 0 */
|
||||||
|
/* 6 */ NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
/* 8 */ NdrFcShort( 0x30 ), /* X64 Stack size/offset = 48 */
|
||||||
|
/* 10 */ 0x32, /* FC_BIND_PRIMITIVE */
|
||||||
|
0x0, /* 0 */
|
||||||
|
/* 12 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */
|
||||||
|
/* 14 */ NdrFcShort( 0x8 ), /* 8 */
|
||||||
|
/* 16 */ NdrFcShort( 0x24 ), /* 36 */
|
||||||
|
/* 18 */ 0x47, /* Oi2 Flags: srv must size, clt must size, has return, has ext, */
|
||||||
|
0x5, /* 5 */
|
||||||
|
/* 20 */ 0xa, /* 10 */
|
||||||
|
0x7, /* Ext Flags: new corr desc, clt corr check, srv corr check, */
|
||||||
|
/* 22 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 24 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 26 */ NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
/* 28 */ NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
|
||||||
|
/* Parameter IDL_handle */
|
||||||
|
|
||||||
|
/* 30 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */
|
||||||
|
/* 32 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */
|
||||||
|
/* 34 */ 0x8, /* FC_LONG */
|
||||||
|
0x0, /* 0 */
|
||||||
|
|
||||||
|
/* Parameter requestSize */
|
||||||
|
|
||||||
|
/* 36 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */
|
||||||
|
/* 38 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */
|
||||||
|
/* 40 */ NdrFcShort( 0x6 ), /* Type Offset=6 */
|
||||||
|
|
||||||
|
/* Parameter request */
|
||||||
|
|
||||||
|
/* 42 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
|
||||||
|
/* 44 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */
|
||||||
|
/* 46 */ 0x8, /* FC_LONG */
|
||||||
|
0x0, /* 0 */
|
||||||
|
|
||||||
|
/* Parameter responseSize */
|
||||||
|
|
||||||
|
/* 48 */ NdrFcShort( 0x2013 ), /* Flags: must size, must free, out, srv alloc size=8 */
|
||||||
|
/* 50 */ NdrFcShort( 0x20 ), /* X64 Stack size/offset = 32 */
|
||||||
|
/* 52 */ NdrFcShort( 0x16 ), /* Type Offset=22 */
|
||||||
|
|
||||||
|
/* Parameter response */
|
||||||
|
|
||||||
|
/* 54 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
|
||||||
|
/* 56 */ NdrFcShort( 0x28 ), /* X64 Stack size/offset = 40 */
|
||||||
|
/* 58 */ 0x8, /* FC_LONG */
|
||||||
|
0x0, /* 0 */
|
||||||
|
|
||||||
|
0x0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const KMSServer_MIDL_TYPE_FORMAT_STRING KMSServer__MIDL_TypeFormatString =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
NdrFcShort( 0x0 ), /* 0 */
|
||||||
|
/* 2 */
|
||||||
|
0x11, 0x0, /* FC_RP */
|
||||||
|
/* 4 */ NdrFcShort( 0x2 ), /* Offset= 2 (6) */
|
||||||
|
/* 6 */
|
||||||
|
0x1b, /* FC_CARRAY */
|
||||||
|
0x0, /* 0 */
|
||||||
|
/* 8 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 10 */ 0x28, /* Corr desc: parameter, FC_LONG */
|
||||||
|
0x0, /* */
|
||||||
|
/* 12 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */
|
||||||
|
/* 14 */ NdrFcShort( 0x1 ), /* Corr flags: early, */
|
||||||
|
/* 16 */ 0x2, /* FC_CHAR */
|
||||||
|
0x5b, /* FC_END */
|
||||||
|
/* 18 */
|
||||||
|
0x11, 0xc, /* FC_RP [alloced_on_stack] [simple_pointer] */
|
||||||
|
/* 20 */ 0x8, /* FC_LONG */
|
||||||
|
0x5c, /* FC_PAD */
|
||||||
|
/* 22 */
|
||||||
|
0x11, 0x14, /* FC_RP [alloced_on_stack] [pointer_deref] */
|
||||||
|
/* 24 */ NdrFcShort( 0x2 ), /* Offset= 2 (26) */
|
||||||
|
/* 26 */
|
||||||
|
0x12, 0x0, /* FC_UP */
|
||||||
|
/* 28 */ NdrFcShort( 0x2 ), /* Offset= 2 (30) */
|
||||||
|
/* 30 */
|
||||||
|
0x1b, /* FC_CARRAY */
|
||||||
|
0x0, /* 0 */
|
||||||
|
/* 32 */ NdrFcShort( 0x1 ), /* 1 */
|
||||||
|
/* 34 */ 0x28, /* Corr desc: parameter, FC_LONG */
|
||||||
|
0x54, /* FC_DEREFERENCE */
|
||||||
|
/* 36 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */
|
||||||
|
/* 38 */ NdrFcShort( 0x1 ), /* Corr flags: early, */
|
||||||
|
/* 40 */ 0x2, /* FC_CHAR */
|
||||||
|
0x5b, /* FC_END */
|
||||||
|
|
||||||
|
0x0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned short KMSServer_FormatStringOffsetTable[] =
|
||||||
|
{
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static const RPC_DISPATCH_FUNCTION KMSServer_table[] =
|
||||||
|
{
|
||||||
|
NdrServerCall2,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
/*static*/ const RPC_DISPATCH_TABLE KMSServer_v1_0_DispatchTable =
|
||||||
|
{
|
||||||
|
1,
|
||||||
|
(RPC_DISPATCH_FUNCTION*)KMSServer_table
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* defined(_M_AMD64)*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* this ALWAYS GENERATED file contains the RPC server stubs */
|
||||||
|
|
||||||
|
|
||||||
|
/* File created by MIDL compiler version 8.00.0603 */
|
||||||
|
/* at Fri Feb 20 04:17:07 2015
|
||||||
|
*/
|
||||||
|
/* Compiler settings for KMSServer.idl:
|
||||||
|
Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.00.0603
|
||||||
|
protocol : all , ms_ext, c_ext, robust
|
||||||
|
error checks: allocation ref bounds_check enum stub_data
|
||||||
|
VC __declspec() decoration level:
|
||||||
|
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
|
||||||
|
DECLSPEC_UUID(), MIDL_INTERFACE()
|
||||||
|
*/
|
||||||
|
/* @@MIDL_FILE_HEADING( ) */
|
||||||
|
|
||||||
|
#if defined(_M_AMD64)
|
||||||
|
|
||||||
|
|
||||||
|
#pragma warning( disable: 4049 ) /* more than 64k source lines */
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(__RPC_WIN64__)
|
||||||
|
#error Invalid build platform for this stub.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "ndr64types.h"
|
||||||
|
#include "pshpack8.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
NDR64_FORMAT_UINT32 frag1;
|
||||||
|
struct _NDR64_EXPR_OPERATOR frag2;
|
||||||
|
struct _NDR64_EXPR_VAR frag3;
|
||||||
|
}
|
||||||
|
__midl_frag13_t;
|
||||||
|
extern const __midl_frag13_t __midl_frag13;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
struct _NDR64_CONF_ARRAY_HEADER_FORMAT frag1;
|
||||||
|
struct _NDR64_ARRAY_ELEMENT_INFO frag2;
|
||||||
|
}
|
||||||
|
__midl_frag12_t;
|
||||||
|
extern const __midl_frag12_t __midl_frag12;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct _NDR64_POINTER_FORMAT
|
||||||
|
__midl_frag11_t;
|
||||||
|
extern const __midl_frag11_t __midl_frag11;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct _NDR64_POINTER_FORMAT
|
||||||
|
__midl_frag10_t;
|
||||||
|
extern const __midl_frag10_t __midl_frag10;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct _NDR64_POINTER_FORMAT
|
||||||
|
__midl_frag8_t;
|
||||||
|
extern const __midl_frag8_t __midl_frag8;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
NDR64_FORMAT_CHAR
|
||||||
|
__midl_frag7_t;
|
||||||
|
extern const __midl_frag7_t __midl_frag7;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
NDR64_FORMAT_UINT32 frag1;
|
||||||
|
struct _NDR64_EXPR_VAR frag2;
|
||||||
|
}
|
||||||
|
__midl_frag6_t;
|
||||||
|
extern const __midl_frag6_t __midl_frag6;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
struct _NDR64_CONF_ARRAY_HEADER_FORMAT frag1;
|
||||||
|
struct _NDR64_ARRAY_ELEMENT_INFO frag2;
|
||||||
|
}
|
||||||
|
__midl_frag5_t;
|
||||||
|
extern const __midl_frag5_t __midl_frag5;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct _NDR64_POINTER_FORMAT
|
||||||
|
__midl_frag4_t;
|
||||||
|
extern const __midl_frag4_t __midl_frag4;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
NDR64_FORMAT_CHAR
|
||||||
|
__midl_frag3_t;
|
||||||
|
extern const __midl_frag3_t __midl_frag3;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
struct _NDR64_PROC_FORMAT frag1;
|
||||||
|
struct _NDR64_BIND_AND_NOTIFY_EXTENSION frag2;
|
||||||
|
struct _NDR64_PARAM_FORMAT frag3;
|
||||||
|
struct _NDR64_PARAM_FORMAT frag4;
|
||||||
|
struct _NDR64_PARAM_FORMAT frag5;
|
||||||
|
struct _NDR64_PARAM_FORMAT frag6;
|
||||||
|
struct _NDR64_PARAM_FORMAT frag7;
|
||||||
|
}
|
||||||
|
__midl_frag2_t;
|
||||||
|
extern const __midl_frag2_t __midl_frag2;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
NDR64_FORMAT_UINT32
|
||||||
|
__midl_frag1_t;
|
||||||
|
extern const __midl_frag1_t __midl_frag1;
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag13_t __midl_frag13 =
|
||||||
|
{
|
||||||
|
/* */
|
||||||
|
(NDR64_UINT32) 1 /* 0x1 */,
|
||||||
|
{
|
||||||
|
/* struct _NDR64_EXPR_OPERATOR */
|
||||||
|
0x4, /* FC_EXPR_OPER */
|
||||||
|
0x5, /* OP_UNARY_INDIRECTION */
|
||||||
|
0x5, /* FC64_INT32 */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* struct _NDR64_EXPR_VAR */
|
||||||
|
0x3, /* FC_EXPR_VAR */
|
||||||
|
0x7, /* FC64_INT64 */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT32) 24 /* 0x18 */ /* Offset */
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag12_t __midl_frag12 =
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
0x41, /* FC64_CONF_ARRAY */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
},
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT32) 1 /* 0x1 */,
|
||||||
|
&__midl_frag13
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* struct _NDR64_ARRAY_ELEMENT_INFO */
|
||||||
|
(NDR64_UINT32) 1 /* 0x1 */,
|
||||||
|
&__midl_frag7
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag11_t __midl_frag11 =
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
0x21, /* FC64_UP */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
&__midl_frag12
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag10_t __midl_frag10 =
|
||||||
|
{
|
||||||
|
/* **char */
|
||||||
|
0x20, /* FC64_RP */
|
||||||
|
(NDR64_UINT8) 20 /* 0x14 */,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
&__midl_frag11
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag8_t __midl_frag8 =
|
||||||
|
{
|
||||||
|
/* *int */
|
||||||
|
0x20, /* FC64_RP */
|
||||||
|
(NDR64_UINT8) 12 /* 0xc */,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
&__midl_frag3
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag7_t __midl_frag7 =
|
||||||
|
0x10 /* FC64_CHAR */;
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag6_t __midl_frag6 =
|
||||||
|
{
|
||||||
|
/* */
|
||||||
|
(NDR64_UINT32) 1 /* 0x1 */,
|
||||||
|
{
|
||||||
|
/* struct _NDR64_EXPR_VAR */
|
||||||
|
0x3, /* FC_EXPR_VAR */
|
||||||
|
0x5, /* FC64_INT32 */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT32) 8 /* 0x8 */ /* Offset */
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag5_t __midl_frag5 =
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
0x41, /* FC64_CONF_ARRAY */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
},
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT32) 1 /* 0x1 */,
|
||||||
|
&__midl_frag6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* struct _NDR64_ARRAY_ELEMENT_INFO */
|
||||||
|
(NDR64_UINT32) 1 /* 0x1 */,
|
||||||
|
&__midl_frag7
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag4_t __midl_frag4 =
|
||||||
|
{
|
||||||
|
/* *char */
|
||||||
|
0x20, /* FC64_RP */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
&__midl_frag5
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag3_t __midl_frag3 =
|
||||||
|
0x5 /* FC64_INT32 */;
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag2_t __midl_frag2 =
|
||||||
|
{
|
||||||
|
/* RequestActivation */
|
||||||
|
{
|
||||||
|
/* RequestActivation */ /* procedure RequestActivation */
|
||||||
|
(NDR64_UINT32) 23986240 /* 0x16e0040 */, /* explicit handle */ /* IsIntrepreted, ServerMustSize, ClientMustSize, HasReturn, ServerCorrelation, ClientCorrelation, HasExtensions */
|
||||||
|
(NDR64_UINT32) 48 /* 0x30 */ , /* Stack size */
|
||||||
|
(NDR64_UINT32) 8 /* 0x8 */,
|
||||||
|
(NDR64_UINT32) 40 /* 0x28 */,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT16) 5 /* 0x5 */,
|
||||||
|
(NDR64_UINT16) 8 /* 0x8 */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* struct _NDR64_BIND_AND_NOTIFY_EXTENSION */
|
||||||
|
{
|
||||||
|
/* struct _NDR64_BIND_AND_NOTIFY_EXTENSION */
|
||||||
|
0x72, /* FC64_BIND_PRIMITIVE */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
0 /* 0x0 */, /* Stack offset */
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */,
|
||||||
|
(NDR64_UINT8) 0 /* 0x0 */
|
||||||
|
},
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */ /* Notify index */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* requestSize */ /* parameter requestSize */
|
||||||
|
&__midl_frag3,
|
||||||
|
{
|
||||||
|
/* requestSize */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
0
|
||||||
|
}, /* [in], Basetype, ByValue */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
8 /* 0x8 */, /* Stack offset */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* request */ /* parameter request */
|
||||||
|
&__midl_frag5,
|
||||||
|
{
|
||||||
|
/* request */
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
0
|
||||||
|
}, /* MustSize, MustFree, [in], SimpleRef */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
16 /* 0x10 */, /* Stack offset */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* responseSize */ /* parameter responseSize */
|
||||||
|
&__midl_frag3,
|
||||||
|
{
|
||||||
|
/* responseSize */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
1
|
||||||
|
}, /* [out], Basetype, SimpleRef, UseCache */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
24 /* 0x18 */, /* Stack offset */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* response */ /* parameter response */
|
||||||
|
&__midl_frag10,
|
||||||
|
{
|
||||||
|
/* response */
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
1
|
||||||
|
}, /* MustSize, MustFree, [out], UseCache */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
32 /* 0x20 */, /* Stack offset */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* int */ /* parameter int */
|
||||||
|
&__midl_frag3,
|
||||||
|
{
|
||||||
|
/* int */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
0
|
||||||
|
}, /* [out], IsReturn, Basetype, ByValue */
|
||||||
|
(NDR64_UINT16) 0 /* 0x0 */,
|
||||||
|
40 /* 0x28 */, /* Stack offset */
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const __midl_frag1_t __midl_frag1 =
|
||||||
|
(NDR64_UINT32) 0 /* 0x0 */;
|
||||||
|
|
||||||
|
|
||||||
|
#include "poppack.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const FormatInfoRef KMSServer_Ndr64ProcTable[] =
|
||||||
|
{
|
||||||
|
&__midl_frag2
|
||||||
|
};
|
||||||
|
|
||||||
|
//typedef void *__RPC_USER MIDL_user_allocate_t(SIZE_T);
|
||||||
|
typedef void *(__RPC_API *midl_allocate_t)(size_t);
|
||||||
|
|
||||||
|
/*static*/ const MIDL_STUB_DESC KMSServer_StubDesc =
|
||||||
|
{
|
||||||
|
(void *)& KMSServer___RpcServerInterface,
|
||||||
|
(midl_allocate_t)MIDL_user_allocate,
|
||||||
|
MIDL_user_free,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
KMSServer__MIDL_TypeFormatString.Format,
|
||||||
|
1, /* -error bounds_check flag */
|
||||||
|
0x60000, /* Ndr library version */
|
||||||
|
0,
|
||||||
|
0x800025b, /* MIDL Version 8.0.603 */
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0, /* notify & notify_flag routine table */
|
||||||
|
0x2000001, /* MIDL flag */
|
||||||
|
0, /* cs routines */
|
||||||
|
(void *)& KMSServer_ServerInfo, /* proxy/server info */
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static const RPC_DISPATCH_FUNCTION KMSServer_NDR64__table[] =
|
||||||
|
{
|
||||||
|
NdrServerCallAll,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
static const RPC_DISPATCH_TABLE KMSServer_NDR64__v1_0_DispatchTable =
|
||||||
|
{
|
||||||
|
1,
|
||||||
|
(RPC_DISPATCH_FUNCTION*)KMSServer_NDR64__table
|
||||||
|
};
|
||||||
|
|
||||||
|
static const MIDL_SYNTAX_INFO KMSServer_SyntaxInfo [ 2 ] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},
|
||||||
|
(RPC_DISPATCH_TABLE*)&KMSServer_v1_0_DispatchTable,
|
||||||
|
KMSServer__MIDL_ProcFormatString.Format,
|
||||||
|
KMSServer_FormatStringOffsetTable,
|
||||||
|
KMSServer__MIDL_TypeFormatString.Format,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
}
|
||||||
|
,{
|
||||||
|
{{0x71710533,0xbeba,0x4937,{0x83,0x19,0xb5,0xdb,0xef,0x9c,0xcc,0x36}},{1,0}},
|
||||||
|
(RPC_DISPATCH_TABLE*)&KMSServer_NDR64__v1_0_DispatchTable,
|
||||||
|
0 ,
|
||||||
|
(unsigned short *) KMSServer_Ndr64ProcTable,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static const SERVER_ROUTINE KMSServer_ServerRoutineTable[] =
|
||||||
|
{
|
||||||
|
(SERVER_ROUTINE)ProcessActivationRequest
|
||||||
|
};
|
||||||
|
|
||||||
|
/*static*/ const MIDL_SERVER_INFO KMSServer_ServerInfo =
|
||||||
|
{
|
||||||
|
&KMSServer_StubDesc,
|
||||||
|
KMSServer_ServerRoutineTable,
|
||||||
|
KMSServer__MIDL_ProcFormatString.Format,
|
||||||
|
(unsigned short *) KMSServer_FormatStringOffsetTable,
|
||||||
|
0,
|
||||||
|
(RPC_SYNTAX_IDENTIFIER*)&_NDR64_RpcTransferSyntax,
|
||||||
|
2,
|
||||||
|
(MIDL_SYNTAX_INFO*)KMSServer_SyntaxInfo
|
||||||
|
};
|
||||||
|
#if _MSC_VER >= 1200
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* defined(_M_AMD64)*/
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Let BSD make switch to GNU make
|
||||||
|
all ${.TARGETS}:
|
||||||
|
@echo "================================================================"
|
||||||
|
@echo " PLEASE USE THE GNU VERSION OF MAKE (gmake) INSTEAD OF ${MAKE} "
|
||||||
|
@echo "================================================================"
|
||||||
|
@echo ""
|
||||||
|
@gmake $@
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
To view the documentation cd to the directory containing the distribution
|
||||||
|
files and type
|
||||||
|
|
||||||
|
man ./vlmcsd.8
|
||||||
|
to see documentation for vlmcsd
|
||||||
|
|
||||||
|
man ./vlmcs.1
|
||||||
|
to see documentation for vlmcs
|
||||||
|
|
||||||
|
man ./vlmcsd.7
|
||||||
|
to see general documentation for kms
|
||||||
|
|
||||||
|
If you don't have man, you may also use the .txt, .html and .pdf files
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
Compilation and pre-built binaries FAQ
|
||||||
|
======================================
|
||||||
|
|
||||||
|
What is the best pre-built binary for my system or device?
|
||||||
|
----------------------------------------------------------
|
||||||
|
|
||||||
|
None. The best binary is compiled by yourself using a toolchain that is
|
||||||
|
optimized for your system or device in every respect.
|
||||||
|
|
||||||
|
|
||||||
|
How do I compile my own binary?
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
On a full blown desktop system this is relativly easy. If not already done so,
|
||||||
|
install a C compiler (e.g. gcc or clang) through your packet manager, e.g.
|
||||||
|
"sudo apt-get install gcc" (Debian/Ubuntu) or "sudo yum install gcc"
|
||||||
|
(RedHat/Fedora).
|
||||||
|
|
||||||
|
Then cd to your vlmcsd directory and type "make". vlmcs and vlmcsd will
|
||||||
|
be built right away for your local system.
|
||||||
|
|
||||||
|
If you installed gcc and it is not the default compiler for your OS or
|
||||||
|
distribution, you may need to type "make CC=gcc" to explicitly select a
|
||||||
|
specific C compiller.
|
||||||
|
|
||||||
|
|
||||||
|
How do I compile a binary for my embedded device?
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
What you need is cross-compiling toolchain for your device. It consists of a
|
||||||
|
C compiler, libraries, header files and some tools (called binutils). The
|
||||||
|
toolchain must match the device in processor architecture, endianess, ABI,
|
||||||
|
library and header files version, library configuration, ...
|
||||||
|
|
||||||
|
If the endianess or ABI differs or the version of some library between
|
||||||
|
toolchain and device differs too much, the resulting binary does not run
|
||||||
|
on your device.
|
||||||
|
|
||||||
|
Once you have a proper toolchain (probably found on the Internet for download),
|
||||||
|
unpack it to any directory and type
|
||||||
|
|
||||||
|
"make CC=/path/to/toolchain/bindir/c-compiler-binary"
|
||||||
|
|
||||||
|
Building vlmcsd for using a cross-compiling toolchain is as easy as building
|
||||||
|
vlmcsd for your local machine. The only question is, whether this you have
|
||||||
|
a toolchain that actually matches your device.
|
||||||
|
|
||||||
|
Whenever you change any parameter of the make command line, you must "clean"
|
||||||
|
the source directory from intermediate files and output from previous runs
|
||||||
|
of make. You can do so by typeing "make clean" or force make to behave as if
|
||||||
|
the directory were clean by adding -B to the command line, e.g.
|
||||||
|
|
||||||
|
"make -B CC=/path/to/toolchain/bindir/c-compiler-binary"
|
||||||
|
|
||||||
|
|
||||||
|
I have downloaded several promising toolchains for my device but they all
|
||||||
|
don't work. Can I create my own toolchain?
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
You can use tools like buildroot or OpenWRT. Both are able to create toolchains
|
||||||
|
for many embedded devices. But this is out of the scope of this document.
|
||||||
|
If you are unable to walk through thousands of configuration options and make
|
||||||
|
the right choice, you may probably want to try the pre-built binaries.
|
||||||
|
|
||||||
|
|
||||||
|
How to choose a pre-built binary?
|
||||||
|
---------------------------------
|
||||||
|
|
||||||
|
The directory structure for the binaries is
|
||||||
|
|
||||||
|
binaries
|
||||||
|
+
|
||||||
|
+--<operating system>
|
||||||
|
+
|
||||||
|
+--<cpu arch>
|
||||||
|
+
|
||||||
|
+--<endianess> (omitted if CPU or OS does not allow multi-endianess)
|
||||||
|
+
|
||||||
|
+--<C-library>
|
||||||
|
|
||||||
|
<C-library> can also be "static". That means no special library is required.
|
||||||
|
Static binaries are much bigger and need more RAM than dynamic binaries but
|
||||||
|
are more likely to run on your system. Use a static binary only, if none of
|
||||||
|
the dynmic binaries run.
|
||||||
|
|
||||||
|
Don't get confused when a binary is named after an OS or a specific device,
|
||||||
|
e.g. the name contains "openwrt", "tomato" or "Fritzbox". This does not mean
|
||||||
|
that the binary will run only on that OS or on that device. It is a hint only
|
||||||
|
where I got or built the toolchain from.
|
||||||
|
|
||||||
|
|
||||||
|
How to determine the endianess of my system?
|
||||||
|
--------------------------------------------
|
||||||
|
|
||||||
|
- All Intel CPUs (x86, x32, x64) are little-endian only
|
||||||
|
- Windows is little-endian only even if the CPU support big-endian
|
||||||
|
- big-endian ARM is extremely uncommon. You can safely assume little-endian
|
||||||
|
- little-endian PowerPC virtually does not exist since only newer POWER7
|
||||||
|
and POWER8 CPUs support it. Always assume big-endian.
|
||||||
|
- For MIPS both little-endian and big-endian are common. Most Broadcomm and
|
||||||
|
TI chips run little-endian. Most Atheros and Ikanos CPUs run big-endian.
|
||||||
|
|
||||||
|
Try typing
|
||||||
|
echo -n I | od -o | awk 'FNR==1{ print substr($2,6,1)}'
|
||||||
|
|
||||||
|
This returns 1 for little-endian systems and 0 for big-endian systems. However
|
||||||
|
some devices do not have the od command and thus this method won't work.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,225 +0,0 @@
|
|||||||
Microsoft KMS Activation
|
|
||||||
========
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
Start a Command Prompt as an `Administrator`.
|
|
||||||
|
|
||||||
### Windows
|
|
||||||
```
|
|
||||||
slmgr.vbs -ipk W269N-WFGWX-YVC9B-4J6C9-T83GX
|
|
||||||
slmgr.vbs -skms kms.srv.crsoo.com
|
|
||||||
slmgr.vbs -ato
|
|
||||||
```
|
|
||||||
|
|
||||||
### Office
|
|
||||||
```
|
|
||||||
cd C:\Program Files\Microsoft Office\Office15
|
|
||||||
cscript ospp.vbs /inpkey:YC7DK-G2NP3-2QQC3-J6H88-GVGXT
|
|
||||||
cscript ospp.vbs /sethst:kms.srv.crsoo.com
|
|
||||||
cscript ospp.vbs /act
|
|
||||||
```
|
|
||||||
|
|
||||||
## GVLKs
|
|
||||||
Authoritative source on Microsoft's [TechNet](https://technet.microsoft.com/en-us/library/jj612867) and [Windows Server Activation Guide](https://docs.microsoft.com/en-us/windows-server/get-started/kmsclientkeys).
|
|
||||||
|
|
||||||
### Windows 10
|
|
||||||
|
|
||||||
| Operating system edition | KMS Client Setup Key |
|
|
||||||
| --------------------------------- | ----------------------------- |
|
|
||||||
| Windows 10 Core | TX9XD-98N7V-6WMQ6-BX7FG-H8Q99 |
|
|
||||||
| Windows 10 Core N | 3KHY7-WNT83-DGQKR-F7HPR-844BM |
|
|
||||||
| Windows 10 Core Country Specific | PVMJN-6DFY6-9CCP6-7BKTT-D3WVR |
|
|
||||||
| Windows 10 Core Single Language | 7HNRX-D7KGG-3K4RQ-4WPJ4-YTDFH |
|
|
||||||
| Windows 10 Professional | W269N-WFGWX-YVC9B-4J6C9-T83GX |
|
|
||||||
| Windows 10 Professional N | MH37W-N47XK-V7XM9-C7227-GCQG9 |
|
|
||||||
| Windows 10 Enterprise | NPPR9-FWDCX-D2C8J-H872K-2YT43 |
|
|
||||||
| Windows 10 Enterprise N | DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4 |
|
|
||||||
| Windows 10 Education | NW6C2-QMPVW-D7KKK-3GKT6-VCFB2 |
|
|
||||||
| Windows 10 Education N | 2WH4N-8QGBV-H22JP-CT43Q-MDWWJ |
|
|
||||||
| Windows 10 Enterprise 2015 LTSB | WNMTR-4C88C-JK8YV-HQ7T2-76DF9 |
|
|
||||||
| Windows 10 Enterprise 2015 LTSB N | 2F77B-TNFGY-69QQF-B8YKP-D69TJ |
|
|
||||||
| Windows 10 Enterprise 2016 LTSB | DCPHK-NFMTC-H88MJ-PFHPY-QJ4BJ |
|
|
||||||
| Windows 10 Enterprise 2016 LTSB N | QFFDN-GRT3P-VKWWX-X7T3R-8B639 |
|
|
||||||
|
|
||||||
### Windows 8 / 8.1
|
|
||||||
|
|
||||||
| Operating system edition | KMS Client Setup Key |
|
|
||||||
| ----------------------------------------- | ----------------------------- |
|
|
||||||
| Windows 8 Professional | NG4HW-VH26C-733KW-K6F98-J8CK4 |
|
|
||||||
| Windows 8 Professional N | XCVCF-2NXM9-723PB-MHCB7-2RYQQ |
|
|
||||||
| Windows 8 Enterprise | 32JNW-9KQ84-P47T8-D8GGY-CWCK7 |
|
|
||||||
| Windows 8 Enterprise N | JMNMF-RHW7P-DMY6X-RF3DR-X2BQT |
|
|
||||||
| Windows Embedded 8 Industry Professional | RYXVT-BNQG7-VD29F-DBMRY-HT73M |
|
|
||||||
| Windows Embedded 8 Industry Enterprise | NKB3R-R2F8T-3XCDP-7Q2KW-XWYQ2 |
|
|
||||||
| Windows 8.1 Professional | GCRJD-8NW9H-F2CDX-CCM8D-9D6T9 |
|
|
||||||
| Windows 8.1 Professional N | HMCNV-VVBFX-7HMBH-CTY9B-B4FXY |
|
|
||||||
| Windows 8.1 Enterprise | MHF9N-XY6XB-WVXMC-BTDCT-MKKG7 |
|
|
||||||
| Windows 8.1 Enterprise N | TT4HM-HN7YT-62K67-RGRQJ-JFFXW |
|
|
||||||
| Windows Embedded 8.1 Industry Pro | NMMPB-38DD4-R2823-62W8D-VXKJB |
|
|
||||||
| Windows Embedded 8.1 Industry Enterprise | FNFKF-PWTVT-9RC8H-32HB2-JB34X |
|
|
||||||
|
|
||||||
### Windows 7
|
|
||||||
|
|
||||||
| Operating system edition | KMS Client Setup Key |
|
|
||||||
| ------------------------- | ----------------------------- |
|
|
||||||
| Windows 7 Professional | FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4 |
|
|
||||||
| Windows 7 Professional N | MRPKT-YTG23-K7D7T-X2JMM-QY7MG |
|
|
||||||
| Windows 7 Professional E | W82YF-2Q76Y-63HXB-FGJG9-GF7QX |
|
|
||||||
| Windows 7 Enterprise | 33PXH-7Y6KF-2VJC9-XBBR8-HVTHH |
|
|
||||||
| Windows 7 Enterprise N | YDRBP-3D83W-TY26F-D46B2-XCKRJ |
|
|
||||||
| Windows 7 Enterprise E | C29WB-22CC8-VJ326-GHFJW-H9DH4 |
|
|
||||||
|
|
||||||
### Windows Server 2022
|
|
||||||
|
|
||||||
| Operating system edition | KMS Client Setup Key |
|
|
||||||
| ----------------------------------------- | ----------------------------- |
|
|
||||||
| Windows Server 2022 Datacenter | WX4NM-KYWYW-QJJR4-XV3QB-6VM33 |
|
|
||||||
| Windows Server 2022 Standard | VDYBN-27WPP-V4HQT-9VMD4-VMK7H |
|
|
||||||
|
|
||||||
### Windows Server 2019
|
|
||||||
|
|
||||||
| Operating system edition | KMS Client Setup Key |
|
|
||||||
| ----------------------------------------- | ----------------------------- |
|
|
||||||
| Windows Server 2019 Datacenter | WMDGN-G9PQG-XVVXX-R3X43-63DFG |
|
|
||||||
| Windows Server 2019 Standard | N69G4-B89J2-4G8F4-WWYCC-J464C |
|
|
||||||
| Windows Server 2019 Essentials | WVDHN-86M7X-466P6-VHXV7-YY726 |
|
|
||||||
|
|
||||||
### Windows Server 2016
|
|
||||||
|
|
||||||
| Operating system edition | KMS Client Setup Key |
|
|
||||||
| ----------------------------------------- | ----------------------------- |
|
|
||||||
| Windows Server 2016 Datacenter | CB7KF-BWN84-R7R2Y-793K2-8XDDG |
|
|
||||||
| Windows Server 2016 Standard | WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY |
|
|
||||||
| Windows Server 2016 Essentials | JCKRF-N37P4-C2D82-9YXRT-4M63B |
|
|
||||||
|
|
||||||
### Windows Server 2012
|
|
||||||
|
|
||||||
| Operating system edition | KMS Client Setup Key |
|
|
||||||
| ----------------------------------------- | ----------------------------- |
|
|
||||||
| Windows Server 2012 | BN3D2-R7TKB-3YPBD-8DRP2-27GG4 |
|
|
||||||
| Windows Server 2012 N | 8N2M2-HWPGY-7PGT9-HGDD8-GVGGY |
|
|
||||||
| Windows Server 2012 Single Language | 2WN2H-YGCQR-KFX6K-CD6TF-84YXQ |
|
|
||||||
| Windows Server 2012 Country Specific | 4K36P-JN4VD-GDC6V-KDT89-DYFKP |
|
|
||||||
| Windows Server 2012 Server Standard | XC9B7-NBPP2-83J2H-RHMBY-92BT4 |
|
|
||||||
| Windows Server 2012 MultiPoint Standard | HM7DN-YVMH3-46JC3-XYTG7-CYQJJ |
|
|
||||||
| Windows Server 2012 MultiPoint Premium | XNH6W-2V9GX-RGJ4K-Y8X6F-QGJ2G |
|
|
||||||
| Windows Server 2012 Datacenter | 48HP8-DN98B-MYWDG-T2DCC-8W83P |
|
|
||||||
| Windows Server 2012 R2 Server Standard | D2N9P-3P6X9-2R39C-7RTCD-MDVJX |
|
|
||||||
| Windows Server 2012 R2 Datacenter | W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9 |
|
|
||||||
| Windows Server 2012 R2 Essentials | KNC87-3J2TX-XB4WP-VCPJV-M4FWM |
|
|
||||||
|
|
||||||
### Windows Server 2008
|
|
||||||
|
|
||||||
| Operating system edition | KMS Client Setup Key |
|
|
||||||
| ------------------------------------------------- | ----------------------------- |
|
|
||||||
| Windows Server 2008 Web | WYR28-R7TFJ-3X2YQ-YCY4H-M249D |
|
|
||||||
| Windows Server 2008 Standard | TM24T-X9RMF-VWXK6-X8JC9-BFGM2 |
|
|
||||||
| Windows Server 2008 Standard without Hyper-V | W7VD6-7JFBR-RX26B-YKQ3Y-6FFFJ |
|
|
||||||
| Windows Server 2008 Enterprise | YQGMW-MPWTJ-34KDK-48M3W-X4Q6V |
|
|
||||||
| Windows Server 2008 Enterprise without Hyper-V | 39BXF-X8Q23-P2WWT-38T2F-G3FPG |
|
|
||||||
| Windows Server 2008 HPC | RCTX3-KWVHP-BR6TB-RB6DM-6X7HP |
|
|
||||||
| Windows Server 2008 Datacenter | 7M67G-PC374-GR742-YH8V4-TCBY3 |
|
|
||||||
| Windows Server 2008 Datacenter without Hyper-V | 22XQ2-VRXRG-P8D42-K34TD-G3QQC |
|
|
||||||
| Windows Server 2008 for Itanium-Based Systems | 4DWFP-JF3DJ-B7DTH-78FJB-PDRHK |
|
|
||||||
| Windows Server 2008 R2 Web | 6TPJF-RBVHG-WBW2R-86QPH-6RTM4 |
|
|
||||||
| Windows Server 2008 R2 HPC edition | TT8MH-CG224-D3D7Q-498W2-9QCTX |
|
|
||||||
| Windows Server 2008 R2 Standard | YC6KT-GKW9T-YTKYR-T4X34-R7VHC |
|
|
||||||
| Windows Server 2008 R2 Enterprise | 489J6-VHDMP-X63PK-3K798-CPX3Y |
|
|
||||||
| Windows Server 2008 R2 Datacenter | 74YFP-3QFB3-KQT8W-PMXWJ-7M648 |
|
|
||||||
| Windows Server 2008 R2 for Itanium-based Systems | GT63C-RJFQ3-4GMB6-BRFB9-CB83V |
|
|
||||||
|
|
||||||
### Office LTSC 2021
|
|
||||||
|
|
||||||
| Product | GVLK |
|
|
||||||
| ---------------------------------- | ----------------------------- |
|
|
||||||
| Office LTSC Professional Plus 2021 | FXYTK-NJJ8C-GB6DW-3DYQT-6F7TH |
|
|
||||||
| Office LTSC Standard 2021 | KDX7X-BNVR8-TXXGX-4Q7Y8-78VT3 |
|
|
||||||
| Project Professional 2021 | FTNWT-C6WBT-8HMGF-K9PRX-QV9H8 |
|
|
||||||
| Project Standard 2021 | J2JDC-NJCYY-9RGQ4-YXWMH-T3D4T |
|
|
||||||
| Visio LTSC Professional 2021 | KNH8D-FGHT4-T8RK3-CTDYJ-K2HT4 |
|
|
||||||
| Visio LTSC Standard 2021 | MJVNY-BYWPY-CWV6J-2RKRT-4M8QG |
|
|
||||||
| Access LTSC 2021 | WM8YG-YNGDD-4JHDC-PG3F4-FC4T4 |
|
|
||||||
| Excel LTSC 2021 | NWG3X-87C9K-TC7YY-BC2G7-G6RVC |
|
|
||||||
| Outlook LTSC 2021 | C9FM6-3N72F-HFJXB-TM3V9-T86R9 |
|
|
||||||
| PowerPoint LTSC 2021 | TY7XF-NFRBR-KJ44C-G83KF-GX27K |
|
|
||||||
| Publisher LTSC 2021 | 2MW9D-N4BXM-9VBPG-Q7W6M-KFBGQ |
|
|
||||||
| Skype for Business LTSC 2021 | HWCXN-K3WBT-WJBKY-R8BD9-XK29P |
|
|
||||||
| Word LTSC 2021 | TN8H9-M34D3-Y64V9-TR72V-X79KV |
|
|
||||||
|
|
||||||
### Office 2019
|
|
||||||
|
|
||||||
| Product | GVLK |
|
|
||||||
| ----------------------------- | ----------------------------- |
|
|
||||||
| Office Professional Plus 2019 | NMMKJ-6RK4F-KMJVX-8D9MJ-6MWKP |
|
|
||||||
| Office Standard 2019 | 6NWWJ-YQWMR-QKGCB-6TMB3-9D9HK |
|
|
||||||
| Project Professional 2019 | B4NPR-3FKK7-T2MBV-FRQ4W-PKD2B |
|
|
||||||
| Project Standard 2019 | C4F7P-NCP8C-6CQPT-MQHV9-JXD2M |
|
|
||||||
| Visio Professional 2019 | 9BGNQ-K37YR-RQHF2-38RQ3-7VCBB |
|
|
||||||
| Visio Standard 2019 | 7TQNQ-K3YQQ-3PFH7-CCPPM-X4VQ2 |
|
|
||||||
| Access 2019 | 9N9PT-27V4Y-VJ2PD-YXFMF-YTFQT |
|
|
||||||
| Excel 2019 | TMJWT-YYNMB-3BKTF-644FC-RVXBD |
|
|
||||||
| Outlook 2019 | 7HD7K-N4PVK-BHBCQ-YWQRW-XW4VK |
|
|
||||||
| PowerPoint 2019 | RRNCX-C64HY-W2MM7-MCH9G-TJHMQ |
|
|
||||||
| Publisher 2019 | G2KWX-3NW6P-PY93R-JXK2T-C9Y9V |
|
|
||||||
| Skype for Business 2019 | NCJ33-JHBBY-HTK98-MYCV8-HMKHJ |
|
|
||||||
| Word 2019 | PBX3G-NWMT6-Q7XBW-PYJGG-WXD33 |
|
|
||||||
|
|
||||||
### Office 2016
|
|
||||||
|
|
||||||
| Product | GVLK |
|
|
||||||
| ----------------------------- | ----------------------------- |
|
|
||||||
| Office Professional Plus 2016 | XQNVK-8JYDB-WJ9W3-YJ8YR-WFG99 |
|
|
||||||
| Office Standard 2016 | JNRGM-WHDWX-FJJG3-K47QV-DRTFM |
|
|
||||||
| Project Professional 2016 | YG9NW-3K39V-2T3HJ-93F3Q-G83KT |
|
|
||||||
| Project Standard 2016 | GNFHQ-F6YQM-KQDGJ-327XX-KQBVC |
|
|
||||||
| Visio Professional 2016 | PD3PC-RHNGV-FXJ29-8JK7D-RJRJK |
|
|
||||||
| Visio Standard 2016 | 7WHWN-4T7MP-G96JF-G33KR-W8GF4 |
|
|
||||||
| Access 2016 | GNH9Y-D2J4T-FJHGG-QRVH7-QPFDW |
|
|
||||||
| Excel 2016 | 9C2PK-NWTVB-JMPW8-BFT28-7FTBF |
|
|
||||||
| OneNote 2016 | DR92N-9HTF2-97XKM-XW2WJ-XW3J6 |
|
|
||||||
| Outlook 2016 | R69KK-NTPKF-7M3Q4-QYBHW-6MT9B |
|
|
||||||
| PowerPoint 2016 | J7MQP-HNJ4Y-WJ7YM-PFYGF-BY6C6 |
|
|
||||||
| Publisher 2016 | F47MM-N3XJP-TQXJ9-BP99D-8K837 |
|
|
||||||
| Skype for Business 2016 | 869NQ-FJ69K-466HW-QYCP2-DDBV6 |
|
|
||||||
| Word 2016 | WXY84-JN2Q9-RBCCQ-3Q3J3-3PFJ6 |
|
|
||||||
|
|
||||||
### Office 2013
|
|
||||||
|
|
||||||
| Product | GVLK |
|
|
||||||
| ----------------------------- | ----------------------------- |
|
|
||||||
| Office 2013 Professional Plus | YC7DK-G2NP3-2QQC3-J6H88-GVGXT |
|
|
||||||
| Office 2013 Standard | KBKQT-2NMXY-JJWGP-M62JB-92CD4 |
|
|
||||||
| Project 2013 Professional | FN8TT-7WMH6-2D4X9-M337T-2342K |
|
|
||||||
| Project 2013 Standard | 6NTH3-CW976-3G3Y2-JK3TX-8QHTT |
|
|
||||||
| Visio 2013 Professional | C2FG9-N6J68-H8BTJ-BW3QX-RM3B3 |
|
|
||||||
| Visio 2013 Standard | J484Y-4NKBF-W2HMG-DBMJC-PGWR7 |
|
|
||||||
| Access 2013 | NG2JY-H4JBT-HQXYP-78QH9-4JM2D |
|
|
||||||
| Excel 2013 | VGPNG-Y7HQW-9RHP7-TKPV3-BG7GB |
|
|
||||||
| InfoPath 2013 | DKT8B-N7VXH-D963P-Q4PHY-F8894 |
|
|
||||||
| Lync 2013 | 2MG3G-3BNTT-3MFW9-KDQW3-TCK7R |
|
|
||||||
| OneNote 2013 | TGN6P-8MMBC-37P2F-XHXXK-P34VW |
|
|
||||||
| Outlook 2013 | QPN8Q-BJBTJ-334K3-93TGY-2PMBT |
|
|
||||||
| PowerPoint 2013 | 4NT99-8RJFH-Q2VDH-KYG2C-4RD4F |
|
|
||||||
| Publisher 2013 | PN2WF-29XG2-T9HJ7-JQPJR-FCXK4 |
|
|
||||||
| Word 2013 | 6Q7VD-NX8JD-WJ2VH-88V73-4GBJ7 |
|
|
||||||
|
|
||||||
### Office 2010
|
|
||||||
|
|
||||||
| Product | GVLK |
|
|
||||||
| ----------------------------- | ----------------------------- |
|
|
||||||
| Office Professional Plus 2010 | VYBBJ-TRJPB-QFQRF-QFT4D-H3GVB |
|
|
||||||
| Office Standard 2010 | V7QKV-4XVVR-XYV4D-F7DFM-8R6BM |
|
|
||||||
| Access 2010 | V7Y44-9T38C-R2VJK-666HK-T7DDX |
|
|
||||||
| Excel 2010 | H62QG-HXVKF-PP4HP-66KMR-CW9BM |
|
|
||||||
| SharePoint Workspace 2010 | QYYW6-QP4CB-MBV6G-HYMCJ-4T3J4 |
|
|
||||||
| InfoPath 2010 | K96W8-67RPQ-62T9Y-J8FQJ-BT37T |
|
|
||||||
| OneNote 2010 | Q4Y4M-RHWJM-PY37F-MTKWH-D3XHX |
|
|
||||||
| Outlook 2010 | 7YDC2-CWM8M-RRTJC-8MDVC-X3DWQ |
|
|
||||||
| PowerPoint 2010 | RC8FX-88JRY-3PF7C-X8P67-P4VTT |
|
|
||||||
| Project Professional 2010 | YGX6F-PGV49-PGW3J-9BTGG-VHKC6 |
|
|
||||||
| Project Standard 2010 | 4HP3K-88W3F-W2K3D-6677X-F9PGB |
|
|
||||||
| Publisher 2010 | BFK7F-9MYHM-V68C7-DRQ66-83YTP |
|
|
||||||
| Word 2010 | HVHB3-C6FV7-KQX9W-YQG79-CRY7T |
|
|
||||||
| Visio Standard 2010 | 767HD-QGMWX-8QTDB-9G3R2-KHFGJ |
|
|
||||||
| Visio Professional 2010 | 7MCW8-VRQVK-G677T-PDJCM-Q8TCP |
|
|
||||||
| Visio Premium 2010 | D9DWC-HPYVV-JGF4P-BTWQB-WX8BJ |
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
IMPORTANT
|
||||||
|
=========
|
||||||
|
|
||||||
|
1. Do not use any of the OpenSSL binaries
|
||||||
|
2. Do not compile OpenSSL binaries yourself
|
||||||
|
|
||||||
|
(except for doing some research into the deep internals of OpenSSL)
|
||||||
|
|
||||||
|
REASONS
|
||||||
|
=======
|
||||||
|
|
||||||
|
All OpenSSL binaries included are highly experimental and are likely to fail
|
||||||
|
in many cases. To get some real benefit from OpenSSL (or PolarSSL) it should
|
||||||
|
handle all crypting/hashing.
|
||||||
|
|
||||||
|
However this is not possible because Microsoft has slightly altered AES
|
||||||
|
encryption in KMSv6 and uses a non-AES variant of the Rijndael CMAC in
|
||||||
|
KMSv4. OpenSSL is not able to handle this if you use it correctly.
|
||||||
|
|
||||||
|
This means OpenSSL can be used safely only for SHA256 and HMAC SHA256
|
||||||
|
calculations used in KMSv5 and KMSv6 but the code size benefit is only
|
||||||
|
100 to 300 bytes (depending on the architecture).
|
||||||
|
|
||||||
|
To benefit more from OpenSSL (getting it performing the AES stuff) I do
|
||||||
|
the first phase of AES encryption/decryption (called key expansion) with my
|
||||||
|
own code. I then poke the expanded key into internal OpenSSL structs to make
|
||||||
|
it behave in a way not intended by the OpenSSL developers but in a way to
|
||||||
|
perform non-standard AES crypting as required by KMSv4 and KMSv6. KMSv5 is
|
||||||
|
the only protocol that could use OpenSSL without hacking the OpenSSL internals.
|
||||||
|
|
||||||
|
That means vlmcsd still needs about 40% of the internal AES code plus some
|
||||||
|
OpenSSL hacking code to poke the expanded key into OpenSSL.
|
||||||
|
|
||||||
|
The entire OpenSSL hacking does not work in every case because the internal
|
||||||
|
OpenSSL structs differ depending on the OpenSSL version, OpenSSL configuration
|
||||||
|
at compile time (whether it is configured to use compiled C code or assembler
|
||||||
|
code), CPU architecture and CPU features (whether it can perform AES in
|
||||||
|
hardware).
|
||||||
|
|
||||||
|
SUMMARY
|
||||||
|
=======
|
||||||
|
|
||||||
|
If you use OpenSSL in a safe way (compile with CRYPTO=openssl), there is not
|
||||||
|
much benefit from it. The binary may become bigger or smaller and you
|
||||||
|
definitely need more RAM when you run vlmcsd or vlmcs.
|
||||||
|
|
||||||
|
If you use hacked OpenSSL (compile with CRYPTO=openssl_with_aes or
|
||||||
|
CRYPTO=openssl_with_aes_soft) you risk malfunction of vlmcs/vlmcsd even if it
|
||||||
|
performed correctly several times before.
|
||||||
|
|
||||||
|
Both vlmcs and vlmcsd do not have more features when compiled with OpenSSL
|
||||||
|
support. It may be faster (especially on CPUs with hardware assisted AES) but
|
||||||
|
uses more memory and may fail or perform unreliably.
|
||||||
|
|
||||||
|
|
||||||
+2693
File diff suppressed because it is too large
Load Diff
+1458
File diff suppressed because it is too large
Load Diff
+1457
File diff suppressed because it is too large
Load Diff
+1485
File diff suppressed because it is too large
Load Diff
+1630
File diff suppressed because it is too large
Load Diff
+1474
File diff suppressed because it is too large
Load Diff
+1485
File diff suppressed because it is too large
Load Diff
+2752
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+1496
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+1521
File diff suppressed because it is too large
Load Diff
+1505
File diff suppressed because it is too large
Load Diff
+2081
File diff suppressed because it is too large
Load Diff
+2080
File diff suppressed because it is too large
Load Diff
+2110
File diff suppressed because it is too large
Load Diff
+2109
File diff suppressed because it is too large
Load Diff
+2110
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+1407
File diff suppressed because it is too large
Load Diff
+1407
File diff suppressed because it is too large
Load Diff
+1407
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+2004
File diff suppressed because it is too large
Load Diff
+2003
File diff suppressed because it is too large
Load Diff
+2003
File diff suppressed because it is too large
Load Diff
+1411
File diff suppressed because it is too large
Load Diff
+1411
File diff suppressed because it is too large
Load Diff
+1411
File diff suppressed because it is too large
Load Diff
+1421
File diff suppressed because it is too large
Load Diff
+1421
File diff suppressed because it is too large
Load Diff
+2010
File diff suppressed because it is too large
Load Diff
+2010
File diff suppressed because it is too large
Load Diff
+2010
File diff suppressed because it is too large
Load Diff
+2038
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,633 @@
|
|||||||
|
#ifndef CONFIG_H_
|
||||||
|
#define CONFIG_H_
|
||||||
|
|
||||||
|
/* Don't change anything ABOVE this line */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* As a best practice do not change the original config.h as distributed with vlmcsd.
|
||||||
|
* Instead make a copy, e.g. myconfig.h, customize it and type 'make CONFIG=myconfig.h'
|
||||||
|
* to build vlmcsd. This prevents your copy being overwritten when you upgrade to a
|
||||||
|
* new version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ----------------------------------------------------------------------------------------
|
||||||
|
* Useful customizations. These options are mandatory. You cannot comment them out.
|
||||||
|
* Feel free to change them to fit your needs.
|
||||||
|
* ----------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VERSION
|
||||||
|
/*
|
||||||
|
* Define your own version identifier here, e.g. '#define VERSION "my vlmcsd based on svn560"'
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define VERSION "private build"
|
||||||
|
|
||||||
|
#endif // VERSION
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define default ePIDs and HWID here. Preferrably grab ePIDs and HWID
|
||||||
|
* from a real KMS server.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EPID_WINDOWS
|
||||||
|
#define EPID_WINDOWS "03612-00206-471-494932-03-1033-14393.0000-2382016"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EPID_OFFICE2010
|
||||||
|
#define EPID_OFFICE2010 "03612-00096-199-954738-03-1033-14393.0000-2382016"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EPID_OFFICE2013
|
||||||
|
#define EPID_OFFICE2013 "03612-00206-437-938274-03-1033-14393.0000-2382016"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HWID // HwId from the Ratiborus VM
|
||||||
|
#define HWID 0x36, 0x4F, 0x46, 0x3A, 0x88, 0x63, 0xD3, 0x5F
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Anything below this line is optional. If you want to use any of these options
|
||||||
|
* uncomment one or more lines starting with "//#define"
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* -------------------------------
|
||||||
|
* Defaults
|
||||||
|
* -------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INI_FILE
|
||||||
|
/*
|
||||||
|
* Uncomment and customize the following line if you want vlmcsd to look for an ini file
|
||||||
|
* at a default location
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define INI_FILE "/etc/vlmcsd.ini"
|
||||||
|
|
||||||
|
#endif // INI_FILE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ----------------------------------------------------------------------------------------
|
||||||
|
* Troubleshooting options. Please note that disabling features may also help troubleshooting.
|
||||||
|
* If you have an old OS that does not support features like pthreads, shared memory or
|
||||||
|
* semaphores, uncomment "#define NO_LIMIT" and "#define NO_SIGHUP" and leave "#define USE_THREADS"
|
||||||
|
* commented out.
|
||||||
|
* ----------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef CHILD_HANDLER
|
||||||
|
/*
|
||||||
|
* Uncomment the following #define if you are compiling for a platform that does
|
||||||
|
* not correctly handle the SA_NOCLDWAIT flag when ignoring SIGCHLD, i.e. forked
|
||||||
|
* processes remain as "zombies" after dying. This option will add a SIGCHLD handler that
|
||||||
|
* "waits" for a child that has terminated. This is only required for a few
|
||||||
|
* unixoid OSses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define CHILD_HANDLER
|
||||||
|
|
||||||
|
#endif // CHILD_HANDLER
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_TIMEOUT
|
||||||
|
/*
|
||||||
|
* Uncomment the following #define if you are compiling for a platform that does
|
||||||
|
* not support custom socket send or receive timeouts.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_TIMEOUT
|
||||||
|
|
||||||
|
#endif // NO_TIMEOUT
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_DNS
|
||||||
|
/*
|
||||||
|
* Uncomment the following #define if you have trouble with accessing routines
|
||||||
|
* from libresolv. If enabled, vlmcs will be compiled without support for
|
||||||
|
* detecting KMS servers via DNS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_DNS
|
||||||
|
|
||||||
|
#endif // NO_DNS
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef TERMINAL_FIXED_WIDTH
|
||||||
|
/*
|
||||||
|
* Uncomment the following #define and optionally change its value if you are compiling for
|
||||||
|
* a platform that cannot properly determine the width of a terminal/command prompt.
|
||||||
|
* This affects the output of "vlmcsd -x" only. It should be rarely necessary to use this.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define TERMINAL_FIXED_WIDTH 80
|
||||||
|
|
||||||
|
#endif // TERMINAL_FIXED_WIDTH
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _PEDANTIC
|
||||||
|
/*
|
||||||
|
* Uncomment the following #define if you want to do vlmcs and vlmcsd more checks on the data
|
||||||
|
* it receives over the network. They are normally not necessary but may provide useful if
|
||||||
|
* you are testing any KMS server or client emulator that may send malformed KMS packets.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define _PEDANTIC
|
||||||
|
|
||||||
|
#endif // _PEDANTIC
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_PROCFS
|
||||||
|
/*
|
||||||
|
* Cygwin, Linux, Android, NetBSD, DragonflyBSD:
|
||||||
|
* Do not rely on a properly mounted proc filesystem and use the less reliable
|
||||||
|
* argv[0] to determine the program's executable name when restarting vlmcsd
|
||||||
|
* by sending a SIGHUP signal. Use only if absolutely necessary (very old versions
|
||||||
|
* of these OSses).
|
||||||
|
*
|
||||||
|
* FreeBSD:
|
||||||
|
* Do not use sysctl and but the less reliable
|
||||||
|
* argv[0] to determine the program's executable name when restarting vlmcsd
|
||||||
|
* by sending a SIGHUP signal. Use only if absolutely necessary (very old FreeBSD).
|
||||||
|
*
|
||||||
|
* OpenBSD:
|
||||||
|
* This option has no effect since OpenBSD always must use the less reliable argv[0].
|
||||||
|
*
|
||||||
|
* Mac OS X, Solaris:
|
||||||
|
* This option is not neccessary (and has no effect) since these OSses provide
|
||||||
|
* a reliable way to determine the executable name.
|
||||||
|
*
|
||||||
|
* Windows:
|
||||||
|
* This option is not used because Windows doesn't support signals.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_PROCFS
|
||||||
|
|
||||||
|
#endif // NO_PROCFS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef USE_AUXV
|
||||||
|
/*
|
||||||
|
* Linux only:
|
||||||
|
* Use the process' ELF aux vector to determine the executable name when restarting
|
||||||
|
* vlmcsd by sending a SIGHUP signal. This is actually the best method but is supported
|
||||||
|
* only with
|
||||||
|
* * the musl library
|
||||||
|
* * the glbic library 2.16 or newer
|
||||||
|
*
|
||||||
|
* It does NOT work with uclibc (most routers and other small devices) and glibc < 2.16.
|
||||||
|
* Use it only if your system supports it and you do not plan to use the binary on older systems.
|
||||||
|
* It won't work on debian 7 or Red Hat 6.x.
|
||||||
|
*
|
||||||
|
* It it safe to try this by yourself. vlmcsd won't compile if your system doesn't support it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define USE_AUXV
|
||||||
|
|
||||||
|
#endif // USE_AUXV
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _OPENSSL_NO_HMAC
|
||||||
|
/*
|
||||||
|
* If you configured vlmcsd to use OpenSSL (which you shouldn't) you may use this option
|
||||||
|
* to calculate the KMSv6 HMAC with internal code instead of using OpenSSL.
|
||||||
|
*
|
||||||
|
* This may be necessary for some embedded devices that have OpenSSL without HMAC support.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define _OPENSSL_NO_HMAC
|
||||||
|
|
||||||
|
#endif // _OPENSSL_NO_HMAC
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ----------------------------------------------------------------------------------------
|
||||||
|
* Modes of operation
|
||||||
|
* ----------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef USE_THREADS
|
||||||
|
/*
|
||||||
|
* Do not use fork() but threads to serve your clients.
|
||||||
|
*
|
||||||
|
* Unix-like operarting systems:
|
||||||
|
* You may use this or not. Entirely your choice. Threads do not require explicitly allocating
|
||||||
|
* a shared memory segment which might be a problem on some systems. Using fork() is more robust
|
||||||
|
* although the threaded version of vlmcsd is rock solid too.
|
||||||
|
*
|
||||||
|
* Some older unixoid OSses may not have pthreads. Do NOT use USE_THREADS and define NO_SIGHUP
|
||||||
|
* and NO_LIMIT instead to disable use of the pthreads, shared memory and semaphores.
|
||||||
|
*
|
||||||
|
* Cygwin:
|
||||||
|
* It is recommended to use threads since fork() is extremely slow (no copy on write) and somewhat
|
||||||
|
* unstable.
|
||||||
|
*
|
||||||
|
* Windows:
|
||||||
|
* This option has no effect since fork() is not supported.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define USE_THREADS
|
||||||
|
|
||||||
|
#endif // USE_THREADS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _CRYPTO_POLARSSL
|
||||||
|
/*
|
||||||
|
* Not available on native Windows. Can be used with Cygwin.
|
||||||
|
*
|
||||||
|
* Use PolarSSL for crypto routines if possible and if it is safe. There is not much benefit by using this
|
||||||
|
* options since it can be used for SHA256 and HMAC_SHA256 only. It cannot be used for AES calculations because
|
||||||
|
* KMSv6 uses a modified algorithm that PolarSSL does not support. KMSv4 CMAC is also unsupported since it uses
|
||||||
|
* a Rijndael keysize (160 bits) that is not part of the AES standard.
|
||||||
|
*
|
||||||
|
* It is strongly recommended not to use an external crypto library.
|
||||||
|
*
|
||||||
|
* Do not define both _CRYPTO_OPENSSL and _CRYPTO_POLARSSL
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define _CRYPTO_POLARSSL
|
||||||
|
|
||||||
|
#endif // _CRYPTO_POLARSSL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _CRYPTO_OPENSSL
|
||||||
|
/*
|
||||||
|
* Not available on native Windows. Can be used with Cygwin.
|
||||||
|
*
|
||||||
|
* Use OpenSSL for crypto routines if possible and if it is safe. There is not much benefit by using this
|
||||||
|
* options since it can be used for SHA256 and HMAC_SHA256 only. It cannot be used for AES calculations because
|
||||||
|
* KMSv6 uses a modified algorithm that OpenSSL does not support. KMSv4 CMAC is also unsupported since it uses
|
||||||
|
* a Rijndael keysize (160 bits) that is not part of the AES standard.
|
||||||
|
*
|
||||||
|
* It is strongly recommended not to use an external crypto library.
|
||||||
|
*
|
||||||
|
* Do not define both _CRYPTO_OPENSSL and _CRYPTO_POLARSSL
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define _CRYPTO_OPENSSL
|
||||||
|
|
||||||
|
#endif // _CRYPTO_OPENSSL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _USE_AES_FROM_OPENSSL
|
||||||
|
/*
|
||||||
|
* DANGEROUS: Tweak OpenSSL to perform KMSv4 CMAC and KMSv6 modified AES. This option creates the expanded
|
||||||
|
* AES key by itself and then applies modifications to it. OpenSSL will then perfom modified AES operations.
|
||||||
|
*
|
||||||
|
* This options tampers with internal structures of OpenSSL that are subject to change or may have a platform
|
||||||
|
* specific implementation. In this case your resulting binary can only perform KMSv5 operations.
|
||||||
|
*
|
||||||
|
* This option has no effect if _CRYPTO_OPENSSL is not defined.
|
||||||
|
*
|
||||||
|
* Don't use this except for your own research on the internals of OpenSSL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define _USE_AES_FROM_OPENSSL
|
||||||
|
|
||||||
|
#endif // _USE_AES_FROM_OPENSSL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _OPENSSL_SOFTWARE
|
||||||
|
/*
|
||||||
|
* Use this only if you have defined _CRYPTO_OPENSSL and _USE_AES_FROM_OPENSSL. It has no effect otherwise.
|
||||||
|
*
|
||||||
|
* This options assumes a different internal AES expanded key in OpenSSL which is used mostly if OpenSSL is
|
||||||
|
* compiled without support for hardware accelerated AES. It's worth a try if _USE_AES_FROM_OPENSSL doesn't work.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define _OPENSSL_SOFTWARE
|
||||||
|
|
||||||
|
#endif // _OPENSSL_SOFTWARE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ------------------------------------------------------------------------------------------
|
||||||
|
* Extra features not compiled by default because they are rarely needed
|
||||||
|
* ------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INCLUDE_BETAS
|
||||||
|
/*
|
||||||
|
* Uncomment the following #define if you want obsolete beta/preview SKUs
|
||||||
|
* to be included in the extended product list.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define INCLUDE_BETAS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ----------------------------------------------------------------------------------------
|
||||||
|
* Removal of features. Allows you to remove features of vlmcsd you do not need or want.
|
||||||
|
* Use it to get smaller binaries. This is especially useful on very small embedded devices.
|
||||||
|
* ----------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_FREEBIND
|
||||||
|
/*
|
||||||
|
* Do not compile support for FREEBIND (Linux) and IP_BINDANY (FreeBSD). This disables the -F1 command
|
||||||
|
* line option and you can bind only to (listen on) IP addresses that are currently up and running on
|
||||||
|
* your system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_FREEBIND
|
||||||
|
|
||||||
|
#endif // NO_FREEBIND
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_EXTENDED_PRODUCT_LIST
|
||||||
|
/*
|
||||||
|
* Do not compile the extended product list. Removes the list of Activation GUIDs (aka
|
||||||
|
* Client SKU Id, License Id) and their respective product names (e.g. Windows 8.1 Enterprise).
|
||||||
|
*
|
||||||
|
* This affects logging only and does not have an effect on activation itself. As long as you
|
||||||
|
* do not also define NO_BASIC_PRODUCT_LIST more generic names like Windows 8.1 or Office 2013
|
||||||
|
* will still be logged. Saves a lot of space without loosing much functionality.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_EXTENDED_PRODUCT_LIST
|
||||||
|
|
||||||
|
#endif // NO_EXTENDED_PRODUCT_LIST
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_BASIC_PRODUCT_LIST
|
||||||
|
/*
|
||||||
|
* Do not compile the basic product list. Removes the list KMS GUIDs (aka Server SKU Id) and their
|
||||||
|
* respective product names. Only affects logging not activation. This has a negative impact only
|
||||||
|
* if you activate a product that is not (yet) in the extended product list. On the other hand you
|
||||||
|
* do not save much space by not compiling this list.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_BASIC_PRODUCT_LIST
|
||||||
|
|
||||||
|
#endif // NO_BASIC_PRODUCT_LIST
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_VERSION_INFORMATION
|
||||||
|
/*
|
||||||
|
* Removes the -V option from vlmcsd and vlmcs that displays the version information
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_VERSION_INFORMATION
|
||||||
|
|
||||||
|
#endif // NO_VERSION_INFORMATION
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_VERBOSE_LOG
|
||||||
|
/*
|
||||||
|
* Removes the ability to do verbose logging and disables -v and -q in vlmcsd. It does not remove the -v
|
||||||
|
* option in the vlmcs client. Disables ini file directive LogVerbose.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_VERBOSE_LOG
|
||||||
|
|
||||||
|
#endif // NO_VERBOSE_LOG
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_LOG
|
||||||
|
/*
|
||||||
|
* Disables logging completely. You can neither log to a file nor to the console. -D and -f will
|
||||||
|
* start vlmcsd in foreground. -e will not be available. Disables ini file directive LogFile.
|
||||||
|
* Implies NO_VERBOSE_LOG, NO_EXTENDED_PRODUCT_LIST and NO_BASIC_PRODUCT_LIST.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_LOG
|
||||||
|
|
||||||
|
#endif // NO_LOG
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_RANDOM_EPID
|
||||||
|
/*
|
||||||
|
* Disables the ability to generate random ePIDs. Useful if you managed to grab ePID/HWID from a
|
||||||
|
* real KMS server and want to use these. Removes -r from the vlmcsd command line and the ini
|
||||||
|
* file directive RandomizationLevel (The randomization level will be harcoded to 0).
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_RANDOM_EPID
|
||||||
|
|
||||||
|
#endif // NO_RANDOM_EPID
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_INI_FILE
|
||||||
|
/*
|
||||||
|
* Disables the ability to use a configuration file (aka ini file). Removes -i from the command line.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_INI_FILE
|
||||||
|
|
||||||
|
#endif // NO_INI_FILE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_PID_FILE
|
||||||
|
/*
|
||||||
|
* Disables the abilty to write a pid file containing the process id of vlmcsd. If your init system
|
||||||
|
* does not need this feature, you can safely disables this but it won't save much space. Disables
|
||||||
|
* the use of -p from the command line and PidFile from the ini file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_PID_FILE
|
||||||
|
|
||||||
|
#endif // NO_PID_FILE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_USER_SWITCH
|
||||||
|
/*
|
||||||
|
* Disables switching to another uid and/or gid after starting the program and setting up the sockets.
|
||||||
|
* You cannot use -u anf -g on the command line as well as User and Group in the ini file. If your init system
|
||||||
|
* supports starting daemons as another uid/gid (user/group) you can disable this feature in vlmcsd as long as you
|
||||||
|
* do not need to run vlmcsd on a privileged port ( < 1024 on most systems).
|
||||||
|
*
|
||||||
|
* This setting has no effect on native Windows since -u and -g is not available anyway. It may be used with
|
||||||
|
* Cygwin.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_USER_SWITCH
|
||||||
|
|
||||||
|
#endif // NO_USER_SWITCH
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_HELP
|
||||||
|
/*
|
||||||
|
* Disables display of help in both vlmcsd and vlmcs. Saves some bytes but only makes sense if you have
|
||||||
|
* access to the man files vlmcsd.8 and vlmcs.1
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_HELP
|
||||||
|
|
||||||
|
#endif // NO_HELP
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_CUSTOM_INTERVALS
|
||||||
|
/*
|
||||||
|
* Disables the ability to specify custom interval for renewing and retrying activation. Newer versions of the Microsoft's
|
||||||
|
* KMS activation client (as in Win 8.1) do not honor these parameters anyway. Disable them to save some bytes. Removes
|
||||||
|
* -A and -R from the command line as well as ActivationInterval and RenewalInterval in the ini file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_CUSTOM_INTERVALS
|
||||||
|
|
||||||
|
#endif // NO_CUSTOM_INTERVALS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_PRIVATE_IP_DETECT
|
||||||
|
/*
|
||||||
|
* Disables the ability to protect vlmcsd against KMS requests from public IP addresses.
|
||||||
|
* Removes -o from the command line.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_PRIVATE_IP_DETECT
|
||||||
|
|
||||||
|
#endif // NO_PRIVATE_IP_DETECT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_SOCKETS
|
||||||
|
/*
|
||||||
|
* Disables standalone startup of vlmcsd. If you use this config directive, you must start vlmcsd from an internet
|
||||||
|
* superserver like inetd, xinetd, systemd or launchd. Disables -m, -t, -4, -6, -e, -f, -P and -L in the vlmcsd
|
||||||
|
* command line. Socket setup is the job of your superserver.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_SOCKETS
|
||||||
|
|
||||||
|
#endif // NO_SOCKETS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_CL_PIDS
|
||||||
|
/*
|
||||||
|
* Disables the ability to specify ePIDs and HWID at the command line. You still may use them in the ini file.
|
||||||
|
* Removes -0, -3, -w and -H from the vlmcsd command line.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_CL_PIDS
|
||||||
|
|
||||||
|
#endif // NO_CL_PIDS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_LIMIT
|
||||||
|
/*
|
||||||
|
* Disables the ability to limit the number of worker threads or processes that vlmcsd uses. While you should set a
|
||||||
|
* limit whenever possible, you may save some bytes by enabling that setting. If you do not use a limit, use vlmcsd
|
||||||
|
* in a "friendly" environment only, i.e. do not run it without a reasonable limit on the internet.
|
||||||
|
*
|
||||||
|
* Removes the ability to use -m in the vlmcsd command line and MaxWorkers in the ini file.
|
||||||
|
*
|
||||||
|
* Some older unixoid OSses may not have pthreads. Do NOT use USE_THREADS and define NO_SIGHUP
|
||||||
|
* and NO_LIMIT instead to disable use of the pthreads, shared memory and semaphores.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_LIMIT
|
||||||
|
|
||||||
|
#endif // NO_LIMIT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_SIGHUP
|
||||||
|
/*
|
||||||
|
* Disables the ability to signal hangup (SIGHUP) to vlmcsd to restart it (rereading the ini file). The SIGHUP
|
||||||
|
* handler makes heavy use of OS specific code. It should not cause any trouble on Solaris, Mac OS X and iOS. On Linux
|
||||||
|
* use "#define USE_AUXV" (see troubleshooting options) if this is supported by your C runtime library.
|
||||||
|
*
|
||||||
|
* You may save some bytes by enabling this option. Use it also if the SIGHUP handler causes any trouble on your
|
||||||
|
* platform. Please note that with no SIGHUP handler at all. vlmcsd will simply terminate (uncleanly) if it receives
|
||||||
|
* the SIGHUP signal. This is the same behavior as with most other signals.
|
||||||
|
*
|
||||||
|
* This option has no effect on native Windows since Posix signaling is not supported. It can be used with Cygwin.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define NO_SIGHUP
|
||||||
|
|
||||||
|
#endif // NO_SIGHUP
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SIMPLE_SOCKETS
|
||||||
|
/*
|
||||||
|
* Disables the ability to choose IP addresses using the -L option in vlmcsd. vlmcsd will listen on all IP addresses.
|
||||||
|
* It still supports IPv4 and IPv6.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define SIMPLE_SOCKETS
|
||||||
|
|
||||||
|
#endif // SIMPLE_SOCKETS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Don't change anything BELOW this line */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* CONFIG_H_ */
|
||||||
@@ -0,0 +1,328 @@
|
|||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#include "crypto.h"
|
||||||
|
#include "endian.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
const BYTE AesKeyV4[] = {
|
||||||
|
0x05, 0x3D, 0x83, 0x07, 0xF9, 0xE5, 0xF0, 0x88, 0xEB, 0x5E, 0xA6, 0x68, 0x6C, 0xF0, 0x37, 0xC7, 0xE4, 0xEF, 0xD2, 0xD6};
|
||||||
|
|
||||||
|
const BYTE AesKeyV5[] = {
|
||||||
|
0xCD, 0x7E, 0x79, 0x6F, 0x2A, 0xB2, 0x5D, 0xCB, 0x55, 0xFF, 0xC8, 0xEF, 0x83, 0x64, 0xC4, 0x70 };
|
||||||
|
|
||||||
|
const BYTE AesKeyV6[] = {
|
||||||
|
0xA9, 0x4A, 0x41, 0x95, 0xE2, 0x01, 0x43, 0x2D, 0x9B, 0xCB, 0x46, 0x04, 0x05, 0xD8, 0x4A, 0x21 };
|
||||||
|
|
||||||
|
static const BYTE SBox[] = {
|
||||||
|
0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B,
|
||||||
|
0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0,
|
||||||
|
0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26,
|
||||||
|
0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
|
||||||
|
0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2,
|
||||||
|
0xEB, 0x27, 0xB2, 0x75, 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0,
|
||||||
|
0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84, 0x53, 0xD1, 0x00, 0xED,
|
||||||
|
0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF,
|
||||||
|
0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F,
|
||||||
|
0x50, 0x3C, 0x9F, 0xA8, 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5,
|
||||||
|
0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, 0xCD, 0x0C, 0x13, 0xEC,
|
||||||
|
0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73,
|
||||||
|
0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14,
|
||||||
|
0xDE, 0x5E, 0x0B, 0xDB, 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C,
|
||||||
|
0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79, 0xE7, 0xC8, 0x37, 0x6D,
|
||||||
|
0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08,
|
||||||
|
0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F,
|
||||||
|
0x4B, 0xBD, 0x8B, 0x8A, 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E,
|
||||||
|
0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, 0xE1, 0xF8, 0x98, 0x11,
|
||||||
|
0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF,
|
||||||
|
0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F,
|
||||||
|
0xB0, 0x54, 0xBB, 0x16
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void XorBlock(const BYTE *const in, const BYTE *out) // Ensure that this is always 32 bit aligned
|
||||||
|
{
|
||||||
|
/*UAA64( out, 0 ) ^= UAA64( in, 0 );
|
||||||
|
UAA64( out, 1 ) ^= UAA64( in, 1 );*/
|
||||||
|
|
||||||
|
uint_fast8_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < AES_BLOCK_WORDS; i++)
|
||||||
|
{
|
||||||
|
((DWORD*)out)[i] ^= ((DWORD*)in)[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define AddRoundKey(d, rk) XorBlock((const BYTE *)rk, (const BYTE *)d)
|
||||||
|
|
||||||
|
#define Mul2(word) (((word & 0x7f7f7f7f) << 1) ^ (((word & 0x80808080) >> 7) * 0x1b))
|
||||||
|
#define Mul3(word) (Mul2(word) ^ word)
|
||||||
|
#define Mul4(word) (Mul2(Mul2(word)))
|
||||||
|
#define Mul8(word) (Mul2(Mul2(Mul2(word))))
|
||||||
|
#define Mul9(word) (Mul8(word) ^ word)
|
||||||
|
#define MulB(word) (Mul8(word) ^ Mul3(word))
|
||||||
|
#define MulD(word) (Mul8(word) ^ Mul4(word) ^ word)
|
||||||
|
#define MulE(word) (Mul8(word) ^ Mul4(word) ^ Mul2(word))
|
||||||
|
|
||||||
|
//32 bit Galois Multiplication (generates bigger code than Macros)
|
||||||
|
/*static DWORD Mul(DWORD x, DWORD y)
|
||||||
|
{
|
||||||
|
DWORD result = x, yTemp = y, log2;
|
||||||
|
|
||||||
|
if (!y) return 0;
|
||||||
|
|
||||||
|
for (log2 = 0; yTemp >>= 1; log2++ )
|
||||||
|
{
|
||||||
|
result = Mul2(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result ^ Mul(x, y - (1 << log2));
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
void MixColumnsR(BYTE *restrict state)
|
||||||
|
{
|
||||||
|
uint_fast8_t i = 0;
|
||||||
|
for (; i < AES_BLOCK_WORDS; i++)
|
||||||
|
{
|
||||||
|
#if defined(_CRYPTO_OPENSSL) && defined(_OPENSSL_SOFTWARE) && defined(_USE_AES_FROM_OPENSSL) //Always byte swap regardless of endianess
|
||||||
|
DWORD word = BS32(((DWORD *) state)[i]);
|
||||||
|
((DWORD *) state)[i] = BS32(MulE(word) ^ ROR32(MulB(word), 8) ^ ROR32(MulD(word), 16) ^ ROR32(Mul9(word), 24));
|
||||||
|
#else
|
||||||
|
DWORD word = LE32(((DWORD *) state)[i]);
|
||||||
|
((DWORD *) state)[i] = LE32(MulE(word) ^ ROR32(MulB(word), 8) ^ ROR32(MulD(word), 16) ^ ROR32(Mul9(word), 24));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static DWORD SubDword(DWORD v)
|
||||||
|
{
|
||||||
|
BYTE *b = (BYTE *)&v;
|
||||||
|
uint_fast8_t i = 0;
|
||||||
|
|
||||||
|
for (; i < sizeof(DWORD); i++) b[i] = SBox[b[i]];
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AesInitKey(AesCtx *Ctx, const BYTE *Key, int_fast8_t IsV6, int RijndaelKeyBytes)
|
||||||
|
{
|
||||||
|
int RijndaelKeyDwords = RijndaelKeyBytes / sizeof(DWORD);
|
||||||
|
Ctx->rounds = (uint_fast8_t)(RijndaelKeyDwords + 6);
|
||||||
|
|
||||||
|
static const DWORD RCon[] = {
|
||||||
|
0x00000000, 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000,
|
||||||
|
0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000 };
|
||||||
|
|
||||||
|
uint_fast8_t i;
|
||||||
|
DWORD temp;
|
||||||
|
|
||||||
|
memcpy(Ctx->Key, Key, RijndaelKeyBytes);
|
||||||
|
|
||||||
|
for ( i = RijndaelKeyDwords; i < ( Ctx->rounds + 1 ) << 2; i++ )
|
||||||
|
{
|
||||||
|
temp = Ctx->Key[ i - 1 ];
|
||||||
|
|
||||||
|
if ( ( i % RijndaelKeyDwords ) == 0 )
|
||||||
|
temp = BE32( SubDword( ROR32( BE32(temp), 24) ) ^ RCon[ i / RijndaelKeyDwords ] );
|
||||||
|
|
||||||
|
Ctx->Key[ i ] = Ctx->Key[ i - RijndaelKeyDwords ] ^ temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( IsV6 )
|
||||||
|
{
|
||||||
|
BYTE *_p = (BYTE *)Ctx->Key;
|
||||||
|
|
||||||
|
_p[ 4 * 16 ] ^= 0x73;
|
||||||
|
_p[ 6 * 16 ] ^= 0x09;
|
||||||
|
_p[ 8 * 16 ] ^= 0xE4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(_CRYPTO_OPENSSL) || !defined(_USE_AES_FROM_OPENSSL) || defined(_OPENSSL_SOFTWARE)
|
||||||
|
static void SubBytes(BYTE *block)
|
||||||
|
{
|
||||||
|
uint_fast8_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < AES_BLOCK_BYTES; i++)
|
||||||
|
block[i] = SBox[ block[i] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void ShiftRows(BYTE *state)
|
||||||
|
{
|
||||||
|
BYTE bIn[AES_BLOCK_BYTES];
|
||||||
|
uint_fast8_t i;
|
||||||
|
|
||||||
|
memcpy(bIn, state, AES_BLOCK_BYTES);
|
||||||
|
for (i = 0; i < AES_BLOCK_BYTES; i++)
|
||||||
|
{
|
||||||
|
state[i] = bIn[(i + ((i & 3) << 2)) & 0xf];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void MixColumns(BYTE *state)
|
||||||
|
{
|
||||||
|
uint_fast8_t i = 0;
|
||||||
|
for (; i < AES_BLOCK_WORDS; i++)
|
||||||
|
{
|
||||||
|
DWORD word = LE32(((DWORD *) state)[i]);
|
||||||
|
((DWORD *) state)[i] = LE32(Mul2(word) ^ ROR32(Mul3(word), 8) ^ ROR32(word, 16) ^ ROR32(word, 24));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AesEncryptBlock(const AesCtx *const Ctx, BYTE *block)
|
||||||
|
{
|
||||||
|
uint_fast8_t i;
|
||||||
|
|
||||||
|
for ( i = 0 ;; i += 4 )
|
||||||
|
{
|
||||||
|
AddRoundKey(block, &Ctx->Key[ i ]);
|
||||||
|
SubBytes(block);
|
||||||
|
ShiftRows(block);
|
||||||
|
|
||||||
|
if ( i >= ( Ctx->rounds - 1 ) << 2 ) break;
|
||||||
|
|
||||||
|
MixColumns(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
AddRoundKey(block, &Ctx->Key[ Ctx->rounds << 2 ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AesCmacV4(BYTE *Message, size_t MessageSize, BYTE *MacOut)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
BYTE mac[AES_BLOCK_BYTES];
|
||||||
|
AesCtx Ctx;
|
||||||
|
|
||||||
|
AesInitKey(&Ctx, AesKeyV4, FALSE, V4_KEY_BYTES);
|
||||||
|
|
||||||
|
memset(mac, 0, sizeof(mac));
|
||||||
|
memset(Message + MessageSize, 0, AES_BLOCK_BYTES);
|
||||||
|
Message[MessageSize] = 0x80;
|
||||||
|
|
||||||
|
for (i = 0; i <= MessageSize; i += AES_BLOCK_BYTES)
|
||||||
|
{
|
||||||
|
XorBlock(Message + i, mac);
|
||||||
|
AesEncryptBlock(&Ctx, mac);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(MacOut, mac, AES_BLOCK_BYTES);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_CRYPTO_OPENSSL) || !defined(_USE_AES_FROM_OPENSSL)
|
||||||
|
|
||||||
|
static const BYTE SBoxR[] = {
|
||||||
|
0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E,
|
||||||
|
0x81, 0xF3, 0xD7, 0xFB, 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87,
|
||||||
|
0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, 0x54, 0x7B, 0x94, 0x32,
|
||||||
|
0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E,
|
||||||
|
0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76, 0x5B, 0xA2, 0x49,
|
||||||
|
0x6D, 0x8B, 0xD1, 0x25, 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16,
|
||||||
|
0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92, 0x6C, 0x70, 0x48, 0x50,
|
||||||
|
0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84,
|
||||||
|
0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05,
|
||||||
|
0xB8, 0xB3, 0x45, 0x06, 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02,
|
||||||
|
0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B, 0x3A, 0x91, 0x11, 0x41,
|
||||||
|
0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73,
|
||||||
|
0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8,
|
||||||
|
0x1C, 0x75, 0xDF, 0x6E, 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89,
|
||||||
|
0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B, 0xFC, 0x56, 0x3E, 0x4B,
|
||||||
|
0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4,
|
||||||
|
0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59,
|
||||||
|
0x27, 0x80, 0xEC, 0x5F, 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D,
|
||||||
|
0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, 0xA0, 0xE0, 0x3B, 0x4D,
|
||||||
|
0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61,
|
||||||
|
0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63,
|
||||||
|
0x55, 0x21, 0x0C, 0x7D
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void ShiftRowsR(BYTE *state)
|
||||||
|
{
|
||||||
|
BYTE b[AES_BLOCK_BYTES];
|
||||||
|
uint_fast8_t i;
|
||||||
|
|
||||||
|
memcpy(b, state, AES_BLOCK_BYTES);
|
||||||
|
|
||||||
|
for (i = 0; i < AES_BLOCK_BYTES; i++)
|
||||||
|
state[i] = b[(i - ((i & 0x3) << 2)) & 0xf];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void SubBytesR(BYTE *block)
|
||||||
|
{
|
||||||
|
uint_fast8_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < AES_BLOCK_BYTES; i++)
|
||||||
|
block[i] = SBoxR[ block[i] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AesEncryptCbc(const AesCtx *const Ctx, BYTE *restrict iv, BYTE *restrict data, size_t *restrict len)
|
||||||
|
{
|
||||||
|
// Pad up to blocksize inclusive
|
||||||
|
size_t i;
|
||||||
|
uint_fast8_t pad = (~*len & (AES_BLOCK_BYTES - 1)) + 1;
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8) // gcc 4.8 memset bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56977
|
||||||
|
for (i = 0; i < pad; i++) data[*len + i] = pad;
|
||||||
|
#else
|
||||||
|
memset(data + *len, pad, pad);
|
||||||
|
#endif
|
||||||
|
*len += pad;
|
||||||
|
|
||||||
|
if ( iv ) XorBlock(iv, data);
|
||||||
|
AesEncryptBlock(Ctx, data);
|
||||||
|
|
||||||
|
for (i = *len - AES_BLOCK_BYTES; i; i -= AES_BLOCK_BYTES)
|
||||||
|
{
|
||||||
|
XorBlock(data, data + AES_BLOCK_BYTES);
|
||||||
|
data += AES_BLOCK_BYTES;
|
||||||
|
AesEncryptBlock(Ctx, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AesDecryptBlock(const AesCtx *const Ctx, BYTE *block)
|
||||||
|
{
|
||||||
|
uint_fast8_t i;
|
||||||
|
|
||||||
|
AddRoundKey(block, &Ctx->Key[ Ctx->rounds << 2 ]);
|
||||||
|
|
||||||
|
for ( i = ( Ctx->rounds - 1 ) << 2 ;; i -= 4 )
|
||||||
|
{
|
||||||
|
ShiftRowsR(block);
|
||||||
|
SubBytesR(block);
|
||||||
|
AddRoundKey(block, &Ctx->Key[ i ]);
|
||||||
|
|
||||||
|
if ( i == 0 ) break;
|
||||||
|
|
||||||
|
MixColumnsR(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AesDecryptCbc(const AesCtx *const Ctx, BYTE *iv, BYTE *data, size_t len)
|
||||||
|
{
|
||||||
|
BYTE *cc;
|
||||||
|
|
||||||
|
for (cc = data + len - AES_BLOCK_BYTES; cc > data; cc -= AES_BLOCK_BYTES)
|
||||||
|
{
|
||||||
|
AesDecryptBlock(Ctx, cc);
|
||||||
|
XorBlock(cc - AES_BLOCK_BYTES, cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
AesDecryptBlock(Ctx, cc);
|
||||||
|
if ( iv ) XorBlock(iv, cc);
|
||||||
|
}
|
||||||
|
#endif // _CRYPTO_OPENSSL || OPENSSL_VERSION_NUMBER < 0x10000000L
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
#ifndef __crypto_h
|
||||||
|
#define __crypto_h
|
||||||
|
|
||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include "endian.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
//#define AES_ROUNDS (10)
|
||||||
|
#define AES_KEY_BYTES (16) // 128 Bits
|
||||||
|
#define AES_BLOCK_BYTES (16)
|
||||||
|
#define AES_BLOCK_WORDS (AES_BLOCK_BYTES / sizeof(DWORD))
|
||||||
|
#define AES_KEY_DWORDS (AES_KEY_BYTES / sizeof(DWORD))
|
||||||
|
//#define V4_ROUNDS (11)
|
||||||
|
#define V4_KEY_BYTES (20) // 160 Bits
|
||||||
|
|
||||||
|
#define ROR32(v, n) ( (v) << (32 - n) | (v) >> n )
|
||||||
|
|
||||||
|
void XorBlock(const BYTE *const in, const BYTE *out);
|
||||||
|
|
||||||
|
void AesCmacV4(BYTE *data, size_t len, BYTE *hash);
|
||||||
|
|
||||||
|
extern const BYTE AesKeyV5[];
|
||||||
|
extern const BYTE AesKeyV6[];
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DWORD Key[48]; // Supports a maximum of 160 key bits!
|
||||||
|
uint_fast8_t rounds;
|
||||||
|
} AesCtx;
|
||||||
|
|
||||||
|
void AesInitKey(AesCtx *Ctx, const BYTE *Key, int_fast8_t IsV6, int AesKeyBytes);
|
||||||
|
void AesEncryptBlock(const AesCtx *const Ctx, BYTE *block);
|
||||||
|
void AesDecryptBlock(const AesCtx *const Ctx, BYTE *block);
|
||||||
|
void AesEncryptCbc(const AesCtx *const Ctx, BYTE *iv, BYTE *data, size_t *len);
|
||||||
|
void AesDecryptCbc(const AesCtx *const Ctx, BYTE *iv, BYTE *data, size_t len);
|
||||||
|
void MixColumnsR(BYTE *restrict state);
|
||||||
|
|
||||||
|
#if defined(_CRYPTO_OPENSSL)
|
||||||
|
#include "crypto_openssl.h"
|
||||||
|
|
||||||
|
#elif defined(_CRYPTO_POLARSSL)
|
||||||
|
#include "crypto_polarssl.h"
|
||||||
|
|
||||||
|
#elif defined(_CRYPTO_WINDOWS)
|
||||||
|
#include "crypto_windows.h"
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include "crypto_internal.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif // __crypto_h
|
||||||
@@ -0,0 +1,212 @@
|
|||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#if !defined(_CRYPTO_OPENSSL) && !defined(_CRYPTO_POLARSSL) && !defined(_CRYPTO_WINDOWS)
|
||||||
|
#include "crypto_internal.h"
|
||||||
|
#include "endian.h"
|
||||||
|
|
||||||
|
#define F0(x, y, z) ( ((x) & (y)) | (~(x) & (z)) )
|
||||||
|
#define F1(x, y, z) ( ((x) & (y)) | ((x) & (z)) | ((y) & (z)) )
|
||||||
|
|
||||||
|
#define SI1(x) ( ROR32(x, 2 ) ^ ROR32(x, 13) ^ ROR32(x, 22) )
|
||||||
|
#define SI2(x) ( ROR32(x, 6 ) ^ ROR32(x, 11) ^ ROR32(x, 25) )
|
||||||
|
#define SI3(x) ( ROR32(x, 7 ) ^ ROR32(x, 18) ^ ((x) >> 3 ) )
|
||||||
|
#define SI4(x) ( ROR32(x, 17) ^ ROR32(x, 19) ^ ((x) >> 10) )
|
||||||
|
|
||||||
|
static const DWORD k[] = {
|
||||||
|
0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1,
|
||||||
|
0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
|
||||||
|
0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786,
|
||||||
|
0x0FC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
|
||||||
|
0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147,
|
||||||
|
0x06CA6351, 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
|
||||||
|
0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B,
|
||||||
|
0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
|
||||||
|
0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A,
|
||||||
|
0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
|
||||||
|
0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void Sha256Init(Sha256Ctx *Ctx)
|
||||||
|
{
|
||||||
|
Ctx->State[0] = 0x6A09E667;
|
||||||
|
Ctx->State[1] = 0xBB67AE85;
|
||||||
|
Ctx->State[2] = 0x3C6EF372;
|
||||||
|
Ctx->State[3] = 0xA54FF53A;
|
||||||
|
Ctx->State[4] = 0x510E527F;
|
||||||
|
Ctx->State[5] = 0x9B05688C;
|
||||||
|
Ctx->State[6] = 0x1F83D9AB;
|
||||||
|
Ctx->State[7] = 0x5BE0CD19;
|
||||||
|
Ctx->Len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void Sha256ProcessBlock(Sha256Ctx *Ctx, BYTE *block)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
DWORD w[64], temp1, temp2;
|
||||||
|
DWORD a = Ctx->State[0];
|
||||||
|
DWORD b = Ctx->State[1];
|
||||||
|
DWORD c = Ctx->State[2];
|
||||||
|
DWORD d = Ctx->State[3];
|
||||||
|
DWORD e = Ctx->State[4];
|
||||||
|
DWORD f = Ctx->State[5];
|
||||||
|
DWORD g = Ctx->State[6];
|
||||||
|
DWORD h = Ctx->State[7];
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
//w[ i ] = GET_UAA32BE(block, i);
|
||||||
|
w[i] = BE32(((DWORD*)block)[i]);
|
||||||
|
|
||||||
|
for (i = 16; i < 64; i++)
|
||||||
|
w[ i ] = SI4(w[ i - 2 ]) + w[ i - 7 ] + SI3(w[ i - 15 ]) + w[ i - 16 ];
|
||||||
|
|
||||||
|
for (i = 0; i < 64; i++)
|
||||||
|
{
|
||||||
|
temp1 = h + SI2(e) + F0(e, f, g) + k[ i ] + w[ i ];
|
||||||
|
temp2 = SI1(a) + F1(a, b, c);
|
||||||
|
|
||||||
|
h = g;
|
||||||
|
g = f;
|
||||||
|
f = e;
|
||||||
|
e = d + temp1;
|
||||||
|
d = c;
|
||||||
|
c = b;
|
||||||
|
b = a;
|
||||||
|
a = temp1 + temp2;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ctx->State[0] += a;
|
||||||
|
Ctx->State[1] += b;
|
||||||
|
Ctx->State[2] += c;
|
||||||
|
Ctx->State[3] += d;
|
||||||
|
Ctx->State[4] += e;
|
||||||
|
Ctx->State[5] += f;
|
||||||
|
Ctx->State[6] += g;
|
||||||
|
Ctx->State[7] += h;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void Sha256Update(Sha256Ctx *Ctx, BYTE *data, size_t len)
|
||||||
|
{
|
||||||
|
unsigned int b_len = Ctx->Len & 63,
|
||||||
|
r_len = (b_len ^ 63) + 1;
|
||||||
|
|
||||||
|
Ctx->Len += len;
|
||||||
|
|
||||||
|
if ( len < r_len )
|
||||||
|
{
|
||||||
|
memcpy(Ctx->Buffer + b_len, data, len);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( r_len < 64 )
|
||||||
|
{
|
||||||
|
memcpy(Ctx->Buffer + b_len, data, r_len);
|
||||||
|
len -= r_len;
|
||||||
|
data += r_len;
|
||||||
|
Sha256ProcessBlock(Ctx, Ctx->Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; len >= 64; len -= 64, data += 64)
|
||||||
|
Sha256ProcessBlock(Ctx, data);
|
||||||
|
|
||||||
|
if ( len ) memcpy(Ctx->Buffer, data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void Sha256Finish(Sha256Ctx *Ctx, BYTE *hash)
|
||||||
|
{
|
||||||
|
unsigned int i, b_len = Ctx->Len & 63;
|
||||||
|
|
||||||
|
Ctx->Buffer[ b_len ] = 0x80;
|
||||||
|
if ( b_len ^ 63 ) memset(Ctx->Buffer + b_len + 1, 0, b_len ^ 63);
|
||||||
|
|
||||||
|
if ( b_len >= 56 )
|
||||||
|
{
|
||||||
|
Sha256ProcessBlock(Ctx, Ctx->Buffer);
|
||||||
|
memset(Ctx->Buffer, 0, 56);
|
||||||
|
}
|
||||||
|
|
||||||
|
//PUT_UAA64BE(Ctx->Buffer, (unsigned long long)(Ctx->Len * 8), 7);
|
||||||
|
((uint64_t*)Ctx->Buffer)[7] = BE64((uint64_t)Ctx->Len << 3);
|
||||||
|
Sha256ProcessBlock(Ctx, Ctx->Buffer);
|
||||||
|
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
//PUT_UAA32BE(hash, Ctx->State[i], i);
|
||||||
|
((DWORD*)hash)[i] = BE32(Ctx->State[i]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Sha256(BYTE *data, size_t len, BYTE *hash)
|
||||||
|
{
|
||||||
|
Sha256Ctx Ctx;
|
||||||
|
|
||||||
|
Sha256Init(&Ctx);
|
||||||
|
Sha256Update(&Ctx, data, len);
|
||||||
|
Sha256Finish(&Ctx, hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void _Sha256HmacInit(Sha256HmacCtx *Ctx, BYTE *key, size_t klen)
|
||||||
|
{
|
||||||
|
BYTE IPad[64];
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
memset(IPad, 0x36, sizeof(IPad));
|
||||||
|
memset(Ctx->OPad, 0x5C, sizeof(Ctx->OPad));
|
||||||
|
|
||||||
|
if ( klen > 64 )
|
||||||
|
{
|
||||||
|
BYTE *temp = (BYTE*)alloca(32);
|
||||||
|
Sha256(key, klen, temp);
|
||||||
|
klen = 32;
|
||||||
|
key = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < klen; i++)
|
||||||
|
{
|
||||||
|
IPad[ i ] ^= key[ i ];
|
||||||
|
Ctx->OPad[ i ] ^= key[ i ];
|
||||||
|
}
|
||||||
|
|
||||||
|
Sha256Init(&Ctx->ShaCtx);
|
||||||
|
Sha256Update(&Ctx->ShaCtx, IPad, sizeof(IPad));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void _Sha256HmacUpdate(Sha256HmacCtx *Ctx, BYTE *data, size_t len)
|
||||||
|
{
|
||||||
|
Sha256Update(&Ctx->ShaCtx, data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void _Sha256HmacFinish(Sha256HmacCtx *Ctx, BYTE *hmac)
|
||||||
|
{
|
||||||
|
BYTE temp[32];
|
||||||
|
|
||||||
|
Sha256Finish(&Ctx->ShaCtx, temp);
|
||||||
|
Sha256Init(&Ctx->ShaCtx);
|
||||||
|
Sha256Update(&Ctx->ShaCtx, Ctx->OPad, sizeof(Ctx->OPad));
|
||||||
|
Sha256Update(&Ctx->ShaCtx, temp, sizeof(temp));
|
||||||
|
Sha256Finish(&Ctx->ShaCtx, hmac);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int_fast8_t Sha256Hmac(BYTE* key, BYTE* restrict data, DWORD len, BYTE* restrict hmac)
|
||||||
|
{
|
||||||
|
Sha256HmacCtx Ctx;
|
||||||
|
_Sha256HmacInit(&Ctx, key, 16);
|
||||||
|
_Sha256HmacUpdate(&Ctx, data, len);
|
||||||
|
_Sha256HmacFinish(&Ctx, hmac);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // No external Crypto
|
||||||
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef __crypto_internal_h
|
||||||
|
#define __crypto_internal_h
|
||||||
|
|
||||||
|
#if !defined(_CRYPTO_OPENSSL) && !defined(_CRYPTO_POLARSSL) && !defined(_CRYPTO_WINDOWS)
|
||||||
|
|
||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#include "crypto.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DWORD State[8];
|
||||||
|
BYTE Buffer[64];
|
||||||
|
unsigned int Len;
|
||||||
|
} Sha256Ctx;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Sha256Ctx ShaCtx;
|
||||||
|
BYTE OPad[64];
|
||||||
|
} Sha256HmacCtx;
|
||||||
|
|
||||||
|
void Sha256(BYTE *data, size_t len, BYTE *hash);
|
||||||
|
int_fast8_t Sha256Hmac(BYTE* key, BYTE* restrict data, DWORD len, BYTE* restrict hmac);
|
||||||
|
|
||||||
|
//void _Sha256HmacInit(Sha256HmacCtx *Ctx, BYTE *key, size_t klen);
|
||||||
|
//void _Sha256HmacUpdate(Sha256HmacCtx *Ctx, BYTE *data, size_t len);
|
||||||
|
//void _Sha256HmacFinish(Sha256HmacCtx *Ctx, BYTE *hmac);
|
||||||
|
|
||||||
|
//#define Sha256HmacInit(c, k, l) ( _Sha256HmacInit(c, k, l), !0 )
|
||||||
|
//#define Sha256HmacUpdate(c, d, l) ( _Sha256HmacUpdate(c, d, l), !0 )
|
||||||
|
//#define Sha256HmacFinish(c, h) ( _Sha256HmacFinish(c, h), !0 )
|
||||||
|
|
||||||
|
|
||||||
|
#endif // !defined(_CRYPTO_OPENSSL) && !defined(_CRYPTO_POLARSSL) && !defined(_CRYPTO_WINDOWS)
|
||||||
|
|
||||||
|
#endif // __crypto_internal_h
|
||||||
@@ -0,0 +1,269 @@
|
|||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#if defined(_CRYPTO_OPENSSL)
|
||||||
|
|
||||||
|
#include "crypto.h"
|
||||||
|
#include "crypto_openssl.h" // Required for Eclipse only
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "endian.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _OPENSSL_NO_HMAC
|
||||||
|
|
||||||
|
int Sha256HmacInit_OpenSSL(HMAC_CTX *c, const void *k, int l)
|
||||||
|
{
|
||||||
|
HMAC_CTX_init(c);
|
||||||
|
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
|
||||||
|
int result =
|
||||||
|
#else
|
||||||
|
int result = TRUE;
|
||||||
|
#endif
|
||||||
|
HMAC_Init_ex(c, k, l, EVP_sha256(), NULL);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Sha256HmacFinish_OpenSSL(HMAC_CTX *c, unsigned char *h, unsigned int *l)
|
||||||
|
{
|
||||||
|
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
|
||||||
|
int result =
|
||||||
|
#else
|
||||||
|
int result = !0;
|
||||||
|
#endif
|
||||||
|
HMAC_Final(c, h, l);
|
||||||
|
HMAC_CTX_cleanup(c);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int_fast8_t Sha256Hmac(BYTE* key, BYTE* restrict data, DWORD len, BYTE* restrict hmac)
|
||||||
|
{
|
||||||
|
HMAC_CTX Ctx;
|
||||||
|
|
||||||
|
# if OPENSSL_VERSION_NUMBER >= 0x10000000L
|
||||||
|
|
||||||
|
return
|
||||||
|
Sha256HmacInit_OpenSSL(&Ctx, key, 16) &&
|
||||||
|
HMAC_Update(&Ctx, data, len) &&
|
||||||
|
Sha256HmacFinish_OpenSSL(&Ctx, hmac, NULL);
|
||||||
|
|
||||||
|
# else // OpenSSL 0.9.x
|
||||||
|
|
||||||
|
Sha256HmacInit_OpenSSL(&Ctx, key, 16);
|
||||||
|
HMAC_Update(&Ctx, data, len);
|
||||||
|
Sha256HmacFinish_OpenSSL(&Ctx, hmac, NULL);
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // _OPENSSL_NO_HMAC (some routers have OpenSSL without support for HMAC)
|
||||||
|
|
||||||
|
int _Sha256HmacInit(Sha256HmacCtx *Ctx, BYTE *key, size_t klen)
|
||||||
|
{
|
||||||
|
BYTE IPad[64];
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
memset(IPad, 0x36, sizeof(IPad));
|
||||||
|
memset(Ctx->OPad, 0x5C, sizeof(Ctx->OPad));
|
||||||
|
|
||||||
|
if ( klen > 64 )
|
||||||
|
{
|
||||||
|
BYTE *temp = (BYTE*)alloca(32);
|
||||||
|
SHA256(key, klen, temp);
|
||||||
|
klen = 32;
|
||||||
|
key = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < klen; i++)
|
||||||
|
{
|
||||||
|
IPad[ i ] ^= key[ i ];
|
||||||
|
Ctx->OPad[ i ] ^= key[ i ];
|
||||||
|
}
|
||||||
|
|
||||||
|
SHA256_Init(&Ctx->ShaCtx);
|
||||||
|
return SHA256_Update(&Ctx->ShaCtx, IPad, sizeof(IPad));
|
||||||
|
}
|
||||||
|
|
||||||
|
int _Sha256HmacUpdate(Sha256HmacCtx *Ctx, BYTE *data, size_t len)
|
||||||
|
{
|
||||||
|
int rc = SHA256_Update(&Ctx->ShaCtx, data, len);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _Sha256HmacFinish(Sha256HmacCtx *Ctx, BYTE *hmac, void* dummy)
|
||||||
|
{
|
||||||
|
BYTE temp[32];
|
||||||
|
|
||||||
|
SHA256_Final(temp, &Ctx->ShaCtx);
|
||||||
|
SHA256_Init(&Ctx->ShaCtx);
|
||||||
|
SHA256_Update(&Ctx->ShaCtx, Ctx->OPad, sizeof(Ctx->OPad));
|
||||||
|
SHA256_Update(&Ctx->ShaCtx, temp, sizeof(temp));
|
||||||
|
return SHA256_Final(hmac, &Ctx->ShaCtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
int_fast8_t Sha256Hmac(BYTE* key, BYTE* restrict data, DWORD len, BYTE* restrict hmac)
|
||||||
|
{
|
||||||
|
Sha256HmacCtx Ctx;
|
||||||
|
_Sha256HmacInit(&Ctx, key, 16);
|
||||||
|
_Sha256HmacUpdate(&Ctx, data, len);
|
||||||
|
_Sha256HmacFinish(&Ctx, hmac, NULL);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_USE_AES_FROM_OPENSSL)
|
||||||
|
void TransformOpenSslEncryptKey(AES_KEY *k, const AesCtx *const Ctx)
|
||||||
|
{
|
||||||
|
uint32_t *rk_OpenSSL = k->rd_key, *rk_vlmcsd = (uint32_t*)Ctx->Key;
|
||||||
|
k->rounds = Ctx->rounds;
|
||||||
|
|
||||||
|
for (; rk_OpenSSL < k->rd_key + ((k->rounds + 1) << 2); rk_OpenSSL++, rk_vlmcsd++)
|
||||||
|
{
|
||||||
|
#ifdef _OPENSSL_SOFTWARE
|
||||||
|
*rk_OpenSSL = BE32(*rk_vlmcsd);
|
||||||
|
#else
|
||||||
|
*rk_OpenSSL = LE32(*rk_vlmcsd);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformOpenSslDecryptKey(AES_KEY *k, const AesCtx *const Ctx)
|
||||||
|
{
|
||||||
|
uint_fast8_t i;
|
||||||
|
|
||||||
|
#ifdef _DEBUG_OPENSSL
|
||||||
|
AES_set_decrypt_key((BYTE*)Ctx->Key, 128, k);
|
||||||
|
errorout("Correct V5 round key:");
|
||||||
|
|
||||||
|
for (i = 0; i < (Ctx->rounds + 1) << 4; i++)
|
||||||
|
{
|
||||||
|
if (!(i % 16)) errorout("\n");
|
||||||
|
if (!(i % 4)) errorout(" ");
|
||||||
|
errorout("%02X", ((BYTE*)(k->rd_key))[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
errorout("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
k->rounds = Ctx->rounds;
|
||||||
|
|
||||||
|
/* invert the order of the round keys blockwise (1 Block = AES_BLOCK_SIZE = 16): */
|
||||||
|
|
||||||
|
for (i = 0; i < (Ctx->rounds + 1) << 2; i++)
|
||||||
|
{
|
||||||
|
#ifdef _OPENSSL_SOFTWARE
|
||||||
|
k->rd_key[((Ctx->rounds-(i >> 2)) << 2) + (i & 3)] = BE32(Ctx->Key[i]);
|
||||||
|
#else
|
||||||
|
k->rd_key[((Ctx->rounds-(i >> 2)) << 2) + (i & 3)] = LE32(Ctx->Key[i]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* apply the inverse MixColumn transform to all round keys but the first and the last: */
|
||||||
|
|
||||||
|
uint32_t *rk = k->rd_key + 4;
|
||||||
|
|
||||||
|
for (i = 0; i < (Ctx->rounds - 1); i++)
|
||||||
|
{
|
||||||
|
MixColumnsR((BYTE*)(rk + (i << 2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _DEBUG_OPENSSL
|
||||||
|
errorout("Real round key:");
|
||||||
|
|
||||||
|
for (i = 0; i < (Ctx->rounds + 1) << 4; i++)
|
||||||
|
{
|
||||||
|
if (!(i % 16)) errorout("\n");
|
||||||
|
if (!(i % 4)) errorout(" ");
|
||||||
|
errorout("%02X", ((BYTE*)(k->rd_key))[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
errorout("\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static BYTE NullIV[AES_BLOCK_SIZE + 8]; // OpenSSL may overwrite bytes behind IV
|
||||||
|
|
||||||
|
void AesEncryptCbc(const AesCtx *const Ctx, BYTE *iv, BYTE *data, size_t *len)
|
||||||
|
{
|
||||||
|
AES_KEY k;
|
||||||
|
|
||||||
|
// OpenSSL overwrites IV plus 4 bytes
|
||||||
|
BYTE localIV[24]; // 4 spare bytes for safety
|
||||||
|
if (iv) memcpy(localIV, iv, AES_BLOCK_SIZE);
|
||||||
|
|
||||||
|
// OpenSSL Low-Level APIs do not pad. Could use EVP API instead but needs more code to access the expanded key
|
||||||
|
uint_fast8_t pad = (~*len & (AES_BLOCK_SIZE - 1)) + 1;
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8) // gcc 4.8 memset bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56977
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < pad; i++) data[*len + i] = pad;
|
||||||
|
#else
|
||||||
|
memset(data + *len, pad, pad);
|
||||||
|
#endif
|
||||||
|
*len += pad;
|
||||||
|
|
||||||
|
memset(NullIV, 0, sizeof(NullIV));
|
||||||
|
|
||||||
|
TransformOpenSslEncryptKey(&k, Ctx);
|
||||||
|
|
||||||
|
AES_cbc_encrypt(data, data, *len, &k, iv ? localIV : NullIV, AES_ENCRYPT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AesDecryptBlock(const AesCtx *const Ctx, BYTE *block)
|
||||||
|
{
|
||||||
|
AES_KEY k;
|
||||||
|
|
||||||
|
TransformOpenSslDecryptKey(&k, Ctx);
|
||||||
|
AES_decrypt(block, block, &k);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(_CRYPTO_OPENSSL) && defined(_USE_AES_FROM_OPENSSL) && !defined(_OPENSSL_SOFTWARE)
|
||||||
|
void AesEncryptBlock(const AesCtx *const Ctx, BYTE *block)
|
||||||
|
{
|
||||||
|
AES_KEY k;
|
||||||
|
|
||||||
|
TransformOpenSslEncryptKey(&k, Ctx);
|
||||||
|
AES_encrypt(block, block, &k);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void AesDecryptCbc(const AesCtx *const Ctx, BYTE *iv, BYTE *data, size_t len)
|
||||||
|
{
|
||||||
|
AES_KEY k;
|
||||||
|
|
||||||
|
memset(NullIV, 0, sizeof(NullIV));
|
||||||
|
|
||||||
|
TransformOpenSslDecryptKey(&k, Ctx);
|
||||||
|
AES_cbc_encrypt(data, data, len, &k, iv ? iv : NullIV, AES_DECRYPT);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef _OPENSSL_SOFTWARE
|
||||||
|
void AesCmacV4(BYTE *Message, size_t MessageSize, BYTE *HashOut)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
BYTE hash[AES_BLOCK_BYTES];
|
||||||
|
AesCtx Ctx;
|
||||||
|
AES_KEY k;
|
||||||
|
|
||||||
|
AesInitKey(&Ctx, AesKeyV4, FALSE, V4_KEY_BYTES);
|
||||||
|
TransformOpenSslEncryptKey(&k, &Ctx);
|
||||||
|
|
||||||
|
memset(hash, 0, sizeof(hash));
|
||||||
|
memset(Message + MessageSize, 0, AES_BLOCK_BYTES);
|
||||||
|
Message[MessageSize] = 0x80;
|
||||||
|
|
||||||
|
for (i = 0; i <= MessageSize; i += AES_BLOCK_BYTES)
|
||||||
|
{
|
||||||
|
XorBlock(Message + i, hash);
|
||||||
|
AES_encrypt(hash, hash, &k);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(HashOut, hash, AES_BLOCK_BYTES);
|
||||||
|
}
|
||||||
|
#endif // !_OPENSSL_SOFTWARE
|
||||||
|
|
||||||
|
#endif // defined(_USE_AES_FROM_OPENSSL)
|
||||||
|
|
||||||
|
#endif // _CRYPTO_OPENSSL
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
#ifndef __crypto_openssl_h
|
||||||
|
#define __crypto_openssl_h
|
||||||
|
|
||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#include <openssl/opensslv.h>
|
||||||
|
#include <openssl/sha.h>
|
||||||
|
#include <openssl/hmac.h>
|
||||||
|
#include <openssl/aes.h>
|
||||||
|
#include "crypto.h"
|
||||||
|
|
||||||
|
#define Sha256(d, l, h) SHA256(d, l, h)
|
||||||
|
int_fast8_t Sha256Hmac(BYTE* key, BYTE* restrict data, DWORD len, BYTE* restrict hmac);
|
||||||
|
|
||||||
|
#ifndef _OPENSSL_NO_HMAC
|
||||||
|
#define Sha256HmacCtx HMAC_CTX
|
||||||
|
#else
|
||||||
|
typedef struct {
|
||||||
|
SHA256_CTX ShaCtx;
|
||||||
|
BYTE OPad[64];
|
||||||
|
} Sha256HmacCtx;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _OPENSSL_NO_HMAC
|
||||||
|
|
||||||
|
#define Sha256HmacInit(c, k, l) Sha256HmacInit_OpenSSL(c, k, l)
|
||||||
|
#define Sha256HmacFinish(c, h) Sha256HmacFinish_OpenSSL(c, h, NULL)
|
||||||
|
|
||||||
|
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
|
||||||
|
#define Sha256HmacUpdate(c, d, l) HMAC_Update(c, d, l)
|
||||||
|
#else // OPENSSL_VERSION_NUMBER < 0x10000000L
|
||||||
|
#define Sha256HmacUpdate(c, d, l) (HMAC_Update(c, d, l), !0)
|
||||||
|
#endif // OPENSSL_VERSION_NUMBER >= 0x10000000L
|
||||||
|
|
||||||
|
int Sha256HmacInit_OpenSSL(HMAC_CTX *c, const void *k, int l);
|
||||||
|
int Sha256HmacFinish_OpenSSL(HMAC_CTX *c, unsigned char *h, unsigned int *l);
|
||||||
|
|
||||||
|
#else // _OPENSSL_NO_HMAC
|
||||||
|
|
||||||
|
int _Sha256HmacInit(Sha256HmacCtx *Ctx, BYTE *key, size_t klen);
|
||||||
|
int _Sha256HmacUpdate(Sha256HmacCtx *Ctx, BYTE *data, size_t len);
|
||||||
|
int _Sha256HmacFinish(Sha256HmacCtx *Ctx, BYTE *hmac, void* dummy);
|
||||||
|
#define Sha256HmacInit(c, k, l) _Sha256HmacInit(c, k, l)
|
||||||
|
#define Sha256HmacFinish(c, h) _Sha256HmacFinish(c, h, NULL)
|
||||||
|
#define Sha256HmacUpdate(c, d, l) _Sha256HmacUpdate(c, d, l)
|
||||||
|
|
||||||
|
#endif // _OPENSSL_NO_HMAC
|
||||||
|
|
||||||
|
extern const BYTE AesKeyV4[];
|
||||||
|
#endif // __crypto_openssl_h
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#ifndef __crypto_polarssl_h
|
||||||
|
#define __crypto_polarssl_h
|
||||||
|
|
||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#include <polarssl/version.h>
|
||||||
|
#include "crypto.h"
|
||||||
|
|
||||||
|
#if POLARSSL_VERSION_NUMBER >= 0x01030000
|
||||||
|
|
||||||
|
#include <polarssl/sha256.h>
|
||||||
|
|
||||||
|
#define Sha256(d, l, h) sha256(d, l, h, 0)
|
||||||
|
|
||||||
|
#define Sha256HmacCtx sha256_context
|
||||||
|
#define Sha256HmacInit(c, k, l) ( sha256_hmac_starts(c, k, l, 0), !0 )
|
||||||
|
#define Sha256HmacUpdate(c, d, l) ( sha256_hmac_update(c, d, l), !0 )
|
||||||
|
#define Sha256HmacFinish(c, h) ( sha256_hmac_finish(c, h), !0 )
|
||||||
|
#define Sha256Hmac(k, d, l, h) ( sha256_hmac(k, 16, d, l, h, FALSE), !0 )
|
||||||
|
|
||||||
|
#else // POLARSSL_VERSION_NUMBER
|
||||||
|
|
||||||
|
#include <polarssl/sha2.h>
|
||||||
|
|
||||||
|
#define Sha256(d, l, h) sha2(d, l, h, 0)
|
||||||
|
|
||||||
|
#define Sha256HmacCtx sha2_context
|
||||||
|
#define Sha256HmacInit(c, k, l) ( sha2_hmac_starts(c, k, l, 0), !0 )
|
||||||
|
#define Sha256HmacUpdate(c, d, l) ( sha2_hmac_update(c, d, l), !0 )
|
||||||
|
#define Sha256HmacFinish(c, h) ( sha2_hmac_finish(c, h), !0 )
|
||||||
|
#define Sha256Hmac(k, d, l, h) ( sha2_hmac(k, 16, d, l, h, FALSE), !0 )
|
||||||
|
|
||||||
|
#endif // POLARSSL_VERSION_NUMBER
|
||||||
|
#endif // __crypto_polarssl_h
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
/*
|
||||||
|
* crypto_windows.c
|
||||||
|
*/
|
||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#ifdef _CRYPTO_WINDOWS
|
||||||
|
|
||||||
|
#if !_WIN32 && !__CYGWIN__
|
||||||
|
#error You cannot use Windows CryptoAPI on non-Windows platforms
|
||||||
|
#else // _WIN32 || __CYGWIN__
|
||||||
|
|
||||||
|
#include "crypto_windows.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _HMAC_KEYBLOB
|
||||||
|
{
|
||||||
|
BLOBHEADER hdr;
|
||||||
|
DWORD dwKeySize;
|
||||||
|
BYTE KeyData[16];
|
||||||
|
} HMAC_KEYBLOB;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MingW and Cygwin define NULL as ((void*)0) (Posix standard) which you can't assign to
|
||||||
|
* non-pointer types without compiler warning. Thus we use the following
|
||||||
|
*/
|
||||||
|
#define NULLHANDLE 0
|
||||||
|
#define NULLFLAGS 0
|
||||||
|
|
||||||
|
|
||||||
|
static HCRYPTPROV hRsaAesProvider = 0; // Needs to be initialized just once per process
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int_fast8_t AcquireCryptContext()
|
||||||
|
{
|
||||||
|
if (!hRsaAesProvider)
|
||||||
|
{
|
||||||
|
return CryptAcquireContextW
|
||||||
|
(
|
||||||
|
&hRsaAesProvider, // Provider handle
|
||||||
|
NULL, // No key container name
|
||||||
|
NULL, // Default provider
|
||||||
|
PROV_RSA_AES, // Provides SHA and AES
|
||||||
|
CRYPT_VERIFYCONTEXT // We don't need access to persistent keys
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int_fast8_t Sha256(BYTE* restrict data, DWORD DataSize, BYTE* restrict hash)
|
||||||
|
{
|
||||||
|
HCRYPTHASH hHash = 0;
|
||||||
|
DWORD HashSize = 32;
|
||||||
|
|
||||||
|
int_fast8_t success =
|
||||||
|
AcquireCryptContext() &&
|
||||||
|
|
||||||
|
CryptCreateHash
|
||||||
|
(
|
||||||
|
hRsaAesProvider,// Provider handle
|
||||||
|
CALG_SHA_256, // Algorithm
|
||||||
|
NULLHANDLE, // SHA256 requires no key
|
||||||
|
NULLFLAGS, // Use default flags
|
||||||
|
&hHash // Handle for hashing
|
||||||
|
) &&
|
||||||
|
|
||||||
|
CryptHashData
|
||||||
|
(
|
||||||
|
hHash, // Handle
|
||||||
|
data, // data to hash
|
||||||
|
DataSize, // size of data
|
||||||
|
NULLFLAGS // Use default flags
|
||||||
|
) &&
|
||||||
|
|
||||||
|
CryptGetHashParam
|
||||||
|
(
|
||||||
|
hHash, // Handle
|
||||||
|
HP_HASHVAL, // what you actually want to get (the resulting hash)
|
||||||
|
hash, // data to retrieve
|
||||||
|
&HashSize, // size of data
|
||||||
|
NULLFLAGS // currently reserved (as of this writing)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hHash) CryptDestroyHash(hHash);
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int_fast8_t Sha256Hmac(const BYTE* key, BYTE* restrict data, DWORD len, BYTE* restrict hmac)
|
||||||
|
{
|
||||||
|
# ifndef USE_THREADS // In fork() mode thread-safety is not required
|
||||||
|
static
|
||||||
|
# endif
|
||||||
|
HMAC_KEYBLOB hmackeyblob = {
|
||||||
|
// Type, Version, Algorithm
|
||||||
|
{ PLAINTEXTKEYBLOB, CUR_BLOB_VERSION, 0, CALG_RC2 },
|
||||||
|
// Key length
|
||||||
|
16
|
||||||
|
};
|
||||||
|
|
||||||
|
HCRYPTKEY hKey = NULLHANDLE;
|
||||||
|
HCRYPTHASH hHmacHash = NULLHANDLE;
|
||||||
|
HMAC_INFO HmacInfo = { 0 };
|
||||||
|
DWORD dwHmacSize = 32;
|
||||||
|
|
||||||
|
HmacInfo.HashAlgid = CALG_SHA_256;
|
||||||
|
memcpy(hmackeyblob.KeyData, key, sizeof(hmackeyblob.KeyData));
|
||||||
|
|
||||||
|
BOOL success =
|
||||||
|
AcquireCryptContext() &&
|
||||||
|
|
||||||
|
CryptImportKey
|
||||||
|
(
|
||||||
|
hRsaAesProvider, // provider handle
|
||||||
|
(PBYTE)&hmackeyblob, // the actual key MS blob format
|
||||||
|
sizeof(HMAC_KEYBLOB), // size of the entire blob
|
||||||
|
NULLHANDLE, // password/key for the key store (none required here)
|
||||||
|
NULLFLAGS, // default flags
|
||||||
|
&hKey // key handle to retrieve (must be kept until you finish hashing)
|
||||||
|
) &&
|
||||||
|
|
||||||
|
CryptCreateHash
|
||||||
|
(
|
||||||
|
hRsaAesProvider, // provider handle
|
||||||
|
CALG_HMAC, // the actual key MS blob format
|
||||||
|
hKey, // size of the entire blob
|
||||||
|
NULLFLAGS, // password/key for the key store (none required here)
|
||||||
|
&hHmacHash // default flags
|
||||||
|
) && // key handle to retrieve (must be kept until you finish hashing)
|
||||||
|
|
||||||
|
CryptSetHashParam
|
||||||
|
(
|
||||||
|
hHmacHash, // hash handle
|
||||||
|
HP_HMAC_INFO, // parameter you want to set
|
||||||
|
(PBYTE)&HmacInfo, // the HMAC parameters (SHA256 with default ipad and opad)
|
||||||
|
NULLFLAGS // flags are reserved up to Windows 8.1
|
||||||
|
) &&
|
||||||
|
|
||||||
|
CryptHashData
|
||||||
|
(
|
||||||
|
hHmacHash, // hash handle
|
||||||
|
data, // Pointer to data you want to hash
|
||||||
|
len, // data length
|
||||||
|
NULLFLAGS // default flags
|
||||||
|
) &&
|
||||||
|
|
||||||
|
CryptGetHashParam
|
||||||
|
(
|
||||||
|
hHmacHash, // hash handle
|
||||||
|
HP_HASHVAL, // what you actually want to get (the resulting HMAC)
|
||||||
|
hmac, // data to retrieve
|
||||||
|
&dwHmacSize, // size of data
|
||||||
|
NULLFLAGS // currently reserved (as of this writing)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hKey) CryptDestroyKey(hKey);
|
||||||
|
if (hHmacHash) CryptDestroyHash(hHmacHash);
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // _WIN32 || __CYGWIN__
|
||||||
|
#endif // _CRYPTO_WINDOWS
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* crypto_windows.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef _CRYPTO_WINDOWS
|
||||||
|
#ifndef CRYPTO_WINDOWS_H_
|
||||||
|
#define CRYPTO_WINDOWS_H_
|
||||||
|
|
||||||
|
#if !_WIN32 && !__CYGWIN__
|
||||||
|
#error You cannot use Windows CryptoAPI on non-Windows platforms
|
||||||
|
#else // _WIN32 || __CYGWIN__
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
typedef struct _Sha2356HmacCtx
|
||||||
|
{
|
||||||
|
HCRYPTHASH hHmac;
|
||||||
|
HCRYPTKEY hKey;
|
||||||
|
} Sha256HmacCtx;
|
||||||
|
|
||||||
|
int_fast8_t Sha256(BYTE *data, DWORD len, BYTE *hash);
|
||||||
|
int_fast8_t Sha256Hmac(const BYTE* key, BYTE* restrict data, DWORD len, BYTE* restrict hmac);
|
||||||
|
|
||||||
|
/*int_fast8_t Sha256HmacInit(Sha256HmacCtx *Ctx, BYTE *key, uint8_t keySize);
|
||||||
|
int_fast8_t Sha256HmacUpdate(Sha256HmacCtx *Ctx, BYTE *data, DWORD len);
|
||||||
|
int_fast8_t Sha256HmacFinish(Sha256HmacCtx *Ctx, BYTE *hmac);*/
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _WIN32 || __CYGWIN__
|
||||||
|
#endif /* CRYPTO_WINDOWS_H_ */
|
||||||
|
#endif // _CRYPTO_WINDOWS
|
||||||
@@ -0,0 +1,330 @@
|
|||||||
|
/*
|
||||||
|
* dns_srv.c
|
||||||
|
*
|
||||||
|
* This file contains the code for KMS SRV record lookup in DNS (_vlmcs._tcp.example.com IN SRV 0 0 1688 mykms.example.com)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#ifndef NO_DNS
|
||||||
|
|
||||||
|
#include "dns_srv.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
//#ifndef DNS_PARSER_INTERNAL
|
||||||
|
#if __ANDROID__
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include "nameser.h"
|
||||||
|
#include "resolv.h"
|
||||||
|
#else // other Unix non-Android
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/nameser.h>
|
||||||
|
#include <resolv.h>
|
||||||
|
#endif // other Unix non-Android
|
||||||
|
//#endif // DNS_PARSER_INTERNAL
|
||||||
|
#else // WIN32
|
||||||
|
#include <windns.h>
|
||||||
|
#endif // WIN32
|
||||||
|
|
||||||
|
#include "helpers.h"
|
||||||
|
#include "output.h"
|
||||||
|
#include "endian.h"
|
||||||
|
|
||||||
|
#if defined(DNS_PARSER_INTERNAL) && !defined(_WIN32)
|
||||||
|
|
||||||
|
#include "ns_name.h"
|
||||||
|
#include "ns_parse.h"
|
||||||
|
|
||||||
|
// Define macros to redirect DNS parser functions to internal versions
|
||||||
|
|
||||||
|
#undef ns_msg
|
||||||
|
#undef ns_initparse
|
||||||
|
#undef ns_parserr
|
||||||
|
#undef ns_rr
|
||||||
|
#undef ns_name_uncompress
|
||||||
|
#undef ns_msg_base
|
||||||
|
#undef ns_msg_end
|
||||||
|
#undef ns_rr_rdata
|
||||||
|
#undef ns_rr_type
|
||||||
|
#undef ns_msg_count
|
||||||
|
#undef ns_rr_class
|
||||||
|
#undef ns_s_an
|
||||||
|
#define ns_msg ns_msg_vlmcsd
|
||||||
|
#define ns_initparse ns_initparse_vlmcsd
|
||||||
|
#define ns_parserr ns_parserr_vlmcsd
|
||||||
|
#define ns_rr ns_rr_vlmcsd
|
||||||
|
#define ns_name_uncompress ns_name_uncompress_vlmcsd
|
||||||
|
#define ns_msg_base ns_msg_base_vlmcsd
|
||||||
|
#define ns_msg_end ns_msg_end_vlmcsd
|
||||||
|
#define ns_rr_rdata ns_rr_rdata_vlmcsd
|
||||||
|
#define ns_rr_type ns_rr_type_vlmcsd
|
||||||
|
#define ns_msg_count ns_msg_count_vlmcsd
|
||||||
|
#define ns_rr_class ns_rr_class_vlmcsd
|
||||||
|
#define ns_s_an ns_s_an_vlmcsd
|
||||||
|
|
||||||
|
#ifndef NS_MAXLABEL
|
||||||
|
#define NS_MAXLABEL 63
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // defined(DNS_PARSER_INTERNAL) && !defined(_WIN32)
|
||||||
|
|
||||||
|
|
||||||
|
//TODO: maybe move to helpers.c
|
||||||
|
static unsigned int isqrt(unsigned int n)
|
||||||
|
{
|
||||||
|
unsigned int c = 0x8000;
|
||||||
|
unsigned int g = 0x8000;
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
if(g*g > n)
|
||||||
|
g ^= c;
|
||||||
|
|
||||||
|
c >>= 1;
|
||||||
|
|
||||||
|
if(c == 0) return g;
|
||||||
|
|
||||||
|
g |= c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compare function for qsort to sort SRV records by priority and weight
|
||||||
|
* random_weight must be product of weight from SRV record and square root of a random number
|
||||||
|
*/
|
||||||
|
static int kmsServerListCompareFunc1(const void* a, const void* b)
|
||||||
|
{
|
||||||
|
if ( !a && !b) return 0;
|
||||||
|
if ( a && !b) return -1;
|
||||||
|
if ( !a && b) return 1;
|
||||||
|
|
||||||
|
int priority_order = (int)((*(kms_server_dns_ptr*)a)->priority) - ((int)(*(kms_server_dns_ptr*)b)->priority);
|
||||||
|
|
||||||
|
if (priority_order) return priority_order;
|
||||||
|
|
||||||
|
return (int)((*(kms_server_dns_ptr*)b)->random_weight) - ((int)(*(kms_server_dns_ptr*)a)->random_weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sort resulting SRV records */
|
||||||
|
void sortSrvRecords(kms_server_dns_ptr* serverlist, const int answers)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < answers; i++)
|
||||||
|
{
|
||||||
|
serverlist[i]->random_weight = (rand32() % 256) * isqrt(serverlist[i]->weight * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
qsort(serverlist, answers, sizeof(kms_server_dns_ptr), kmsServerListCompareFunc1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define RECEIVE_BUFFER_SIZE 2048
|
||||||
|
#ifndef _WIN32 // UNIX resolver
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieves a raw DNS answer (a buffer of what came over the net)
|
||||||
|
* Result must be parsed
|
||||||
|
*/
|
||||||
|
static int getDnsRawAnswer(const char *restrict query, unsigned char** receive_buffer)
|
||||||
|
{
|
||||||
|
if (res_init() < 0)
|
||||||
|
{
|
||||||
|
errorout("Cannot initialize resolver: %s", strerror(errno));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if(!(*receive_buffer = (unsigned char*)malloc(RECEIVE_BUFFER_SIZE))) OutOfMemory();
|
||||||
|
*receive_buffer = (unsigned char*)vlmcsd_malloc(RECEIVE_BUFFER_SIZE);
|
||||||
|
|
||||||
|
int bytes_received;
|
||||||
|
|
||||||
|
if (*query == '.')
|
||||||
|
{
|
||||||
|
# if __ANDROID__ || __GLIBC__ /* including __UCLIBC__*/ || __APPLE__ || __CYGWIN__ || __FreeBSD__ || __NetBSD__ || __DragonFly__ || __OpenBSD__ || __sun__
|
||||||
|
bytes_received = res_querydomain("_vlmcs._tcp", query + 1, ns_c_in, ns_t_srv, *receive_buffer, RECEIVE_BUFFER_SIZE);
|
||||||
|
# else
|
||||||
|
char* querystring = (char*)alloca(strlen(query) + 12);
|
||||||
|
strcpy(querystring, "_vlmcs._tcp");
|
||||||
|
strcat(querystring, query);
|
||||||
|
bytes_received = res_query(querystring, ns_c_in, ns_t_srv, *receive_buffer, RECEIVE_BUFFER_SIZE);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bytes_received = res_search("_vlmcs._tcp", ns_c_in, ns_t_srv, *receive_buffer, RECEIVE_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bytes_received < 0)
|
||||||
|
{
|
||||||
|
errorout("Fatal: DNS query to %s%s failed: %s\n", "_vlmcs._tcp", *query == '.' ? query : "", hstrerror(h_errno));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes_received;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieves an unsorted array of SRV records (Unix / Posix)
|
||||||
|
*/
|
||||||
|
int getKmsServerList(kms_server_dns_ptr** serverlist, const char *restrict query)
|
||||||
|
{
|
||||||
|
unsigned char* receive_buffer;
|
||||||
|
*serverlist = NULL;
|
||||||
|
|
||||||
|
int bytes_received = getDnsRawAnswer(query, &receive_buffer);
|
||||||
|
|
||||||
|
if (bytes_received == 0) return 0;
|
||||||
|
|
||||||
|
ns_msg msg;
|
||||||
|
|
||||||
|
if (ns_initparse(receive_buffer, bytes_received, &msg) < 0)
|
||||||
|
{
|
||||||
|
errorout("Fatal: Incorrect DNS response: %s\n", strerror(errno));
|
||||||
|
free(receive_buffer);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t i, answers = ns_msg_count(msg, ns_s_an);
|
||||||
|
//if(!(*serverlist = (kms_server_dns_ptr*)malloc(answers * sizeof(kms_server_dns_ptr)))) OutOfMemory();
|
||||||
|
*serverlist = (kms_server_dns_ptr*)malloc(answers * sizeof(kms_server_dns_ptr));
|
||||||
|
|
||||||
|
memset(*serverlist, 0, answers * sizeof(kms_server_dns_ptr));
|
||||||
|
|
||||||
|
for (i = 0; i < answers; i++)
|
||||||
|
{
|
||||||
|
ns_rr rr;
|
||||||
|
|
||||||
|
if (ns_parserr(&msg, ns_s_an, i, &rr) < 0)
|
||||||
|
{
|
||||||
|
errorout("Warning: Error in DNS resource record: %s\n", strerror(errno));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ns_rr_type(rr) != ns_t_srv)
|
||||||
|
{
|
||||||
|
errorout("Warning: DNS server returned non-SRV record\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ns_rr_class(rr) != ns_c_in)
|
||||||
|
{
|
||||||
|
errorout("Warning: DNS server returned non-IN class record\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
dns_srv_record_ptr srvrecord = (dns_srv_record_ptr)ns_rr_rdata(rr);
|
||||||
|
kms_server_dns_ptr kms_server = (kms_server_dns_ptr)vlmcsd_malloc(sizeof(kms_server_dns_t));
|
||||||
|
|
||||||
|
(*serverlist)[i] = kms_server;
|
||||||
|
|
||||||
|
if (ns_name_uncompress(ns_msg_base(msg), ns_msg_end(msg), srvrecord->name, kms_server->serverName, sizeof(kms_server->serverName)) < 0)
|
||||||
|
{
|
||||||
|
errorout("Warning: No valid DNS name returned in SRV record: %s\n", strerror(errno));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(kms_server->serverName + strlen(kms_server->serverName), ":%hu", GET_UA16BE(&srvrecord->port));
|
||||||
|
kms_server->priority = GET_UA16BE(&srvrecord->priority);
|
||||||
|
kms_server->weight = GET_UA16BE(&srvrecord->weight);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
free(receive_buffer);
|
||||||
|
return answers;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // WIN32 (Windows Resolver)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieves an unsorted array of SRV records (Windows)
|
||||||
|
*/
|
||||||
|
int getKmsServerList(kms_server_dns_ptr** serverlist, const char *const restrict query)
|
||||||
|
{
|
||||||
|
# define MAX_DNS_NAME_SIZE 254
|
||||||
|
*serverlist = NULL;
|
||||||
|
PDNS_RECORD receive_buffer;
|
||||||
|
char dnsDomain[MAX_DNS_NAME_SIZE];
|
||||||
|
char FqdnQuery[MAX_DNS_NAME_SIZE];
|
||||||
|
DWORD size = MAX_DNS_NAME_SIZE;
|
||||||
|
DNS_STATUS result;
|
||||||
|
int answers = 0;
|
||||||
|
PDNS_RECORD dns_iterator;
|
||||||
|
|
||||||
|
if (*query == '-')
|
||||||
|
{
|
||||||
|
if (!GetComputerNameExA(ComputerNamePhysicalDnsDomain, dnsDomain, &size))
|
||||||
|
{
|
||||||
|
errorout("Fatal: Could not determine computer's DNS name: %s\n", vlmcsd_strerror(GetLastError()));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(FqdnQuery, "_vlmcs._tcp.");
|
||||||
|
strncat(FqdnQuery, dnsDomain, MAX_DNS_NAME_SIZE - 12);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcpy(FqdnQuery, "_vlmcs._tcp");
|
||||||
|
strncat(FqdnQuery, query, MAX_DNS_NAME_SIZE - 11);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((result = DnsQuery_UTF8(FqdnQuery, DNS_TYPE_SRV, 0, NULL, &receive_buffer, NULL)) != 0)
|
||||||
|
{
|
||||||
|
errorout("Fatal: DNS query to %s failed: %s\n", FqdnQuery, vlmcsd_strerror(result));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (dns_iterator = receive_buffer; dns_iterator; dns_iterator = dns_iterator->pNext)
|
||||||
|
{
|
||||||
|
if (dns_iterator->Flags.S.Section != 1) continue;
|
||||||
|
|
||||||
|
if (dns_iterator->wType != DNS_TYPE_SRV)
|
||||||
|
{
|
||||||
|
errorout("Warning: DNS server returned non-SRV record\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
answers++;
|
||||||
|
}
|
||||||
|
|
||||||
|
*serverlist = (kms_server_dns_ptr*)vlmcsd_malloc(answers * sizeof(kms_server_dns_ptr));
|
||||||
|
|
||||||
|
for (answers = 0, dns_iterator = receive_buffer; dns_iterator; dns_iterator = dns_iterator->pNext)
|
||||||
|
{
|
||||||
|
if (dns_iterator->wType != DNS_TYPE_SRV) continue;
|
||||||
|
|
||||||
|
kms_server_dns_ptr kms_server = (kms_server_dns_ptr)vlmcsd_malloc(sizeof(kms_server_dns_t));
|
||||||
|
|
||||||
|
memset(kms_server, 0, sizeof(kms_server_dns_t));
|
||||||
|
|
||||||
|
snprintf(kms_server->serverName, sizeof(kms_server->serverName), "%s:%hu", dns_iterator->Data.SRV.pNameTarget, dns_iterator->Data.SRV.wPort);
|
||||||
|
kms_server->priority = dns_iterator->Data.SRV.wPriority;
|
||||||
|
kms_server->weight = dns_iterator->Data.SRV.wWeight;
|
||||||
|
|
||||||
|
(*serverlist)[answers++] = kms_server;
|
||||||
|
}
|
||||||
|
|
||||||
|
//sortSrvRecords(*serverlist, answers, NoSrvRecordPriority);
|
||||||
|
|
||||||
|
DnsRecordListFree(receive_buffer, DnsFreeRecordList);
|
||||||
|
|
||||||
|
return answers;
|
||||||
|
# undef MAX_DNS_NAME_SIZE
|
||||||
|
}
|
||||||
|
#endif // _WIN32
|
||||||
|
#undef RECEIVE_BUFFER_SIZE
|
||||||
|
#endif // NO_DNS
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* dns_srv.h
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DNS_SRV_H_
|
||||||
|
#define DNS_SRV_H_
|
||||||
|
#ifndef NO_DNS
|
||||||
|
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t random_weight;
|
||||||
|
uint16_t priority;
|
||||||
|
uint16_t weight;
|
||||||
|
char serverName[260];
|
||||||
|
} kms_server_dns_t, *kms_server_dns_ptr;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t priority;
|
||||||
|
uint16_t weight;
|
||||||
|
uint16_t port;
|
||||||
|
unsigned char name[1];
|
||||||
|
} dns_srv_record_t, *dns_srv_record_ptr;
|
||||||
|
|
||||||
|
#if __OpenBSD__
|
||||||
|
typedef enum __ns_type {
|
||||||
|
ns_t_invalid = 0, /*%< Cookie. */
|
||||||
|
ns_t_a = 1, /*%< Host address. */
|
||||||
|
ns_t_ns = 2, /*%< Authoritative server. */
|
||||||
|
ns_t_md = 3, /*%< Mail destination. */
|
||||||
|
ns_t_mf = 4, /*%< Mail forwarder. */
|
||||||
|
ns_t_cname = 5, /*%< Canonical name. */
|
||||||
|
ns_t_soa = 6, /*%< Start of authority zone. */
|
||||||
|
ns_t_mb = 7, /*%< Mailbox domain name. */
|
||||||
|
ns_t_mg = 8, /*%< Mail group member. */
|
||||||
|
ns_t_mr = 9, /*%< Mail rename name. */
|
||||||
|
ns_t_null = 10, /*%< Null resource record. */
|
||||||
|
ns_t_wks = 11, /*%< Well known service. */
|
||||||
|
ns_t_ptr = 12, /*%< Domain name pointer. */
|
||||||
|
ns_t_hinfo = 13, /*%< Host information. */
|
||||||
|
ns_t_minfo = 14, /*%< Mailbox information. */
|
||||||
|
ns_t_mx = 15, /*%< Mail routing information. */
|
||||||
|
ns_t_txt = 16, /*%< Text strings. */
|
||||||
|
ns_t_rp = 17, /*%< Responsible person. */
|
||||||
|
ns_t_afsdb = 18, /*%< AFS cell database. */
|
||||||
|
ns_t_x25 = 19, /*%< X_25 calling address. */
|
||||||
|
ns_t_isdn = 20, /*%< ISDN calling address. */
|
||||||
|
ns_t_rt = 21, /*%< Router. */
|
||||||
|
ns_t_nsap = 22, /*%< NSAP address. */
|
||||||
|
ns_t_nsap_ptr = 23, /*%< Reverse NSAP lookup (deprecated). */
|
||||||
|
ns_t_sig = 24, /*%< Security signature. */
|
||||||
|
ns_t_key = 25, /*%< Security key. */
|
||||||
|
ns_t_px = 26, /*%< X.400 mail mapping. */
|
||||||
|
ns_t_gpos = 27, /*%< Geographical position (withdrawn). */
|
||||||
|
ns_t_aaaa = 28, /*%< Ip6 Address. */
|
||||||
|
ns_t_loc = 29, /*%< Location Information. */
|
||||||
|
ns_t_nxt = 30, /*%< Next domain (security). */
|
||||||
|
ns_t_eid = 31, /*%< Endpoint identifier. */
|
||||||
|
ns_t_nimloc = 32, /*%< Nimrod Locator. */
|
||||||
|
ns_t_srv = 33, /*%< Server Selection. */
|
||||||
|
ns_t_atma = 34, /*%< ATM Address */
|
||||||
|
ns_t_naptr = 35, /*%< Naming Authority PoinTeR */
|
||||||
|
ns_t_kx = 36, /*%< Key Exchange */
|
||||||
|
ns_t_cert = 37, /*%< Certification record */
|
||||||
|
ns_t_a6 = 38, /*%< IPv6 address (deprecated, use ns_t_aaaa) */
|
||||||
|
ns_t_dname = 39, /*%< Non-terminal DNAME (for IPv6) */
|
||||||
|
ns_t_sink = 40, /*%< Kitchen sink (experimentatl) */
|
||||||
|
ns_t_opt = 41, /*%< EDNS0 option (meta-RR) */
|
||||||
|
ns_t_apl = 42, /*%< Address prefix list (RFC3123) */
|
||||||
|
ns_t_tkey = 249, /*%< Transaction key */
|
||||||
|
ns_t_tsig = 250, /*%< Transaction signature. */
|
||||||
|
ns_t_ixfr = 251, /*%< Incremental zone transfer. */
|
||||||
|
ns_t_axfr = 252, /*%< Transfer zone of authority. */
|
||||||
|
ns_t_mailb = 253, /*%< Transfer mailbox records. */
|
||||||
|
ns_t_maila = 254, /*%< Transfer mail agent records. */
|
||||||
|
ns_t_any = 255, /*%< Wildcard match. */
|
||||||
|
ns_t_zxfr = 256, /*%< BIND-specific, nonstandard. */
|
||||||
|
ns_t_max = 65536
|
||||||
|
} ns_type;
|
||||||
|
|
||||||
|
typedef enum __ns_class {
|
||||||
|
ns_c_invalid = 0, /*%< Cookie. */
|
||||||
|
ns_c_in = 1, /*%< Internet. */
|
||||||
|
ns_c_2 = 2, /*%< unallocated/unsupported. */
|
||||||
|
ns_c_chaos = 3, /*%< MIT Chaos-net. */
|
||||||
|
ns_c_hs = 4, /*%< MIT Hesiod. */
|
||||||
|
/* Query class values which do not appear in resource records */
|
||||||
|
ns_c_none = 254, /*%< for prereq. sections in update requests */
|
||||||
|
ns_c_any = 255, /*%< Wildcard match. */
|
||||||
|
ns_c_max = 65536
|
||||||
|
} ns_class;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int getKmsServerList(kms_server_dns_ptr** serverlist, const char *restrict query);
|
||||||
|
void sortSrvRecords(kms_server_dns_ptr* serverlist, const int answers);
|
||||||
|
|
||||||
|
#endif // NO_DNS
|
||||||
|
#endif /* DNS_SRV_H_ */
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#include "endian.h"
|
||||||
|
|
||||||
|
#if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) \
|
||||||
|
&& defined(BS16) && defined(BS32) && defined(BS64)
|
||||||
|
|
||||||
|
#else // ! defined(__BYTE_ORDER)
|
||||||
|
|
||||||
|
void PUT_UAA64BE(void *p, unsigned long long v, unsigned int i)
|
||||||
|
{
|
||||||
|
unsigned char *_p = (unsigned char *)&((unsigned long long *)p)[i];
|
||||||
|
_p[ 0 ] = v >> 56;
|
||||||
|
_p[ 1 ] = v >> 48;
|
||||||
|
_p[ 2 ] = v >> 40;
|
||||||
|
_p[ 3 ] = v >> 32;
|
||||||
|
_p[ 4 ] = v >> 24;
|
||||||
|
_p[ 5 ] = v >> 16;
|
||||||
|
_p[ 6 ] = v >> 8;
|
||||||
|
_p[ 7 ] = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PUT_UAA32BE(void *p, unsigned int v, unsigned int i)
|
||||||
|
{
|
||||||
|
unsigned char *_p = (unsigned char *)&((unsigned int *)p)[i];
|
||||||
|
_p[ 0 ] = v >> 24;
|
||||||
|
_p[ 1 ] = v >> 16;
|
||||||
|
_p[ 2 ] = v >> 8;
|
||||||
|
_p[ 3 ] = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PUT_UAA16BE(void *p, unsigned short v, unsigned int i)
|
||||||
|
{
|
||||||
|
unsigned char *_p = (unsigned char *)&((unsigned short *)p)[i];
|
||||||
|
_p[ 0 ] = v >> 8;
|
||||||
|
_p[ 1 ] = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PUT_UAA64LE(void *p, unsigned long long v, unsigned int i)
|
||||||
|
{
|
||||||
|
unsigned char *_p = (unsigned char *)&((unsigned long long *)p)[i];
|
||||||
|
_p[ 0 ] = v;
|
||||||
|
_p[ 1 ] = v >> 8;
|
||||||
|
_p[ 2 ] = v >> 16;
|
||||||
|
_p[ 3 ] = v >> 24;
|
||||||
|
_p[ 4 ] = v >> 32;
|
||||||
|
_p[ 5 ] = v >> 40;
|
||||||
|
_p[ 6 ] = v >> 48;
|
||||||
|
_p[ 7 ] = v >> 56;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PUT_UAA32LE(void *p, unsigned int v, unsigned int i)
|
||||||
|
{
|
||||||
|
unsigned char *_p = (unsigned char *)&((unsigned int *)p)[i];
|
||||||
|
_p[ 0 ] = v;
|
||||||
|
_p[ 1 ] = v >> 8;
|
||||||
|
_p[ 2 ] = v >> 16;
|
||||||
|
_p[ 3 ] = v >> 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PUT_UAA16LE(void *p, unsigned short v, unsigned int i)
|
||||||
|
{
|
||||||
|
unsigned char *_p = (unsigned char *)&((unsigned short *)p)[i];
|
||||||
|
_p[ 0 ] = v;
|
||||||
|
_p[ 1 ] = v >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned long long GET_UAA64BE(void *p, unsigned int i)
|
||||||
|
{
|
||||||
|
unsigned char *_p = (unsigned char *)&((unsigned long long *)p)[i];
|
||||||
|
return
|
||||||
|
(unsigned long long)_p[ 0 ] << 56 |
|
||||||
|
(unsigned long long)_p[ 1 ] << 48 |
|
||||||
|
(unsigned long long)_p[ 2 ] << 40 |
|
||||||
|
(unsigned long long)_p[ 3 ] << 32 |
|
||||||
|
(unsigned long long)_p[ 4 ] << 24 |
|
||||||
|
(unsigned long long)_p[ 5 ] << 16 |
|
||||||
|
(unsigned long long)_p[ 6 ] << 8 |
|
||||||
|
(unsigned long long)_p[ 7 ];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int GET_UAA32BE(void *p, unsigned int i)
|
||||||
|
{
|
||||||
|
unsigned char *_p = (unsigned char *)&((unsigned int *)p)[i];
|
||||||
|
return
|
||||||
|
(unsigned int)_p[ 0 ] << 24 |
|
||||||
|
(unsigned int)_p[ 1 ] << 16 |
|
||||||
|
(unsigned int)_p[ 2 ] << 8 |
|
||||||
|
(unsigned int)_p[ 3 ];
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short GET_UAA16BE(void *p, unsigned int i)
|
||||||
|
{
|
||||||
|
unsigned char *_p = (unsigned char *)&((unsigned short *)p)[i];
|
||||||
|
return
|
||||||
|
(unsigned short)_p[ 0 ] << 8 |
|
||||||
|
(unsigned short)_p[ 1 ];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned long long GET_UAA64LE(void *p, unsigned int i)
|
||||||
|
{
|
||||||
|
unsigned char *_p = (unsigned char *)&((unsigned long long *)p)[i];
|
||||||
|
return
|
||||||
|
(unsigned long long)_p[ 0 ] |
|
||||||
|
(unsigned long long)_p[ 1 ] << 8 |
|
||||||
|
(unsigned long long)_p[ 2 ] << 16 |
|
||||||
|
(unsigned long long)_p[ 3 ] << 24 |
|
||||||
|
(unsigned long long)_p[ 4 ] << 32 |
|
||||||
|
(unsigned long long)_p[ 5 ] << 40 |
|
||||||
|
(unsigned long long)_p[ 6 ] << 48 |
|
||||||
|
(unsigned long long)_p[ 7 ] << 56;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int GET_UAA32LE(void *p, unsigned int i)
|
||||||
|
{
|
||||||
|
unsigned char *_p = (unsigned char *)&((unsigned int *)p)[i];
|
||||||
|
return
|
||||||
|
(unsigned int)_p[ 0 ] |
|
||||||
|
(unsigned int)_p[ 1 ] << 8 |
|
||||||
|
(unsigned int)_p[ 2 ] << 16 |
|
||||||
|
(unsigned int)_p[ 3 ] << 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short GET_UAA16LE(void *p, unsigned int i)
|
||||||
|
{
|
||||||
|
unsigned char *_p = (unsigned char *)&((unsigned short *)p)[i];
|
||||||
|
return
|
||||||
|
(unsigned short)_p[ 0 ] |
|
||||||
|
(unsigned short)_p[ 1 ] << 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned short BE16(unsigned short x)
|
||||||
|
{
|
||||||
|
return GET_UAA16BE(&x, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short LE16(unsigned short x)
|
||||||
|
{
|
||||||
|
return GET_UAA16LE(&x, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int BE32(unsigned int x)
|
||||||
|
{
|
||||||
|
return GET_UAA32BE(&x, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int LE32(unsigned int x)
|
||||||
|
{
|
||||||
|
return GET_UAA32LE(&x, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long long BE64(unsigned long long x)
|
||||||
|
{
|
||||||
|
return GET_UAA64BE(&x, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline unsigned long long LE64(unsigned long long x)
|
||||||
|
{
|
||||||
|
return GET_UAA64LE(&x, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // defined(__BYTE_ORDER)
|
||||||
@@ -0,0 +1,296 @@
|
|||||||
|
#ifndef __endian_h
|
||||||
|
#define __endian_h
|
||||||
|
|
||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
//
|
||||||
|
// Unaligned access
|
||||||
|
//
|
||||||
|
#define UAA16(p, i) (((PACKED16*)p)->val[i])
|
||||||
|
#define UAA32(p, i) (((PACKED32*)p)->val[i])
|
||||||
|
#define UAA64(p, i) (((PACKED64*)p)->val[i])
|
||||||
|
|
||||||
|
#define UA64(p) UAA64(p, 0)
|
||||||
|
#define UA32(p) UAA32(p, 0)
|
||||||
|
#define UA16(p) UAA16(p, 0)
|
||||||
|
|
||||||
|
//
|
||||||
|
//Byteswap: Use compiler support if available
|
||||||
|
//
|
||||||
|
#ifdef __has_builtin // Clang supports this
|
||||||
|
|
||||||
|
#if __has_builtin(__builtin_bswap16)
|
||||||
|
#define BS16(x) __builtin_bswap16(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_builtin(__builtin_bswap32)
|
||||||
|
#define BS32(x) __builtin_bswap32(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_builtin(__builtin_bswap64)
|
||||||
|
#define BS64(x) __builtin_bswap64(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // has_builtin
|
||||||
|
|
||||||
|
#ifdef __GNUC__ // GNU C >= 4.3 has bswap32 and bswap64. GNU C >= 4.8 also has bswap16
|
||||||
|
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)
|
||||||
|
|
||||||
|
#ifndef BS32
|
||||||
|
#define BS32(x) __builtin_bswap32(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BS64
|
||||||
|
#define BS64(x) __builtin_bswap64(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (__GNUC__ > 4) || (__GNUC_MINOR__ > 7)
|
||||||
|
|
||||||
|
#ifndef BS16
|
||||||
|
#define BS16(x) __builtin_bswap16(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // GNU C > 4.7
|
||||||
|
#endif // __GNUC__ > 4
|
||||||
|
#endif // __GNUC__
|
||||||
|
|
||||||
|
//
|
||||||
|
// Byteorder
|
||||||
|
//
|
||||||
|
#if defined(__linux__) || defined(__GLIBC__) || defined(__CYGWIN__)
|
||||||
|
|
||||||
|
#include <endian.h>
|
||||||
|
#include <byteswap.h>
|
||||||
|
|
||||||
|
#ifndef BS16
|
||||||
|
#define BS16(x) bswap_16(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BS32
|
||||||
|
#define BS32(x) bswap_32(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BS64
|
||||||
|
#define BS64(x) bswap_64(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(__sun__)
|
||||||
|
|
||||||
|
#include <sys/byteorder.h>
|
||||||
|
|
||||||
|
#ifndef BS16
|
||||||
|
#define BS16(x) BSWAP_16(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BS32
|
||||||
|
#define BS32(x) BSWAP_32(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BS64
|
||||||
|
#define BS64(x) BSWAP_64(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define __LITTLE_ENDIAN 1234
|
||||||
|
#define __BIG_ENDIAN 4321
|
||||||
|
|
||||||
|
#ifdef _LITTLE_ENDIAN
|
||||||
|
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||||
|
#else
|
||||||
|
#define __BYTE_ORDER __BIG_ENDIAN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif __minix__ || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/endian.h>
|
||||||
|
|
||||||
|
#define __BYTE_ORDER _BYTE_ORDER
|
||||||
|
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||||
|
#define __BIG_ENDIAN _BIG_ENDIAN
|
||||||
|
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
|
||||||
|
#ifndef BS16
|
||||||
|
#define BS16 swap16
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BS32
|
||||||
|
#define BS32 swap32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BS64
|
||||||
|
#define BS64 swap64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else // !__OpenBSD__
|
||||||
|
|
||||||
|
#ifndef BS16
|
||||||
|
#define BS16 bswap16
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BS32
|
||||||
|
#define BS32 bswap32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BS64
|
||||||
|
#define BS64 bswap64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // !__OpenBSD__
|
||||||
|
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <machine/endian.h>
|
||||||
|
#include <libkern/OSByteOrder.h>
|
||||||
|
|
||||||
|
#define __BYTE_ORDER _BYTE_ORDER
|
||||||
|
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||||
|
#define __BIG_ENDIAN _BIG_ENDIAN
|
||||||
|
|
||||||
|
#ifndef BS16
|
||||||
|
#define BS16 OSSwapInt16
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BS32
|
||||||
|
#define BS32 OSSwapInt32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BS64
|
||||||
|
#define BS64 OSSwapInt64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
|
||||||
|
#define __LITTLE_ENDIAN 1234
|
||||||
|
#define __BIG_ENDIAN 4321
|
||||||
|
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifndef BS16
|
||||||
|
#define BS16 _byteswap_ushort
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BS32
|
||||||
|
#define BS32 _byteswap_ulong
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BS64
|
||||||
|
#define BS64 _byteswap_uint64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // Byteorder in different OS
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) \
|
||||||
|
&& defined(BS16) && defined(BS32) && defined(BS64)
|
||||||
|
|
||||||
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
|
|
||||||
|
#define __BE16(x) BS16(x)
|
||||||
|
#define __LE16(x) (x)
|
||||||
|
#define __BE32(x) BS32(x)
|
||||||
|
#define __LE32(x) (x)
|
||||||
|
#define __BE64(x) BS64(x)
|
||||||
|
#define __LE64(x) (x)
|
||||||
|
|
||||||
|
#else // __BYTE_ORDER == __BIG_ENDIAN
|
||||||
|
|
||||||
|
#define __BE16(x) (x)
|
||||||
|
#define __LE16(x) BS16(x)
|
||||||
|
#define __BE32(x) (x)
|
||||||
|
#define __LE32(x) BS32(x)
|
||||||
|
#define __BE64(x) (x)
|
||||||
|
#define __LE64(x) BS64(x)
|
||||||
|
|
||||||
|
#endif // __BYTE_ORDER
|
||||||
|
|
||||||
|
#define PUT_UAA64BE(p, v, i) ( UAA64(p, i) = __BE64(v) )
|
||||||
|
#define PUT_UAA32BE(p, v, i) ( UAA32(p, i) = __BE32(v) )
|
||||||
|
#define PUT_UAA16BE(p, v, i) ( UAA16(p, i) = __BE16(v) )
|
||||||
|
|
||||||
|
#define PUT_UAA64LE(p, v, i) ( UAA64(p, i) = __LE64(v) )
|
||||||
|
#define PUT_UAA32LE(p, v, i) ( UAA32(p, i) = __LE32(v) )
|
||||||
|
#define PUT_UAA16LE(p, v, i) ( UAA16(p, i) = __LE16(v) )
|
||||||
|
|
||||||
|
#define GET_UAA64BE(p, i) __BE64(UAA64(p, i))
|
||||||
|
#define GET_UAA32BE(p, i) __BE32(UAA32(p, i))
|
||||||
|
#define GET_UAA16BE(p, i) __BE16(UAA16(p, i))
|
||||||
|
|
||||||
|
#define GET_UAA64LE(p, i) __LE64(UAA64(p, i))
|
||||||
|
#define GET_UAA32LE(p, i) __LE32(UAA32(p, i))
|
||||||
|
#define GET_UAA16LE(p, i) __LE16(UAA16(p, i))
|
||||||
|
|
||||||
|
#define BE16(x) __BE16(x)
|
||||||
|
#define LE16(x) __LE16(x)
|
||||||
|
#define BE32(x) __BE32(x)
|
||||||
|
#define LE32(x) __LE32(x)
|
||||||
|
#define BE64(x) __BE64(x)
|
||||||
|
#define LE64(x) __LE64(x)
|
||||||
|
|
||||||
|
#else // ! defined(__BYTE_ORDER)
|
||||||
|
|
||||||
|
extern void PUT_UAA64BE(void *p, unsigned long long v, unsigned int i);
|
||||||
|
|
||||||
|
extern void PUT_UAA32BE(void *p, unsigned int v, unsigned int i);
|
||||||
|
|
||||||
|
extern void PUT_UAA16BE(void *p, unsigned short v, unsigned int i);
|
||||||
|
|
||||||
|
|
||||||
|
extern void PUT_UAA64LE(void *p, unsigned long long v, unsigned int i);
|
||||||
|
|
||||||
|
extern void PUT_UAA32LE(void *p, unsigned int v, unsigned int i);
|
||||||
|
|
||||||
|
extern void PUT_UAA16LE(void *p, unsigned short v, unsigned int i);
|
||||||
|
|
||||||
|
|
||||||
|
extern unsigned long long GET_UAA64BE(void *p, unsigned int i);
|
||||||
|
|
||||||
|
extern unsigned int GET_UAA32BE(void *p, unsigned int i);
|
||||||
|
|
||||||
|
extern unsigned short GET_UAA16BE(void *p, unsigned int i);
|
||||||
|
|
||||||
|
|
||||||
|
extern unsigned long long GET_UAA64LE(void *p, unsigned int i);
|
||||||
|
|
||||||
|
extern unsigned int GET_UAA32LE(void *p, unsigned int i);
|
||||||
|
|
||||||
|
extern unsigned short GET_UAA16LE(void *p, unsigned int i);
|
||||||
|
|
||||||
|
|
||||||
|
extern unsigned short BE16(unsigned short x);
|
||||||
|
|
||||||
|
extern unsigned short LE16(unsigned short x);
|
||||||
|
|
||||||
|
extern unsigned int BE32(unsigned int x);
|
||||||
|
|
||||||
|
extern unsigned int LE32(unsigned int x);
|
||||||
|
|
||||||
|
extern unsigned long long BE64(unsigned long long x);
|
||||||
|
|
||||||
|
extern unsigned long long LE64(unsigned long long x);
|
||||||
|
|
||||||
|
#endif // defined(__BYTE_ORDER)
|
||||||
|
|
||||||
|
|
||||||
|
#define PUT_UA64BE(p, v) PUT_UAA64BE(p, v, 0)
|
||||||
|
#define PUT_UA32BE(p, v) PUT_UAA32BE(p, v, 0)
|
||||||
|
#define PUT_UA16BE(p, v) PUT_UAA16BE(p, v, 0)
|
||||||
|
|
||||||
|
#define PUT_UA64LE(p, v) PUT_UAA64LE(p, v, 0)
|
||||||
|
#define PUT_UA32LE(p, v) PUT_UAA32LE(p, v, 0)
|
||||||
|
#define PUT_UA16LE(p, v) PUT_UAA16LE(p, v, 0)
|
||||||
|
|
||||||
|
#define GET_UA64BE(p) GET_UAA64BE(p, 0)
|
||||||
|
#define GET_UA32BE(p) GET_UAA32BE(p, 0)
|
||||||
|
#define GET_UA16BE(p) GET_UAA16BE(p, 0)
|
||||||
|
|
||||||
|
#define GET_UA64LE(p) GET_UAA64LE(p, 0)
|
||||||
|
#define GET_UA32LE(p) GET_UAA32LE(p, 0)
|
||||||
|
#define GET_UA16LE(p) GET_UAA16LE(p, 0)
|
||||||
|
|
||||||
|
#endif // __endian_h
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,254 @@
|
|||||||
|
#
|
||||||
|
# Automatically generated file; DO NOT EDIT.
|
||||||
|
# uClibc-ng 1.0.15 C Library Configuration
|
||||||
|
#
|
||||||
|
# TARGET_alpha is not set
|
||||||
|
# TARGET_arc is not set
|
||||||
|
# TARGET_arm is not set
|
||||||
|
# TARGET_avr32 is not set
|
||||||
|
# TARGET_bfin is not set
|
||||||
|
# TARGET_c6x is not set
|
||||||
|
# TARGET_cris is not set
|
||||||
|
# TARGET_frv is not set
|
||||||
|
# TARGET_h8300 is not set
|
||||||
|
# TARGET_hppa is not set
|
||||||
|
TARGET_i386=y
|
||||||
|
# TARGET_ia64 is not set
|
||||||
|
# TARGET_lm32 is not set
|
||||||
|
# TARGET_m68k is not set
|
||||||
|
# TARGET_metag is not set
|
||||||
|
# TARGET_microblaze is not set
|
||||||
|
# TARGET_mips is not set
|
||||||
|
# TARGET_nios2 is not set
|
||||||
|
# TARGET_or1k is not set
|
||||||
|
# TARGET_powerpc is not set
|
||||||
|
# TARGET_sh is not set
|
||||||
|
# TARGET_sparc is not set
|
||||||
|
# TARGET_x86_64 is not set
|
||||||
|
# TARGET_xtensa is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Target Architecture Features and Options
|
||||||
|
#
|
||||||
|
TARGET_ARCH="i386"
|
||||||
|
FORCE_OPTIONS_FOR_ARCH=y
|
||||||
|
# CONFIG_386 is not set
|
||||||
|
CONFIG_486=y
|
||||||
|
# CONFIG_586 is not set
|
||||||
|
# CONFIG_686 is not set
|
||||||
|
TARGET_SUBARCH="i486"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Using ELF file format
|
||||||
|
#
|
||||||
|
ARCH_HAS_DEPRECATED_SYSCALLS=y
|
||||||
|
ARCH_LITTLE_ENDIAN=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Using Little Endian
|
||||||
|
#
|
||||||
|
ARCH_HAS_MMU=y
|
||||||
|
ARCH_USE_MMU=y
|
||||||
|
UCLIBC_HAS_FLOATS=y
|
||||||
|
UCLIBC_HAS_FPU=y
|
||||||
|
DO_C99_MATH=y
|
||||||
|
DO_XSI_MATH=y
|
||||||
|
# UCLIBC_HAS_FENV is not set
|
||||||
|
# UCLIBC_HAS_LONG_DOUBLE_MATH is not set
|
||||||
|
KERNEL_HEADERS="/root/openadk/target_generic-x86_uclibc-ng/usr/include"
|
||||||
|
HAVE_DOT_CONFIG=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# General Library Settings
|
||||||
|
#
|
||||||
|
DOPIC=y
|
||||||
|
ARCH_HAS_UCONTEXT=y
|
||||||
|
HAVE_SHARED=y
|
||||||
|
# FORCE_SHAREABLE_TEXT_SEGMENTS is not set
|
||||||
|
LDSO_LDD_SUPPORT=y
|
||||||
|
LDSO_CACHE_SUPPORT=y
|
||||||
|
# LDSO_PRELOAD_ENV_SUPPORT is not set
|
||||||
|
# LDSO_PRELOAD_FILE_SUPPORT is not set
|
||||||
|
LDSO_BASE_FILENAME="ld.so"
|
||||||
|
# LDSO_STANDALONE_SUPPORT is not set
|
||||||
|
# LDSO_PRELINK_SUPPORT is not set
|
||||||
|
# UCLIBC_STATIC_LDCONFIG is not set
|
||||||
|
LDSO_RUNPATH=y
|
||||||
|
LDSO_RUNPATH_OF_EXECUTABLE=y
|
||||||
|
LDSO_SAFE_RUNPATH=y
|
||||||
|
LDSO_SEARCH_INTERP_PATH=y
|
||||||
|
LDSO_LD_LIBRARY_PATH=y
|
||||||
|
LDSO_NO_CLEANUP=y
|
||||||
|
UCLIBC_CTOR_DTOR=y
|
||||||
|
# LDSO_GNU_HASH_SUPPORT is not set
|
||||||
|
# HAS_NO_THREADS is not set
|
||||||
|
UCLIBC_HAS_THREADS_NATIVE=y
|
||||||
|
UCLIBC_HAS_THREADS=y
|
||||||
|
UCLIBC_HAS_TLS=y
|
||||||
|
PTHREADS_DEBUG_SUPPORT=y
|
||||||
|
UCLIBC_HAS_SYSLOG=y
|
||||||
|
UCLIBC_HAS_LFS=y
|
||||||
|
MALLOC=y
|
||||||
|
# MALLOC_SIMPLE is not set
|
||||||
|
# MALLOC_STANDARD is not set
|
||||||
|
MALLOC_GLIBC_COMPAT=y
|
||||||
|
# UCLIBC_HAS_OBSTACK is not set
|
||||||
|
UCLIBC_DYNAMIC_ATEXIT=y
|
||||||
|
COMPAT_ATEXIT=y
|
||||||
|
UCLIBC_HAS_UTMPX=y
|
||||||
|
UCLIBC_HAS_UTMP=y
|
||||||
|
UCLIBC_SUSV2_LEGACY=y
|
||||||
|
UCLIBC_SUSV3_LEGACY=y
|
||||||
|
UCLIBC_HAS_CONTEXT_FUNCS=y
|
||||||
|
# UCLIBC_SUSV3_LEGACY_MACROS is not set
|
||||||
|
UCLIBC_SUSV4_LEGACY=y
|
||||||
|
# UCLIBC_STRICT_HEADERS is not set
|
||||||
|
# UCLIBC_HAS_STUBS is not set
|
||||||
|
UCLIBC_HAS_SHADOW=y
|
||||||
|
UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y
|
||||||
|
UCLIBC_HAS___PROGNAME=y
|
||||||
|
UCLIBC_HAS_PTY=y
|
||||||
|
ASSUME_DEVPTS=y
|
||||||
|
UNIX98PTY_ONLY=y
|
||||||
|
UCLIBC_HAS_GETPT=y
|
||||||
|
UCLIBC_HAS_LIBUTIL=y
|
||||||
|
UCLIBC_HAS_TM_EXTENSIONS=y
|
||||||
|
UCLIBC_HAS_TZ_CACHING=y
|
||||||
|
UCLIBC_HAS_TZ_FILE=y
|
||||||
|
UCLIBC_HAS_TZ_FILE_READ_MANY=y
|
||||||
|
UCLIBC_TZ_FILE_PATH="/etc/TZ"
|
||||||
|
UCLIBC_FALLBACK_TO_ETC_LOCALTIME=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Advanced Library Settings
|
||||||
|
#
|
||||||
|
UCLIBC_PWD_BUFFER_SIZE=256
|
||||||
|
UCLIBC_GRP_BUFFER_SIZE=256
|
||||||
|
|
||||||
|
#
|
||||||
|
# Support various families of functions
|
||||||
|
#
|
||||||
|
UCLIBC_LINUX_MODULE_26=y
|
||||||
|
# UCLIBC_LINUX_MODULE_24 is not set
|
||||||
|
UCLIBC_LINUX_SPECIFIC=y
|
||||||
|
UCLIBC_HAS_GNU_ERROR=y
|
||||||
|
UCLIBC_BSD_SPECIFIC=y
|
||||||
|
UCLIBC_HAS_BSD_ERR=y
|
||||||
|
UCLIBC_HAS_OBSOLETE_BSD_SIGNAL=y
|
||||||
|
# UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL is not set
|
||||||
|
# UCLIBC_NTP_LEGACY is not set
|
||||||
|
UCLIBC_SV4_DEPRECATED=y
|
||||||
|
UCLIBC_HAS_REALTIME=y
|
||||||
|
UCLIBC_HAS_ADVANCED_REALTIME=y
|
||||||
|
UCLIBC_HAS_EPOLL=y
|
||||||
|
UCLIBC_HAS_XATTR=y
|
||||||
|
# UCLIBC_HAS_PROFILING is not set
|
||||||
|
UCLIBC_HAS_CRYPT_IMPL=y
|
||||||
|
UCLIBC_HAS_SHA256_CRYPT_IMPL=y
|
||||||
|
# UCLIBC_HAS_SHA512_CRYPT_IMPL is not set
|
||||||
|
UCLIBC_HAS_CRYPT=y
|
||||||
|
UCLIBC_HAS_NETWORK_SUPPORT=y
|
||||||
|
UCLIBC_HAS_SOCKET=y
|
||||||
|
UCLIBC_HAS_IPV4=y
|
||||||
|
UCLIBC_HAS_IPV6=y
|
||||||
|
# UCLIBC_HAS_RPC is not set
|
||||||
|
UCLIBC_USE_NETLINK=y
|
||||||
|
UCLIBC_SUPPORT_AI_ADDRCONFIG=y
|
||||||
|
UCLIBC_HAS_BSD_RES_CLOSE=y
|
||||||
|
UCLIBC_HAS_COMPAT_RES_STATE=y
|
||||||
|
# UCLIBC_HAS_EXTRA_COMPAT_RES_STATE is not set
|
||||||
|
UCLIBC_HAS_RESOLVER_SUPPORT=y
|
||||||
|
UCLIBC_HAS_LIBRESOLV_STUB=y
|
||||||
|
UCLIBC_HAS_LIBNSL_STUB=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# String and Stdio Support
|
||||||
|
#
|
||||||
|
UCLIBC_HAS_STRING_GENERIC_OPT=y
|
||||||
|
UCLIBC_HAS_STRING_ARCH_OPT=y
|
||||||
|
UCLIBC_HAS_STDIO_FUTEXES=y
|
||||||
|
UCLIBC_HAS_CTYPE_TABLES=y
|
||||||
|
UCLIBC_HAS_CTYPE_SIGNED=y
|
||||||
|
# UCLIBC_HAS_CTYPE_UNSAFE is not set
|
||||||
|
UCLIBC_HAS_CTYPE_CHECKED=y
|
||||||
|
# UCLIBC_HAS_CTYPE_ENFORCED is not set
|
||||||
|
UCLIBC_HAS_WCHAR=y
|
||||||
|
# UCLIBC_HAS_LOCALE is not set
|
||||||
|
UCLIBC_HAS_HEXADECIMAL_FLOATS=y
|
||||||
|
UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y
|
||||||
|
UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
|
||||||
|
# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set
|
||||||
|
# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set
|
||||||
|
# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set
|
||||||
|
# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set
|
||||||
|
UCLIBC_HAS_STDIO_BUFSIZ_4096=y
|
||||||
|
# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set
|
||||||
|
UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
|
||||||
|
# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set
|
||||||
|
# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set
|
||||||
|
# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set
|
||||||
|
UCLIBC_HAS_STDIO_GETC_MACRO=y
|
||||||
|
UCLIBC_HAS_STDIO_PUTC_MACRO=y
|
||||||
|
UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y
|
||||||
|
# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set
|
||||||
|
UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y
|
||||||
|
# UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE is not set
|
||||||
|
UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
|
||||||
|
UCLIBC_HAS_PRINTF_M_SPEC=y
|
||||||
|
UCLIBC_HAS_ERRNO_MESSAGES=y
|
||||||
|
# UCLIBC_HAS_SYS_ERRLIST is not set
|
||||||
|
UCLIBC_HAS_SIGNUM_MESSAGES=y
|
||||||
|
# UCLIBC_HAS_SYS_SIGLIST is not set
|
||||||
|
UCLIBC_HAS_GNU_GETOPT=y
|
||||||
|
UCLIBC_HAS_GETOPT_LONG=y
|
||||||
|
UCLIBC_HAS_GNU_GETSUBOPT=y
|
||||||
|
UCLIBC_HAS_ARGP=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Big and Tall
|
||||||
|
#
|
||||||
|
UCLIBC_HAS_REGEX=y
|
||||||
|
# UCLIBC_HAS_REGEX_OLD is not set
|
||||||
|
UCLIBC_HAS_FNMATCH=y
|
||||||
|
# UCLIBC_HAS_FNMATCH_OLD is not set
|
||||||
|
UCLIBC_HAS_WORDEXP=y
|
||||||
|
UCLIBC_HAS_NFTW=y
|
||||||
|
UCLIBC_HAS_FTW=y
|
||||||
|
UCLIBC_HAS_FTS=y
|
||||||
|
UCLIBC_HAS_GLOB=y
|
||||||
|
UCLIBC_HAS_GNU_GLOB=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Library Installation Options
|
||||||
|
#
|
||||||
|
RUNTIME_PREFIX="/"
|
||||||
|
DEVEL_PREFIX="/usr/"
|
||||||
|
MULTILIB_DIR="lib"
|
||||||
|
HARDWIRED_ABSPATH=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Security options
|
||||||
|
#
|
||||||
|
# UCLIBC_BUILD_PIE is not set
|
||||||
|
UCLIBC_HAS_ARC4RANDOM=y
|
||||||
|
# ARC4RANDOM_USES_NODEV is not set
|
||||||
|
# UCLIBC_HAS_SSP is not set
|
||||||
|
UCLIBC_BUILD_RELRO=y
|
||||||
|
UCLIBC_BUILD_NOW=y
|
||||||
|
UCLIBC_BUILD_NOEXECSTACK=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Development/debugging options
|
||||||
|
#
|
||||||
|
CROSS_COMPILER_PREFIX=""
|
||||||
|
UCLIBC_EXTRA_CFLAGS=""
|
||||||
|
# DODEBUG is not set
|
||||||
|
# DOSTRIP is not set
|
||||||
|
# DOASSERTS is not set
|
||||||
|
# SUPPORT_LD_DEBUG is not set
|
||||||
|
# SUPPORT_LD_DEBUG_EARLY is not set
|
||||||
|
# UCLIBC_MALLOC_DEBUGGING is not set
|
||||||
|
# UCLIBC_HAS_BACKTRACE is not set
|
||||||
|
WARNINGS="-Wall"
|
||||||
|
# EXTRA_WARNINGS is not set
|
||||||
|
# DOMULTI is not set
|
||||||
Binary file not shown.
@@ -0,0 +1,263 @@
|
|||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "ifaddrs-musl.h"
|
||||||
|
//#include <syscall.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include "netlink-musl.h"
|
||||||
|
|
||||||
|
#define IFADDRS_HASH_SIZE 64
|
||||||
|
|
||||||
|
/* getifaddrs() reports hardware addresses with PF_PACKET that implies
|
||||||
|
* struct sockaddr_ll. But e.g. Infiniband socket address length is
|
||||||
|
* longer than sockaddr_ll.ssl_addr[8] can hold. Use this hack struct
|
||||||
|
* to extend ssl_addr - callers should be able to still use it. */
|
||||||
|
struct sockaddr_ll_hack {
|
||||||
|
unsigned short sll_family, sll_protocol;
|
||||||
|
int sll_ifindex;
|
||||||
|
unsigned short sll_hatype;
|
||||||
|
unsigned char sll_pkttype, sll_halen;
|
||||||
|
unsigned char sll_addr[24];
|
||||||
|
};
|
||||||
|
|
||||||
|
union sockany {
|
||||||
|
struct sockaddr sa;
|
||||||
|
struct sockaddr_ll_hack ll;
|
||||||
|
struct sockaddr_in v4;
|
||||||
|
struct sockaddr_in6 v6;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ifaddrs_storage {
|
||||||
|
struct ifaddrs ifa;
|
||||||
|
struct ifaddrs_storage *hash_next;
|
||||||
|
union sockany addr, netmask, ifu;
|
||||||
|
unsigned int index;
|
||||||
|
char name[IFNAMSIZ+1];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ifaddrs_ctx {
|
||||||
|
struct ifaddrs_storage *first;
|
||||||
|
struct ifaddrs_storage *last;
|
||||||
|
struct ifaddrs_storage *hash[IFADDRS_HASH_SIZE];
|
||||||
|
};
|
||||||
|
|
||||||
|
void freeifaddrs(struct ifaddrs *ifp)
|
||||||
|
{
|
||||||
|
struct ifaddrs *n;
|
||||||
|
while (ifp) {
|
||||||
|
n = ifp->ifa_next;
|
||||||
|
free(ifp);
|
||||||
|
ifp = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __netlink_enumerate(int fd, unsigned int seq, int type, int af,
|
||||||
|
int (*cb)(void *ctx, struct nlmsghdr *h), void *ctx)
|
||||||
|
{
|
||||||
|
struct nlmsghdr *h;
|
||||||
|
union {
|
||||||
|
uint8_t buf[8192];
|
||||||
|
struct {
|
||||||
|
struct nlmsghdr nlh;
|
||||||
|
struct rtgenmsg g;
|
||||||
|
} req;
|
||||||
|
struct nlmsghdr reply;
|
||||||
|
} u;
|
||||||
|
int r, ret;
|
||||||
|
|
||||||
|
memset(&u.req, 0, sizeof(u.req));
|
||||||
|
u.req.nlh.nlmsg_len = sizeof(u.req);
|
||||||
|
u.req.nlh.nlmsg_type = type;
|
||||||
|
u.req.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST;
|
||||||
|
u.req.nlh.nlmsg_seq = seq;
|
||||||
|
u.req.g.rtgen_family = af;
|
||||||
|
r = send(fd, &u.req, sizeof(u.req), 0);
|
||||||
|
if (r < 0) return r;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
r = recv(fd, u.buf, sizeof(u.buf), MSG_DONTWAIT);
|
||||||
|
if (r <= 0) return -1;
|
||||||
|
for (h = &u.reply; NLMSG_OK(h, (void*)&u.buf[r]); h = NLMSG_NEXT(h)) {
|
||||||
|
if (h->nlmsg_type == NLMSG_DONE) return 0;
|
||||||
|
if (h->nlmsg_type == NLMSG_ERROR) return -1;
|
||||||
|
ret = cb(ctx, h);
|
||||||
|
if (ret) return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int __rtnetlink_enumerate(int link_af, int addr_af, int (*cb)(void *ctx, struct nlmsghdr *h), void *ctx)
|
||||||
|
{
|
||||||
|
int fd, r;
|
||||||
|
|
||||||
|
fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||||
|
if (fd < 0) return -1;
|
||||||
|
r = __netlink_enumerate(fd, 1, RTM_GETLINK, link_af, cb, ctx);
|
||||||
|
if (!r) r = __netlink_enumerate(fd, 2, RTM_GETADDR, addr_af, cb, ctx);
|
||||||
|
close(fd);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void copy_addr(struct sockaddr **r, int af, union sockany *sa, void *addr, size_t addrlen, int ifindex)
|
||||||
|
{
|
||||||
|
uint8_t *dst;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
switch (af) {
|
||||||
|
case AF_INET:
|
||||||
|
dst = (uint8_t*) &sa->v4.sin_addr;
|
||||||
|
len = 4;
|
||||||
|
break;
|
||||||
|
case AF_INET6:
|
||||||
|
dst = (uint8_t*) &sa->v6.sin6_addr;
|
||||||
|
len = 16;
|
||||||
|
if (IN6_IS_ADDR_LINKLOCAL(addr) || IN6_IS_ADDR_MC_LINKLOCAL(addr))
|
||||||
|
sa->v6.sin6_scope_id = ifindex;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (addrlen < len) return;
|
||||||
|
sa->sa.sa_family = af;
|
||||||
|
memcpy(dst, addr, len);
|
||||||
|
*r = &sa->sa;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gen_netmask(struct sockaddr **r, int af, union sockany *sa, int prefixlen)
|
||||||
|
{
|
||||||
|
uint8_t addr[16] = {0};
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (prefixlen > 8*sizeof(addr)) prefixlen = 8*sizeof(addr);
|
||||||
|
i = prefixlen / 8;
|
||||||
|
memset(addr, 0xff, i);
|
||||||
|
if (i < sizeof(addr)) addr[i++] = 0xff << (8 - (prefixlen % 8));
|
||||||
|
copy_addr(r, af, sa, addr, sizeof(addr), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void copy_lladdr(struct sockaddr **r, union sockany *sa, void *addr, size_t addrlen, int ifindex, unsigned short hatype)
|
||||||
|
{
|
||||||
|
if (addrlen > sizeof(sa->ll.sll_addr)) return;
|
||||||
|
sa->ll.sll_family = AF_PACKET;
|
||||||
|
sa->ll.sll_ifindex = ifindex;
|
||||||
|
sa->ll.sll_hatype = hatype;
|
||||||
|
sa->ll.sll_halen = addrlen;
|
||||||
|
memcpy(sa->ll.sll_addr, addr, addrlen);
|
||||||
|
*r = &sa->sa;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int netlink_msg_to_ifaddr(void *pctx, struct nlmsghdr *h)
|
||||||
|
{
|
||||||
|
struct ifaddrs_ctx *ctx = pctx;
|
||||||
|
struct ifaddrs_storage *ifs, *ifs0;
|
||||||
|
struct ifinfomsg *ifi = NLMSG_DATA(h);
|
||||||
|
struct ifaddrmsg *ifa = NLMSG_DATA(h);
|
||||||
|
struct rtattr *rta;
|
||||||
|
int stats_len = 0;
|
||||||
|
|
||||||
|
if (h->nlmsg_type == RTM_NEWLINK) {
|
||||||
|
for (rta = NLMSG_RTA(h, sizeof(*ifi)); NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
|
||||||
|
if (rta->rta_type != IFLA_STATS) continue;
|
||||||
|
stats_len = RTA_DATALEN(rta);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (ifs0 = ctx->hash[ifa->ifa_index % IFADDRS_HASH_SIZE]; ifs0; ifs0 = ifs0->hash_next)
|
||||||
|
if (ifs0->index == ifa->ifa_index)
|
||||||
|
break;
|
||||||
|
if (!ifs0) return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ifs = calloc(1, sizeof(struct ifaddrs_storage) + stats_len);
|
||||||
|
if (ifs == 0) return -1;
|
||||||
|
|
||||||
|
if (h->nlmsg_type == RTM_NEWLINK) {
|
||||||
|
ifs->index = ifi->ifi_index;
|
||||||
|
ifs->ifa.ifa_flags = ifi->ifi_flags;
|
||||||
|
|
||||||
|
for (rta = NLMSG_RTA(h, sizeof(*ifi)); NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
|
||||||
|
switch (rta->rta_type) {
|
||||||
|
case IFLA_IFNAME:
|
||||||
|
if (RTA_DATALEN(rta) < sizeof(ifs->name)) {
|
||||||
|
memcpy(ifs->name, RTA_DATA(rta), RTA_DATALEN(rta));
|
||||||
|
ifs->ifa.ifa_name = ifs->name;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IFLA_ADDRESS:
|
||||||
|
copy_lladdr(&ifs->ifa.ifa_addr, &ifs->addr, RTA_DATA(rta), RTA_DATALEN(rta), ifi->ifi_index, ifi->ifi_type);
|
||||||
|
break;
|
||||||
|
case IFLA_BROADCAST:
|
||||||
|
copy_lladdr(&ifs->ifa.ifa_broadaddr, &ifs->ifu, RTA_DATA(rta), RTA_DATALEN(rta), ifi->ifi_index, ifi->ifi_type);
|
||||||
|
break;
|
||||||
|
case IFLA_STATS:
|
||||||
|
ifs->ifa.ifa_data = (void*)(ifs+1);
|
||||||
|
memcpy(ifs->ifa.ifa_data, RTA_DATA(rta), RTA_DATALEN(rta));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ifs->ifa.ifa_name) {
|
||||||
|
unsigned int bucket = ifs->index % IFADDRS_HASH_SIZE;
|
||||||
|
ifs->hash_next = ctx->hash[bucket];
|
||||||
|
ctx->hash[bucket] = ifs;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ifs->ifa.ifa_name = ifs0->ifa.ifa_name;
|
||||||
|
ifs->ifa.ifa_flags = ifs0->ifa.ifa_flags;
|
||||||
|
for (rta = NLMSG_RTA(h, sizeof(*ifa)); NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
|
||||||
|
switch (rta->rta_type) {
|
||||||
|
case IFA_ADDRESS:
|
||||||
|
/* If ifa_addr is already set we, received an IFA_LOCAL before
|
||||||
|
* so treat this as destination address */
|
||||||
|
if (ifs->ifa.ifa_addr)
|
||||||
|
copy_addr(&ifs->ifa.ifa_dstaddr, ifa->ifa_family, &ifs->ifu, RTA_DATA(rta), RTA_DATALEN(rta), ifa->ifa_index);
|
||||||
|
else
|
||||||
|
copy_addr(&ifs->ifa.ifa_addr, ifa->ifa_family, &ifs->addr, RTA_DATA(rta), RTA_DATALEN(rta), ifa->ifa_index);
|
||||||
|
break;
|
||||||
|
case IFA_BROADCAST:
|
||||||
|
copy_addr(&ifs->ifa.ifa_broadaddr, ifa->ifa_family, &ifs->ifu, RTA_DATA(rta), RTA_DATALEN(rta), ifa->ifa_index);
|
||||||
|
break;
|
||||||
|
case IFA_LOCAL:
|
||||||
|
/* If ifa_addr is set and we get IFA_LOCAL, assume we have
|
||||||
|
* a point-to-point network. Move address to correct field. */
|
||||||
|
if (ifs->ifa.ifa_addr) {
|
||||||
|
ifs->ifu = ifs->addr;
|
||||||
|
ifs->ifa.ifa_dstaddr = &ifs->ifu.sa;
|
||||||
|
memset(&ifs->addr, 0, sizeof(ifs->addr));
|
||||||
|
}
|
||||||
|
copy_addr(&ifs->ifa.ifa_addr, ifa->ifa_family, &ifs->addr, RTA_DATA(rta), RTA_DATALEN(rta), ifa->ifa_index);
|
||||||
|
break;
|
||||||
|
case IFA_LABEL:
|
||||||
|
if (RTA_DATALEN(rta) < sizeof(ifs->name)) {
|
||||||
|
memcpy(ifs->name, RTA_DATA(rta), RTA_DATALEN(rta));
|
||||||
|
ifs->ifa.ifa_name = ifs->name;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ifs->ifa.ifa_addr)
|
||||||
|
gen_netmask(&ifs->ifa.ifa_netmask, ifa->ifa_family, &ifs->netmask, ifa->ifa_prefixlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ifs->ifa.ifa_name) {
|
||||||
|
if (!ctx->first) ctx->first = ifs;
|
||||||
|
if (ctx->last) ctx->last->ifa.ifa_next = &ifs->ifa;
|
||||||
|
ctx->last = ifs;
|
||||||
|
} else {
|
||||||
|
free(ifs);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getifaddrs(struct ifaddrs **ifap)
|
||||||
|
{
|
||||||
|
struct ifaddrs_ctx _ctx, *ctx = &_ctx;
|
||||||
|
int r;
|
||||||
|
memset(ctx, 0, sizeof *ctx);
|
||||||
|
r = __rtnetlink_enumerate(AF_UNSPEC, AF_UNSPEC, netlink_msg_to_ifaddr, ctx);
|
||||||
|
if (r == 0) *ifap = &ctx->first->ifa;
|
||||||
|
else freeifaddrs(&ctx->first->ifa);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
@@ -0,0 +1,369 @@
|
|||||||
|
/*
|
||||||
|
* Helper functions used by other modules
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <errno.h>
|
||||||
|
#endif // _WIN32
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include "helpers.h"
|
||||||
|
#include "output.h"
|
||||||
|
#include "endian.h"
|
||||||
|
#include "shared_globals.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* UCS2 <-> UTF-8 functions
|
||||||
|
* All functions use little endian UCS2 since we only need it to communicate with Windows via RPC
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Convert one character from UTF-8 to UCS2
|
||||||
|
// Returns 0xffff, if utf-8 evaluates to > 0xfffe (outside basic multilingual pane)
|
||||||
|
WCHAR utf8_to_ucs2_char (const unsigned char *input, const unsigned char **end_ptr)
|
||||||
|
{
|
||||||
|
*end_ptr = input;
|
||||||
|
if (input[0] == 0)
|
||||||
|
return ~0;
|
||||||
|
|
||||||
|
if (input[0] < 0x80) {
|
||||||
|
*end_ptr = input + 1;
|
||||||
|
return LE16(input[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((input[0] & 0xE0) == 0xE0) {
|
||||||
|
|
||||||
|
if (input[1] == 0 || input[2] == 0)
|
||||||
|
return ~0;
|
||||||
|
|
||||||
|
*end_ptr = input + 3;
|
||||||
|
|
||||||
|
return
|
||||||
|
LE16((input[0] & 0x0F)<<12 |
|
||||||
|
(input[1] & 0x3F)<<6 |
|
||||||
|
(input[2] & 0x3F));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((input[0] & 0xC0) == 0xC0) {
|
||||||
|
if (input[1] == 0)
|
||||||
|
return ~0;
|
||||||
|
|
||||||
|
*end_ptr = input + 2;
|
||||||
|
|
||||||
|
return
|
||||||
|
LE16((input[0] & 0x1F)<<6 |
|
||||||
|
(input[1] & 0x3F));
|
||||||
|
}
|
||||||
|
return ~0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert one character from UCS2 to UTF-8
|
||||||
|
// Returns length of UTF-8 char (1, 2 or 3) or -1 on error (UTF-16 outside UCS2)
|
||||||
|
// char *utf8 must be large enough to hold 3 bytes
|
||||||
|
int ucs2_to_utf8_char (const WCHAR ucs2_le, char *utf8)
|
||||||
|
{
|
||||||
|
const WCHAR ucs2 = LE16(ucs2_le);
|
||||||
|
|
||||||
|
if (ucs2 < 0x80) {
|
||||||
|
utf8[0] = ucs2;
|
||||||
|
utf8[1] = '\0';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ucs2 >= 0x80 && ucs2 < 0x800) {
|
||||||
|
utf8[0] = (ucs2 >> 6) | 0xC0;
|
||||||
|
utf8[1] = (ucs2 & 0x3F) | 0x80;
|
||||||
|
utf8[2] = '\0';
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ucs2 >= 0x800 && ucs2 < 0xFFFF) {
|
||||||
|
|
||||||
|
if (ucs2 >= 0xD800 && ucs2 <= 0xDFFF) {
|
||||||
|
/* Ill-formed (UTF-16 ouside of BMP) */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
utf8[0] = ((ucs2 >> 12) ) | 0xE0;
|
||||||
|
utf8[1] = ((ucs2 >> 6 ) & 0x3F) | 0x80;
|
||||||
|
utf8[2] = ((ucs2 ) & 0x3F) | 0x80;
|
||||||
|
utf8[3] = '\0';
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Converts UTF8 to UCS2. Returns size in bytes of the converted string or -1 on error
|
||||||
|
size_t utf8_to_ucs2(WCHAR* const ucs2_le, const char* const utf8, const size_t maxucs2, const size_t maxutf8)
|
||||||
|
{
|
||||||
|
const unsigned char* current_utf8 = (unsigned char*)utf8;
|
||||||
|
WCHAR* current_ucs2_le = ucs2_le;
|
||||||
|
|
||||||
|
for (; *current_utf8; current_ucs2_le++)
|
||||||
|
{
|
||||||
|
size_t size = (char*)current_utf8 - utf8;
|
||||||
|
|
||||||
|
if (size >= maxutf8) return (size_t)-1;
|
||||||
|
if (((*current_utf8 & 0xc0) == 0xc0) && (size >= maxutf8 - 1)) return (size_t)-1;
|
||||||
|
if (((*current_utf8 & 0xe0) == 0xe0) && (size >= maxutf8 - 2)) return (size_t)-1;
|
||||||
|
if (current_ucs2_le - ucs2_le >= (intptr_t)maxucs2 - 1) return (size_t)-1;
|
||||||
|
|
||||||
|
*current_ucs2_le = utf8_to_ucs2_char(current_utf8, ¤t_utf8);
|
||||||
|
current_ucs2_le[1] = 0;
|
||||||
|
|
||||||
|
if (*current_ucs2_le == (WCHAR)-1) return (size_t)-1;
|
||||||
|
}
|
||||||
|
return current_ucs2_le - ucs2_le;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Converts UCS2 to UTF-8. Return TRUE or FALSE
|
||||||
|
BOOL ucs2_to_utf8(const WCHAR* const ucs2_le, char* utf8, size_t maxucs2, size_t maxutf8)
|
||||||
|
{
|
||||||
|
char utf8_char[4];
|
||||||
|
const WCHAR* current_ucs2 = ucs2_le;
|
||||||
|
unsigned int index_utf8 = 0;
|
||||||
|
|
||||||
|
for(*utf8 = 0; *current_ucs2; current_ucs2++)
|
||||||
|
{
|
||||||
|
if (current_ucs2 - ucs2_le > (intptr_t)maxucs2) return FALSE;
|
||||||
|
int len = ucs2_to_utf8_char(*current_ucs2, utf8_char);
|
||||||
|
if (index_utf8 + len > maxutf8) return FALSE;
|
||||||
|
strncat(utf8, utf8_char, len);
|
||||||
|
index_utf8+=len;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End of UTF-8 <-> UCS2 conversion */
|
||||||
|
|
||||||
|
|
||||||
|
// Checks, whether a string is a valid integer number between min and max. Returns TRUE or FALSE. Puts int value in *value
|
||||||
|
BOOL stringToInt(const char *const szValue, const unsigned int min, const unsigned int max, unsigned int *const value)
|
||||||
|
{
|
||||||
|
char *nextchar;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
long long result = strtoll(szValue, &nextchar, 10);
|
||||||
|
|
||||||
|
if (errno || result < (long long)min || result > (long long)max || *nextchar)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*value = (unsigned int)result;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Converts a String Guid to a host binary guid in host endianess
|
||||||
|
int_fast8_t string2Uuid(const char *const restrict input, GUID *const restrict guid)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (strlen(input) < GUID_STRING_LENGTH) return FALSE;
|
||||||
|
if (input[8] != '-' || input[13] != '-' || input[18] != '-' || input[23] != '-') return FALSE;
|
||||||
|
|
||||||
|
for (i = 0; i < GUID_STRING_LENGTH; i++)
|
||||||
|
{
|
||||||
|
if (i == 8 || i == 13 || i == 18 || i == 23) continue;
|
||||||
|
|
||||||
|
const char c = toupper((int)input[i]);
|
||||||
|
|
||||||
|
if (c < '0' || c > 'F' || (c > '9' && c < 'A')) return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
char inputCopy[GUID_STRING_LENGTH + 1];
|
||||||
|
strncpy(inputCopy, input, GUID_STRING_LENGTH + 1);
|
||||||
|
inputCopy[8] = inputCopy[13] = inputCopy[18] = 0;
|
||||||
|
|
||||||
|
hex2bin((BYTE*)&guid->Data1, inputCopy, 8);
|
||||||
|
hex2bin((BYTE*)&guid->Data2, inputCopy + 9, 4);
|
||||||
|
hex2bin((BYTE*)&guid->Data3, inputCopy + 14, 4);
|
||||||
|
hex2bin(guid->Data4, input + 19, 16);
|
||||||
|
|
||||||
|
guid->Data1 = BE32(guid->Data1);
|
||||||
|
guid->Data2 = BE16(guid->Data2);
|
||||||
|
guid->Data3 = BE16(guid->Data3);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// convert GUID to little-endian
|
||||||
|
void LEGUID(GUID *const restrict out, const GUID* const restrict in)
|
||||||
|
{
|
||||||
|
#if __BYTE_ORDER != __LITTLE_ENDIAN
|
||||||
|
out->Data1 = LE32(in->Data1);
|
||||||
|
out->Data2 = LE16(in->Data2);
|
||||||
|
out->Data3 = LE16(in->Data3);
|
||||||
|
memcpy(out->Data4, in->Data4, sizeof(out->Data4));
|
||||||
|
#else
|
||||||
|
memcpy(out, in, sizeof(GUID));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Checks a command line argument if it is numeric and between min and max. Returns the numeric value or exits on error
|
||||||
|
__pure unsigned int getOptionArgumentInt(const char o, const unsigned int min, const unsigned int max)
|
||||||
|
{
|
||||||
|
unsigned int result;
|
||||||
|
|
||||||
|
if (!stringToInt(optarg, min, max, &result))
|
||||||
|
{
|
||||||
|
printerrorf("Fatal: Option \"-%c\" must be numeric between %u and %u.\n", o, min, max);
|
||||||
|
exit(!0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Resets getopt() to start parsing from the beginning
|
||||||
|
void optReset(void)
|
||||||
|
{
|
||||||
|
#if __minix__ || defined(__BSD__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
|
||||||
|
optind = 1;
|
||||||
|
optreset = 1; // Makes newer BSD getopt happy
|
||||||
|
#elif defined(__UCLIBC__) // uClibc headers also define __GLIBC__ so be careful here
|
||||||
|
optind = 0; // uClibc seeks compatibility with GLIBC
|
||||||
|
#elif defined(__GLIBC__)
|
||||||
|
optind = 0; // Makes GLIBC getopt happy
|
||||||
|
#else // Standard for most systems
|
||||||
|
optind = 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(USE_MSRPC)
|
||||||
|
|
||||||
|
// Returns a static message buffer containing text for a given Win32 error. Not thread safe (same as strerror)
|
||||||
|
char* win_strerror(const int message)
|
||||||
|
{
|
||||||
|
#define STRERROR_BUFFER_SIZE 256
|
||||||
|
static char buffer[STRERROR_BUFFER_SIZE];
|
||||||
|
|
||||||
|
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, message, 0, buffer, STRERROR_BUFFER_SIZE, NULL);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // defined(_WIN32) || defined(USE_MSRPC)
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* parses an address in the form host:[port] in addr
|
||||||
|
* returns host and port in seperate strings
|
||||||
|
*/
|
||||||
|
void parseAddress(char *const addr, char** szHost, char** szPort)
|
||||||
|
{
|
||||||
|
*szHost = addr;
|
||||||
|
|
||||||
|
# ifndef NO_SOCKETS
|
||||||
|
*szPort = (char*)defaultport;
|
||||||
|
# else // NO_SOCKETS
|
||||||
|
*szPort = "1688";
|
||||||
|
# endif // NO_SOCKETS
|
||||||
|
|
||||||
|
char *lastcolon = strrchr(addr, ':');
|
||||||
|
char *firstcolon = strchr(addr, ':');
|
||||||
|
char *closingbracket = strrchr(addr, ']');
|
||||||
|
|
||||||
|
if (*addr == '[' && closingbracket) //Address in brackets
|
||||||
|
{
|
||||||
|
*closingbracket = 0;
|
||||||
|
(*szHost)++;
|
||||||
|
|
||||||
|
if (closingbracket[1] == ':')
|
||||||
|
*szPort = closingbracket + 2;
|
||||||
|
}
|
||||||
|
else if (firstcolon && firstcolon == lastcolon) //IPv4 address or hostname with port
|
||||||
|
{
|
||||||
|
*firstcolon = 0;
|
||||||
|
*szPort = firstcolon + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Initialize random generator (needs to be done in each thread)
|
||||||
|
void randomNumberInit()
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
srand((unsigned int)(tv.tv_sec ^ tv.tv_usec));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// We always exit immediately if any OOM condition occurs
|
||||||
|
__noreturn void OutOfMemory(void)
|
||||||
|
{
|
||||||
|
errorout("Fatal: Out of memory");
|
||||||
|
exit(!0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void* vlmcsd_malloc(size_t len)
|
||||||
|
{
|
||||||
|
void* buf = malloc(len);
|
||||||
|
if (!buf) OutOfMemory();
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts hex digits to bytes in big-endian order.
|
||||||
|
* Ignores any non-hex characters
|
||||||
|
*/
|
||||||
|
void hex2bin(BYTE *const bin, const char *hex, const size_t maxbin)
|
||||||
|
{
|
||||||
|
static const char *const hexdigits = "0123456789ABCDEF";
|
||||||
|
char* nextchar;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; (i < 16) && utf8_to_ucs2_char((const unsigned char*)hex, (const unsigned char**)&nextchar) != (WCHAR)-1; hex = nextchar)
|
||||||
|
{
|
||||||
|
const char* pos = strchr(hexdigits, toupper((int)*hex));
|
||||||
|
if (!pos) continue;
|
||||||
|
|
||||||
|
if (!(i & 1)) bin[i >> 1] = 0;
|
||||||
|
bin[i >> 1] |= (char)(pos - hexdigits);
|
||||||
|
if (!(i & 1)) bin[i >> 1] <<= 4;
|
||||||
|
i++;
|
||||||
|
if (i >> 1 > maxbin) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
__pure BOOL getArgumentBool(int_fast8_t *result, const char *const argument)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
!strncasecmp(argument, "true", 4) ||
|
||||||
|
!strncasecmp(argument, "on", 2) ||
|
||||||
|
!strncasecmp(argument, "yes", 3) ||
|
||||||
|
!strncasecmp(argument, "1", 1)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
*result = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
!strncasecmp(argument, "false", 5) ||
|
||||||
|
!strncasecmp(argument, "off", 3) ||
|
||||||
|
!strncasecmp(argument, "no", 2) ||
|
||||||
|
!strncasecmp(argument, "0", 1)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
*result = FALSE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#ifndef HELPERS_H
|
||||||
|
#define HELPERS_H
|
||||||
|
|
||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
#define GUID_LE 0
|
||||||
|
#define GUID_BE 1
|
||||||
|
#define GUID_SWAP 2
|
||||||
|
|
||||||
|
BOOL stringToInt(const char *const szValue, const unsigned int min, const unsigned int max, unsigned int *const value);
|
||||||
|
unsigned int getOptionArgumentInt(const char o, const unsigned int min, const unsigned int max);
|
||||||
|
void optReset(void);
|
||||||
|
char* win_strerror(const int message);
|
||||||
|
int ucs2_to_utf8_char (const WCHAR ucs2_le, char *utf8);
|
||||||
|
size_t utf8_to_ucs2(WCHAR* const ucs2_le, const char* const utf8, const size_t maxucs2, const size_t maxutf8);
|
||||||
|
WCHAR utf8_to_ucs2_char (const unsigned char * input, const unsigned char ** end_ptr);
|
||||||
|
BOOL ucs2_to_utf8(const WCHAR* const ucs2_le, char* utf8, size_t maxucs2, size_t maxutf8);
|
||||||
|
int_fast8_t string2Uuid(const char *const restrict input, GUID *const restrict guid);
|
||||||
|
void randomNumberInit();
|
||||||
|
void LEGUID(GUID *const restrict result, const GUID* const restrict guid);
|
||||||
|
void parseAddress(char *const addr, char** szHost, char** szPort);
|
||||||
|
__noreturn void OutOfMemory(void);
|
||||||
|
void* vlmcsd_malloc(size_t len);
|
||||||
|
void hex2bin(BYTE *const bin, const char *hex, const size_t maxbin);
|
||||||
|
__pure BOOL getArgumentBool(int_fast8_t *result, const char *const argument);
|
||||||
|
|
||||||
|
|
||||||
|
#endif // HELPERS_H
|
||||||
@@ -0,0 +1,600 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2013, Kenneth MacKay
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ifaddrs-android.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <net/if_arp.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <linux/netlink.h>
|
||||||
|
#include <linux/rtnetlink.h>
|
||||||
|
|
||||||
|
typedef struct NetlinkList
|
||||||
|
{
|
||||||
|
struct NetlinkList *m_next;
|
||||||
|
struct nlmsghdr *m_data;
|
||||||
|
unsigned int m_size;
|
||||||
|
} NetlinkList;
|
||||||
|
|
||||||
|
static int netlink_socket(void)
|
||||||
|
{
|
||||||
|
int l_socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||||
|
if(l_socket < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sockaddr_nl l_addr;
|
||||||
|
memset(&l_addr, 0, sizeof(l_addr));
|
||||||
|
l_addr.nl_family = AF_NETLINK;
|
||||||
|
if(bind(l_socket, (struct sockaddr *)&l_addr, sizeof(l_addr)) < 0)
|
||||||
|
{
|
||||||
|
close(l_socket);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return l_socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int netlink_send(int p_socket, int p_request)
|
||||||
|
{
|
||||||
|
char l_buffer[NLMSG_ALIGN(sizeof(struct nlmsghdr)) + NLMSG_ALIGN(sizeof(struct rtgenmsg))];
|
||||||
|
memset(l_buffer, 0, sizeof(l_buffer));
|
||||||
|
struct nlmsghdr *l_hdr = (struct nlmsghdr *)l_buffer;
|
||||||
|
struct rtgenmsg *l_msg = (struct rtgenmsg *)NLMSG_DATA(l_hdr);
|
||||||
|
|
||||||
|
l_hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*l_msg));
|
||||||
|
l_hdr->nlmsg_type = p_request;
|
||||||
|
l_hdr->nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
|
||||||
|
l_hdr->nlmsg_pid = 0;
|
||||||
|
l_hdr->nlmsg_seq = p_socket;
|
||||||
|
l_msg->rtgen_family = AF_UNSPEC;
|
||||||
|
|
||||||
|
struct sockaddr_nl l_addr;
|
||||||
|
memset(&l_addr, 0, sizeof(l_addr));
|
||||||
|
l_addr.nl_family = AF_NETLINK;
|
||||||
|
return (sendto(p_socket, l_hdr, l_hdr->nlmsg_len, 0, (struct sockaddr *)&l_addr, sizeof(l_addr)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int netlink_recv(int p_socket, void *p_buffer, size_t p_len)
|
||||||
|
{
|
||||||
|
struct msghdr l_msg;
|
||||||
|
struct iovec l_iov = { p_buffer, p_len };
|
||||||
|
struct sockaddr_nl l_addr;
|
||||||
|
//int l_result;
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
l_msg.msg_name = (void *)&l_addr;
|
||||||
|
l_msg.msg_namelen = sizeof(l_addr);
|
||||||
|
l_msg.msg_iov = &l_iov;
|
||||||
|
l_msg.msg_iovlen = 1;
|
||||||
|
l_msg.msg_control = NULL;
|
||||||
|
l_msg.msg_controllen = 0;
|
||||||
|
l_msg.msg_flags = 0;
|
||||||
|
int l_result = recvmsg(p_socket, &l_msg, 0);
|
||||||
|
|
||||||
|
if(l_result < 0)
|
||||||
|
{
|
||||||
|
if(errno == EINTR)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_msg.msg_flags & MSG_TRUNC)
|
||||||
|
{ // buffer was too small
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return l_result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct nlmsghdr *getNetlinkResponse(int p_socket, int *p_size, int *p_done)
|
||||||
|
{
|
||||||
|
size_t l_size = 4096;
|
||||||
|
void *l_buffer = NULL;
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
free(l_buffer);
|
||||||
|
l_buffer = malloc(l_size);
|
||||||
|
|
||||||
|
int l_read = netlink_recv(p_socket, l_buffer, l_size);
|
||||||
|
*p_size = l_read;
|
||||||
|
if(l_read == -2)
|
||||||
|
{
|
||||||
|
free(l_buffer);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if(l_read >= 0)
|
||||||
|
{
|
||||||
|
pid_t l_pid = getpid();
|
||||||
|
struct nlmsghdr *l_hdr;
|
||||||
|
for(l_hdr = (struct nlmsghdr *)l_buffer; NLMSG_OK(l_hdr, (unsigned int)l_read); l_hdr = (struct nlmsghdr *)NLMSG_NEXT(l_hdr, l_read))
|
||||||
|
{
|
||||||
|
if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_hdr->nlmsg_type == NLMSG_DONE)
|
||||||
|
{
|
||||||
|
*p_done = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_hdr->nlmsg_type == NLMSG_ERROR)
|
||||||
|
{
|
||||||
|
free(l_buffer);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return l_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
l_size *= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static NetlinkList *newListItem(struct nlmsghdr *p_data, unsigned int p_size)
|
||||||
|
{
|
||||||
|
NetlinkList *l_item = malloc(sizeof(NetlinkList));
|
||||||
|
l_item->m_next = NULL;
|
||||||
|
l_item->m_data = p_data;
|
||||||
|
l_item->m_size = p_size;
|
||||||
|
return l_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void freeResultList(NetlinkList *p_list)
|
||||||
|
{
|
||||||
|
NetlinkList *l_cur;
|
||||||
|
while(p_list)
|
||||||
|
{
|
||||||
|
l_cur = p_list;
|
||||||
|
p_list = p_list->m_next;
|
||||||
|
free(l_cur->m_data);
|
||||||
|
free(l_cur);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static NetlinkList *getResultList(int p_socket, int p_request)
|
||||||
|
{
|
||||||
|
if(netlink_send(p_socket, p_request) < 0)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetlinkList *l_list = NULL;
|
||||||
|
NetlinkList *l_end = NULL;
|
||||||
|
int l_size;
|
||||||
|
int l_done = 0;
|
||||||
|
while(!l_done)
|
||||||
|
{
|
||||||
|
struct nlmsghdr *l_hdr = getNetlinkResponse(p_socket, &l_size, &l_done);
|
||||||
|
if(!l_hdr)
|
||||||
|
{ // error
|
||||||
|
freeResultList(l_list);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetlinkList *l_item = newListItem(l_hdr, l_size);
|
||||||
|
if(!l_list)
|
||||||
|
{
|
||||||
|
l_list = l_item;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l_end->m_next = l_item;
|
||||||
|
}
|
||||||
|
l_end = l_item;
|
||||||
|
}
|
||||||
|
return l_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t maxSize(size_t a, size_t b)
|
||||||
|
{
|
||||||
|
return (a > b ? a : b);
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t calcAddrLen(sa_family_t p_family, int p_dataSize)
|
||||||
|
{
|
||||||
|
switch(p_family)
|
||||||
|
{
|
||||||
|
case AF_INET:
|
||||||
|
return sizeof(struct sockaddr_in);
|
||||||
|
case AF_INET6:
|
||||||
|
return sizeof(struct sockaddr_in6);
|
||||||
|
case AF_PACKET:
|
||||||
|
return maxSize(sizeof(struct sockaddr_ll), offsetof(struct sockaddr_ll, sll_addr) + p_dataSize);
|
||||||
|
default:
|
||||||
|
return maxSize(sizeof(struct sockaddr), offsetof(struct sockaddr, sa_data) + p_dataSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void makeSockaddr(sa_family_t p_family, struct sockaddr *p_dest, void *p_data, size_t p_size)
|
||||||
|
{
|
||||||
|
switch(p_family)
|
||||||
|
{
|
||||||
|
case AF_INET:
|
||||||
|
memcpy(&((struct sockaddr_in*)p_dest)->sin_addr, p_data, p_size);
|
||||||
|
break;
|
||||||
|
case AF_INET6:
|
||||||
|
memcpy(&((struct sockaddr_in6*)p_dest)->sin6_addr, p_data, p_size);
|
||||||
|
break;
|
||||||
|
case AF_PACKET:
|
||||||
|
memcpy(((struct sockaddr_ll*)p_dest)->sll_addr, p_data, p_size);
|
||||||
|
((struct sockaddr_ll*)p_dest)->sll_halen = p_size;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
memcpy(p_dest->sa_data, p_data, p_size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p_dest->sa_family = p_family;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void addToEnd(struct ifaddrs **p_resultList, struct ifaddrs *p_entry)
|
||||||
|
{
|
||||||
|
if(!*p_resultList)
|
||||||
|
{
|
||||||
|
*p_resultList = p_entry;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct ifaddrs *l_cur = *p_resultList;
|
||||||
|
while(l_cur->ifa_next)
|
||||||
|
{
|
||||||
|
l_cur = l_cur->ifa_next;
|
||||||
|
}
|
||||||
|
l_cur->ifa_next = p_entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void interpretLink(struct nlmsghdr *p_hdr, struct ifaddrs **p_links, struct ifaddrs **p_resultList)
|
||||||
|
{
|
||||||
|
struct ifinfomsg *l_info = (struct ifinfomsg *)NLMSG_DATA(p_hdr);
|
||||||
|
|
||||||
|
size_t l_nameSize = 0;
|
||||||
|
size_t l_addrSize = 0;
|
||||||
|
size_t l_dataSize = 0;
|
||||||
|
|
||||||
|
size_t l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifinfomsg));
|
||||||
|
struct rtattr *l_rta;
|
||||||
|
for(l_rta = (struct rtattr *)(((char *)l_info) + NLMSG_ALIGN(sizeof(struct ifinfomsg))); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize))
|
||||||
|
{
|
||||||
|
//void *l_rtaData = RTA_DATA(l_rta);
|
||||||
|
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta);
|
||||||
|
switch(l_rta->rta_type)
|
||||||
|
{
|
||||||
|
case IFLA_ADDRESS:
|
||||||
|
case IFLA_BROADCAST:
|
||||||
|
l_addrSize += NLMSG_ALIGN(calcAddrLen(AF_PACKET, l_rtaDataSize));
|
||||||
|
break;
|
||||||
|
case IFLA_IFNAME:
|
||||||
|
l_nameSize += NLMSG_ALIGN(l_rtaSize + 1);
|
||||||
|
break;
|
||||||
|
case IFLA_STATS:
|
||||||
|
l_dataSize += NLMSG_ALIGN(l_rtaSize);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ifaddrs *l_entry = malloc(sizeof(struct ifaddrs) + l_nameSize + l_addrSize + l_dataSize);
|
||||||
|
memset(l_entry, 0, sizeof(struct ifaddrs));
|
||||||
|
l_entry->ifa_name = "";
|
||||||
|
|
||||||
|
char *l_name = ((char *)l_entry) + sizeof(struct ifaddrs);
|
||||||
|
char *l_addr = l_name + l_nameSize;
|
||||||
|
char *l_data = l_addr + l_addrSize;
|
||||||
|
|
||||||
|
l_entry->ifa_flags = l_info->ifi_flags;
|
||||||
|
|
||||||
|
l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifinfomsg));
|
||||||
|
for(l_rta = (struct rtattr *)(((char *)l_info) + NLMSG_ALIGN(sizeof(struct ifinfomsg))); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize))
|
||||||
|
{
|
||||||
|
void *l_rtaData = RTA_DATA(l_rta);
|
||||||
|
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta);
|
||||||
|
switch(l_rta->rta_type)
|
||||||
|
{
|
||||||
|
case IFLA_ADDRESS:
|
||||||
|
case IFLA_BROADCAST:
|
||||||
|
{
|
||||||
|
size_t l_addrLen = calcAddrLen(AF_PACKET, l_rtaDataSize);
|
||||||
|
makeSockaddr(AF_PACKET, (struct sockaddr *)l_addr, l_rtaData, l_rtaDataSize);
|
||||||
|
((struct sockaddr_ll *)l_addr)->sll_ifindex = l_info->ifi_index;
|
||||||
|
((struct sockaddr_ll *)l_addr)->sll_hatype = l_info->ifi_type;
|
||||||
|
if(l_rta->rta_type == IFLA_ADDRESS)
|
||||||
|
{
|
||||||
|
l_entry->ifa_addr = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l_entry->ifa_broadaddr = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
l_addr += NLMSG_ALIGN(l_addrLen);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IFLA_IFNAME:
|
||||||
|
strncpy(l_name, l_rtaData, l_rtaDataSize);
|
||||||
|
l_name[l_rtaDataSize] = '\0';
|
||||||
|
l_entry->ifa_name = l_name;
|
||||||
|
break;
|
||||||
|
case IFLA_STATS:
|
||||||
|
memcpy(l_data, l_rtaData, l_rtaDataSize);
|
||||||
|
l_entry->ifa_data = l_data;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addToEnd(p_resultList, l_entry);
|
||||||
|
p_links[l_info->ifi_index - 1] = l_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_links, struct ifaddrs **p_resultList)
|
||||||
|
{
|
||||||
|
struct ifaddrmsg *l_info = (struct ifaddrmsg *)NLMSG_DATA(p_hdr);
|
||||||
|
|
||||||
|
size_t l_nameSize = 0;
|
||||||
|
size_t l_addrSize = 0;
|
||||||
|
|
||||||
|
int l_addedNetmask = 0;
|
||||||
|
|
||||||
|
size_t l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg));
|
||||||
|
struct rtattr *l_rta;
|
||||||
|
for(l_rta = (struct rtattr *)(((char *)l_info) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize))
|
||||||
|
{
|
||||||
|
//void *l_rtaData = RTA_DATA(l_rta);
|
||||||
|
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta);
|
||||||
|
if(l_info->ifa_family == AF_PACKET)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(l_rta->rta_type)
|
||||||
|
{
|
||||||
|
case IFA_ADDRESS:
|
||||||
|
case IFA_LOCAL:
|
||||||
|
if((l_info->ifa_family == AF_INET || l_info->ifa_family == AF_INET6) && !l_addedNetmask)
|
||||||
|
{ // make room for netmask
|
||||||
|
l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize));
|
||||||
|
l_addedNetmask = 1;
|
||||||
|
}
|
||||||
|
case IFA_BROADCAST:
|
||||||
|
l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize));
|
||||||
|
break;
|
||||||
|
case IFA_LABEL:
|
||||||
|
l_nameSize += NLMSG_ALIGN(l_rtaSize + 1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ifaddrs *l_entry = malloc(sizeof(struct ifaddrs) + l_nameSize + l_addrSize);
|
||||||
|
memset(l_entry, 0, sizeof(struct ifaddrs));
|
||||||
|
l_entry->ifa_name = p_links[l_info->ifa_index - 1]->ifa_name;
|
||||||
|
|
||||||
|
char *l_name = ((char *)l_entry) + sizeof(struct ifaddrs);
|
||||||
|
char *l_addr = l_name + l_nameSize;
|
||||||
|
|
||||||
|
l_entry->ifa_flags = l_info->ifa_flags | p_links[l_info->ifa_index - 1]->ifa_flags;
|
||||||
|
|
||||||
|
l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg));
|
||||||
|
for(l_rta = (struct rtattr *)(((char *)l_info) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize))
|
||||||
|
{
|
||||||
|
void *l_rtaData = RTA_DATA(l_rta);
|
||||||
|
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta);
|
||||||
|
switch(l_rta->rta_type)
|
||||||
|
{
|
||||||
|
case IFA_ADDRESS:
|
||||||
|
case IFA_BROADCAST:
|
||||||
|
case IFA_LOCAL:
|
||||||
|
{
|
||||||
|
size_t l_addrLen = calcAddrLen(l_info->ifa_family, l_rtaDataSize);
|
||||||
|
makeSockaddr(l_info->ifa_family, (struct sockaddr *)l_addr, l_rtaData, l_rtaDataSize);
|
||||||
|
if(l_info->ifa_family == AF_INET6)
|
||||||
|
{
|
||||||
|
if(IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)l_rtaData) || IN6_IS_ADDR_MC_LINKLOCAL((struct in6_addr *)l_rtaData))
|
||||||
|
{
|
||||||
|
((struct sockaddr_in6 *)l_addr)->sin6_scope_id = l_info->ifa_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_rta->rta_type == IFA_ADDRESS)
|
||||||
|
{ // apparently in a point-to-point network IFA_ADDRESS contains the dest address and IFA_LOCAL contains the local address
|
||||||
|
if(l_entry->ifa_addr)
|
||||||
|
{
|
||||||
|
l_entry->ifa_dstaddr = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l_entry->ifa_addr = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(l_rta->rta_type == IFA_LOCAL)
|
||||||
|
{
|
||||||
|
if(l_entry->ifa_addr)
|
||||||
|
{
|
||||||
|
l_entry->ifa_dstaddr = l_entry->ifa_addr;
|
||||||
|
}
|
||||||
|
l_entry->ifa_addr = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l_entry->ifa_broadaddr = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
l_addr += NLMSG_ALIGN(l_addrLen);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IFA_LABEL:
|
||||||
|
strncpy(l_name, l_rtaData, l_rtaDataSize);
|
||||||
|
l_name[l_rtaDataSize] = '\0';
|
||||||
|
l_entry->ifa_name = l_name;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_entry->ifa_addr && (l_entry->ifa_addr->sa_family == AF_INET || l_entry->ifa_addr->sa_family == AF_INET6))
|
||||||
|
{
|
||||||
|
unsigned l_maxPrefix = (l_entry->ifa_addr->sa_family == AF_INET ? 32 : 128);
|
||||||
|
unsigned l_prefix = (l_info->ifa_prefixlen > l_maxPrefix ? l_maxPrefix : l_info->ifa_prefixlen);
|
||||||
|
char l_mask[16] = {0};
|
||||||
|
unsigned i;
|
||||||
|
for(i=0; i<(l_prefix/8); ++i)
|
||||||
|
{
|
||||||
|
l_mask[i] = 0xff;
|
||||||
|
}
|
||||||
|
l_mask[i] = 0xff << (8 - (l_prefix % 8));
|
||||||
|
|
||||||
|
makeSockaddr(l_entry->ifa_addr->sa_family, (struct sockaddr *)l_addr, l_mask, l_maxPrefix / 8);
|
||||||
|
l_entry->ifa_netmask = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
addToEnd(p_resultList, l_entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void interpret(int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_links, struct ifaddrs **p_resultList)
|
||||||
|
{
|
||||||
|
pid_t l_pid = getpid();
|
||||||
|
for(; p_netlinkList; p_netlinkList = p_netlinkList->m_next)
|
||||||
|
{
|
||||||
|
unsigned int l_nlsize = p_netlinkList->m_size;
|
||||||
|
struct nlmsghdr *l_hdr;
|
||||||
|
for(l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize))
|
||||||
|
{
|
||||||
|
if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_hdr->nlmsg_type == NLMSG_DONE)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_hdr->nlmsg_type == RTM_NEWLINK)
|
||||||
|
{
|
||||||
|
interpretLink(l_hdr, p_links, p_resultList);
|
||||||
|
}
|
||||||
|
else if(l_hdr->nlmsg_type == RTM_NEWADDR)
|
||||||
|
{
|
||||||
|
interpretAddr(l_hdr, p_links, p_resultList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned countLinks(int p_socket, NetlinkList *p_netlinkList)
|
||||||
|
{
|
||||||
|
unsigned l_links = 0;
|
||||||
|
pid_t l_pid = getpid();
|
||||||
|
for(; p_netlinkList; p_netlinkList = p_netlinkList->m_next)
|
||||||
|
{
|
||||||
|
unsigned int l_nlsize = p_netlinkList->m_size;
|
||||||
|
struct nlmsghdr *l_hdr;
|
||||||
|
for(l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize))
|
||||||
|
{
|
||||||
|
if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_hdr->nlmsg_type == NLMSG_DONE)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_hdr->nlmsg_type == RTM_NEWLINK)
|
||||||
|
{
|
||||||
|
++l_links;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return l_links;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getifaddrs(struct ifaddrs **ifap)
|
||||||
|
{
|
||||||
|
if(!ifap)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*ifap = NULL;
|
||||||
|
|
||||||
|
int l_socket = netlink_socket();
|
||||||
|
if(l_socket < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetlinkList *l_linkResults = getResultList(l_socket, RTM_GETLINK);
|
||||||
|
if(!l_linkResults)
|
||||||
|
{
|
||||||
|
close(l_socket);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetlinkList *l_addrResults = getResultList(l_socket, RTM_GETADDR);
|
||||||
|
if(!l_addrResults)
|
||||||
|
{
|
||||||
|
close(l_socket);
|
||||||
|
freeResultList(l_linkResults);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned l_numLinks = countLinks(l_socket, l_linkResults) + countLinks(l_socket, l_addrResults);
|
||||||
|
struct ifaddrs *l_links[l_numLinks];
|
||||||
|
memset(l_links, 0, l_numLinks * sizeof(struct ifaddrs *));
|
||||||
|
|
||||||
|
interpret(l_socket, l_linkResults, l_links, ifap);
|
||||||
|
interpret(l_socket, l_addrResults, l_links, ifap);
|
||||||
|
|
||||||
|
freeResultList(l_linkResults);
|
||||||
|
freeResultList(l_addrResults);
|
||||||
|
close(l_socket);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void freeifaddrs(struct ifaddrs *ifa)
|
||||||
|
{
|
||||||
|
struct ifaddrs *l_cur;
|
||||||
|
while(ifa)
|
||||||
|
{
|
||||||
|
l_cur = ifa;
|
||||||
|
ifa = ifa->ifa_next;
|
||||||
|
free(l_cur);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1995, 1999
|
||||||
|
* Berkeley Software Design, Inc. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !__ANDROID__
|
||||||
|
#error ifaddrs-android only works with Android
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _IFADDRS_H_
|
||||||
|
#define _IFADDRS_H_
|
||||||
|
|
||||||
|
struct ifaddrs {
|
||||||
|
struct ifaddrs *ifa_next;
|
||||||
|
char *ifa_name;
|
||||||
|
unsigned int ifa_flags;
|
||||||
|
struct sockaddr *ifa_addr;
|
||||||
|
struct sockaddr *ifa_netmask;
|
||||||
|
struct sockaddr *ifa_dstaddr;
|
||||||
|
void *ifa_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This may have been defined in <net/if.h>. Note that if <net/if.h> is
|
||||||
|
* to be included it must be included before this header file.
|
||||||
|
*/
|
||||||
|
#ifndef ifa_broadaddr
|
||||||
|
#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
extern int getifaddrs(struct ifaddrs **ifap);
|
||||||
|
extern void freeifaddrs(struct ifaddrs *ifa);
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
#ifndef _IFADDRS_H
|
||||||
|
#define _IFADDRS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !__linux__
|
||||||
|
#error ifaddrs-musl.h only works with a Linux kernel
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __ANDROID__
|
||||||
|
#error ifaddrs-musl.h does not work with Android
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <features.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
struct ifaddrs {
|
||||||
|
struct ifaddrs *ifa_next;
|
||||||
|
char *ifa_name;
|
||||||
|
unsigned ifa_flags;
|
||||||
|
struct sockaddr *ifa_addr;
|
||||||
|
struct sockaddr *ifa_netmask;
|
||||||
|
union {
|
||||||
|
struct sockaddr *ifu_broadaddr;
|
||||||
|
struct sockaddr *ifu_dstaddr;
|
||||||
|
} ifa_ifu;
|
||||||
|
void *ifa_data;
|
||||||
|
};
|
||||||
|
#define ifa_broadaddr ifa_ifu.ifu_broadaddr
|
||||||
|
#define ifa_dstaddr ifa_ifu.ifu_dstaddr
|
||||||
|
|
||||||
|
void freeifaddrs(struct ifaddrs *ifp);
|
||||||
|
int getifaddrs(struct ifaddrs **ifap);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,291 @@
|
|||||||
|
#ifndef __kms_h
|
||||||
|
#define __kms_h
|
||||||
|
|
||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "types.h"
|
||||||
|
//
|
||||||
|
// REQUEST... types are actually fixed size
|
||||||
|
// RESPONSE... size may vary, defined here is max possible size
|
||||||
|
//
|
||||||
|
|
||||||
|
#define MAX_RESPONSE_SIZE 384
|
||||||
|
#define PID_BUFFER_SIZE 64
|
||||||
|
#define MAX_REQUEST_SIZE sizeof(REQUEST_V6)
|
||||||
|
#define WORKSTATION_NAME_BUFFER 64
|
||||||
|
|
||||||
|
// Constants for V6 time stamp interval
|
||||||
|
#define TIME_C1 0x00000022816889BDULL
|
||||||
|
#define TIME_C2 0x000000208CBAB5EDULL
|
||||||
|
#define TIME_C3 0x3156CD5AC628477AULL
|
||||||
|
|
||||||
|
#define VERSION_INFO union \
|
||||||
|
{ \
|
||||||
|
DWORD Version;\
|
||||||
|
struct { \
|
||||||
|
WORD MinorVer; \
|
||||||
|
WORD MajorVer; \
|
||||||
|
} /*__packed*/; \
|
||||||
|
} /*__packed*/
|
||||||
|
|
||||||
|
// Aliases for various KMS struct members
|
||||||
|
#define IsClientVM VMInfo
|
||||||
|
#define GraceTime BindingExpiration
|
||||||
|
#define MinutesRemaingInCurrentStatus BindingExpiration
|
||||||
|
#define ID ActID
|
||||||
|
#define ApplicationID AppID
|
||||||
|
#define SkuId ActID
|
||||||
|
#define KmsId KMSID
|
||||||
|
#define ClientMachineId CMID
|
||||||
|
#define MinimumClients N_Policy
|
||||||
|
#define TimeStamp ClientTime
|
||||||
|
#define PreviousCLientMachineId CMID_prev
|
||||||
|
#define Salt IV
|
||||||
|
#define XorSalt XoredIVs
|
||||||
|
#define ActivationInterval VLActivationInterval
|
||||||
|
#define RenewalInterval VLRenewalInterval
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
VERSION_INFO;
|
||||||
|
DWORD VMInfo; // 0 = client is bare metal / 1 = client is VM
|
||||||
|
DWORD LicenseStatus; // 0 = Unlicensed, 1 = Licensed (Activated), 2 = OOB grace, 3 = OOT grace, 4 = NonGenuineGrace, 5 = Notification, 6 = extended grace
|
||||||
|
DWORD BindingExpiration; // Expiration of the current status in minutes (e.g. when KMS activation or OOB grace expires).
|
||||||
|
GUID AppID; // Can currently be Windows, Office2010 or Office2013 (see kms.c, table AppList).
|
||||||
|
GUID ActID; // Most detailed product list. One product key per ActID (see kms.c, table ExtendedProductList). Is ignored by KMS server.
|
||||||
|
GUID KMSID; // This is actually what the KMS server uses to grant or refuse activation (see kms.c, table BasicProductList).
|
||||||
|
GUID CMID; // Client machine id. Used by the KMS server for counting minimum clients.
|
||||||
|
DWORD N_Policy; // Minimum clients required for activation.
|
||||||
|
FILETIME ClientTime; // Current client time.
|
||||||
|
GUID CMID_prev; // previous client machine id. All zeros, if it never changed.
|
||||||
|
WCHAR WorkstationName[64]; // Workstation name. FQDN if available, NetBIOS otherwise.
|
||||||
|
} /*__packed*/ REQUEST;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
VERSION_INFO;
|
||||||
|
DWORD PIDSize; // Size of PIDData in bytes.
|
||||||
|
WCHAR KmsPID[PID_BUFFER_SIZE]; // ePID (must include terminating zero)
|
||||||
|
GUID CMID; // Client machine id. Must be the same as in request.
|
||||||
|
FILETIME ClientTime; // Current client time. Must be the same as in request.
|
||||||
|
DWORD Count; // Current activated machines. KMS server counts up to N_Policy << 1 then stops
|
||||||
|
DWORD VLActivationInterval; // Time in minutes when clients should retry activation if it was unsuccessful (default 2 hours)
|
||||||
|
DWORD VLRenewalInterval; // Time in minutes when clients should renew KMS activation (default 7 days)
|
||||||
|
} /*__packed*/ RESPONSE;
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
typedef struct {
|
||||||
|
VERSION_INFO;
|
||||||
|
DWORD PIDSize;
|
||||||
|
WCHAR KmsPID[49]; // Set this to the ePID length you want to debug
|
||||||
|
GUID CMID;
|
||||||
|
FILETIME ClientTime;
|
||||||
|
DWORD Count;
|
||||||
|
DWORD VLActivationInterval;
|
||||||
|
DWORD VLRenewalInterval;
|
||||||
|
} __packed RESPONSE_DEBUG;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
REQUEST RequestBase; // Base request
|
||||||
|
BYTE MAC[16]; // Aes 160 bit CMAC
|
||||||
|
} /*__packed*/ REQUEST_V4;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
RESPONSE ResponseBase; // Base response
|
||||||
|
BYTE MAC[16]; // Aes 160 bit CMAC
|
||||||
|
} /*__packed*/ RESPONSE_V4;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
VERSION_INFO; // unencrypted version info
|
||||||
|
BYTE IV[16]; // IV
|
||||||
|
REQUEST RequestBase; // Base Request
|
||||||
|
BYTE Pad[4]; // since this struct is fixed, we use fixed PKCS pad bytes
|
||||||
|
} /*__packed*/ REQUEST_V5;
|
||||||
|
|
||||||
|
typedef REQUEST_V5 REQUEST_V6; // v5 and v6 requests are identical
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
VERSION_INFO;
|
||||||
|
BYTE IV[16];
|
||||||
|
RESPONSE ResponseBase;
|
||||||
|
BYTE RandomXoredIVs[16]; // If RequestIV was used for decryption: Random ^ decrypted Request IV ^ ResponseIV. If NULL IV was used for decryption: Random ^ decrypted Request IV
|
||||||
|
BYTE Hash[32]; // SHA256 of Random used in RandomXoredIVs
|
||||||
|
BYTE HwId[8]; // HwId from the KMS server
|
||||||
|
BYTE XoredIVs[16]; // If RequestIV was used for decryption: decrypted Request IV ^ ResponseIV. If NULL IV was used for decryption: decrypted Request IV.
|
||||||
|
BYTE HMAC[16]; // V6 Hmac (low 16 bytes only), see kms.c CreateV6Hmac
|
||||||
|
//BYTE Pad[10]; // Pad is variable sized. So do not include in struct
|
||||||
|
} /*__packed*/ RESPONSE_V6;
|
||||||
|
|
||||||
|
typedef struct { // not used except for sizeof(). Fields are the same as RESPONSE_V6
|
||||||
|
VERSION_INFO;
|
||||||
|
BYTE IV[16];
|
||||||
|
RESPONSE ResponseBase;
|
||||||
|
BYTE RandomXoredIVs[16];
|
||||||
|
BYTE Hash[32];
|
||||||
|
} /*__packed*/ RESPONSE_V5;
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
typedef struct { // Debug structure for direct casting of RPC data in debugger
|
||||||
|
VERSION_INFO;
|
||||||
|
BYTE IV[16];
|
||||||
|
RESPONSE_DEBUG ResponseBase;
|
||||||
|
BYTE RandomXoredIVs[16];
|
||||||
|
BYTE MAC[32];
|
||||||
|
BYTE Unknown[8];
|
||||||
|
BYTE XorSalts[16];
|
||||||
|
BYTE HMAC[16];
|
||||||
|
BYTE Pad[16];
|
||||||
|
} __packed RESPONSE_V6_DEBUG;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define V4_PRE_EPID_SIZE ( \
|
||||||
|
sizeof(((RESPONSE*)0)->Version) + \
|
||||||
|
sizeof(((RESPONSE*)0)->PIDSize) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define V4_POST_EPID_SIZE ( \
|
||||||
|
sizeof(((RESPONSE*)0)->CMID) + \
|
||||||
|
sizeof(((RESPONSE*)0)->ClientTime) + \
|
||||||
|
sizeof(((RESPONSE*)0)->Count) + \
|
||||||
|
sizeof(((RESPONSE*)0)->VLActivationInterval) + \
|
||||||
|
sizeof(((RESPONSE*)0)->VLRenewalInterval) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define V6_DECRYPT_SIZE ( \
|
||||||
|
sizeof(((REQUEST_V6*)0)->IV) + \
|
||||||
|
sizeof(((REQUEST_V6*)0)->RequestBase) + \
|
||||||
|
sizeof(((REQUEST_V6*)0)->Pad) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define V6_UNENCRYPTED_SIZE ( \
|
||||||
|
sizeof(((RESPONSE_V6*)0)->Version) + \
|
||||||
|
sizeof(((RESPONSE_V6*)0)->IV) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define V6_PRE_EPID_SIZE ( \
|
||||||
|
V6_UNENCRYPTED_SIZE + \
|
||||||
|
sizeof(((RESPONSE*)0)->Version) + \
|
||||||
|
sizeof(((RESPONSE*)0)->PIDSize) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define V5_POST_EPID_SIZE ( \
|
||||||
|
V4_POST_EPID_SIZE + \
|
||||||
|
sizeof(((RESPONSE_V6*)0)->RandomXoredIVs) + \
|
||||||
|
sizeof(((RESPONSE_V6*)0)->Hash) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define V6_POST_EPID_SIZE ( \
|
||||||
|
V5_POST_EPID_SIZE + \
|
||||||
|
sizeof(((RESPONSE_V6*)0)->HwId) + \
|
||||||
|
sizeof(((RESPONSE_V6*)0)->XoredIVs) + \
|
||||||
|
sizeof(((RESPONSE_V6*)0)->HMAC) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define RESPONSE_RESULT_OK ((1 << 10) - 1) //(9 bits)
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
DWORD mask;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
BOOL HashOK : 1;
|
||||||
|
BOOL TimeStampOK : 1;
|
||||||
|
BOOL ClientMachineIDOK : 1;
|
||||||
|
BOOL VersionOK : 1;
|
||||||
|
BOOL IVsOK : 1;
|
||||||
|
BOOL DecryptSuccess : 1;
|
||||||
|
BOOL HmacSha256OK : 1;
|
||||||
|
BOOL PidLengthOK : 1;
|
||||||
|
BOOL RpcOK : 1;
|
||||||
|
BOOL IVnotSuspicious : 1;
|
||||||
|
BOOL reserved3 : 1;
|
||||||
|
BOOL reserved4 : 1;
|
||||||
|
BOOL reserved5 : 1;
|
||||||
|
BOOL reserved6 : 1;
|
||||||
|
uint32_t effectiveResponseSize : 9;
|
||||||
|
uint32_t correctResponseSize : 9;
|
||||||
|
};
|
||||||
|
} RESPONSE_RESULT;
|
||||||
|
|
||||||
|
typedef BYTE hwid_t[8];
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GUID guid;
|
||||||
|
const char* name;
|
||||||
|
const char* pid;
|
||||||
|
uint8_t AppIndex;
|
||||||
|
uint8_t KmsIndex;
|
||||||
|
} KmsIdList;
|
||||||
|
|
||||||
|
#define KMS_PARAM_MAJOR AppIndex
|
||||||
|
#define KMS_PARAM_REQUIREDCOUNT KmsIndex
|
||||||
|
|
||||||
|
#define APP_ID_WINDOWS 0
|
||||||
|
#define APP_ID_OFFICE2010 1
|
||||||
|
#define APP_ID_OFFICE2013 2
|
||||||
|
|
||||||
|
// Update these numbers in License Manager
|
||||||
|
#define KMS_ID_VISTA 0
|
||||||
|
#define KMS_ID_WIN7 1
|
||||||
|
#define KMS_ID_WIN8_VL 2
|
||||||
|
#define KMS_ID_WIN_BETA 3
|
||||||
|
#define KMS_ID_WIN8_RETAIL 4
|
||||||
|
#define KMS_ID_WIN81_VL 5
|
||||||
|
#define KMS_ID_WIN81_RETAIL 6
|
||||||
|
#define KMS_ID_WIN2008A 7
|
||||||
|
#define KMS_ID_WIN2008B 8
|
||||||
|
#define KMS_ID_WIN2008C 9
|
||||||
|
#define KMS_ID_WIN2008R2A 10
|
||||||
|
#define KMS_ID_WIN2008R2B 11
|
||||||
|
#define KMS_ID_WIN2008R2C 12
|
||||||
|
#define KMS_ID_WIN2012 13
|
||||||
|
#define KMS_ID_WIN2012R2 14
|
||||||
|
#define KMS_ID_OFFICE2010 15
|
||||||
|
#define KMS_ID_OFFICE2013 16
|
||||||
|
#define KMS_ID_WIN_SRV_BETA 17
|
||||||
|
#define KMS_ID_OFFICE2016 18
|
||||||
|
#define KMS_ID_WIN10_VL 19
|
||||||
|
#define KMS_ID_WIN10_RETAIL 20
|
||||||
|
#define KMS_ID_WIN2016 21
|
||||||
|
#define KMS_ID_OFFICE2013_BETA 22
|
||||||
|
#define KMS_ID_WIN10_LTSB2016 23
|
||||||
|
|
||||||
|
#define PWINGUID &AppList[APP_ID_WINDOWS].guid
|
||||||
|
#define POFFICE2010GUID &AppList[APP_ID_OFFICE2010].guid
|
||||||
|
#define POFFICE2013GUID &AppList[APP_ID_OFFICE2013].guid
|
||||||
|
|
||||||
|
typedef BOOL(__stdcall *RequestCallback_t)(const REQUEST *const baseRequest, RESPONSE *const baseResponse, BYTE *const hwId, const char* const ipstr);
|
||||||
|
|
||||||
|
size_t CreateResponseV4(REQUEST_V4 *const Request, BYTE *const response_data, const char* const ipstr);
|
||||||
|
size_t CreateResponseV6(REQUEST_V6 *restrict Request, BYTE *const response_data, const char* const ipstr);
|
||||||
|
BYTE *CreateRequestV4(size_t *size, const REQUEST* requestBase);
|
||||||
|
BYTE *CreateRequestV6(size_t *size, const REQUEST* requestBase);
|
||||||
|
void randomPidInit();
|
||||||
|
void get16RandomBytes(void* ptr);
|
||||||
|
RESPONSE_RESULT DecryptResponseV6(RESPONSE_V6* Response_v6, int responseSize, BYTE* const response, const BYTE* const request, BYTE* hwid);
|
||||||
|
RESPONSE_RESULT DecryptResponseV4(RESPONSE_V4* Response_v4, const int responseSize, BYTE* const response, const BYTE* const request);
|
||||||
|
void getUnixTimeAsFileTime(FILETIME *const ts);
|
||||||
|
__pure int64_t fileTimeToUnixTime(const FILETIME *const ts);
|
||||||
|
const char* getProductNameHE(const GUID *const guid, const KmsIdList *const List, ProdListIndex_t *const i);
|
||||||
|
const char* getProductNameLE(const GUID *const guid, const KmsIdList *const List, ProdListIndex_t *const i);
|
||||||
|
__pure ProdListIndex_t getExtendedProductListSize();
|
||||||
|
__pure ProdListIndex_t getAppListSize(void);
|
||||||
|
|
||||||
|
extern const KmsIdList ProductList[];
|
||||||
|
extern const KmsIdList AppList[];
|
||||||
|
extern const KmsIdList ExtendedProductList[];
|
||||||
|
|
||||||
|
extern RequestCallback_t CreateResponseBase;
|
||||||
|
|
||||||
|
#ifdef _PEDANTIC
|
||||||
|
uint16_t IsValidLcid(const uint16_t Lcid);
|
||||||
|
#endif // _PEDANTIC
|
||||||
|
|
||||||
|
#endif // __kms_h
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "libkms.h"
|
||||||
|
#include "kms.h"
|
||||||
|
#include "endian.h"
|
||||||
|
|
||||||
|
static const char ePID[] = { 'T', 0, 'E', 0, 'S', 0, 'T', 0, 0, 0 };
|
||||||
|
|
||||||
|
__stdcall BOOL KmsCallBack(const REQUEST *const baseRequest, RESPONSE *const baseResponse, BYTE *const hwId, const char* const ipstr)
|
||||||
|
{
|
||||||
|
printf("libvlmcs-test.c: Entered KmsCallBack for client %s\n", ipstr);
|
||||||
|
|
||||||
|
memcpy(&baseResponse->CMID, &baseRequest->CMID, sizeof(GUID));
|
||||||
|
memcpy(&baseResponse->ClientTime, &baseRequest->ClientTime, sizeof(FILETIME));
|
||||||
|
memcpy(&baseResponse->KmsPID, ePID, sizeof(ePID));
|
||||||
|
|
||||||
|
baseResponse->Version = baseRequest->Version;
|
||||||
|
baseResponse->Count = LE32(LE32(baseRequest->N_Policy) << 1);
|
||||||
|
baseResponse->PIDSize = sizeof(ePID);
|
||||||
|
baseResponse->VLActivationInterval = LE32(120);
|
||||||
|
baseResponse->VLRenewalInterval = LE32(10080);
|
||||||
|
|
||||||
|
if (hwId && baseResponse->MajorVer > 5) memcpy(hwId, "\x01\x02\x03\x04\x05\x06\x07\x08", 8);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
int version = GetLibKmsVersion();
|
||||||
|
|
||||||
|
if (version < 0x30001)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "KMS library version %u.%u or greater required\n", (unsigned int)(version >> 16), (unsigned int)(version & 0xffff));
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s: Program start\n", GetEmulatorVersion());
|
||||||
|
StartKmsServer(1688, KmsCallBack);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
/*
|
||||||
|
* libkms.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#ifdef EXTERNAL
|
||||||
|
#undef EXTERNAL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define EXTERNAL dllexport
|
||||||
|
|
||||||
|
#define DLLVERSION 0x30002
|
||||||
|
|
||||||
|
#include "libkms.h"
|
||||||
|
#include "shared_globals.h"
|
||||||
|
#include "network.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#endif // WIN32
|
||||||
|
|
||||||
|
static int_fast8_t IsServerStarted = FALSE;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifndef USE_MSRPC
|
||||||
|
|
||||||
|
static int_fast8_t SocketsInitialized = FALSE;
|
||||||
|
WSADATA wsadata;
|
||||||
|
|
||||||
|
static int initializeWinSockets()
|
||||||
|
{
|
||||||
|
if (SocketsInitialized) return 0;
|
||||||
|
SocketsInitialized = TRUE;
|
||||||
|
return WSAStartup(0x0202, &wsadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // USE_MSRPC
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
|
EXTERNC __declspec(EXTERNAL) char* __cdecl GetErrorMessage()
|
||||||
|
{
|
||||||
|
return ErrorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
EXTERNC __declspec(EXTERNAL) SOCKET __cdecl ConnectToServer(const char* host, const char* port, const int addressFamily)
|
||||||
|
{
|
||||||
|
SOCKET sock;
|
||||||
|
*ErrorMessage = 0;
|
||||||
|
|
||||||
|
# if defined(_WIN32) && !defined(USE_MSRPC)
|
||||||
|
initializeWinSockets();
|
||||||
|
# endif // defined(_WIN32) && !defined(USE_MSRPC)
|
||||||
|
|
||||||
|
size_t adrlen = strlen(host) + 16;
|
||||||
|
char* RemoteAddr = (char*)alloca(adrlen);
|
||||||
|
snprintf(RemoteAddr, adrlen, "[%s]:%s", host, port);
|
||||||
|
sock = connectToAddress(RemoteAddr, addressFamily, FALSE);
|
||||||
|
|
||||||
|
if (sock == INVALID_RPCCTX)
|
||||||
|
{
|
||||||
|
printerrorf("Fatal: Could not connect to %s\n", RemoteAddr);
|
||||||
|
return sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
EXTERNC __declspec(EXTERNAL) RpcStatus __cdecl BindRpc(const SOCKET sock, const int_fast8_t useMultiplexedRpc)
|
||||||
|
{
|
||||||
|
*ErrorMessage = 0;
|
||||||
|
UseMultiplexedRpc = useMultiplexedRpc;
|
||||||
|
return rpcBindClient(sock, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
EXTERNC __declspec(EXTERNAL) void __cdecl CloseConnection(const SOCKET sock)
|
||||||
|
{
|
||||||
|
socketclose(sock);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EXTERNC __declspec(EXTERNAL) DWORD __cdecl SendKMSRequest(const SOCKET sock, RESPONSE* baseResponse, REQUEST* baseRequest, RESPONSE_RESULT* result, BYTE *hwid)
|
||||||
|
{
|
||||||
|
*ErrorMessage = 0;
|
||||||
|
return SendActivationRequest(sock, baseResponse, baseRequest, result, hwid);
|
||||||
|
}
|
||||||
|
|
||||||
|
EXTERNC __declspec(EXTERNAL) int_fast8_t __cdecl IsDisconnected(const SOCKET sock)
|
||||||
|
{
|
||||||
|
return isDisconnected(sock);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EXTERNC __declspec(EXTERNAL) DWORD __cdecl StartKmsServer(const int port, RequestCallback_t requestCallback)
|
||||||
|
{
|
||||||
|
#ifndef SIMPLE_SOCKETS
|
||||||
|
char listenAddress[64];
|
||||||
|
|
||||||
|
if (IsServerStarted) return !0;
|
||||||
|
|
||||||
|
# ifdef _WIN32
|
||||||
|
int error = initializeWinSockets();
|
||||||
|
if (error) return error;
|
||||||
|
# endif // _WIN32
|
||||||
|
|
||||||
|
CreateResponseBase = requestCallback;
|
||||||
|
|
||||||
|
int maxsockets = 0;
|
||||||
|
int_fast8_t haveIPv4 = FALSE;
|
||||||
|
int_fast8_t haveIPv6 = FALSE;
|
||||||
|
|
||||||
|
if (checkProtocolStack(AF_INET)) { haveIPv4 = TRUE; maxsockets++; }
|
||||||
|
if (checkProtocolStack(AF_INET6)) { haveIPv6 = TRUE; maxsockets++; }
|
||||||
|
|
||||||
|
if(!maxsockets) return !0;
|
||||||
|
|
||||||
|
SocketList = (SOCKET*)vlmcsd_malloc(sizeof(SOCKET) * (size_t)maxsockets);
|
||||||
|
numsockets = 0;
|
||||||
|
|
||||||
|
if (haveIPv4)
|
||||||
|
{
|
||||||
|
snprintf(listenAddress, 64, "0.0.0.0:%u", (unsigned int)port);
|
||||||
|
addListeningSocket(listenAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (haveIPv6)
|
||||||
|
{
|
||||||
|
snprintf(listenAddress, 64, "[::]:%u", (unsigned int)port);
|
||||||
|
addListeningSocket(listenAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!numsockets)
|
||||||
|
{
|
||||||
|
free(SocketList);
|
||||||
|
return !0;
|
||||||
|
}
|
||||||
|
|
||||||
|
IsServerStarted = TRUE;
|
||||||
|
|
||||||
|
runServer();
|
||||||
|
|
||||||
|
IsServerStarted = FALSE;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
# else // SIMPLE_SOCKETS
|
||||||
|
|
||||||
|
if (IsServerStarted) return !0;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
# ifdef _WIN32
|
||||||
|
error = initializeWinSockets();
|
||||||
|
if (error) return error;
|
||||||
|
# endif // _WIN32
|
||||||
|
|
||||||
|
defaultport = vlmcsd_malloc(16);
|
||||||
|
snprintf((char*)defaultport, (size_t)16, "%i", port);
|
||||||
|
|
||||||
|
CreateResponseBase = requestCallback;
|
||||||
|
error = listenOnAllAddresses();
|
||||||
|
if (error) return error;
|
||||||
|
|
||||||
|
IsServerStarted = TRUE;
|
||||||
|
runServer();
|
||||||
|
IsServerStarted = FALSE;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
# endif // SIMPLE_SOCKETS
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EXTERNC __declspec(EXTERNAL) DWORD __cdecl StopKmsServer()
|
||||||
|
{
|
||||||
|
if (!IsServerStarted) return !0;
|
||||||
|
|
||||||
|
closeAllListeningSockets();
|
||||||
|
|
||||||
|
# ifndef SIMPLE_SOCKETS
|
||||||
|
if (SocketList) free(SocketList);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EXTERNC __declspec(EXTERNAL) int __cdecl GetLibKmsVersion()
|
||||||
|
{
|
||||||
|
return DLLVERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EXTERNC __declspec(EXTERNAL) const char* const __cdecl GetEmulatorVersion()
|
||||||
|
{
|
||||||
|
return VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* libkms.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LIBKMS_H_
|
||||||
|
#define LIBKMS_H_
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
#include "kms.h"
|
||||||
|
#include "rpc.h"
|
||||||
|
#include "vlmcs.h"
|
||||||
|
|
||||||
|
#ifndef EXTERNC
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERNC EXTERN "C"
|
||||||
|
#else
|
||||||
|
#define EXTERNC
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EXTERNC __declspec(EXTERNAL) DWORD __cdecl SendKMSRequest(const SOCKET sock, RESPONSE* baseResponse, REQUEST* baseRequest, RESPONSE_RESULT* result, BYTE *hwid);
|
||||||
|
EXTERNC __declspec(EXTERNAL) DWORD __cdecl StartKmsServer(const int port, RequestCallback_t requestCallback);
|
||||||
|
EXTERNC __declspec(EXTERNAL) DWORD __cdecl StopKmsServer();
|
||||||
|
EXTERNC __declspec(EXTERNAL) int __cdecl GetLibKmsVersion();
|
||||||
|
EXTERNC __declspec(EXTERNAL) const char* const __cdecl GetEmulatorVersion();
|
||||||
|
EXTERNC __declspec(EXTERNAL) SOCKET __cdecl ConnectToServer(const char* host, const char* port, const int addressFamily);
|
||||||
|
EXTERNC __declspec(EXTERNAL) char* __cdecl GetErrorMessage();
|
||||||
|
EXTERNC __declspec(EXTERNAL) void __cdecl CloseConnection(const SOCKET sock);
|
||||||
|
EXTERNC __declspec(EXTERNAL) RpcStatus __cdecl BindRpc(const SOCKET sock, const int_fast8_t useMultiplexedRpc);
|
||||||
|
EXTERNC __declspec(EXTERNAL) int_fast8_t __cdecl IsDisconnected(const SOCKET sock);
|
||||||
|
//EXTERN_C __declspec(EXTERNAL) unsigned int __cdecl GetRandom32();
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* LIBKMS_H_ */
|
||||||
Executable
+32
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/local/bin/bash
|
||||||
|
|
||||||
|
export VLMCSD_VERSION="svn`svnversion`"
|
||||||
|
|
||||||
|
export VERBOSE=3
|
||||||
|
export DNS_PARSER=OS
|
||||||
|
|
||||||
|
rm -f vlmcsd-Dragon* vlmcs-* vlmcsdmulti-* *_all.* 2>/dev/null
|
||||||
|
rm -f vlmcsdmulti vlmcsd vlmcs 2>/dev/null
|
||||||
|
|
||||||
|
MAKEFLAGS="-B -j12"
|
||||||
|
REUSEOBJFLAGS="-j12"
|
||||||
|
|
||||||
|
CF="-flto=12 -static-libgcc -pipe -fwhole-program -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
CF45="-static-libgcc -pipe -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
CFCLANG="-pipe -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
LF="-Wl,-z,norelro -Wl,--hash-style=sysv -Wl,--build-id=none"
|
||||||
|
LFCLANG="-Wl,-z,norelro -Wl,--hash-style=sysv"
|
||||||
|
export CC=gcc5
|
||||||
|
|
||||||
|
gmake $MAKEFLAGS MULTI_NAME=vlmcsdmulti-DragonFly-x64 PROGRAM_NAME=vlmcsd-DragonFly-x64 CLIENT_NAME=vlmcs-DragonFly-x64 CFLAGS="$CF" LDFLAGS="$LF" allmulti
|
||||||
|
|
||||||
|
rm *.o
|
||||||
|
|
||||||
|
strip -s --strip-unneeded --remove-section=.eh_frame_hdr --remove-section=.eh_frame --remove-section=.note.gnu.gold-version --remove-section=.comment --remove-section=.note --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag vlmcs-* vlmcsd-* vlmcsdmulti-*
|
||||||
|
sstrip -z vlmcs-* vlmcsd-* vlmcsdmulti-*
|
||||||
|
|
||||||
|
cp -af vlmcsd-DragonFly-x64 /usr/local/sbin/vlmcsd
|
||||||
|
cp -af vlmcs-DragonFly-x64 /usr/local/bin/vlmcs
|
||||||
|
|
||||||
|
# Copy everything to distribution server
|
||||||
|
scp -p vlmcsdmulti-* vlmcsd-Dragon* vlmcs-* root@ubuntu64:x/binaries/DragonFly/intel/
|
||||||
Executable
+38
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/local/bin/bash
|
||||||
|
|
||||||
|
export VLMCSD_VERSION="svn`svnversion`"
|
||||||
|
export VERBOSE=3
|
||||||
|
export DNS_PARSER=OS
|
||||||
|
|
||||||
|
rm -f vlmcsd-Free* vlmcs-* vlmcsdmulti-* *_all.* 2>/dev/null
|
||||||
|
rm -f vlmcsdmulti vlmcsd vlmcs 2>/dev/null
|
||||||
|
|
||||||
|
MAKEFLAGS="-B -j12"
|
||||||
|
REUSEOBJFLAGS="-j12"
|
||||||
|
|
||||||
|
CF="-flto=12 -static-libgcc -pipe -fwhole-program -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
CFCLANG="-pipe -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
LF="-Wl,-z,norelro -Wl,--hash-style=gnu -Wl,--build-id=none"
|
||||||
|
LFCLANG="-Wl,-z,norelro -Wl,--hash-style=gnu"
|
||||||
|
|
||||||
|
gmake $MAKEFLAGS allmulti CAT=2 MULTI_NAME=vlmcsdmulti-FreeBSD-10.3-x64-gcc CLIENT_NAME=vlmcs-FreeBSD-10.3-x64-gcc PROGRAM_NAME=vlmcsd-FreeBSD-10.3-x64-gcc CC=gcc5 CFLAGS="$CF" LDFLAGS="$LF"
|
||||||
|
gmake $MAKEFLAGS MULTI_NAME=vlmcsdmulti-FreeBSD-10.3-x64 CLIENT_NAME=vlmcs-FreeBSD-10.3-x64 PROGRAM_NAME=vlmcsd-FreeBSD-10.3-x64 CC=clang38 CFLAGS="$CFCLANG" LDFLAGS="$LF" allmulti
|
||||||
|
gmake $MAKEFLAGS MULTI_NAME=vlmcsdmulti-FreeBSD-10.3-x86 CLIENT_NAME=vlmcs-FreeBSD-10.3-x86 PROGRAM_NAME=vlmcsd-FreeBSD-10.3-x86 CC=clang38 CFLAGS="$CFCLANG -m32" LDFLAGS="$LF"
|
||||||
|
gmake $MAKEFLAGS allmulti CAT=2 MULTI_NAME=vlmcsdmulti-FreeBSD-10.3-x86-gcc CLIENT_NAME=vlmcs-FreeBSD-10.3-x86-gcc PROGRAM_NAME=vlmcsd-FreeBSD-10.3-x86-gcc CC=gcc5 CFLAGS="$CF -m32 -DCOMPAT_32BIT" LDFLAGS="-L/usr/lib32 -B/usr/lib32 $LF"
|
||||||
|
gmake $MAKEFLAGS CAT=2 vlmcsd-FreeBSD-10.3-x64-threads-gcc PROGRAM_NAME=vlmcsd-FreeBSD-10.3-x64-threads-gcc THREADS=1 CC=gcc5 CFLAGS="$CF" LDFLAGS="-lpthread $LF"
|
||||||
|
gmake $MAKEFLAGS vlmcsd-FreeBSD-10.3-x64-threads PROGRAM_NAME=vlmcsd-FreeBSD-10.3-x64-threads THREADS=1 CC=clang38 CFLAGS="$CFCLANG" LDFLAGS="-lpthread $LF"
|
||||||
|
gmake $MAKEFLAGS vlmcsd-FreeBSD-10.3-x86-threads PROGRAM_NAME=vlmcsd-FreeBSD-10.3-x86-threads THREADS=1 CC=clang38 CFLAGS="$CFCLANG -m32" LDFLAGS="-lpthread $LF"
|
||||||
|
gmake $MAKEFLAGS CAT=2 vlmcsd-FreeBSD-10.3-x86-threads-gcc PROGRAM_NAME=vlmcsd-FreeBSD-10.3-x86-threads-gcc THREADS=1 CC=gcc5 CFLAGS="$CF -m32 -DCOMPAT_32BIT" LDFLAGS="-lpthread -L/usr/lib32 -B/usr/lib32 $LF"
|
||||||
|
gmake $MAKEFLAGS CRYPTO=openssl_with_aes CLIENT_NAME=vlmcs-FreeBSD-10.3-x64-openssl1.0.1-EXPERIMENTAL PROGRAM_NAME=vlmcsd-FreeBSD-10.3-x64-openssl1.0.1-EXPERIMENTAL CC=clang38 CFLAGS="$CFCLANG" LDFLAGS="$LF"
|
||||||
|
gmake $MAKEFLAGS CRYPTO=openssl_with_aes CLIENT_NAME=vlmcs-FreeBSD-10.3-x86-openssl1.0.1-EXPERIMENTAL PROGRAM_NAME=vlmcsd-FreeBSD-10.3-x86-openssl1.0.1-EXPERIMENTAL CC=clang38 CFLAGS="$CFCLANG -m32" LDFLAGS="$LF"
|
||||||
|
|
||||||
|
rm *.o
|
||||||
|
|
||||||
|
strip -s --strip-unneeded --remove-section=.eh_frame_hdr --remove-section=.eh_frame --remove-section=.note.gnu.gold-version --remove-section=.comment --remove-section=.note --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag vlmcs-* vlmcsd-* vlmcsdmulti-*
|
||||||
|
sstrip -z vlmcs-* vlmcsd-* vlmcsdmulti-*
|
||||||
|
|
||||||
|
sudo cp -af vlmcsd-FreeBSD-10.3-x64-gcc /usr/local/sbin/vlmcsd
|
||||||
|
sudo cp -af vlmcs-FreeBSD-10.3-x64-gcc /usr/local/bin/vlmcs
|
||||||
|
|
||||||
|
# Copy everything to distribution server
|
||||||
|
scp -p vlmcsdmulti-* vlmcsd-Free* vlmcs-* root@ubuntu64:x/binaries/FreeBSD/intel/
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export VLMCSD_VERSION="svn`svnversion`"
|
||||||
|
export VERBOSE=3
|
||||||
|
export DNS_PARSER=OS
|
||||||
|
|
||||||
|
rm -f vlmcsd-hurd* vlmcs-* vlmcsdmulti-* *_all.* 2>/dev/null
|
||||||
|
rm -f vlmcsdmulti vlmcsd vlmcs 2>/dev/null
|
||||||
|
|
||||||
|
MAKEFLAGS="-B -j1"
|
||||||
|
|
||||||
|
export CC=gcc
|
||||||
|
CF="-flto=jobserver -pipe -fwhole-program -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
LF="-fuse-ld=gold -lresolv -Wl,-z,norelro,--hash-style=gnu,--build-id=none"
|
||||||
|
|
||||||
|
make $MAKEFLAGS MULTI_NAME=vlmcsdmulti-hurd-x86-glibc vlmcsdmulti-hurd-x86-glibc PROGRAM_NAME=vlmcsd-hurd-x86-glibc CLIENT_NAME=vlmcs-hurd-x86-glibc CFLAGS="$CF" LDFLAGS="$LF" allmulti
|
||||||
|
|
||||||
|
make clean
|
||||||
|
|
||||||
|
sstrip -z vlmcs-* vlmcsd-* vlmcsdmulti-*
|
||||||
|
|
||||||
|
cp -af vlmcsd-hurd-x86-glibc /usr/local/sbin/vlmcsd
|
||||||
|
cp -af vlmcs-hurd-x86-glibc /usr/local/bin/vlmcs
|
||||||
|
|
||||||
|
# Copy man pages
|
||||||
|
mkdir -p /usr/local/man/man1 2>/dev/null
|
||||||
|
mkdir -p /usr/local/man/man5 2>/dev/null
|
||||||
|
mkdir -p /usr/local/man/man8 2>/dev/null
|
||||||
|
mkdir -p /usr/local/man/man7 2>/dev/null
|
||||||
|
cp -af vlmcs.1 vlmcsdmulti.1 /usr/local/man/man1/
|
||||||
|
cp -af vlmcsd.7 /usr/local/man/man7/
|
||||||
|
cp -af vlmcsd.8 /usr/local/man/man8/
|
||||||
|
cp -af vlmcsd.ini.5 /usr/local/man/man5/
|
||||||
|
bzip2 -f -9 /usr/local/man/man5/vlmcsd.ini.5 /usr/local/man/man1/vlmcs.1 /usr/local/man/man1/vlmcsdmulti.1 /usr/local/man/man7/vlmcsd.7 /usr/local/man/man8/vlmcsd.8
|
||||||
|
|
||||||
|
# Copy everything to distribution server
|
||||||
|
scp -p vlmcsdmulti-* vlmcsd-hurd* vlmcs-* root@ubuntu64.internal:x/binaries/Hurd/intel/
|
||||||
|
|
||||||
Executable
+46
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export VLMCSD_VERSION="svn`svnversion`"
|
||||||
|
export VERBOSE=3
|
||||||
|
export DNS_PARSER=OS
|
||||||
|
|
||||||
|
rm -f vlmcsd-Free* vlmcs-* vlmcsdmulti-* *_all.* 2>/dev/null
|
||||||
|
rm -f vlmcsdmulti vlmcsd vlmcs 2>/dev/null
|
||||||
|
|
||||||
|
MAKEFLAGS="-B -j`nproc`"
|
||||||
|
|
||||||
|
export CC=gcc
|
||||||
|
CF="-flto=jobserver -pipe -fwhole-program -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
LF="-lresolv -Wl,-z,norelro,--hash-style=gnu,--build-id=none"
|
||||||
|
|
||||||
|
export PROGRAM_NAME=vlmcsd-FreeBSD-10.1-x64-glibc
|
||||||
|
export CLIENT_NAME=vlmcs-FreeBSD-10.1-x64-glibc
|
||||||
|
export MULTI_NAME=vlmcsdmulti-FreeBSD-10.1-x64-glibc
|
||||||
|
|
||||||
|
make $MAKEFLAGS CFLAGS="$CF -m64" LDFLAGS="$LF" CAT=2 allmulti
|
||||||
|
|
||||||
|
cp -af $PROGRAM_NAME /usr/local/sbin/vlmcsd
|
||||||
|
cp -af $CLIENT_NAME /usr/local/bin/vlmcs
|
||||||
|
|
||||||
|
export PROGRAM_NAME=vlmcsd-FreeBSD-10.1-x86-glibc
|
||||||
|
export CLIENT_NAME=vlmcs-FreeBSD-10.1-x86-glibc
|
||||||
|
export MULTI_NAME=vlmcsdmulti-FreeBSD-10.1-x86-glibc
|
||||||
|
|
||||||
|
make $MAKEFLAGS CFLAGS="$CF -m32" LDFLAGS="$LF" CAT=2 allmulti
|
||||||
|
|
||||||
|
sstrip -z vlmcs-* vlmcsd-* vlmcsdmulti-*
|
||||||
|
|
||||||
|
# Copy man pages
|
||||||
|
mkdir -p /usr/local/man/man1 2>/dev/null
|
||||||
|
mkdir -p /usr/local/man/man5 2>/dev/null
|
||||||
|
mkdir -p /usr/local/man/man8 2>/dev/null
|
||||||
|
mkdir -p /usr/local/man/man7 2>/dev/null
|
||||||
|
cp -af vlmcs.1 vlmcsdmulti.1 /usr/local/man/man1/
|
||||||
|
cp -af vlmcsd.7 /usr/local/man/man7/
|
||||||
|
cp -af vlmcsd.8 /usr/local/man/man8/
|
||||||
|
cp -af vlmcsd.ini.5 /usr/local/man/man5/
|
||||||
|
bzip2 -f -9 /usr/local/man/man5/vlmcsd.ini.5 /usr/local/man/man1/vlmcs.1 /usr/local/man/man1/vlmcsdmulti.1 /usr/local/man/man7/vlmcsd.7 /usr/local/man/man8/vlmcsd.8
|
||||||
|
|
||||||
|
# Copy everything to distribution server
|
||||||
|
scp -p vlmcsdmulti-* vlmcsd-Free* vlmcs-* root@ubuntu64.internal:x/binaries/FreeBSD/intel/
|
||||||
|
|
||||||
Executable
+2821
File diff suppressed because it is too large
Load Diff
Executable
+23
@@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
export VLMCSD_VERSION=svn$(ssh root@ubuntu64.internal "cd x; svnversion")
|
||||||
|
scp -p make_minix root@ubuntu64.internal:x
|
||||||
|
scp -pr root@ubuntu64.internal:x/* .
|
||||||
|
|
||||||
|
|
||||||
|
# Compile vlmcsd binaries for Minix 3
|
||||||
|
|
||||||
|
SUFFIX=-minix-$(uname -r)-x86
|
||||||
|
export CC=clang
|
||||||
|
export CFLAGS="-pipe -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
export LDFLAGS="-Wl,--hash-style=sysv -Wl,-z,norelro -Wl,--build-id=none"
|
||||||
|
export PROGRAM_NAME=vlmcsd$SUFFIX
|
||||||
|
export CLIENT_NAME=vlmcs$SUFFIX
|
||||||
|
export MULTI_NAME=vlmcsdmulti$SUFFIX
|
||||||
|
|
||||||
|
gmake clean
|
||||||
|
gmake -B allmulti
|
||||||
|
|
||||||
|
strip -s --strip-unneeded --remove-section .eh_frame_hdr --remove-section .eh_frame --remove-section .ident --remove-section .note.minix.ident --remove-section .note.netbsd.pax --remove-section=.note.gnu.gold-version --remove-section=.comment --remove-section=.note --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag *$SUFFIX
|
||||||
|
|
||||||
|
scp -p *$SUFFIX root@ubuntu64.internal:x/binaries/Minix/intel/
|
||||||
Executable
+122
@@ -0,0 +1,122 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export VLMCSD_VERSION="svn`svnversion`"
|
||||||
|
SMALLCC="-pipe -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
SMALLLD="-pipe -Wl,--hash-style=sysv -Wl,-z,norelro -Wl,--build-id=none"
|
||||||
|
SMALL="$SMALLCC $SMALLLD"
|
||||||
|
|
||||||
|
rm -f vlmcsd vlmcs vlmcsdmulti vlmcsd-s390* vlmcsd-sparc64* vlmcsd-mips64* vlmcs-* vlmcsdmulti-*
|
||||||
|
|
||||||
|
## IBM S/390
|
||||||
|
|
||||||
|
export CFLAGS="$SMALLCC"
|
||||||
|
export PLATFORMFLAGS="-flto=jobserver -fwhole-program -m31 -mesa -mpacked-stack -msmall-exec"
|
||||||
|
export LDFLAGS="$SMALLLD -Wl,--hash-style=gnu"
|
||||||
|
export THREADS=0
|
||||||
|
export FEATURES=full
|
||||||
|
export CC=s390x-linux-gnu-gcc
|
||||||
|
export VERBOSE=3
|
||||||
|
|
||||||
|
export MULTI_NAME=vlmcsdmulti-s390-glibc
|
||||||
|
export CLIENT_NAME=vlmcs-s390-glibc
|
||||||
|
export PROGRAM_NAME=vlmcsd-s390-glibc
|
||||||
|
|
||||||
|
make -B -j`nproc` allmulti
|
||||||
|
|
||||||
|
sstrip -z $CLIENT_NAME $PROGRAM_NAME $MULTI_NAME
|
||||||
|
|
||||||
|
export PLATFORMFLAGS="-flto=jobserver -fwhole-program -m64 -mzarch -mpacked-stack -msmall-exec"
|
||||||
|
export MULTI_NAME=vlmcsdmulti-s390x-glibc
|
||||||
|
export CLIENT_NAME=vlmcs-s390x-glibc
|
||||||
|
export PROGRAM_NAME=vlmcsd-s390x-glibc
|
||||||
|
|
||||||
|
make -B -j`nproc` allmulti
|
||||||
|
sstrip -z $CLIENT_NAME $PROGRAM_NAME $MULTI_NAME
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## SPARC64
|
||||||
|
|
||||||
|
export PLATFORMFLAGS="-flto=jobserver -fwhole-program -mcpu=v7"
|
||||||
|
export LDFLAGS="$SMALLLD"
|
||||||
|
export CC=sparc64-linux-gnu-gcc
|
||||||
|
|
||||||
|
export MULTI_NAME=vlmcsdmulti-sparc64v9-glibc
|
||||||
|
export CLIENT_NAME=vlmcs-sparc64v9-glibc
|
||||||
|
export PROGRAM_NAME=vlmcsd-sparc64v9-glibc
|
||||||
|
|
||||||
|
make -B -j`nproc` allmulti
|
||||||
|
|
||||||
|
sstrip -z $CLIENT_NAME $PROGRAM_NAME $MULTI_NAME
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## MIPS64 BIG-ENDIAN
|
||||||
|
|
||||||
|
export PLATFORMFLAGS="-flto=jobserver -fwhole-program -mips64 -mno-mips16"
|
||||||
|
export LDFLAGS="$SMALLLD"
|
||||||
|
export CC=mips64-linux-gnuabi64-gcc
|
||||||
|
|
||||||
|
export MULTI_NAME=vlmcsdmulti-mips64-glibc
|
||||||
|
export CLIENT_NAME=vlmcs-mips64-glibc
|
||||||
|
export PROGRAM_NAME=vlmcsd-mips64-glibc
|
||||||
|
|
||||||
|
make -B -j`nproc` allmulti
|
||||||
|
|
||||||
|
sstrip -z $CLIENT_NAME $PROGRAM_NAME $MULTI_NAME
|
||||||
|
|
||||||
|
export PLATFORMFLAGS="-flto=jobserver -fwhole-program -mips64 -mmicromips"
|
||||||
|
export MULTI_NAME=vlmcsdmulti-mips64mm-glibc
|
||||||
|
export CLIENT_NAME=vlmcs-mips64mm-glibc
|
||||||
|
export PROGRAM_NAME=vlmcsd-mips64mm-glibc
|
||||||
|
|
||||||
|
make -B -j`nproc` allmulti
|
||||||
|
|
||||||
|
sstrip -z $CLIENT_NAME $PROGRAM_NAME $MULTI_NAME
|
||||||
|
|
||||||
|
|
||||||
|
## MIPS64 LITTLE-ENDIAN
|
||||||
|
|
||||||
|
export PLATFORMFLAGS="-flto=jobserver -fwhole-program -mips64 -mno-mips16"
|
||||||
|
export LDFLAGS="$SMALLLD"
|
||||||
|
export CC=mips64el-linux-gnuabi64-gcc
|
||||||
|
|
||||||
|
export MULTI_NAME=vlmcsdmulti-mips64el-glibc
|
||||||
|
export CLIENT_NAME=vlmcs-mips64el-glibc
|
||||||
|
export PROGRAM_NAME=vlmcsd-mips64el-glibc
|
||||||
|
|
||||||
|
make -B -j`nproc` allmulti
|
||||||
|
|
||||||
|
sstrip -z $CLIENT_NAME $PROGRAM_NAME $MULTI_NAME
|
||||||
|
|
||||||
|
export PLATFORMFLAGS="-flto=jobserver -fwhole-program -mips64 -mmicromips"
|
||||||
|
export MULTI_NAME=vlmcsdmulti-mips64elmm-glibc
|
||||||
|
export CLIENT_NAME=vlmcs-mips64elmm-glibc
|
||||||
|
export PROGRAM_NAME=vlmcsd-mips64elmm-glibc
|
||||||
|
|
||||||
|
make -B -j`nproc` allmulti
|
||||||
|
|
||||||
|
sstrip -z $CLIENT_NAME $PROGRAM_NAME $MULTI_NAME
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$1" == "nocopy" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p /usr/local/man/man1 2>/dev/null
|
||||||
|
mkdir -p /usr/local/man/man5 2>/dev/null
|
||||||
|
mkdir -p /usr/local/man/man8 2>/dev/null
|
||||||
|
mkdir -p /usr/local/man/man7 2>/dev/null
|
||||||
|
cp -a vlmcs.1 vlmcsdmulti.1 /usr/local/man/man1/
|
||||||
|
cp -a vlmcsd.7 /usr/local/man/man7/
|
||||||
|
cp -a vlmcsd.8 /usr/local/man/man8/
|
||||||
|
cp -a vlmcsd.ini.5 /usr/local/man/man5/
|
||||||
|
pbzip2 -f -9 /usr/local/man/man5/vlmcsd.ini.5 /usr/local/man/man1/vlmcs.1 /usr/local/man/man1/vlmcsdmulti.1 /usr/local/man/man7/vlmcsd.7 /usr/local/man/man8/vlmcsd.8
|
||||||
|
|
||||||
|
scp -p vlmcsdmulti-s390-glibc vlmcs-s390-glibc vlmcsd-s390-glibc vlmcsdmulti-s390x-glibc vlmcs-s390x-glibc vlmcsd-s390x-glibc ubuntu64.internal:x/binaries/Linux/s390/glibc
|
||||||
|
scp -p vlmcsdmulti-sparc64v9-glibc vlmcs-sparc64v9-glibc vlmcsd-sparc64v9-glibc ubuntu64.internal:x/binaries/Linux/sparc/glibc
|
||||||
|
scp -p vlmcsdmulti-mips64-glibc vlmcs-mips64-glibc vlmcsd-mips64-glibc vlmcsdmulti-mips64mm-glibc vlmcs-mips64mm-glibc vlmcsd-mips64mm-glibc ubuntu64.internal:x/binaries/Linux/mips/big-endian/glibc
|
||||||
|
scp -p vlmcsdmulti-mips64el-glibc vlmcs-mips64el-glibc vlmcsd-mips64el-glibc vlmcsdmulti-mips64elmm-glibc vlmcs-mips64elmm-glibc vlmcsd-mips64elmm-glibc ubuntu64.internal:x/binaries/Linux/mips/little-endian/glibc
|
||||||
|
scp -p -P 2222 vlmcsdmulti-s390-glibc vlmcs-s390-glibc vlmcsd-s390-glibc vlmcsdmulti-s390x-glibc vlmcs-s390x-glibc vlmcsd-s390x-glibc s390:vlmcsd
|
||||||
|
scp -p -P 2222 vlmcsdmulti-s390-glibc vlmcsdmulti-s390x-glibc s390:/usr/local/sbin
|
||||||
Executable
+34
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/pkg/bin/bash
|
||||||
|
|
||||||
|
export VLMCSD_VERSION="svn`svnversion`"
|
||||||
|
export VERBOSE=3
|
||||||
|
export DNS_PARSER=OS
|
||||||
|
|
||||||
|
rm -f vlmcsd-NetBSD* vlmcs-* vlmcsdmulti-* *_all.* 2>/dev/null
|
||||||
|
gmake clean
|
||||||
|
|
||||||
|
MAKEFLAGS="-B -j12"
|
||||||
|
REUSEOBJFLAGS="-j12"
|
||||||
|
|
||||||
|
CF="-flto=12 -static-libgcc -pipe -fwhole-program -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
CF45="-flto=12 -static-libgcc -pipe -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
CFCLANG="-pipe -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
LF="-Wl,-z,norelro -Wl,--hash-style=sysv -Wl,--build-id=none"
|
||||||
|
LFCLANG="-Wl,-z,norelro -Wl,--hash-style=sysv"
|
||||||
|
|
||||||
|
gmake $MAKEFLAGS CC=/usr/pkg/gcc5/bin/gcc PROGRAM_NAME=vlmcsd-NetBSD-x64 CLIENT_NAME=vlmcs-NetBSD-x64 MULTI_NAME=vlmcsdmulti-NetBSD-x64 allmulti CFLAGS="$CF" LDFLAGS="$LF"
|
||||||
|
|
||||||
|
gmake allmulti CC=gcc $MAKEFLAGS CAT=2 MULTI_NAME=vlmcsdmulti-NetBSD-x86 PROGRAM_NAME=vlmcsd-NetBSD-x86 CLIENT_NAME=vlmcs-NetBSD-x86 CFLAGS="$CF45 -m32" LDFLAGS="$LF"
|
||||||
|
|
||||||
|
#gmake $MAKEFLAGS CC=clang PROGRAM_NAME=vlmcsd-NetBSD-x64-clang CLIENT_NAME=vlmcs-NetBSD-x64-clang CFLAGS="$CFCLANG" LDFLAGS="$LFCLANG"
|
||||||
|
|
||||||
|
rm *.o
|
||||||
|
|
||||||
|
strip -s --strip-unneeded -R .ident -R .got -R .note.netbsd.pax -R .gnu.version -R .eh_frame -R .note.gnu.gold-version -R .comment -R .note -R .note.gnu.build-id -R .note.ABI-tag vlmcs-* vlmcsd-* vlmcsdmulti-*
|
||||||
|
#sstrip -z vlmcs-* vlmcsd-* vlmcsdmulti-*
|
||||||
|
|
||||||
|
cp -af vlmcsd-NetBSD-x86 /usr/local/sbin/vlmcsd
|
||||||
|
cp -af vlmcs-NetBSD-x86 /usr/local/bin/vlmcs
|
||||||
|
|
||||||
|
# Copy everything to distribution server
|
||||||
|
scp -p vlmcsdmulti-* vlmcsd-Net* vlmcs-* root@ubuntu64:x/binaries/NetBSD/intel/
|
||||||
Executable
+34
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/local/bin/bash
|
||||||
|
|
||||||
|
export VLMCSD_VERSION="svn`svnversion`"
|
||||||
|
export VERBOSE=3
|
||||||
|
export DNS_PARSER=OS
|
||||||
|
|
||||||
|
rm -f vlmcsd-Open* vlmcs-* vlmcsdmulti-* *_all.* 2>/dev/null
|
||||||
|
rm -f vlmcsdmulti vlmcsd vlmcs 2>/dev/null
|
||||||
|
|
||||||
|
MAKEFLAGS="-B -j12"
|
||||||
|
REUSEOBJFLAGS="-j12"
|
||||||
|
|
||||||
|
CF="-static-libgcc -pipe -fwhole-program -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
CF45="-static-libgcc -pipe -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
CFCLANG="-pipe -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
LF="-Wl,-z,norelro"
|
||||||
|
LFCLANG="-Wl,-z,norelro"
|
||||||
|
|
||||||
|
gmake -Bj12 allmulti $MAKEFLAGS CC=egcc MULTI_NAME=vlmcsdmulti-OpenBSD-x64 PROGRAM_NAME=vlmcsd-OpenBSD-x64 CLIENT_NAME=vlmcs-OpenBSD-x64 CFLAGS="$CF" LDFLAGS="$LF"
|
||||||
|
|
||||||
|
#gmake allmulti $MAKEFLAGS CAT=2 MULTI_NAME=vlmcsdmulti-OpenBSD-x86 PROGRAM_NAME=vlmcsd-OpenBSD-x86 CLIENT_NAME=vlmcs-OpenBSD-x86 CFLAGS="$CF45 -m32" LDFLAGS="$LF"
|
||||||
|
|
||||||
|
#gmake $MAKEFLAGS CC=clang PROGRAM_NAME=vlmcsd-OpenBSD-x64-clang CLIENT_NAME=vlmcs-OpenBSD-x64-clang CFLAGS="$CFCLANG" LDFLAGS="$LFCLANG"
|
||||||
|
|
||||||
|
rm *.o
|
||||||
|
|
||||||
|
strip -s --strip-unneeded --remove-section=.eh_frame_hdr --remove-section=.eh_frame --remove-section=.note.gnu.gold-version --remove-section=.comment --remove-section=.note --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag vlmcs-* vlmcsd-* vlmcsdmulti-*
|
||||||
|
#sstrip -z vlmcs-* vlmcsd-* vlmcsdmulti-*
|
||||||
|
|
||||||
|
cp -f vlmcsd-OpenBSD-x64 /usr/local/sbin/vlmcsd
|
||||||
|
cp -f vlmcs-OpenBSD-x64 /usr/local/bin/vlmcs
|
||||||
|
|
||||||
|
# Copy everything to distribution server
|
||||||
|
scp -p vlmcsdmulti-* vlmcsd-Open* vlmcs-* root@ubuntu64:x/binaries/OpenBSD/intel/
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export VLMCSD_VERSION="svn`svnversion`"
|
||||||
|
export VERBOSE=3
|
||||||
|
export DNS_PARSER=OS
|
||||||
|
|
||||||
|
rm vlmcsd-Mac* vlmcsd-iOS* vlmcs-* vlmcsdmulti-* *_all.* 2>/dev/null
|
||||||
|
rm vlmcsd vlmcs vlmcsdmulti 2>/dev/null
|
||||||
|
|
||||||
|
MAKEFLAGS="-Bj"
|
||||||
|
REUSEOBJFLAGS="-j"
|
||||||
|
CFGCC="-static-libgcc -mdynamic-no-pic -Os -flto=jobserver -fwhole-program -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
CFCLANG="-mdynamic-no-pic -Os -flto -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
CFGCC42="-static-libgcc -mdynamic-no-pic -Os -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
|
||||||
|
|
||||||
|
make $MAKEFLAGS allmulti MULTI_NAME=vlmcsdmulti-MacOSX-x86 CLIENT_NAME=vlmcs-MacOSX-x86 PROGRAM_NAME=vlmcsd-MacOSX-x86 CC=clang CFLAGS="$CFCLANG" PLATFORMFLAGS="-m32 -march=core2 -mmacosx-version-min=10.0" && \
|
||||||
|
make $MAKEFLAGS vlmcsd-MacOSX-x86-threads THREADS=1 PROGRAM_NAME=vlmcsd-MacOSX-x86-threads CC=clang CFLAGS="$CFCLANG" PLATFORMFLAGS="-m32 -march=core2 -mmacosx-version-min=10.0" && \
|
||||||
|
make $MAKEFLAGS allmulti MULTI_NAME=vlmcsdmulti-MacOSX-x64 CLIENT_NAME=vlmcs-MacOSX-x64 PROGRAM_NAME=vlmcsd-MacOSX-x64 CC=clang CFLAGS="$CFCLANG" PLATFORMFLAGS="-m64 -march=core2 -mmacosx-version-min=10.0" && \
|
||||||
|
make $MAKEFLAGS vlmcsd-MacOSX-x64-threads THREADS=1 PROGRAM_NAME=vlmcsd-MacOSX-x64-threads CC=clang CFLAGS="$CFCLANG" PLATFORMFLAGS="-m64 -march=core2 -mmacosx-version-min=10.0" && \
|
||||||
|
#make $MAKEFLAGS CLIENT_NAME=vlmcs-MacOSX-x86-openssl-EXPERIMENTAL PROGRAM_NAME=vlmcsd-MacOSX-x86-openssl-EXPERIMENTAL CRYPTO=openssl_with_aes_soft CC=clang CFLAGS="$CFCLANG" PLATFORMFLAGS="-m32 -march=core2 -mmacosx-version-min=10.4" && \
|
||||||
|
#make $MAKEFLAGS CLIENT_NAME=vlmcs-MacOSX-x64-openssl-EXPERIMENTAL PROGRAM_NAME=vlmcsd-MacOSX-x64-openssl-EXPERIMENTAL CRYPTO=openssl_with_aes_soft CC=clang CFLAGS="$CFCLANG" PLATFORMFLAGS="-m64 -march=core2 -mmacosx-version-min=10.4" && \
|
||||||
|
|
||||||
|
#make $MAKEFLAGS CLIENT_NAME=vlmcs-iOS-7.1-armv7 PROGRAM_NAME=vlmcsd-iOS-7.1-armv7 CC=clang CFLAGS="$CFCLANG" PLATFORMFLAGS="-mthumb -m32 -arch armv7 -miphoneos-version-min=1.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk" && \
|
||||||
|
#rm -f vlmcs.o vlmcsd.o vlmcsdmulti.o *_all.* && \
|
||||||
|
#make $REUSEOBJFLAGS vlmcsdmulti-iOS-7.1-armv7 MULTI_NAME=vlmcsdmulti-iOS-7.1-armv7 CC=clang CFLAGS="$CFCLANG" PLATFORMFLAGS="-mthumb -m32 -arch armv7 -miphoneos-version-min=1.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk" && \
|
||||||
|
|
||||||
|
make $MAKEFLAGS allmulti MULTI_NAME=vlmcsdmulti-iOS-armv7 CLIENT_NAME=vlmcs-iOS-armv7 PROGRAM_NAME=vlmcsd-iOS-armv7 CC=clang CFLAGS="$CFCLANG" PLATFORMFLAGS="-mthumb -m32 -arch armv7 -miphoneos-version-min=1.0 -isysroot ~/toolchains/iPhoneOS.sdk" && \
|
||||||
|
make $MAKEFLAGS allmulti MULTI_NAME=vlmcsdmulti-iOS-armv8-aarch64 CLIENT_NAME=vlmcs-iOS-armv8-aarch64 PROGRAM_NAME=vlmcsd-iOS-armv8-aarch64 CC=clang CFLAGS="$CFCLANG" PLATFORMFLAGS="-m64 -arch arm64 -miphoneos-version-min=7.0 -isysroot ~/toolchains/iPhoneOS.sdk" && \
|
||||||
|
|
||||||
|
make $MAKEFLAGS allmulti MULTI_NAME=vlmcsdmulti-iOS-6.1-armv7 CLIENT_NAME=vlmcs-iOS-6.1-armv7 PROGRAM_NAME=vlmcsd-iOS-6.1-armv7 CC=clang CFLAGS="$CFCLANG" PLATFORMFLAGS="-mthumb -m32 -arch armv7 -miphoneos-version-min=1.0 --sysroot ~/toolchains/iPhoneOS6.1.sdk -isysroot ~/toolchains/iPhoneOS6.1.sdk" && \
|
||||||
|
|
||||||
|
make $MAKEFLAGS allmulti MULTI_NAME=vlmcsdmulti-iOS-5.1-armv7-clang3.4 CLIENT_NAME=vlmcs-iOS-5.1-armv7-clang3.4 PROGRAM_NAME=vlmcsd-iOS-5.1-armv7-clang3.4 CC=clang CFLAGS="$CFCLANG" PLATFORMFLAGS="-mthumb -m32 -arch armv7 -miphoneos-version-min=1.0 --sysroot ~/toolchains/iPhoneOS5.1.sdk -isysroot ~/toolchains/iPhoneOS5.1.sdk" && \
|
||||||
|
|
||||||
|
#PATH=~/toolchains/iOS5.1-MacOS-Lion/usr/bin:$PATH clang --version
|
||||||
|
PATH=~/toolchains/iOS5.1-MacOS-Lion/usr/bin:$PATH make $MAKEFLAGS allmulti MULTI_NAME=vlmcsdmulti-iOS-5.1-armv6-clang3.1 CLIENT_NAME=vlmcs-iOS-5.1-armv6-clang3.1 PROGRAM_NAME=vlmcsd-iOS-5.1-armv6-clang3.1 CC=clang CFLAGS="$CFCLANG" PLATFORMFLAGS="-arch armv6 -miphoneos-version-min=1.0 --sysroot ~/toolchains/iPhoneOS5.1.sdk -isysroot ~/toolchains/iPhoneOS5.1.sdk" && \
|
||||||
|
|
||||||
|
#PATH=~/toolchains/gcc4.2/usr/bin/bin:$PATH make $MAKEFLAGS CLIENT_NAME=vlmcs-iOS-4.1-armv6-llvm-gcc4.2 PROGRAM_NAME=vlmcsd-iOS-4.1-armv6-llvm-gcc4.2 CC=llvm-g++-4.2 CFLAGS="$CFGCC42" PLATFORMFLAGS="-arch armv6 -miphoneos-version-min=1.0 --sysroot ~/toolchains/iPhoneOS4.1.sdk -isysroot ~/toolchains/iPhoneOS4.1.sdk" && \
|
||||||
|
#rm -f vlmcs.o vlmcsd.o vlmcsdmulti.o *_all.* && \
|
||||||
|
#PATH=~/toolchains/gcc4.2/usr/bin/bin:$PATH make $REUSEOBJFLAGS vlmcsdmulti-iOS-4.1-armv6-llvm-gcc4.2 MULTI_NAME=vlmcsdmulti-iOS-4.1-armv6-llvm-gcc4.2 CC=llvm-g++-4.2 CFLAGS="$CFGCC42" PLATFORMFLAGS="-arch armv6 -miphoneos-version-min=1.0 --sysroot ~/toolchains/iPhoneOS4.1.sdk -isysroot ~/toolchains/iPhoneOS4.1.sdk" && \
|
||||||
|
|
||||||
|
#PATH=~/toolchains/gcc4.2/usr/bin:$PATH make $MAKEFLAGS CLIENT_NAME=vlmcs-iOS-4.1-armv7-clang PROGRAM_NAME=vlmcsd-iOS-4.1-armv7-llvm-clang CC=~/toolchains/gcc4.2/usr/bin/bin/clang CFLAGS="$CFGCC42" PLATFORMFLAGS="-mthumb -arch armv7 -miphoneos-version-min=4.1 --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk" && \
|
||||||
|
#rm -f vlmcs.o vlmcsd.o vlmcsdmulti.o && \
|
||||||
|
#PATH=~/toolchains/gcc4.2/usr/bin:$PATH make $REUSEOBJFLAGS vlmcsdmulti-iOS-4.1-armv7-llvm-clang MULTI_NAME=vlmcsdmulti-iOS-4.1-armv7-llvm-clang CC=~/toolchains/gcc4.2/usr/bin/bin/clang CFLAGS="$CFGCC42" PLATFORMFLAGS="-mthumb -arch armv7 -miphoneos-version-min=4.1 --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk" && \
|
||||||
|
|
||||||
|
|
||||||
|
PATH=~/toolchains/gcc4.2/usr/bin:$PATH make -Bj allmulti SAFE_MODE=1 MULTI_NAME=vlmcsdmulti-MacOSX-ppc PROGRAM_NAME=vlmcsd-MacOSX-ppc CLIENT_NAME=vlmcs-MacOSX-ppc CC=gcc CFLAGS="$CFGCC42 -isysroot ~/toolchains/MacOSX10.5.sdk -arch ppc -mmacosx-version-min=10.0" && \
|
||||||
|
|
||||||
|
|
||||||
|
make $MAKEFLAGS allmulti MULTI_NAME=vlmcsdmulti-MacOSX-x86-gcc CLIENT_NAME=vlmcs-MacOSX-x86-gcc PROGRAM_NAME=vlmcsd-MacOSX-x86-gcc CC=gcc-5 CFLAGS="$CFGCC" PLATFORMFLAGS="-m32 -march=core2 -mmacosx-version-min=10.11" && \
|
||||||
|
make $MAKEFLAGS vlmcsd-MacOSX-x86-threads-gcc THREADS=1 PROGRAM_NAME=vlmcsd-MacOSX-x86-threads-gcc CC=gcc-5 CFLAGS="$CFGCC" PLATFORMFLAGS="-m32 -march=core2 -mmacosx-version-min=10.11" && \
|
||||||
|
make $MAKEFLAGS allmulti MULTI_NAME=vlmcsdmulti-MacOSX-x64-gcc CLIENT_NAME=vlmcs-MacOSX-x64-gcc PROGRAM_NAME=vlmcsd-MacOSX-x64-gcc CC=gcc-5 CFLAGS="$CFGCC" PLATFORMFLAGS="-m64 -march=core2 -mmacosx-version-min=10.11" && \
|
||||||
|
make $MAKEFLAGS vlmcsd-MacOSX-x64-threads-gcc THREADS=1 PROGRAM_NAME=vlmcsd-MacOSX-x64-threads-gcc CC=gcc-5 CFLAGS="$CFGCC" PLATFORMFLAGS="-m64 -march=core2 -mmacosx-version-min=10.11" && \
|
||||||
|
|
||||||
|
# Sign the iOS binaries
|
||||||
|
#ldid -S *iOS*
|
||||||
|
|
||||||
|
#strip vlmcs-* vlmcsd-* vlmcsdmulti-*
|
||||||
|
|
||||||
|
rm -f *.o *_all.*
|
||||||
|
rm -fr *.dSYM
|
||||||
|
|
||||||
|
sudo cp -p vlmcs-MacOSX-x86-gcc /usr/local/bin/vlmcs
|
||||||
|
sudo cp -p vlmcsd-MacOSX-x86-gcc /usr/local/bin/vlmcsd
|
||||||
|
|
||||||
|
sudo mkdir -p /usr/local/share/man/man8
|
||||||
|
sudo mkdir -p /usr/local/share/man/man1
|
||||||
|
sudo mkdir -p /usr/local/share/man/man7
|
||||||
|
sudo mkdir -p /usr/local/share/man/man5
|
||||||
|
|
||||||
|
sudo cp -p vlmcsd.8 /usr/local/share/man/man8
|
||||||
|
sudo cp -p vlmcs.1 vlmcsdmulti.1 /usr/local/share/man/man1
|
||||||
|
sudo cp -p vlmcsd-floppy.7 vlmcsd.7 /usr/local/share/man/man7
|
||||||
|
sudo cp -p vlmcsd.ini.5 //usr/local/share/man/man5
|
||||||
|
|
||||||
|
# Copy the stuff to distribution server
|
||||||
|
scp -p vlmcsd-MacOSX-x* vlmcs-MacOSX-x* vlmcsdmulti-MacOSX-x* root@ubuntu64:x/binaries/MacOSX/intel
|
||||||
|
scp -p vlmcsd-MacOSX-ppc* vlmcs-MacOSX-ppc* vlmcsdmulti-MacOSX-ppc* root@ubuntu64:x/binaries/MacOSX/ppc
|
||||||
|
scp -p vlmcsd-iOS* vlmcs-iOS* vlmcsdmulti-iOS* root@ubuntu64:x/binaries/iOS/arm
|
||||||
Executable
+54
@@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
export VLMCSD_VERSION="svn`svnversion`"
|
||||||
|
export VERBOSE=3
|
||||||
|
export CAT=2
|
||||||
|
|
||||||
|
if [ `uname -s` != "SunOS" ]; then
|
||||||
|
echo "This is no SunOS operating system."
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
SOLARIS_VERSION=`uname -v`
|
||||||
|
|
||||||
|
rm -f vlmcsd-Solaris* vlmcs-* vlmcsdmulti-* *_all.* 2>/dev/null
|
||||||
|
rm -f vlmcsdmulti vlmcsd vlmcs 2>/dev/null
|
||||||
|
|
||||||
|
MAKEFLAGS="-B -j`nproc`"
|
||||||
|
REUSEOBJFLAGS="-j`nproc`"
|
||||||
|
|
||||||
|
CF="-fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants -Wno-char-subscripts"
|
||||||
|
LF="-fwhole-program -Wl,-z,norelro -Wl,--hash-style=sysv -Wl,--build-id=none"
|
||||||
|
|
||||||
|
|
||||||
|
# 32 bit
|
||||||
|
if [ "$CAT" != "" ]; then
|
||||||
|
gmake $MAKEFLAGS LD_ALTEXEC=/usr/bin/gld vlmcs-Solaris$SOLARIS_VERSION-x86 vlmcsd-Solaris$SOLARIS_VERSION-x86 vlmcsdmulti-Solaris$SOLARIS_VERSION-x86 CLIENT_NAME=vlmcs-Solaris$SOLARIS_VERSION-x86 PROGRAM_NAME=vlmcsd-Solaris$SOLARIS_VERSION-x86 MULTI_NAME=vlmcsdmulti-Solaris$SOLARIS_VERSION-x86 CC=gcc CFLAGS="$CF" LDFLAGS="$LF"
|
||||||
|
else
|
||||||
|
gmake $MAKEFLAGS LD_ALTEXEC=/usr/bin/gld MULTI_NAME=vlmcsdmulti-Solaris$SOLARIS_VERSION-x86 CLIENT_NAME=vlmcs-Solaris$SOLARIS_VERSION-x86 PROGRAM_NAME=vlmcsd-Solaris$SOLARIS_VERSION-x86 CC=gcc CFLAGS="$CF" LDFLAGS="$LF" allmulti
|
||||||
|
fi
|
||||||
|
|
||||||
|
gmake $MAKEFLAGS LD_ALTEXEC=/usr/bin/gld vlmcsd-Solaris$SOLARIS_VERSION-x86-threads PROGRAM_NAME=vlmcsd-Solaris$SOLARIS_VERSION-x86-threads CC=gcc THREADS=1 CFLAGS="$CF" LDFLAGS="-lpthread $LF"
|
||||||
|
gmake $MAKEFLAGS LD_ALTEXEC=/usr/bin/gld CLIENT_NAME=vlmcs-Solaris$SOLARIS_VERSION-x86-openssl1.0-EXPERIMENTAL CRYPTO=openssl_with_aes PROGRAM_NAME=vlmcsd-Solaris$SOLARIS_VERSION-x86-openssl1.0-EXPERIMENTAL CC=gcc CFLAGS="$CF" LDFLAGS="$LF"
|
||||||
|
|
||||||
|
# 64 bit
|
||||||
|
|
||||||
|
LF="$LF -Wl,-melf_x86_64_sol2"
|
||||||
|
|
||||||
|
if [ "$CAT" != "" ]; then
|
||||||
|
gmake $MAKEFLAGS LD_ALTEXEC=/usr/bin/gld vlmcsdmulti-Solaris$SOLARIS_VERSION-x64 vlmcs-Solaris$SOLARIS_VERSION-x64 vlmcsd-Solaris$SOLARIS_VERSION-x64 MULTI_NAME=vlmcsdmulti-Solaris$SOLARIS_VERSION-x64 CLIENT_NAME=vlmcs-Solaris$SOLARIS_VERSION-x64 PROGRAM_NAME=vlmcsd-Solaris$SOLARIS_VERSION-x64 CC=gcc CFLAGS="$CF" LDFLAGS="$LF" PLATFORMFLAGS="-m64"
|
||||||
|
else
|
||||||
|
gmake $MAKEFLAGS LD_ALTEXEC=/usr/bin/gld MULTI_NAME=vlmcsdmulti-Solaris$SOLARIS_VERSION-x64 CLIENT_NAME=vlmcs-Solaris$SOLARIS_VERSION-x64 PROGRAM_NAME=vlmcsd-Solaris$SOLARIS_VERSION-x64 CC=gcc CFLAGS="$CF" LDFLAGS="$LF" PLATFORMFLAGS="-m64" allmulti
|
||||||
|
fi
|
||||||
|
|
||||||
|
gmake $MAKEFLAGS LD_ALTEXEC=/usr/bin/gld vlmcsd-Solaris$SOLARIS_VERSION-x64-threads PROGRAM_NAME=vlmcsd-Solaris$SOLARIS_VERSION-x64-threads CC=gcc THREADS=1 CFLAGS="$CF" LDFLAGS="$LF -lpthread" PLATFORMFLAGS="-m64"
|
||||||
|
gmake $MAKEFLAGS LD_ALTEXEC=/usr/bin/gld CLIENT_NAME=vlmcs-Solaris$SOLARIS_VERSION-x64-openssl1.0-EXPERIMENTAL CRYPTO=openssl_with_aes PROGRAM_NAME=vlmcsd-Solaris$SOLARIS_VERSION-x64-openssl1.0-EXPERIMENTAL CC=gcc CFLAGS="$CF" LDFLAGS="$LF" PLATFORMFLAGS="-m64"
|
||||||
|
|
||||||
|
rm -f *.o *_all.*
|
||||||
|
|
||||||
|
gstrip -s --strip-unneeded --remove-section=.note.gnu.gold-version --remove-section=.comment --remove-section=.note --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag vlmcs-* vlmcsd-*
|
||||||
|
#gstrip -s --strip-unneeded --remove-section=.eh_frame_hdr --remove-section=.eh_frame --remove-section=.note.gnu.gold-version --remove-section=.comment --remove-section=.note --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag vlmcs-* vlmcsd-*
|
||||||
|
#sstrip -z vlmcs-* vlmcsd-*
|
||||||
|
|
||||||
|
# Copy stuff to distribution server
|
||||||
|
scp -p vlmcsd-Sola* vlmcs-* vlmcsdmulti-* root@ubuntu64:x/binaries/Solaris/intel
|
||||||
Executable
+85
@@ -0,0 +1,85 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export VLMCSD_VERSION="svn`svnversion`"
|
||||||
|
rm -f cygkms*.dll libkms*.dll vlmcs-* vlmcsd-win* vlmcsd-cyg* vlmcsdmulti-* *_all.* vlmcsd.exe vlmcs.exe vlmcsdmulti.exe 2> /dev/null
|
||||||
|
|
||||||
|
export CAT=2
|
||||||
|
export VERBOSE=3
|
||||||
|
NUMCPU=`cat /proc/cpuinfo | grep "processor" | wc -l`
|
||||||
|
|
||||||
|
CF="-Wno-missing-braces -fno-common -fno-exceptions -fno-non-call-exceptions -fno-stack-protector -fmerge-all-constants -fno-unwind-tables -fno-asynchronous-unwind-tables -pipe"
|
||||||
|
CFMSRPC="-Wno-missing-braces -Wno-unused-variable $CF" # -fno-common -fno-stack-protector -fmerge-all-constants -pipe"
|
||||||
|
PF32=""
|
||||||
|
PF64="-mpreferred-stack-boundary=4 -march=nocona -mtune=generic"
|
||||||
|
LFCYG32="-fwhole-program -Wl,--nxcompat,--dynamicbase,--tsaware,--large-address-aware,--disable-long-section-names"
|
||||||
|
LFWIN32="-fwhole-program -Wl,--nxcompat,--dynamicbase,--tsaware,--large-address-aware,--disable-long-section-names"
|
||||||
|
LFCYG64="-fwhole-program -Wl,--nxcompat,--dynamicbase,--tsaware,--disable-long-section-names,--high-entropy-va"
|
||||||
|
LFWIN64="-fwhole-program -Wl,--nxcompat,--dynamicbase,--tsaware,--disable-long-section-names,--high-entropy-va"
|
||||||
|
|
||||||
|
MAKEFLAGS="-j$NUMCPU -B"
|
||||||
|
REUSEFLAGS="-j$NUMCPU"
|
||||||
|
|
||||||
|
make $MAKEFLAGS cygkms32.dll FEATURES=minimum THREADS=1 DLL_NAME=cygkms32.dll DNS_PARSER=internal CC=i686-pc-cygwin-gcc.exe CFLAGS="$CF -flto=jobserver -fvisibility=hidden" PLATFORMFLAGS="$PF32" LDFLAGS="$LFCYG32 -Wl,--no-seh"
|
||||||
|
make $MAKEFLAGS cygkms64.dll FEATURES=minimum THREADS=1 DLL_NAME=cygkms64.dll DNS_PARSER=internal CC=x86_64-pc-cygwin-gcc.exe CFLAGS="$CF -flto=jobserver -fvisibility=hidden" PLATFORMFLAGS="$PF64" LDFLAGS="$LFCYG64 -Wl,--no-seh"
|
||||||
|
make $MAKEFLAGS allmulti THREADS=1 DNS_PARSER=internal CLIENT_NAME=vlmcs-cygwin-x86 PROGRAM_NAME=vlmcsd-cygwin-x86 MULTI_NAME=vlmcsdmulti-cygwin-x86 CC=i686-pc-cygwin-gcc.exe CFLAGS="$CF" PLATFORMFLAGS="$PF32" LDFLAGS="$LFCYG32 -Wl,--no-seh"
|
||||||
|
make $MAKEFLAGS allmulti THREADS=1 DNS_PARSER=internal CLIENT_NAME=vlmcs-cygwin-x64 PROGRAM_NAME=vlmcsd-cygwin-x64 MULTI_NAME=vlmcsdmulti-cygwin-x64 CC=x86_64-pc-cygwin-gcc.exe CFLAGS="$CF" PLATFORMFLAGS="$PF64" LDFLAGS="$LFCYG64 -Wl,--no-seh"
|
||||||
|
make $MAKEFLAGS MSRPC=1 THREADS=1 DNS_PARSER=internal CLIENT_NAME=vlmcs-cygwin-msrpc-x86 PROGRAM_NAME=vlmcsd-cygwin-msrpc-x86 MULTI_NAME=vlmcsdmulti-cygwin-msrpc-x86 CC=i686-pc-cygwin-gcc.exe CFLAGS="$CF -fasynchronous-unwind-tables" PLATFORMFLAGS="$PF32" LDFLAGS="$LFCYG32"
|
||||||
|
make $MAKEFLAGS MSRPC=1 THREADS=1 DNS_PARSER=internal CLIENT_NAME=vlmcs-cygwin-msrpc-x64 PROGRAM_NAME=vlmcsd-cygwin-msrpc-x64 MULTI_NAME=vlmcsdmulti-cygwin-msrpc-x64 CC=x86_64-pc-cygwin-gcc.exe CFLAGS="$CFMSRPC" PLATFORMFLAGS="$PF64" LDFLAGS="$LFCYG64"
|
||||||
|
unset CAT
|
||||||
|
make $MAKEFLAGS vlmcsdmulti-cygwin-msrpc-x64 MSRPC=1 THREADS=1 DNS_PARSER=internal MULTI_NAME=vlmcsdmulti-cygwin-msrpc-x64 CC=x86_64-pc-cygwin-gcc.exe CFLAGS="$CFMSRPC -flto=jobserver" PLATFORMFLAGS="$PF64" LDFLAGS="$LFCYG64"
|
||||||
|
make $MAKEFLAGS vlmcsdmulti-cygwin-msrpc-x86 MSRPC=1 THREADS=1 DNS_PARSER=internal MULTI_NAME=vlmcsdmulti-cygwin-msrpc-x86 CC=i686-pc-cygwin-gcc.exe CFLAGS="$CFMSRPC -flto=jobserver" PLATFORMFLAGS="$PF32" LDFLAGS="$LFCYG32"
|
||||||
|
export CAT=2
|
||||||
|
|
||||||
|
make $MAKEFLAGS THREADS=1 MSRPC=1 DNS_PARSER=internal CLIENT_NAME=vlmcs-cygwin-msrpc-x86-openssl-EXPERIMENTAL CRYPTO=openssl_with_aes PROGRAM_NAME=vlmcsd-cygwin-x86-openssl-EXPERIMENTAL CC=i686-pc-cygwin-gcc.exe CFLAGS="$CFMSRPC" PLATFORMFLAGS="$PF32" LDFLAGS="$LFCYG32"
|
||||||
|
make $MAKEFLAGS THREADS=1 MSRPC=1 DNS_PARSER=internal CLIENT_NAME=vlmcs-cygwin-msrpc-x64-openssl-EXPERIMENTAL CRYPTO=openssl_with_aes PROGRAM_NAME=vlmcsd-cygwin-x64-openssl-EXPERIMENTAL CC=x86_64-pc-cygwin-gcc.exe CFLAGS="$CFMSRPC" PLATFORMFLAGS="$PF64" LDFLAGS="$LFCYG64"
|
||||||
|
|
||||||
|
export CAT=2
|
||||||
|
#unset CAT
|
||||||
|
make $MAKEFLAGS libkms32.dll CRYPTO=windows FEATURES=minimum THREADS=1 DLL_NAME=libkms32.dll CC=i686-w64-MingW32-gcc.exe CFLAGS="$CF -flto=jobserver -fvisibility=hidden" PLATFORMFLAGS="$PF32" LDFLAGS="-static-libgcc $LFWIN32"
|
||||||
|
make $MAKEFLAGS libkms64.dll CRYPTO=windows FEATURES=minimum THREADS=1 DLL_NAME=libkms64.dll CC=x86_64-w64-MingW32-gcc.exe CFLAGS="$CF -flto=jobserver -fvisibility=hidden" PLATFORMFLAGS="$PF64" LDFLAGS="-static-libgcc $LFWIN64"
|
||||||
|
#make $MAKEFLAGS all vlmcsdmulti-Windows-x86 THREADS=1 CRYPTO=windows CLIENT_NAME=vlmcs-Windows-x86 PROGRAM_NAME=vlmcsd-Windows-x86 MULTI_NAME=vlmcsdmulti-Windows-x86 CC=i686-w64-MingW32-gcc.exe CFLAGS="$CF" PLATFORMFLAGS="$PF32" LDFLAGS="$LFWIN32"
|
||||||
|
#make $MAKEFLAGS all vlmcsdmulti-Windows-x64 THREADS=1 CRYPTO=windows CLIENT_NAME=vlmcs-Windows-x64 PROGRAM_NAME=vlmcsd-Windows-x64 MULTI_NAME=vlmcsdmulti-Windows-x64 CC=x86_64-w64-MingW32-gcc.exe CFLAGS="$CF" PLATFORMFLAGS="$PF64" LDFLAGS="$LFWIN64"
|
||||||
|
#make -Bj MSRPC=1 CRYPTO=windows CLIENT_NAME=vlmcs-Windows-msrpc-x86 PROGRAM_NAME=vlmcsd-Windows-msrpc-x86 MULTI_NAME=vlmcsdmulti-Windows-msrpc-x86 CC=i686-w64-MingW32-gcc.exe CFLAGS="$CFMSRPC" PLATFORMFLAGS="$PF32" LDFLAGS="-Wl,--nxcompat,--dynamicbase,--tsaware,--large-address-aware"
|
||||||
|
#make $MAKEFLAGS THREADS=1 MSRPC=1 CRYPTO=windows CLIENT_NAME=vlmcs-Windows-msrpc-x64 PROGRAM_NAME=vlmcsd-Windows-msrpc-x64 MULTI_NAME=vlmcsdmulti-Windows-msrpc-x64 CC=x86_64-w64-MingW32-gcc.exe CFLAGS="$CFMSRPC" PLATFORMFLAGS="$PF64" LDFLAGS="$LFCYG64"
|
||||||
|
#unset CAT
|
||||||
|
#make $MAKEFLAGS vlmcsdmulti-Windows-msrpc-x86 THREADS=1 MSRPC=1 CRYPTO=windows MULTI_NAME=vlmcsdmulti-Windows-msrpc-x86 CC=i686-w64-MingW32-gcc.exe CFLAGS="$CFMSRPC" PLATFORMFLAGS="$PF32" LDFLAGS="-Wl,--nxcompat,--dynamicbase,--tsaware,--large-address-aware"
|
||||||
|
#make $MAKEFLAGS vlmcsdmulti-Windows-msrpc-x64 THREADS=1 MSRPC=1 CRYPTO=windows MULTI_NAME=vlmcsdmulti-Windows-msrpc-x64 CC=x86_64-w64-MingW32-gcc.exe CFLAGS="$CFMSRPC" PLATFORMFLAGS="$PF64" LDFLAGS="$LFCYG64"
|
||||||
|
export CAT=2
|
||||||
|
|
||||||
|
rm -f *_all.* *.o 2> /dev/null &
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Copying MingW binaries from distribution server"
|
||||||
|
|
||||||
|
scp -p root@ubuntu64:x/binaries/Windows/intel/*Windows* root@ubuntu64:x/binaries/Windows/intel/libkms* .
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Installing binaries"
|
||||||
|
|
||||||
|
cp -p vlmcs-cygwin-x64.exe /usr/local/bin/vlmcs &
|
||||||
|
cp -p vlmcsd-cygwin-x64.exe /usr/local/bin/vlmcsd &
|
||||||
|
cp -p cygkms64.dll /usr/local/bin/cygkms.dll &
|
||||||
|
|
||||||
|
cp -p libkms32.dll /cygdrive/c/nttools/x86 &
|
||||||
|
cp -p libkms64.dll /cygdrive/c/nttools/x64 &
|
||||||
|
cp -p vlmcsdmulti-Windows-x86.exe /cygdrive/c/nttools/x86/vlmcsdmulti.exe
|
||||||
|
|
||||||
|
cmd /C mklink c:\\nttools\\x86\\vlmcsd.exe vlmcsdmulti.exe 2> /dev/null &
|
||||||
|
cmd /C mklink c:\\nttools\\x86\\vlmcs.exe vlmcsdmulti.exe 2> /dev/null &
|
||||||
|
|
||||||
|
echo "Installing man pages"
|
||||||
|
|
||||||
|
mkdir -p /usr/share/man/man8
|
||||||
|
mkdir -p /usr/share/man/man1
|
||||||
|
mkdir -p /usr/share/man/man7
|
||||||
|
mkdir -p /usr/share/man/man5
|
||||||
|
|
||||||
|
cp -p vlmcsd.7 vlmcsd-floppy.7 /usr/share/man/man7
|
||||||
|
cp -p vlmcsd.8 /usr/share/man/man8
|
||||||
|
cp -p vlmcsd.ini.5 /usr/share/man/man5
|
||||||
|
cp -p vlmcs.1 vlmcsdmulti.1 /usr/share/man/man1
|
||||||
|
|
||||||
|
bzip2 -f /usr/share/man/man7/vlmcsd-floppy.7 /usr/share/man/man5/vlmcsd.ini.5 /usr/share/man/man7/vlmcsd.7 /usr/share/man/man8/vlmcsd.8 /usr/share/man/man1/vlmcs.1 /usr/share/man/man1/vlmcsdmulti.1 &
|
||||||
|
|
||||||
|
# Copy stuff to distribution server
|
||||||
|
scp -p vlmcsd-cyg* vlmcsd-Win* vlmcs-* vlmcsdmulti-* *.dll root@ubuntu64:x/binaries/Windows/intel
|
||||||
Executable
+17
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# To use on x64 hosted native multilib compiler toolchain
|
||||||
|
#
|
||||||
|
|
||||||
|
rm vlmcsd-*
|
||||||
|
rm vlmcsd
|
||||||
|
|
||||||
|
MAKEFLAGS="-j -B"
|
||||||
|
|
||||||
|
make $MAKEFLAGS PROGRAM_NAME=vlmcsd-mingw64-x86 CC=x86_64-w64-mingw32-gcc.exe CFLAGS="-flto -m32" "PLATFORMFLAGS=-march=i686 -mtune=generic" "LDFLAGS=-lcrypto -lz -lkernel32 -ladvapi32 -lws2_32 -lgdi32"
|
||||||
|
make $MAKEFLAGS PROGRAM_NAME=vlmcsd-mingw64-x64 CC=x86_64-w64-mingw32-gcc.exe CFLAGS="-flto" "PLATFORMFLAGS=-mtune=generic" "LDFLAGS=-lcrypto -lz -lkernel32 -ladvapi32 -lws2_32 -lgdi32"
|
||||||
|
make $MAKEFLAGS CRYPTO=openssl_with_aes PROGRAM_NAME=vlmcsd-mingw64-x86-openssl CC=x86_64-w64-mingw32-gcc.exe CFLAGS="-flto -m32" "PLATFORMFLAGS=-march=i686 -mtune=generic" "LDFLAGS=-lcrypto -lz -lkernel32 -ladvapi32 -lws2_32 -lgdi32"
|
||||||
|
make $MAKEFLAGS CRYPTO=openssl_with_aes PROGRAM_NAME=vlmcsd-mingw64-x64-openssl CC=x86_64-w64-mingw32-gcc.exe CFLAGS="-flto" "PLATFORMFLAGS=-mtune=generic" "LDFLAGS=-lcrypto -lz -lkernel32 -ladvapi32 -lws2_32 -lgdi32"
|
||||||
|
|
||||||
|
rm *.o
|
||||||
+191
@@ -0,0 +1,191 @@
|
|||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#ifdef USE_MSRPC
|
||||||
|
|
||||||
|
#if !defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
#error MSRPC is only available with native Windows or Cygwin
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "msrpc-client.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "output.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
|
#if __amd64 || defined(_M_AMD64) // 64-bit
|
||||||
|
|
||||||
|
#ifndef _M_AMD64
|
||||||
|
#define _M_AMD64
|
||||||
|
#endif // _M_AMD64
|
||||||
|
|
||||||
|
#include "KMSServer_c_x64_mingw_gcc.c"
|
||||||
|
|
||||||
|
#else // 32-bit
|
||||||
|
|
||||||
|
#include "KMSServer_c_mingw_gcc.c"
|
||||||
|
|
||||||
|
#endif // 32-bit
|
||||||
|
|
||||||
|
static RPC_CSTR stringBinding;
|
||||||
|
jmp_buf jmp;
|
||||||
|
RPC_STATUS PreviousRpcCallFailed = RPC_S_OK;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates an RPC string binding that is used to connect to the server.
|
||||||
|
* Input is host:port, e.g. "[::1]:1688" or "127.0.0.1:1688"
|
||||||
|
* Output is for example "ncacn_ip_tcp:127.0.0.1[endpoint=1688]"
|
||||||
|
*/
|
||||||
|
#if !__amd64
|
||||||
|
#pragma GCC optimize("O0") ////TODO: Find out why gcc needs -O0 for RPC handling
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static RPC_STATUS createStringBinding(char *const addr, RPC_CSTR* stringBinding)
|
||||||
|
{
|
||||||
|
char *szHost, *szPort;
|
||||||
|
|
||||||
|
parseAddress(addr, &szHost, &szPort);
|
||||||
|
|
||||||
|
return RpcStringBindingComposeA
|
||||||
|
(
|
||||||
|
NULL, /* UUID */
|
||||||
|
(RPC_CSTR)"ncacn_ip_tcp", /* use TCP */
|
||||||
|
(RPC_CSTR)szHost, /* host name or IP address */
|
||||||
|
(RPC_CSTR)szPort, /* endpoint (TCP port here) */
|
||||||
|
NULL, /* options */
|
||||||
|
stringBinding /* resulting string binding */
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This does not actually connect to a TCP port because MS RPC doesn't connect
|
||||||
|
* before the actual RPC call is made. So this a stub
|
||||||
|
*/
|
||||||
|
RpcCtx connectToAddress(char *const addr, const int AddressFamily_unused, int_fast8_t showHostName_unused)
|
||||||
|
{
|
||||||
|
RPC_STATUS status;
|
||||||
|
|
||||||
|
printf("Connecting to %s ... ", addr);
|
||||||
|
|
||||||
|
if ((status = createStringBinding(addr, &stringBinding)) != RPC_S_OK)
|
||||||
|
{
|
||||||
|
printerrorf("%s\n", win_strerror(status));
|
||||||
|
return !0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PreviousRpcCallFailed)
|
||||||
|
{
|
||||||
|
printerrorf("%s\n", win_strerror(PreviousRpcCallFailed));
|
||||||
|
return !0;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("successful\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Does not do RPC binding on the wire. Just initializes the interface
|
||||||
|
*/
|
||||||
|
RpcStatus rpcBindClient(const RpcCtx handle, const int_fast8_t verbose)
|
||||||
|
{
|
||||||
|
RPC_STATUS status;
|
||||||
|
|
||||||
|
if ((status = RpcBindingFromStringBindingA(stringBinding, &KMSServer_v1_0_c_ifspec)) != RPC_S_OK)
|
||||||
|
{
|
||||||
|
errorout("\n%s\n", win_strerror(status));
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* You never know if you have a TCP connection or not
|
||||||
|
* This returns true if the previous RPC call failed
|
||||||
|
*/
|
||||||
|
int_fast8_t isDisconnected(const RpcCtx handle)
|
||||||
|
{
|
||||||
|
return PreviousRpcCallFailed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the exception handler because the RPC call may
|
||||||
|
* throw an SEH exception and gcc does not support
|
||||||
|
* __try / __except as MSVC does.
|
||||||
|
*/
|
||||||
|
static LONG WINAPI rpcException (LPEXCEPTION_POINTERS exception_pointers)
|
||||||
|
{
|
||||||
|
DWORD exception = exception_pointers->ExceptionRecord->ExceptionCode;
|
||||||
|
if (!exception) exception = (DWORD)~0;
|
||||||
|
longjmp(jmp, exception_pointers->ExceptionRecord->ExceptionCode);
|
||||||
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This actually calls the RPC server
|
||||||
|
*/
|
||||||
|
#define try SetUnhandledExceptionFilter(rpcException); RPC_STATUS exception = setjmp(jmp); if (!exception)
|
||||||
|
#define catch else
|
||||||
|
RpcStatus rpcSendRequest(const RpcCtx handle, BYTE* KmsRequest, const size_t requestSize, BYTE **KmsResponse, size_t* responseSize)
|
||||||
|
{
|
||||||
|
*KmsResponse = NULL; // Let midl_user_allocate do the job
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
exception = RequestActivation(KMSServer_v1_0_c_ifspec, (int)requestSize, KmsRequest, (int*)responseSize, KmsResponse);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
errorout("\n%s", win_strerror(exception));
|
||||||
|
}
|
||||||
|
|
||||||
|
PreviousRpcCallFailed = exception;
|
||||||
|
SetUnhandledExceptionFilter(NULL);
|
||||||
|
|
||||||
|
return exception;
|
||||||
|
|
||||||
|
}
|
||||||
|
#undef catch
|
||||||
|
#undef try
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Only frees local handles. Cannot close the TCP connection
|
||||||
|
*/
|
||||||
|
RpcStatus closeRpc(const RpcCtx handle)
|
||||||
|
{
|
||||||
|
RPC_STATUS status;
|
||||||
|
|
||||||
|
if ((status = RpcBindingFree(&KMSServer_v1_0_c_ifspec)) != RPC_S_OK) return status;
|
||||||
|
status = RpcStringFreeA(&stringBinding);
|
||||||
|
//Ctx = INVALID_RPCCTX;
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !MULTI_CALL_BINARY
|
||||||
|
// Memory allocation function for RPC.
|
||||||
|
void *__RPC_USER midl_user_allocate(SIZE_T len)
|
||||||
|
{
|
||||||
|
return vlmcsd_malloc(len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Memory deallocation function for RPC.
|
||||||
|
void __RPC_USER midl_user_free(void __RPC_FAR *ptr)
|
||||||
|
{
|
||||||
|
if (ptr) free(ptr);
|
||||||
|
ptr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !MULTI_CALL_BINARY
|
||||||
|
|
||||||
|
|
||||||
|
#endif // USE_MSRPC
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* msrpc-client.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MSRPC_CLIENT_H_
|
||||||
|
#define MSRPC_CLIENT_H_
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include "output.h"
|
||||||
|
|
||||||
|
typedef int_fast8_t RpcCtx;
|
||||||
|
typedef RPC_STATUS RpcStatus;
|
||||||
|
|
||||||
|
RpcCtx connectToAddress(char *const addr, const int AddressFamily_unused, int_fast8_t showHostName);
|
||||||
|
int_fast8_t isDisconnected(const RpcCtx handle);
|
||||||
|
RpcStatus rpcBindClient(const RpcCtx handle, const int_fast8_t verbose);
|
||||||
|
RpcStatus rpcSendRequest(const RpcCtx handle, BYTE* KmsRequest, size_t requestSize, BYTE **KmsResponse, size_t *responseSize);
|
||||||
|
RpcStatus closeRpc(RpcCtx s);
|
||||||
|
|
||||||
|
#define INVALID_RPCCTX ((RpcCtx)~0)
|
||||||
|
|
||||||
|
#endif /* MSRPC_CLIENT_H_ */
|
||||||
+311
@@ -0,0 +1,311 @@
|
|||||||
|
#ifndef CONFIG
|
||||||
|
#define CONFIG "config.h"
|
||||||
|
#endif // CONFIG
|
||||||
|
#include CONFIG
|
||||||
|
|
||||||
|
#ifdef USE_MSRPC
|
||||||
|
|
||||||
|
#if !defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
#error MSRPC is only available with native Windows or Cygwin
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _WIN32 && !defined(NO_PRIVATE_IP_DETECT)
|
||||||
|
#include <winsock2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "msrpc-server.h"
|
||||||
|
#include "output.h"
|
||||||
|
#include "kms.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
#include "shared_globals.h"
|
||||||
|
#include "ntservice.h"
|
||||||
|
#include "endian.h"
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
#if __amd64 || defined(_M_AMD64) // 64-bit
|
||||||
|
|
||||||
|
#ifndef _M_AMD64
|
||||||
|
#define _M_AMD64
|
||||||
|
#endif // _M_AMD64
|
||||||
|
|
||||||
|
#include "KMSServer_s2_x64_mingw_gcc.c"
|
||||||
|
|
||||||
|
#else // 32-bit
|
||||||
|
|
||||||
|
#include "KMSServer_s2_mingw_gcc.c"
|
||||||
|
|
||||||
|
#endif // 32-bit
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(NO_LIMIT)
|
||||||
|
#define MAXCALLS MaxTasks
|
||||||
|
#else // defined(NO_LIMIT)
|
||||||
|
#define MAXCALLS RPC_C_LISTEN_MAX_CALLS_DEFAULT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the main run loop for the KMS server
|
||||||
|
* We actually just setup things (must be after Cygwin fork) and then sleep
|
||||||
|
*/
|
||||||
|
int runServer()
|
||||||
|
{
|
||||||
|
# if !defined(NO_SOCKETS) && !defined(NO_SIGHUP) && !defined(_WIN32)
|
||||||
|
|
||||||
|
// The RPC setup survives a Cygwin exec without problems but no daemonizing
|
||||||
|
// SIGHUP is currently disabled for Cygwin. So this code should never compile
|
||||||
|
|
||||||
|
if (IsRestarted)
|
||||||
|
{
|
||||||
|
# ifndef NO_LOG
|
||||||
|
logger("vlmcsd %s started successfully\n", Version);
|
||||||
|
# endif // NO_LOG
|
||||||
|
}
|
||||||
|
else
|
||||||
|
# endif // !defined(NO_SOCKETS) && !defined(NO_SIGHUP) && !defined(_WIN32)
|
||||||
|
{
|
||||||
|
RPC_STATUS status;
|
||||||
|
|
||||||
|
// Endpoint is actually a TCP port for "ncacn_ip_tcp"
|
||||||
|
status = RpcServerUseProtseqEpA
|
||||||
|
(
|
||||||
|
(RPC_CSTR)"ncacn_ip_tcp",
|
||||||
|
RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
|
||||||
|
(RPC_CSTR)defaultport,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
if (status)
|
||||||
|
{
|
||||||
|
printerrorf("Fatal: Cannot bind to port %s: %s\n", defaultport, win_strerror(status));
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ifndef NO_LOG
|
||||||
|
logger("Listening on port %s\n", defaultport);
|
||||||
|
# endif // NO_LOG
|
||||||
|
|
||||||
|
// Registers the KMSServer interface.
|
||||||
|
status = RpcServerRegisterIf2
|
||||||
|
(
|
||||||
|
KMSServer_v1_0_s_ifspec,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH | RPC_IF_AUTOLISTEN,
|
||||||
|
MAXCALLS,
|
||||||
|
MAX_RESPONSE_SIZE, // currently set to sizeof(RESPONSE_V6)
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
if (status)
|
||||||
|
{
|
||||||
|
printerrorf("Fatal: Cannot register RPC interface: %s\n", win_strerror(status));
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ifndef NO_LOG
|
||||||
|
logger("vlmcsd %s started successfully\n", Version);
|
||||||
|
# endif // NO_LOG
|
||||||
|
|
||||||
|
if (IsNTService) ReportServiceStatus(SERVICE_RUNNING, NO_ERROR, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We could run RpcServerListen here but we need something
|
||||||
|
// that can be signaled from Cygwin. So we just sleep 24h (POSIX sleep, no Windows Sleep),
|
||||||
|
// wake up for some nanoseconds and sleep again.
|
||||||
|
|
||||||
|
while(TRUE) sleep(86400); // Sleep one day
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get's the IP address from an RPC_BINDING_HANDLE. Caller must call RpcStringFreeA to
|
||||||
|
* release memory allocated in *ipAddress
|
||||||
|
*/
|
||||||
|
#ifndef NO_LOG
|
||||||
|
RPC_STATUS getClientIp(const RPC_BINDING_HANDLE clientBinding, RPC_CSTR *ipAddress)
|
||||||
|
{
|
||||||
|
RPC_STATUS result;
|
||||||
|
RPC_CSTR stringBinding;
|
||||||
|
RPC_BINDING_HANDLE serverBinding;
|
||||||
|
|
||||||
|
// Fix for wine (disabled by default, because vlmcsd runs natively on all platforms where wine runs)
|
||||||
|
// Feel free to #define SUPPORT_WINE if you really want to run the Windows version with MS RPC (Wine RPC in this case)
|
||||||
|
#ifdef SUPPORT_WINE
|
||||||
|
HMODULE h = GetModuleHandleA("kernel32.dll");
|
||||||
|
|
||||||
|
if (h)
|
||||||
|
{
|
||||||
|
// Since wine simply terminates the thread when RpcBindingServerFromClient is called, we exit with an error
|
||||||
|
if (GetProcAddress(h, "wine_get_unix_file_name")) return RPC_S_CANNOT_SUPPORT;
|
||||||
|
}
|
||||||
|
#endif // SUPPORT_WINE
|
||||||
|
|
||||||
|
if ((result = RpcBindingServerFromClient(clientBinding, &serverBinding)) != RPC_S_OK) return result;
|
||||||
|
|
||||||
|
if ((result = RpcBindingToStringBindingA(serverBinding, &stringBinding)) != RPC_S_OK)
|
||||||
|
{
|
||||||
|
RpcBindingFree(&serverBinding);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = RpcStringBindingParseA(stringBinding, NULL, NULL, ipAddress, NULL, NULL);
|
||||||
|
RpcStringFreeA(&stringBinding);
|
||||||
|
RpcBindingFree(&serverBinding);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif // NO_LOG
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_PRIVATE_IP_DETECT
|
||||||
|
static int_fast8_t IsPrivateIPAddress(char* ipAddress)
|
||||||
|
{
|
||||||
|
int family = strchr(ipAddress,'.') ? AF_INET : AF_INET6;
|
||||||
|
|
||||||
|
switch(family)
|
||||||
|
{
|
||||||
|
case AF_INET:
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char* current;
|
||||||
|
char* next;
|
||||||
|
uint32_t ip;
|
||||||
|
|
||||||
|
for (ip = 0, i = 0, current = ipAddress; i < 4; i++, current = next + 1)
|
||||||
|
{
|
||||||
|
ip = (ip << 8) | strtoul(current, &next, 10);
|
||||||
|
if (*next != '.') break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
(ip & 0xff000000) == 0x7f000000 || // 127.x.x.x localhost
|
||||||
|
(ip & 0xffff0000) == 0xc0a80000 || // 192.168.x.x private routeable
|
||||||
|
(ip & 0xffff0000) == 0xa9fe0000 || // 169.254.x.x link local
|
||||||
|
(ip & 0xff000000) == 0x0a000000 || // 10.x.x.x private routeable
|
||||||
|
(ip & 0xfff00000) == 0xac100000 // 172.16-31.x.x private routeable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case AF_INET6:
|
||||||
|
{
|
||||||
|
if (!strcmp(ipAddress, "::1")) return TRUE;
|
||||||
|
if (strchr(ipAddress, ':') - ipAddress != 4) break;
|
||||||
|
|
||||||
|
int16_t firstWord;
|
||||||
|
hex2bin((BYTE*)&firstWord, ipAddress, 2);
|
||||||
|
if ((BE16(firstWord) & 0xe000) != 0x2000) return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif // NO_PRIVATE_IP_DETECT
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the callback function for the RPC request as defined in KMSServer.idl
|
||||||
|
* Output from the MIDL compiler has been modified manually to support gcc (and compatible compilers)
|
||||||
|
* as well as Cygwin and MingW-w64 toolchains.
|
||||||
|
*/
|
||||||
|
int ProcessActivationRequest(handle_t IDL_handle, int requestSize, unsigned char *request, int *responseSize, unsigned char **response)
|
||||||
|
{
|
||||||
|
RPC_CSTR clientIpAddress;
|
||||||
|
RPC_STATUS result;
|
||||||
|
int status = 0;
|
||||||
|
|
||||||
|
result = getClientIp(IDL_handle, &clientIpAddress);
|
||||||
|
|
||||||
|
# ifndef NO_LOG
|
||||||
|
|
||||||
|
logger("RPC connection accepted: %s\n", !result ? (const char*)clientIpAddress : "Unknown IP");
|
||||||
|
|
||||||
|
# endif // NO_LOG
|
||||||
|
|
||||||
|
# ifndef NO_PRIVATE_IP_DETECT
|
||||||
|
if (result && (PublicIPProtectionLevel & 2))
|
||||||
|
{
|
||||||
|
# ifndef NO_LOG
|
||||||
|
logger ("Cannot verify that client has a private IP address\n");
|
||||||
|
# endif
|
||||||
|
|
||||||
|
return 0x80070000 | RPC_S_ACCESS_DENIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result && (PublicIPProtectionLevel & 2) && !IsPrivateIPAddress((char*)clientIpAddress))
|
||||||
|
{
|
||||||
|
# ifndef NO_LOG
|
||||||
|
logger("Client with public IP address rejected\n");
|
||||||
|
# endif
|
||||||
|
|
||||||
|
RpcStringFreeA(&clientIpAddress);
|
||||||
|
return 0x80070000 | RPC_S_ACCESS_DENIED;
|
||||||
|
}
|
||||||
|
# endif // NO_PRIVATE_IP_DETECT
|
||||||
|
|
||||||
|
// Discard any packet smaller than a v4 request
|
||||||
|
if (requestSize < (int)sizeof(REQUEST_V4))
|
||||||
|
{
|
||||||
|
if (!result) RpcStringFreeA(&clientIpAddress);
|
||||||
|
return 0x8007000D;
|
||||||
|
}
|
||||||
|
|
||||||
|
*response = (uint8_t *)midl_user_allocate(MAX_RESPONSE_SIZE);
|
||||||
|
int kmsStatus = 0x8007000D;
|
||||||
|
int version = LE32(((REQUEST*)(request))->Version);
|
||||||
|
|
||||||
|
switch(version)
|
||||||
|
{
|
||||||
|
case 0x40000:
|
||||||
|
kmsStatus = CreateResponseV4((REQUEST_V4 *)request, *response, (char*)clientIpAddress);
|
||||||
|
break;
|
||||||
|
case 0x50000:
|
||||||
|
case 0x60000:
|
||||||
|
kmsStatus = CreateResponseV6((REQUEST_V6 *) request, *response, (char*)clientIpAddress);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
# ifndef NO_LOG
|
||||||
|
logger("Fatal: KMSv%u.%u unsupported\n", version >> 16, version & 0xffff);
|
||||||
|
# endif // NO_LOG
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kmsStatus < 0)
|
||||||
|
{
|
||||||
|
status = kmsStatus;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*responseSize = kmsStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result) RpcStringFreeA(&clientIpAddress);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Memory allocation function for RPC.
|
||||||
|
void *__RPC_USER midl_user_allocate(SIZE_T len)
|
||||||
|
{
|
||||||
|
return vlmcsd_malloc(len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Memory deallocation function for RPC.
|
||||||
|
void __RPC_USER midl_user_free(void __RPC_FAR *ptr)
|
||||||
|
{
|
||||||
|
if (ptr) free(ptr);
|
||||||
|
ptr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // USE_MSRPC
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* msrpc-server.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MSRPC_SERVER_H_
|
||||||
|
#define MSRPC_SERVER_H_
|
||||||
|
|
||||||
|
int runServer();
|
||||||
|
|
||||||
|
#endif /* MSRPC_SERVER_H_ */
|
||||||
@@ -0,0 +1,569 @@
|
|||||||
|
/* $NetBSD: nameser.h,v 1.19 2005/12/26 19:01:47 perry Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1983, 1989, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||||
|
* Copyright (c) 1996-1999 by Internet Software Consortium.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Id: nameser.h,v 1.2.2.4.4.1 2004/03/09 08:33:30 marka Exp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _ARPA_NAMESER_H_
|
||||||
|
#define _ARPA_NAMESER_H_
|
||||||
|
|
||||||
|
#define BIND_4_COMPAT
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Revision information. This is the release date in YYYYMMDD format.
|
||||||
|
* It can change every day so the right thing to do with it is use it
|
||||||
|
* in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not
|
||||||
|
* compare for equality; rather, use it to determine whether your libbind.a
|
||||||
|
* contains a new enough lib/nameser/ to support the feature you need.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __NAMESER 19991006 /* New interface version stamp. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define constants based on RFC 883, RFC 1034, RFC 1035
|
||||||
|
*/
|
||||||
|
#define NS_PACKETSZ 512 /* default UDP packet size */
|
||||||
|
#define NS_MAXDNAME 1025 /* maximum domain name */
|
||||||
|
#define NS_MAXMSG 65535 /* maximum message size */
|
||||||
|
#define NS_MAXCDNAME 255 /* maximum compressed domain name */
|
||||||
|
#define NS_MAXLABEL 63 /* maximum length of domain label */
|
||||||
|
#define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */
|
||||||
|
#define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */
|
||||||
|
#define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
|
||||||
|
#define NS_INT32SZ 4 /* #/bytes of data in a uint32_t */
|
||||||
|
#define NS_INT16SZ 2 /* #/bytes of data in a uint16_t */
|
||||||
|
#define NS_INT8SZ 1 /* #/bytes of data in a uint8_t */
|
||||||
|
#define NS_INADDRSZ 4 /* IPv4 T_A */
|
||||||
|
#define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */
|
||||||
|
#define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */
|
||||||
|
#define NS_DEFAULTPORT 53 /* For both TCP and UDP. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord()
|
||||||
|
* in synch with it.
|
||||||
|
*/
|
||||||
|
typedef enum __ns_sect {
|
||||||
|
ns_s_qd = 0, /* Query: Question. */
|
||||||
|
ns_s_zn = 0, /* Update: Zone. */
|
||||||
|
ns_s_an = 1, /* Query: Answer. */
|
||||||
|
ns_s_pr = 1, /* Update: Prerequisites. */
|
||||||
|
ns_s_ns = 2, /* Query: Name servers. */
|
||||||
|
ns_s_ud = 2, /* Update: Update. */
|
||||||
|
ns_s_ar = 3, /* Query|Update: Additional records. */
|
||||||
|
ns_s_max = 4
|
||||||
|
} ns_sect;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is a message handle. It is caller allocated and has no dynamic data.
|
||||||
|
* This structure is intended to be opaque to all but ns_parse.c, thus the
|
||||||
|
* leading _'s on the member names. Use the accessor functions, not the _'s.
|
||||||
|
*/
|
||||||
|
typedef struct __ns_msg {
|
||||||
|
const u_char *_msg, *_eom;
|
||||||
|
uint16_t _id, _flags, _counts[ns_s_max];
|
||||||
|
const u_char *_sections[ns_s_max];
|
||||||
|
ns_sect _sect;
|
||||||
|
int _rrnum;
|
||||||
|
const u_char *_msg_ptr;
|
||||||
|
} ns_msg;
|
||||||
|
|
||||||
|
/* Private data structure - do not use from outside library. */
|
||||||
|
struct _ns_flagdata { int mask, shift; };
|
||||||
|
extern const struct _ns_flagdata _ns_flagdata[];
|
||||||
|
|
||||||
|
/* Accessor macros - this is part of the public interface. */
|
||||||
|
|
||||||
|
#define ns_msg_id(handle) ((handle)._id + 0)
|
||||||
|
#define ns_msg_base(handle) ((handle)._msg + 0)
|
||||||
|
#define ns_msg_end(handle) ((handle)._eom + 0)
|
||||||
|
#define ns_msg_size(handle) ((size_t)((handle)._eom - (handle)._msg))
|
||||||
|
#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is a parsed record. It is caller allocated and has no dynamic data.
|
||||||
|
*/
|
||||||
|
typedef struct __ns_rr {
|
||||||
|
char name[NS_MAXDNAME];
|
||||||
|
uint16_t type;
|
||||||
|
uint16_t rr_class;
|
||||||
|
uint32_t ttl;
|
||||||
|
uint16_t rdlength;
|
||||||
|
const u_char * rdata;
|
||||||
|
} ns_rr;
|
||||||
|
|
||||||
|
/* Accessor macros - this is part of the public interface. */
|
||||||
|
#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".")
|
||||||
|
#define ns_rr_type(rr) ((ns_type)((rr).type + 0))
|
||||||
|
#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0))
|
||||||
|
#define ns_rr_ttl(rr) ((u_long)(rr).ttl + 0)
|
||||||
|
#define ns_rr_rdlen(rr) ((size_t)(rr).rdlength + 0)
|
||||||
|
#define ns_rr_rdata(rr) ((rr).rdata + 0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These don't have to be in the same order as in the packet flags word,
|
||||||
|
* and they can even overlap in some cases, but they will need to be kept
|
||||||
|
* in synch with ns_parse.c:ns_flagdata[].
|
||||||
|
*/
|
||||||
|
typedef enum __ns_flag {
|
||||||
|
ns_f_qr, /* Question/Response. */
|
||||||
|
ns_f_opcode, /* Operation code. */
|
||||||
|
ns_f_aa, /* Authoritative Answer. */
|
||||||
|
ns_f_tc, /* Truncation occurred. */
|
||||||
|
ns_f_rd, /* Recursion Desired. */
|
||||||
|
ns_f_ra, /* Recursion Available. */
|
||||||
|
ns_f_z, /* MBZ. */
|
||||||
|
ns_f_ad, /* Authentic Data (DNSSEC). */
|
||||||
|
ns_f_cd, /* Checking Disabled (DNSSEC). */
|
||||||
|
ns_f_rcode, /* Response code. */
|
||||||
|
ns_f_max
|
||||||
|
} ns_flag;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Currently defined opcodes.
|
||||||
|
*/
|
||||||
|
typedef enum __ns_opcode {
|
||||||
|
ns_o_query = 0, /* Standard query. */
|
||||||
|
ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */
|
||||||
|
ns_o_status = 2, /* Name server status query (unsupported). */
|
||||||
|
/* Opcode 3 is undefined/reserved. */
|
||||||
|
ns_o_notify = 4, /* Zone change notification. */
|
||||||
|
ns_o_update = 5, /* Zone update message. */
|
||||||
|
ns_o_max = 6
|
||||||
|
} ns_opcode;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Currently defined response codes.
|
||||||
|
*/
|
||||||
|
typedef enum __ns_rcode {
|
||||||
|
ns_r_noerror = 0, /* No error occurred. */
|
||||||
|
ns_r_formerr = 1, /* Format error. */
|
||||||
|
ns_r_servfail = 2, /* Server failure. */
|
||||||
|
ns_r_nxdomain = 3, /* Name error. */
|
||||||
|
ns_r_notimpl = 4, /* Unimplemented. */
|
||||||
|
ns_r_refused = 5, /* Operation refused. */
|
||||||
|
/* these are for BIND_UPDATE */
|
||||||
|
ns_r_yxdomain = 6, /* Name exists */
|
||||||
|
ns_r_yxrrset = 7, /* RRset exists */
|
||||||
|
ns_r_nxrrset = 8, /* RRset does not exist */
|
||||||
|
ns_r_notauth = 9, /* Not authoritative for zone */
|
||||||
|
ns_r_notzone = 10, /* Zone of record different from zone section */
|
||||||
|
ns_r_max = 11,
|
||||||
|
/* The following are EDNS extended rcodes */
|
||||||
|
ns_r_badvers = 16,
|
||||||
|
/* The following are TSIG errors */
|
||||||
|
ns_r_badsig = 16,
|
||||||
|
ns_r_badkey = 17,
|
||||||
|
ns_r_badtime = 18
|
||||||
|
} ns_rcode;
|
||||||
|
|
||||||
|
/* BIND_UPDATE */
|
||||||
|
typedef enum __ns_update_operation {
|
||||||
|
ns_uop_delete = 0,
|
||||||
|
ns_uop_add = 1,
|
||||||
|
ns_uop_max = 2
|
||||||
|
} ns_update_operation;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure is used for TSIG authenticated messages
|
||||||
|
*/
|
||||||
|
struct ns_tsig_key {
|
||||||
|
char name[NS_MAXDNAME], alg[NS_MAXDNAME];
|
||||||
|
unsigned char *data;
|
||||||
|
int len;
|
||||||
|
};
|
||||||
|
typedef struct ns_tsig_key ns_tsig_key;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure is used for TSIG authenticated TCP messages
|
||||||
|
*/
|
||||||
|
struct ns_tcp_tsig_state {
|
||||||
|
int counter;
|
||||||
|
struct dst_key *key;
|
||||||
|
void *ctx;
|
||||||
|
unsigned char sig[NS_PACKETSZ];
|
||||||
|
int siglen;
|
||||||
|
};
|
||||||
|
typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
|
||||||
|
|
||||||
|
#define NS_TSIG_FUDGE 300
|
||||||
|
#define NS_TSIG_TCP_COUNT 100
|
||||||
|
#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
|
||||||
|
|
||||||
|
#define NS_TSIG_ERROR_NO_TSIG -10
|
||||||
|
#define NS_TSIG_ERROR_NO_SPACE -11
|
||||||
|
#define NS_TSIG_ERROR_FORMERR -12
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Currently defined type values for resources and queries.
|
||||||
|
*/
|
||||||
|
typedef enum __ns_type {
|
||||||
|
ns_t_invalid = 0, /* Cookie. */
|
||||||
|
ns_t_a = 1, /* Host address. */
|
||||||
|
ns_t_ns = 2, /* Authoritative server. */
|
||||||
|
ns_t_md = 3, /* Mail destination. */
|
||||||
|
ns_t_mf = 4, /* Mail forwarder. */
|
||||||
|
ns_t_cname = 5, /* Canonical name. */
|
||||||
|
ns_t_soa = 6, /* Start of authority zone. */
|
||||||
|
ns_t_mb = 7, /* Mailbox domain name. */
|
||||||
|
ns_t_mg = 8, /* Mail group member. */
|
||||||
|
ns_t_mr = 9, /* Mail rename name. */
|
||||||
|
ns_t_null = 10, /* Null resource record. */
|
||||||
|
ns_t_wks = 11, /* Well known service. */
|
||||||
|
ns_t_ptr = 12, /* Domain name pointer. */
|
||||||
|
ns_t_hinfo = 13, /* Host information. */
|
||||||
|
ns_t_minfo = 14, /* Mailbox information. */
|
||||||
|
ns_t_mx = 15, /* Mail routing information. */
|
||||||
|
ns_t_txt = 16, /* Text strings. */
|
||||||
|
ns_t_rp = 17, /* Responsible person. */
|
||||||
|
ns_t_afsdb = 18, /* AFS cell database. */
|
||||||
|
ns_t_x25 = 19, /* X_25 calling address. */
|
||||||
|
ns_t_isdn = 20, /* ISDN calling address. */
|
||||||
|
ns_t_rt = 21, /* Router. */
|
||||||
|
ns_t_nsap = 22, /* NSAP address. */
|
||||||
|
ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */
|
||||||
|
ns_t_sig = 24, /* Security signature. */
|
||||||
|
ns_t_key = 25, /* Security key. */
|
||||||
|
ns_t_px = 26, /* X.400 mail mapping. */
|
||||||
|
ns_t_gpos = 27, /* Geographical position (withdrawn). */
|
||||||
|
ns_t_aaaa = 28, /* Ip6 Address. */
|
||||||
|
ns_t_loc = 29, /* Location Information. */
|
||||||
|
ns_t_nxt = 30, /* Next domain (security). */
|
||||||
|
ns_t_eid = 31, /* Endpoint identifier. */
|
||||||
|
ns_t_nimloc = 32, /* Nimrod Locator. */
|
||||||
|
ns_t_srv = 33, /* Server Selection. */
|
||||||
|
ns_t_atma = 34, /* ATM Address */
|
||||||
|
ns_t_naptr = 35, /* Naming Authority PoinTeR */
|
||||||
|
ns_t_kx = 36, /* Key Exchange */
|
||||||
|
ns_t_cert = 37, /* Certification record */
|
||||||
|
ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */
|
||||||
|
ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */
|
||||||
|
ns_t_sink = 40, /* Kitchen sink (experimentatl) */
|
||||||
|
ns_t_opt = 41, /* EDNS0 option (meta-RR) */
|
||||||
|
ns_t_apl = 42, /* Address prefix list (RFC 3123) */
|
||||||
|
ns_t_tkey = 249, /* Transaction key */
|
||||||
|
ns_t_tsig = 250, /* Transaction signature. */
|
||||||
|
ns_t_ixfr = 251, /* Incremental zone transfer. */
|
||||||
|
ns_t_axfr = 252, /* Transfer zone of authority. */
|
||||||
|
ns_t_mailb = 253, /* Transfer mailbox records. */
|
||||||
|
ns_t_maila = 254, /* Transfer mail agent records. */
|
||||||
|
ns_t_any = 255, /* Wildcard match. */
|
||||||
|
ns_t_zxfr = 256, /* BIND-specific, nonstandard. */
|
||||||
|
ns_t_max = 65536
|
||||||
|
} ns_type;
|
||||||
|
|
||||||
|
/* Exclusively a QTYPE? (not also an RTYPE) */
|
||||||
|
#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
|
||||||
|
(t) == ns_t_mailb || (t) == ns_t_maila)
|
||||||
|
/* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */
|
||||||
|
#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
|
||||||
|
/* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */
|
||||||
|
#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
|
||||||
|
#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
|
||||||
|
#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
|
||||||
|
(t) == ns_t_zxfr)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Values for class field
|
||||||
|
*/
|
||||||
|
typedef enum __ns_class {
|
||||||
|
ns_c_invalid = 0, /* Cookie. */
|
||||||
|
ns_c_in = 1, /* Internet. */
|
||||||
|
ns_c_2 = 2, /* unallocated/unsupported. */
|
||||||
|
ns_c_chaos = 3, /* MIT Chaos-net. */
|
||||||
|
ns_c_hs = 4, /* MIT Hesiod. */
|
||||||
|
/* Query class values which do not appear in resource records */
|
||||||
|
ns_c_none = 254, /* for prereq. sections in update requests */
|
||||||
|
ns_c_any = 255, /* Wildcard match. */
|
||||||
|
ns_c_max = 65536
|
||||||
|
} ns_class;
|
||||||
|
|
||||||
|
/* DNSSEC constants. */
|
||||||
|
|
||||||
|
typedef enum __ns_key_types {
|
||||||
|
ns_kt_rsa = 1, /* key type RSA/MD5 */
|
||||||
|
ns_kt_dh = 2, /* Diffie Hellman */
|
||||||
|
ns_kt_dsa = 3, /* Digital Signature Standard (MANDATORY) */
|
||||||
|
ns_kt_private = 254 /* Private key type starts with OID */
|
||||||
|
} ns_key_types;
|
||||||
|
|
||||||
|
typedef enum __ns_cert_types {
|
||||||
|
cert_t_pkix = 1, /* PKIX (X.509v3) */
|
||||||
|
cert_t_spki = 2, /* SPKI */
|
||||||
|
cert_t_pgp = 3, /* PGP */
|
||||||
|
cert_t_url = 253, /* URL private type */
|
||||||
|
cert_t_oid = 254 /* OID private type */
|
||||||
|
} ns_cert_types;
|
||||||
|
|
||||||
|
/* Flags field of the KEY RR rdata. */
|
||||||
|
#define NS_KEY_TYPEMASK 0xC000 /* Mask for "type" bits */
|
||||||
|
#define NS_KEY_TYPE_AUTH_CONF 0x0000 /* Key usable for both */
|
||||||
|
#define NS_KEY_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */
|
||||||
|
#define NS_KEY_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */
|
||||||
|
#define NS_KEY_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */
|
||||||
|
/* The type bits can also be interpreted independently, as single bits: */
|
||||||
|
#define NS_KEY_NO_AUTH 0x8000 /* Key unusable for authentication */
|
||||||
|
#define NS_KEY_NO_CONF 0x4000 /* Key unusable for confidentiality */
|
||||||
|
#define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */
|
||||||
|
#define NS_KEY_EXTENDED_FLAGS 0x1000 /* reserved - must be zero */
|
||||||
|
#define NS_KEY_RESERVED4 0x0800 /* reserved - must be zero */
|
||||||
|
#define NS_KEY_RESERVED5 0x0400 /* reserved - must be zero */
|
||||||
|
#define NS_KEY_NAME_TYPE 0x0300 /* these bits determine the type */
|
||||||
|
#define NS_KEY_NAME_USER 0x0000 /* key is assoc. with user */
|
||||||
|
#define NS_KEY_NAME_ENTITY 0x0200 /* key is assoc. with entity eg host */
|
||||||
|
#define NS_KEY_NAME_ZONE 0x0100 /* key is zone key */
|
||||||
|
#define NS_KEY_NAME_RESERVED 0x0300 /* reserved meaning */
|
||||||
|
#define NS_KEY_RESERVED8 0x0080 /* reserved - must be zero */
|
||||||
|
#define NS_KEY_RESERVED9 0x0040 /* reserved - must be zero */
|
||||||
|
#define NS_KEY_RESERVED10 0x0020 /* reserved - must be zero */
|
||||||
|
#define NS_KEY_RESERVED11 0x0010 /* reserved - must be zero */
|
||||||
|
#define NS_KEY_SIGNATORYMASK 0x000F /* key can sign RR's of same name */
|
||||||
|
#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \
|
||||||
|
NS_KEY_RESERVED4 | \
|
||||||
|
NS_KEY_RESERVED5 | \
|
||||||
|
NS_KEY_RESERVED8 | \
|
||||||
|
NS_KEY_RESERVED9 | \
|
||||||
|
NS_KEY_RESERVED10 | \
|
||||||
|
NS_KEY_RESERVED11 )
|
||||||
|
#define NS_KEY_RESERVED_BITMASK2 0xFFFF /* no bits defined here */
|
||||||
|
|
||||||
|
/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */
|
||||||
|
#define NS_ALG_MD5RSA 1 /* MD5 with RSA */
|
||||||
|
#define NS_ALG_DH 2 /* Diffie Hellman KEY */
|
||||||
|
#define NS_ALG_DSA 3 /* DSA KEY */
|
||||||
|
#define NS_ALG_DSS NS_ALG_DSA
|
||||||
|
#define NS_ALG_EXPIRE_ONLY 253 /* No alg, no security */
|
||||||
|
#define NS_ALG_PRIVATE_OID 254 /* Key begins with OID giving alg */
|
||||||
|
|
||||||
|
/* Protocol values */
|
||||||
|
/* value 0 is reserved */
|
||||||
|
#define NS_KEY_PROT_TLS 1
|
||||||
|
#define NS_KEY_PROT_EMAIL 2
|
||||||
|
#define NS_KEY_PROT_DNSSEC 3
|
||||||
|
#define NS_KEY_PROT_IPSEC 4
|
||||||
|
#define NS_KEY_PROT_ANY 255
|
||||||
|
|
||||||
|
/* Signatures */
|
||||||
|
#define NS_MD5RSA_MIN_BITS 512 /* Size of a mod or exp in bits */
|
||||||
|
#define NS_MD5RSA_MAX_BITS 4096
|
||||||
|
/* Total of binary mod and exp */
|
||||||
|
#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3)
|
||||||
|
/* Max length of text sig block */
|
||||||
|
#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4)
|
||||||
|
#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8)
|
||||||
|
#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8)
|
||||||
|
|
||||||
|
#define NS_DSA_SIG_SIZE 41
|
||||||
|
#define NS_DSA_MIN_SIZE 213
|
||||||
|
#define NS_DSA_MAX_BYTES 405
|
||||||
|
|
||||||
|
/* Offsets into SIG record rdata to find various values */
|
||||||
|
#define NS_SIG_TYPE 0 /* Type flags */
|
||||||
|
#define NS_SIG_ALG 2 /* Algorithm */
|
||||||
|
#define NS_SIG_LABELS 3 /* How many labels in name */
|
||||||
|
#define NS_SIG_OTTL 4 /* Original TTL */
|
||||||
|
#define NS_SIG_EXPIR 8 /* Expiration time */
|
||||||
|
#define NS_SIG_SIGNED 12 /* Signature time */
|
||||||
|
#define NS_SIG_FOOT 16 /* Key footprint */
|
||||||
|
#define NS_SIG_SIGNER 18 /* Domain name of who signed it */
|
||||||
|
|
||||||
|
/* How RR types are represented as bit-flags in NXT records */
|
||||||
|
#define NS_NXT_BITS 8
|
||||||
|
#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS)))
|
||||||
|
#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
|
||||||
|
#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS)))
|
||||||
|
#define NS_NXT_MAX 127
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EDNS0 extended flags, host order.
|
||||||
|
*/
|
||||||
|
#define NS_OPT_DNSSEC_OK 0x8000U
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inline versions of get/put short/long. Pointer is advanced.
|
||||||
|
*/
|
||||||
|
#define NS_GET16(s, cp) do { \
|
||||||
|
const u_char *t_cp = (const u_char *)(cp); \
|
||||||
|
(s) = ((uint16_t)t_cp[0] << 8) \
|
||||||
|
| ((uint16_t)t_cp[1]) \
|
||||||
|
; \
|
||||||
|
(cp) += NS_INT16SZ; \
|
||||||
|
} while (/*CONSTCOND*/0)
|
||||||
|
|
||||||
|
#define NS_GET32(l, cp) do { \
|
||||||
|
const u_char *t_cp = (const u_char *)(cp); \
|
||||||
|
(l) = ((uint32_t)t_cp[0] << 24) \
|
||||||
|
| ((uint32_t)t_cp[1] << 16) \
|
||||||
|
| ((uint32_t)t_cp[2] << 8) \
|
||||||
|
| ((uint32_t)t_cp[3]) \
|
||||||
|
; \
|
||||||
|
(cp) += NS_INT32SZ; \
|
||||||
|
} while (/*CONSTCOND*/0)
|
||||||
|
|
||||||
|
#define NS_PUT16(s, cp) do { \
|
||||||
|
uint32_t t_s = (uint32_t)(s); \
|
||||||
|
u_char *t_cp = (u_char *)(cp); \
|
||||||
|
*t_cp++ = t_s >> 8; \
|
||||||
|
*t_cp = t_s; \
|
||||||
|
(cp) += NS_INT16SZ; \
|
||||||
|
} while (/*CONSTCOND*/0)
|
||||||
|
|
||||||
|
#define NS_PUT32(l, cp) do { \
|
||||||
|
uint32_t t_l = (uint32_t)(l); \
|
||||||
|
u_char *t_cp = (u_char *)(cp); \
|
||||||
|
*t_cp++ = t_l >> 24; \
|
||||||
|
*t_cp++ = t_l >> 16; \
|
||||||
|
*t_cp++ = t_l >> 8; \
|
||||||
|
*t_cp = t_l; \
|
||||||
|
(cp) += NS_INT32SZ; \
|
||||||
|
} while (/*CONSTCOND*/0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ANSI C identifier hiding for bind's lib/nameser.
|
||||||
|
*/
|
||||||
|
#define ns_msg_getflag __ns_msg_getflag
|
||||||
|
#define ns_get16 __ns_get16
|
||||||
|
#define ns_get32 __ns_get32
|
||||||
|
#define ns_put16 __ns_put16
|
||||||
|
#define ns_put32 __ns_put32
|
||||||
|
#define ns_initparse __ns_initparse
|
||||||
|
#define ns_skiprr __ns_skiprr
|
||||||
|
#define ns_parserr __ns_parserr
|
||||||
|
#define ns_sprintrr __ns_sprintrr
|
||||||
|
#define ns_sprintrrf __ns_sprintrrf
|
||||||
|
#define ns_format_ttl __ns_format_ttl
|
||||||
|
#define ns_parse_ttl __ns_parse_ttl
|
||||||
|
#define ns_datetosecs __ns_datetosecs
|
||||||
|
#define ns_name_ntol __ns_name_ntol
|
||||||
|
#define ns_name_ntop __ns_name_ntop
|
||||||
|
#define ns_name_pton __ns_name_pton
|
||||||
|
#define ns_name_unpack __ns_name_unpack
|
||||||
|
#define ns_name_pack __ns_name_pack
|
||||||
|
#define ns_name_compress __ns_name_compress
|
||||||
|
#define ns_name_uncompress __ns_name_uncompress
|
||||||
|
#define ns_name_skip __ns_name_skip
|
||||||
|
#define ns_name_rollback __ns_name_rollback
|
||||||
|
#define ns_sign __ns_sign
|
||||||
|
#define ns_sign2 __ns_sign2
|
||||||
|
#define ns_sign_tcp __ns_sign_tcp
|
||||||
|
#define ns_sign_tcp2 __ns_sign_tcp2
|
||||||
|
#define ns_sign_tcp_init __ns_sign_tcp_init
|
||||||
|
#define ns_find_tsig __ns_find_tsig
|
||||||
|
#define ns_verify __ns_verify
|
||||||
|
#define ns_verify_tcp __ns_verify_tcp
|
||||||
|
#define ns_verify_tcp_init __ns_verify_tcp_init
|
||||||
|
#define ns_samedomain __ns_samedomain
|
||||||
|
#define ns_subdomain __ns_subdomain
|
||||||
|
#define ns_makecanon __ns_makecanon
|
||||||
|
#define ns_samename __ns_samename
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
int ns_msg_getflag(ns_msg, int);
|
||||||
|
uint16_t ns_get16(const u_char *);
|
||||||
|
uint32_t ns_get32(const u_char *);
|
||||||
|
void ns_put16(uint16_t, u_char *);
|
||||||
|
void ns_put32(uint32_t, u_char *);
|
||||||
|
int ns_initparse(const u_char *, int, ns_msg *);
|
||||||
|
int ns_skiprr(const u_char *, const u_char *, ns_sect, int);
|
||||||
|
int ns_parserr(ns_msg *, ns_sect, int, ns_rr *);
|
||||||
|
int ns_sprintrr(const ns_msg *, const ns_rr *,
|
||||||
|
const char *, const char *, char *, size_t);
|
||||||
|
int ns_sprintrrf(const u_char *, size_t, const char *,
|
||||||
|
ns_class, ns_type, u_long, const u_char *,
|
||||||
|
size_t, const char *, const char *,
|
||||||
|
char *, size_t);
|
||||||
|
int ns_format_ttl(u_long, char *, size_t);
|
||||||
|
int ns_parse_ttl(const char *, u_long *);
|
||||||
|
uint32_t ns_datetosecs(const char *cp, int *errp);
|
||||||
|
int ns_name_ntol(const u_char *, u_char *, size_t);
|
||||||
|
int ns_name_ntop(const u_char *, char *, size_t);
|
||||||
|
int ns_name_pton(const char *, u_char *, size_t);
|
||||||
|
int ns_name_unpack(const u_char *, const u_char *,
|
||||||
|
const u_char *, u_char *, size_t);
|
||||||
|
int ns_name_pack(const u_char *, u_char *, int,
|
||||||
|
const u_char **, const u_char **);
|
||||||
|
int ns_name_uncompress(const u_char *, const u_char *,
|
||||||
|
const u_char *, char *, size_t);
|
||||||
|
int ns_name_compress(const char *, u_char *, size_t,
|
||||||
|
const u_char **, const u_char **);
|
||||||
|
int ns_name_skip(const u_char **, const u_char *);
|
||||||
|
void ns_name_rollback(const u_char *, const u_char **,
|
||||||
|
const u_char **);
|
||||||
|
int ns_sign(u_char *, int *, int, int, void *,
|
||||||
|
const u_char *, int, u_char *, int *, time_t);
|
||||||
|
int ns_sign2(u_char *, int *, int, int, void *,
|
||||||
|
const u_char *, int, u_char *, int *, time_t,
|
||||||
|
u_char **, u_char **);
|
||||||
|
int ns_sign_tcp(u_char *, int *, int, int,
|
||||||
|
ns_tcp_tsig_state *, int);
|
||||||
|
int ns_sign_tcp2(u_char *, int *, int, int,
|
||||||
|
ns_tcp_tsig_state *, int,
|
||||||
|
u_char **, u_char **);
|
||||||
|
int ns_sign_tcp_init(void *, const u_char *, int,
|
||||||
|
ns_tcp_tsig_state *);
|
||||||
|
u_char *ns_find_tsig(u_char *, u_char *);
|
||||||
|
int ns_verify(u_char *, int *, void *,
|
||||||
|
const u_char *, int, u_char *, int *,
|
||||||
|
time_t *, int);
|
||||||
|
int ns_verify_tcp(u_char *, int *, ns_tcp_tsig_state *, int);
|
||||||
|
int ns_verify_tcp_init(void *, const u_char *, int,
|
||||||
|
ns_tcp_tsig_state *);
|
||||||
|
int ns_samedomain(const char *, const char *);
|
||||||
|
int ns_subdomain(const char *, const char *);
|
||||||
|
int ns_makecanon(const char *, char *, size_t);
|
||||||
|
int ns_samename(const char *, const char *);
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
|
#ifdef BIND_4_COMPAT
|
||||||
|
#include "nameser_compat.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* !_ARPA_NAMESER_H_ */
|
||||||
@@ -0,0 +1,236 @@
|
|||||||
|
/* $NetBSD: nameser_compat.h,v 1.1.1.2 2004/11/07 01:28:27 christos Exp $ */
|
||||||
|
|
||||||
|
/* Copyright (c) 1983, 1989
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the University of
|
||||||
|
* California, Berkeley and its contributors.
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* from nameser.h 8.1 (Berkeley) 6/2/93
|
||||||
|
* Id: nameser_compat.h,v 1.1.2.3.4.2 2004/07/01 04:43:41 marka Exp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _ARPA_NAMESER_COMPAT_
|
||||||
|
#define _ARPA_NAMESER_COMPAT_
|
||||||
|
|
||||||
|
#define __BIND 19950621 /* (DEAD) interface version stamp. */
|
||||||
|
|
||||||
|
#include <endian.h>
|
||||||
|
|
||||||
|
#ifndef BYTE_ORDER
|
||||||
|
#if (BSD >= 199103)
|
||||||
|
# include <machine/endian.h>
|
||||||
|
#else
|
||||||
|
#ifdef __linux
|
||||||
|
# include <endian.h>
|
||||||
|
#else
|
||||||
|
#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
|
||||||
|
#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
|
||||||
|
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
|
||||||
|
|
||||||
|
#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
|
||||||
|
defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
|
||||||
|
defined(__alpha__) || defined(__alpha) || \
|
||||||
|
(defined(__Lynx__) && defined(__x86__))
|
||||||
|
#define BYTE_ORDER LITTLE_ENDIAN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
|
||||||
|
defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
|
||||||
|
defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
|
||||||
|
defined(apollo) || defined(__convex__) || defined(_CRAY) || \
|
||||||
|
defined(__hppa) || defined(__hp9000) || \
|
||||||
|
defined(__hp9000s300) || defined(__hp9000s700) || \
|
||||||
|
defined(__hp3000s900) || defined(__hpux) || defined(MPE) || \
|
||||||
|
defined (BIT_ZERO_ON_LEFT) || defined(m68k) || defined(__sparc) || \
|
||||||
|
(defined(__Lynx__) && \
|
||||||
|
(defined(__68k__) || defined(__sparc__) || defined(__powerpc__)))
|
||||||
|
#define BYTE_ORDER BIG_ENDIAN
|
||||||
|
#endif
|
||||||
|
#endif /* __linux */
|
||||||
|
#endif /* BSD */
|
||||||
|
#endif /* BYTE_ORDER */
|
||||||
|
|
||||||
|
#if !defined(BYTE_ORDER) || \
|
||||||
|
(BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
|
||||||
|
BYTE_ORDER != PDP_ENDIAN)
|
||||||
|
/* you must determine what the correct bit order is for
|
||||||
|
* your compiler - the next line is an intentional error
|
||||||
|
* which will force your compiles to bomb until you fix
|
||||||
|
* the above macros.
|
||||||
|
*/
|
||||||
|
#error "Undefined or invalid BYTE_ORDER";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Structure for query header. The order of the fields is machine- and
|
||||||
|
* compiler-dependent, depending on the byte/bit order and the layout
|
||||||
|
* of bit fields. We use bit fields only in int variables, as this
|
||||||
|
* is all ANSI requires. This requires a somewhat confusing rearrangement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned id :16; /* query identification number */
|
||||||
|
#if BYTE_ORDER == BIG_ENDIAN
|
||||||
|
/* fields in third byte */
|
||||||
|
unsigned qr: 1; /* response flag */
|
||||||
|
unsigned opcode: 4; /* purpose of message */
|
||||||
|
unsigned aa: 1; /* authoritive answer */
|
||||||
|
unsigned tc: 1; /* truncated message */
|
||||||
|
unsigned rd: 1; /* recursion desired */
|
||||||
|
/* fields in fourth byte */
|
||||||
|
unsigned ra: 1; /* recursion available */
|
||||||
|
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
|
||||||
|
unsigned ad: 1; /* authentic data from named */
|
||||||
|
unsigned cd: 1; /* checking disabled by resolver */
|
||||||
|
unsigned rcode :4; /* response code */
|
||||||
|
#endif
|
||||||
|
#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
|
||||||
|
/* fields in third byte */
|
||||||
|
unsigned rd :1; /* recursion desired */
|
||||||
|
unsigned tc :1; /* truncated message */
|
||||||
|
unsigned aa :1; /* authoritive answer */
|
||||||
|
unsigned opcode :4; /* purpose of message */
|
||||||
|
unsigned qr :1; /* response flag */
|
||||||
|
/* fields in fourth byte */
|
||||||
|
unsigned rcode :4; /* response code */
|
||||||
|
unsigned cd: 1; /* checking disabled by resolver */
|
||||||
|
unsigned ad: 1; /* authentic data from named */
|
||||||
|
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
|
||||||
|
unsigned ra :1; /* recursion available */
|
||||||
|
#endif
|
||||||
|
/* remaining bytes */
|
||||||
|
unsigned qdcount :16; /* number of question entries */
|
||||||
|
unsigned ancount :16; /* number of answer entries */
|
||||||
|
unsigned nscount :16; /* number of authority entries */
|
||||||
|
unsigned arcount :16; /* number of resource entries */
|
||||||
|
} HEADER;
|
||||||
|
|
||||||
|
#define PACKETSZ NS_PACKETSZ
|
||||||
|
#define MAXDNAME NS_MAXDNAME
|
||||||
|
#define MAXCDNAME NS_MAXCDNAME
|
||||||
|
#define MAXLABEL NS_MAXLABEL
|
||||||
|
#define HFIXEDSZ NS_HFIXEDSZ
|
||||||
|
#define QFIXEDSZ NS_QFIXEDSZ
|
||||||
|
#define RRFIXEDSZ NS_RRFIXEDSZ
|
||||||
|
#define INT32SZ NS_INT32SZ
|
||||||
|
#define INT16SZ NS_INT16SZ
|
||||||
|
#define INT8SZ NS_INT8SZ
|
||||||
|
#define INADDRSZ NS_INADDRSZ
|
||||||
|
#define IN6ADDRSZ NS_IN6ADDRSZ
|
||||||
|
#define INDIR_MASK NS_CMPRSFLGS
|
||||||
|
#define NAMESERVER_PORT NS_DEFAULTPORT
|
||||||
|
|
||||||
|
#define S_ZONE ns_s_zn
|
||||||
|
#define S_PREREQ ns_s_pr
|
||||||
|
#define S_UPDATE ns_s_ud
|
||||||
|
#define S_ADDT ns_s_ar
|
||||||
|
|
||||||
|
#define QUERY ns_o_query
|
||||||
|
#define IQUERY ns_o_iquery
|
||||||
|
#define STATUS ns_o_status
|
||||||
|
#define NS_NOTIFY_OP ns_o_notify
|
||||||
|
#define NS_UPDATE_OP ns_o_update
|
||||||
|
|
||||||
|
#define NOERROR ns_r_noerror
|
||||||
|
#define FORMERR ns_r_formerr
|
||||||
|
#define SERVFAIL ns_r_servfail
|
||||||
|
#define NXDOMAIN ns_r_nxdomain
|
||||||
|
#define NOTIMP ns_r_notimpl
|
||||||
|
#define REFUSED ns_r_refused
|
||||||
|
#define YXDOMAIN ns_r_yxdomain
|
||||||
|
#define YXRRSET ns_r_yxrrset
|
||||||
|
#define NXRRSET ns_r_nxrrset
|
||||||
|
#define NOTAUTH ns_r_notauth
|
||||||
|
#define NOTZONE ns_r_notzone
|
||||||
|
/*#define BADSIG ns_r_badsig*/
|
||||||
|
/*#define BADKEY ns_r_badkey*/
|
||||||
|
/*#define BADTIME ns_r_badtime*/
|
||||||
|
|
||||||
|
|
||||||
|
#define DELETE ns_uop_delete
|
||||||
|
#define ADD ns_uop_add
|
||||||
|
|
||||||
|
#define T_A ns_t_a
|
||||||
|
#define T_NS ns_t_ns
|
||||||
|
#define T_MD ns_t_md
|
||||||
|
#define T_MF ns_t_mf
|
||||||
|
#define T_CNAME ns_t_cname
|
||||||
|
#define T_SOA ns_t_soa
|
||||||
|
#define T_MB ns_t_mb
|
||||||
|
#define T_MG ns_t_mg
|
||||||
|
#define T_MR ns_t_mr
|
||||||
|
#define T_NULL ns_t_null
|
||||||
|
#define T_WKS ns_t_wks
|
||||||
|
#define T_PTR ns_t_ptr
|
||||||
|
#define T_HINFO ns_t_hinfo
|
||||||
|
#define T_MINFO ns_t_minfo
|
||||||
|
#define T_MX ns_t_mx
|
||||||
|
#define T_TXT ns_t_txt
|
||||||
|
#define T_RP ns_t_rp
|
||||||
|
#define T_AFSDB ns_t_afsdb
|
||||||
|
#define T_X25 ns_t_x25
|
||||||
|
#define T_ISDN ns_t_isdn
|
||||||
|
#define T_RT ns_t_rt
|
||||||
|
#define T_NSAP ns_t_nsap
|
||||||
|
#define T_NSAP_PTR ns_t_nsap_ptr
|
||||||
|
#define T_SIG ns_t_sig
|
||||||
|
#define T_KEY ns_t_key
|
||||||
|
#define T_PX ns_t_px
|
||||||
|
#define T_GPOS ns_t_gpos
|
||||||
|
#define T_AAAA ns_t_aaaa
|
||||||
|
#define T_LOC ns_t_loc
|
||||||
|
#define T_NXT ns_t_nxt
|
||||||
|
#define T_EID ns_t_eid
|
||||||
|
#define T_NIMLOC ns_t_nimloc
|
||||||
|
#define T_SRV ns_t_srv
|
||||||
|
#define T_ATMA ns_t_atma
|
||||||
|
#define T_NAPTR ns_t_naptr
|
||||||
|
#define T_A6 ns_t_a6
|
||||||
|
#define T_TSIG ns_t_tsig
|
||||||
|
#define T_IXFR ns_t_ixfr
|
||||||
|
#define T_AXFR ns_t_axfr
|
||||||
|
#define T_MAILB ns_t_mailb
|
||||||
|
#define T_MAILA ns_t_maila
|
||||||
|
#define T_ANY ns_t_any
|
||||||
|
|
||||||
|
#define C_IN ns_c_in
|
||||||
|
#define C_CHAOS ns_c_chaos
|
||||||
|
#define C_HS ns_c_hs
|
||||||
|
/* BIND_UPDATE */
|
||||||
|
#define C_NONE ns_c_none
|
||||||
|
#define C_ANY ns_c_any
|
||||||
|
|
||||||
|
#define GETSHORT NS_GET16
|
||||||
|
#define GETLONG NS_GET32
|
||||||
|
#define PUTSHORT NS_PUT16
|
||||||
|
#define PUTLONG NS_PUT32
|
||||||
|
|
||||||
|
#endif /* _ARPA_NAMESER_COMPAT_ */
|
||||||
+107
@@ -0,0 +1,107 @@
|
|||||||
|
#ifndef NETLINK_MUSL_H
|
||||||
|
#define NETLINK_MUSL_H
|
||||||
|
|
||||||
|
#if !__linux__
|
||||||
|
#error netlink-musl.h only works with a linux kernel
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __ANDROID__
|
||||||
|
#error netlink-musl.h does not work with Android
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/* linux/netlink.h */
|
||||||
|
|
||||||
|
#define NETLINK_ROUTE 0
|
||||||
|
|
||||||
|
struct nlmsghdr {
|
||||||
|
uint32_t nlmsg_len;
|
||||||
|
uint16_t nlmsg_type;
|
||||||
|
uint16_t nlmsg_flags;
|
||||||
|
uint32_t nlmsg_seq;
|
||||||
|
uint32_t nlmsg_pid;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NLM_F_REQUEST 1
|
||||||
|
#define NLM_F_MULTI 2
|
||||||
|
#define NLM_F_ACK 4
|
||||||
|
|
||||||
|
#define NLM_F_ROOT 0x100
|
||||||
|
#define NLM_F_MATCH 0x200
|
||||||
|
#define NLM_F_ATOMIC 0x400
|
||||||
|
#define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
|
||||||
|
|
||||||
|
#define NLMSG_NOOP 0x1
|
||||||
|
#define NLMSG_ERROR 0x2
|
||||||
|
#define NLMSG_DONE 0x3
|
||||||
|
#define NLMSG_OVERRUN 0x4
|
||||||
|
|
||||||
|
/* linux/rtnetlink.h */
|
||||||
|
|
||||||
|
#define RTM_NEWLINK 16
|
||||||
|
#define RTM_GETLINK 18
|
||||||
|
#define RTM_NEWADDR 20
|
||||||
|
#define RTM_GETADDR 22
|
||||||
|
|
||||||
|
struct rtattr {
|
||||||
|
unsigned short rta_len;
|
||||||
|
unsigned short rta_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rtgenmsg {
|
||||||
|
unsigned char rtgen_family;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ifinfomsg {
|
||||||
|
unsigned char ifi_family;
|
||||||
|
unsigned char __ifi_pad;
|
||||||
|
unsigned short ifi_type;
|
||||||
|
int ifi_index;
|
||||||
|
unsigned ifi_flags;
|
||||||
|
unsigned ifi_change;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* linux/if_link.h */
|
||||||
|
|
||||||
|
#define IFLA_ADDRESS 1
|
||||||
|
#define IFLA_BROADCAST 2
|
||||||
|
#define IFLA_IFNAME 3
|
||||||
|
#define IFLA_STATS 7
|
||||||
|
|
||||||
|
/* linux/if_addr.h */
|
||||||
|
|
||||||
|
struct ifaddrmsg {
|
||||||
|
uint8_t ifa_family;
|
||||||
|
uint8_t ifa_prefixlen;
|
||||||
|
uint8_t ifa_flags;
|
||||||
|
uint8_t ifa_scope;
|
||||||
|
uint32_t ifa_index;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define IFA_ADDRESS 1
|
||||||
|
#define IFA_LOCAL 2
|
||||||
|
#define IFA_LABEL 3
|
||||||
|
#define IFA_BROADCAST 4
|
||||||
|
|
||||||
|
/* musl */
|
||||||
|
|
||||||
|
#define NETLINK_ALIGN(len) (((len)+3) & ~3)
|
||||||
|
#define NLMSG_DATA(nlh) ((void*)((char*)(nlh)+sizeof(struct nlmsghdr)))
|
||||||
|
#define NLMSG_DATALEN(nlh) ((nlh)->nlmsg_len-sizeof(struct nlmsghdr))
|
||||||
|
#define NLMSG_DATAEND(nlh) ((char*)(nlh)+(nlh)->nlmsg_len)
|
||||||
|
#define NLMSG_NEXT(nlh) (struct nlmsghdr*)((char*)(nlh)+NETLINK_ALIGN((nlh)->nlmsg_len))
|
||||||
|
#define NLMSG_OK(nlh,end) ((char*)(end)-(char*)(nlh) >= sizeof(struct nlmsghdr))
|
||||||
|
|
||||||
|
#define RTA_DATA(rta) ((void*)((char*)(rta)+sizeof(struct rtattr)))
|
||||||
|
#define RTA_DATALEN(rta) ((rta)->rta_len-sizeof(struct rtattr))
|
||||||
|
#define RTA_DATAEND(rta) ((char*)(rta)+(rta)->rta_len)
|
||||||
|
#define RTA_NEXT(rta) (struct rtattr*)((char*)(rta)+NETLINK_ALIGN((rta)->rta_len))
|
||||||
|
#define RTA_OK(nlh,end) ((char*)(end)-(char*)(rta) >= sizeof(struct rtattr))
|
||||||
|
|
||||||
|
#define NLMSG_RTA(nlh,len) ((void*)((char*)(nlh)+sizeof(struct nlmsghdr)+NETLINK_ALIGN(len)))
|
||||||
|
#define NLMSG_RTAOK(rta,nlh) RTA_OK(rta,NLMSG_DATAEND(nlh))
|
||||||
|
|
||||||
|
int __rtnetlink_enumerate(int link_af, int addr_af, int (*cb)(void *ctx, struct nlmsghdr *h), void *ctx);
|
||||||
|
|
||||||
|
#endif // NETLINK_MUSL_H
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user