Compare commits
7
Commits
main
..
linux-build
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c7d11371b | ||
|
|
64b374fa06 | ||
|
|
e3daf90ba3 | ||
|
|
fa677beeed | ||
|
|
195f02a41d | ||
|
|
7f93d1a353 | ||
|
|
f742770311 |
@@ -8,9 +8,11 @@ TMP_ARCH_DIR := ../tmp/lin/console/$(ARCH_DIR)
|
|||||||
TMP_DIR := $(TMP_ARCH_DIR)/$(CFG_DIR)/$(PROJECT)
|
TMP_DIR := $(TMP_ARCH_DIR)/$(CFG_DIR)/$(PROJECT)
|
||||||
PCH_DIR := $(TMP_DIR)/$(PROJECT).gch
|
PCH_DIR := $(TMP_DIR)/$(PROJECT).gch
|
||||||
DEFINES := $(CONFIG) -DTIXML_USE_STL
|
DEFINES := $(CONFIG) -DTIXML_USE_STL
|
||||||
LFLAGS := -Wl,-rpath,\$$ORIGIN
|
LFLAGS := -Wl,-rpath,\$$ORIGIN -no-pie -Wl,--allow-multiple-definition
|
||||||
LIBS := $(SDK_LIBS) -Wl,--no-as-needed -L../bin -lDogProtectSDK$(ARCH_DIR) -ldl -Wl,--as-needed
|
LIBS := $(SDK_LIBS) -Wl,--no-as-needed -L../bin -lDogProtectSDK$(ARCH_DIR) -ldl -Wl,--as-needed
|
||||||
OBJCOMP := ../bin/$(ARCH_DIR)/$(CFG_DIR)/core.a ../bin/$(ARCH_DIR)/invariant_core.a ../third-party/libffi/libffi$(ARCH_DIR).a /usr/lib/$(ARCH)/libcrypto.a
|
# Linux: static libcrypto.a drags in zlib/zstd; use the shared libs instead.
|
||||||
|
# Prebuilt libffi is non-PIE, hence -no-pie above.
|
||||||
|
OBJCOMP := ../bin/$(ARCH_DIR)/$(CFG_DIR)/core.a ../bin/$(ARCH_DIR)/invariant_core.a ../third-party/libffi/libffi$(ARCH_DIR).a -lcrypto -lz
|
||||||
DYLIBS :=
|
DYLIBS :=
|
||||||
PCH_DIR := $(TMP_DIR)
|
PCH_DIR := $(TMP_DIR)
|
||||||
|
|
||||||
|
|||||||
+12
-6
@@ -1700,7 +1700,11 @@ bool Core::Compile()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
rand_seed = 0;
|
rand_seed = 0;
|
||||||
|
#ifdef _WIN32
|
||||||
OutputDebugStringA(string_format("rand_seed:%d\n", rand_seed).c_str());
|
OutputDebugStringA(string_format("rand_seed:%d\n", rand_seed).c_str());
|
||||||
|
#else
|
||||||
|
(void)rand_seed;
|
||||||
|
#endif
|
||||||
|
|
||||||
srand(rand_seed);
|
srand(rand_seed);
|
||||||
|
|
||||||
@@ -3219,12 +3223,14 @@ bool RSA::CreateKeyPair(size_t key_length)
|
|||||||
delete modulus_;
|
delete modulus_;
|
||||||
bool bInv = false;
|
bool bInv = false;
|
||||||
uint8_t *data = new uint8_t[key_length / 8 + 1];
|
uint8_t *data = new uint8_t[key_length / 8 + 1];
|
||||||
OpenSSL::BN_bn2bin(r->n, data);
|
const OpenSSL::BIGNUM *rn = NULL, *re = NULL, *rd = NULL;
|
||||||
modulus_ = new BigNumber(data, BN_num_bytes(r->n), bInv);
|
OpenSSL::RSA_get0_key(r, &rn, &re, &rd);
|
||||||
OpenSSL::BN_bn2bin(r->e, data);
|
OpenSSL::BN_bn2bin(rn, data);
|
||||||
public_exp_ = new BigNumber(data, BN_num_bytes(r->e), bInv);
|
modulus_ = new BigNumber(data, BN_num_bytes(rn), bInv);
|
||||||
OpenSSL::BN_bn2bin(r->d, data);
|
OpenSSL::BN_bn2bin(re, data);
|
||||||
private_exp_ = new BigNumber(data, BN_num_bytes(r->d), bInv);
|
public_exp_ = new BigNumber(data, BN_num_bytes(re), bInv);
|
||||||
|
OpenSSL::BN_bn2bin(rd, data);
|
||||||
|
private_exp_ = new BigNumber(data, BN_num_bytes(rd), bInv);
|
||||||
delete data;
|
delete data;
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,11 @@
|
|||||||
#include "packer.h"
|
#include "packer.h"
|
||||||
#include "intel.h"
|
#include "intel.h"
|
||||||
#include "objc.h"
|
#include "objc.h"
|
||||||
|
#ifdef _WIN32
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
|
#else
|
||||||
|
#include <x86intrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IntelCommand
|
* IntelCommand
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "objects.h"
|
#include "objects.h"
|
||||||
|
#include <cstdarg>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#define _vsnprintf_s(dest, dest_sz, cnt, fmt, args) _vsnprintf((dest), (dest_sz), (fmt), (args))
|
#define _vsnprintf_s(dest, dest_sz, cnt, fmt, args) _vsnprintf((dest), (dest_sz), (fmt), (args))
|
||||||
|
|||||||
+4
-4
@@ -3163,7 +3163,7 @@ void PERuntimeFunctionList::ReadFromFile(PEArchitecture &file, PEDirectory &dire
|
|||||||
std::vector<uint8_t> call_frame_instructions;
|
std::vector<uint8_t> call_frame_instructions;
|
||||||
for (size_t i = 0; i < directory.size(); i += sizeof(data)) {
|
for (size_t i = 0; i < directory.size(); i += sizeof(data)) {
|
||||||
file.Read(&data, sizeof(data));
|
file.Read(&data, sizeof(data));
|
||||||
Add(address_ + i, data.BeginAddress + image_base, data.EndAddress + image_base, data.u.UnwindData + image_base, 0, call_frame_instructions);
|
Add(address_ + i, data.BeginAddress + image_base, data.EndAddress + image_base, data.UnwindInfoAddress + image_base, 0, call_frame_instructions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3178,7 +3178,7 @@ size_t PERuntimeFunctionList::WriteToFile(PEArchitecture &file)
|
|||||||
PERuntimeFunction *runtime_function = item(i);
|
PERuntimeFunction *runtime_function = item(i);
|
||||||
data.BeginAddress = static_cast<uint32_t>(runtime_function->begin() - image_base);
|
data.BeginAddress = static_cast<uint32_t>(runtime_function->begin() - image_base);
|
||||||
data.EndAddress = static_cast<uint32_t>(runtime_function->end() - image_base);
|
data.EndAddress = static_cast<uint32_t>(runtime_function->end() - image_base);
|
||||||
data.u.UnwindData = static_cast<uint32_t>(runtime_function->unwind_address() - image_base);
|
data.UnwindInfoAddress = static_cast<uint32_t>(runtime_function->unwind_address() - image_base);
|
||||||
res += file.Write(&data, sizeof(data));
|
res += file.Write(&data, sizeof(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3405,7 +3405,7 @@ void PETLSDirectory::ReadFromFile(PEArchitecture &file, PEDirectory &directory)
|
|||||||
address_of_index_ = tls.AddressOfIndex;
|
address_of_index_ = tls.AddressOfIndex;
|
||||||
address_of_call_backs_ = tls.AddressOfCallBacks;
|
address_of_call_backs_ = tls.AddressOfCallBacks;
|
||||||
size_of_zero_fill_ = tls.SizeOfZeroFill;
|
size_of_zero_fill_ = tls.SizeOfZeroFill;
|
||||||
characteristics_ = tls.u.Characteristics;
|
characteristics_ = tls.Characteristics;
|
||||||
} else {
|
} else {
|
||||||
IMAGE_TLS_DIRECTORY64 tls;
|
IMAGE_TLS_DIRECTORY64 tls;
|
||||||
file.Read(&tls, sizeof(tls));
|
file.Read(&tls, sizeof(tls));
|
||||||
@@ -3414,7 +3414,7 @@ void PETLSDirectory::ReadFromFile(PEArchitecture &file, PEDirectory &directory)
|
|||||||
address_of_index_ = tls.AddressOfIndex;
|
address_of_index_ = tls.AddressOfIndex;
|
||||||
address_of_call_backs_ = tls.AddressOfCallBacks;
|
address_of_call_backs_ = tls.AddressOfCallBacks;
|
||||||
size_of_zero_fill_ = tls.SizeOfZeroFill;
|
size_of_zero_fill_ = tls.SizeOfZeroFill;
|
||||||
characteristics_ = tls.u.Characteristics;
|
characteristics_ = tls.Characteristics;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!address_of_call_backs_)
|
if (!address_of_call_backs_)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#define CORE_PCH
|
#define CORE_PCH
|
||||||
|
|
||||||
#include "../runtime/precommon.h"
|
#include "../runtime/precommon.h"
|
||||||
|
#include <cstdarg>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -38,7 +39,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#ifdef __APPLE__
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DUMMYUNIONNAME u
|
#define DUMMYUNIONNAME u
|
||||||
#define DUMMYUNIONNAME2 u2
|
#define DUMMYUNIONNAME2 u2
|
||||||
|
|||||||
@@ -6,7 +6,11 @@
|
|||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "processors.h"
|
#include "processors.h"
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
|
#ifdef _WIN32
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
|
#else
|
||||||
|
#include <x86intrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AddressRange
|
* AddressRange
|
||||||
|
|||||||
+4
-3
@@ -1,6 +1,7 @@
|
|||||||
#WARN: no incremental build supported yet (use 'all' target carefully)
|
#WARN: no incremental build supported yet (use 'all' target carefully)
|
||||||
|
|
||||||
.PHONY: clean all rebuild
|
.PHONY: clean all rebuild
|
||||||
|
.DEFAULT_GOAL := all
|
||||||
|
|
||||||
BIN_TARGET := $(BIN_DIR)/$(TARGET)
|
BIN_TARGET := $(BIN_DIR)/$(TARGET)
|
||||||
|
|
||||||
@@ -9,9 +10,9 @@ CXX := clang++
|
|||||||
LINK := clang++
|
LINK := clang++
|
||||||
CFLAGS := $(CFLAGS) -pipe -fvisibility=hidden -DNDEBUG -O3 -gdwarf-2 -target $(ARCH) -Wall -W -fPIC $(DEFINES)
|
CFLAGS := $(CFLAGS) -pipe -fvisibility=hidden -DNDEBUG -O3 -gdwarf-2 -target $(ARCH) -Wall -W -fPIC $(DEFINES)
|
||||||
CXXFLAGS := $(CXXFLAGS) $(CFLAGS) -std=c++11 -fvisibility-inlines-hidden -fno-stack-protector -fno-builtin -Wno-reorder -Wno-switch -Wno-unused-parameter -Wno-unused-variable
|
CXXFLAGS := $(CXXFLAGS) $(CFLAGS) -std=c++11 -fvisibility-inlines-hidden -fno-stack-protector -fno-builtin -Wno-reorder -Wno-switch -Wno-unused-parameter -Wno-unused-variable
|
||||||
# Linux 目标按 Ultimate 版编译:授权子系统只在 ULTIMATE 分支里编译,
|
# Linux 目标统一按 Ultimate 版编译:授权/序列号子系统(LicensingManager、-lf 授权参数文件、
|
||||||
# 否则打包时报 "The licensing system not supported in this version"。
|
# 密钥对与密钥库)只在 ULTIMATE 分支里编译,其余版本打包时会报
|
||||||
# 用 += 追加,别改 $(DEFINES),否则会覆盖各目标自带的宏。
|
# "The licensing system not supported in this version"。追加而不是改 $(DEFINES),避免覆盖各目标的宏。
|
||||||
CFLAGS += -DULTIMATE
|
CFLAGS += -DULTIMATE
|
||||||
CXXFLAGS += -DULTIMATE
|
CXXFLAGS += -DULTIMATE
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -72,7 +72,7 @@ inline uint64_t _rotr64(uint64_t value, int shift)
|
|||||||
return (value >> shift) | (value << (sizeof(value) * 8 - shift));
|
return (value >> shift) | (value << (sizeof(value) * 8 - shift));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint64_t __rdtsc()
|
inline uint64_t vmp_rdtsc()
|
||||||
{
|
{
|
||||||
uint32_t hi, lo;
|
uint32_t hi, lo;
|
||||||
__asm__ __volatile__ ("rdtsc"
|
__asm__ __volatile__ ("rdtsc"
|
||||||
@@ -80,6 +80,7 @@ inline uint64_t __rdtsc()
|
|||||||
);
|
);
|
||||||
return static_cast<uint64_t>(lo) | static_cast<uint64_t>(hi) << 32;
|
return static_cast<uint64_t>(lo) | static_cast<uint64_t>(hi) << 32;
|
||||||
}
|
}
|
||||||
|
#define __rdtsc() vmp_rdtsc()
|
||||||
|
|
||||||
|
|
||||||
inline void __cpuid(int regs[4], uint32_t value)
|
inline void __cpuid(int regs[4], uint32_t value)
|
||||||
|
|||||||
@@ -106,7 +106,11 @@ typedef int (FAR WINAPI *FARPROC)();
|
|||||||
#else
|
#else
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
|
#ifdef _WIN32
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
|
#else
|
||||||
|
#include <x86intrin.h>
|
||||||
|
#endif
|
||||||
#include <wtsapi32.h>
|
#include <wtsapi32.h>
|
||||||
#include <winternl.h>
|
#include <winternl.h>
|
||||||
#include <tlhelp32.h>
|
#include <tlhelp32.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user