├── x86 ├── lib │ ├── auth.cpp │ ├── curl │ │ ├── libcurl.lib │ │ ├── libcurl86.lib │ │ ├── stdcheaders.h │ │ ├── Makefile.am │ │ ├── mprintf.h │ │ ├── curlver.h │ │ ├── easy.h │ │ └── urlapi.h │ ├── utils.hpp │ ├── nlohmann │ │ ├── detail │ │ │ ├── meta │ │ │ │ ├── void_t.hpp │ │ │ │ ├── detected.hpp │ │ │ │ ├── cpp_future.hpp │ │ │ │ └── is_sax.hpp │ │ │ ├── macro_unscope.hpp │ │ │ ├── input │ │ │ │ └── position_t.hpp │ │ │ ├── iterators │ │ │ │ ├── internal_iterator.hpp │ │ │ │ ├── iterator_traits.hpp │ │ │ │ ├── primitive_iterator.hpp │ │ │ │ ├── json_reverse_iterator.hpp │ │ │ │ └── iteration_proxy.hpp │ │ │ ├── json_ref.hpp │ │ │ ├── value_t.hpp │ │ │ ├── output │ │ │ │ └── output_adapters.hpp │ │ │ ├── hash.hpp │ │ │ └── conversions │ │ │ │ ├── to_json.hpp │ │ │ │ └── from_json.hpp │ │ ├── adl_serializer.hpp │ │ ├── json_fwd.hpp │ │ ├── ordered_map.hpp │ │ ├── byte_container_with_subtype.hpp │ │ └── thirdparty │ │ │ └── hedley │ │ │ └── hedley_undef.hpp │ ├── includes.hpp │ ├── utils.cpp │ ├── hmac_sha256.h │ ├── integrity.h │ ├── hmac_sha256.c │ ├── Security.hpp │ ├── sha256.h │ ├── auth.hpp │ ├── xorstr.hpp │ └── sha256.c ├── example.vcxproj.user ├── utils.hpp ├── example.sln ├── skStr.h ├── main.cpp ├── example.vcxproj.filters └── example.vcxproj ├── x64 ├── library_x64.lib ├── example.vcxproj.user ├── example.sln ├── utils.hpp ├── example.vcxproj.filters ├── auth.hpp ├── skStr.h ├── example.vcxproj └── main.cpp ├── .github └── workflows │ └── pr_notification.yml ├── LICENSE └── .gitignore /x86/lib/auth.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KeyAuth/KeyAuth-CPP-Example/HEAD/x86/lib/auth.cpp -------------------------------------------------------------------------------- /x64/library_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KeyAuth/KeyAuth-CPP-Example/HEAD/x64/library_x64.lib -------------------------------------------------------------------------------- /x86/lib/curl/libcurl.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KeyAuth/KeyAuth-CPP-Example/HEAD/x86/lib/curl/libcurl.lib -------------------------------------------------------------------------------- /x86/lib/curl/libcurl86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KeyAuth/KeyAuth-CPP-Example/HEAD/x86/lib/curl/libcurl86.lib -------------------------------------------------------------------------------- /x86/lib/utils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace utils 6 | { 7 | std::string get_hwid(); 8 | std::time_t string_to_timet(std::string timestamp); 9 | std::tm timet_to_tm(time_t timestamp); 10 | } -------------------------------------------------------------------------------- /x64/example.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /x86/example.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /.github/workflows/pr_notification.yml: -------------------------------------------------------------------------------- 1 | name: Pull Request Notification 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - opened 7 | 8 | jobs: 9 | notify: 10 | uses: KeyAuth/.github/.github/workflows/pr_notification_global.yml@main 11 | secrets: 12 | DISCORD_PR: ${{ secrets.DISCORD_PR }} 13 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/meta/void_t.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace nlohmann 4 | { 5 | namespace detail 6 | { 7 | template struct make_void 8 | { 9 | using type = void; 10 | }; 11 | template using void_t = typename make_void::type; 12 | } // namespace detail 13 | } // namespace nlohmann 14 | -------------------------------------------------------------------------------- /x86/lib/includes.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #pragma comment (lib, "advapi32.lib") 8 | #pragma comment(lib, "libcurl.lib") 9 | #pragma comment(lib, "Normaliz.lib") 10 | #pragma comment(lib, "wldap32.lib" ) 11 | #pragma comment(lib, "crypt32.lib" ) 12 | #pragma comment(lib, "Ws2_32.lib") 13 | 14 | #define CURL_STATICLIB 15 | #include 16 | 17 | #include "utils.hpp" -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/macro_unscope.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // restore GCC/clang diagnostic settings 4 | #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) 5 | #pragma GCC diagnostic pop 6 | #endif 7 | #if defined(__clang__) 8 | #pragma GCC diagnostic pop 9 | #endif 10 | 11 | // clean up 12 | #undef JSON_ASSERT 13 | #undef JSON_INTERNAL_CATCH 14 | #undef JSON_CATCH 15 | #undef JSON_THROW 16 | #undef JSON_TRY 17 | #undef JSON_HAS_CPP_14 18 | #undef JSON_HAS_CPP_17 19 | #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION 20 | #undef NLOHMANN_BASIC_JSON_TPL 21 | #undef JSON_EXPLICIT 22 | 23 | #include 24 | -------------------------------------------------------------------------------- /x86/lib/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.hpp" 2 | 3 | #include 4 | 5 | std::string utils::get_hwid() { 6 | ATL::CAccessToken accessToken; 7 | ATL::CSid currentUserSid; 8 | if (accessToken.GetProcessToken(TOKEN_READ | TOKEN_QUERY) && 9 | accessToken.GetUser(¤tUserSid)) 10 | return std::string(CT2A(currentUserSid.Sid())); 11 | return "none"; 12 | } 13 | 14 | std::time_t utils::string_to_timet(std::string timestamp) { 15 | auto cv = strtol(timestamp.c_str(), NULL, 10); 16 | 17 | return (time_t)cv; 18 | } 19 | 20 | std::tm utils::timet_to_tm(time_t timestamp) { 21 | std::tm context; 22 | 23 | localtime_s(&context, ×tamp); 24 | 25 | return context; 26 | } 27 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/input/position_t.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // size_t 4 | 5 | namespace nlohmann 6 | { 7 | namespace detail 8 | { 9 | /// struct to capture the start position of the current token 10 | struct position_t 11 | { 12 | /// the total number of characters read 13 | std::size_t chars_read_total = 0; 14 | /// the number of characters read in the current line 15 | std::size_t chars_read_current_line = 0; 16 | /// the number of lines read 17 | std::size_t lines_read = 0; 18 | 19 | /// conversion to size_t to preserve SAX interface 20 | constexpr operator size_t() const 21 | { 22 | return chars_read_total; 23 | } 24 | }; 25 | 26 | } // namespace detail 27 | } // namespace nlohmann 28 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/iterators/internal_iterator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace nlohmann 6 | { 7 | namespace detail 8 | { 9 | /*! 10 | @brief an iterator value 11 | 12 | @note This structure could easily be a union, but MSVC currently does not allow 13 | unions members with complex constructors, see https://github.com/nlohmann/json/pull/105. 14 | */ 15 | template struct internal_iterator 16 | { 17 | /// iterator for JSON objects 18 | typename BasicJsonType::object_t::iterator object_iterator {}; 19 | /// iterator for JSON arrays 20 | typename BasicJsonType::array_t::iterator array_iterator {}; 21 | /// generic iterator for all other types 22 | primitive_iterator_t primitive_iterator {}; 23 | }; 24 | } // namespace detail 25 | } // namespace nlohmann 26 | -------------------------------------------------------------------------------- /x86/lib/hmac_sha256.h: -------------------------------------------------------------------------------- 1 | /* 2 | hmac_sha256.h 3 | Originally written by https://github.com/h5p9sl 4 | */ 5 | 6 | #ifndef _HMAC_SHA256_H_ 7 | #define _HMAC_SHA256_H_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif // __cplusplus 12 | 13 | #include 14 | 15 | size_t // Returns the number of bytes written to `out` 16 | hmac_sha256( 17 | // [in]: The key and its length. 18 | // Should be at least 32 bytes long for optimal security. 19 | const void* key, 20 | const size_t keylen, 21 | 22 | // [in]: The data to hash alongside the key. 23 | const void* data, 24 | const size_t datalen, 25 | 26 | // [out]: The output hash. 27 | // Should be 32 bytes long. If it's less than 32 bytes, 28 | // the resulting hash will be truncated to the specified length. 29 | void* out, 30 | const size_t outlen); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif // __cplusplus 35 | 36 | #endif // _HMAC_SHA256_H_ 37 | -------------------------------------------------------------------------------- /x64/example.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.6.33815.320 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcxproj", "{3E584710-D844-49E5-9938-B4EFA4928B17}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Release|x64 = Release|x64 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3E584710-D844-49E5-9938-B4EFA4928B17}.Release|x64.ActiveCfg = Release|x64 15 | {3E584710-D844-49E5-9938-B4EFA4928B17}.Release|x64.Build.0 = Release|x64 16 | {3E584710-D844-49E5-9938-B4EFA4928B17}.Release|x86.ActiveCfg = Release|Win32 17 | {3E584710-D844-49E5-9938-B4EFA4928B17}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {9EE66AFE-8CA5-4A35-9001-B4A57E4493E3} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /x86/utils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "skStr.h" 6 | #include "json.hpp" 7 | using json = nlohmann::json; 8 | 9 | std::string ReadFromJson(std::string path, std::string section) 10 | { 11 | if (!std::filesystem::exists(path)) 12 | return skCrypt("File Not Found").decrypt(); 13 | std::ifstream file(path); 14 | json data = json::parse(file); 15 | return data[section]; 16 | } 17 | 18 | bool CheckIfJsonKeyExists(std::string path, std::string section) 19 | { 20 | if (!std::filesystem::exists(path)) 21 | return skCrypt("File Not Found").decrypt(); 22 | std::ifstream file(path); 23 | json data = json::parse(file); 24 | return data.contains(section); 25 | } 26 | 27 | bool WriteToJson(std::string path, std::string name, std::string value, bool userpass, std::string name2, std::string value2) 28 | { 29 | json file; 30 | if (!userpass) 31 | { 32 | file[name] = value; 33 | } 34 | else 35 | { 36 | file[name] = value; 37 | file[name2] = value2; 38 | } 39 | 40 | std::ofstream jsonfile(path, std::ios::out); 41 | jsonfile << file; 42 | jsonfile.close(); 43 | if (!std::filesystem::exists(path)) 44 | return false; 45 | 46 | return true; 47 | } 48 | -------------------------------------------------------------------------------- /x86/lib/curl/stdcheaders.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_STDCHEADERS_H 2 | #define CURLINC_STDCHEADERS_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2019, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | #include 26 | 27 | size_t fread(void *, size_t, size_t, FILE *); 28 | size_t fwrite(const void *, size_t, size_t, FILE *); 29 | 30 | int strcasecmp(const char *, const char *); 31 | int strncasecmp(const char *, const char *, size_t); 32 | 33 | #endif /* CURLINC_STDCHEADERS_H */ 34 | -------------------------------------------------------------------------------- /x64/utils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "skStr.h" 6 | #include "json.hpp" 7 | using json = nlohmann::json; 8 | 9 | std::string ReadFromJson(std::string path, std::string section) 10 | { 11 | if (!std::filesystem::exists(path)) 12 | return skCrypt("File Not Found").decrypt(); 13 | std::ifstream file(path); 14 | json data = json::parse(file); 15 | return data[section]; 16 | } 17 | 18 | bool CheckIfJsonKeyExists(std::string path, std::string section) 19 | { 20 | if (!std::filesystem::exists(path)) 21 | return skCrypt("File Not Found").decrypt(); 22 | std::ifstream file(path); 23 | json data = json::parse(file); 24 | return data.contains(section); 25 | } 26 | 27 | bool WriteToJson(std::string path, std::string name, std::string value, bool userpass, std::string name2, std::string value2) 28 | { 29 | json file; 30 | if (!userpass) 31 | { 32 | file[name] = value; 33 | } 34 | else 35 | { 36 | file[name] = value; 37 | file[name2] = value2; 38 | } 39 | 40 | std::ofstream jsonfile(path, std::ios::out); 41 | jsonfile << file; 42 | jsonfile.close(); 43 | if (!std::filesystem::exists(path)) 44 | return false; 45 | 46 | return true; 47 | } 48 | 49 | void checkAuthenticated(std::string ownerid) { 50 | while (true) { 51 | if (GlobalFindAtomA(ownerid.c_str()) == 0) { 52 | exit(13); 53 | } 54 | Sleep(1000); // thread interval 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /x86/example.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31624.102 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcxproj", "{3E584710-D844-49E5-9938-B4EFA4928B17}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {3E584710-D844-49E5-9938-B4EFA4928B17}.Debug|x64.ActiveCfg = Debug|x64 17 | {3E584710-D844-49E5-9938-B4EFA4928B17}.Debug|x64.Build.0 = Debug|x64 18 | {3E584710-D844-49E5-9938-B4EFA4928B17}.Debug|x86.ActiveCfg = Debug|Win32 19 | {3E584710-D844-49E5-9938-B4EFA4928B17}.Debug|x86.Build.0 = Debug|Win32 20 | {3E584710-D844-49E5-9938-B4EFA4928B17}.Release|x64.ActiveCfg = Release|x64 21 | {3E584710-D844-49E5-9938-B4EFA4928B17}.Release|x64.Build.0 = Release|x64 22 | {3E584710-D844-49E5-9938-B4EFA4928B17}.Release|x86.ActiveCfg = Release|Win32 23 | {3E584710-D844-49E5-9938-B4EFA4928B17}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {9EE66AFE-8CA5-4A35-9001-B4A57E4493E3} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /x86/lib/curl/Makefile.am: -------------------------------------------------------------------------------- 1 | #*************************************************************************** 2 | # _ _ ____ _ 3 | # Project ___| | | | _ \| | 4 | # / __| | | | |_) | | 5 | # | (__| |_| | _ <| |___ 6 | # \___|\___/|_| \_\_____| 7 | # 8 | # Copyright (C) 1998 - 2019, Daniel Stenberg, , et al. 9 | # 10 | # This software is licensed as described in the file COPYING, which 11 | # you should have received as part of this distribution. The terms 12 | # are also available at https://curl.haxx.se/docs/copyright.html. 13 | # 14 | # You may opt to use, copy, modify, merge, publish, distribute and/or sell 15 | # copies of the Software, and permit persons to whom the Software is 16 | # furnished to do so, under the terms of the COPYING file. 17 | # 18 | # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 19 | # KIND, either express or implied. 20 | # 21 | ########################################################################### 22 | pkginclude_HEADERS = \ 23 | curl.h curlver.h easy.h mprintf.h stdcheaders.h multi.h \ 24 | typecheck-gcc.h system.h urlapi.h 25 | 26 | pkgincludedir= $(includedir)/curl 27 | 28 | CHECKSRC = $(CS_$(V)) 29 | CS_0 = @echo " RUN " $@; 30 | CS_1 = 31 | CS_ = $(CS_0) 32 | 33 | checksrc: 34 | $(CHECKSRC)@PERL@ $(top_srcdir)/lib/checksrc.pl -D$(top_srcdir)/include/curl $(pkginclude_HEADERS) 35 | 36 | if CURLDEBUG 37 | # for debug builds, we scan the sources on all regular make invokes 38 | all-local: checksrc 39 | endif 40 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/iterators/iterator_traits.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // random_access_iterator_tag 4 | 5 | #include 6 | #include 7 | 8 | namespace nlohmann 9 | { 10 | namespace detail 11 | { 12 | template 13 | struct iterator_types {}; 14 | 15 | template 16 | struct iterator_types < 17 | It, 18 | void_t> 20 | { 21 | using difference_type = typename It::difference_type; 22 | using value_type = typename It::value_type; 23 | using pointer = typename It::pointer; 24 | using reference = typename It::reference; 25 | using iterator_category = typename It::iterator_category; 26 | }; 27 | 28 | // This is required as some compilers implement std::iterator_traits in a way that 29 | // doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. 30 | template 31 | struct iterator_traits 32 | { 33 | }; 34 | 35 | template 36 | struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> 37 | : iterator_types 38 | { 39 | }; 40 | 41 | template 42 | struct iterator_traits::value>> 43 | { 44 | using iterator_category = std::random_access_iterator_tag; 45 | using value_type = T; 46 | using difference_type = ptrdiff_t; 47 | using pointer = T*; 48 | using reference = T&; 49 | }; 50 | } // namespace detail 51 | } // namespace nlohmann 52 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/adl_serializer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace nlohmann 9 | { 10 | 11 | template 12 | struct adl_serializer 13 | { 14 | /*! 15 | @brief convert a JSON value to any value type 16 | 17 | This function is usually called by the `get()` function of the 18 | @ref basic_json class (either explicit or via conversion operators). 19 | 20 | @param[in] j JSON value to read from 21 | @param[in,out] val value to write to 22 | */ 23 | template 24 | static auto from_json(BasicJsonType&& j, ValueType& val) noexcept( 25 | noexcept(::nlohmann::from_json(std::forward(j), val))) 26 | -> decltype(::nlohmann::from_json(std::forward(j), val), void()) 27 | { 28 | ::nlohmann::from_json(std::forward(j), val); 29 | } 30 | 31 | /*! 32 | @brief convert any value type to a JSON value 33 | 34 | This function is usually called by the constructors of the @ref basic_json 35 | class. 36 | 37 | @param[in,out] j JSON value to write to 38 | @param[in] val value to read from 39 | */ 40 | template 41 | static auto to_json(BasicJsonType& j, ValueType&& val) noexcept( 42 | noexcept(::nlohmann::to_json(j, std::forward(val)))) 43 | -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) 44 | { 45 | ::nlohmann::to_json(j, std::forward(val)); 46 | } 47 | }; 48 | 49 | } // namespace nlohmann 50 | -------------------------------------------------------------------------------- /x64/example.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {de1a561c-edb6-4e62-a44a-ca45ef812d97} 18 | 19 | 20 | {587eab74-13d3-4764-9f32-49b7924744df} 21 | 22 | 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files\auth 31 | 32 | 33 | Header Files\Protection 34 | 35 | 36 | 37 | 38 | Header Files\auth 39 | 40 | 41 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/meta/detected.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | // https://en.cppreference.com/w/cpp/experimental/is_detected 8 | namespace nlohmann 9 | { 10 | namespace detail 11 | { 12 | struct nonesuch 13 | { 14 | nonesuch() = delete; 15 | ~nonesuch() = delete; 16 | nonesuch(nonesuch const&) = delete; 17 | nonesuch(nonesuch const&&) = delete; 18 | void operator=(nonesuch const&) = delete; 19 | void operator=(nonesuch&&) = delete; 20 | }; 21 | 22 | template class Op, 25 | class... Args> 26 | struct detector 27 | { 28 | using value_t = std::false_type; 29 | using type = Default; 30 | }; 31 | 32 | template class Op, class... Args> 33 | struct detector>, Op, Args...> 34 | { 35 | using value_t = std::true_type; 36 | using type = Op; 37 | }; 38 | 39 | template class Op, class... Args> 40 | using is_detected = typename detector::value_t; 41 | 42 | template class Op, class... Args> 43 | using detected_t = typename detector::type; 44 | 45 | template class Op, class... Args> 46 | using detected_or = detector; 47 | 48 | template class Op, class... Args> 49 | using detected_or_t = typename detected_or::type; 50 | 51 | template class Op, class... Args> 52 | using is_detected_exact = std::is_same>; 53 | 54 | template class Op, class... Args> 55 | using is_detected_convertible = 56 | std::is_convertible, To>; 57 | } // namespace detail 58 | } // namespace nlohmann 59 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/json_ref.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace nlohmann 9 | { 10 | namespace detail 11 | { 12 | template 13 | class json_ref 14 | { 15 | public: 16 | using value_type = BasicJsonType; 17 | 18 | json_ref(value_type&& value) 19 | : owned_value(std::move(value)) 20 | , value_ref(&owned_value) 21 | , is_rvalue(true) 22 | {} 23 | 24 | json_ref(const value_type& value) 25 | : value_ref(const_cast(&value)) 26 | , is_rvalue(false) 27 | {} 28 | 29 | json_ref(std::initializer_list init) 30 | : owned_value(init) 31 | , value_ref(&owned_value) 32 | , is_rvalue(true) 33 | {} 34 | 35 | template < 36 | class... Args, 37 | enable_if_t::value, int> = 0 > 38 | json_ref(Args && ... args) 39 | : owned_value(std::forward(args)...) 40 | , value_ref(&owned_value) 41 | , is_rvalue(true) 42 | {} 43 | 44 | // class should be movable only 45 | json_ref(json_ref&&) = default; 46 | json_ref(const json_ref&) = delete; 47 | json_ref& operator=(const json_ref&) = delete; 48 | json_ref& operator=(json_ref&&) = delete; 49 | ~json_ref() = default; 50 | 51 | value_type moved_or_copied() const 52 | { 53 | if (is_rvalue) 54 | { 55 | return std::move(*value_ref); 56 | } 57 | return *value_ref; 58 | } 59 | 60 | value_type const& operator*() const 61 | { 62 | return *static_cast(value_ref); 63 | } 64 | 65 | value_type const* operator->() const 66 | { 67 | return static_cast(value_ref); 68 | } 69 | 70 | private: 71 | mutable value_type owned_value = nullptr; 72 | value_type* value_ref = nullptr; 73 | const bool is_rvalue = true; 74 | }; 75 | } // namespace detail 76 | } // namespace nlohmann 77 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/meta/cpp_future.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // size_t 4 | #include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type 5 | 6 | namespace nlohmann 7 | { 8 | namespace detail 9 | { 10 | // alias templates to reduce boilerplate 11 | template 12 | using enable_if_t = typename std::enable_if::type; 13 | 14 | template 15 | using uncvref_t = typename std::remove_cv::type>::type; 16 | 17 | // implementation of C++14 index_sequence and affiliates 18 | // source: https://stackoverflow.com/a/32223343 19 | template 20 | struct index_sequence 21 | { 22 | using type = index_sequence; 23 | using value_type = std::size_t; 24 | static constexpr std::size_t size() noexcept 25 | { 26 | return sizeof...(Ints); 27 | } 28 | }; 29 | 30 | template 31 | struct merge_and_renumber; 32 | 33 | template 34 | struct merge_and_renumber, index_sequence> 35 | : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; 36 | 37 | template 38 | struct make_index_sequence 39 | : merge_and_renumber < typename make_index_sequence < N / 2 >::type, 40 | typename make_index_sequence < N - N / 2 >::type > {}; 41 | 42 | template<> struct make_index_sequence<0> : index_sequence<> {}; 43 | template<> struct make_index_sequence<1> : index_sequence<0> {}; 44 | 45 | template 46 | using index_sequence_for = make_index_sequence; 47 | 48 | // dispatch utility (taken from ranges-v3) 49 | template struct priority_tag : priority_tag < N - 1 > {}; 50 | template<> struct priority_tag<0> {}; 51 | 52 | // taken from ranges-v3 53 | template 54 | struct static_const 55 | { 56 | static constexpr T value{}; 57 | }; 58 | 59 | template 60 | constexpr T static_const::value; 61 | } // namespace detail 62 | } // namespace nlohmann 63 | -------------------------------------------------------------------------------- /x86/lib/integrity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | typedef struct _integrity_check 7 | { 8 | struct section { 9 | std::uint8_t* name = {}; 10 | void* address = {}; 11 | std::uint32_t checksum = {}; 12 | 13 | bool operator==(section& other) 14 | { 15 | return checksum == other.checksum; 16 | } 17 | }; section _cached; 18 | 19 | _integrity_check() 20 | { 21 | _cached = get_text_section(reinterpret_cast(GetModuleHandle(nullptr))); 22 | } 23 | 24 | std::uint32_t crc32(void* data, std::size_t size) 25 | { 26 | std::uint32_t result = {}; 27 | 28 | for (std::size_t index = {}; index < size; ++index) 29 | result = _mm_crc32_u32(result, reinterpret_cast(data)[index]); 30 | 31 | return result; 32 | } 33 | 34 | section get_text_section(std::uintptr_t module) 35 | { 36 | section text_section = {}; 37 | 38 | PIMAGE_DOS_HEADER dosheader = reinterpret_cast(module); 39 | PIMAGE_NT_HEADERS nt_headers = reinterpret_cast(module + dosheader->e_lfanew); 40 | 41 | PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(nt_headers); 42 | 43 | for (int i = 0; i < nt_headers->FileHeader.NumberOfSections; i++, section++) 44 | { 45 | std::string name(reinterpret_cast(section->Name)); 46 | if (name != ".text") 47 | continue; 48 | 49 | void* address = reinterpret_cast(module + section->VirtualAddress); 50 | text_section = { section->Name, address, crc32(address, section->Misc.VirtualSize) }; 51 | } 52 | return text_section; 53 | } 54 | /// 55 | /// Checks .text integrity. 56 | /// 57 | /// Returns true if it has been changed. 58 | bool check_integrity() 59 | { 60 | section section2 = get_text_section(reinterpret_cast(GetModuleHandle(nullptr))); 61 | return (!(_cached == section2)); 62 | } 63 | }; -------------------------------------------------------------------------------- /x86/lib/curl/mprintf.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_MPRINTF_H 2 | #define CURLINC_MPRINTF_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2019, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | #include 26 | #include /* needed for FILE */ 27 | #include "curl.h" /* for CURL_EXTERN */ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | CURL_EXTERN int curl_mprintf(const char *format, ...); 34 | CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...); 35 | CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...); 36 | CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength, 37 | const char *format, ...); 38 | CURL_EXTERN int curl_mvprintf(const char *format, va_list args); 39 | CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args); 40 | CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args); 41 | CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength, 42 | const char *format, va_list args); 43 | CURL_EXTERN char *curl_maprintf(const char *format, ...); 44 | CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /* CURLINC_MPRINTF_H */ 51 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/json_fwd.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ 2 | #define INCLUDE_NLOHMANN_JSON_FWD_HPP_ 3 | 4 | #include // int64_t, uint64_t 5 | #include // map 6 | #include // allocator 7 | #include // string 8 | #include // vector 9 | 10 | /*! 11 | @brief namespace for Niels Lohmann 12 | @see https://github.com/nlohmann 13 | @since version 1.0.0 14 | */ 15 | namespace nlohmann 16 | { 17 | /*! 18 | @brief default JSONSerializer template argument 19 | 20 | This serializer ignores the template arguments and uses ADL 21 | ([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) 22 | for serialization. 23 | */ 24 | template 25 | struct adl_serializer; 26 | 27 | template class ObjectType = 28 | std::map, 29 | template class ArrayType = std::vector, 30 | class StringType = std::string, class BooleanType = bool, 31 | class NumberIntegerType = std::int64_t, 32 | class NumberUnsignedType = std::uint64_t, 33 | class NumberFloatType = double, 34 | template class AllocatorType = std::allocator, 35 | template class JSONSerializer = 36 | adl_serializer, 37 | class BinaryType = std::vector> 38 | class basic_json; 39 | 40 | /*! 41 | @brief JSON Pointer 42 | 43 | A JSON pointer defines a string syntax for identifying a specific value 44 | within a JSON document. It can be used with functions `at` and 45 | `operator[]`. Furthermore, JSON pointers are the base for JSON patches. 46 | 47 | @sa [RFC 6901](https://tools.ietf.org/html/rfc6901) 48 | 49 | @since version 2.0.0 50 | */ 51 | template 52 | class json_pointer; 53 | 54 | /*! 55 | @brief default JSON class 56 | 57 | This type is the default specialization of the @ref basic_json class which 58 | uses the standard template types. 59 | 60 | @since version 1.0.0 61 | */ 62 | using json = basic_json<>; 63 | 64 | template 65 | struct ordered_map; 66 | 67 | /*! 68 | @brief ordered JSON class 69 | 70 | This type preserves the insertion order of object keys. 71 | 72 | @since version 3.9.0 73 | */ 74 | using ordered_json = basic_json; 75 | 76 | } // namespace nlohmann 77 | 78 | #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ 79 | -------------------------------------------------------------------------------- /x86/lib/hmac_sha256.c: -------------------------------------------------------------------------------- 1 | /* 2 | hmac_sha256.c 3 | Originally written by https://github.com/h5p9sl 4 | */ 5 | 6 | #include "hmac_sha256.h" 7 | #include "sha256.h" 8 | 9 | #include 10 | #include 11 | 12 | #define SHA256_BLOCK_SIZE 64 13 | 14 | /* LOCAL FUNCTIONS */ 15 | 16 | // Concatenate X & Y, return hash. 17 | static void* H(const void* x, 18 | const size_t xlen, 19 | const void* y, 20 | const size_t ylen, 21 | void* out, 22 | const size_t outlen); 23 | 24 | // Wrapper for sha256 25 | static void* sha256(const void* data, 26 | const size_t datalen, 27 | void* out, 28 | const size_t outlen); 29 | 30 | // Declared in hmac_sha256.h 31 | size_t hmac_sha256(const void* key, 32 | const size_t keylen, 33 | const void* data, 34 | const size_t datalen, 35 | void* out, 36 | const size_t outlen) { 37 | uint8_t k[SHA256_BLOCK_SIZE]; 38 | uint8_t k_ipad[SHA256_BLOCK_SIZE]; 39 | uint8_t k_opad[SHA256_BLOCK_SIZE]; 40 | uint8_t ihash[SHA256_HASH_SIZE]; 41 | uint8_t ohash[SHA256_HASH_SIZE]; 42 | size_t sz; 43 | int i; 44 | 45 | memset(k, 0, sizeof(k)); 46 | memset(k_ipad, 0x36, SHA256_BLOCK_SIZE); 47 | memset(k_opad, 0x5c, SHA256_BLOCK_SIZE); 48 | 49 | if (keylen > SHA256_BLOCK_SIZE) { 50 | // If the key is larger than the hash algorithm's 51 | // block size, we must digest it first. 52 | sha256(key, keylen, k, sizeof(k)); 53 | } else { 54 | memcpy(k, key, keylen); 55 | } 56 | 57 | for (i = 0; i < SHA256_BLOCK_SIZE; i++) { 58 | k_ipad[i] ^= k[i]; 59 | k_opad[i] ^= k[i]; 60 | } 61 | 62 | // Perform HMAC algorithm: ( https://tools.ietf.org/html/rfc2104 ) 63 | // `H(K XOR opad, H(K XOR ipad, data))` 64 | H(k_ipad, sizeof(k_ipad), data, datalen, ihash, sizeof(ihash)); 65 | H(k_opad, sizeof(k_opad), ihash, sizeof(ihash), ohash, sizeof(ohash)); 66 | 67 | sz = (outlen > SHA256_HASH_SIZE) ? SHA256_HASH_SIZE : outlen; 68 | memcpy(out, ohash, sz); 69 | return sz; 70 | } 71 | 72 | static void* H(const void* x, 73 | const size_t xlen, 74 | const void* y, 75 | const size_t ylen, 76 | void* out, 77 | const size_t outlen) { 78 | void* result; 79 | size_t buflen = (xlen + ylen); 80 | uint8_t* buf = (uint8_t*)malloc(buflen); 81 | 82 | memcpy(buf, x, xlen); 83 | memcpy(buf + xlen, y, ylen); 84 | result = sha256(buf, buflen, out, outlen); 85 | 86 | free(buf); 87 | return result; 88 | } 89 | 90 | static void* sha256(const void* data, 91 | const size_t datalen, 92 | void* out, 93 | const size_t outlen) { 94 | size_t sz; 95 | Sha256Context ctx; 96 | SHA256_HASH hash; 97 | 98 | Sha256Initialise(&ctx); 99 | Sha256Update(&ctx, data, datalen); 100 | Sha256Finalise(&ctx, &hash); 101 | 102 | sz = (outlen > SHA256_HASH_SIZE) ? SHA256_HASH_SIZE : outlen; 103 | return memcpy(out, hash.bytes, sz); 104 | } 105 | -------------------------------------------------------------------------------- /x64/auth.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | struct channel_struct 7 | { 8 | std::string author; 9 | std::string message; 10 | std::string timestamp; 11 | }; 12 | 13 | namespace KeyAuth { 14 | class api { 15 | public: 16 | 17 | std::string name, ownerid, version, url, path; 18 | static bool debug; 19 | 20 | api(std::string name, std::string ownerid, std::string version, std::string url, std::string path, bool debugParameter = false) 21 | : name(name), ownerid(ownerid), version(version), url(url), path(path) 22 | { 23 | setDebug(debugParameter); 24 | } 25 | 26 | void ban(std::string reason = ""); 27 | void init(); 28 | void check(bool check_paid = false); 29 | void log(std::string msg); 30 | void license(std::string key, std::string code = ""); 31 | std::string var(std::string varid); 32 | std::string webhook(std::string id, std::string params, std::string body = "", std::string contenttype = ""); 33 | void setvar(std::string var, std::string vardata); 34 | std::string getvar(std::string var); 35 | bool checkblack(); 36 | void web_login(); 37 | void button(std::string value); 38 | void upgrade(std::string username, std::string key); 39 | void login(std::string username, std::string password, std::string code = ""); 40 | std::vector download(std::string fileid); 41 | void regstr(std::string username, std::string password, std::string key, std::string email = ""); 42 | void chatget(std::string channel); 43 | bool chatsend(std::string message, std::string channel); 44 | void changeUsername(std::string newusername); 45 | std::string fetchonline(); 46 | void fetchstats(); 47 | void forgot(std::string username, std::string email); 48 | void logout(); 49 | 50 | class subscriptions_class { 51 | public: 52 | std::string name; 53 | std::string expiry; 54 | }; 55 | 56 | class userdata { 57 | public: 58 | 59 | // user data 60 | std::string username; 61 | std::string ip; 62 | std::string hwid; 63 | std::string createdate; 64 | std::string lastlogin; 65 | 66 | std::vector subscriptions; 67 | }; 68 | 69 | class appdata { 70 | public: 71 | // app data 72 | std::string numUsers; 73 | std::string numOnlineUsers; 74 | std::string numKeys; 75 | std::string version; 76 | std::string customerPanelLink; 77 | std::string downloadLink; 78 | }; 79 | 80 | class responsedata { 81 | public: 82 | // response data 83 | std::vector channeldata; 84 | bool success{}; 85 | std::string message; 86 | bool isPaid{}; 87 | }; 88 | 89 | bool activate = false; 90 | class Tfa { 91 | public: 92 | std::string secret; 93 | std::string link; 94 | Tfa& handleInput(KeyAuth::api& apiInstance); 95 | private: 96 | void QrCode(); 97 | }; 98 | 99 | Tfa& enable2fa(std::string code = ""); 100 | Tfa& disable2fa(std::string code = ""); 101 | 102 | userdata user_data; 103 | appdata app_data; 104 | responsedata response; 105 | Tfa tfa; 106 | 107 | private: 108 | std::string sessionid, enckey; 109 | static void setDebug(bool value); 110 | }; 111 | } 112 | -------------------------------------------------------------------------------- /x86/lib/curl/curlver.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_CURLVER_H 2 | #define CURLINC_CURLVER_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2020, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | /* This header file contains nothing but libcurl version info, generated by 26 | a script at release-time. This was made its own header file in 7.11.2 */ 27 | 28 | /* This is the global package copyright */ 29 | #define LIBCURL_COPYRIGHT "1996 - 2020 Daniel Stenberg, ." 30 | 31 | /* This is the version number of the libcurl package from which this header 32 | file origins: */ 33 | #define LIBCURL_VERSION "7.71.1" 34 | 35 | /* The numeric version number is also available "in parts" by using these 36 | defines: */ 37 | #define LIBCURL_VERSION_MAJOR 7 38 | #define LIBCURL_VERSION_MINOR 71 39 | #define LIBCURL_VERSION_PATCH 1 40 | 41 | /* This is the numeric version of the libcurl version number, meant for easier 42 | parsing and comparisons by programs. The LIBCURL_VERSION_NUM define will 43 | always follow this syntax: 44 | 45 | 0xXXYYZZ 46 | 47 | Where XX, YY and ZZ are the main version, release and patch numbers in 48 | hexadecimal (using 8 bits each). All three numbers are always represented 49 | using two digits. 1.2 would appear as "0x010200" while version 9.11.7 50 | appears as "0x090b07". 51 | 52 | This 6-digit (24 bits) hexadecimal number does not show pre-release number, 53 | and it is always a greater number in a more recent release. It makes 54 | comparisons with greater than and less than work. 55 | 56 | Note: This define is the full hex number and _does not_ use the 57 | CURL_VERSION_BITS() macro since curl's own configure script greps for it 58 | and needs it to contain the full number. 59 | */ 60 | #define LIBCURL_VERSION_NUM 0x074701 61 | 62 | /* 63 | * This is the date and time when the full source package was created. The 64 | * timestamp is not stored in git, as the timestamp is properly set in the 65 | * tarballs by the maketgz script. 66 | * 67 | * The format of the date follows this template: 68 | * 69 | * "2007-11-23" 70 | */ 71 | #define LIBCURL_TIMESTAMP "2020-07-01" 72 | 73 | #define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z)) 74 | #define CURL_AT_LEAST_VERSION(x,y,z) \ 75 | (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) 76 | 77 | #endif /* CURLINC_CURLVER_H */ 78 | -------------------------------------------------------------------------------- /x86/lib/Security.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | // code submitted in pull request from https://github.com/sbtoonz, authored by KeePassXC https://github.com/keepassxreboot/keepassxc/blob/dab7047113c4ad4ffead944d5c4ebfb648c1d0b0/src/core/Bootstrap.cpp#L121 9 | inline bool LockMemAccess() 10 | { 11 | bool bSuccess = false; 12 | // Process token and user 13 | HANDLE hToken = nullptr; 14 | PTOKEN_USER pTokenUser = nullptr; 15 | DWORD cbBufferSize = 0; 16 | 17 | // Access control list 18 | PACL pACL = nullptr; 19 | DWORD cbACL = 0; 20 | 21 | // Open the access token associated with the calling process 22 | if (!OpenProcessToken( 23 | GetCurrentProcess(), 24 | TOKEN_QUERY, 25 | &hToken 26 | )) { 27 | goto Cleanup; 28 | } 29 | 30 | // Retrieve the token information in a TOKEN_USER structure 31 | GetTokenInformation( 32 | hToken, 33 | TokenUser, // request for a TOKEN_USER structure 34 | nullptr, 35 | 0, 36 | &cbBufferSize 37 | ); 38 | 39 | pTokenUser = static_cast(malloc(cbBufferSize)); 40 | if (pTokenUser == nullptr) { 41 | goto Cleanup; 42 | } 43 | 44 | if (!GetTokenInformation( 45 | hToken, 46 | TokenUser, 47 | pTokenUser, 48 | cbBufferSize, 49 | &cbBufferSize 50 | )) { 51 | goto Cleanup; 52 | } 53 | 54 | if (!IsValidSid(pTokenUser->User.Sid)) { 55 | goto Cleanup; 56 | } 57 | 58 | // Calculate the amount of memory that must be allocated for the DACL 59 | cbACL = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(pTokenUser->User.Sid); 60 | 61 | // Create and initialize an ACL 62 | pACL = static_cast(malloc(cbACL)); 63 | if (pACL == nullptr) { 64 | goto Cleanup; 65 | } 66 | 67 | if (!InitializeAcl(pACL, cbACL, ACL_REVISION)) { 68 | goto Cleanup; 69 | } 70 | 71 | // Add allowed access control entries, everything else is denied 72 | if (!AddAccessAllowedAce( 73 | pACL, 74 | ACL_REVISION, 75 | SYNCHRONIZE | PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_TERMINATE, // same as protected process 76 | pTokenUser->User.Sid // pointer to the trustee's SID 77 | )) { 78 | goto Cleanup; 79 | } 80 | 81 | // Set discretionary access control list 82 | bSuccess = ERROR_SUCCESS == SetSecurityInfo( 83 | GetCurrentProcess(), // object handle 84 | SE_KERNEL_OBJECT, // type of object 85 | DACL_SECURITY_INFORMATION, // change only the objects DACL 86 | nullptr, nullptr, // do not change owner or group 87 | pACL, // DACL specified 88 | nullptr // do not change SACL 89 | ); 90 | 91 | Cleanup: 92 | 93 | if (pACL != nullptr) { 94 | free(pACL); 95 | 96 | } 97 | if (pTokenUser != nullptr) { 98 | free(pTokenUser); 99 | 100 | } 101 | if (hToken != nullptr) { 102 | CloseHandle(hToken); 103 | 104 | } 105 | return bSuccess; 106 | } -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/value_t.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // array 4 | #include // size_t 5 | #include // uint8_t 6 | #include // string 7 | 8 | namespace nlohmann 9 | { 10 | namespace detail 11 | { 12 | /////////////////////////// 13 | // JSON type enumeration // 14 | /////////////////////////// 15 | 16 | /*! 17 | @brief the JSON type enumeration 18 | 19 | This enumeration collects the different JSON types. It is internally used to 20 | distinguish the stored values, and the functions @ref basic_json::is_null(), 21 | @ref basic_json::is_object(), @ref basic_json::is_array(), 22 | @ref basic_json::is_string(), @ref basic_json::is_boolean(), 23 | @ref basic_json::is_number() (with @ref basic_json::is_number_integer(), 24 | @ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()), 25 | @ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and 26 | @ref basic_json::is_structured() rely on it. 27 | 28 | @note There are three enumeration entries (number_integer, number_unsigned, and 29 | number_float), because the library distinguishes these three types for numbers: 30 | @ref basic_json::number_unsigned_t is used for unsigned integers, 31 | @ref basic_json::number_integer_t is used for signed integers, and 32 | @ref basic_json::number_float_t is used for floating-point numbers or to 33 | approximate integers which do not fit in the limits of their respective type. 34 | 35 | @sa @ref basic_json::basic_json(const value_t value_type) -- create a JSON 36 | value with the default value for a given type 37 | 38 | @since version 1.0.0 39 | */ 40 | enum class value_t : std::uint8_t 41 | { 42 | null, ///< null value 43 | object, ///< object (unordered set of name/value pairs) 44 | array, ///< array (ordered collection of values) 45 | string, ///< string value 46 | boolean, ///< boolean value 47 | number_integer, ///< number value (signed integer) 48 | number_unsigned, ///< number value (unsigned integer) 49 | number_float, ///< number value (floating-point) 50 | binary, ///< binary array (ordered collection of bytes) 51 | discarded ///< discarded by the parser callback function 52 | }; 53 | 54 | /*! 55 | @brief comparison operator for JSON types 56 | 57 | Returns an ordering that is similar to Python: 58 | - order: null < boolean < number < object < array < string < binary 59 | - furthermore, each type is not smaller than itself 60 | - discarded values are not comparable 61 | - binary is represented as a b"" string in python and directly comparable to a 62 | string; however, making a binary array directly comparable with a string would 63 | be surprising behavior in a JSON file. 64 | 65 | @since version 1.0.0 66 | */ 67 | inline bool operator<(const value_t lhs, const value_t rhs) noexcept 68 | { 69 | static constexpr std::array order = {{ 70 | 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, 71 | 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, 72 | 6 /* binary */ 73 | } 74 | }; 75 | 76 | const auto l_index = static_cast(lhs); 77 | const auto r_index = static_cast(rhs); 78 | return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index]; 79 | } 80 | } // namespace detail 81 | } // namespace nlohmann 82 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/iterators/primitive_iterator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // ptrdiff_t 4 | #include // numeric_limits 5 | 6 | namespace nlohmann 7 | { 8 | namespace detail 9 | { 10 | /* 11 | @brief an iterator for primitive JSON types 12 | 13 | This class models an iterator for primitive JSON types (boolean, number, 14 | string). It's only purpose is to allow the iterator/const_iterator classes 15 | to "iterate" over primitive values. Internally, the iterator is modeled by 16 | a `difference_type` variable. Value begin_value (`0`) models the begin, 17 | end_value (`1`) models past the end. 18 | */ 19 | class primitive_iterator_t 20 | { 21 | private: 22 | using difference_type = std::ptrdiff_t; 23 | static constexpr difference_type begin_value = 0; 24 | static constexpr difference_type end_value = begin_value + 1; 25 | 26 | /// iterator as signed integer type 27 | difference_type m_it = (std::numeric_limits::min)(); 28 | 29 | public: 30 | constexpr difference_type get_value() const noexcept 31 | { 32 | return m_it; 33 | } 34 | 35 | /// set iterator to a defined beginning 36 | void set_begin() noexcept 37 | { 38 | m_it = begin_value; 39 | } 40 | 41 | /// set iterator to a defined past the end 42 | void set_end() noexcept 43 | { 44 | m_it = end_value; 45 | } 46 | 47 | /// return whether the iterator can be dereferenced 48 | constexpr bool is_begin() const noexcept 49 | { 50 | return m_it == begin_value; 51 | } 52 | 53 | /// return whether the iterator is at end 54 | constexpr bool is_end() const noexcept 55 | { 56 | return m_it == end_value; 57 | } 58 | 59 | friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept 60 | { 61 | return lhs.m_it == rhs.m_it; 62 | } 63 | 64 | friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept 65 | { 66 | return lhs.m_it < rhs.m_it; 67 | } 68 | 69 | primitive_iterator_t operator+(difference_type n) noexcept 70 | { 71 | auto result = *this; 72 | result += n; 73 | return result; 74 | } 75 | 76 | friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept 77 | { 78 | return lhs.m_it - rhs.m_it; 79 | } 80 | 81 | primitive_iterator_t& operator++() noexcept 82 | { 83 | ++m_it; 84 | return *this; 85 | } 86 | 87 | primitive_iterator_t const operator++(int) noexcept 88 | { 89 | auto result = *this; 90 | ++m_it; 91 | return result; 92 | } 93 | 94 | primitive_iterator_t& operator--() noexcept 95 | { 96 | --m_it; 97 | return *this; 98 | } 99 | 100 | primitive_iterator_t const operator--(int) noexcept 101 | { 102 | auto result = *this; 103 | --m_it; 104 | return result; 105 | } 106 | 107 | primitive_iterator_t& operator+=(difference_type n) noexcept 108 | { 109 | m_it += n; 110 | return *this; 111 | } 112 | 113 | primitive_iterator_t& operator-=(difference_type n) noexcept 114 | { 115 | m_it -= n; 116 | return *this; 117 | } 118 | }; 119 | } // namespace detail 120 | } // namespace nlohmann 121 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/output/output_adapters.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // copy 4 | #include // size_t 5 | #include // streamsize 6 | #include // back_inserter 7 | #include // shared_ptr, make_shared 8 | #include // basic_ostream 9 | #include // basic_string 10 | #include // vector 11 | #include 12 | 13 | namespace nlohmann 14 | { 15 | namespace detail 16 | { 17 | /// abstract output adapter interface 18 | template struct output_adapter_protocol 19 | { 20 | virtual void write_character(CharType c) = 0; 21 | virtual void write_characters(const CharType* s, std::size_t length) = 0; 22 | virtual ~output_adapter_protocol() = default; 23 | }; 24 | 25 | /// a type to simplify interfaces 26 | template 27 | using output_adapter_t = std::shared_ptr>; 28 | 29 | /// output adapter for byte vectors 30 | template 31 | class output_vector_adapter : public output_adapter_protocol 32 | { 33 | public: 34 | explicit output_vector_adapter(std::vector& vec) noexcept 35 | : v(vec) 36 | {} 37 | 38 | void write_character(CharType c) override 39 | { 40 | v.push_back(c); 41 | } 42 | 43 | JSON_HEDLEY_NON_NULL(2) 44 | void write_characters(const CharType* s, std::size_t length) override 45 | { 46 | std::copy(s, s + length, std::back_inserter(v)); 47 | } 48 | 49 | private: 50 | std::vector& v; 51 | }; 52 | 53 | /// output adapter for output streams 54 | template 55 | class output_stream_adapter : public output_adapter_protocol 56 | { 57 | public: 58 | explicit output_stream_adapter(std::basic_ostream& s) noexcept 59 | : stream(s) 60 | {} 61 | 62 | void write_character(CharType c) override 63 | { 64 | stream.put(c); 65 | } 66 | 67 | JSON_HEDLEY_NON_NULL(2) 68 | void write_characters(const CharType* s, std::size_t length) override 69 | { 70 | stream.write(s, static_cast(length)); 71 | } 72 | 73 | private: 74 | std::basic_ostream& stream; 75 | }; 76 | 77 | /// output adapter for basic_string 78 | template> 79 | class output_string_adapter : public output_adapter_protocol 80 | { 81 | public: 82 | explicit output_string_adapter(StringType& s) noexcept 83 | : str(s) 84 | {} 85 | 86 | void write_character(CharType c) override 87 | { 88 | str.push_back(c); 89 | } 90 | 91 | JSON_HEDLEY_NON_NULL(2) 92 | void write_characters(const CharType* s, std::size_t length) override 93 | { 94 | str.append(s, length); 95 | } 96 | 97 | private: 98 | StringType& str; 99 | }; 100 | 101 | template> 102 | class output_adapter 103 | { 104 | public: 105 | output_adapter(std::vector& vec) 106 | : oa(std::make_shared>(vec)) {} 107 | 108 | output_adapter(std::basic_ostream& s) 109 | : oa(std::make_shared>(s)) {} 110 | 111 | output_adapter(StringType& s) 112 | : oa(std::make_shared>(s)) {} 113 | 114 | operator output_adapter_t() 115 | { 116 | return oa; 117 | } 118 | 119 | private: 120 | output_adapter_t oa = nullptr; 121 | }; 122 | } // namespace detail 123 | } // namespace nlohmann 124 | -------------------------------------------------------------------------------- /x86/lib/sha256.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // WjCryptLib_Sha256 3 | // 4 | // Implementation of SHA256 hash function. 5 | // Original author: Tom St Denis, tomstdenis@gmail.com, http://libtom.org 6 | // Modified by WaterJuice retaining Public Domain license. 7 | // 8 | // This is free and unencumbered software released into the public domain - 9 | // June 2013 waterjuice.org 10 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | #pragma once 13 | 14 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 15 | // IMPORTS 16 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 17 | 18 | #include 19 | #include 20 | 21 | typedef struct { 22 | uint64_t length; 23 | uint32_t state[8]; 24 | uint32_t curlen; 25 | uint8_t buf[64]; 26 | } Sha256Context; 27 | 28 | #define SHA256_HASH_SIZE (256 / 8) 29 | 30 | typedef struct { 31 | uint8_t bytes[SHA256_HASH_SIZE]; 32 | } SHA256_HASH; 33 | 34 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 35 | // PUBLIC FUNCTIONS 36 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 37 | 38 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 39 | // Sha256Initialise 40 | // 41 | // Initialises a SHA256 Context. Use this to initialise/reset a context. 42 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 43 | void Sha256Initialise(Sha256Context* Context // [out] 44 | ); 45 | 46 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 47 | // Sha256Update 48 | // 49 | // Adds data to the SHA256 context. This will process the data and update the 50 | // internal state of the context. Keep on calling this function until all the 51 | // data has been added. Then call Sha256Finalise to calculate the hash. 52 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 53 | void Sha256Update(Sha256Context* Context, // [in out] 54 | void const* Buffer, // [in] 55 | uint32_t BufferSize // [in] 56 | ); 57 | 58 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 59 | // Sha256Finalise 60 | // 61 | // Performs the final calculation of the hash and returns the digest (32 byte 62 | // buffer containing 256bit hash). After calling this, Sha256Initialised must 63 | // be used to reuse the context. 64 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 65 | void Sha256Finalise(Sha256Context* Context, // [in out] 66 | SHA256_HASH* Digest // [out] 67 | ); 68 | 69 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 70 | // Sha256Calculate 71 | // 72 | // Combines Sha256Initialise, Sha256Update, and Sha256Finalise into one 73 | // function. Calculates the SHA256 hash of the buffer. 74 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 75 | void Sha256Calculate(void const* Buffer, // [in] 76 | uint32_t BufferSize, // [in] 77 | SHA256_HASH* Digest // [in] 78 | ); 79 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/hash.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // size_t, uint8_t 4 | #include // hash 5 | 6 | namespace nlohmann 7 | { 8 | namespace detail 9 | { 10 | 11 | // boost::hash_combine 12 | inline std::size_t combine(std::size_t seed, std::size_t h) noexcept 13 | { 14 | seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U); 15 | return seed; 16 | } 17 | 18 | /*! 19 | @brief hash a JSON value 20 | 21 | The hash function tries to rely on std::hash where possible. Furthermore, the 22 | type of the JSON value is taken into account to have different hash values for 23 | null, 0, 0U, and false, etc. 24 | 25 | @tparam BasicJsonType basic_json specialization 26 | @param j JSON value to hash 27 | @return hash value of j 28 | */ 29 | template 30 | std::size_t hash(const BasicJsonType& j) 31 | { 32 | using string_t = typename BasicJsonType::string_t; 33 | using number_integer_t = typename BasicJsonType::number_integer_t; 34 | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; 35 | using number_float_t = typename BasicJsonType::number_float_t; 36 | 37 | const auto type = static_cast(j.type()); 38 | switch (j.type()) 39 | { 40 | case BasicJsonType::value_t::null: 41 | case BasicJsonType::value_t::discarded: 42 | { 43 | return combine(type, 0); 44 | } 45 | 46 | case BasicJsonType::value_t::object: 47 | { 48 | auto seed = combine(type, j.size()); 49 | for (const auto& element : j.items()) 50 | { 51 | const auto h = std::hash {}(element.key()); 52 | seed = combine(seed, h); 53 | seed = combine(seed, hash(element.value())); 54 | } 55 | return seed; 56 | } 57 | 58 | case BasicJsonType::value_t::array: 59 | { 60 | auto seed = combine(type, j.size()); 61 | for (const auto& element : j) 62 | { 63 | seed = combine(seed, hash(element)); 64 | } 65 | return seed; 66 | } 67 | 68 | case BasicJsonType::value_t::string: 69 | { 70 | const auto h = std::hash {}(j.template get_ref()); 71 | return combine(type, h); 72 | } 73 | 74 | case BasicJsonType::value_t::boolean: 75 | { 76 | const auto h = std::hash {}(j.template get()); 77 | return combine(type, h); 78 | } 79 | 80 | case BasicJsonType::value_t::number_integer: 81 | { 82 | const auto h = std::hash {}(j.template get()); 83 | return combine(type, h); 84 | } 85 | 86 | case nlohmann::detail::value_t::number_unsigned: 87 | { 88 | const auto h = std::hash {}(j.template get()); 89 | return combine(type, h); 90 | } 91 | 92 | case nlohmann::detail::value_t::number_float: 93 | { 94 | const auto h = std::hash {}(j.template get()); 95 | return combine(type, h); 96 | } 97 | 98 | case nlohmann::detail::value_t::binary: 99 | { 100 | auto seed = combine(type, j.get_binary().size()); 101 | const auto h = std::hash {}(j.get_binary().has_subtype()); 102 | seed = combine(seed, h); 103 | seed = combine(seed, j.get_binary().subtype()); 104 | for (const auto byte : j.get_binary()) 105 | { 106 | seed = combine(seed, std::hash {}(byte)); 107 | } 108 | return seed; 109 | } 110 | 111 | default: // LCOV_EXCL_LINE 112 | JSON_ASSERT(false); // LCOV_EXCL_LINE 113 | } 114 | } 115 | 116 | } // namespace detail 117 | } // namespace nlohmann 118 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/iterators/json_reverse_iterator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // ptrdiff_t 4 | #include // reverse_iterator 5 | #include // declval 6 | 7 | namespace nlohmann 8 | { 9 | namespace detail 10 | { 11 | ////////////////////// 12 | // reverse_iterator // 13 | ////////////////////// 14 | 15 | /*! 16 | @brief a template for a reverse iterator class 17 | 18 | @tparam Base the base iterator type to reverse. Valid types are @ref 19 | iterator (to create @ref reverse_iterator) and @ref const_iterator (to 20 | create @ref const_reverse_iterator). 21 | 22 | @requirement The class satisfies the following concept requirements: 23 | - 24 | [BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): 25 | The iterator that can be moved can be moved in both directions (i.e. 26 | incremented and decremented). 27 | - [OutputIterator](https://en.cppreference.com/w/cpp/named_req/OutputIterator): 28 | It is possible to write to the pointed-to element (only if @a Base is 29 | @ref iterator). 30 | 31 | @since version 1.0.0 32 | */ 33 | template 34 | class json_reverse_iterator : public std::reverse_iterator 35 | { 36 | public: 37 | using difference_type = std::ptrdiff_t; 38 | /// shortcut to the reverse iterator adapter 39 | using base_iterator = std::reverse_iterator; 40 | /// the reference type for the pointed-to element 41 | using reference = typename Base::reference; 42 | 43 | /// create reverse iterator from iterator 44 | explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept 45 | : base_iterator(it) {} 46 | 47 | /// create reverse iterator from base class 48 | explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {} 49 | 50 | /// post-increment (it++) 51 | json_reverse_iterator const operator++(int) 52 | { 53 | return static_cast(base_iterator::operator++(1)); 54 | } 55 | 56 | /// pre-increment (++it) 57 | json_reverse_iterator& operator++() 58 | { 59 | return static_cast(base_iterator::operator++()); 60 | } 61 | 62 | /// post-decrement (it--) 63 | json_reverse_iterator const operator--(int) 64 | { 65 | return static_cast(base_iterator::operator--(1)); 66 | } 67 | 68 | /// pre-decrement (--it) 69 | json_reverse_iterator& operator--() 70 | { 71 | return static_cast(base_iterator::operator--()); 72 | } 73 | 74 | /// add to iterator 75 | json_reverse_iterator& operator+=(difference_type i) 76 | { 77 | return static_cast(base_iterator::operator+=(i)); 78 | } 79 | 80 | /// add to iterator 81 | json_reverse_iterator operator+(difference_type i) const 82 | { 83 | return static_cast(base_iterator::operator+(i)); 84 | } 85 | 86 | /// subtract from iterator 87 | json_reverse_iterator operator-(difference_type i) const 88 | { 89 | return static_cast(base_iterator::operator-(i)); 90 | } 91 | 92 | /// return difference 93 | difference_type operator-(const json_reverse_iterator& other) const 94 | { 95 | return base_iterator(*this) - base_iterator(other); 96 | } 97 | 98 | /// access to successor 99 | reference operator[](difference_type n) const 100 | { 101 | return *(this->operator+(n)); 102 | } 103 | 104 | /// return the key of an object iterator 105 | auto key() const -> decltype(std::declval().key()) 106 | { 107 | auto it = --this->base(); 108 | return it.key(); 109 | } 110 | 111 | /// return the value of an iterator 112 | reference value() const 113 | { 114 | auto it = --this->base(); 115 | return it.operator * (); 116 | } 117 | }; 118 | } // namespace detail 119 | } // namespace nlohmann 120 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Elastic License 2.0 2 | 3 | URL: https://www.elastic.co/licensing/elastic-license 4 | 5 | ## Acceptance 6 | 7 | By using the software, you agree to all of the terms and conditions below. 8 | 9 | ## Copyright License 10 | 11 | The licensor grants you a non-exclusive, royalty-free, worldwide, 12 | non-sublicensable, non-transferable license to use, copy, distribute, make 13 | available, and prepare derivative works of the software, in each case subject to 14 | the limitations and conditions below. 15 | 16 | ## Limitations 17 | 18 | You may not provide the software to third parties as a hosted or managed 19 | service, where the service provides users with access to any substantial set of 20 | the features or functionality of the software. 21 | 22 | You may not move, change, disable, or circumvent the license key functionality 23 | in the software, and you may not remove or obscure any functionality in the 24 | software that is protected by the license key. 25 | 26 | You may not alter, remove, or obscure any licensing, copyright, or other notices 27 | of the licensor in the software. Any use of the licensor’s trademarks is subject 28 | to applicable law. 29 | 30 | ## Patents 31 | 32 | The licensor grants you a license, under any patent claims the licensor can 33 | license, or becomes able to license, to make, have made, use, sell, offer for 34 | sale, import and have imported the software, in each case subject to the 35 | limitations and conditions in this license. This license does not cover any 36 | patent claims that you cause to be infringed by modifications or additions to 37 | the software. If you or your company make any written claim that the software 38 | infringes or contributes to infringement of any patent, your patent license for 39 | the software granted under these terms ends immediately. If your company makes 40 | such a claim, your patent license ends immediately for work on behalf of your 41 | company. 42 | 43 | ## Notices 44 | 45 | You must ensure that anyone who gets a copy of any part of the software from you 46 | also gets a copy of these terms. 47 | 48 | If you modify the software, you must include in any modified copies of the 49 | software prominent notices stating that you have modified the software. 50 | 51 | ## No Other Rights 52 | 53 | These terms do not imply any licenses other than those expressly granted in 54 | these terms. 55 | 56 | ## Termination 57 | 58 | If you use the software in violation of these terms, such use is not licensed, 59 | and your licenses will automatically terminate. If the licensor provides you 60 | with a notice of your violation, and you cease all violation of this license no 61 | later than 30 days after you receive that notice, your licenses will be 62 | reinstated retroactively. However, if you violate these terms after such 63 | reinstatement, any additional violation of these terms will cause your licenses 64 | to terminate automatically and permanently. 65 | 66 | ## No Liability 67 | 68 | *As far as the law allows, the software comes as is, without any warranty or 69 | condition, and the licensor will not be liable to you for any damages arising 70 | out of these terms or the use or nature of the software, under any kind of 71 | legal claim.* 72 | 73 | ## Definitions 74 | 75 | The **licensor** is the entity offering these terms, and the **software** is the 76 | software the licensor makes available under these terms, including any portion 77 | of it. 78 | 79 | **you** refers to the individual or entity agreeing to these terms. 80 | 81 | **your company** is any legal entity, sole proprietorship, or other kind of 82 | organization that you work for, plus all organizations that have control over, 83 | are under the control of, or are under common control with that 84 | organization. **control** means ownership of substantially all the assets of an 85 | entity, or the power to direct its management and policies by vote, contract, or 86 | otherwise. Control can be direct or indirect. 87 | 88 | **your licenses** are all the licenses granted to you for the software under 89 | these terms. 90 | 91 | **use** means anything you do with the software requiring one of your licenses. 92 | 93 | **trademark** means trademarks, service marks, and similar rights. 94 | -------------------------------------------------------------------------------- /x86/lib/curl/easy.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_EASY_H 2 | #define CURLINC_EASY_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2020, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Flag bits in the curl_blob struct: */ 29 | #define CURL_BLOB_COPY 1 /* tell libcurl to copy the data */ 30 | #define CURL_BLOB_NOCOPY 0 /* tell libcurl to NOT copy the data */ 31 | 32 | struct curl_blob { 33 | void *data; 34 | size_t len; 35 | unsigned int flags; /* bit 0 is defined, the rest are reserved and should be 36 | left zeroes */ 37 | }; 38 | 39 | CURL_EXTERN CURL *curl_easy_init(void); 40 | CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...); 41 | CURL_EXTERN CURLcode curl_easy_perform(CURL *curl); 42 | CURL_EXTERN void curl_easy_cleanup(CURL *curl); 43 | 44 | /* 45 | * NAME curl_easy_getinfo() 46 | * 47 | * DESCRIPTION 48 | * 49 | * Request internal information from the curl session with this function. The 50 | * third argument MUST be a pointer to a long, a pointer to a char * or a 51 | * pointer to a double (as the documentation describes elsewhere). The data 52 | * pointed to will be filled in accordingly and can be relied upon only if the 53 | * function returns CURLE_OK. This function is intended to get used *AFTER* a 54 | * performed transfer, all results from this function are undefined until the 55 | * transfer is completed. 56 | */ 57 | CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...); 58 | 59 | 60 | /* 61 | * NAME curl_easy_duphandle() 62 | * 63 | * DESCRIPTION 64 | * 65 | * Creates a new curl session handle with the same options set for the handle 66 | * passed in. Duplicating a handle could only be a matter of cloning data and 67 | * options, internal state info and things like persistent connections cannot 68 | * be transferred. It is useful in multithreaded applications when you can run 69 | * curl_easy_duphandle() for each new thread to avoid a series of identical 70 | * curl_easy_setopt() invokes in every thread. 71 | */ 72 | CURL_EXTERN CURL *curl_easy_duphandle(CURL *curl); 73 | 74 | /* 75 | * NAME curl_easy_reset() 76 | * 77 | * DESCRIPTION 78 | * 79 | * Re-initializes a CURL handle to the default values. This puts back the 80 | * handle to the same state as it was in when it was just created. 81 | * 82 | * It does keep: live connections, the Session ID cache, the DNS cache and the 83 | * cookies. 84 | */ 85 | CURL_EXTERN void curl_easy_reset(CURL *curl); 86 | 87 | /* 88 | * NAME curl_easy_recv() 89 | * 90 | * DESCRIPTION 91 | * 92 | * Receives data from the connected socket. Use after successful 93 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. 94 | */ 95 | CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, 96 | size_t *n); 97 | 98 | /* 99 | * NAME curl_easy_send() 100 | * 101 | * DESCRIPTION 102 | * 103 | * Sends data over the connected socket. Use after successful 104 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. 105 | */ 106 | CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer, 107 | size_t buflen, size_t *n); 108 | 109 | 110 | /* 111 | * NAME curl_easy_upkeep() 112 | * 113 | * DESCRIPTION 114 | * 115 | * Performs connection upkeep for the given session handle. 116 | */ 117 | CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl); 118 | 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /x64/skStr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /*____________________________________________________________________________________________________________ 4 | 5 | Original Author: skadro 6 | Github: https://github.com/skadro-official 7 | License: See end of file 8 | 9 | skCrypter 10 | Compile-time, Usermode + Kernelmode, safe and lightweight string crypter library for C++11+ 11 | 12 | *Not removing this part is appreciated* 13 | ____________________________________________________________________________________________________________*/ 14 | 15 | #ifdef _KERNEL_MODE 16 | namespace std 17 | { 18 | // STRUCT TEMPLATE remove_reference 19 | template 20 | struct remove_reference { 21 | using type = _Ty; 22 | }; 23 | 24 | template 25 | struct remove_reference<_Ty&> { 26 | using type = _Ty; 27 | }; 28 | 29 | template 30 | struct remove_reference<_Ty&&> { 31 | using type = _Ty; 32 | }; 33 | 34 | template 35 | using remove_reference_t = typename remove_reference<_Ty>::type; 36 | 37 | // STRUCT TEMPLATE remove_const 38 | template 39 | struct remove_const { // remove top-level const qualifier 40 | using type = _Ty; 41 | }; 42 | 43 | template 44 | struct remove_const { 45 | using type = _Ty; 46 | }; 47 | 48 | template 49 | using remove_const_t = typename remove_const<_Ty>::type; 50 | } 51 | #else 52 | #include 53 | #endif 54 | 55 | namespace skc 56 | { 57 | template 58 | using clean_type = typename std::remove_const_t>; 59 | 60 | template 61 | class skCrypter 62 | { 63 | public: 64 | __forceinline constexpr skCrypter(T* data) 65 | { 66 | crypt(data); 67 | } 68 | 69 | __forceinline T* get() 70 | { 71 | return _storage; 72 | } 73 | 74 | __forceinline int size() // (w)char count 75 | { 76 | return _size; 77 | } 78 | 79 | __forceinline char key() 80 | { 81 | return _key1; 82 | } 83 | 84 | __forceinline T* encrypt() 85 | { 86 | if (!isEncrypted()) 87 | crypt(_storage); 88 | 89 | return _storage; 90 | } 91 | 92 | __forceinline T* decrypt() 93 | { 94 | if (isEncrypted()) 95 | crypt(_storage); 96 | 97 | return _storage; 98 | } 99 | 100 | __forceinline bool isEncrypted() 101 | { 102 | return _storage[_size - 1] != 0; 103 | } 104 | 105 | __forceinline void clear() // set full storage to 0 106 | { 107 | for (int i = 0; i < _size; i++) 108 | { 109 | _storage[i] = 0; 110 | } 111 | } 112 | 113 | __forceinline operator T* () 114 | { 115 | decrypt(); 116 | 117 | return _storage; 118 | } 119 | 120 | private: 121 | __forceinline constexpr void crypt(T* data) 122 | { 123 | for (int i = 0; i < _size; i++) 124 | { 125 | _storage[i] = data[i] ^ (_key1 + i % (1 + _key2)); 126 | } 127 | } 128 | 129 | T _storage[_size]{}; 130 | }; 131 | } 132 | 133 | #define skCrypt(str) skCrypt_key(str, __TIME__[4], __TIME__[7]) 134 | #define skCrypt_key(str, key1, key2) []() { \ 135 | constexpr static auto crypted = skc::skCrypter \ 136 | >((skc::clean_type*)str); \ 137 | return crypted; }() 138 | 139 | /*________________________________________________________________________________ 140 | 141 | MIT License 142 | 143 | Copyright (c) 2020 skadro 144 | 145 | Permission is hereby granted, free of charge, to any person obtaining a copy 146 | of this software and associated documentation files (the "Software"), to deal 147 | in the Software without restriction, including without limitation the rights 148 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 149 | copies of the Software, and to permit persons to whom the Software is 150 | furnished to do so, subject to the following conditions: 151 | 152 | The above copyright notice and this permission notice shall be included in all 153 | copies or substantial portions of the Software. 154 | 155 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 156 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 157 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 158 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 159 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 160 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 161 | SOFTWARE. 162 | 163 | ________________________________________________________________________________*/ -------------------------------------------------------------------------------- /x86/skStr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /*____________________________________________________________________________________________________________ 4 | 5 | Original Author: skadro 6 | Github: https://github.com/skadro-official 7 | License: See end of file 8 | 9 | skCrypter 10 | Compile-time, Usermode + Kernelmode, safe and lightweight string crypter library for C++11+ 11 | 12 | *Not removing this part is appreciated* 13 | ____________________________________________________________________________________________________________*/ 14 | 15 | #ifdef _KERNEL_MODE 16 | namespace std 17 | { 18 | // STRUCT TEMPLATE remove_reference 19 | template 20 | struct remove_reference { 21 | using type = _Ty; 22 | }; 23 | 24 | template 25 | struct remove_reference<_Ty&> { 26 | using type = _Ty; 27 | }; 28 | 29 | template 30 | struct remove_reference<_Ty&&> { 31 | using type = _Ty; 32 | }; 33 | 34 | template 35 | using remove_reference_t = typename remove_reference<_Ty>::type; 36 | 37 | // STRUCT TEMPLATE remove_const 38 | template 39 | struct remove_const { // remove top-level const qualifier 40 | using type = _Ty; 41 | }; 42 | 43 | template 44 | struct remove_const { 45 | using type = _Ty; 46 | }; 47 | 48 | template 49 | using remove_const_t = typename remove_const<_Ty>::type; 50 | } 51 | #else 52 | #include 53 | #endif 54 | 55 | namespace skc 56 | { 57 | template 58 | using clean_type = typename std::remove_const_t>; 59 | 60 | template 61 | class skCrypter 62 | { 63 | public: 64 | __forceinline constexpr skCrypter(T* data) 65 | { 66 | crypt(data); 67 | } 68 | 69 | __forceinline T* get() 70 | { 71 | return _storage; 72 | } 73 | 74 | __forceinline int size() // (w)char count 75 | { 76 | return _size; 77 | } 78 | 79 | __forceinline char key() 80 | { 81 | return _key1; 82 | } 83 | 84 | __forceinline T* encrypt() 85 | { 86 | if (!isEncrypted()) 87 | crypt(_storage); 88 | 89 | return _storage; 90 | } 91 | 92 | __forceinline T* decrypt() 93 | { 94 | if (isEncrypted()) 95 | crypt(_storage); 96 | 97 | return _storage; 98 | } 99 | 100 | __forceinline bool isEncrypted() 101 | { 102 | return _storage[_size - 1] != 0; 103 | } 104 | 105 | __forceinline void clear() // set full storage to 0 106 | { 107 | for (int i = 0; i < _size; i++) 108 | { 109 | _storage[i] = 0; 110 | } 111 | } 112 | 113 | __forceinline operator T* () 114 | { 115 | decrypt(); 116 | 117 | return _storage; 118 | } 119 | 120 | private: 121 | __forceinline constexpr void crypt(T* data) 122 | { 123 | for (int i = 0; i < _size; i++) 124 | { 125 | _storage[i] = data[i] ^ (_key1 + i % (1 + _key2)); 126 | } 127 | } 128 | 129 | T _storage[_size]{}; 130 | }; 131 | } 132 | 133 | #define skCrypt(str) skCrypt_key(str, __TIME__[4], __TIME__[7]) 134 | #define skCrypt_key(str, key1, key2) []() { \ 135 | constexpr static auto crypted = skc::skCrypter \ 136 | >((skc::clean_type*)str); \ 137 | return crypted; }() 138 | 139 | /*________________________________________________________________________________ 140 | 141 | MIT License 142 | 143 | Copyright (c) 2020 skadro 144 | 145 | Permission is hereby granted, free of charge, to any person obtaining a copy 146 | of this software and associated documentation files (the "Software"), to deal 147 | in the Software without restriction, including without limitation the rights 148 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 149 | copies of the Software, and to permit persons to whom the Software is 150 | furnished to do so, subject to the following conditions: 151 | 152 | The above copyright notice and this permission notice shall be included in all 153 | copies or substantial portions of the Software. 154 | 155 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 156 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 157 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 158 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 159 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 160 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 161 | SOFTWARE. 162 | 163 | ________________________________________________________________________________*/ -------------------------------------------------------------------------------- /x86/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "utils.hpp" 5 | #include "skStr.h" 6 | std::string tm_to_readable_time(tm ctx); 7 | static std::time_t string_to_timet(std::string timestamp); 8 | static std::tm timet_to_tm(time_t timestamp); 9 | const std::string compilation_date = (std::string)skCrypt(__DATE__); 10 | const std::string compilation_time = (std::string)skCrypt(__TIME__); 11 | 12 | using namespace KeyAuth; 13 | 14 | std::string name = skCrypt("name").decrypt(); 15 | std::string ownerid = skCrypt("ownerid").decrypt(); 16 | std::string secret = skCrypt("secret").decrypt(); 17 | std::string version = skCrypt("1.0").decrypt(); 18 | std::string url = skCrypt("https://keyauth.win/api/1.2/").decrypt(); // change if you're self-hosting 19 | std::string path = skCrypt("").decrypt(); //optional, set a path if you're using the token validation setting 20 | 21 | api KeyAuthApp(name, ownerid, secret, version, url, path); 22 | 23 | int main() 24 | { 25 | // Freeing memory to prevent memory leak or memory scraping 26 | name.clear(); ownerid.clear(); secret.clear(); version.clear(); url.clear(); 27 | 28 | std::string consoleTitle = skCrypt("Loader - Built at: ").decrypt() + compilation_date + " " + compilation_time; 29 | SetConsoleTitleA(consoleTitle.c_str()); 30 | std::cout << skCrypt("\n\n Connecting.."); 31 | KeyAuthApp.init(); 32 | if (!KeyAuthApp.response.success) 33 | { 34 | std::cout << skCrypt("\n Status: ") << KeyAuthApp.response.message; 35 | Sleep(1500); 36 | exit(1); 37 | } 38 | 39 | std::cout << skCrypt("\n\n [1] Login\n [2] Register\n [3] Upgrade\n [4] License key only\n\n Choose option: "); 40 | 41 | int option; 42 | std::string username; 43 | std::string password; 44 | std::string key; 45 | 46 | std::cin >> option; 47 | switch (option) 48 | { 49 | case 1: 50 | std::cout << skCrypt("\n\n Enter username: "); 51 | std::cin >> username; 52 | std::cout << skCrypt("\n Enter password: "); 53 | std::cin >> password; 54 | KeyAuthApp.login(username, password); 55 | break; 56 | case 2: 57 | std::cout << skCrypt("\n\n Enter username: "); 58 | std::cin >> username; 59 | std::cout << skCrypt("\n Enter password: "); 60 | std::cin >> password; 61 | std::cout << skCrypt("\n Enter license: "); 62 | std::cin >> key; 63 | KeyAuthApp.regstr(username, password, key); 64 | break; 65 | case 3: 66 | std::cout << skCrypt("\n\n Enter username: "); 67 | std::cin >> username; 68 | std::cout << skCrypt("\n Enter license: "); 69 | std::cin >> key; 70 | KeyAuthApp.upgrade(username, key); 71 | break; 72 | case 4: 73 | std::cout << skCrypt("\n Enter license: "); 74 | std::cin >> key; 75 | KeyAuthApp.license(key); 76 | break; 77 | default: 78 | std::cout << skCrypt("\n\n Status: Failure: Invalid Selection"); 79 | Sleep(3000); 80 | exit(1); 81 | } 82 | 83 | if (!KeyAuthApp.response.success) 84 | { 85 | std::cout << skCrypt("\n Status: ") << KeyAuthApp.response.message; 86 | Sleep(1500); 87 | exit(1); 88 | } 89 | 90 | std::cout << skCrypt("\n User data:"); 91 | std::cout << skCrypt("\n Username: ") << KeyAuthApp.user_data.username; 92 | std::cout << skCrypt("\n IP address: ") << KeyAuthApp.user_data.ip; 93 | std::cout << skCrypt("\n Hardware-Id: ") << KeyAuthApp.user_data.hwid; 94 | std::cout << skCrypt("\n Create date: ") << tm_to_readable_time(timet_to_tm(string_to_timet(KeyAuthApp.user_data.createdate))); 95 | std::cout << skCrypt("\n Last login: ") << tm_to_readable_time(timet_to_tm(string_to_timet(KeyAuthApp.user_data.lastlogin))); 96 | std::cout << skCrypt("\n Subscription(s): "); 97 | 98 | for (int i = 0; i < KeyAuthApp.user_data.subscriptions.size(); i++) { 99 | auto sub = KeyAuthApp.user_data.subscriptions.at(i); 100 | std::cout << skCrypt("\n name: ") << sub.name; 101 | std::cout << skCrypt(" : expiry: ") << tm_to_readable_time(timet_to_tm(string_to_timet(sub.expiry))); 102 | } 103 | 104 | std::cout << skCrypt("\n\n Closing in five seconds..."); 105 | Sleep(5000); 106 | 107 | return 0; 108 | } 109 | 110 | std::string tm_to_readable_time(tm ctx) { 111 | char buffer[80]; 112 | 113 | strftime(buffer, sizeof(buffer), "%a %m/%d/%y %H:%M:%S %Z", &ctx); 114 | 115 | return std::string(buffer); 116 | } 117 | 118 | static std::time_t string_to_timet(std::string timestamp) { 119 | auto cv = strtol(timestamp.c_str(), NULL, 10); // long 120 | 121 | return (time_t)cv; 122 | } 123 | 124 | static std::tm timet_to_tm(time_t timestamp) { 125 | std::tm context; 126 | 127 | localtime_s(&context, ×tamp); 128 | 129 | return context; 130 | } 131 | -------------------------------------------------------------------------------- /x86/lib/curl/urlapi.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_URLAPI_H 2 | #define CURLINC_URLAPI_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 2018 - 2019, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | #include "curl.h" 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* the error codes for the URL API */ 32 | typedef enum { 33 | CURLUE_OK, 34 | CURLUE_BAD_HANDLE, /* 1 */ 35 | CURLUE_BAD_PARTPOINTER, /* 2 */ 36 | CURLUE_MALFORMED_INPUT, /* 3 */ 37 | CURLUE_BAD_PORT_NUMBER, /* 4 */ 38 | CURLUE_UNSUPPORTED_SCHEME, /* 5 */ 39 | CURLUE_URLDECODE, /* 6 */ 40 | CURLUE_OUT_OF_MEMORY, /* 7 */ 41 | CURLUE_USER_NOT_ALLOWED, /* 8 */ 42 | CURLUE_UNKNOWN_PART, /* 9 */ 43 | CURLUE_NO_SCHEME, /* 10 */ 44 | CURLUE_NO_USER, /* 11 */ 45 | CURLUE_NO_PASSWORD, /* 12 */ 46 | CURLUE_NO_OPTIONS, /* 13 */ 47 | CURLUE_NO_HOST, /* 14 */ 48 | CURLUE_NO_PORT, /* 15 */ 49 | CURLUE_NO_QUERY, /* 16 */ 50 | CURLUE_NO_FRAGMENT /* 17 */ 51 | } CURLUcode; 52 | 53 | typedef enum { 54 | CURLUPART_URL, 55 | CURLUPART_SCHEME, 56 | CURLUPART_USER, 57 | CURLUPART_PASSWORD, 58 | CURLUPART_OPTIONS, 59 | CURLUPART_HOST, 60 | CURLUPART_PORT, 61 | CURLUPART_PATH, 62 | CURLUPART_QUERY, 63 | CURLUPART_FRAGMENT, 64 | CURLUPART_ZONEID /* added in 7.65.0 */ 65 | } CURLUPart; 66 | 67 | #define CURLU_DEFAULT_PORT (1<<0) /* return default port number */ 68 | #define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set, 69 | if the port number matches the 70 | default for the scheme */ 71 | #define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if 72 | missing */ 73 | #define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */ 74 | #define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */ 75 | #define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */ 76 | #define CURLU_URLDECODE (1<<6) /* URL decode on get */ 77 | #define CURLU_URLENCODE (1<<7) /* URL encode on set */ 78 | #define CURLU_APPENDQUERY (1<<8) /* append a form style part */ 79 | #define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */ 80 | #define CURLU_NO_AUTHORITY (1<<10) /* Allow empty authority when the 81 | scheme is unknown. */ 82 | 83 | typedef struct Curl_URL CURLU; 84 | 85 | /* 86 | * curl_url() creates a new CURLU handle and returns a pointer to it. 87 | * Must be freed with curl_url_cleanup(). 88 | */ 89 | CURL_EXTERN CURLU *curl_url(void); 90 | 91 | /* 92 | * curl_url_cleanup() frees the CURLU handle and related resources used for 93 | * the URL parsing. It will not free strings previously returned with the URL 94 | * API. 95 | */ 96 | CURL_EXTERN void curl_url_cleanup(CURLU *handle); 97 | 98 | /* 99 | * curl_url_dup() duplicates a CURLU handle and returns a new copy. The new 100 | * handle must also be freed with curl_url_cleanup(). 101 | */ 102 | CURL_EXTERN CURLU *curl_url_dup(CURLU *in); 103 | 104 | /* 105 | * curl_url_get() extracts a specific part of the URL from a CURLU 106 | * handle. Returns error code. The returned pointer MUST be freed with 107 | * curl_free() afterwards. 108 | */ 109 | CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what, 110 | char **part, unsigned int flags); 111 | 112 | /* 113 | * curl_url_set() sets a specific part of the URL in a CURLU handle. Returns 114 | * error code. The passed in string will be copied. Passing a NULL instead of 115 | * a part string, clears that part. 116 | */ 117 | CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what, 118 | const char *part, unsigned int flags); 119 | 120 | 121 | #ifdef __cplusplus 122 | } /* end of extern "C" */ 123 | #endif 124 | 125 | #endif /* CURLINC_URLAPI_H */ 126 | -------------------------------------------------------------------------------- /x86/lib/auth.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #pragma comment(lib, "libcurl.lib") 4 | 5 | #if defined(__x86_64__) || defined(_M_X64) 6 | #pragma comment(lib, "libcurl.lib") 7 | #elif defined(__i386) || defined(_M_IX86) 8 | #pragma comment(lib, "libcurl86.lib") 9 | #endif 10 | 11 | #define CURL_STATICLIB 12 | 13 | struct channel_struct 14 | { 15 | std::string author; 16 | std::string message; 17 | std::string timestamp; 18 | }; 19 | 20 | namespace KeyAuth { 21 | class api { 22 | public: 23 | 24 | std::string name, ownerid, secret, version, url, path; 25 | 26 | api(std::string name, std::string ownerid, std::string secret, std::string version, std::string url, std::string path = "") : name(name), ownerid(ownerid), secret(secret), version(version), url(url), path(path) {} 27 | 28 | void ban(std::string reason = ""); 29 | void init(); 30 | void check(); 31 | void log(std::string msg); 32 | void license(std::string key); 33 | std::string var(std::string varid); 34 | std::string webhook(std::string id, std::string params, std::string body = "", std::string contenttype = ""); 35 | void setvar(std::string var, std::string vardata); 36 | std::string getvar(std::string var); 37 | bool checkblack(); 38 | void web_login(); 39 | void button(std::string value); 40 | void upgrade(std::string username, std::string key); 41 | void login(std::string username, std::string password); 42 | std::vector download(std::string fileid); 43 | void regstr(std::string username, std::string password, std::string key, std::string email = ""); 44 | void chatget(std::string channel); 45 | bool chatsend(std::string message, std::string channel); 46 | void changeUsername(std::string newusername); 47 | std::string fetchonline(); 48 | void fetchstats(); 49 | void forgot(std::string username, std::string email); 50 | void logout(); 51 | 52 | class subscriptions_class { 53 | public: 54 | std::string name; 55 | std::string expiry; 56 | }; 57 | 58 | class userdata { 59 | public: 60 | 61 | // user data 62 | std::string username; 63 | std::string ip; 64 | std::string hwid; 65 | std::string createdate; 66 | std::string lastlogin; 67 | 68 | std::vector subscriptions; 69 | }; 70 | 71 | class appdata { 72 | public: 73 | // app data 74 | std::string numUsers; 75 | std::string numOnlineUsers; 76 | std::string numKeys; 77 | std::string version; 78 | std::string customerPanelLink; 79 | }; 80 | 81 | class responsedata { 82 | public: 83 | // response data 84 | std::vector channeldata{}; 85 | bool success; 86 | std::string message; 87 | }; 88 | 89 | userdata user_data; 90 | appdata app_data; 91 | responsedata response; 92 | private: 93 | std::string sessionid, enckey; 94 | 95 | static std::string req(std::string data, std::string url); 96 | 97 | 98 | void load_user_data(nlohmann::json data) { 99 | api::user_data.username = data["username"]; 100 | api::user_data.ip = data["ip"]; 101 | if (data["hwid"].is_null()) { 102 | api::user_data.hwid = "none"; 103 | } 104 | else { 105 | api::user_data.hwid = data["hwid"]; 106 | } 107 | api::user_data.createdate = data["createdate"]; 108 | api::user_data.lastlogin = data["lastlogin"]; 109 | 110 | for (int i = 0; i < data["subscriptions"].size(); i++) { // Prompto#7895 & stars#2297 was here 111 | subscriptions_class subscriptions; 112 | subscriptions.name = data["subscriptions"][i]["subscription"]; 113 | subscriptions.expiry = data["subscriptions"][i]["expiry"]; 114 | api::user_data.subscriptions.emplace_back(subscriptions); 115 | } 116 | } 117 | 118 | void load_app_data(nlohmann::json data) { 119 | api::app_data.numUsers = data["numUsers"]; 120 | api::app_data.numOnlineUsers = data["numOnlineUsers"]; 121 | api::app_data.numKeys = data["numKeys"]; 122 | api::app_data.version = data["version"]; 123 | api::app_data.customerPanelLink = data["customerPanelLink"]; 124 | } 125 | 126 | void load_response_data(nlohmann::json data) { 127 | api::response.success = data["success"]; 128 | api::response.message = data["message"]; 129 | } 130 | 131 | void load_channel_data(nlohmann::json data) { 132 | api::response.success = data["success"]; 133 | api::response.message = data["message"]; 134 | for (const auto sub : data["messages"]) { 135 | 136 | std::string authoroutput = sub["author"]; 137 | std::string messageoutput = sub["message"]; 138 | int timestamp = sub["timestamp"]; std::string timestampoutput = std::to_string(timestamp); 139 | authoroutput.erase(remove(authoroutput.begin(), authoroutput.end(), '"'), authoroutput.end()); 140 | messageoutput.erase(remove(messageoutput.begin(), messageoutput.end(), '"'), messageoutput.end()); 141 | timestampoutput.erase(remove(timestampoutput.begin(), timestampoutput.end(), '"'), timestampoutput.end()); 142 | channel_struct output = { authoroutput , messageoutput, timestampoutput }; 143 | api::response.channeldata.push_back(output); 144 | } 145 | } 146 | 147 | nlohmann::json response_decoder; 148 | 149 | }; 150 | } 151 | -------------------------------------------------------------------------------- /x86/lib/xorstr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace 7 | { 8 | constexpr int const_atoi(char c) 9 | { 10 | return c - '0'; 11 | } 12 | } 13 | 14 | #ifdef _MSC_VER 15 | #define ALWAYS_INLINE __forceinline 16 | #else 17 | #define ALWAYS_INLINE __attribute__((always_inline)) 18 | #endif 19 | 20 | template 21 | class _Basic_XorStr 22 | { 23 | using value_type = typename _string_type::value_type; 24 | static constexpr auto _length_minus_one = _length - 1; 25 | 26 | public: 27 | constexpr ALWAYS_INLINE _Basic_XorStr(value_type const (&str)[_length]) 28 | : _Basic_XorStr(str, std::make_index_sequence<_length_minus_one>()) 29 | { 30 | 31 | } 32 | 33 | inline auto c_str() const 34 | { 35 | decrypt(); 36 | 37 | return data; 38 | } 39 | 40 | inline auto str() const 41 | { 42 | decrypt(); 43 | 44 | return _string_type(data, data + _length_minus_one); 45 | } 46 | 47 | inline operator _string_type() const 48 | { 49 | return str(); 50 | } 51 | 52 | private: 53 | template 54 | constexpr ALWAYS_INLINE _Basic_XorStr(value_type const (&str)[_length], std::index_sequence) 55 | : data{ crypt(str[indices], indices)..., '\0' }, 56 | encrypted(true) 57 | { 58 | 59 | } 60 | 61 | static constexpr auto XOR_KEY = static_cast( 62 | const_atoi(__TIME__[7]) + 63 | const_atoi(__TIME__[6]) * 10 + 64 | const_atoi(__TIME__[4]) * 60 + 65 | const_atoi(__TIME__[3]) * 600 + 66 | const_atoi(__TIME__[1]) * 3600 + 67 | const_atoi(__TIME__[0]) * 36000 68 | ); 69 | 70 | static ALWAYS_INLINE constexpr auto crypt(value_type c, size_t i) 71 | { 72 | return static_cast(c ^ (XOR_KEY + i)); 73 | } 74 | 75 | inline void decrypt() const 76 | { 77 | if (encrypted) 78 | { 79 | for (size_t t = 0; t < _length_minus_one; t++) 80 | { 81 | data[t] = crypt(data[t], t); 82 | } 83 | encrypted = false; 84 | } 85 | } 86 | 87 | mutable value_type data[_length]; 88 | mutable bool encrypted; 89 | }; 90 | //--------------------------------------------------------------------------- 91 | template 92 | using XorStrA = _Basic_XorStr; 93 | template 94 | using XorStrW = _Basic_XorStr; 95 | template 96 | using XorStrU16 = _Basic_XorStr; 97 | template 98 | using XorStrU32 = _Basic_XorStr; 99 | //--------------------------------------------------------------------------- 100 | template 101 | inline auto operator==(const _Basic_XorStr<_string_type, _length>& lhs, const _Basic_XorStr<_string_type, _length2>& rhs) 102 | { 103 | static_assert(_length == _length2, "XorStr== different length"); 104 | 105 | return _length == _length2 && lhs.str() == rhs.str(); 106 | } 107 | //--------------------------------------------------------------------------- 108 | template 109 | inline auto operator==(const _string_type& lhs, const _Basic_XorStr<_string_type, _length>& rhs) 110 | { 111 | return lhs.size() == _length && lhs == rhs.str(); 112 | } 113 | //--------------------------------------------------------------------------- 114 | template 115 | inline auto& operator<<(_stream_type& lhs, const _Basic_XorStr<_string_type, _length>& rhs) 116 | { 117 | lhs << rhs.c_str(); 118 | 119 | return lhs; 120 | } 121 | //--------------------------------------------------------------------------- 122 | template 123 | inline auto operator+(const _Basic_XorStr<_string_type, _length>& lhs, const _Basic_XorStr<_string_type, _length2>& rhs) 124 | { 125 | return lhs.str() + rhs.str(); 126 | } 127 | //--------------------------------------------------------------------------- 128 | template 129 | inline auto operator+(const _string_type& lhs, const _Basic_XorStr<_string_type, _length>& rhs) 130 | { 131 | return lhs + rhs.str(); 132 | } 133 | //--------------------------------------------------------------------------- 134 | template 135 | constexpr ALWAYS_INLINE auto XorStr(char const (&str)[_length]) 136 | { 137 | return XorStrA<_length>(str); 138 | } 139 | //--------------------------------------------------------------------------- 140 | template 141 | constexpr ALWAYS_INLINE auto XorStr(wchar_t const (&str)[_length]) 142 | { 143 | return XorStrW<_length>(str); 144 | } 145 | //--------------------------------------------------------------------------- 146 | template 147 | constexpr ALWAYS_INLINE auto XorStr(char16_t const (&str)[_length]) 148 | { 149 | return XorStrU16<_length>(str); 150 | } 151 | //--------------------------------------------------------------------------- 152 | template 153 | constexpr ALWAYS_INLINE auto XorStr(char32_t const (&str)[_length]) 154 | { 155 | return XorStrU32<_length>(str); 156 | } 157 | //--------------------------------------------------------------------------- -------------------------------------------------------------------------------- /x86/lib/nlohmann/ordered_map.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // less 4 | #include // allocator 5 | #include // pair 6 | #include // vector 7 | 8 | namespace nlohmann 9 | { 10 | 11 | /// ordered_map: a minimal map-like container that preserves insertion order 12 | /// for use within nlohmann::basic_json 13 | template , 14 | class Allocator = std::allocator>> 15 | struct ordered_map : std::vector, Allocator> 16 | { 17 | using key_type = Key; 18 | using mapped_type = T; 19 | using Container = std::vector, Allocator>; 20 | using typename Container::iterator; 21 | using typename Container::const_iterator; 22 | using typename Container::size_type; 23 | using typename Container::value_type; 24 | 25 | // Explicit constructors instead of `using Container::Container` 26 | // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4) 27 | ordered_map(const Allocator& alloc = Allocator()) : Container{alloc} {} 28 | template 29 | ordered_map(It first, It last, const Allocator& alloc = Allocator()) 30 | : Container{first, last, alloc} {} 31 | ordered_map(std::initializer_list init, const Allocator& alloc = Allocator() ) 32 | : Container{init, alloc} {} 33 | 34 | std::pair emplace(const key_type& key, T&& t) 35 | { 36 | for (auto it = this->begin(); it != this->end(); ++it) 37 | { 38 | if (it->first == key) 39 | { 40 | return {it, false}; 41 | } 42 | } 43 | Container::emplace_back(key, t); 44 | return {--this->end(), true}; 45 | } 46 | 47 | T& operator[](const Key& key) 48 | { 49 | return emplace(key, T{}).first->second; 50 | } 51 | 52 | const T& operator[](const Key& key) const 53 | { 54 | return at(key); 55 | } 56 | 57 | T& at(const Key& key) 58 | { 59 | for (auto it = this->begin(); it != this->end(); ++it) 60 | { 61 | if (it->first == key) 62 | { 63 | return it->second; 64 | } 65 | } 66 | 67 | throw std::out_of_range("key not found"); 68 | } 69 | 70 | const T& at(const Key& key) const 71 | { 72 | for (auto it = this->begin(); it != this->end(); ++it) 73 | { 74 | if (it->first == key) 75 | { 76 | return it->second; 77 | } 78 | } 79 | 80 | throw std::out_of_range("key not found"); 81 | } 82 | 83 | size_type erase(const Key& key) 84 | { 85 | for (auto it = this->begin(); it != this->end(); ++it) 86 | { 87 | if (it->first == key) 88 | { 89 | // Since we cannot move const Keys, re-construct them in place 90 | for (auto next = it; ++next != this->end(); ++it) 91 | { 92 | it->~value_type(); // Destroy but keep allocation 93 | new (&*it) value_type{std::move(*next)}; 94 | } 95 | Container::pop_back(); 96 | return 1; 97 | } 98 | } 99 | return 0; 100 | } 101 | 102 | iterator erase(iterator pos) 103 | { 104 | auto it = pos; 105 | 106 | // Since we cannot move const Keys, re-construct them in place 107 | for (auto next = it; ++next != this->end(); ++it) 108 | { 109 | it->~value_type(); // Destroy but keep allocation 110 | new (&*it) value_type{std::move(*next)}; 111 | } 112 | Container::pop_back(); 113 | return pos; 114 | } 115 | 116 | size_type count(const Key& key) const 117 | { 118 | for (auto it = this->begin(); it != this->end(); ++it) 119 | { 120 | if (it->first == key) 121 | { 122 | return 1; 123 | } 124 | } 125 | return 0; 126 | } 127 | 128 | iterator find(const Key& key) 129 | { 130 | for (auto it = this->begin(); it != this->end(); ++it) 131 | { 132 | if (it->first == key) 133 | { 134 | return it; 135 | } 136 | } 137 | return Container::end(); 138 | } 139 | 140 | const_iterator find(const Key& key) const 141 | { 142 | for (auto it = this->begin(); it != this->end(); ++it) 143 | { 144 | if (it->first == key) 145 | { 146 | return it; 147 | } 148 | } 149 | return Container::end(); 150 | } 151 | 152 | std::pair insert( value_type&& value ) 153 | { 154 | return emplace(value.first, std::move(value.second)); 155 | } 156 | 157 | std::pair insert( const value_type& value ) 158 | { 159 | for (auto it = this->begin(); it != this->end(); ++it) 160 | { 161 | if (it->first == value.first) 162 | { 163 | return {it, false}; 164 | } 165 | } 166 | Container::push_back(value); 167 | return {--this->end(), true}; 168 | } 169 | }; 170 | 171 | } // namespace nlohmann 172 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/byte_container_with_subtype.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // uint8_t 4 | #include // tie 5 | #include // move 6 | 7 | namespace nlohmann 8 | { 9 | 10 | /*! 11 | @brief an internal type for a backed binary type 12 | 13 | This type extends the template parameter @a BinaryType provided to `basic_json` 14 | with a subtype used by BSON and MessagePack. This type exists so that the user 15 | does not have to specify a type themselves with a specific naming scheme in 16 | order to override the binary type. 17 | 18 | @tparam BinaryType container to store bytes (`std::vector` by 19 | default) 20 | 21 | @since version 3.8.0 22 | */ 23 | template 24 | class byte_container_with_subtype : public BinaryType 25 | { 26 | public: 27 | /// the type of the underlying container 28 | using container_type = BinaryType; 29 | 30 | byte_container_with_subtype() noexcept(noexcept(container_type())) 31 | : container_type() 32 | {} 33 | 34 | byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b))) 35 | : container_type(b) 36 | {} 37 | 38 | byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b)))) 39 | : container_type(std::move(b)) 40 | {} 41 | 42 | byte_container_with_subtype(const container_type& b, std::uint8_t subtype) noexcept(noexcept(container_type(b))) 43 | : container_type(b) 44 | , m_subtype(subtype) 45 | , m_has_subtype(true) 46 | {} 47 | 48 | byte_container_with_subtype(container_type&& b, std::uint8_t subtype) noexcept(noexcept(container_type(std::move(b)))) 49 | : container_type(std::move(b)) 50 | , m_subtype(subtype) 51 | , m_has_subtype(true) 52 | {} 53 | 54 | bool operator==(const byte_container_with_subtype& rhs) const 55 | { 56 | return std::tie(static_cast(*this), m_subtype, m_has_subtype) == 57 | std::tie(static_cast(rhs), rhs.m_subtype, rhs.m_has_subtype); 58 | } 59 | 60 | bool operator!=(const byte_container_with_subtype& rhs) const 61 | { 62 | return !(rhs == *this); 63 | } 64 | 65 | /*! 66 | @brief sets the binary subtype 67 | 68 | Sets the binary subtype of the value, also flags a binary JSON value as 69 | having a subtype, which has implications for serialization. 70 | 71 | @complexity Constant. 72 | 73 | @exceptionsafety No-throw guarantee: this member function never throws 74 | exceptions. 75 | 76 | @sa @ref subtype() -- return the binary subtype 77 | @sa @ref clear_subtype() -- clears the binary subtype 78 | @sa @ref has_subtype() -- returns whether or not the binary value has a 79 | subtype 80 | 81 | @since version 3.8.0 82 | */ 83 | void set_subtype(std::uint8_t subtype) noexcept 84 | { 85 | m_subtype = subtype; 86 | m_has_subtype = true; 87 | } 88 | 89 | /*! 90 | @brief return the binary subtype 91 | 92 | Returns the numerical subtype of the value if it has a subtype. If it does 93 | not have a subtype, this function will return size_t(-1) as a sentinel 94 | value. 95 | 96 | @return the numerical subtype of the binary value 97 | 98 | @complexity Constant. 99 | 100 | @exceptionsafety No-throw guarantee: this member function never throws 101 | exceptions. 102 | 103 | @sa @ref set_subtype() -- sets the binary subtype 104 | @sa @ref clear_subtype() -- clears the binary subtype 105 | @sa @ref has_subtype() -- returns whether or not the binary value has a 106 | subtype 107 | 108 | @since version 3.8.0 109 | */ 110 | constexpr std::uint8_t subtype() const noexcept 111 | { 112 | return m_subtype; 113 | } 114 | 115 | /*! 116 | @brief return whether the value has a subtype 117 | 118 | @return whether the value has a subtype 119 | 120 | @complexity Constant. 121 | 122 | @exceptionsafety No-throw guarantee: this member function never throws 123 | exceptions. 124 | 125 | @sa @ref subtype() -- return the binary subtype 126 | @sa @ref set_subtype() -- sets the binary subtype 127 | @sa @ref clear_subtype() -- clears the binary subtype 128 | 129 | @since version 3.8.0 130 | */ 131 | constexpr bool has_subtype() const noexcept 132 | { 133 | return m_has_subtype; 134 | } 135 | 136 | /*! 137 | @brief clears the binary subtype 138 | 139 | Clears the binary subtype and flags the value as not having a subtype, which 140 | has implications for serialization; for instance MessagePack will prefer the 141 | bin family over the ext family. 142 | 143 | @complexity Constant. 144 | 145 | @exceptionsafety No-throw guarantee: this member function never throws 146 | exceptions. 147 | 148 | @sa @ref subtype() -- return the binary subtype 149 | @sa @ref set_subtype() -- sets the binary subtype 150 | @sa @ref has_subtype() -- returns whether or not the binary value has a 151 | subtype 152 | 153 | @since version 3.8.0 154 | */ 155 | void clear_subtype() noexcept 156 | { 157 | m_subtype = 0; 158 | m_has_subtype = false; 159 | } 160 | 161 | private: 162 | std::uint8_t m_subtype = 0; 163 | bool m_has_subtype = false; 164 | }; 165 | 166 | } // namespace nlohmann 167 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/thirdparty/hedley/hedley_undef.hpp: -------------------------------------------------------------------------------- 1 | #undef JSON_HEDLEY_ALWAYS_INLINE 2 | #undef JSON_HEDLEY_ARM_VERSION 3 | #undef JSON_HEDLEY_ARM_VERSION_CHECK 4 | #undef JSON_HEDLEY_ARRAY_PARAM 5 | #undef JSON_HEDLEY_ASSUME 6 | #undef JSON_HEDLEY_BEGIN_C_DECLS 7 | #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE 8 | #undef JSON_HEDLEY_CLANG_HAS_BUILTIN 9 | #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE 10 | #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE 11 | #undef JSON_HEDLEY_CLANG_HAS_EXTENSION 12 | #undef JSON_HEDLEY_CLANG_HAS_FEATURE 13 | #undef JSON_HEDLEY_CLANG_HAS_WARNING 14 | #undef JSON_HEDLEY_COMPCERT_VERSION 15 | #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK 16 | #undef JSON_HEDLEY_CONCAT 17 | #undef JSON_HEDLEY_CONCAT3 18 | #undef JSON_HEDLEY_CONCAT3_EX 19 | #undef JSON_HEDLEY_CONCAT_EX 20 | #undef JSON_HEDLEY_CONST 21 | #undef JSON_HEDLEY_CONSTEXPR 22 | #undef JSON_HEDLEY_CONST_CAST 23 | #undef JSON_HEDLEY_CPP_CAST 24 | #undef JSON_HEDLEY_CRAY_VERSION 25 | #undef JSON_HEDLEY_CRAY_VERSION_CHECK 26 | #undef JSON_HEDLEY_C_DECL 27 | #undef JSON_HEDLEY_DEPRECATED 28 | #undef JSON_HEDLEY_DEPRECATED_FOR 29 | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL 30 | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ 31 | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED 32 | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES 33 | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS 34 | #undef JSON_HEDLEY_DIAGNOSTIC_POP 35 | #undef JSON_HEDLEY_DIAGNOSTIC_PUSH 36 | #undef JSON_HEDLEY_DMC_VERSION 37 | #undef JSON_HEDLEY_DMC_VERSION_CHECK 38 | #undef JSON_HEDLEY_EMPTY_BASES 39 | #undef JSON_HEDLEY_EMSCRIPTEN_VERSION 40 | #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK 41 | #undef JSON_HEDLEY_END_C_DECLS 42 | #undef JSON_HEDLEY_FLAGS 43 | #undef JSON_HEDLEY_FLAGS_CAST 44 | #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE 45 | #undef JSON_HEDLEY_GCC_HAS_BUILTIN 46 | #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE 47 | #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE 48 | #undef JSON_HEDLEY_GCC_HAS_EXTENSION 49 | #undef JSON_HEDLEY_GCC_HAS_FEATURE 50 | #undef JSON_HEDLEY_GCC_HAS_WARNING 51 | #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK 52 | #undef JSON_HEDLEY_GCC_VERSION 53 | #undef JSON_HEDLEY_GCC_VERSION_CHECK 54 | #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE 55 | #undef JSON_HEDLEY_GNUC_HAS_BUILTIN 56 | #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE 57 | #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE 58 | #undef JSON_HEDLEY_GNUC_HAS_EXTENSION 59 | #undef JSON_HEDLEY_GNUC_HAS_FEATURE 60 | #undef JSON_HEDLEY_GNUC_HAS_WARNING 61 | #undef JSON_HEDLEY_GNUC_VERSION 62 | #undef JSON_HEDLEY_GNUC_VERSION_CHECK 63 | #undef JSON_HEDLEY_HAS_ATTRIBUTE 64 | #undef JSON_HEDLEY_HAS_BUILTIN 65 | #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE 66 | #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS 67 | #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE 68 | #undef JSON_HEDLEY_HAS_EXTENSION 69 | #undef JSON_HEDLEY_HAS_FEATURE 70 | #undef JSON_HEDLEY_HAS_WARNING 71 | #undef JSON_HEDLEY_IAR_VERSION 72 | #undef JSON_HEDLEY_IAR_VERSION_CHECK 73 | #undef JSON_HEDLEY_IBM_VERSION 74 | #undef JSON_HEDLEY_IBM_VERSION_CHECK 75 | #undef JSON_HEDLEY_IMPORT 76 | #undef JSON_HEDLEY_INLINE 77 | #undef JSON_HEDLEY_INTEL_VERSION 78 | #undef JSON_HEDLEY_INTEL_VERSION_CHECK 79 | #undef JSON_HEDLEY_IS_CONSTANT 80 | #undef JSON_HEDLEY_IS_CONSTEXPR_ 81 | #undef JSON_HEDLEY_LIKELY 82 | #undef JSON_HEDLEY_MALLOC 83 | #undef JSON_HEDLEY_MESSAGE 84 | #undef JSON_HEDLEY_MSVC_VERSION 85 | #undef JSON_HEDLEY_MSVC_VERSION_CHECK 86 | #undef JSON_HEDLEY_NEVER_INLINE 87 | #undef JSON_HEDLEY_NON_NULL 88 | #undef JSON_HEDLEY_NO_ESCAPE 89 | #undef JSON_HEDLEY_NO_RETURN 90 | #undef JSON_HEDLEY_NO_THROW 91 | #undef JSON_HEDLEY_NULL 92 | #undef JSON_HEDLEY_PELLES_VERSION 93 | #undef JSON_HEDLEY_PELLES_VERSION_CHECK 94 | #undef JSON_HEDLEY_PGI_VERSION 95 | #undef JSON_HEDLEY_PGI_VERSION_CHECK 96 | #undef JSON_HEDLEY_PREDICT 97 | #undef JSON_HEDLEY_PRINTF_FORMAT 98 | #undef JSON_HEDLEY_PRIVATE 99 | #undef JSON_HEDLEY_PUBLIC 100 | #undef JSON_HEDLEY_PURE 101 | #undef JSON_HEDLEY_REINTERPRET_CAST 102 | #undef JSON_HEDLEY_REQUIRE 103 | #undef JSON_HEDLEY_REQUIRE_CONSTEXPR 104 | #undef JSON_HEDLEY_REQUIRE_MSG 105 | #undef JSON_HEDLEY_RESTRICT 106 | #undef JSON_HEDLEY_RETURNS_NON_NULL 107 | #undef JSON_HEDLEY_SENTINEL 108 | #undef JSON_HEDLEY_STATIC_ASSERT 109 | #undef JSON_HEDLEY_STATIC_CAST 110 | #undef JSON_HEDLEY_STRINGIFY 111 | #undef JSON_HEDLEY_STRINGIFY_EX 112 | #undef JSON_HEDLEY_SUNPRO_VERSION 113 | #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK 114 | #undef JSON_HEDLEY_TINYC_VERSION 115 | #undef JSON_HEDLEY_TINYC_VERSION_CHECK 116 | #undef JSON_HEDLEY_TI_ARMCL_VERSION 117 | #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK 118 | #undef JSON_HEDLEY_TI_CL2000_VERSION 119 | #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK 120 | #undef JSON_HEDLEY_TI_CL430_VERSION 121 | #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK 122 | #undef JSON_HEDLEY_TI_CL6X_VERSION 123 | #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK 124 | #undef JSON_HEDLEY_TI_CL7X_VERSION 125 | #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK 126 | #undef JSON_HEDLEY_TI_CLPRU_VERSION 127 | #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK 128 | #undef JSON_HEDLEY_TI_VERSION 129 | #undef JSON_HEDLEY_TI_VERSION_CHECK 130 | #undef JSON_HEDLEY_UNAVAILABLE 131 | #undef JSON_HEDLEY_UNLIKELY 132 | #undef JSON_HEDLEY_UNPREDICTABLE 133 | #undef JSON_HEDLEY_UNREACHABLE 134 | #undef JSON_HEDLEY_UNREACHABLE_RETURN 135 | #undef JSON_HEDLEY_VERSION 136 | #undef JSON_HEDLEY_VERSION_DECODE_MAJOR 137 | #undef JSON_HEDLEY_VERSION_DECODE_MINOR 138 | #undef JSON_HEDLEY_VERSION_DECODE_REVISION 139 | #undef JSON_HEDLEY_VERSION_ENCODE 140 | #undef JSON_HEDLEY_WARNING 141 | #undef JSON_HEDLEY_WARN_UNUSED_RESULT 142 | #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG 143 | #undef JSON_HEDLEY_FALL_THROUGH 144 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/iterators/iteration_proxy.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // size_t 4 | #include // input_iterator_tag 5 | #include // string, to_string 6 | #include // tuple_size, get, tuple_element 7 | 8 | #include 9 | #include 10 | 11 | namespace nlohmann 12 | { 13 | namespace detail 14 | { 15 | template 16 | void int_to_string( string_type& target, std::size_t value ) 17 | { 18 | // For ADL 19 | using std::to_string; 20 | target = to_string(value); 21 | } 22 | template class iteration_proxy_value 23 | { 24 | public: 25 | using difference_type = std::ptrdiff_t; 26 | using value_type = iteration_proxy_value; 27 | using pointer = value_type * ; 28 | using reference = value_type & ; 29 | using iterator_category = std::input_iterator_tag; 30 | using string_type = typename std::remove_cv< typename std::remove_reference().key() ) >::type >::type; 31 | 32 | private: 33 | /// the iterator 34 | IteratorType anchor; 35 | /// an index for arrays (used to create key names) 36 | std::size_t array_index = 0; 37 | /// last stringified array index 38 | mutable std::size_t array_index_last = 0; 39 | /// a string representation of the array index 40 | mutable string_type array_index_str = "0"; 41 | /// an empty string (to return a reference for primitive values) 42 | const string_type empty_str = ""; 43 | 44 | public: 45 | explicit iteration_proxy_value(IteratorType it) noexcept : anchor(it) {} 46 | 47 | /// dereference operator (needed for range-based for) 48 | iteration_proxy_value& operator*() 49 | { 50 | return *this; 51 | } 52 | 53 | /// increment operator (needed for range-based for) 54 | iteration_proxy_value& operator++() 55 | { 56 | ++anchor; 57 | ++array_index; 58 | 59 | return *this; 60 | } 61 | 62 | /// equality operator (needed for InputIterator) 63 | bool operator==(const iteration_proxy_value& o) const 64 | { 65 | return anchor == o.anchor; 66 | } 67 | 68 | /// inequality operator (needed for range-based for) 69 | bool operator!=(const iteration_proxy_value& o) const 70 | { 71 | return anchor != o.anchor; 72 | } 73 | 74 | /// return key of the iterator 75 | const string_type& key() const 76 | { 77 | JSON_ASSERT(anchor.m_object != nullptr); 78 | 79 | switch (anchor.m_object->type()) 80 | { 81 | // use integer array index as key 82 | case value_t::array: 83 | { 84 | if (array_index != array_index_last) 85 | { 86 | int_to_string( array_index_str, array_index ); 87 | array_index_last = array_index; 88 | } 89 | return array_index_str; 90 | } 91 | 92 | // use key from the object 93 | case value_t::object: 94 | return anchor.key(); 95 | 96 | // use an empty key for all primitive types 97 | default: 98 | return empty_str; 99 | } 100 | } 101 | 102 | /// return value of the iterator 103 | typename IteratorType::reference value() const 104 | { 105 | return anchor.value(); 106 | } 107 | }; 108 | 109 | /// proxy class for the items() function 110 | template class iteration_proxy 111 | { 112 | private: 113 | /// the container to iterate 114 | typename IteratorType::reference container; 115 | 116 | public: 117 | /// construct iteration proxy from a container 118 | explicit iteration_proxy(typename IteratorType::reference cont) noexcept 119 | : container(cont) {} 120 | 121 | /// return iterator begin (needed for range-based for) 122 | iteration_proxy_value begin() noexcept 123 | { 124 | return iteration_proxy_value(container.begin()); 125 | } 126 | 127 | /// return iterator end (needed for range-based for) 128 | iteration_proxy_value end() noexcept 129 | { 130 | return iteration_proxy_value(container.end()); 131 | } 132 | }; 133 | // Structured Bindings Support 134 | // For further reference see https://blog.tartanllama.xyz/structured-bindings/ 135 | // And see https://github.com/nlohmann/json/pull/1391 136 | template = 0> 137 | auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.key()) 138 | { 139 | return i.key(); 140 | } 141 | // Structured Bindings Support 142 | // For further reference see https://blog.tartanllama.xyz/structured-bindings/ 143 | // And see https://github.com/nlohmann/json/pull/1391 144 | template = 0> 145 | auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.value()) 146 | { 147 | return i.value(); 148 | } 149 | } // namespace detail 150 | } // namespace nlohmann 151 | 152 | // The Addition to the STD Namespace is required to add 153 | // Structured Bindings Support to the iteration_proxy_value class 154 | // For further reference see https://blog.tartanllama.xyz/structured-bindings/ 155 | // And see https://github.com/nlohmann/json/pull/1391 156 | namespace std 157 | { 158 | #if defined(__clang__) 159 | // Fix: https://github.com/nlohmann/json/issues/1401 160 | #pragma clang diagnostic push 161 | #pragma clang diagnostic ignored "-Wmismatched-tags" 162 | #endif 163 | template 164 | class tuple_size<::nlohmann::detail::iteration_proxy_value> 165 | : public std::integral_constant {}; 166 | 167 | template 168 | class tuple_element> 169 | { 170 | public: 171 | using type = decltype( 172 | get(std::declval < 173 | ::nlohmann::detail::iteration_proxy_value> ())); 174 | }; 175 | #if defined(__clang__) 176 | #pragma clang diagnostic pop 177 | #endif 178 | } // namespace std 179 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/meta/is_sax.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // size_t 4 | #include // declval 5 | #include // string 6 | 7 | #include 8 | #include 9 | 10 | namespace nlohmann 11 | { 12 | namespace detail 13 | { 14 | template 15 | using null_function_t = decltype(std::declval().null()); 16 | 17 | template 18 | using boolean_function_t = 19 | decltype(std::declval().boolean(std::declval())); 20 | 21 | template 22 | using number_integer_function_t = 23 | decltype(std::declval().number_integer(std::declval())); 24 | 25 | template 26 | using number_unsigned_function_t = 27 | decltype(std::declval().number_unsigned(std::declval())); 28 | 29 | template 30 | using number_float_function_t = decltype(std::declval().number_float( 31 | std::declval(), std::declval())); 32 | 33 | template 34 | using string_function_t = 35 | decltype(std::declval().string(std::declval())); 36 | 37 | template 38 | using binary_function_t = 39 | decltype(std::declval().binary(std::declval())); 40 | 41 | template 42 | using start_object_function_t = 43 | decltype(std::declval().start_object(std::declval())); 44 | 45 | template 46 | using key_function_t = 47 | decltype(std::declval().key(std::declval())); 48 | 49 | template 50 | using end_object_function_t = decltype(std::declval().end_object()); 51 | 52 | template 53 | using start_array_function_t = 54 | decltype(std::declval().start_array(std::declval())); 55 | 56 | template 57 | using end_array_function_t = decltype(std::declval().end_array()); 58 | 59 | template 60 | using parse_error_function_t = decltype(std::declval().parse_error( 61 | std::declval(), std::declval(), 62 | std::declval())); 63 | 64 | template 65 | struct is_sax 66 | { 67 | private: 68 | static_assert(is_basic_json::value, 69 | "BasicJsonType must be of type basic_json<...>"); 70 | 71 | using number_integer_t = typename BasicJsonType::number_integer_t; 72 | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; 73 | using number_float_t = typename BasicJsonType::number_float_t; 74 | using string_t = typename BasicJsonType::string_t; 75 | using binary_t = typename BasicJsonType::binary_t; 76 | using exception_t = typename BasicJsonType::exception; 77 | 78 | public: 79 | static constexpr bool value = 80 | is_detected_exact::value && 81 | is_detected_exact::value && 82 | is_detected_exact::value && 83 | is_detected_exact::value && 84 | is_detected_exact::value && 85 | is_detected_exact::value && 86 | is_detected_exact::value && 87 | is_detected_exact::value && 88 | is_detected_exact::value && 89 | is_detected_exact::value && 90 | is_detected_exact::value && 91 | is_detected_exact::value && 92 | is_detected_exact::value; 93 | }; 94 | 95 | template 96 | struct is_sax_static_asserts 97 | { 98 | private: 99 | static_assert(is_basic_json::value, 100 | "BasicJsonType must be of type basic_json<...>"); 101 | 102 | using number_integer_t = typename BasicJsonType::number_integer_t; 103 | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; 104 | using number_float_t = typename BasicJsonType::number_float_t; 105 | using string_t = typename BasicJsonType::string_t; 106 | using binary_t = typename BasicJsonType::binary_t; 107 | using exception_t = typename BasicJsonType::exception; 108 | 109 | public: 110 | static_assert(is_detected_exact::value, 111 | "Missing/invalid function: bool null()"); 112 | static_assert(is_detected_exact::value, 113 | "Missing/invalid function: bool boolean(bool)"); 114 | static_assert(is_detected_exact::value, 115 | "Missing/invalid function: bool boolean(bool)"); 116 | static_assert( 117 | is_detected_exact::value, 119 | "Missing/invalid function: bool number_integer(number_integer_t)"); 120 | static_assert( 121 | is_detected_exact::value, 123 | "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); 124 | static_assert(is_detected_exact::value, 126 | "Missing/invalid function: bool number_float(number_float_t, const string_t&)"); 127 | static_assert( 128 | is_detected_exact::value, 129 | "Missing/invalid function: bool string(string_t&)"); 130 | static_assert( 131 | is_detected_exact::value, 132 | "Missing/invalid function: bool binary(binary_t&)"); 133 | static_assert(is_detected_exact::value, 134 | "Missing/invalid function: bool start_object(std::size_t)"); 135 | static_assert(is_detected_exact::value, 136 | "Missing/invalid function: bool key(string_t&)"); 137 | static_assert(is_detected_exact::value, 138 | "Missing/invalid function: bool end_object()"); 139 | static_assert(is_detected_exact::value, 140 | "Missing/invalid function: bool start_array(std::size_t)"); 141 | static_assert(is_detected_exact::value, 142 | "Missing/invalid function: bool end_array()"); 143 | static_assert( 144 | is_detected_exact::value, 145 | "Missing/invalid function: bool parse_error(std::size_t, const " 146 | "std::string&, const exception&)"); 147 | }; 148 | } // namespace detail 149 | } // namespace nlohmann 150 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /x64/example.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {3e584710-d844-49e5-9938-b4efa4928b17} 25 | example 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v142 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | MultiByte 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | .\;$(IncludePath) 79 | .\;$(LibraryPath) 80 | 81 | 82 | true 83 | 84 | 85 | false 86 | .\;$(IncludePath) 87 | .\;$(LibraryPath) 88 | 89 | 90 | 91 | Level3 92 | true 93 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 94 | true 95 | 96 | 97 | Console 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | true 106 | true 107 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 108 | true 109 | stdcpp17 110 | 111 | 112 | Console 113 | true 114 | true 115 | true 116 | library_x86.lib;%(AdditionalDependencies) 117 | 118 | 119 | 120 | 121 | Level3 122 | true 123 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 124 | true 125 | stdcpp20 126 | 127 | 128 | Console 129 | true 130 | 131 | 132 | 133 | 134 | Level3 135 | true 136 | true 137 | true 138 | _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 139 | true 140 | stdcpp17 141 | MultiThreadedDLL 142 | %(AdditionalIncludeDirectories) 143 | 144 | 145 | Console 146 | true 147 | true 148 | false 149 | library_x64.lib;%(AdditionalDependencies) 150 | MachineX64 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /x64/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "auth.hpp" 3 | #include 4 | #include 5 | #include "utils.hpp" 6 | #include "skStr.h" 7 | #include 8 | std::string tm_to_readable_time(tm ctx); 9 | static std::time_t string_to_timet(std::string timestamp); 10 | static std::tm timet_to_tm(time_t timestamp); 11 | const std::string compilation_date = (std::string)skCrypt(__DATE__); 12 | const std::string compilation_time = (std::string)skCrypt(__TIME__); 13 | void sessionStatus(); 14 | 15 | using namespace KeyAuth; 16 | 17 | // copy and paste from https://keyauth.cc/app/ and replace these string variables 18 | // Please watch tutorial HERE https://www.youtube.com/watch?v=5x4YkTmFH-U 19 | std::string name = skCrypt("name").decrypt(); // App name 20 | std::string ownerid = skCrypt("ownerid").decrypt(); // Account ID 21 | std::string version = skCrypt("1.0").decrypt(); // Application version. Used for automatic downloads see video here https://www.youtube.com/watch?v=kW195PLCBKs 22 | std::string url = skCrypt("https://keyauth.win/api/1.3/").decrypt(); // change if using KeyAuth custom domains feature 23 | std::string path = skCrypt("").decrypt(); // (OPTIONAL) see tutorial here https://www.youtube.com/watch?v=I9rxt821gMk&t=1s 24 | 25 | 26 | api KeyAuthApp(name, ownerid, version, url, path); 27 | 28 | int main() 29 | { 30 | std::string consoleTitle = skCrypt("Loader - Built at: ").decrypt() + compilation_date + " " + compilation_time; 31 | SetConsoleTitleA(consoleTitle.c_str()); 32 | std::cout << skCrypt("\n\n Connecting.."); 33 | 34 | KeyAuthApp.init(); 35 | if (!KeyAuthApp.response.success) 36 | { 37 | std::cout << skCrypt("\n Status: ") << KeyAuthApp.response.message; 38 | Sleep(1500); 39 | exit(1); 40 | } 41 | 42 | std::string username, password, key, TfaCode; // keep this before the auto-login with saved file. 43 | // because if you don't and the user has 2FA on, then they won't be asked for 2FA code and can't login. 44 | 45 | if (std::filesystem::exists("test.json")) //change test.txt to the path of your file :smile: 46 | { 47 | if (!CheckIfJsonKeyExists("test.json", "username")) 48 | { 49 | key = ReadFromJson("test.json", "license"); 50 | KeyAuthApp.license(key); 51 | } 52 | else 53 | { 54 | username = ReadFromJson("test.json", "username"); 55 | password = ReadFromJson("test.json", "password"); 56 | KeyAuthApp.login(username, password); 57 | } 58 | } 59 | else 60 | { 61 | std::cout << skCrypt("\n\n [1] Login\n [2] Register\n [3] Upgrade\n [4] License key only\n\n Choose option: "); 62 | 63 | int option; 64 | 65 | std::cin >> option; 66 | switch (option) 67 | { 68 | case 1: 69 | std::cout << skCrypt("\n\n Enter username: "); 70 | std::cin >> username; 71 | std::cout << skCrypt("\n Enter password: "); 72 | std::cin >> password; 73 | KeyAuthApp.login(username, password, ""); 74 | break; 75 | case 2: 76 | std::cout << skCrypt("\n\n Enter username: "); 77 | std::cin >> username; 78 | std::cout << skCrypt("\n Enter password: "); 79 | std::cin >> password; 80 | std::cout << skCrypt("\n Enter license: "); 81 | std::cin >> key; 82 | KeyAuthApp.regstr(username, password, key); 83 | break; 84 | case 3: 85 | std::cout << skCrypt("\n\n Enter username: "); 86 | std::cin >> username; 87 | std::cout << skCrypt("\n Enter license: "); 88 | std::cin >> key; 89 | KeyAuthApp.upgrade(username, key); 90 | break; 91 | case 4: 92 | std::cout << skCrypt("\n Enter license: "); 93 | std::cin >> key; 94 | KeyAuthApp.license(key, ""); 95 | break; 96 | default: 97 | std::cout << skCrypt("\n\n Status: Failure: Invalid Selection"); 98 | Sleep(3000); 99 | exit(1); 100 | } 101 | } 102 | 103 | if (KeyAuthApp.response.message.empty()) exit(11); 104 | if (!KeyAuthApp.response.success) 105 | { 106 | if (KeyAuthApp.response.message == "2FA code required.") { 107 | if (username.empty() || password.empty()) { 108 | std::cout << skCrypt("\n Your account has 2FA enabled, please enter 6-digit code:"); 109 | std::cin >> TfaCode; 110 | KeyAuthApp.license(key, TfaCode); 111 | } 112 | else { 113 | std::cout << skCrypt("\n Your account has 2FA enabled, please enter 6-digit code:"); 114 | std::cin >> TfaCode; 115 | KeyAuthApp.login(username, password, TfaCode); 116 | } 117 | 118 | if (KeyAuthApp.response.message.empty()) exit(11); 119 | if (!KeyAuthApp.response.success) { 120 | std::cout << skCrypt("\n Status: ") << KeyAuthApp.response.message; 121 | std::remove("test.json"); 122 | Sleep(1500); 123 | exit(1); 124 | } 125 | } 126 | else { 127 | std::cout << skCrypt("\n Status: ") << KeyAuthApp.response.message; 128 | std::remove("test.json"); 129 | Sleep(1500); 130 | exit(1); 131 | } 132 | } 133 | 134 | if (username.empty() || password.empty()) 135 | { 136 | WriteToJson("test.json", "license", key, false, "", ""); 137 | std::cout << skCrypt("Successfully Created File For Auto Login"); 138 | } 139 | else 140 | { 141 | WriteToJson("test.json", "username", username, true, "password", password); 142 | std::cout << skCrypt("Successfully Created File For Auto Login"); 143 | } 144 | 145 | /* 146 | * Do NOT remove this checkAuthenticated() function. 147 | * It protects you from cracking, it would be NOT be a good idea to remove it 148 | */ 149 | std::thread run(checkAuthenticated, ownerid); 150 | // do NOT remove checkAuthenticated(), it MUST stay for security reasons 151 | std::thread check(sessionStatus); // do NOT remove this function either. 152 | 153 | //enable 2FA 154 | // KeyAuthApp.enable2fa(); you will need to ask for the code 155 | //enable 2fa without the need of asking for the code 156 | //KeyAuthApp.enable2fa().handleInput(KeyAuthApp); 157 | 158 | //disbale 2FA 159 | // KeyAuthApp.disable2fa(); 160 | 161 | if (KeyAuthApp.user_data.username.empty()) exit(10); 162 | std::cout << skCrypt("\n User data:"); 163 | std::cout << skCrypt("\n Username: ") << KeyAuthApp.user_data.username; 164 | std::cout << skCrypt("\n IP address: ") << KeyAuthApp.user_data.ip; 165 | std::cout << skCrypt("\n Hardware-Id: ") << KeyAuthApp.user_data.hwid; 166 | std::cout << skCrypt("\n Create date: ") << tm_to_readable_time(timet_to_tm(string_to_timet(KeyAuthApp.user_data.createdate))); 167 | std::cout << skCrypt("\n Last login: ") << tm_to_readable_time(timet_to_tm(string_to_timet(KeyAuthApp.user_data.lastlogin))); 168 | std::cout << skCrypt("\n Subscription(s): "); 169 | 170 | for (int i = 0; i < KeyAuthApp.user_data.subscriptions.size(); i++) { 171 | auto sub = KeyAuthApp.user_data.subscriptions.at(i); 172 | std::cout << skCrypt("\n name: ") << sub.name; 173 | std::cout << skCrypt(" : expiry: ") << tm_to_readable_time(timet_to_tm(string_to_timet(sub.expiry))); 174 | } 175 | 176 | 177 | std::cout << skCrypt("\n\n Status: ") << KeyAuthApp.response.message; 178 | 179 | 180 | std::cout << skCrypt("\n\n Closing in five seconds..."); 181 | Sleep(5000); 182 | 183 | return 0; 184 | } 185 | 186 | void sessionStatus() { 187 | KeyAuthApp.check(true); // do NOT specify true usually, it is slower and will get you blocked from API 188 | if (!KeyAuthApp.response.success) { 189 | exit(0); 190 | } 191 | 192 | if (KeyAuthApp.response.isPaid) { 193 | while (true) { 194 | Sleep(20000); // this MUST be included or else you get blocked from API 195 | KeyAuthApp.check(); 196 | if (!KeyAuthApp.response.success) { 197 | exit(0); 198 | } 199 | } 200 | } 201 | } 202 | 203 | std::string tm_to_readable_time(tm ctx) { 204 | char buffer[80]; 205 | 206 | strftime(buffer, sizeof(buffer), "%a %m/%d/%y %H:%M:%S %Z", &ctx); 207 | 208 | return std::string(buffer); 209 | } 210 | 211 | static std::time_t string_to_timet(std::string timestamp) { 212 | auto cv = strtol(timestamp.c_str(), NULL, 10); // long 213 | 214 | return (time_t)cv; 215 | } 216 | 217 | static std::tm timet_to_tm(time_t timestamp) { 218 | std::tm context; 219 | 220 | localtime_s(&context, ×tamp); 221 | 222 | return context; 223 | } 224 | -------------------------------------------------------------------------------- /x86/example.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {de1a561c-edb6-4e62-a44a-ca45ef812d97} 18 | 19 | 20 | {587eab74-13d3-4764-9f32-49b7924744df} 21 | 22 | 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | 41 | 42 | Header Files\Protection 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | Header Files 100 | 101 | 102 | Header Files 103 | 104 | 105 | Header Files 106 | 107 | 108 | Header Files 109 | 110 | 111 | Header Files 112 | 113 | 114 | Header Files 115 | 116 | 117 | Header Files 118 | 119 | 120 | Header Files 121 | 122 | 123 | Header Files 124 | 125 | 126 | Header Files 127 | 128 | 129 | Header Files 130 | 131 | 132 | Header Files 133 | 134 | 135 | Header Files 136 | 137 | 138 | Header Files 139 | 140 | 141 | Header Files 142 | 143 | 144 | Header Files 145 | 146 | 147 | Header Files 148 | 149 | 150 | Header Files 151 | 152 | 153 | Header Files 154 | 155 | 156 | Header Files 157 | 158 | 159 | Header Files 160 | 161 | 162 | Header Files 163 | 164 | 165 | Header Files 166 | 167 | 168 | Header Files 169 | 170 | 171 | Header Files 172 | 173 | 174 | Header Files 175 | 176 | 177 | Header Files 178 | 179 | 180 | Header Files 181 | 182 | 183 | Header Files 184 | 185 | 186 | Header Files 187 | 188 | 189 | Header Files 190 | 191 | 192 | Header Files 193 | 194 | 195 | Header Files 196 | 197 | 198 | Header Files 199 | 200 | 201 | Header Files 202 | 203 | 204 | Header Files 205 | 206 | 207 | 208 | 209 | 210 | -------------------------------------------------------------------------------- /x86/lib/sha256.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // WjCryptLib_Sha256 3 | // 4 | // Implementation of SHA256 hash function. 5 | // Original author: Tom St Denis, tomstdenis@gmail.com, http://libtom.org 6 | // Modified by WaterJuice retaining Public Domain license. 7 | // 8 | // This is free and unencumbered software released into the public domain - 9 | // June 2013 waterjuice.org 10 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 13 | // IMPORTS 14 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 15 | 16 | #include "sha256.h" 17 | #include 18 | 19 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 20 | // MACROS 21 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 22 | 23 | #define ror(value, bits) (((value) >> (bits)) | ((value) << (32 - (bits)))) 24 | 25 | #define MIN(x, y) (((x) < (y)) ? (x) : (y)) 26 | 27 | #define STORE32H(x, y) \ 28 | { \ 29 | (y)[0] = (uint8_t)(((x) >> 24) & 255); \ 30 | (y)[1] = (uint8_t)(((x) >> 16) & 255); \ 31 | (y)[2] = (uint8_t)(((x) >> 8) & 255); \ 32 | (y)[3] = (uint8_t)((x)&255); \ 33 | } 34 | 35 | #define LOAD32H(x, y) \ 36 | { \ 37 | x = ((uint32_t)((y)[0] & 255) << 24) | ((uint32_t)((y)[1] & 255) << 16) | \ 38 | ((uint32_t)((y)[2] & 255) << 8) | ((uint32_t)((y)[3] & 255)); \ 39 | } 40 | 41 | #define STORE64H(x, y) \ 42 | { \ 43 | (y)[0] = (uint8_t)(((x) >> 56) & 255); \ 44 | (y)[1] = (uint8_t)(((x) >> 48) & 255); \ 45 | (y)[2] = (uint8_t)(((x) >> 40) & 255); \ 46 | (y)[3] = (uint8_t)(((x) >> 32) & 255); \ 47 | (y)[4] = (uint8_t)(((x) >> 24) & 255); \ 48 | (y)[5] = (uint8_t)(((x) >> 16) & 255); \ 49 | (y)[6] = (uint8_t)(((x) >> 8) & 255); \ 50 | (y)[7] = (uint8_t)((x)&255); \ 51 | } 52 | 53 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 54 | // CONSTANTS 55 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 56 | 57 | // The K array 58 | static const uint32_t K[64] = { 59 | 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, 60 | 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, 61 | 0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 62 | 0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, 63 | 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL, 64 | 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL, 65 | 0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 66 | 0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, 67 | 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL, 68 | 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL, 69 | 0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 70 | 0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, 71 | 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL}; 72 | 73 | #define BLOCK_SIZE 64 74 | 75 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 76 | // INTERNAL FUNCTIONS 77 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 78 | 79 | // Various logical functions 80 | #define Ch(x, y, z) (z ^ (x & (y ^ z))) 81 | #define Maj(x, y, z) (((x | y) & z) | (x & y)) 82 | #define S(x, n) ror((x), (n)) 83 | #define R(x, n) (((x)&0xFFFFFFFFUL) >> (n)) 84 | #define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22)) 85 | #define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25)) 86 | #define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3)) 87 | #define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10)) 88 | 89 | #define Sha256Round(a, b, c, d, e, f, g, h, i) \ 90 | t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \ 91 | t1 = Sigma0(a) + Maj(a, b, c); \ 92 | d += t0; \ 93 | h = t0 + t1; 94 | 95 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 96 | // TransformFunction 97 | // 98 | // Compress 512-bits 99 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 100 | static void TransformFunction(Sha256Context* Context, uint8_t const* Buffer) { 101 | uint32_t S[8]; 102 | uint32_t W[64]; 103 | uint32_t t0; 104 | uint32_t t1; 105 | uint32_t t; 106 | int i; 107 | 108 | // Copy state into S 109 | for (i = 0; i < 8; i++) { 110 | S[i] = Context->state[i]; 111 | } 112 | 113 | // Copy the state into 512-bits into W[0..15] 114 | for (i = 0; i < 16; i++) { 115 | LOAD32H(W[i], Buffer + (4 * i)); 116 | } 117 | 118 | // Fill W[16..63] 119 | for (i = 16; i < 64; i++) { 120 | W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16]; 121 | } 122 | 123 | // Compress 124 | for (i = 0; i < 64; i++) { 125 | Sha256Round(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i); 126 | t = S[7]; 127 | S[7] = S[6]; 128 | S[6] = S[5]; 129 | S[5] = S[4]; 130 | S[4] = S[3]; 131 | S[3] = S[2]; 132 | S[2] = S[1]; 133 | S[1] = S[0]; 134 | S[0] = t; 135 | } 136 | 137 | // Feedback 138 | for (i = 0; i < 8; i++) { 139 | Context->state[i] = Context->state[i] + S[i]; 140 | } 141 | } 142 | 143 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 144 | // PUBLIC FUNCTIONS 145 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 146 | 147 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 148 | // Sha256Initialise 149 | // 150 | // Initialises a SHA256 Context. Use this to initialise/reset a context. 151 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 152 | void Sha256Initialise(Sha256Context* Context // [out] 153 | ) { 154 | Context->curlen = 0; 155 | Context->length = 0; 156 | Context->state[0] = 0x6A09E667UL; 157 | Context->state[1] = 0xBB67AE85UL; 158 | Context->state[2] = 0x3C6EF372UL; 159 | Context->state[3] = 0xA54FF53AUL; 160 | Context->state[4] = 0x510E527FUL; 161 | Context->state[5] = 0x9B05688CUL; 162 | Context->state[6] = 0x1F83D9ABUL; 163 | Context->state[7] = 0x5BE0CD19UL; 164 | } 165 | 166 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 167 | // Sha256Update 168 | // 169 | // Adds data to the SHA256 context. This will process the data and update the 170 | // internal state of the context. Keep on calling this function until all the 171 | // data has been added. Then call Sha256Finalise to calculate the hash. 172 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 173 | void Sha256Update(Sha256Context* Context, // [in out] 174 | void const* Buffer, // [in] 175 | uint32_t BufferSize // [in] 176 | ) { 177 | uint32_t n; 178 | 179 | if (Context->curlen > sizeof(Context->buf)) { 180 | return; 181 | } 182 | 183 | while (BufferSize > 0) { 184 | if (Context->curlen == 0 && BufferSize >= BLOCK_SIZE) { 185 | TransformFunction(Context, (uint8_t*)Buffer); 186 | Context->length += BLOCK_SIZE * 8; 187 | Buffer = (uint8_t*)Buffer + BLOCK_SIZE; 188 | BufferSize -= BLOCK_SIZE; 189 | } else { 190 | n = MIN(BufferSize, (BLOCK_SIZE - Context->curlen)); 191 | memcpy(Context->buf + Context->curlen, Buffer, (size_t)n); 192 | Context->curlen += n; 193 | Buffer = (uint8_t*)Buffer + n; 194 | BufferSize -= n; 195 | if (Context->curlen == BLOCK_SIZE) { 196 | TransformFunction(Context, Context->buf); 197 | Context->length += 8 * BLOCK_SIZE; 198 | Context->curlen = 0; 199 | } 200 | } 201 | } 202 | } 203 | 204 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 205 | // Sha256Finalise 206 | // 207 | // Performs the final calculation of the hash and returns the digest (32 byte 208 | // buffer containing 256bit hash). After calling this, Sha256Initialised must 209 | // be used to reuse the context. 210 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 211 | void Sha256Finalise(Sha256Context* Context, // [in out] 212 | SHA256_HASH* Digest // [out] 213 | ) { 214 | int i; 215 | 216 | if (Context->curlen >= sizeof(Context->buf)) { 217 | return; 218 | } 219 | 220 | // Increase the length of the message 221 | Context->length += Context->curlen * 8; 222 | 223 | // Append the '1' bit 224 | Context->buf[Context->curlen++] = (uint8_t)0x80; 225 | 226 | // if the length is currently above 56 bytes we append zeros 227 | // then compress. Then we can fall back to padding zeros and length 228 | // encoding like normal. 229 | if (Context->curlen > 56) { 230 | while (Context->curlen < 64) { 231 | Context->buf[Context->curlen++] = (uint8_t)0; 232 | } 233 | TransformFunction(Context, Context->buf); 234 | Context->curlen = 0; 235 | } 236 | 237 | // Pad up to 56 bytes of zeroes 238 | while (Context->curlen < 56) { 239 | Context->buf[Context->curlen++] = (uint8_t)0; 240 | } 241 | 242 | // Store length 243 | STORE64H(Context->length, Context->buf + 56); 244 | TransformFunction(Context, Context->buf); 245 | 246 | // Copy output 247 | for (i = 0; i < 8; i++) { 248 | STORE32H(Context->state[i], Digest->bytes + (4 * i)); 249 | } 250 | } 251 | 252 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 253 | // Sha256Calculate 254 | // 255 | // Combines Sha256Initialise, Sha256Update, and Sha256Finalise into one 256 | // function. Calculates the SHA256 hash of the buffer. 257 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 258 | void Sha256Calculate(void const* Buffer, // [in] 259 | uint32_t BufferSize, // [in] 260 | SHA256_HASH* Digest // [in] 261 | ) { 262 | Sha256Context context; 263 | 264 | Sha256Initialise(&context); 265 | Sha256Update(&context, Buffer, BufferSize); 266 | Sha256Finalise(&context, Digest); 267 | } 268 | -------------------------------------------------------------------------------- /x86/example.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {3e584710-d844-49e5-9938-b4efa4928b17} 25 | example 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v142 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | MultiByte 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | ./lib/nlohmann;./lib/curl;./lib;.\;$(IncludePath) 79 | ./lib/curl;.\;$(LibraryPath) 80 | 81 | 82 | true 83 | 84 | 85 | false 86 | ./lib;./lib/nlohmann;./lib/curl;.\;$(IncludePath) 87 | .\;$(LibraryPath) 88 | 89 | 90 | 91 | Level3 92 | true 93 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 94 | true 95 | 96 | 97 | Console 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | true 106 | true 107 | CURL_STATICLIB;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 108 | true 109 | stdcpp17 110 | 111 | 112 | Console 113 | true 114 | true 115 | true 116 | libcurl.lib;%(AdditionalDependencies) 117 | 118 | 119 | 120 | 121 | Level3 122 | true 123 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 124 | true 125 | stdcpp20 126 | 127 | 128 | Console 129 | true 130 | 131 | 132 | 133 | 134 | Level3 135 | true 136 | true 137 | true 138 | _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 139 | true 140 | stdcpp17 141 | MultiThreadedDLL 142 | 143 | 144 | Console 145 | true 146 | true 147 | false 148 | %(AdditionalDependencies) 149 | MachineX64 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/conversions/to_json.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // copy 4 | #include // begin, end 5 | #include // string 6 | #include // tuple, get 7 | #include // is_same, is_constructible, is_floating_point, is_enum, underlying_type 8 | #include // move, forward, declval, pair 9 | #include // valarray 10 | #include // vector 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace nlohmann 18 | { 19 | namespace detail 20 | { 21 | ////////////////// 22 | // constructors // 23 | ////////////////// 24 | 25 | template struct external_constructor; 26 | 27 | template<> 28 | struct external_constructor 29 | { 30 | template 31 | static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept 32 | { 33 | j.m_type = value_t::boolean; 34 | j.m_value = b; 35 | j.assert_invariant(); 36 | } 37 | }; 38 | 39 | template<> 40 | struct external_constructor 41 | { 42 | template 43 | static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s) 44 | { 45 | j.m_type = value_t::string; 46 | j.m_value = s; 47 | j.assert_invariant(); 48 | } 49 | 50 | template 51 | static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s) 52 | { 53 | j.m_type = value_t::string; 54 | j.m_value = std::move(s); 55 | j.assert_invariant(); 56 | } 57 | 58 | template < typename BasicJsonType, typename CompatibleStringType, 59 | enable_if_t < !std::is_same::value, 60 | int > = 0 > 61 | static void construct(BasicJsonType& j, const CompatibleStringType& str) 62 | { 63 | j.m_type = value_t::string; 64 | j.m_value.string = j.template create(str); 65 | j.assert_invariant(); 66 | } 67 | }; 68 | 69 | template<> 70 | struct external_constructor 71 | { 72 | template 73 | static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b) 74 | { 75 | j.m_type = value_t::binary; 76 | typename BasicJsonType::binary_t value{b}; 77 | j.m_value = value; 78 | j.assert_invariant(); 79 | } 80 | 81 | template 82 | static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b) 83 | { 84 | j.m_type = value_t::binary; 85 | typename BasicJsonType::binary_t value{std::move(b)}; 86 | j.m_value = value; 87 | j.assert_invariant(); 88 | } 89 | }; 90 | 91 | template<> 92 | struct external_constructor 93 | { 94 | template 95 | static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept 96 | { 97 | j.m_type = value_t::number_float; 98 | j.m_value = val; 99 | j.assert_invariant(); 100 | } 101 | }; 102 | 103 | template<> 104 | struct external_constructor 105 | { 106 | template 107 | static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept 108 | { 109 | j.m_type = value_t::number_unsigned; 110 | j.m_value = val; 111 | j.assert_invariant(); 112 | } 113 | }; 114 | 115 | template<> 116 | struct external_constructor 117 | { 118 | template 119 | static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept 120 | { 121 | j.m_type = value_t::number_integer; 122 | j.m_value = val; 123 | j.assert_invariant(); 124 | } 125 | }; 126 | 127 | template<> 128 | struct external_constructor 129 | { 130 | template 131 | static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr) 132 | { 133 | j.m_type = value_t::array; 134 | j.m_value = arr; 135 | j.assert_invariant(); 136 | } 137 | 138 | template 139 | static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr) 140 | { 141 | j.m_type = value_t::array; 142 | j.m_value = std::move(arr); 143 | j.assert_invariant(); 144 | } 145 | 146 | template < typename BasicJsonType, typename CompatibleArrayType, 147 | enable_if_t < !std::is_same::value, 148 | int > = 0 > 149 | static void construct(BasicJsonType& j, const CompatibleArrayType& arr) 150 | { 151 | using std::begin; 152 | using std::end; 153 | j.m_type = value_t::array; 154 | j.m_value.array = j.template create(begin(arr), end(arr)); 155 | j.assert_invariant(); 156 | } 157 | 158 | template 159 | static void construct(BasicJsonType& j, const std::vector& arr) 160 | { 161 | j.m_type = value_t::array; 162 | j.m_value = value_t::array; 163 | j.m_value.array->reserve(arr.size()); 164 | for (const bool x : arr) 165 | { 166 | j.m_value.array->push_back(x); 167 | } 168 | j.assert_invariant(); 169 | } 170 | 171 | template::value, int> = 0> 173 | static void construct(BasicJsonType& j, const std::valarray& arr) 174 | { 175 | j.m_type = value_t::array; 176 | j.m_value = value_t::array; 177 | j.m_value.array->resize(arr.size()); 178 | if (arr.size() > 0) 179 | { 180 | std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); 181 | } 182 | j.assert_invariant(); 183 | } 184 | }; 185 | 186 | template<> 187 | struct external_constructor 188 | { 189 | template 190 | static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj) 191 | { 192 | j.m_type = value_t::object; 193 | j.m_value = obj; 194 | j.assert_invariant(); 195 | } 196 | 197 | template 198 | static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj) 199 | { 200 | j.m_type = value_t::object; 201 | j.m_value = std::move(obj); 202 | j.assert_invariant(); 203 | } 204 | 205 | template < typename BasicJsonType, typename CompatibleObjectType, 206 | enable_if_t < !std::is_same::value, int > = 0 > 207 | static void construct(BasicJsonType& j, const CompatibleObjectType& obj) 208 | { 209 | using std::begin; 210 | using std::end; 211 | 212 | j.m_type = value_t::object; 213 | j.m_value.object = j.template create(begin(obj), end(obj)); 214 | j.assert_invariant(); 215 | } 216 | }; 217 | 218 | ///////////// 219 | // to_json // 220 | ///////////// 221 | 222 | template::value, int> = 0> 224 | void to_json(BasicJsonType& j, T b) noexcept 225 | { 226 | external_constructor::construct(j, b); 227 | } 228 | 229 | template::value, int> = 0> 231 | void to_json(BasicJsonType& j, const CompatibleString& s) 232 | { 233 | external_constructor::construct(j, s); 234 | } 235 | 236 | template 237 | void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s) 238 | { 239 | external_constructor::construct(j, std::move(s)); 240 | } 241 | 242 | template::value, int> = 0> 244 | void to_json(BasicJsonType& j, FloatType val) noexcept 245 | { 246 | external_constructor::construct(j, static_cast(val)); 247 | } 248 | 249 | template::value, int> = 0> 251 | void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept 252 | { 253 | external_constructor::construct(j, static_cast(val)); 254 | } 255 | 256 | template::value, int> = 0> 258 | void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept 259 | { 260 | external_constructor::construct(j, static_cast(val)); 261 | } 262 | 263 | template::value, int> = 0> 265 | void to_json(BasicJsonType& j, EnumType e) noexcept 266 | { 267 | using underlying_type = typename std::underlying_type::type; 268 | external_constructor::construct(j, static_cast(e)); 269 | } 270 | 271 | template 272 | void to_json(BasicJsonType& j, const std::vector& e) 273 | { 274 | external_constructor::construct(j, e); 275 | } 276 | 277 | template < typename BasicJsonType, typename CompatibleArrayType, 278 | enable_if_t < is_compatible_array_type::value&& 280 | !is_compatible_object_type::value&& 281 | !is_compatible_string_type::value&& 282 | !std::is_same::value&& 283 | !is_basic_json::value, 284 | int > = 0 > 285 | void to_json(BasicJsonType& j, const CompatibleArrayType& arr) 286 | { 287 | external_constructor::construct(j, arr); 288 | } 289 | 290 | template 291 | void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin) 292 | { 293 | external_constructor::construct(j, bin); 294 | } 295 | 296 | template::value, int> = 0> 298 | void to_json(BasicJsonType& j, const std::valarray& arr) 299 | { 300 | external_constructor::construct(j, std::move(arr)); 301 | } 302 | 303 | template 304 | void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) 305 | { 306 | external_constructor::construct(j, std::move(arr)); 307 | } 308 | 309 | template < typename BasicJsonType, typename CompatibleObjectType, 310 | enable_if_t < is_compatible_object_type::value&& !is_basic_json::value, int > = 0 > 311 | void to_json(BasicJsonType& j, const CompatibleObjectType& obj) 312 | { 313 | external_constructor::construct(j, obj); 314 | } 315 | 316 | template 317 | void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) 318 | { 319 | external_constructor::construct(j, std::move(obj)); 320 | } 321 | 322 | template < 323 | typename BasicJsonType, typename T, std::size_t N, 324 | enable_if_t < !std::is_constructible::value, 326 | int > = 0 > 327 | void to_json(BasicJsonType& j, const T(&arr)[N]) 328 | { 329 | external_constructor::construct(j, arr); 330 | } 331 | 332 | template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible::value&& std::is_constructible::value, int > = 0 > 333 | void to_json(BasicJsonType& j, const std::pair& p) 334 | { 335 | j = { p.first, p.second }; 336 | } 337 | 338 | // for https://github.com/nlohmann/json/pull/1134 339 | template>::value, int> = 0> 341 | void to_json(BasicJsonType& j, const T& b) 342 | { 343 | j = { {b.key(), b.value()} }; 344 | } 345 | 346 | template 347 | void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence /*unused*/) 348 | { 349 | j = { std::get(t)... }; 350 | } 351 | 352 | template::value, int > = 0> 353 | void to_json(BasicJsonType& j, const T& t) 354 | { 355 | to_json_tuple_impl(j, t, make_index_sequence::value> {}); 356 | } 357 | 358 | struct to_json_fn 359 | { 360 | template 361 | auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward(val)))) 362 | -> decltype(to_json(j, std::forward(val)), void()) 363 | { 364 | return to_json(j, std::forward(val)); 365 | } 366 | }; 367 | } // namespace detail 368 | 369 | /// namespace to hold default `to_json` function 370 | namespace 371 | { 372 | constexpr const auto& to_json = detail::static_const::value; 373 | } // namespace 374 | } // namespace nlohmann 375 | -------------------------------------------------------------------------------- /x86/lib/nlohmann/detail/conversions/from_json.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // transform 4 | #include // array 5 | #include // forward_list 6 | #include // inserter, front_inserter, end 7 | #include // map 8 | #include // string 9 | #include // tuple, make_tuple 10 | #include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible 11 | #include // unordered_map 12 | #include // pair, declval 13 | #include // valarray 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | namespace nlohmann 22 | { 23 | namespace detail 24 | { 25 | template 26 | void from_json(const BasicJsonType& j, typename std::nullptr_t& n) 27 | { 28 | if (JSON_HEDLEY_UNLIKELY(!j.is_null())) 29 | { 30 | JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()))); 31 | } 32 | n = nullptr; 33 | } 34 | 35 | // overloads for basic_json template parameters 36 | template < typename BasicJsonType, typename ArithmeticType, 37 | enable_if_t < std::is_arithmetic::value&& 38 | !std::is_same::value, 39 | int > = 0 > 40 | void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) 41 | { 42 | switch (static_cast(j)) 43 | { 44 | case value_t::number_unsigned: 45 | { 46 | val = static_cast(*j.template get_ptr()); 47 | break; 48 | } 49 | case value_t::number_integer: 50 | { 51 | val = static_cast(*j.template get_ptr()); 52 | break; 53 | } 54 | case value_t::number_float: 55 | { 56 | val = static_cast(*j.template get_ptr()); 57 | break; 58 | } 59 | 60 | default: 61 | JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()))); 62 | } 63 | } 64 | 65 | template 66 | void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) 67 | { 68 | if (JSON_HEDLEY_UNLIKELY(!j.is_boolean())) 69 | { 70 | JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()))); 71 | } 72 | b = *j.template get_ptr(); 73 | } 74 | 75 | template 76 | void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) 77 | { 78 | if (JSON_HEDLEY_UNLIKELY(!j.is_string())) 79 | { 80 | JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); 81 | } 82 | s = *j.template get_ptr(); 83 | } 84 | 85 | template < 86 | typename BasicJsonType, typename ConstructibleStringType, 87 | enable_if_t < 88 | is_constructible_string_type::value&& 89 | !std::is_same::value, 91 | int > = 0 > 92 | void from_json(const BasicJsonType& j, ConstructibleStringType& s) 93 | { 94 | if (JSON_HEDLEY_UNLIKELY(!j.is_string())) 95 | { 96 | JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); 97 | } 98 | 99 | s = *j.template get_ptr(); 100 | } 101 | 102 | template 103 | void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val) 104 | { 105 | get_arithmetic_value(j, val); 106 | } 107 | 108 | template 109 | void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val) 110 | { 111 | get_arithmetic_value(j, val); 112 | } 113 | 114 | template 115 | void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val) 116 | { 117 | get_arithmetic_value(j, val); 118 | } 119 | 120 | template::value, int> = 0> 122 | void from_json(const BasicJsonType& j, EnumType& e) 123 | { 124 | typename std::underlying_type::type val; 125 | get_arithmetic_value(j, val); 126 | e = static_cast(val); 127 | } 128 | 129 | // forward_list doesn't have an insert method 130 | template::value, int> = 0> 132 | void from_json(const BasicJsonType& j, std::forward_list& l) 133 | { 134 | if (JSON_HEDLEY_UNLIKELY(!j.is_array())) 135 | { 136 | JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); 137 | } 138 | l.clear(); 139 | std::transform(j.rbegin(), j.rend(), 140 | std::front_inserter(l), [](const BasicJsonType & i) 141 | { 142 | return i.template get(); 143 | }); 144 | } 145 | 146 | // valarray doesn't have an insert method 147 | template::value, int> = 0> 149 | void from_json(const BasicJsonType& j, std::valarray& l) 150 | { 151 | if (JSON_HEDLEY_UNLIKELY(!j.is_array())) 152 | { 153 | JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); 154 | } 155 | l.resize(j.size()); 156 | std::transform(j.begin(), j.end(), std::begin(l), 157 | [](const BasicJsonType & elem) 158 | { 159 | return elem.template get(); 160 | }); 161 | } 162 | 163 | template 164 | auto from_json(const BasicJsonType& j, T (&arr)[N]) 165 | -> decltype(j.template get(), void()) 166 | { 167 | for (std::size_t i = 0; i < N; ++i) 168 | { 169 | arr[i] = j.at(i).template get(); 170 | } 171 | } 172 | 173 | template 174 | void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/) 175 | { 176 | arr = *j.template get_ptr(); 177 | } 178 | 179 | template 180 | auto from_json_array_impl(const BasicJsonType& j, std::array& arr, 181 | priority_tag<2> /*unused*/) 182 | -> decltype(j.template get(), void()) 183 | { 184 | for (std::size_t i = 0; i < N; ++i) 185 | { 186 | arr[i] = j.at(i).template get(); 187 | } 188 | } 189 | 190 | template 191 | auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/) 192 | -> decltype( 193 | arr.reserve(std::declval()), 194 | j.template get(), 195 | void()) 196 | { 197 | using std::end; 198 | 199 | ConstructibleArrayType ret; 200 | ret.reserve(j.size()); 201 | std::transform(j.begin(), j.end(), 202 | std::inserter(ret, end(ret)), [](const BasicJsonType & i) 203 | { 204 | // get() returns *this, this won't call a from_json 205 | // method when value_type is BasicJsonType 206 | return i.template get(); 207 | }); 208 | arr = std::move(ret); 209 | } 210 | 211 | template 212 | void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, 213 | priority_tag<0> /*unused*/) 214 | { 215 | using std::end; 216 | 217 | ConstructibleArrayType ret; 218 | std::transform( 219 | j.begin(), j.end(), std::inserter(ret, end(ret)), 220 | [](const BasicJsonType & i) 221 | { 222 | // get() returns *this, this won't call a from_json 223 | // method when value_type is BasicJsonType 224 | return i.template get(); 225 | }); 226 | arr = std::move(ret); 227 | } 228 | 229 | template < typename BasicJsonType, typename ConstructibleArrayType, 230 | enable_if_t < 231 | is_constructible_array_type::value&& 232 | !is_constructible_object_type::value&& 233 | !is_constructible_string_type::value&& 234 | !std::is_same::value&& 235 | !is_basic_json::value, 236 | int > = 0 > 237 | auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) 238 | -> decltype(from_json_array_impl(j, arr, priority_tag<3> {}), 239 | j.template get(), 240 | void()) 241 | { 242 | if (JSON_HEDLEY_UNLIKELY(!j.is_array())) 243 | { 244 | JSON_THROW(type_error::create(302, "type must be array, but is " + 245 | std::string(j.type_name()))); 246 | } 247 | 248 | from_json_array_impl(j, arr, priority_tag<3> {}); 249 | } 250 | 251 | template 252 | void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin) 253 | { 254 | if (JSON_HEDLEY_UNLIKELY(!j.is_binary())) 255 | { 256 | JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(j.type_name()))); 257 | } 258 | 259 | bin = *j.template get_ptr(); 260 | } 261 | 262 | template::value, int> = 0> 264 | void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) 265 | { 266 | if (JSON_HEDLEY_UNLIKELY(!j.is_object())) 267 | { 268 | JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()))); 269 | } 270 | 271 | ConstructibleObjectType ret; 272 | auto inner_object = j.template get_ptr(); 273 | using value_type = typename ConstructibleObjectType::value_type; 274 | std::transform( 275 | inner_object->begin(), inner_object->end(), 276 | std::inserter(ret, ret.begin()), 277 | [](typename BasicJsonType::object_t::value_type const & p) 278 | { 279 | return value_type(p.first, p.second.template get()); 280 | }); 281 | obj = std::move(ret); 282 | } 283 | 284 | // overload for arithmetic types, not chosen for basic_json template arguments 285 | // (BooleanType, etc..); note: Is it really necessary to provide explicit 286 | // overloads for boolean_t etc. in case of a custom BooleanType which is not 287 | // an arithmetic type? 288 | template < typename BasicJsonType, typename ArithmeticType, 289 | enable_if_t < 290 | std::is_arithmetic::value&& 291 | !std::is_same::value&& 292 | !std::is_same::value&& 293 | !std::is_same::value&& 294 | !std::is_same::value, 295 | int > = 0 > 296 | void from_json(const BasicJsonType& j, ArithmeticType& val) 297 | { 298 | switch (static_cast(j)) 299 | { 300 | case value_t::number_unsigned: 301 | { 302 | val = static_cast(*j.template get_ptr()); 303 | break; 304 | } 305 | case value_t::number_integer: 306 | { 307 | val = static_cast(*j.template get_ptr()); 308 | break; 309 | } 310 | case value_t::number_float: 311 | { 312 | val = static_cast(*j.template get_ptr()); 313 | break; 314 | } 315 | case value_t::boolean: 316 | { 317 | val = static_cast(*j.template get_ptr()); 318 | break; 319 | } 320 | 321 | default: 322 | JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()))); 323 | } 324 | } 325 | 326 | template 327 | void from_json(const BasicJsonType& j, std::pair& p) 328 | { 329 | p = {j.at(0).template get(), j.at(1).template get()}; 330 | } 331 | 332 | template 333 | void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence /*unused*/) 334 | { 335 | t = std::make_tuple(j.at(Idx).template get::type>()...); 336 | } 337 | 338 | template 339 | void from_json(const BasicJsonType& j, std::tuple& t) 340 | { 341 | from_json_tuple_impl(j, t, index_sequence_for {}); 342 | } 343 | 344 | template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, 345 | typename = enable_if_t < !std::is_constructible < 346 | typename BasicJsonType::string_t, Key >::value >> 347 | void from_json(const BasicJsonType& j, std::map& m) 348 | { 349 | if (JSON_HEDLEY_UNLIKELY(!j.is_array())) 350 | { 351 | JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); 352 | } 353 | m.clear(); 354 | for (const auto& p : j) 355 | { 356 | if (JSON_HEDLEY_UNLIKELY(!p.is_array())) 357 | { 358 | JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); 359 | } 360 | m.emplace(p.at(0).template get(), p.at(1).template get()); 361 | } 362 | } 363 | 364 | template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator, 365 | typename = enable_if_t < !std::is_constructible < 366 | typename BasicJsonType::string_t, Key >::value >> 367 | void from_json(const BasicJsonType& j, std::unordered_map& m) 368 | { 369 | if (JSON_HEDLEY_UNLIKELY(!j.is_array())) 370 | { 371 | JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); 372 | } 373 | m.clear(); 374 | for (const auto& p : j) 375 | { 376 | if (JSON_HEDLEY_UNLIKELY(!p.is_array())) 377 | { 378 | JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); 379 | } 380 | m.emplace(p.at(0).template get(), p.at(1).template get()); 381 | } 382 | } 383 | 384 | struct from_json_fn 385 | { 386 | template 387 | auto operator()(const BasicJsonType& j, T& val) const 388 | noexcept(noexcept(from_json(j, val))) 389 | -> decltype(from_json(j, val), void()) 390 | { 391 | return from_json(j, val); 392 | } 393 | }; 394 | } // namespace detail 395 | 396 | /// namespace to hold default `from_json` function 397 | /// to see why this is required: 398 | /// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html 399 | namespace 400 | { 401 | constexpr const auto& from_json = detail::static_const::value; 402 | } // namespace 403 | } // namespace nlohmann 404 | --------------------------------------------------------------------------------