diff --git a/common/key.h b/common/key.h index 488fab3..29149ca 100644 --- a/common/key.h +++ b/common/key.h @@ -1,7 +1,21 @@ // V2 License Public Key // Generated: 2026-03-05 00:48:25 +#pragma once -const BYTE g_LicensePublicKey[64] = { +// License public key of this build. DO NOT CHANGE IT. +// +// The array is const, so it is emitted into a read-only section: any attempt to +// overwrite it at run time faults instead of silently succeeding, and every +// reader in the process sees exactly the same bytes. +// +// `extern` + __declspec(selectany) give it one shared definition across +// translation units -- the linker merges the per-TU copies into a single +// COMDAT -- and extern "C" keeps the symbol name unmangled for callers +// outside C++. +#ifdef __cplusplus +extern "C" { +#endif +extern __declspec(selectany) const BYTE g_LicensePublicKey[64] = { 0xa9, 0x5d, 0x1d, 0x44, 0x35, 0x86, 0x85, 0xdd, 0xbe, 0x27, 0x26, 0x6d, 0xe7, 0x33, 0x27, 0xf8, 0xbe, 0x2d, 0x87, 0xdd, 0xc1, 0x47, 0x18, 0xbf, @@ -11,3 +25,6 @@ const BYTE g_LicensePublicKey[64] = { 0x86, 0x64, 0x85, 0xe1, 0xf3, 0xa3, 0x18, 0x95, 0x5d, 0xd6, 0x3f, 0x2f, 0x55, 0x0b, 0x76, 0xbd }; +#ifdef __cplusplus +} +#endif diff --git a/lib/shrink.lib b/lib/shrink.lib index 6441fac..1cc698c 100644 Binary files a/lib/shrink.lib and b/lib/shrink.lib differ diff --git a/lib/shrink_x64.lib b/lib/shrink_x64.lib index 7978002..7a4b8ba 100644 Binary files a/lib/shrink_x64.lib and b/lib/shrink_x64.lib differ diff --git a/server/2015Remote/pwd_gen.cpp b/server/2015Remote/pwd_gen.cpp index 842d288..bdc4170 100644 --- a/server/2015Remote/pwd_gen.cpp +++ b/server/2015Remote/pwd_gen.cpp @@ -354,7 +354,13 @@ bool base64Decode(const std::string& encoded, BYTE* dataOut, size_t* lenOut) std::string formatPublicKeyAsCode(const BYTE* publicKey) { std::ostringstream ss; - ss << "const BYTE g_LicensePublicKey[64] = {\n "; + // 生成的代码要能直接替换 common/key.h:extern + selectany 让各 TU 共享 + // 同一定义(C++14 也能编),extern "C" 让符号名不被修饰、可被其它模块按名字引用。 + ss << "#pragma once\n\n"; + ss << "#ifdef __cplusplus\n"; + ss << "extern \"C\" {\n"; + ss << "#endif\n"; + ss << "extern __declspec(selectany) const BYTE g_LicensePublicKey[64] = {\n "; for (int i = 0; i < V2_PUBKEY_SIZE; i++) { ss << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)publicKey[i]; if (i < V2_PUBKEY_SIZE - 1) { @@ -362,7 +368,10 @@ std::string formatPublicKeyAsCode(const BYTE* publicKey) if ((i + 1) % 8 == 0) ss << "\n "; } } - ss << "\n};"; + ss << "\n};\n"; + ss << "#ifdef __cplusplus\n"; + ss << "}\n"; + ss << "#endif"; return ss.str(); }