├── .gitignore ├── CHANGELOG.md ├── CMakeLists.txt ├── LICENSE ├── README.md ├── bin └── WinRing0 │ ├── LICENSE │ └── WinRing0x64.sys ├── cmake ├── FindHWLOC.cmake ├── FindUV.cmake ├── OpenSSL.cmake ├── argon2.cmake ├── asm.cmake ├── cpu.cmake ├── flags.cmake ├── os.cmake └── randomx.cmake ├── doc ├── ALGORITHMS.md ├── API.md ├── CHANGELOG.md ├── CHANGELOG_OLD.md ├── CPU.md ├── CPU_MAX_USAGE.md ├── PERSISTENT_OPTIONS.md ├── api │ └── 1 │ │ ├── config.json │ │ ├── summary.json │ │ └── threads.json ├── build │ └── CMAKE_OPTIONS.md ├── building.md ├── gpg_keys │ └── xmrig.asc ├── releases │ └── 5_0_1 │ │ ├── SHA256SUMS │ │ └── SHA256SUMS.sig ├── screenshot_v5.png └── topology │ ├── AMD_FX_8320_windows_2_0_4.xml │ ├── AMD_Opteron_6272_x4_N8_linux_2_0_4_LXC.xml │ ├── AMD_Opteron_6278_x2_UMA_windows_2_0_4.xml │ ├── AMD_Opteron_6344_x2_N4_win7_2_0_4_bug.xml │ ├── AMD_Opteron_6348_x4_N8_linux_1_11_2.xml │ ├── AMD_Opteron_6348_x4_N8_linux_2_0_4.xml │ ├── AMD_Opteron_6380_x4_N8_linux_1_11_5.xml │ ├── AMD_Ryzen_7_2700X_windows_2_0_4.xml │ ├── AMD_Ryzen_7_3700X_windows_2_0_4.xml │ ├── AMD_Ryzen_Threadripper_2950X_N2_linux_2_0_4.xml │ ├── AMD_Ryzen_Threadripper_2950X_UMA_linux_1_11_9.xml │ ├── Intel_Core_i7-3770_linux_2_0_4.xml │ ├── Intel_Core_i7-6700_linux_2_0_4.xml │ ├── Intel_Core_i7-6700_windows_2_0_4.xml │ ├── Intel_Core_i7-7660U_windows_2_0_4.xml │ ├── Intel_Xeon_E5-4650_0_x4_N4_windows_2_0_4.xml │ ├── Intel_Xeon_E5620_x2_UMA_windows_2_0_4.xml │ ├── Intel_Xeon_E7-4870_x4_N4_windows_2_0_4.xml │ ├── Intel_Xeon_Gold_6146_x2_UMA_linux_2_0_4.xml │ ├── Intel_Xeon_Silver_4114_x2_N2_linux_1_11_9.xml │ └── Intel_Xeon_Silver_4114_x2_N2_linux_2_0_4.xml ├── package.json ├── res ├── app.ico └── app.rc ├── scripts ├── benchmark_10M.cmd ├── benchmark_1M.cmd ├── build.hwloc.sh ├── build.libressl.sh ├── build.libressl_win.sh ├── build.openssl3.sh ├── build.uv.sh ├── build_deps.sh ├── enable_1gb_pages.sh ├── generate_cl.js ├── js │ ├── opencl.js │ └── opencl_minify.js ├── pool_mine_example.cmd ├── randomx_boost.sh └── solo_mine_example.cmd └── src ├── 3rdparty ├── adl │ ├── adl_defines.h │ ├── adl_sdk.h │ └── adl_structures.h ├── argon2.h ├── argon2 │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── arch │ │ ├── generic │ │ │ └── lib │ │ │ │ └── argon2-arch.c │ │ └── x86_64 │ │ │ ├── lib │ │ │ ├── argon2-arch.c │ │ │ ├── argon2-avx2.c │ │ │ ├── argon2-avx2.h │ │ │ ├── argon2-avx512f.c │ │ │ ├── argon2-avx512f.h │ │ │ ├── argon2-sse2.c │ │ │ ├── argon2-sse2.h │ │ │ ├── argon2-ssse3.c │ │ │ ├── argon2-ssse3.h │ │ │ ├── argon2-template-128.h │ │ │ ├── argon2-xop.c │ │ │ └── argon2-xop.h │ │ │ └── src │ │ │ ├── test-feature-avx2.c │ │ │ ├── test-feature-avx512f.c │ │ │ ├── test-feature-sse2.c │ │ │ ├── test-feature-ssse3.c │ │ │ └── test-feature-xop.c │ ├── include │ │ └── argon2.h │ └── lib │ │ ├── argon2-template-64.h │ │ ├── argon2.c │ │ ├── blake2 │ │ ├── blake2-impl.h │ │ ├── blake2.c │ │ └── blake2.h │ │ ├── core.c │ │ ├── core.h │ │ ├── encoding.c │ │ ├── encoding.h │ │ ├── genkat.c │ │ ├── genkat.h │ │ ├── impl-select.c │ │ └── impl-select.h ├── base32 │ └── base32.h ├── cl.h ├── fmt │ ├── LICENSE.rst │ ├── README.rst │ ├── chrono.h │ ├── color.h │ ├── compile.h │ ├── core.h │ ├── format-inl.h │ ├── format.cc │ ├── format.h │ ├── locale.h │ ├── os.cc │ ├── os.h │ ├── ostream.h │ ├── posix.h │ ├── printf.h │ └── ranges.h ├── getopt │ └── getopt.h ├── http-parser │ ├── AUTHORS │ ├── LICENSE-MIT │ ├── README.md │ ├── http_parser.c │ └── http_parser.h ├── hwloc │ ├── AUTHORS │ ├── CMakeLists.txt │ ├── COPYING │ ├── NEWS │ ├── README │ ├── VERSION │ ├── include │ │ ├── hwloc.h │ │ ├── hwloc │ │ │ ├── autogen │ │ │ │ └── config.h │ │ │ ├── bitmap.h │ │ │ ├── cpukinds.h │ │ │ ├── cuda.h │ │ │ ├── cudart.h │ │ │ ├── deprecated.h │ │ │ ├── diff.h │ │ │ ├── distances.h │ │ │ ├── export.h │ │ │ ├── gl.h │ │ │ ├── glibc-sched.h │ │ │ ├── helper.h │ │ │ ├── inlines.h │ │ │ ├── intel-mic.h │ │ │ ├── linux-libnuma.h │ │ │ ├── linux.h │ │ │ ├── memattrs.h │ │ │ ├── nvml.h │ │ │ ├── opencl.h │ │ │ ├── openfabrics-verbs.h │ │ │ ├── plugins.h │ │ │ ├── rename.h │ │ │ ├── rsmi.h │ │ │ └── shmem.h │ │ └── private │ │ │ ├── autogen │ │ │ └── config.h │ │ │ ├── components.h │ │ │ ├── cpuid-x86.h │ │ │ ├── debug.h │ │ │ ├── internal-components.h │ │ │ ├── misc.h │ │ │ ├── netloc.h │ │ │ ├── private.h │ │ │ ├── solaris-chiptype.h │ │ │ └── xml.h │ └── src │ │ ├── base64.c │ │ ├── bind.c │ │ ├── bitmap.c │ │ ├── components.c │ │ ├── cpukinds.c │ │ ├── diff.c │ │ ├── distances.c │ │ ├── memattrs.c │ │ ├── misc.c │ │ ├── pci-common.c │ │ ├── shmem.c │ │ ├── static-components.h │ │ ├── topology-noos.c │ │ ├── topology-synthetic.c │ │ ├── topology-windows.c │ │ ├── topology-x86.c │ │ ├── topology-xml-nolibxml.c │ │ ├── topology-xml.c │ │ ├── topology.c │ │ └── traversal.c ├── libethash │ ├── CMakeLists.txt │ ├── data_sizes.h │ ├── endian.h │ ├── ethash.h │ ├── ethash_internal.c │ ├── ethash_internal.h │ ├── fnv.h │ └── keccakf800.c ├── llhttp │ ├── LICENSE-MIT │ ├── README.md │ ├── api.c │ ├── api.h │ ├── http.c │ ├── llhttp.c │ └── llhttp.h └── rapidjson │ ├── allocators.h │ ├── cursorstreamwrapper.h │ ├── document.h │ ├── encodedstream.h │ ├── encodings.h │ ├── error │ ├── en.h │ └── error.h │ ├── filereadstream.h │ ├── filewritestream.h │ ├── fwd.h │ ├── internal │ ├── biginteger.h │ ├── diyfp.h │ ├── dtoa.h │ ├── ieee754.h │ ├── itoa.h │ ├── meta.h │ ├── pow10.h │ ├── regex.h │ ├── stack.h │ ├── strfunc.h │ ├── strtod.h │ └── swap.h │ ├── istreamwrapper.h │ ├── license.txt │ ├── memorybuffer.h │ ├── memorystream.h │ ├── msinttypes │ ├── inttypes.h │ └── stdint.h │ ├── ostreamwrapper.h │ ├── pointer.h │ ├── prettywriter.h │ ├── rapidjson.h │ ├── reader.h │ ├── schema.h │ ├── stream.h │ ├── stringbuffer.h │ └── writer.h ├── App.cpp ├── App.h ├── App_unix.cpp ├── App_win.cpp ├── Summary.cpp ├── Summary.h ├── backend ├── backend.cmake ├── common │ ├── Hashrate.cpp │ ├── Hashrate.h │ ├── HashrateInterpolator.cpp │ ├── HashrateInterpolator.h │ ├── Tags.h │ ├── Thread.h │ ├── Threads.cpp │ ├── Threads.h │ ├── Worker.cpp │ ├── Worker.h │ ├── WorkerJob.h │ ├── Workers.cpp │ ├── Workers.h │ ├── common.cmake │ ├── interfaces │ │ ├── IBackend.h │ │ ├── IBenchListener.h │ │ ├── IMemoryPool.h │ │ ├── IRxListener.h │ │ ├── IRxStorage.h │ │ └── IWorker.h │ └── misc │ │ └── PciTopology.h └── cpu │ ├── Cpu.cpp │ ├── Cpu.h │ ├── CpuBackend.cpp │ ├── CpuBackend.h │ ├── CpuConfig.cpp │ ├── CpuConfig.h │ ├── CpuConfig_gen.h │ ├── CpuLaunchData.cpp │ ├── CpuLaunchData.h │ ├── CpuThread.cpp │ ├── CpuThread.h │ ├── CpuThreads.cpp │ ├── CpuThreads.h │ ├── CpuWorker.cpp │ ├── CpuWorker.h │ ├── cpu.cmake │ ├── interfaces │ └── ICpuInfo.h │ └── platform │ ├── BasicCpuInfo.cpp │ ├── BasicCpuInfo.h │ ├── BasicCpuInfo_arm.cpp │ ├── HwlocCpuInfo.cpp │ ├── HwlocCpuInfo.h │ └── lscpu_arm.cpp ├── base ├── api │ ├── Api.cpp │ ├── Api.h │ ├── Httpd.cpp │ ├── Httpd.h │ ├── interfaces │ │ ├── IApiListener.h │ │ └── IApiRequest.h │ └── requests │ │ ├── ApiRequest.cpp │ │ ├── ApiRequest.h │ │ ├── HttpApiRequest.cpp │ │ └── HttpApiRequest.h ├── base.cmake ├── crypto │ ├── Algorithm.cpp │ ├── Algorithm.h │ ├── Coin.cpp │ ├── Coin.h │ ├── keccak.cpp │ ├── keccak.h │ ├── sha3.cpp │ └── sha3.h ├── io │ ├── Async.cpp │ ├── Async.h │ ├── Console.cpp │ ├── Console.h │ ├── Env.cpp │ ├── Env.h │ ├── Signals.cpp │ ├── Signals.h │ ├── Watcher.cpp │ ├── Watcher.h │ ├── json │ │ ├── Json.cpp │ │ ├── Json.h │ │ ├── JsonChain.cpp │ │ ├── JsonChain.h │ │ ├── JsonRequest.cpp │ │ ├── JsonRequest.h │ │ ├── Json_unix.cpp │ │ └── Json_win.cpp │ └── log │ │ ├── FileLogWriter.cpp │ │ ├── FileLogWriter.h │ │ ├── Log.cpp │ │ ├── Log.h │ │ ├── Tags.cpp │ │ ├── Tags.h │ │ └── backends │ │ ├── ConsoleLog.cpp │ │ ├── ConsoleLog.h │ │ ├── FileLog.cpp │ │ ├── FileLog.h │ │ ├── SysLog.cpp │ │ └── SysLog.h ├── kernel │ ├── Base.cpp │ ├── Base.h │ ├── Entry.cpp │ ├── Entry.h │ ├── Platform.cpp │ ├── Platform.h │ ├── Platform_hwloc.cpp │ ├── Platform_mac.cpp │ ├── Platform_unix.cpp │ ├── Platform_win.cpp │ ├── Process.cpp │ ├── Process.h │ ├── Process_unix.cpp │ ├── Process_win.cpp │ ├── config │ │ ├── BaseConfig.cpp │ │ ├── BaseConfig.h │ │ ├── BaseTransform.cpp │ │ ├── BaseTransform.h │ │ ├── Title.cpp │ │ └── Title.h │ ├── constants.h │ └── interfaces │ │ ├── IAsyncListener.h │ │ ├── IBaseListener.h │ │ ├── IClient.h │ │ ├── IClientListener.h │ │ ├── IConfig.h │ │ ├── IConfigListener.h │ │ ├── IConfigTransform.h │ │ ├── IConsoleListener.h │ │ ├── IDnsListener.h │ │ ├── IHttpListener.h │ │ ├── IJsonReader.h │ │ ├── ILineListener.h │ │ ├── ILogBackend.h │ │ ├── ISignalListener.h │ │ ├── IStrategy.h │ │ ├── IStrategyListener.h │ │ ├── ITcpServerListener.h │ │ ├── ITimerListener.h │ │ └── IWatcherListener.h ├── net │ ├── dns │ │ ├── Dns.cpp │ │ ├── Dns.h │ │ ├── DnsRecord.cpp │ │ └── DnsRecord.h │ ├── http │ │ ├── Fetch.cpp │ │ ├── Fetch.h │ │ ├── Http.cpp │ │ ├── Http.h │ │ ├── HttpApiResponse.cpp │ │ ├── HttpApiResponse.h │ │ ├── HttpClient.cpp │ │ ├── HttpClient.h │ │ ├── HttpContext.cpp │ │ ├── HttpContext.h │ │ ├── HttpData.cpp │ │ ├── HttpData.h │ │ ├── HttpListener.cpp │ │ ├── HttpListener.h │ │ ├── HttpResponse.cpp │ │ ├── HttpResponse.h │ │ ├── HttpServer.cpp │ │ └── HttpServer.h │ ├── https │ │ ├── HttpsClient.cpp │ │ ├── HttpsClient.h │ │ ├── HttpsContext.cpp │ │ ├── HttpsContext.h │ │ ├── HttpsServer.cpp │ │ └── HttpsServer.h │ ├── stratum │ │ ├── AutoClient.cpp │ │ ├── AutoClient.h │ │ ├── BaseClient.cpp │ │ ├── BaseClient.h │ │ ├── Client.cpp │ │ ├── Client.h │ │ ├── DaemonClient.cpp │ │ ├── DaemonClient.h │ │ ├── EthStratumClient.cpp │ │ ├── EthStratumClient.h │ │ ├── Job.cpp │ │ ├── Job.h │ │ ├── NetworkState.cpp │ │ ├── NetworkState.h │ │ ├── Pool.cpp │ │ ├── Pool.h │ │ ├── Pools.cpp │ │ ├── Pools.h │ │ ├── ProxyUrl.cpp │ │ ├── ProxyUrl.h │ │ ├── SelfSelectClient.cpp │ │ ├── SelfSelectClient.h │ │ ├── Socks5.cpp │ │ ├── Socks5.h │ │ ├── SubmitResult.h │ │ ├── Tls.cpp │ │ ├── Tls.h │ │ ├── Url.cpp │ │ ├── Url.h │ │ └── strategies │ │ │ ├── FailoverStrategy.cpp │ │ │ ├── FailoverStrategy.h │ │ │ ├── SinglePoolStrategy.cpp │ │ │ ├── SinglePoolStrategy.h │ │ │ └── StrategyProxy.h │ ├── tls │ │ ├── ServerTls.cpp │ │ ├── ServerTls.h │ │ ├── TlsConfig.cpp │ │ ├── TlsConfig.h │ │ ├── TlsContext.cpp │ │ ├── TlsContext.h │ │ ├── TlsGen.cpp │ │ └── TlsGen.h │ └── tools │ │ ├── LineReader.cpp │ │ ├── LineReader.h │ │ ├── MemPool.h │ │ ├── NetBuffer.cpp │ │ ├── NetBuffer.h │ │ ├── Storage.h │ │ ├── TcpServer.cpp │ │ └── TcpServer.h └── tools │ ├── Arguments.cpp │ ├── Arguments.h │ ├── Baton.h │ ├── Buffer.h │ ├── Chrono.h │ ├── Cvt.cpp │ ├── Cvt.h │ ├── Handle.h │ ├── Object.h │ ├── String.cpp │ ├── String.h │ ├── Timer.cpp │ └── Timer.h ├── config.json ├── core ├── Controller.cpp ├── Controller.h ├── Miner.cpp ├── Miner.h └── config │ ├── Config.cpp │ ├── Config.h │ ├── ConfigTransform.cpp │ ├── ConfigTransform.h │ ├── Config_default.h │ ├── Config_platform.h │ └── usage.h ├── crypto ├── argon2 │ ├── Hash.h │ ├── Impl.cpp │ └── Impl.h ├── astrobwt │ ├── AstroBWT.cpp │ ├── AstroBWT.h │ ├── Salsa20.cpp │ ├── Salsa20.hpp │ ├── salsa20_ref │ │ ├── ecrypt-config.h │ │ ├── ecrypt-machine.h │ │ ├── ecrypt-portable.h │ │ ├── ecrypt-sync.h │ │ └── salsa20.c │ ├── sha3_256_avx2.S │ ├── sha3_256_avx2.asm │ ├── sha3_256_avx2.inc │ └── sha3_256_keccakf1600_avx2.inc ├── cn │ ├── CnAlgo.h │ ├── CnCtx.cpp │ ├── CnCtx.h │ ├── CnHash.cpp │ ├── CnHash.h │ ├── CryptoNight.h │ ├── CryptoNight_arm.h │ ├── CryptoNight_monero.h │ ├── CryptoNight_test.h │ ├── CryptoNight_x86.h │ ├── asm │ │ ├── CryptonightR_soft_aes_template.inc │ │ ├── CryptonightR_soft_aes_template_win.inc │ │ ├── CryptonightR_template.S │ │ ├── CryptonightR_template.asm │ │ ├── CryptonightR_template.h │ │ ├── CryptonightR_template.inc │ │ ├── CryptonightR_template_win.inc │ │ ├── cn2 │ │ │ ├── cnv2_double_main_loop_sandybridge.inc │ │ │ ├── cnv2_main_loop_bulldozer.inc │ │ │ ├── cnv2_main_loop_ivybridge.inc │ │ │ ├── cnv2_main_loop_ryzen.inc │ │ │ ├── cnv2_rwz_double_main_loop.inc │ │ │ └── cnv2_rwz_main_loop.inc │ │ ├── cn_main_loop.S │ │ ├── cn_main_loop.asm │ │ └── win64 │ │ │ ├── CryptonightR_soft_aes_template_win.inc │ │ │ ├── CryptonightR_template.asm │ │ │ ├── CryptonightR_template_win.inc │ │ │ ├── cn2 │ │ │ ├── cnv2_double_main_loop_sandybridge.inc │ │ │ ├── cnv2_main_loop_bulldozer.inc │ │ │ ├── cnv2_main_loop_ivybridge.inc │ │ │ ├── cnv2_main_loop_ryzen.inc │ │ │ ├── cnv2_rwz_double_main_loop.inc │ │ │ └── cnv2_rwz_main_loop.inc │ │ │ ├── cn_main_loop.S │ │ │ └── cn_main_loop.asm │ ├── c_blake256.c │ ├── c_blake256.h │ ├── c_groestl.c │ ├── c_groestl.h │ ├── c_jh.c │ ├── c_jh.h │ ├── c_skein.c │ ├── c_skein.h │ ├── groestl_tables.h │ ├── hash.h │ ├── r │ │ ├── CryptonightR_gen.cpp │ │ └── variant4_random_math.h │ ├── skein_port.h │ ├── soft_aes.h │ └── sse2neon.h ├── common │ ├── Assembly.cpp │ ├── Assembly.h │ ├── HugePagesInfo.cpp │ ├── HugePagesInfo.h │ ├── LinuxMemory.cpp │ ├── LinuxMemory.h │ ├── MemoryPool.cpp │ ├── MemoryPool.h │ ├── NUMAMemoryPool.cpp │ ├── NUMAMemoryPool.h │ ├── Nonce.cpp │ ├── Nonce.h │ ├── VirtualMemory.cpp │ ├── VirtualMemory.h │ ├── VirtualMemory_hwloc.cpp │ ├── VirtualMemory_unix.cpp │ ├── VirtualMemory_win.cpp │ └── portable │ │ └── mm_malloc.h ├── kawpow │ ├── KPCache.cpp │ ├── KPCache.h │ ├── KPHash.cpp │ └── KPHash.h ├── randomx │ ├── aes_hash.cpp │ ├── aes_hash.hpp │ ├── allocator.cpp │ ├── allocator.hpp │ ├── asm │ │ ├── program_epilogue_linux.inc │ │ ├── program_epilogue_store.inc │ │ ├── program_epilogue_win64.inc │ │ ├── program_loop_load.inc │ │ ├── program_loop_load_xop.inc │ │ ├── program_loop_store.inc │ │ ├── program_prologue_linux.inc │ │ ├── program_prologue_win64.inc │ │ ├── program_read_dataset.inc │ │ ├── program_read_dataset_ryzen.inc │ │ ├── program_read_dataset_sshash_fin.inc │ │ ├── program_read_dataset_sshash_init.inc │ │ ├── program_sshash_avx2_constants.inc │ │ ├── program_sshash_avx2_epilogue.inc │ │ ├── program_sshash_avx2_loop_begin.inc │ │ ├── program_sshash_avx2_loop_end.inc │ │ ├── program_sshash_avx2_save_registers.inc │ │ ├── program_sshash_avx2_ssh_load.inc │ │ ├── program_sshash_avx2_ssh_prefetch.inc │ │ ├── program_sshash_constants.inc │ │ ├── program_sshash_load.inc │ │ ├── program_sshash_prefetch.inc │ │ ├── program_xmm_constants.inc │ │ └── randomx_reciprocal.inc │ ├── blake2 │ │ ├── blake2-impl.h │ │ ├── blake2.h │ │ ├── blake2b-round.h │ │ ├── blake2b.c │ │ ├── blake2b_sse41.c │ │ ├── blamka-round-ref.h │ │ └── endian.h │ ├── blake2_generator.cpp │ ├── blake2_generator.hpp │ ├── bytecode_machine.cpp │ ├── bytecode_machine.hpp │ ├── common.hpp │ ├── configuration.h │ ├── dataset.cpp │ ├── dataset.hpp │ ├── instruction.hpp │ ├── instructions_portable.cpp │ ├── intrin_portable.h │ ├── jit_compiler.hpp │ ├── jit_compiler_a64.cpp │ ├── jit_compiler_a64.hpp │ ├── jit_compiler_a64_static.S │ ├── jit_compiler_a64_static.hpp │ ├── jit_compiler_fallback.cpp │ ├── jit_compiler_fallback.hpp │ ├── jit_compiler_x86.cpp │ ├── jit_compiler_x86.hpp │ ├── jit_compiler_x86_static.S │ ├── jit_compiler_x86_static.asm │ ├── jit_compiler_x86_static.hpp │ ├── panthera │ │ ├── KangarooTwelve.c │ │ ├── KangarooTwelve.h │ │ ├── KeccakP-1600-SnP.h │ │ ├── KeccakP-1600-reference.c │ │ ├── KeccakSponge-common.h │ │ ├── KeccakSponge.inc │ │ ├── KeccakSpongeWidth1600.c │ │ ├── KeccakSpongeWidth1600.h │ │ ├── Phases.h │ │ ├── align.h │ │ ├── brg_endian.h │ │ ├── insecure_memzero.h │ │ ├── sha256.c │ │ ├── sha256.h │ │ ├── sysendian.h │ │ ├── yespower-opt.c │ │ ├── yespower-platform.c │ │ ├── yespower-ref.c │ │ └── yespower.h │ ├── program.hpp │ ├── randomx.cpp │ ├── randomx.h │ ├── reciprocal.c │ ├── reciprocal.h │ ├── soft_aes.cpp │ ├── soft_aes.h │ ├── superscalar.cpp │ ├── superscalar.hpp │ ├── superscalar_program.hpp │ ├── virtual_machine.cpp │ ├── virtual_machine.hpp │ ├── virtual_memory.cpp │ ├── virtual_memory.hpp │ ├── vm_compiled.cpp │ ├── vm_compiled.hpp │ ├── vm_compiled_light.cpp │ ├── vm_compiled_light.hpp │ ├── vm_interpreted.cpp │ ├── vm_interpreted.hpp │ ├── vm_interpreted_light.cpp │ └── vm_interpreted_light.hpp └── rx │ ├── Profiler.cpp │ ├── Profiler.h │ ├── Rx.cpp │ ├── Rx.h │ ├── RxAlgo.cpp │ ├── RxAlgo.h │ ├── RxBasicStorage.cpp │ ├── RxBasicStorage.h │ ├── RxCache.cpp │ ├── RxCache.h │ ├── RxConfig.cpp │ ├── RxConfig.h │ ├── RxDataset.cpp │ ├── RxDataset.h │ ├── RxFix.h │ ├── RxFix_linux.cpp │ ├── RxFix_win.cpp │ ├── RxMsr.cpp │ ├── RxMsr.h │ ├── RxNUMAStorage.cpp │ ├── RxNUMAStorage.h │ ├── RxQueue.cpp │ ├── RxQueue.h │ ├── RxSeed.h │ ├── RxVm.cpp │ └── RxVm.h ├── donate.h ├── hw ├── api │ ├── HwApi.cpp │ ├── HwApi.h │ └── api.cmake ├── dmi │ ├── DmiBoard.cpp │ ├── DmiBoard.h │ ├── DmiMemory.cpp │ ├── DmiMemory.h │ ├── DmiReader.cpp │ ├── DmiReader.h │ ├── DmiReader_mac.cpp │ ├── DmiReader_unix.cpp │ ├── DmiReader_win.cpp │ ├── DmiTools.cpp │ ├── DmiTools.h │ └── dmi.cmake └── msr │ ├── Msr.cpp │ ├── Msr.h │ ├── MsrItem.cpp │ ├── MsrItem.h │ ├── Msr_linux.cpp │ └── Msr_win.cpp ├── net ├── JobResult.h ├── JobResults.cpp ├── JobResults.h ├── Network.cpp ├── Network.h ├── interfaces │ └── IJobResultListener.h └── strategies │ ├── DonateStrategy.cpp │ └── DonateStrategy.h ├── version.h └── xlarig.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /CMakeLists.txt.user 3 | /.idea 4 | /src/backend/opencl/cl/cn/cryptonight_gen.cl 5 | /cmake-build-debug 6 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v5.2.4 2 | - Updated dependencies (OpenSSL 3, ...) 3 | - Miner won't try to mine Diardi's block 4 | 5 | # v5.2.3 6 | - Removed the True Core functionnality (too buggy at this time) 7 | - Removed code for GPU's (OpenCL/Cuda) 8 | - Removed non-randomx algorythms 9 | - Rebased from XMRig v6.10.0 [(changelog)](doc/CHANGELOG.md) 10 | - Added CPU stats for pool owners 11 | 12 | # v5.2.2 13 | - Rebased from XMRig v6.8.1 14 | - Full RandomX integration for Panthera 15 | - Better algo detection (it only use the "True" CPU Cores, since HT ones only add electricity costs if used) 16 | - New Feature : Pool auto-redirection 17 | 18 | # v5.2.1 19 | - Rebased from XMRig v6.7.0 20 | - Added Compatibiliy with Apple M1 CPU's 21 | - Several optimisations for the latest x86 CPU's (mainly Ryzen's) 22 | 23 | 24 | # v5.2.0 25 | - Updated Panthera algo 26 | - Removed DefyX algo 27 | 28 | 29 | # v5.1.0 30 | - Added Panthera algo 31 | - Moved DefyX config data into RandomX. 32 | - Rebased from XMRig v5.11.1 33 | 34 | # v5.0.2 35 | 36 | - Rebase from XMRig v5.5.1 37 | 38 | 39 | # v5.0.1 40 | 41 | - Rebase from XMRig v5.4.0 42 | 43 | 44 | # v5.0.0 45 | 46 | - Rebase from XMRig v5.3.0 47 | - Some extra DefyX optimizations 48 | - Disabled OpenCL/Cuda 49 | - Updated Readme and changelog 50 | -------------------------------------------------------------------------------- /bin/WinRing0/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007-2009 OpenLibSys.org. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 1. Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 13 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 14 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 15 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 16 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 17 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 18 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 19 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 21 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /bin/WinRing0/WinRing0x64.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scala-network/XLArig/6b500b9f5656d2a25f7577438e22bf9a1a5fa5aa/bin/WinRing0/WinRing0x64.sys -------------------------------------------------------------------------------- /cmake/FindHWLOC.cmake: -------------------------------------------------------------------------------- 1 | find_path( 2 | HWLOC_INCLUDE_DIR 3 | NAMES hwloc.h 4 | PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS" 5 | PATH_SUFFIXES "include" 6 | NO_DEFAULT_PATH 7 | ) 8 | 9 | find_path(HWLOC_INCLUDE_DIR NAMES hwloc.h) 10 | 11 | find_library( 12 | HWLOC_LIBRARY 13 | NAMES hwloc.a hwloc libhwloc 14 | PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS" 15 | PATH_SUFFIXES "lib" 16 | NO_DEFAULT_PATH 17 | ) 18 | 19 | find_library(HWLOC_LIBRARY NAMES hwloc.a hwloc libhwloc) 20 | 21 | set(HWLOC_LIBRARIES ${HWLOC_LIBRARY}) 22 | set(HWLOC_INCLUDE_DIRS ${HWLOC_INCLUDE_DIR}) 23 | 24 | include(FindPackageHandleStandardArgs) 25 | find_package_handle_standard_args(HWLOC DEFAULT_MSG HWLOC_LIBRARY HWLOC_INCLUDE_DIR) 26 | -------------------------------------------------------------------------------- /cmake/FindUV.cmake: -------------------------------------------------------------------------------- 1 | find_path( 2 | UV_INCLUDE_DIR 3 | NAMES uv.h 4 | PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS" 5 | PATH_SUFFIXES "include" 6 | NO_DEFAULT_PATH 7 | ) 8 | 9 | find_path(UV_INCLUDE_DIR NAMES uv.h) 10 | 11 | find_library( 12 | UV_LIBRARY 13 | NAMES libuv.a uv libuv 14 | PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS" 15 | PATH_SUFFIXES "lib" 16 | NO_DEFAULT_PATH 17 | ) 18 | 19 | find_library(UV_LIBRARY NAMES libuv.a uv libuv) 20 | 21 | set(UV_LIBRARIES ${UV_LIBRARY}) 22 | set(UV_INCLUDE_DIRS ${UV_INCLUDE_DIR}) 23 | 24 | include(FindPackageHandleStandardArgs) 25 | find_package_handle_standard_args(UV DEFAULT_MSG UV_LIBRARY UV_INCLUDE_DIR) 26 | -------------------------------------------------------------------------------- /cmake/argon2.cmake: -------------------------------------------------------------------------------- 1 | if (WITH_ARGON2) 2 | add_definitions(/DXMRIG_ALGO_ARGON2) 3 | 4 | list(APPEND HEADERS_CRYPTO 5 | src/crypto/argon2/Hash.h 6 | src/crypto/argon2/Impl.h 7 | ) 8 | 9 | list(APPEND SOURCES_CRYPTO 10 | src/crypto/argon2/Impl.cpp 11 | ) 12 | 13 | add_subdirectory(src/3rdparty/argon2) 14 | set(ARGON2_LIBRARY argon2) 15 | else() 16 | remove_definitions(/DXMRIG_ALGO_ARGON2) 17 | set(ARGON2_LIBRARY "") 18 | endif() 19 | -------------------------------------------------------------------------------- /cmake/asm.cmake: -------------------------------------------------------------------------------- 1 | if (WITH_ASM AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8) 2 | set(XMRIG_ASM_LIBRARY "xlarig-asm") 3 | 4 | if (CMAKE_C_COMPILER_ID MATCHES MSVC) 5 | enable_language(ASM_MASM) 6 | 7 | if (MSVC_TOOLSET_VERSION GREATER_EQUAL 141) 8 | set(XMRIG_ASM_FILES 9 | "src/crypto/cn/asm/cn_main_loop.asm" 10 | "src/crypto/cn/asm/CryptonightR_template.asm" 11 | ) 12 | else() 13 | set(XMRIG_ASM_FILES 14 | "src/crypto/cn/asm/win64/cn_main_loop.asm" 15 | "src/crypto/cn/asm/win64/CryptonightR_template.asm" 16 | ) 17 | endif() 18 | 19 | set_property(SOURCE ${XMRIG_ASM_FILES} PROPERTY ASM_MASM) 20 | else() 21 | enable_language(ASM) 22 | 23 | if (WIN32 AND CMAKE_C_COMPILER_ID MATCHES GNU) 24 | set(XMRIG_ASM_FILES 25 | "src/crypto/cn/asm/win64/cn_main_loop.S" 26 | "src/crypto/cn/asm/CryptonightR_template.S" 27 | ) 28 | else() 29 | set(XMRIG_ASM_FILES 30 | "src/crypto/cn/asm/cn_main_loop.S" 31 | "src/crypto/cn/asm/CryptonightR_template.S" 32 | ) 33 | endif() 34 | 35 | set_property(SOURCE ${XMRIG_ASM_FILES} PROPERTY C) 36 | endif() 37 | 38 | add_library(${XMRIG_ASM_LIBRARY} STATIC ${XMRIG_ASM_FILES}) 39 | set(XMRIG_ASM_SOURCES 40 | src/crypto/common/Assembly.h 41 | src/crypto/common/Assembly.cpp 42 | src/crypto/cn/r/CryptonightR_gen.cpp 43 | ) 44 | set_property(TARGET ${XMRIG_ASM_LIBRARY} PROPERTY LINKER_LANGUAGE C) 45 | 46 | add_definitions(/DXMRIG_FEATURE_ASM) 47 | else() 48 | set(XMRIG_ASM_SOURCES "") 49 | set(XMRIG_ASM_LIBRARY "") 50 | 51 | remove_definitions(/DXMRIG_FEATURE_ASM) 52 | endif() 53 | -------------------------------------------------------------------------------- /cmake/cpu.cmake: -------------------------------------------------------------------------------- 1 | if (NOT CMAKE_SYSTEM_PROCESSOR) 2 | message(WARNING "CMAKE_SYSTEM_PROCESSOR not defined") 3 | endif() 4 | 5 | if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$" AND CMAKE_SIZEOF_VOID_P EQUAL 8) 6 | add_definitions(/DRAPIDJSON_SSE2) 7 | else() 8 | set(WITH_SSE4_1 OFF) 9 | endif() 10 | 11 | if (NOT ARM_TARGET) 12 | if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64|armv8-a)$") 13 | set(ARM_TARGET 8) 14 | elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv7|armv7f|armv7s|armv7k|armv7-a|armv7l)$") 15 | set(ARM_TARGET 7) 16 | endif() 17 | endif() 18 | 19 | if (ARM_TARGET AND ARM_TARGET GREATER 6) 20 | set(XMRIG_ARM ON) 21 | add_definitions(/DXMRIG_ARM) 22 | 23 | message(STATUS "Use ARM_TARGET=${ARM_TARGET} (${CMAKE_SYSTEM_PROCESSOR})") 24 | 25 | include(CheckCXXCompilerFlag) 26 | 27 | if (ARM_TARGET EQUAL 8) 28 | set(XMRIG_ARMv8 ON) 29 | add_definitions(/DXMRIG_ARMv8) 30 | 31 | CHECK_CXX_COMPILER_FLAG(-march=armv8-a+crypto XMRIG_ARM_CRYPTO) 32 | 33 | if (XMRIG_ARM_CRYPTO) 34 | add_definitions(/DXMRIG_ARM_CRYPTO) 35 | set(ARM8_CXX_FLAGS "-march=armv8-a+crypto") 36 | else() 37 | set(ARM8_CXX_FLAGS "-march=armv8-a") 38 | endif() 39 | elseif (ARM_TARGET EQUAL 7) 40 | set(XMRIG_ARMv7 ON) 41 | add_definitions(/DXMRIG_ARMv7) 42 | endif() 43 | endif() 44 | 45 | if (WITH_SSE4_1) 46 | add_definitions(/DXMRIG_FEATURE_SSE4_1) 47 | endif() 48 | -------------------------------------------------------------------------------- /cmake/os.cmake: -------------------------------------------------------------------------------- 1 | if (WIN32) 2 | set(XMRIG_OS_WIN ON) 3 | elseif (APPLE) 4 | set(XMRIG_OS_APPLE ON) 5 | 6 | if (IOS OR CMAKE_SYSTEM_NAME STREQUAL iOS) 7 | set(XMRIG_OS_IOS ON) 8 | else() 9 | set(XMRIG_OS_MACOS ON) 10 | endif() 11 | else() 12 | set(XMRIG_OS_UNIX ON) 13 | 14 | if (ANDROID OR CMAKE_SYSTEM_NAME MATCHES "Android") 15 | set(XMRIG_OS_ANDROID ON) 16 | elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") 17 | set(XMRIG_OS_LINUX ON) 18 | elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) 19 | set(XMRIG_OS_FREEBSD ON) 20 | endif() 21 | endif() 22 | 23 | 24 | if (XMRIG_OS_WIN) 25 | add_definitions(/DWIN32) 26 | add_definitions(/DXMRIG_OS_WIN) 27 | elseif(XMRIG_OS_APPLE) 28 | add_definitions(/DXMRIG_OS_APPLE) 29 | 30 | if (XMRIG_OS_IOS) 31 | add_definitions(/DXMRIG_OS_IOS) 32 | else() 33 | add_definitions(/DXMRIG_OS_MACOS) 34 | endif() 35 | 36 | if (XMRIG_ARM) 37 | set(WITH_SECURE_JIT ON) 38 | endif() 39 | elseif(XMRIG_OS_UNIX) 40 | add_definitions(/DXMRIG_OS_UNIX) 41 | 42 | if (XMRIG_OS_ANDROID) 43 | add_definitions(/DXMRIG_OS_ANDROID) 44 | elseif (XMRIG_OS_LINUX) 45 | add_definitions(/DXMRIG_OS_LINUX) 46 | elseif (XMRIG_OS_FREEBSD) 47 | add_definitions(/DXMRIG_OS_FREEBSD) 48 | endif() 49 | endif() 50 | 51 | if (WITH_SECURE_JIT) 52 | add_definitions(/DXMRIG_SECURE_JIT) 53 | endif() 54 | -------------------------------------------------------------------------------- /doc/CPU_MAX_USAGE.md: -------------------------------------------------------------------------------- 1 | # Maximum CPU usage 2 | 3 | Please read this document carefully, `max-threads-hint` (was known as `max-cpu-usage`) option is most confusing option in the miner with many myth and legends. 4 | This option is just hint for automatic configuration and can't precise define CPU usage. 5 | 6 | ### Option definition 7 | #### Config file: 8 | ```json 9 | { 10 | ... 11 | "cpu": { 12 | "max-threads-hint": 100, 13 | ... 14 | }, 15 | ... 16 | } 17 | ``` 18 | 19 | #### Command line 20 | `--cpu-max-threads-hint 100` 21 | 22 | ### Known issues and usage 23 | 24 | * This option has no effect if miner already generated CPU configuration, to prevent config generation use `"autosave":false,`. 25 | * Only threads count can be changed, for 1 core CPU this option has no effect, for 2 core CPU only 2 values possible 50% and 100%, for 4 cores: 25%, 50%, 75%, 100%. etc. 26 | * You CPU may limited by other factors, eg cache. 27 | -------------------------------------------------------------------------------- /doc/PERSISTENT_OPTIONS.md: -------------------------------------------------------------------------------- 1 | # Persistent options 2 | 3 | Options in list below can't changed in runtime by watching config file or via API. 4 | 5 | * `background` 6 | * `donate-level` 7 | * `cpu/argon2-impl` 8 | * `opencl/loader` 9 | * `opencl/platform` 10 | -------------------------------------------------------------------------------- /doc/api/1/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "algo": "cryptonight", 3 | "api": { 4 | "port": 44444, 5 | "access-token": "TOKEN", 6 | "worker-id": null, 7 | "ipv6": false, 8 | "restricted": false 9 | }, 10 | "av": 1, 11 | "background": false, 12 | "colors": true, 13 | "cpu-affinity": null, 14 | "cpu-priority": null, 15 | "donate-level": 5, 16 | "huge-pages": true, 17 | "hw-aes": null, 18 | "log-file": null, 19 | "max-cpu-usage": 75, 20 | "pools": [ 21 | { 22 | "url": "pool.monero.hashvault.pro:3333", 23 | "user": "48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD", 24 | "pass": "x", 25 | "keepalive": false, 26 | "nicehash": false, 27 | "variant": -1 28 | }, 29 | { 30 | "url": "pool.supportxmr.com:3333", 31 | "user": "48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD", 32 | "pass": "x", 33 | "keepalive": false, 34 | "nicehash": false, 35 | "variant": -1 36 | } 37 | ], 38 | "print-time": 60, 39 | "retries": 5, 40 | "retry-pause": 5, 41 | "safe": false, 42 | "threads": [ 43 | { 44 | "low_power_mode": 1, 45 | "affine_to_cpu": 0 46 | }, 47 | { 48 | "low_power_mode": 1, 49 | "affine_to_cpu": 1 50 | }, 51 | { 52 | "low_power_mode": 1, 53 | "affine_to_cpu": 2 54 | }, 55 | { 56 | "low_power_mode": 1, 57 | "affine_to_cpu": 3 58 | } 59 | ], 60 | "user-agent": null, 61 | "syslog": false, 62 | "watch": false 63 | } -------------------------------------------------------------------------------- /doc/api/1/summary.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "92f3104f9a2ee78c", 3 | "worker_id": "Ubuntu-1604-xenial-64-minimal", 4 | "version": "2.6.0-beta3", 5 | "kind": "cpu", 6 | "ua": "XMRig/2.6.0-beta3 (Linux x86_64) libuv/1.8.0 gcc/5.4.0", 7 | "cpu": { 8 | "brand": "Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz", 9 | "aes": true, 10 | "x64": true, 11 | "sockets": 1 12 | }, 13 | "algo": "cryptonight", 14 | "hugepages": true, 15 | "donate_level": 5, 16 | "hashrate": { 17 | "total": [ 18 | 296.24, 19 | 296.23, 20 | 295.97 21 | ], 22 | "highest": 296.5, 23 | "threads": [ 24 | [ 25 | 73.39, 26 | 73.39, 27 | 73.28 28 | ], 29 | [ 30 | 74.72, 31 | 74.72, 32 | 74.71 33 | ], 34 | [ 35 | 74.72, 36 | 74.72, 37 | 74.71 38 | ], 39 | [ 40 | 73.39, 41 | 73.39, 42 | 73.27 43 | ] 44 | ] 45 | }, 46 | "results": { 47 | "diff_current": 9990, 48 | "shares_good": 30, 49 | "shares_total": 30, 50 | "avg_time": 31, 51 | "hashes_total": 311833, 52 | "best": [ 53 | 278199, 54 | 181923, 55 | 103717, 56 | 96632, 57 | 56154, 58 | 51580, 59 | 45667, 60 | 33159, 61 | 29581, 62 | 29514 63 | ], 64 | "error_log": [] 65 | }, 66 | "connection": { 67 | "pool": "pool.monero.hashvault.pro:3333", 68 | "uptime": 953, 69 | "ping": 35, 70 | "failures": 0, 71 | "error_log": [] 72 | } 73 | } -------------------------------------------------------------------------------- /doc/api/1/threads.json: -------------------------------------------------------------------------------- 1 | { 2 | "hugepages": [ 3 | 4, 4 | 4 5 | ], 6 | "memory": 8388608, 7 | "threads": [ 8 | { 9 | "type": "cpu", 10 | "algo": "cryptonight", 11 | "av": 1, 12 | "low_power_mode": 1, 13 | "affine_to_cpu": 0, 14 | "priority": -1, 15 | "soft_aes": false, 16 | "hashrate": [ 17 | 73.39, 18 | 73.4, 19 | 73.28 20 | ] 21 | }, 22 | { 23 | "type": "cpu", 24 | "algo": "cryptonight", 25 | "av": 1, 26 | "low_power_mode": 1, 27 | "affine_to_cpu": 1, 28 | "priority": -1, 29 | "soft_aes": false, 30 | "hashrate": [ 31 | 74.72, 32 | 74.72, 33 | 74.7 34 | ] 35 | }, 36 | { 37 | "type": "cpu", 38 | "algo": "cryptonight", 39 | "av": 1, 40 | "low_power_mode": 1, 41 | "affine_to_cpu": 2, 42 | "priority": -1, 43 | "soft_aes": false, 44 | "hashrate": [ 45 | 74.71, 46 | 74.72, 47 | 74.7 48 | ] 49 | }, 50 | { 51 | "type": "cpu", 52 | "algo": "cryptonight", 53 | "av": 1, 54 | "low_power_mode": 1, 55 | "affine_to_cpu": 3, 56 | "priority": -1, 57 | "soft_aes": false, 58 | "hashrate": [ 59 | 73.39, 60 | 73.4, 61 | 73.28 62 | ] 63 | } 64 | ] 65 | } -------------------------------------------------------------------------------- /doc/gpg_keys/xmrig.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | 3 | mQENBF3VSRIBCADfFjDUbq0WLGulFeSou0A+jTvweNllPyLNOn3SNCC0XLEYyEcu 4 | JiEBK80DlvR06TVr8Aw1rT5S2iH0i5Tl8DqShH2mmcN1rBp1M0Y95D89KVj3BIhE 5 | nxmgmD4N3Wgm+5FmEH4W/RpG1xdYWJx3eJhtWPdFJqpg083E2D5P30wIQem+EnTR 6 | 5YrtTZPh5cPj2KRY+UmsDE3ahmxCgP7LYgnnpZQlWBBiMV932s7MvYBPJQc1wecS 7 | 0wi1zxyS81xHc3839EkA7wueCeNo+5jha+KH66tMKsfrI2WvfPHTCPjK9v7WJc/O 8 | /eRp9d+wacn09D1L6CoRO0ers5p10GO84VhTABEBAAG0GVhNUmlnIDxzdXBwb3J0 9 | QHhtcmlnLmNvbT6JAU4EEwEIADgWIQSaxM6o5m41pcfN3BtEalNji+lECQUCXdVJ 10 | EgIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRBEalNji+lECbkQB/9nRou0 11 | tOlBwYn8xVgBu7IiDWNVETRWfrjrtdTvSahgbbo6lWgjA/vBLkjN9fISdBQ/n/Mt 12 | hNDJbEtxHHt2baJhvT8du1eWcIHHXCV/rmv+iY/hTXa1gKqHiHDJrtYSVBG3BMme 13 | 1rdsUHTiKf3t5yRHOXAfY2C+XNblKAV7mhlxQBiKxdFDIkFEQKNrHNUvnzkOqoCT 14 | 2kTZZ2tPUMQdOn1eek6zG/+C7SwcBpJnakJ8jce4yA/xZbOVKetNWO3Ufu3TE34k 15 | OdA+H4PU9+fV77XfOY8DtXeS3boUI97ei+4s/mwX/NFC0i8CPXyefxl3WRUBGDOI 16 | w//kPNQVh4HobOCeuQENBF3VSRIBCADl29WorEi+vRA/3kg9VUXtxSU6caibFS3N 17 | VXANiFRjrOmICdfrIgOSGNrYCQFsXu0Xe0udDYVX8yX6WJk+CT02Pdg0gkXiKoze 18 | KrnK15mo3xXbb2tr1o9ROPgwY/o2AwQHj0o1JhdS2cybfuRiUQRoGgBX7a9X0cTY 19 | r4ZJvOjzgAajl3ciwB3yWUmDiRlzZpO7YWESXbOhGVzyCnP5MlMEJ/fPRw9h38vK 20 | HNKLhzcRfsLpXk34ghY3SxIv4NWUfuZXFWqpSdC9JgNc5zA72lJEQcF4DHJCKl7B 21 | ddmrfsr9mdiIpo+/ZZFPPngdeZ2kvkJ2YKaZNVu2XooJARPQ8B8tABEBAAGJATYE 22 | GAEIACAWIQSaxM6o5m41pcfN3BtEalNji+lECQUCXdVJEgIbDAAKCRBEalNji+lE 23 | CdPUB/4nH1IdhHGmfko2kxdaHqQgCGLqh3pcrQXD9mBv/LYVnoHZpVRHsIDgg2Z4 24 | lQYrIRRqe69FjVxo7sA2eMIlV0GRDlUrw+HeURFpEhKPEdwFy6i/cti2MY0YxOrB 25 | TvQoRutUoMnyjM4TBJWaaqccbTsavMdLmG3JHdAkiHtUis/fUwVctmEQwN+d/J2b 26 | wJAtliqw3nXchUfdIfwHF/7hg8seUuYUaifzkazBZhVWvRkTVLVanzZ51HRfuzwD 27 | ntaa7kfYGdE+4TKOylAPh+8E6WnR19RRTpsaW0dVBgOiBTE0uc7rUv2HWS/u6RUR 28 | t7ldSBzkuDTlM2V59Iq2hXoSC6dT 29 | =cIG9 30 | -----END PGP PUBLIC KEY BLOCK----- 31 | -------------------------------------------------------------------------------- /doc/releases/5_0_1/SHA256SUMS: -------------------------------------------------------------------------------- 1 | 6bb1a2e3a0fbca5195be6022f2a9fbff8a353c37c7542e7ab89420cb45b64505 xmrig-5.0.1-gcc-win32.zip 2 | 24dba9ec281acfb2ea2c401ebd0e4e2d1f1ee5fd557da5ff3c7049020c1f78b6 xmrig-5.0.1-gcc-win64.zip 3 | 86d65c6693ec9e35cd7547329580638b85c9eb0cf8383892a1c15199de5b556f xmrig-5.0.1-msvc-cuda10_1-win64.zip 4 | 0fbfe518b1c4b6993b0f66ff01302626375b15620ccf8f64d6fb97845068ffca xmrig-5.0.1-msvc-win64.zip 5 | aa34890738a3494de2fa0e44db346937fea7339852f5f10b5d4655f95e2d8f1f xmrig-5.0.1-xenial-x64.tar.gz 6 | -------------------------------------------------------------------------------- /doc/releases/5_0_1/SHA256SUMS.sig: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iQEzBAABCgAdFiEEmsTOqOZuNaXHzdwbRGpTY4vpRAkFAl3VcsoACgkQRGpTY4vp 4 | RAm9vQgA1MyTUU2jley2TCYLUzQy2Fffc8fbXYv64r44jbWOjC/6qo2iIlRgPhIc 5 | oVyPKr5TYS3QjDzCEm8IvozS0YudS6soESbPzqDonboK8pd0K4bsML9TQY2feV7A 6 | NL5vln0rfVHp1wxLLrQpfBqAgvJUXEyaHece6gFQN79JOGhEo2bHL2NyrOl+FViS 7 | b2BaMtXq410Fh+XT6ShnOaG/2EuO8ZqSGdCO6A/2LHQw1UY+mZiCvue6P6B06HmB 8 | WD/urOv38V389v+V+Sp4UlEW6VpBOOjvtChoVWtLt+tKzydrnt2EmoWWWg475pka 9 | 4G6whHuMWS8CTt5/PDhJpvVXNQTIOw== 10 | =C764 11 | -----END PGP SIGNATURE----- 12 | -------------------------------------------------------------------------------- /doc/screenshot_v5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scala-network/XLArig/6b500b9f5656d2a25f7577438e22bf9a1a5fa5aa/doc/screenshot_v5.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "xmrig", 3 | "version": "3.0.0", 4 | "description": "RandomX, CryptoNight and Argon2 miner", 5 | "main": "index.js", 6 | "directories": { 7 | "doc": "doc" 8 | }, 9 | "scripts": { 10 | "build": "node scripts/generate_cl.js" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/xmrig/xmrig.git" 15 | }, 16 | "keywords": [], 17 | "author": "", 18 | "license": "GPLv3", 19 | "bugs": { 20 | "url": "https://github.com/xmrig/xmrig/issues" 21 | }, 22 | "homepage": "https://github.com/xmrig/xmrig#readme" 23 | } 24 | -------------------------------------------------------------------------------- /res/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scala-network/XLArig/6b500b9f5656d2a25f7577438e22bf9a1a5fa5aa/res/app.ico -------------------------------------------------------------------------------- /res/app.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../src/version.h" 3 | 4 | 101 ICON "app.ico" 5 | 6 | VS_VERSION_INFO VERSIONINFO 7 | FILEVERSION APP_VER_MAJOR,APP_VER_MINOR,APP_VER_PATCH,0 8 | PRODUCTVERSION APP_VER_MAJOR,APP_VER_MINOR,APP_VER_PATCH,0 9 | FILEFLAGSMASK 0x3fL 10 | #ifdef _DEBUG 11 | FILEFLAGS VS_FF_DEBUG 12 | #else 13 | FILEFLAGS 0x0L 14 | #endif 15 | FILEOS VOS__WINDOWS32 16 | FILETYPE VFT_APP 17 | FILESUBTYPE 0x0L 18 | BEGIN 19 | BLOCK "StringFileInfo" 20 | BEGIN 21 | BLOCK "000004b0" 22 | BEGIN 23 | VALUE "CompanyName", APP_SITE 24 | VALUE "FileDescription", APP_DESC 25 | VALUE "FileVersion", APP_VERSION 26 | VALUE "LegalCopyright", APP_COPYRIGHT 27 | VALUE "OriginalFilename", "xlarig.exe" 28 | VALUE "ProductName", APP_NAME 29 | VALUE "ProductVersion", APP_VERSION 30 | END 31 | END 32 | BLOCK "VarFileInfo" 33 | BEGIN 34 | VALUE "Translation", 0x0, 1200 35 | END 36 | END 37 | 38 | -------------------------------------------------------------------------------- /scripts/benchmark_10M.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd %~dp0 3 | xlarig.exe --bench=10M --submit 4 | pause 5 | -------------------------------------------------------------------------------- /scripts/benchmark_1M.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd %~dp0 3 | xlarig.exe --bench=1M --submit 4 | pause 5 | -------------------------------------------------------------------------------- /scripts/build.hwloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | HWLOC_BRANCH="2.10" 4 | HWLOC_VERSION="2.10.0" 5 | 6 | mkdir -p deps 7 | mkdir -p deps/include 8 | mkdir -p deps/lib 9 | 10 | mkdir -p build && cd build 11 | 12 | wget https://download.open-mpi.org/release/hwloc/v${HWLOC_BRANCH}/hwloc-${HWLOC_VERSION}.tar.gz -O hwloc-${HWLOC_VERSION}.tar.gz 13 | tar -xzf hwloc-${HWLOC_VERSION}.tar.gz 14 | 15 | cd hwloc-${HWLOC_VERSION} 16 | ./configure --disable-shared --enable-static --disable-io --disable-libudev --disable-libxml2 17 | make -j$(nproc || sysctl -n hw.ncpu || sysctl -n hw.logicalcpu) 18 | cp -fr include ../../deps 19 | cp hwloc/.libs/libhwloc.a ../../deps/lib 20 | cd .. -------------------------------------------------------------------------------- /scripts/build.libressl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | LIBRESSL_VERSION="3.8.2" 4 | 5 | mkdir -p deps 6 | mkdir -p deps/include 7 | mkdir -p deps/lib 8 | 9 | mkdir -p build && cd build 10 | 11 | wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${LIBRESSL_VERSION}.tar.gz -O libressl-${LIBRESSL_VERSION}.tar.gz 12 | tar -xzf libressl-${LIBRESSL_VERSION}.tar.gz 13 | 14 | cd libressl-${LIBRESSL_VERSION} 15 | ./configure --disable-shared 16 | make -j$(nproc || sysctl -n hw.ncpu || sysctl -n hw.logicalcpu) 17 | cp -fr include ../../deps 18 | cp crypto/.libs/libcrypto.a ../../deps/lib 19 | cp ssl/.libs/libssl.a ../../deps/lib 20 | cd .. -------------------------------------------------------------------------------- /scripts/build.libressl_win.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | LIBRESSL_VERSION="3.2.4" 4 | 5 | mkdir -p deps 6 | mkdir -p deps/include 7 | mkdir -p deps/lib 8 | 9 | mkdir -p build && cd build 10 | 11 | wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${LIBRESSL_VERSION}.tar.gz -O libressl-${LIBRESSL_VERSION}.tar.gz 12 | tar -xzf libressl-${LIBRESSL_VERSION}.tar.gz 13 | 14 | cd libressl-${LIBRESSL_VERSION} 15 | ./configure --disable-shared CPPFLAGS="-D_FORTIFY_SOURCE=0" CFLAGS="-static" 16 | make -j3 17 | cp -fr include ../../deps 18 | cp crypto/.libs/libcrypto.a ../../deps/lib 19 | cp ssl/.libs/libssl.a ../../deps/lib 20 | cd .. -------------------------------------------------------------------------------- /scripts/build.openssl3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | OPENSSL_VERSION="3.0.12" 4 | 5 | mkdir -p deps 6 | mkdir -p deps/include 7 | mkdir -p deps/lib 8 | 9 | mkdir -p build && cd build 10 | 11 | wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz -O openssl-${OPENSSL_VERSION}.tar.gz 12 | tar -xzf openssl-${OPENSSL_VERSION}.tar.gz 13 | 14 | cd openssl-${OPENSSL_VERSION} 15 | ./config -no-shared -no-asm -no-zlib -no-comp -no-dgram -no-filenames -no-cms 16 | make -j$(nproc || sysctl -n hw.ncpu || sysctl -n hw.logicalcpu) 17 | cp -fr include ../../deps 18 | cp libcrypto.a ../../deps/lib 19 | cp libssl.a ../../deps/lib 20 | cd .. 21 | -------------------------------------------------------------------------------- /scripts/build.uv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | UV_VERSION="1.47.0" 4 | 5 | mkdir -p deps 6 | mkdir -p deps/include 7 | mkdir -p deps/lib 8 | 9 | mkdir -p build && cd build 10 | 11 | wget https://dist.libuv.org/dist/v${UV_VERSION}/libuv-v${UV_VERSION}.tar.gz -O v${UV_VERSION}.tar.gz 12 | tar -xzf v${UV_VERSION}.tar.gz 13 | 14 | cd libuv-v${UV_VERSION} 15 | sh autogen.sh 16 | ./configure --disable-shared 17 | make -j$(nproc || sysctl -n hw.ncpu || sysctl -n hw.logicalcpu) 18 | cp -fr include ../../deps 19 | cp .libs/libuv.a ../../deps/lib 20 | cd .. -------------------------------------------------------------------------------- /scripts/build_deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ./build.uv.sh 4 | ./build.hwloc.sh 5 | ./build.openssl3.sh -------------------------------------------------------------------------------- /scripts/enable_1gb_pages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # https://xmrig.com/docs/miner/hugepages#onegb-huge-pages 4 | 5 | sysctl -w vm.nr_hugepages=$(nproc) 6 | 7 | for i in $(find /sys/devices/system/node/node* -maxdepth 0 -type d); 8 | do 9 | echo 3 > "$i/hugepages/hugepages-1048576kB/nr_hugepages"; 10 | done 11 | 12 | echo "1GB pages successfully enabled" -------------------------------------------------------------------------------- /scripts/pool_mine_example.cmd: -------------------------------------------------------------------------------- 1 | :: Example batch file for mining Monero at a pool 2 | :: 3 | :: Format: 4 | :: xmrig.exe -o : -u -p 5 | :: 6 | :: Fields: 7 | :: pool address The host name of the pool stratum or its IP address, for example pool.hashvault.pro 8 | :: pool port The port of the pool's stratum to connect to, for example 3333. Check your pool's getting started page. 9 | :: pool username/wallet For most pools, this is the wallet address you want to mine to. Some pools require a username 10 | :: pool password For most pools this can be just 'x'. For pools using usernames, you may need to provide a password as configured on the pool. 11 | :: 12 | :: List of Monero mining pools: 13 | :: https://miningpoolstats.stream/monero 14 | :: 15 | :: Choose pools outside of top 5 to help Monero network be more decentralized! 16 | :: Smaller pools also often have smaller fees/payout limits. 17 | 18 | cd %~dp0 19 | xlarig.exe -o pool.hashvault.pro:3333 -u 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD -p x 20 | pause 21 | -------------------------------------------------------------------------------- /scripts/randomx_boost.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | modprobe msr 4 | 5 | if cat /proc/cpuinfo | grep "AMD Ryzen" > /dev/null; 6 | then 7 | if cat /proc/cpuinfo | grep "cpu family[[:space:]]:[[:space:]]25" > /dev/null; 8 | then 9 | echo "Detected Ryzen (Zen3)" 10 | wrmsr -a 0xc0011020 0x4480000000000 11 | wrmsr -a 0xc0011021 0x1c000200000040 12 | wrmsr -a 0xc0011022 0xc000000401500000 13 | wrmsr -a 0xc001102b 0x2000cc14 14 | echo "MSR register values for Ryzen (Zen3) applied" 15 | else 16 | echo "Detected Ryzen (Zen1/Zen2)" 17 | wrmsr -a 0xc0011020 0 18 | wrmsr -a 0xc0011021 0x40 19 | wrmsr -a 0xc0011022 0x1510000 20 | wrmsr -a 0xc001102b 0x2000cc16 21 | echo "MSR register values for Ryzen (Zen1/Zen2) applied" 22 | fi 23 | elif cat /proc/cpuinfo | grep "Intel" > /dev/null; 24 | then 25 | echo "Detected Intel" 26 | wrmsr -a 0x1a4 0xf 27 | echo "MSR register values for Intel applied" 28 | else 29 | echo "No supported CPU detected" 30 | fi 31 | -------------------------------------------------------------------------------- /scripts/solo_mine_example.cmd: -------------------------------------------------------------------------------- 1 | :: Example batch file for mining Monero solo 2 | :: 3 | :: Format: 4 | :: xmrig.exe -o : -a rx/0 -u --daemon 5 | :: 6 | :: Fields: 7 | :: node address The host name of your monerod node or its IP address. It can also be a public node with RPC enabled, for example node.xmr.to 8 | :: node port The RPC port of your monerod node to connect to, usually 18081. 9 | :: wallet address Check your Monero CLI or GUI wallet to see your wallet's address. 10 | :: 11 | :: Mining solo is the best way to help Monero network be more decentralized! 12 | :: But you will only get a payout when you find a block which can take more than a year for a single low-end PC. 13 | 14 | cd %~dp0 15 | xlarig.exe -o node.xmr.to:18081 -a rx/0 -u 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD --daemon 16 | pause 17 | -------------------------------------------------------------------------------- /src/3rdparty/argon2.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2019 SChernykh 9 | * Copyright 2016-2019 XMRig , 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | 26 | #ifndef XMRIG_3RDPARTY_ARGON2_H 27 | #define XMRIG_3RDPARTY_ARGON2_H 28 | 29 | 30 | #include "3rdparty/argon2/include/argon2.h" 31 | 32 | 33 | #endif /* XMRIG_3RDPARTY_ARGON2_H */ 34 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Ondrej Mosnáček 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/arch/generic/lib/argon2-arch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "impl-select.h" 6 | 7 | #define rotr64(x, n) (((x) >> (n)) | ((x) << (64 - (n)))) 8 | 9 | #include "argon2-template-64.h" 10 | 11 | void fill_segment_default(const argon2_instance_t *instance, 12 | argon2_position_t position) 13 | { 14 | fill_segment_64(instance, position); 15 | } 16 | 17 | void argon2_get_impl_list(argon2_impl_list *list) 18 | { 19 | list->count = 0; 20 | } 21 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/arch/x86_64/lib/argon2-arch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "impl-select.h" 6 | 7 | #include "argon2-sse2.h" 8 | #include "argon2-ssse3.h" 9 | #include "argon2-xop.h" 10 | #include "argon2-avx2.h" 11 | #include "argon2-avx512f.h" 12 | 13 | /* NOTE: there is no portable intrinsic for 64-bit rotate, but any 14 | * sane compiler should be able to compile this into a ROR instruction: */ 15 | #define rotr64(x, n) ((x) >> (n)) | ((x) << (64 - (n))) 16 | 17 | #include "argon2-template-64.h" 18 | 19 | void fill_segment_default(const argon2_instance_t *instance, 20 | argon2_position_t position) 21 | { 22 | fill_segment_64(instance, position); 23 | } 24 | 25 | void argon2_get_impl_list(argon2_impl_list *list) 26 | { 27 | static const argon2_impl IMPLS[] = { 28 | { "x86_64", NULL, fill_segment_default }, 29 | { "SSE2", xmrig_ar2_check_sse2, xmrig_ar2_fill_segment_sse2 }, 30 | { "SSSE3", xmrig_ar2_check_ssse3, xmrig_ar2_fill_segment_ssse3 }, 31 | { "XOP", xmrig_ar2_check_xop, xmrig_ar2_fill_segment_xop }, 32 | { "AVX2", xmrig_ar2_check_avx2, xmrig_ar2_fill_segment_avx2 }, 33 | { "AVX-512F", xmrig_ar2_check_avx512f, xmrig_ar2_fill_segment_avx512f }, 34 | }; 35 | 36 | list->count = sizeof(IMPLS) / sizeof(IMPLS[0]); 37 | list->entries = IMPLS; 38 | } 39 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/arch/x86_64/lib/argon2-avx2.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_AVX2_H 2 | #define ARGON2_AVX2_H 3 | 4 | #include "core.h" 5 | 6 | void xmrig_ar2_fill_segment_avx2(const argon2_instance_t *instance, argon2_position_t position); 7 | int xmrig_ar2_check_avx2(void); 8 | 9 | #endif // ARGON2_AVX2_H 10 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/arch/x86_64/lib/argon2-avx512f.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_AVX512F_H 2 | #define ARGON2_AVX512F_H 3 | 4 | #include "core.h" 5 | 6 | void xmrig_ar2_fill_segment_avx512f(const argon2_instance_t *instance, argon2_position_t position); 7 | int xmrig_ar2_check_avx512f(void); 8 | 9 | #endif // ARGON2_AVX512F_H 10 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/arch/x86_64/lib/argon2-sse2.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_SSE2_H 2 | #define ARGON2_SSE2_H 3 | 4 | #include "core.h" 5 | 6 | void xmrig_ar2_fill_segment_sse2(const argon2_instance_t *instance, argon2_position_t position); 7 | int xmrig_ar2_check_sse2(void); 8 | 9 | #endif // ARGON2_SSE2_H 10 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/arch/x86_64/lib/argon2-ssse3.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_SSSE3_H 2 | #define ARGON2_SSSE3_H 3 | 4 | #include "core.h" 5 | 6 | void xmrig_ar2_fill_segment_ssse3(const argon2_instance_t *instance, argon2_position_t position); 7 | int xmrig_ar2_check_ssse3(void); 8 | 9 | #endif // ARGON2_SSSE3_H 10 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/arch/x86_64/lib/argon2-xop.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_XOP_H 2 | #define ARGON2_XOP_H 3 | 4 | #include "core.h" 5 | 6 | void xmrig_ar2_fill_segment_xop(const argon2_instance_t *instance, argon2_position_t position); 7 | int xmrig_ar2_check_xop(void); 8 | 9 | #endif // ARGON2_XOP_H 10 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/arch/x86_64/src/test-feature-avx2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void function_avx2(__m256i *dst, const __m256i *a, const __m256i *b) 4 | { 5 | *dst = _mm256_xor_si256(*a, *b); 6 | } 7 | 8 | int main(void) { return 0; } 9 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/arch/x86_64/src/test-feature-avx512f.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void function_avx512f(__m512i *dst, const __m512i *a) 4 | { 5 | *dst = _mm512_ror_epi64(*a, 57); 6 | } 7 | 8 | int main(void) { return 0; } 9 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/arch/x86_64/src/test-feature-sse2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void function_sse2(__m128i *dst, const __m128i *a, const __m128i *b) 4 | { 5 | *dst = _mm_xor_si128(*a, *b); 6 | } 7 | 8 | int main(void) { return 0; } 9 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/arch/x86_64/src/test-feature-ssse3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void function_ssse3(__m128i *dst, const __m128i *a, const __m128i *b) 4 | { 5 | *dst = _mm_shuffle_epi8(*a, *b); 6 | } 7 | 8 | int main(void) { return 0; } 9 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/arch/x86_64/src/test-feature-xop.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void function_xop(__m128i *dst, const __m128i *a, int b) 4 | { 5 | *dst = _mm_roti_epi64(*a, b); 6 | } 7 | 8 | int main(void) { return 0; } 9 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/lib/blake2/blake2.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_BLAKE2_H 2 | #define ARGON2_BLAKE2_H 3 | 4 | #include 5 | #include 6 | 7 | enum blake2b_constant { 8 | BLAKE2B_BLOCKBYTES = 128, 9 | BLAKE2B_OUTBYTES = 64, 10 | BLAKE2B_KEYBYTES = 64, 11 | BLAKE2B_SALTBYTES = 16, 12 | BLAKE2B_PERSONALBYTES = 16 13 | }; 14 | 15 | typedef struct __blake2b_state { 16 | uint64_t h[8]; 17 | uint64_t t[2]; 18 | uint8_t buf[BLAKE2B_BLOCKBYTES]; 19 | size_t buflen; 20 | } blake2b_state; 21 | 22 | /* Streaming API */ 23 | void xmrig_ar2_blake2b_init(blake2b_state *S, size_t outlen); 24 | void xmrig_ar2_blake2b_update(blake2b_state *S, const void *in, size_t inlen); 25 | void xmrig_ar2_blake2b_final(blake2b_state *S, void *out, size_t outlen); 26 | 27 | void xmrig_ar2_blake2b_long(void *out, size_t outlen, const void *in, size_t inlen); 28 | 29 | #endif // ARGON2_BLAKE2_H 30 | 31 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/lib/encoding.h: -------------------------------------------------------------------------------- 1 | #ifndef ENCODING_H 2 | #define ENCODING_H 3 | #include "3rdparty/argon2.h" 4 | 5 | #define ARGON2_MAX_DECODED_LANES UINT32_C(255) 6 | #define ARGON2_MIN_DECODED_SALT_LEN UINT32_C(8) 7 | #define ARGON2_MIN_DECODED_OUT_LEN UINT32_C(12) 8 | 9 | /* 10 | * encode an Argon2 hash string into the provided buffer. 'dst_len' 11 | * contains the size, in characters, of the 'dst' buffer; if 'dst_len' 12 | * is less than the number of required characters (including the 13 | * terminating 0), then this function returns ARGON2_ENCODING_ERROR. 14 | * 15 | * on success, ARGON2_OK is returned. 16 | */ 17 | int encode_string(char *dst, size_t dst_len, argon2_context *ctx, 18 | argon2_type type); 19 | 20 | /* 21 | * Decodes an Argon2 hash string into the provided structure 'ctx'. 22 | * The only fields that must be set prior to this call are ctx.saltlen and 23 | * ctx.outlen (which must be the maximal salt and out length values that are 24 | * allowed), ctx.salt and ctx.out (which must be buffers of the specified 25 | * length), and ctx.pwd and ctx.pwdlen which must hold a valid password. 26 | * 27 | * Invalid input string causes an error. On success, the ctx is valid and all 28 | * fields have been initialized. 29 | * 30 | * Returned value is ARGON2_OK on success, other ARGON2_ codes on error. 31 | */ 32 | int decode_string(argon2_context *ctx, const char *str, argon2_type type); 33 | 34 | /* Returns the length of the encoded byte stream with length len */ 35 | size_t b64len(uint32_t len); 36 | 37 | /* Returns the length of the encoded number num */ 38 | size_t numlen(uint32_t num); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/lib/genkat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Argon2 source code package 3 | * 4 | * Written by Daniel Dinu and Dmitry Khovratovich, 2015 5 | * 6 | * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. 7 | * 8 | * You should have received a copy of the CC0 Public Domain Dedication along 9 | * with 10 | * this software. If not, see 11 | * . 12 | */ 13 | 14 | #ifndef ARGON2_KAT_H 15 | #define ARGON2_KAT_H 16 | 17 | #include "core.h" 18 | 19 | /* 20 | * Initial KAT function that prints the inputs to the file 21 | * @param blockhash Array that contains pre-hashing digest 22 | * @param context Holds inputs 23 | * @param type Argon2 type 24 | * @pre blockhash must point to INPUT_INITIAL_HASH_LENGTH bytes 25 | * @pre context member pointers must point to allocated memory of size according 26 | * to the length values 27 | */ 28 | void initial_kat(const uint8_t *blockhash, const argon2_context *context, 29 | argon2_type type); 30 | 31 | /* 32 | * Function that prints the output tag 33 | * @param out output array pointer 34 | * @param outlen digest length 35 | * @pre out must point to @a outlen bytes 36 | **/ 37 | void print_tag(const void *out, uint32_t outlen); 38 | 39 | /* 40 | * Function that prints the internal state at given moment 41 | * @param instance pointer to the current instance 42 | * @param pass current pass number 43 | * @pre instance must have necessary memory allocated 44 | **/ 45 | void internal_kat(const argon2_instance_t *instance, uint32_t pass); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/3rdparty/argon2/lib/impl-select.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_IMPL_SELECT_H 2 | #define ARGON2_IMPL_SELECT_H 3 | 4 | #include "core.h" 5 | 6 | typedef struct Argon2_impl { 7 | const char *name; 8 | int (*check)(void); 9 | void (*fill_segment)(const argon2_instance_t *instance, 10 | argon2_position_t position); 11 | } argon2_impl; 12 | 13 | typedef struct Argon2_impl_list { 14 | const argon2_impl *entries; 15 | size_t count; 16 | } argon2_impl_list; 17 | 18 | void argon2_get_impl_list(argon2_impl_list *list); 19 | void fill_segment_default(const argon2_instance_t *instance, 20 | argon2_position_t position); 21 | 22 | #endif // ARGON2_IMPL_SELECT_H 23 | 24 | -------------------------------------------------------------------------------- /src/3rdparty/cl.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2019 SChernykh 9 | * Copyright 2016-2019 XMRig , 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | #ifndef XMRIG_CL_H 26 | #define XMRIG_CL_H 27 | 28 | 29 | #if defined(__APPLE__) 30 | # include 31 | #else 32 | # include "3rdparty/CL/cl.h" 33 | #endif 34 | 35 | 36 | #endif /* XMRIG_CL_H */ 37 | -------------------------------------------------------------------------------- /src/3rdparty/fmt/LICENSE.rst: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - present, Victor Zverovich 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | --- Optional exception to the license --- 23 | 24 | As an exception, if, as a result of your compiling your source code, portions 25 | of this Software are embedded into a machine-executable object form of such 26 | source code, you may redistribute such embedded portions in such object form 27 | without including the above copyright and permission notices. 28 | -------------------------------------------------------------------------------- /src/3rdparty/fmt/posix.h: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #warning "fmt/posix.h is deprecated; use fmt/os.h instead" 3 | -------------------------------------------------------------------------------- /src/3rdparty/http-parser/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright Joyent, Inc. and other Node contributors. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to 5 | deal in the Software without restriction, including without limitation the 6 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /src/3rdparty/hwloc/AUTHORS: -------------------------------------------------------------------------------- 1 | hwloc Authors 2 | ============= 3 | 4 | The following cumulative list contains the names of most individuals 5 | who have committed code to the hwloc repository 6 | (either directly or through a third party). 7 | 8 | Name Affiliation(s) 9 | --------------------------- -------------------- 10 | Grzegorz Andrejczuk Intel 11 | Cédric Augonnet University of Bordeaux 12 | Guillaume Beauchamp Inria 13 | Ahmad Boissetri Binzagr Inria 14 | Cyril Bordage Inria 15 | Nicholas Buroker UWL 16 | Christopher M. Cantalupo Intel 17 | Jérôme Clet-Ortega University of Bordeaux 18 | Ludovic Courtès Inria 19 | Clément Foyer Inria 20 | Nathalie Furmento CNRS 21 | Bryon Gloden 22 | Brice Goglin Inria 23 | Gilles Gouaillardet RIST 24 | Valentin Hoyet Inria 25 | Joshua Hursey UWL 26 | Alexey Kardashevskiy IBM 27 | Rob Latham ANL 28 | Douglas MacFarland UWL 29 | Marc Marí BSC 30 | Jonathan L Peyton Intel 31 | Piotr Luc Intel 32 | Antoine Rougier intern from University of Bordeaux 33 | Jeff Squyres Cisco 34 | Samuel Thibault University of Bordeaux 35 | Jean-Yves VET DDN 36 | Benjamin Worpitz 37 | Jeff Zhao Zhaoxin 38 | 39 | Affiliaion abbreviations: 40 | ------------------------- 41 | ANL = Argonne National Lab 42 | BSC = Barcelona Supercomputing Center 43 | Cisco = Cisco Systems, Inc. 44 | CNRS = Centre national de la recherche scientifique (France) 45 | UWL = University of Wisconsin-La Crosse 46 | -------------------------------------------------------------------------------- /src/3rdparty/hwloc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8.12) 2 | project (hwloc C) 3 | 4 | include_directories(include) 5 | include_directories(src) 6 | 7 | add_definitions(/D_CRT_SECURE_NO_WARNINGS) 8 | set(CMAKE_C_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG") 9 | 10 | set(HEADERS 11 | include/hwloc.h 12 | src/static-components.h 13 | ) 14 | 15 | set(SOURCES 16 | src/base64.c 17 | src/bind.c 18 | src/bitmap.c 19 | src/components.c 20 | src/diff.c 21 | src/distances.c 22 | src/misc.c 23 | src/pci-common.c 24 | src/shmem.c 25 | src/topology.c 26 | src/topology-noos.c 27 | src/topology-synthetic.c 28 | src/topology-windows.c 29 | src/topology-x86.c 30 | src/topology-xml.c 31 | src/topology-xml-nolibxml.c 32 | src/traversal.c 33 | src/memattrs.c 34 | src/cpukinds.c 35 | ) 36 | 37 | add_library(hwloc STATIC 38 | ${HEADERS} 39 | ${SOURCES} 40 | ) 41 | -------------------------------------------------------------------------------- /src/3rdparty/hwloc/include/hwloc/autogen/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2009 CNRS 3 | * Copyright © 2009-2020 Inria. All rights reserved. 4 | * Copyright © 2009-2012 Université Bordeaux 5 | * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved. 6 | * See COPYING in top-level directory. 7 | */ 8 | 9 | /* The configuration file */ 10 | 11 | #ifndef HWLOC_CONFIG_H 12 | #define HWLOC_CONFIG_H 13 | 14 | #define HWLOC_VERSION "2.4.1" 15 | #define HWLOC_VERSION_MAJOR 2 16 | #define HWLOC_VERSION_MINOR 4 17 | #define HWLOC_VERSION_RELEASE 1 18 | #define HWLOC_VERSION_GREEK "" 19 | 20 | #define __hwloc_restrict 21 | #define __hwloc_inline __inline 22 | 23 | #define __hwloc_attribute_unused 24 | #define __hwloc_attribute_malloc 25 | #define __hwloc_attribute_const 26 | #define __hwloc_attribute_pure 27 | #define __hwloc_attribute_deprecated 28 | #define __hwloc_attribute_may_alias 29 | #define __hwloc_attribute_warn_unused_result 30 | 31 | /* Defined to 1 if you have the `windows.h' header. */ 32 | #define HWLOC_HAVE_WINDOWS_H 1 33 | #define hwloc_pid_t HANDLE 34 | #define hwloc_thread_t HANDLE 35 | 36 | #include 37 | #include 38 | typedef DWORDLONG hwloc_uint64_t; 39 | 40 | #if defined( _USRDLL ) /* dynamic linkage */ 41 | #if defined( DECLSPEC_EXPORTS ) 42 | #define HWLOC_DECLSPEC __declspec(dllexport) 43 | #else 44 | #define HWLOC_DECLSPEC __declspec(dllimport) 45 | #endif 46 | #else /* static linkage */ 47 | #define HWLOC_DECLSPEC 48 | #endif 49 | 50 | /* Whether we need to re-define all the hwloc public symbols or not */ 51 | #define HWLOC_SYM_TRANSFORM 0 52 | 53 | /* The hwloc symbol prefix */ 54 | #define HWLOC_SYM_PREFIX hwloc_ 55 | 56 | /* The hwloc symbol prefix in all caps */ 57 | #define HWLOC_SYM_PREFIX_CAPS HWLOC_ 58 | 59 | #endif /* HWLOC_CONFIG_H */ 60 | -------------------------------------------------------------------------------- /src/3rdparty/hwloc/include/private/solaris-chiptype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2009-2010 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * Copyright © 2017 Inria. All rights reserved. 5 | * $COPYRIGHT$ 6 | * 7 | * Additional copyrights may follow 8 | * 9 | * $HEADER$ 10 | */ 11 | 12 | 13 | #ifdef HWLOC_INSIDE_PLUGIN 14 | /* 15 | * these declarations are internal only, they are not available to plugins 16 | * (functions below are internal static symbols). 17 | */ 18 | #error This file should not be used in plugins 19 | #endif 20 | 21 | 22 | #ifndef HWLOC_PRIVATE_SOLARIS_CHIPTYPE_H 23 | #define HWLOC_PRIVATE_SOLARIS_CHIPTYPE_H 24 | 25 | struct hwloc_solaris_chip_info_s { 26 | char *model; 27 | char *type; 28 | /* L1i, L1d, L2, L3 */ 29 | #define HWLOC_SOLARIS_CHIP_INFO_L1I 0 30 | #define HWLOC_SOLARIS_CHIP_INFO_L1D 1 31 | #define HWLOC_SOLARIS_CHIP_INFO_L2I 2 32 | #define HWLOC_SOLARIS_CHIP_INFO_L2D 3 33 | #define HWLOC_SOLARIS_CHIP_INFO_L3 4 34 | long cache_size[5]; /* cleared to -1 if we don't want of that cache */ 35 | unsigned cache_linesize[5]; 36 | unsigned cache_associativity[5]; 37 | int l2_unified; 38 | }; 39 | 40 | /* fills the structure with 0 on error */ 41 | extern void hwloc_solaris_get_chip_info(struct hwloc_solaris_chip_info_s *info); 42 | 43 | #endif /* HWLOC_PRIVATE_SOLARIS_CHIPTYPE_H */ 44 | -------------------------------------------------------------------------------- /src/3rdparty/hwloc/src/static-components.h: -------------------------------------------------------------------------------- 1 | HWLOC_DECLSPEC extern const struct hwloc_component hwloc_noos_component; 2 | HWLOC_DECLSPEC extern const struct hwloc_component hwloc_xml_component; 3 | HWLOC_DECLSPEC extern const struct hwloc_component hwloc_synthetic_component; 4 | HWLOC_DECLSPEC extern const struct hwloc_component hwloc_xml_nolibxml_component; 5 | HWLOC_DECLSPEC extern const struct hwloc_component hwloc_windows_component; 6 | HWLOC_DECLSPEC extern const struct hwloc_component hwloc_x86_component; 7 | static const struct hwloc_component * hwloc_static_components[] = { 8 | &hwloc_noos_component, 9 | &hwloc_xml_component, 10 | &hwloc_synthetic_component, 11 | &hwloc_xml_nolibxml_component, 12 | &hwloc_windows_component, 13 | &hwloc_x86_component, 14 | NULL 15 | }; 16 | -------------------------------------------------------------------------------- /src/3rdparty/libethash/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8.12) 2 | project (ethash C) 3 | 4 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Os") 5 | 6 | set(HEADERS 7 | data_sizes.h 8 | endian.h 9 | ethash.h 10 | ethash_internal.h 11 | fnv.h 12 | ) 13 | 14 | set(SOURCES 15 | ethash_internal.c 16 | keccakf800.c 17 | ) 18 | 19 | include_directories(../..) 20 | 21 | add_library(ethash STATIC 22 | ${HEADERS} 23 | ${SOURCES} 24 | ) 25 | -------------------------------------------------------------------------------- /src/3rdparty/libethash/fnv.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of cpp-ethereum. 3 | 4 | cpp-ethereum is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | cpp-ethereum is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with cpp-ethereum. If not, see . 16 | */ 17 | /** @file fnv.h 18 | * @author Matthew Wampler-Doty 19 | * @date 2015 20 | */ 21 | 22 | #pragma once 23 | #include 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #define FNV_PRIME 0x01000193 30 | 31 | /* The FNV-1 spec multiplies the prime with the input one byte (octet) in turn. 32 | We instead multiply it with the full 32-bit input. 33 | This gives a different result compared to a canonical FNV-1 implementation. 34 | */ 35 | static inline uint32_t fnv_hash(uint32_t const x, uint32_t const y) 36 | { 37 | return x * FNV_PRIME ^ y; 38 | } 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /src/3rdparty/llhttp/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | This software is licensed under the MIT License. 2 | 3 | Copyright Fedor Indutny, 2018. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to permit 10 | persons to whom the Software is furnished to do so, subject to the 11 | following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 19 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 21 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 22 | USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/3rdparty/rapidjson/internal/swap.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_SWAP_H_ 16 | #define RAPIDJSON_INTERNAL_SWAP_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(__clang__) 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(c++98-compat) 23 | #endif 24 | 25 | RAPIDJSON_NAMESPACE_BEGIN 26 | namespace internal { 27 | 28 | //! Custom swap() to avoid dependency on C++ header 29 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. 30 | \note This has the same semantics as std::swap(). 31 | */ 32 | template 33 | inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT { 34 | T tmp = a; 35 | a = b; 36 | b = tmp; 37 | } 38 | 39 | } // namespace internal 40 | RAPIDJSON_NAMESPACE_END 41 | 42 | #if defined(__clang__) 43 | RAPIDJSON_DIAG_POP 44 | #endif 45 | 46 | #endif // RAPIDJSON_INTERNAL_SWAP_H_ 47 | -------------------------------------------------------------------------------- /src/Summary.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2021 SChernykh 9 | * Copyright 2016-2021 XMRig , 10 | * Copyright 2018-2021 The Scala Project Team , 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation, either version 3 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with this program. If not, see . 24 | */ 25 | 26 | #ifndef XMRIG_SUMMARY_H 27 | #define XMRIG_SUMMARY_H 28 | 29 | 30 | namespace xmrig { 31 | 32 | 33 | class Controller; 34 | 35 | 36 | class Summary 37 | { 38 | public: 39 | static void print(Controller *controller); 40 | }; 41 | 42 | 43 | } // namespace xmrig 44 | 45 | 46 | #endif /* XMRIG_SUMMARY_H */ 47 | -------------------------------------------------------------------------------- /src/backend/backend.cmake: -------------------------------------------------------------------------------- 1 | include(src/backend/cpu/cpu.cmake) 2 | include(src/backend/common/common.cmake) 3 | 4 | 5 | set(HEADERS_BACKEND 6 | "${HEADERS_BACKEND_COMMON}" 7 | "${HEADERS_BACKEND_CPU}" 8 | ) 9 | 10 | set(SOURCES_BACKEND 11 | "${SOURCES_BACKEND_COMMON}" 12 | "${SOURCES_BACKEND_CPU}" 13 | ) 14 | -------------------------------------------------------------------------------- /src/backend/common/HashrateInterpolator.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2018-2020 SChernykh 3 | * Copyright 2016-2020 XMRig , 4 | * Copyright 2018-2021 The Scala Project Team , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef XMRIG_HASHRATE_INTERPOLATOR_H 21 | #define XMRIG_HASHRATE_INTERPOLATOR_H 22 | 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | namespace xmrig { 30 | 31 | 32 | class HashrateInterpolator 33 | { 34 | public: 35 | enum { 36 | LagMS = 4000, 37 | }; 38 | 39 | uint64_t interpolate(uint64_t timeStamp) const; 40 | void addDataPoint(uint64_t count, uint64_t timeStamp); 41 | 42 | private: 43 | // Buffer of hashrate counters, used for linear interpolation of past data 44 | mutable std::mutex m_lock; 45 | std::deque > m_data; 46 | }; 47 | 48 | 49 | } // namespace xmrig 50 | 51 | 52 | #endif /* XMRIG_HASHRATE_INTERPOLATOR_H */ 53 | -------------------------------------------------------------------------------- /src/backend/common/Tags.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018 Lee Clagett 9 | * Copyright 2018-2020 SChernykh 10 | * Copyright 2016-2020 XMRig , 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation, either version 3 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with this program. If not, see . 24 | */ 25 | 26 | #ifndef XMRIG_BACKEND_TAGS_H 27 | #define XMRIG_BACKEND_TAGS_H 28 | 29 | 30 | #include 31 | 32 | 33 | namespace xmrig { 34 | 35 | 36 | const char *backend_tag(uint32_t backend); 37 | const char *cpu_tag(); 38 | 39 | 40 | #ifdef XMRIG_FEATURE_OPENCL 41 | const char *ocl_tag(); 42 | #endif 43 | 44 | 45 | #ifdef XMRIG_FEATURE_CUDA 46 | const char *cuda_tag(); 47 | #endif 48 | 49 | 50 | } // namespace xmrig 51 | 52 | 53 | #endif /* XMRIG_BACKEND_TAGS_H */ 54 | -------------------------------------------------------------------------------- /src/backend/common/Worker.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * Copyright 2018-2021 The Scala Project Team , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | 21 | #include "backend/common/Worker.h" 22 | #include "base/kernel/Platform.h" 23 | #include "crypto/common/VirtualMemory.h" 24 | 25 | 26 | xmrig::Worker::Worker(size_t id, int64_t affinity, int priority) : 27 | m_affinity(affinity), 28 | m_id(id) 29 | { 30 | m_node = VirtualMemory::bindToNUMANode(affinity); 31 | 32 | Platform::trySetThreadAffinity(affinity); 33 | Platform::setThreadPriority(priority); 34 | } 35 | -------------------------------------------------------------------------------- /src/backend/common/Worker.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_WORKER_H 20 | #define XMRIG_WORKER_H 21 | 22 | 23 | #include "backend/common/interfaces/IWorker.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class Worker : public IWorker 30 | { 31 | public: 32 | Worker(size_t id, int64_t affinity, int priority); 33 | 34 | protected: 35 | inline int64_t affinity() const { return m_affinity; } 36 | inline size_t id() const override { return m_id; } 37 | inline uint32_t node() const { return m_node; } 38 | 39 | uint64_t m_count = 0; 40 | 41 | private: 42 | const int64_t m_affinity; 43 | const size_t m_id; 44 | uint32_t m_node = 0; 45 | }; 46 | 47 | 48 | } // namespace xmrig 49 | 50 | 51 | #endif /* XMRIG_WORKER_H */ 52 | -------------------------------------------------------------------------------- /src/backend/common/common.cmake: -------------------------------------------------------------------------------- 1 | set(HEADERS_BACKEND_COMMON 2 | src/backend/common/Hashrate.h 3 | src/backend/common/Tags.h 4 | src/backend/common/interfaces/IBackend.h 5 | src/backend/common/interfaces/IRxListener.h 6 | src/backend/common/interfaces/IRxStorage.h 7 | src/backend/common/interfaces/IWorker.h 8 | src/backend/common/misc/PciTopology.h 9 | src/backend/common/Thread.h 10 | src/backend/common/Threads.h 11 | src/backend/common/Worker.h 12 | src/backend/common/WorkerJob.h 13 | src/backend/common/Workers.h 14 | ) 15 | 16 | set(SOURCES_BACKEND_COMMON 17 | src/backend/common/Hashrate.cpp 18 | src/backend/common/Threads.cpp 19 | src/backend/common/Worker.cpp 20 | src/backend/common/Workers.cpp 21 | ) 22 | -------------------------------------------------------------------------------- /src/backend/common/interfaces/IBenchListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_IBENCHLISTENER_H 20 | #define XMRIG_IBENCHLISTENER_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class IBackend; 30 | 31 | 32 | class IBenchListener 33 | { 34 | public: 35 | XMRIG_DISABLE_COPY_MOVE(IBenchListener) 36 | 37 | IBenchListener() = default; 38 | virtual ~IBenchListener() = default; 39 | 40 | virtual void onBenchDone(uint64_t result, uint64_t diff, uint64_t ts) = 0; 41 | virtual void onBenchReady(uint64_t ts, uint32_t threads, const IBackend *backend) = 0; 42 | }; 43 | 44 | 45 | } /* namespace xmrig */ 46 | 47 | 48 | #endif // XMRIG_IBENCHLISTENER_H 49 | -------------------------------------------------------------------------------- /src/backend/common/interfaces/IMemoryPool.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_IMEMORYPOOL_H 20 | #define XMRIG_IMEMORYPOOL_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | 25 | 26 | #include 27 | #include 28 | 29 | 30 | namespace xmrig { 31 | 32 | 33 | class IMemoryPool 34 | { 35 | public: 36 | XMRIG_DISABLE_COPY_MOVE(IMemoryPool) 37 | 38 | IMemoryPool() = default; 39 | virtual ~IMemoryPool() = default; 40 | 41 | virtual bool isHugePages(uint32_t node) const = 0; 42 | virtual uint8_t *get(size_t size, uint32_t node) = 0; 43 | virtual void release(uint32_t node) = 0; 44 | }; 45 | 46 | 47 | } /* namespace xmrig */ 48 | 49 | 50 | 51 | #endif /* XMRIG_IMEMORYPOOL_H */ 52 | -------------------------------------------------------------------------------- /src/backend/common/interfaces/IRxListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2019 tevador 3 | * Copyright (c) 2018-2020 SChernykh 4 | * Copyright (c) 2016-2020 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef XMRIG_IRXLISTENER_H 21 | #define XMRIG_IRXLISTENER_H 22 | 23 | 24 | #include "base/tools/Object.h" 25 | 26 | 27 | namespace xmrig { 28 | 29 | 30 | class IRxListener 31 | { 32 | public: 33 | XMRIG_DISABLE_COPY_MOVE(IRxListener) 34 | 35 | IRxListener() = default; 36 | virtual ~IRxListener() = default; 37 | 38 | # ifdef XMRIG_ALGO_RANDOMX 39 | virtual void onDatasetReady() = 0; 40 | # endif 41 | }; 42 | 43 | 44 | } /* namespace xmrig */ 45 | 46 | 47 | #endif // XMRIG_IRXLISTENER_H 48 | -------------------------------------------------------------------------------- /src/backend/cpu/Cpu.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include 21 | 22 | 23 | #include "backend/cpu/Cpu.h" 24 | #include "3rdparty/rapidjson/document.h" 25 | 26 | 27 | #if defined(XMRIG_FEATURE_HWLOC) 28 | # include "backend/cpu/platform/HwlocCpuInfo.h" 29 | #else 30 | # include "backend/cpu/platform/BasicCpuInfo.h" 31 | #endif 32 | 33 | 34 | static xmrig::ICpuInfo *cpuInfo = nullptr; 35 | 36 | 37 | xmrig::ICpuInfo *xmrig::Cpu::info() 38 | { 39 | if (cpuInfo == nullptr) { 40 | # if defined(XMRIG_FEATURE_HWLOC) 41 | cpuInfo = new HwlocCpuInfo(); 42 | # else 43 | cpuInfo = new BasicCpuInfo(); 44 | # endif 45 | } 46 | 47 | return cpuInfo; 48 | } 49 | 50 | 51 | rapidjson::Value xmrig::Cpu::toJSON(rapidjson::Document &doc) 52 | { 53 | return info()->toJSON(doc); 54 | } 55 | 56 | 57 | void xmrig::Cpu::release() 58 | { 59 | delete cpuInfo; 60 | cpuInfo = nullptr; 61 | } 62 | -------------------------------------------------------------------------------- /src/backend/cpu/Cpu.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_CPU_H 20 | #define XMRIG_CPU_H 21 | 22 | 23 | #include "backend/cpu/interfaces/ICpuInfo.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class Cpu 30 | { 31 | public: 32 | static ICpuInfo *info(); 33 | static rapidjson::Value toJSON(rapidjson::Document &doc); 34 | static void release(); 35 | 36 | inline static Assembly::Id assembly(Assembly::Id hint) { return hint == Assembly::AUTO ? Cpu::info()->assembly() : hint; } 37 | }; 38 | 39 | 40 | } /* namespace xmrig */ 41 | 42 | 43 | #endif /* XMRIG_CPU_H */ 44 | -------------------------------------------------------------------------------- /src/base/api/interfaces/IApiListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2018-2021 SChernykh 3 | * Copyright 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_IAPILISTENER_H 20 | #define XMRIG_IAPILISTENER_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class IApiRequest; 30 | 31 | 32 | class IApiListener 33 | { 34 | public: 35 | XMRIG_DISABLE_COPY_MOVE(IApiListener) 36 | 37 | IApiListener() = default; 38 | virtual ~IApiListener() = default; 39 | 40 | # ifdef XMRIG_FEATURE_API 41 | virtual void onRequest(IApiRequest &request) = 0; 42 | # endif 43 | }; 44 | 45 | 46 | } /* namespace xmrig */ 47 | 48 | 49 | #endif // XMRIG_IAPILISTENER_H 50 | -------------------------------------------------------------------------------- /src/base/api/requests/ApiRequest.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2019 SChernykh 9 | * Copyright 2016-2019 XMRig , 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | 26 | #include "base/api/requests/ApiRequest.h" 27 | 28 | 29 | xmrig::ApiRequest::ApiRequest(Source source, bool restricted) : 30 | m_restricted(restricted), 31 | m_source(source) 32 | { 33 | } 34 | 35 | 36 | xmrig::ApiRequest::~ApiRequest() = default; 37 | -------------------------------------------------------------------------------- /src/base/io/Async.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2015-2020 libuv project contributors. 3 | * Copyright (c) 2020 cohcho 4 | * Copyright (c) 2018-2020 SChernykh 5 | * Copyright (c) 2016-2020 XMRig , 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #ifndef XMRIG_ASYNC_H 22 | #define XMRIG_ASYNC_H 23 | 24 | 25 | #include "base/tools/Object.h" 26 | 27 | 28 | #include 29 | 30 | 31 | namespace xmrig { 32 | 33 | 34 | class AsyncPrivate; 35 | class IAsyncListener; 36 | 37 | 38 | class Async 39 | { 40 | public: 41 | XMRIG_DISABLE_COPY_MOVE_DEFAULT(Async) 42 | 43 | using Callback = std::function; 44 | 45 | Async(Callback callback); 46 | Async(IAsyncListener *listener); 47 | ~Async(); 48 | 49 | void send(); 50 | 51 | private: 52 | AsyncPrivate *d_ptr; 53 | }; 54 | 55 | 56 | } // namespace xmrig 57 | 58 | 59 | #endif /* XMRIG_ASYNC_H */ 60 | -------------------------------------------------------------------------------- /src/base/io/Env.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_ENV_H 20 | #define XMRIG_ENV_H 21 | 22 | 23 | #include "base/tools/String.h" 24 | 25 | 26 | #include 27 | 28 | 29 | namespace xmrig { 30 | 31 | 32 | class Env 33 | { 34 | public: 35 | static String expand(const char *in, const std::map &extra = {}); 36 | static String get(const String &name, const std::map &extra = {}); 37 | static String hostname(); 38 | }; 39 | 40 | 41 | } /* namespace xmrig */ 42 | 43 | 44 | #endif /* XMRIG_ENV_H */ 45 | -------------------------------------------------------------------------------- /src/base/io/Signals.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_SIGNALS_H 20 | #define XMRIG_SIGNALS_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | 25 | 26 | #include 27 | #include 28 | 29 | 30 | using uv_signal_t = struct uv_signal_s; 31 | 32 | 33 | namespace xmrig { 34 | 35 | 36 | class ISignalListener; 37 | 38 | 39 | class Signals 40 | { 41 | public: 42 | XMRIG_DISABLE_COPY_MOVE_DEFAULT(Signals) 43 | 44 | # ifdef SIGUSR1 45 | constexpr static const size_t kSignalsCount = 4; 46 | # else 47 | constexpr static const size_t kSignalsCount = 3; 48 | # endif 49 | 50 | Signals(ISignalListener *listener); 51 | ~Signals(); 52 | 53 | private: 54 | void close(int signum); 55 | 56 | static void onSignal(uv_signal_t *handle, int signum); 57 | 58 | ISignalListener *m_listener; 59 | uv_signal_t *m_signals[kSignalsCount]{}; 60 | }; 61 | 62 | 63 | } /* namespace xmrig */ 64 | 65 | 66 | #endif /* XMRIG_SIGNALS_H */ 67 | -------------------------------------------------------------------------------- /src/base/io/log/FileLogWriter.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2021 SChernykh 3 | * Copyright (c) 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_FILELOGWRITER_H 20 | #define XMRIG_FILELOGWRITER_H 21 | 22 | 23 | #include 24 | #include 25 | 26 | 27 | namespace xmrig { 28 | 29 | 30 | class FileLogWriter 31 | { 32 | public: 33 | FileLogWriter() = default; 34 | FileLogWriter(const char *fileName) { open(fileName); } 35 | 36 | inline bool isOpen() const { return m_file >= 0; } 37 | inline int64_t pos() const { return m_pos; } 38 | 39 | bool open(const char *fileName); 40 | bool write(const char *data, size_t size); 41 | bool writeLine(const char *data, size_t size); 42 | 43 | private: 44 | # ifdef XMRIG_OS_WIN 45 | char m_endl[3] = "\r\n"; 46 | # else 47 | char m_endl[2] = "\n"; 48 | # endif 49 | 50 | int m_file = -1; 51 | int64_t m_pos = 0; 52 | }; 53 | 54 | 55 | } /* namespace xmrig */ 56 | 57 | 58 | #endif /* XMRIG_FILELOGWRITER_H */ 59 | -------------------------------------------------------------------------------- /src/base/io/log/backends/FileLog.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2019 Spudz76 3 | * Copyright (c) 2018-2020 SChernykh 4 | * Copyright (c) 2016-2020 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | 21 | #include "base/io/log/backends/FileLog.h" 22 | 23 | 24 | #include 25 | #include 26 | 27 | 28 | xmrig::FileLog::FileLog(const char *fileName) : 29 | m_writer(fileName) 30 | { 31 | } 32 | 33 | 34 | void xmrig::FileLog::print(uint64_t, int, const char *line, size_t, size_t size, bool colors) 35 | { 36 | if (!m_writer.isOpen() || colors) { 37 | return; 38 | } 39 | 40 | assert(strlen(line) == size); 41 | 42 | m_writer.write(line, size); 43 | } 44 | -------------------------------------------------------------------------------- /src/base/io/log/backends/FileLog.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2019 Spudz76 3 | * Copyright (c) 2018-2020 SChernykh 4 | * Copyright (c) 2016-2020 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef XMRIG_FILELOG_H 21 | #define XMRIG_FILELOG_H 22 | 23 | 24 | #include "base/io/log/FileLogWriter.h" 25 | #include "base/kernel/interfaces/ILogBackend.h" 26 | 27 | 28 | namespace xmrig { 29 | 30 | 31 | class FileLog : public ILogBackend 32 | { 33 | public: 34 | FileLog(const char *fileName); 35 | 36 | protected: 37 | void print(uint64_t timestamp, int level, const char *line, size_t offset, size_t size, bool colors) override; 38 | 39 | private: 40 | FileLogWriter m_writer; 41 | }; 42 | 43 | 44 | } /* namespace xmrig */ 45 | 46 | 47 | #endif /* XMRIG_FILELOG_H */ 48 | -------------------------------------------------------------------------------- /src/base/io/log/backends/SysLog.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2019 Spudz76 3 | * Copyright (c) 2018-2020 SChernykh 4 | * Copyright (c) 2016-2020 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | 21 | #include 22 | 23 | 24 | #include "base/io/log/backends/SysLog.h" 25 | #include "version.h" 26 | 27 | 28 | xmrig::SysLog::SysLog() 29 | { 30 | openlog(APP_ID, LOG_PID, LOG_USER); 31 | } 32 | 33 | 34 | xmrig::SysLog::~SysLog() 35 | { 36 | closelog(); 37 | } 38 | 39 | 40 | void xmrig::SysLog::print(uint64_t, int level, const char *line, size_t offset, size_t, bool colors) 41 | { 42 | if (colors) { 43 | return; 44 | } 45 | 46 | syslog(level == -1 ? LOG_INFO : level, "%s", line + offset); 47 | } 48 | -------------------------------------------------------------------------------- /src/base/io/log/backends/SysLog.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2019 Spudz76 3 | * Copyright (c) 2018-2020 SChernykh 4 | * Copyright (c) 2016-2020 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef XMRIG_SYSLOG_H 21 | #define XMRIG_SYSLOG_H 22 | 23 | 24 | #include "base/kernel/interfaces/ILogBackend.h" 25 | 26 | 27 | namespace xmrig { 28 | 29 | 30 | class SysLog : public ILogBackend 31 | { 32 | public: 33 | XMRIG_DISABLE_COPY_MOVE(SysLog) 34 | 35 | SysLog(); 36 | ~SysLog() override; 37 | 38 | protected: 39 | void print(uint64_t timestamp, int level, const char *line, size_t offset, size_t size, bool colors) override; 40 | }; 41 | 42 | 43 | } /* namespace xmrig */ 44 | 45 | 46 | #endif /* XMRIG_SYSLOG_H */ 47 | -------------------------------------------------------------------------------- /src/base/kernel/Entry.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2019 SChernykh 9 | * Copyright 2016-2019 XMRig , 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | #ifndef XMRIG_ENTRY_H 26 | #define XMRIG_ENTRY_H 27 | 28 | 29 | namespace xmrig { 30 | 31 | 32 | class Process; 33 | 34 | 35 | class Entry 36 | { 37 | public: 38 | enum Id { 39 | Default, 40 | Usage, 41 | Version, 42 | Topo, 43 | Platforms 44 | }; 45 | 46 | static Id get(const Process &process); 47 | static int exec(const Process &process, Id id); 48 | }; 49 | 50 | 51 | } /* namespace xmrig */ 52 | 53 | 54 | #endif /* XMRIG_ENTRY_H */ 55 | -------------------------------------------------------------------------------- /src/base/kernel/Platform.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2021 SChernykh 3 | * Copyright (c) 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include "base/kernel/Platform.h" 21 | 22 | 23 | #include 24 | #include 25 | 26 | 27 | #ifdef XMRIG_FEATURE_TLS 28 | # include 29 | # include 30 | #endif 31 | 32 | 33 | namespace xmrig { 34 | 35 | String Platform::m_userAgent; 36 | 37 | } // namespace xmrig 38 | 39 | 40 | void xmrig::Platform::init(const char *userAgent) 41 | { 42 | # ifdef XMRIG_FEATURE_TLS 43 | SSL_library_init(); 44 | SSL_load_error_strings(); 45 | ERR_load_BIO_strings(); 46 | ERR_load_crypto_strings(); 47 | SSL_load_error_strings(); 48 | OpenSSL_add_all_digests(); 49 | # endif 50 | 51 | if (userAgent) { 52 | m_userAgent = userAgent; 53 | } 54 | else { 55 | m_userAgent = createUserAgent(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/base/kernel/Platform_hwloc.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include "base/kernel/Platform.h" 21 | #include "backend/cpu/platform/HwlocCpuInfo.h" 22 | #include "backend/cpu/Cpu.h" 23 | 24 | 25 | #include 26 | #include 27 | 28 | 29 | #ifndef XMRIG_OS_APPLE 30 | bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) 31 | { 32 | auto cpu = static_cast(Cpu::info()); 33 | hwloc_obj_t pu = hwloc_get_pu_obj_by_os_index(cpu->topology(), static_cast(cpu_id)); 34 | 35 | if (pu == nullptr) { 36 | return false; 37 | } 38 | 39 | if (hwloc_set_cpubind(cpu->topology(), pu->cpuset, HWLOC_CPUBIND_THREAD | HWLOC_CPUBIND_STRICT) >= 0) { 40 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); 41 | return true; 42 | } 43 | 44 | const bool result = (hwloc_set_cpubind(cpu->topology(), pu->cpuset, HWLOC_CPUBIND_THREAD) >= 0); 45 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); 46 | return result; 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /src/base/kernel/Process.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_PROCESS_H 20 | #define XMRIG_PROCESS_H 21 | 22 | 23 | #include "base/tools/Arguments.h" 24 | 25 | 26 | #ifdef WIN32 27 | # define XMRIG_DIR_SEPARATOR "\\" 28 | #else 29 | # define XMRIG_DIR_SEPARATOR "/" 30 | #endif 31 | 32 | 33 | namespace xmrig { 34 | 35 | 36 | class Process 37 | { 38 | public: 39 | enum Location { 40 | ExeLocation, 41 | CwdLocation, 42 | DataLocation, 43 | HomeLocation, 44 | TempLocation 45 | }; 46 | 47 | Process(int argc, char **argv); 48 | 49 | static int pid(); 50 | static int ppid(); 51 | static String exepath(); 52 | static String location(Location location, const char *fileName = nullptr); 53 | 54 | inline const Arguments &arguments() const { return m_arguments; } 55 | 56 | private: 57 | Arguments m_arguments; 58 | }; 59 | 60 | 61 | } /* namespace xmrig */ 62 | 63 | 64 | #endif /* XMRIG_PROCESS_H */ 65 | -------------------------------------------------------------------------------- /src/base/kernel/Process_unix.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include 21 | #include 22 | 23 | 24 | #include "base/kernel/Process.h" 25 | 26 | 27 | int xmrig::Process::pid() 28 | { 29 | # if UV_VERSION_HEX >= 0x011200 30 | return uv_os_getpid(); 31 | # else 32 | return getpid(); 33 | # endif 34 | } 35 | -------------------------------------------------------------------------------- /src/base/kernel/Process_win.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include 21 | 22 | 23 | #include "base/kernel/Process.h" 24 | 25 | 26 | int xmrig::Process::pid() 27 | { 28 | # if UV_VERSION_HEX >= 0x011200 29 | return uv_os_getpid(); 30 | # else 31 | return GetCurrentProcessId(); 32 | # endif 33 | } 34 | -------------------------------------------------------------------------------- /src/base/kernel/config/Title.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include "base/kernel/config/Title.h" 21 | #include "3rdparty/rapidjson/document.h" 22 | #include "base/io/Env.h" 23 | #include "version.h" 24 | 25 | 26 | xmrig::Title::Title(const rapidjson::Value &value) 27 | { 28 | if (value.IsBool()) { 29 | m_enabled = value.GetBool(); 30 | } 31 | else if (value.IsString()) { 32 | m_value = value.GetString(); 33 | } 34 | } 35 | 36 | 37 | rapidjson::Value xmrig::Title::toJSON() const 38 | { 39 | if (isEnabled() && !m_value.isNull()) { 40 | return m_value.toJSON(); 41 | } 42 | 43 | return rapidjson::Value(m_enabled); 44 | } 45 | 46 | 47 | xmrig::String xmrig::Title::value() const 48 | { 49 | if (!isEnabled()) { 50 | return {}; 51 | } 52 | 53 | if (m_value.isNull()) { 54 | return APP_NAME " " APP_VERSION; 55 | } 56 | 57 | return Env::expand(m_value); 58 | } 59 | -------------------------------------------------------------------------------- /src/base/kernel/config/Title.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_TITLE_H 20 | #define XMRIG_TITLE_H 21 | 22 | 23 | #include "3rdparty/rapidjson/fwd.h" 24 | #include "base/tools/String.h" 25 | 26 | 27 | namespace xmrig { 28 | 29 | 30 | class Title 31 | { 32 | public: 33 | Title() = default; 34 | Title(const rapidjson::Value &value); 35 | 36 | inline bool isEnabled() const { return m_enabled; } 37 | 38 | rapidjson::Value toJSON() const; 39 | String value() const; 40 | 41 | private: 42 | bool m_enabled = true; 43 | String m_value; 44 | }; 45 | 46 | 47 | } // namespace xmrig 48 | 49 | 50 | #endif /* XMRIG_TITLE_H */ 51 | -------------------------------------------------------------------------------- /src/base/kernel/constants.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_CONSTANTS_H 20 | #define XMRIG_CONSTANTS_H 21 | 22 | 23 | #include 24 | #include 25 | 26 | 27 | constexpr size_t XMRIG_NET_BUFFER_CHUNK_SIZE = 64 * 1024; 28 | constexpr size_t XMRIG_NET_BUFFER_INIT_CHUNKS = 4; 29 | 30 | 31 | #endif /* XMRIG_CONSTANTS_H */ 32 | -------------------------------------------------------------------------------- /src/base/kernel/interfaces/IAsyncListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2018-2020 SChernykh 3 | * Copyright 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_IASYNCLISTENER_H 20 | #define XMRIG_IASYNCLISTENER_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class Async; 30 | 31 | 32 | class IAsyncListener 33 | { 34 | public: 35 | XMRIG_DISABLE_COPY_MOVE(IAsyncListener) 36 | 37 | IAsyncListener() = default; 38 | virtual ~IAsyncListener() = default; 39 | 40 | virtual void onAsync() = 0; 41 | }; 42 | 43 | 44 | } /* namespace xmrig */ 45 | 46 | 47 | #endif // XMRIG_IASYNCLISTENER_H 48 | -------------------------------------------------------------------------------- /src/base/kernel/interfaces/IBaseListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2018-2021 SChernykh 3 | * Copyright 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_IBASELISTENER_H 20 | #define XMRIG_IBASELISTENER_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class Config; 30 | 31 | 32 | class IBaseListener 33 | { 34 | public: 35 | XMRIG_DISABLE_COPY_MOVE(IBaseListener) 36 | 37 | IBaseListener() = default; 38 | virtual ~IBaseListener() = default; 39 | 40 | virtual void onConfigChanged(Config *config, Config *previousConfig) = 0; 41 | }; 42 | 43 | 44 | } /* namespace xmrig */ 45 | 46 | 47 | #endif // XMRIG_IBASELISTENER_H 48 | -------------------------------------------------------------------------------- /src/base/kernel/interfaces/IConfigListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2019 SChernykh 9 | * Copyright 2016-2019 XMRig , 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | #ifndef XMRIG_ICONFIGLISTENER_H 26 | #define XMRIG_ICONFIGLISTENER_H 27 | 28 | 29 | namespace xmrig { 30 | 31 | 32 | class IConfig; 33 | 34 | 35 | class IConfigListener 36 | { 37 | public: 38 | virtual ~IConfigListener() = default; 39 | 40 | virtual void onNewConfig(IConfig *config) = 0; 41 | }; 42 | 43 | 44 | } /* namespace xmrig */ 45 | 46 | 47 | #endif // XMRIG_ICONFIGLISTENER_H 48 | -------------------------------------------------------------------------------- /src/base/kernel/interfaces/IConsoleListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_ICONSOLELISTENER_H 20 | #define XMRIG_ICONSOLELISTENER_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class IConsoleListener 30 | { 31 | public: 32 | XMRIG_DISABLE_COPY_MOVE(IConsoleListener) 33 | 34 | IConsoleListener() = default; 35 | virtual ~IConsoleListener() = default; 36 | 37 | virtual void onConsoleCommand(char command) = 0; 38 | }; 39 | 40 | 41 | } /* namespace xmrig */ 42 | 43 | 44 | #endif // XMRIG_ICONSOLELISTENER_H 45 | -------------------------------------------------------------------------------- /src/base/kernel/interfaces/IDnsListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_IDNSLISTENER_H 20 | #define XMRIG_IDNSLISTENER_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class Dns; 30 | 31 | 32 | class IDnsListener 33 | { 34 | public: 35 | XMRIG_DISABLE_COPY_MOVE(IDnsListener) 36 | 37 | IDnsListener() = default; 38 | virtual ~IDnsListener() = default; 39 | 40 | virtual void onResolved(const Dns &dns, int status) = 0; 41 | }; 42 | 43 | 44 | } /* namespace xmrig */ 45 | 46 | 47 | #endif // XMRIG_IDNSLISTENER_H 48 | -------------------------------------------------------------------------------- /src/base/kernel/interfaces/IHttpListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_IHTTPLISTENER_H 20 | #define XMRIG_IHTTPLISTENER_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class HttpData; 30 | class HttpResponse; 31 | 32 | 33 | class IHttpListener 34 | { 35 | public: 36 | XMRIG_DISABLE_COPY_MOVE(IHttpListener) 37 | 38 | IHttpListener() = default; 39 | virtual ~IHttpListener() = default; 40 | 41 | virtual void onHttpData(const HttpData &data) = 0; 42 | }; 43 | 44 | 45 | } /* namespace xmrig */ 46 | 47 | 48 | #endif // XMRIG_IHTTPLISTENER_H 49 | -------------------------------------------------------------------------------- /src/base/kernel/interfaces/ILogBackend.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_ILOGBACKEND_H 20 | #define XMRIG_ILOGBACKEND_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | 25 | 26 | #include 27 | #include 28 | 29 | 30 | namespace xmrig { 31 | 32 | 33 | class ILogBackend 34 | { 35 | public: 36 | XMRIG_DISABLE_COPY_MOVE(ILogBackend) 37 | 38 | ILogBackend() = default; 39 | virtual ~ILogBackend() = default; 40 | 41 | virtual void print(uint64_t timestamp, int level, const char *line, size_t offset, size_t size, bool colors) = 0; 42 | }; 43 | 44 | 45 | } /* namespace xmrig */ 46 | 47 | 48 | #endif // XMRIG_ILOGBACKEND_H 49 | -------------------------------------------------------------------------------- /src/base/kernel/interfaces/ISignalListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_ISIGNALLISTENER_H 20 | #define XMRIG_ISIGNALLISTENER_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class String; 30 | 31 | 32 | class ISignalListener 33 | { 34 | public: 35 | XMRIG_DISABLE_COPY_MOVE(ISignalListener) 36 | 37 | ISignalListener() = default; 38 | virtual ~ISignalListener() = default; 39 | 40 | virtual void onSignal(int signum) = 0; 41 | }; 42 | 43 | 44 | } /* namespace xmrig */ 45 | 46 | 47 | #endif // XMRIG_ISIGNALLISTENER_H 48 | -------------------------------------------------------------------------------- /src/base/kernel/interfaces/ITcpServerListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2019 SChernykh 9 | * Copyright 2016-2019 XMRig , 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | #ifndef XMRIG_ITCPSERVERLISTENER_H 26 | #define XMRIG_ITCPSERVERLISTENER_H 27 | 28 | 29 | #include 30 | 31 | 32 | typedef struct uv_stream_s uv_stream_t; 33 | 34 | 35 | namespace xmrig { 36 | 37 | 38 | class String; 39 | 40 | 41 | class ITcpServerListener 42 | { 43 | public: 44 | virtual ~ITcpServerListener() = default; 45 | 46 | virtual void onConnection(uv_stream_t *stream, uint16_t port) = 0; 47 | }; 48 | 49 | 50 | } /* namespace xmrig */ 51 | 52 | 53 | #endif // XMRIG_ITCPSERVERLISTENER_H 54 | -------------------------------------------------------------------------------- /src/base/kernel/interfaces/ITimerListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_ITIMERLISTENER_H 20 | #define XMRIG_ITIMERLISTENER_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class Timer; 30 | 31 | 32 | class ITimerListener 33 | { 34 | public: 35 | XMRIG_DISABLE_COPY_MOVE(ITimerListener) 36 | 37 | ITimerListener() = default; 38 | virtual ~ITimerListener() = default; 39 | 40 | virtual void onTimer(const Timer *timer) = 0; 41 | }; 42 | 43 | 44 | } /* namespace xmrig */ 45 | 46 | 47 | #endif // XMRIG_ITIMERLISTENER_H 48 | -------------------------------------------------------------------------------- /src/base/kernel/interfaces/IWatcherListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2019 SChernykh 9 | * Copyright 2016-2019 XMRig , 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | #ifndef XMRIG_IWATCHERLISTENER_H 26 | #define XMRIG_IWATCHERLISTENER_H 27 | 28 | 29 | namespace xmrig { 30 | 31 | 32 | class String; 33 | 34 | 35 | class IWatcherListener 36 | { 37 | public: 38 | virtual ~IWatcherListener() = default; 39 | 40 | virtual void onFileChanged(const String &fileName) = 0; 41 | }; 42 | 43 | 44 | } /* namespace xmrig */ 45 | 46 | 47 | #endif // XMRIG_IWATCHERLISTENER_H 48 | -------------------------------------------------------------------------------- /src/base/net/dns/DnsRecord.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_DNSRECORD_H 20 | #define XMRIG_DNSRECORD_H 21 | 22 | 23 | struct addrinfo; 24 | struct sockaddr; 25 | 26 | 27 | #include "base/tools/String.h" 28 | 29 | 30 | namespace xmrig { 31 | 32 | 33 | class DnsRecord 34 | { 35 | public: 36 | enum Type { 37 | Unknown, 38 | A, 39 | AAAA 40 | }; 41 | 42 | DnsRecord() {} 43 | DnsRecord(const addrinfo *addr); 44 | 45 | sockaddr *addr(uint16_t port = 0) const; 46 | 47 | inline bool isValid() const { return m_type != Unknown; } 48 | inline const String &ip() const { return m_ip; } 49 | inline Type type() const { return m_type; } 50 | 51 | private: 52 | Type m_type = Unknown; 53 | String m_ip; 54 | }; 55 | 56 | 57 | } /* namespace xmrig */ 58 | 59 | 60 | #endif /* XMRIG_DNSRECORD_H */ 61 | -------------------------------------------------------------------------------- /src/base/net/http/HttpApiResponse.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2014-2019 heapwolf 3 | * Copyright (c) 2018-2021 SChernykh 4 | * Copyright (c) 2016-2021 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef XMRIG_HTTPAPIRESPONSE_H 21 | #define XMRIG_HTTPAPIRESPONSE_H 22 | 23 | 24 | #include "3rdparty/rapidjson/document.h" 25 | #include "base/net/http/HttpResponse.h" 26 | 27 | 28 | namespace xmrig { 29 | 30 | 31 | class HttpApiResponse : public HttpResponse 32 | { 33 | public: 34 | HttpApiResponse(uint64_t id); 35 | HttpApiResponse(uint64_t id, int status); 36 | 37 | inline rapidjson::Document &doc() { return m_doc; } 38 | 39 | void end(); 40 | 41 | private: 42 | rapidjson::Document m_doc; 43 | }; 44 | 45 | 46 | } // namespace xmrig 47 | 48 | 49 | #endif // XMRIG_HTTPAPIRESPONSE_H 50 | 51 | -------------------------------------------------------------------------------- /src/base/net/http/HttpListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2021 SChernykh 3 | * Copyright (c) 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_HTTPLISTENER_H 20 | #define XMRIG_HTTPLISTENER_H 21 | 22 | 23 | #include "base/kernel/interfaces/IHttpListener.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class HttpListener : public IHttpListener 30 | { 31 | public: 32 | inline HttpListener(IHttpListener *listener, const char *tag = nullptr) : 33 | # ifdef APP_DEBUG 34 | m_tag(tag), 35 | # endif 36 | m_listener(listener) 37 | {} 38 | 39 | protected: 40 | void onHttpData(const HttpData &data) override; 41 | 42 | private: 43 | # ifdef APP_DEBUG 44 | const char *m_tag; 45 | # endif 46 | IHttpListener *m_listener; 47 | }; 48 | 49 | 50 | } /* namespace xmrig */ 51 | 52 | 53 | #endif // XMRIG_HTTPLISTENER_H 54 | -------------------------------------------------------------------------------- /src/base/net/http/HttpServer.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2014-2019 heapwolf 3 | * Copyright (c) 2018-2021 SChernykh 4 | * Copyright (c) 2016-2021 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef XMRIG_HTTPSERVER_H 21 | #define XMRIG_HTTPSERVER_H 22 | 23 | 24 | #include "base/kernel/interfaces/ITcpServerListener.h" 25 | #include "base/tools/Object.h" 26 | 27 | 28 | #include 29 | 30 | 31 | namespace xmrig { 32 | 33 | 34 | class IHttpListener; 35 | 36 | 37 | class HttpServer : public ITcpServerListener 38 | { 39 | public: 40 | XMRIG_DISABLE_COPY_MOVE_DEFAULT(HttpServer) 41 | 42 | HttpServer(const std::shared_ptr &listener); 43 | ~HttpServer() override; 44 | 45 | protected: 46 | void onConnection(uv_stream_t *stream, uint16_t port) override; 47 | 48 | private: 49 | std::weak_ptr m_listener; 50 | }; 51 | 52 | 53 | } // namespace xmrig 54 | 55 | 56 | #endif // XMRIG_HTTPSERVER_H 57 | 58 | -------------------------------------------------------------------------------- /src/base/net/stratum/ProxyUrl.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2018-2020 SChernykh 3 | * Copyright 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include "base/net/stratum/ProxyUrl.h" 21 | #include "3rdparty/rapidjson/document.h" 22 | 23 | 24 | namespace xmrig { 25 | 26 | static const String kLocalhost = "127.0.0.1"; 27 | 28 | } // namespace xmrig 29 | 30 | 31 | xmrig::ProxyUrl::ProxyUrl(const rapidjson::Value &value) 32 | { 33 | m_port = 0; 34 | 35 | if (value.IsString()) { 36 | parse(value.GetString()); 37 | } 38 | else if (value.IsUint()) { 39 | m_port = value.GetUint(); 40 | } 41 | } 42 | 43 | 44 | const xmrig::String &xmrig::ProxyUrl::host() const 45 | { 46 | return m_host.isNull() && isValid() ? kLocalhost : m_host; 47 | } 48 | 49 | 50 | rapidjson::Value xmrig::ProxyUrl::toJSON(rapidjson::Document &doc) const 51 | { 52 | using namespace rapidjson; 53 | if (!isValid()) { 54 | return Value(kNullType); 55 | } 56 | 57 | if (!m_host.isNull()) { 58 | return m_url.toJSON(doc); 59 | } 60 | 61 | return Value(m_port); 62 | } 63 | -------------------------------------------------------------------------------- /src/base/net/stratum/ProxyUrl.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2018-2020 SChernykh 3 | * Copyright 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_PROXYURL_H 20 | #define XMRIG_PROXYURL_H 21 | 22 | 23 | #include "base/net/stratum/Url.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class ProxyUrl : public Url 30 | { 31 | public: 32 | inline ProxyUrl() { m_port = 0; } 33 | 34 | ProxyUrl(const rapidjson::Value &value); 35 | 36 | inline bool isValid() const { return m_port > 0 && (m_scheme == UNSPECIFIED || m_scheme == SOCKS5); } 37 | 38 | const String &host() const; 39 | rapidjson::Value toJSON(rapidjson::Document &doc) const; 40 | }; 41 | 42 | 43 | } /* namespace xmrig */ 44 | 45 | 46 | #endif /* XMRIG_PROXYURL_H */ 47 | -------------------------------------------------------------------------------- /src/base/net/stratum/Socks5.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2018-2020 SChernykh 3 | * Copyright 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_SOCKS5_H 20 | #define XMRIG_SOCKS5_H 21 | 22 | 23 | #include "base/net/stratum/Client.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class Client::Socks5 30 | { 31 | public: 32 | Socks5(Client *client); 33 | 34 | inline bool isReady() const { return m_state == Ready; } 35 | 36 | bool read(const char *data, size_t size); 37 | void handshake(); 38 | 39 | private: 40 | enum State { 41 | Created, 42 | SentInitialHandshake, 43 | SentFinalHandshake, 44 | Ready 45 | }; 46 | 47 | bool isIPv4(const String &host, sockaddr_storage *addr) const; 48 | bool isIPv6(const String &host, sockaddr_storage *addr) const; 49 | void connect(); 50 | 51 | Client *m_client; 52 | size_t m_nextSize = 0; 53 | State m_state = Created; 54 | }; 55 | 56 | 57 | } /* namespace xmrig */ 58 | 59 | 60 | #endif /* XMRIG_SOCKS5_H */ 61 | -------------------------------------------------------------------------------- /src/base/net/tls/TlsContext.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018 Lee Clagett 3 | * Copyright (c) 2018-2023 SChernykh 4 | * Copyright (c) 2016-2023 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef XMRIG_TLSCONTEXT_H 21 | #define XMRIG_TLSCONTEXT_H 22 | 23 | 24 | #include "base/tools/Object.h" 25 | 26 | 27 | using SSL_CTX = struct ssl_ctx_st; 28 | 29 | 30 | namespace xmrig { 31 | 32 | 33 | class TlsConfig; 34 | 35 | 36 | class TlsContext 37 | { 38 | public: 39 | XMRIG_DISABLE_COPY_MOVE(TlsContext) 40 | 41 | ~TlsContext(); 42 | 43 | static TlsContext *create(const TlsConfig &config); 44 | 45 | inline SSL_CTX *ctx() const { return m_ctx; } 46 | 47 | private: 48 | TlsContext() = default; 49 | 50 | bool load(const TlsConfig &config); 51 | bool setCiphers(const char *ciphers); 52 | bool setCipherSuites(const char *ciphersuites); 53 | bool setDH(const char *dhparam); 54 | void setProtocols(uint32_t protocols); 55 | 56 | SSL_CTX *m_ctx = nullptr; 57 | }; 58 | 59 | 60 | } // namespace xmrig 61 | 62 | 63 | #endif // XMRIG_TLSCONTEXT_H 64 | -------------------------------------------------------------------------------- /src/base/net/tls/TlsGen.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2023 SChernykh 3 | * Copyright (c) 2016-2023 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_TLSGEN_H 20 | #define XMRIG_TLSGEN_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | #include "base/tools/String.h" 25 | 26 | 27 | using EVP_PKEY = struct evp_pkey_st; 28 | using X509 = struct x509_st; 29 | 30 | 31 | namespace xmrig { 32 | 33 | 34 | class TlsGen 35 | { 36 | public: 37 | XMRIG_DISABLE_COPY_MOVE(TlsGen) 38 | 39 | TlsGen() : m_cert("cert.pem"), m_certKey("cert_key.pem") {} 40 | ~TlsGen(); 41 | 42 | inline const String &cert() const { return m_cert; } 43 | inline const String &certKey() const { return m_certKey; } 44 | 45 | void generate(const char *commonName = nullptr); 46 | 47 | private: 48 | bool generate_x509(const char *commonName); 49 | bool write(); 50 | 51 | const String m_cert; 52 | const String m_certKey; 53 | EVP_PKEY *m_pkey = nullptr; 54 | X509 *m_x509 = nullptr; 55 | }; 56 | 57 | 58 | } // namespace xmrig 59 | 60 | 61 | #endif // XMRIG_TLSGEN_H 62 | -------------------------------------------------------------------------------- /src/base/net/tools/NetBuffer.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_NETBUFFER_H 20 | #define XMRIG_NETBUFFER_H 21 | 22 | 23 | struct uv_buf_t; 24 | using uv_handle_t = struct uv_handle_s; 25 | 26 | 27 | #include 28 | 29 | 30 | namespace xmrig { 31 | 32 | 33 | class NetBuffer 34 | { 35 | public: 36 | static char *allocate(); 37 | static void destroy(); 38 | static void onAlloc(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf); 39 | static void release(const char *buf); 40 | static void release(const uv_buf_t *buf); 41 | }; 42 | 43 | 44 | } /* namespace xmrig */ 45 | 46 | 47 | #endif /* XMRIG_NETBUFFER_H */ 48 | -------------------------------------------------------------------------------- /src/base/tools/Arguments.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_ARGUMENTS_H 20 | #define XMRIG_ARGUMENTS_H 21 | 22 | 23 | #include 24 | 25 | 26 | #include "base/tools/String.h" 27 | 28 | 29 | namespace xmrig { 30 | 31 | 32 | class Arguments 33 | { 34 | public: 35 | Arguments(int argc, char **argv); 36 | 37 | bool hasArg(const char *name) const; 38 | const char *value(const char *key1, const char *key2 = nullptr) const; 39 | 40 | inline char **argv() const { return m_argv; } 41 | inline const std::vector &data() const { return m_data; } 42 | inline int argc() const { return m_argc; } 43 | 44 | private: 45 | void add(const char *arg); 46 | 47 | char **m_argv; 48 | int m_argc; 49 | std::vector m_data; 50 | }; 51 | 52 | 53 | } /* namespace xmrig */ 54 | 55 | 56 | #endif /* XMRIG_ARGUMENTS_H */ 57 | -------------------------------------------------------------------------------- /src/base/tools/Baton.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_BATON_H 20 | #define XMRIG_BATON_H 21 | 22 | 23 | namespace xmrig { 24 | 25 | 26 | template 27 | class Baton 28 | { 29 | public: 30 | inline Baton() { req.data = this; } 31 | 32 | REQ req; 33 | }; 34 | 35 | 36 | } /* namespace xmrig */ 37 | 38 | 39 | #endif /* XMRIG_BATON_H */ 40 | -------------------------------------------------------------------------------- /src/base/tools/Buffer.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_BUFFER_H 20 | #define XMRIG_BUFFER_H 21 | 22 | 23 | #include 24 | #include 25 | 26 | 27 | namespace xmrig { 28 | 29 | 30 | using Buffer = std::vector; 31 | 32 | 33 | } /* namespace xmrig */ 34 | 35 | 36 | #endif /* XMRIG_BUFFER_H */ 37 | -------------------------------------------------------------------------------- /src/base/tools/Object.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_OBJECT_H 20 | #define XMRIG_OBJECT_H 21 | 22 | 23 | #include 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | #define XMRIG_DISABLE_COPY_MOVE(X) \ 30 | X(const X &other) = delete; \ 31 | X(X &&other) = delete; \ 32 | X &operator=(const X &other) = delete; \ 33 | X &operator=(X &&other) = delete; 34 | 35 | 36 | #define XMRIG_DISABLE_COPY_MOVE_DEFAULT(X) \ 37 | X() = delete; \ 38 | X(const X &other) = delete; \ 39 | X(X &&other) = delete; \ 40 | X &operator=(const X &other) = delete; \ 41 | X &operator=(X &&other) = delete; 42 | 43 | 44 | } /* namespace xmrig */ 45 | 46 | #endif /* XMRIG_OBJECT_H */ 47 | -------------------------------------------------------------------------------- /src/core/Controller.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2018-2021 SChernykh 3 | * Copyright 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_CONTROLLER_H 20 | #define XMRIG_CONTROLLER_H 21 | 22 | 23 | #include "base/kernel/Base.h" 24 | 25 | 26 | #include 27 | 28 | 29 | namespace xmrig { 30 | 31 | 32 | class HwApi; 33 | class Job; 34 | class Miner; 35 | class Network; 36 | 37 | 38 | class Controller : public Base 39 | { 40 | public: 41 | XMRIG_DISABLE_COPY_MOVE_DEFAULT(Controller) 42 | 43 | Controller(Process *process); 44 | ~Controller() override; 45 | 46 | int init() override; 47 | void start() override; 48 | void stop() override; 49 | 50 | Miner *miner() const; 51 | Network *network() const; 52 | void execCommand(char command); 53 | 54 | private: 55 | std::shared_ptr m_miner; 56 | std::shared_ptr m_network; 57 | 58 | # ifdef XMRIG_FEATURE_API 59 | std::shared_ptr m_hwApi; 60 | # endif 61 | }; 62 | 63 | 64 | } // namespace xmrig 65 | 66 | 67 | #endif /* XMRIG_CONTROLLER_H */ 68 | -------------------------------------------------------------------------------- /src/core/config/ConfigTransform.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2021 SChernykh 3 | * Copyright (c) 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_CONFIGTRANSFORM_H 20 | #define XMRIG_CONFIGTRANSFORM_H 21 | 22 | 23 | #include "base/kernel/config/BaseTransform.h" 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class ConfigTransform : public BaseTransform 30 | { 31 | protected: 32 | void finalize(rapidjson::Document &doc) override; 33 | void transform(rapidjson::Document &doc, int key, const char *arg) override; 34 | 35 | private: 36 | void transformBoolean(rapidjson::Document &doc, int key, bool enable); 37 | void transformUint64(rapidjson::Document &doc, int key, uint64_t arg); 38 | 39 | # ifdef XMRIG_FEATURE_BENCHMARK 40 | void transformBenchmark(rapidjson::Document &doc, int key, const char *arg); 41 | # endif 42 | 43 | bool m_opencl = false; 44 | int64_t m_affinity = -1; 45 | uint64_t m_intensity = 1; 46 | uint64_t m_threads = 0; 47 | }; 48 | 49 | 50 | } // namespace xmrig 51 | 52 | 53 | #endif /* XMRIG_CONFIGTRANSFORM_H */ 54 | -------------------------------------------------------------------------------- /src/crypto/argon2/Impl.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2020 SChernykh 9 | * Copyright 2016-2020 XMRig , 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | #ifndef XMRIG_ARGON2_IMPL_H 26 | #define XMRIG_ARGON2_IMPL_H 27 | 28 | 29 | namespace xmrig { 30 | 31 | 32 | class String; 33 | 34 | 35 | namespace argon2 { 36 | 37 | 38 | class Impl 39 | { 40 | public: 41 | static bool select(const String &nameHint, bool benchmark = false); 42 | static const String &name(); 43 | }; 44 | 45 | 46 | }} // namespace xmrig::argon2 47 | 48 | 49 | #endif /* XMRIG_ARGON2_IMPL_H */ 50 | -------------------------------------------------------------------------------- /src/crypto/astrobwt/Salsa20.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on public domain code available at: http://cr.yp.to/snuffle.html 3 | * 4 | * This therefore is public domain. 5 | */ 6 | 7 | #ifndef ZT_SALSA20_HPP 8 | #define ZT_SALSA20_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace ZeroTier { 17 | 18 | /** 19 | * Salsa20 stream cipher 20 | */ 21 | class Salsa20 22 | { 23 | public: 24 | /** 25 | * @param key 256-bit (32 byte) key 26 | * @param iv 64-bit initialization vector 27 | */ 28 | Salsa20(const void *key,const void *iv) 29 | { 30 | init(key,iv); 31 | } 32 | 33 | /** 34 | * Initialize cipher 35 | * 36 | * @param key Key bits 37 | * @param iv 64-bit initialization vector 38 | */ 39 | void init(const void *key,const void *iv); 40 | 41 | void XORKeyStream(void *out,unsigned int bytes); 42 | 43 | private: 44 | union { 45 | __m128i v[4]; 46 | uint32_t i[16]; 47 | } _state; 48 | }; 49 | 50 | } // namespace ZeroTier 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/crypto/astrobwt/salsa20_ref/ecrypt-machine.h: -------------------------------------------------------------------------------- 1 | /* ecrypt-machine.h */ 2 | 3 | /* 4 | * This file is included by 'ecrypt-portable.h'. It allows to override 5 | * the default macros for specific platforms. Please carefully check 6 | * the machine code generated by your compiler (with optimisations 7 | * turned on) before deciding to edit this file. 8 | */ 9 | 10 | /* ------------------------------------------------------------------------- */ 11 | 12 | #if (defined(ECRYPT_DEFAULT_ROT) && !defined(ECRYPT_MACHINE_ROT)) 13 | 14 | #define ECRYPT_MACHINE_ROT 15 | 16 | #if (defined(WIN32) && defined(_MSC_VER)) 17 | 18 | #undef ROTL32 19 | #undef ROTR32 20 | #undef ROTL64 21 | #undef ROTR64 22 | 23 | #include 24 | 25 | #define ROTL32(v, n) _lrotl(v, n) 26 | #define ROTR32(v, n) _lrotr(v, n) 27 | #define ROTL64(v, n) _rotl64(v, n) 28 | #define ROTR64(v, n) _rotr64(v, n) 29 | 30 | #endif 31 | 32 | #endif 33 | 34 | /* ------------------------------------------------------------------------- */ 35 | 36 | #if (defined(ECRYPT_DEFAULT_SWAP) && !defined(ECRYPT_MACHINE_SWAP)) 37 | 38 | #define ECRYPT_MACHINE_SWAP 39 | 40 | /* 41 | * If you want to overwrite the default swap macros, put it here. And so on. 42 | */ 43 | 44 | #endif 45 | 46 | /* ------------------------------------------------------------------------- */ 47 | -------------------------------------------------------------------------------- /src/crypto/cn/CnCtx.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2019 XMR-Stak , 8 | * Copyright 2018 Lee Clagett 9 | * Copyright 2018-2020 SChernykh 10 | * Copyright 2016-2020 XMRig , 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation, either version 3 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with this program. If not, see . 24 | */ 25 | 26 | #ifndef XMRIG_CN_CTX_H 27 | #define XMRIG_CN_CTX_H 28 | 29 | 30 | #include 31 | #include 32 | 33 | 34 | struct cryptonight_ctx; 35 | 36 | 37 | namespace xmrig 38 | { 39 | 40 | 41 | class CnCtx 42 | { 43 | public: 44 | static void create(cryptonight_ctx **ctx, uint8_t *memory, size_t size, size_t count); 45 | static void release(cryptonight_ctx **ctx, size_t count); 46 | }; 47 | 48 | 49 | } /* namespace xmrig */ 50 | 51 | 52 | #endif /* XMRIG_CN_CTX_H */ 53 | -------------------------------------------------------------------------------- /src/crypto/cn/asm/cn_main_loop.asm: -------------------------------------------------------------------------------- 1 | _TEXT_CNV2_MAINLOOP SEGMENT PAGE READ EXECUTE 2 | PUBLIC cnv2_mainloop_ivybridge_asm 3 | PUBLIC cnv2_mainloop_ryzen_asm 4 | PUBLIC cnv2_mainloop_bulldozer_asm 5 | PUBLIC cnv2_double_mainloop_sandybridge_asm 6 | PUBLIC cnv2_rwz_mainloop_asm 7 | PUBLIC cnv2_rwz_double_mainloop_asm 8 | 9 | ALIGN(64) 10 | cnv2_mainloop_ivybridge_asm PROC 11 | INCLUDE cn2/cnv2_main_loop_ivybridge.inc 12 | ret 0 13 | mov eax, 3735929054 14 | cnv2_mainloop_ivybridge_asm ENDP 15 | 16 | ALIGN(64) 17 | cnv2_mainloop_ryzen_asm PROC 18 | INCLUDE cn2/cnv2_main_loop_ryzen.inc 19 | ret 0 20 | mov eax, 3735929054 21 | cnv2_mainloop_ryzen_asm ENDP 22 | 23 | ALIGN(64) 24 | cnv2_mainloop_bulldozer_asm PROC 25 | INCLUDE cn2/cnv2_main_loop_bulldozer.inc 26 | ret 0 27 | mov eax, 3735929054 28 | cnv2_mainloop_bulldozer_asm ENDP 29 | 30 | ALIGN(64) 31 | cnv2_double_mainloop_sandybridge_asm PROC 32 | INCLUDE cn2/cnv2_double_main_loop_sandybridge.inc 33 | ret 0 34 | mov eax, 3735929054 35 | cnv2_double_mainloop_sandybridge_asm ENDP 36 | 37 | ALIGN(64) 38 | cnv2_rwz_mainloop_asm PROC 39 | INCLUDE cn2/cnv2_rwz_main_loop.inc 40 | ret 0 41 | mov eax, 3735929054 42 | cnv2_rwz_mainloop_asm ENDP 43 | 44 | ALIGN(64) 45 | cnv2_rwz_double_mainloop_asm PROC 46 | INCLUDE cn2/cnv2_rwz_double_main_loop.inc 47 | ret 0 48 | mov eax, 3735929054 49 | cnv2_rwz_double_mainloop_asm ENDP 50 | 51 | _TEXT_CNV2_MAINLOOP ENDS 52 | END 53 | -------------------------------------------------------------------------------- /src/crypto/cn/asm/win64/cn_main_loop.S: -------------------------------------------------------------------------------- 1 | #define ALIGN(x) .align 64 2 | .intel_syntax noprefix 3 | .section .text 4 | .global cnv2_mainloop_ivybridge_asm 5 | .global cnv2_mainloop_ryzen_asm 6 | .global cnv2_mainloop_bulldozer_asm 7 | .global cnv2_double_mainloop_sandybridge_asm 8 | .global cnv2_rwz_mainloop_asm 9 | .global cnv2_rwz_double_mainloop_asm 10 | 11 | ALIGN(64) 12 | cnv2_mainloop_ivybridge_asm: 13 | #include "../cn2/cnv2_main_loop_ivybridge.inc" 14 | ret 0 15 | mov eax, 3735929054 16 | 17 | ALIGN(64) 18 | cnv2_mainloop_ryzen_asm: 19 | #include "../cn2/cnv2_main_loop_ryzen.inc" 20 | ret 0 21 | mov eax, 3735929054 22 | 23 | ALIGN(64) 24 | cnv2_mainloop_bulldozer_asm: 25 | #include "../cn2/cnv2_main_loop_bulldozer.inc" 26 | ret 0 27 | mov eax, 3735929054 28 | 29 | ALIGN(64) 30 | cnv2_double_mainloop_sandybridge_asm: 31 | #include "../cn2/cnv2_double_main_loop_sandybridge.inc" 32 | ret 0 33 | mov eax, 3735929054 34 | 35 | ALIGN(64) 36 | cnv2_rwz_mainloop_asm: 37 | #include "cn2/cnv2_rwz_main_loop.inc" 38 | ret 0 39 | mov eax, 3735929054 40 | 41 | ALIGN(64) 42 | cnv2_rwz_double_mainloop_asm: 43 | #include "cn2/cnv2_rwz_double_main_loop.inc" 44 | ret 0 45 | mov eax, 3735929054 46 | -------------------------------------------------------------------------------- /src/crypto/cn/asm/win64/cn_main_loop.asm: -------------------------------------------------------------------------------- 1 | _TEXT_CNV2_MAINLOOP SEGMENT PAGE READ EXECUTE 2 | PUBLIC cnv2_mainloop_ivybridge_asm 3 | PUBLIC cnv2_mainloop_ryzen_asm 4 | PUBLIC cnv2_mainloop_bulldozer_asm 5 | PUBLIC cnv2_double_mainloop_sandybridge_asm 6 | PUBLIC cnv2_rwz_mainloop_asm 7 | PUBLIC cnv2_rwz_double_mainloop_asm 8 | 9 | ALIGN 64 10 | cnv2_mainloop_ivybridge_asm PROC 11 | INCLUDE cn2/cnv2_main_loop_ivybridge.inc 12 | ret 0 13 | mov eax, 3735929054 14 | cnv2_mainloop_ivybridge_asm ENDP 15 | 16 | ALIGN 64 17 | cnv2_mainloop_ryzen_asm PROC 18 | INCLUDE cn2/cnv2_main_loop_ryzen.inc 19 | ret 0 20 | mov eax, 3735929054 21 | cnv2_mainloop_ryzen_asm ENDP 22 | 23 | ALIGN 64 24 | cnv2_mainloop_bulldozer_asm PROC 25 | INCLUDE cn2/cnv2_main_loop_bulldozer.inc 26 | ret 0 27 | mov eax, 3735929054 28 | cnv2_mainloop_bulldozer_asm ENDP 29 | 30 | ALIGN 64 31 | cnv2_double_mainloop_sandybridge_asm PROC 32 | INCLUDE cn2/cnv2_double_main_loop_sandybridge.inc 33 | ret 0 34 | mov eax, 3735929054 35 | cnv2_double_mainloop_sandybridge_asm ENDP 36 | 37 | ALIGN(64) 38 | cnv2_rwz_mainloop_asm PROC 39 | INCLUDE cn2/cnv2_rwz_main_loop.inc 40 | ret 0 41 | mov eax, 3735929054 42 | cnv2_rwz_mainloop_asm ENDP 43 | 44 | ALIGN(64) 45 | cnv2_rwz_double_mainloop_asm PROC 46 | INCLUDE cn2/cnv2_rwz_double_main_loop.inc 47 | ret 0 48 | mov eax, 3735929054 49 | cnv2_rwz_double_mainloop_asm ENDP 50 | 51 | _TEXT_CNV2_MAINLOOP ENDS 52 | END 53 | -------------------------------------------------------------------------------- /src/crypto/cn/c_blake256.h: -------------------------------------------------------------------------------- 1 | #ifndef _BLAKE256_H_ 2 | #define _BLAKE256_H_ 3 | 4 | #include 5 | 6 | typedef struct { 7 | uint32_t h[8], s[4], t[2]; 8 | int buflen, nullt; 9 | uint8_t buf[64]; 10 | } state; 11 | 12 | typedef struct { 13 | state inner; 14 | state outer; 15 | } hmac_state; 16 | 17 | void blake256_init(state *); 18 | void blake224_init(state *); 19 | 20 | void blake256_update(state *, const uint8_t *, uint64_t); 21 | void blake224_update(state *, const uint8_t *, uint64_t); 22 | 23 | void blake256_final(state *, uint8_t *); 24 | void blake224_final(state *, uint8_t *); 25 | 26 | void blake256_hash(uint8_t *, const uint8_t *, uint64_t); 27 | void blake224_hash(uint8_t *, const uint8_t *, uint64_t); 28 | 29 | /* HMAC functions: */ 30 | 31 | void hmac_blake256_init(hmac_state *, const uint8_t *, uint64_t); 32 | void hmac_blake224_init(hmac_state *, const uint8_t *, uint64_t); 33 | 34 | void hmac_blake256_update(hmac_state *, const uint8_t *, uint64_t); 35 | void hmac_blake224_update(hmac_state *, const uint8_t *, uint64_t); 36 | 37 | void hmac_blake256_final(hmac_state *, uint8_t *); 38 | void hmac_blake224_final(hmac_state *, uint8_t *); 39 | 40 | void hmac_blake256_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); 41 | void hmac_blake224_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); 42 | 43 | #endif /* _BLAKE256_H_ */ 44 | -------------------------------------------------------------------------------- /src/crypto/cn/c_groestl.h: -------------------------------------------------------------------------------- 1 | #ifndef __hash_h 2 | #define __hash_h 3 | /* 4 | #include "crypto_uint8.h" 5 | #include "crypto_uint32.h" 6 | #include "crypto_uint64.h" 7 | #include "crypto_hash.h" 8 | 9 | typedef crypto_uint8 uint8_t; 10 | typedef crypto_uint32 uint32_t; 11 | typedef crypto_uint64 uint64_t; 12 | */ 13 | #include 14 | 15 | #include "hash.h" 16 | 17 | /* some sizes (number of bytes) */ 18 | #define ROWS 8 19 | #define LENGTHFIELDLEN ROWS 20 | #define COLS512 8 21 | 22 | #define SIZE512 (ROWS*COLS512) 23 | 24 | #define ROUNDS512 10 25 | #define HASH_BIT_LEN 256 26 | 27 | #define ROTL32(v, n) ((((v)<<(n))|((v)>>(32-(n))))&li_32(ffffffff)) 28 | 29 | 30 | #define li_32(h) 0x##h##u 31 | #define EXT_BYTE(var,n) ((uint8_t)((uint32_t)(var) >> (8*n))) 32 | #define u32BIG(a) \ 33 | ((ROTL32(a,8) & li_32(00FF00FF)) | \ 34 | (ROTL32(a,24) & li_32(FF00FF00))) 35 | 36 | 37 | /* NIST API begin */ 38 | typedef struct { 39 | uint32_t chaining[SIZE512/sizeof(uint32_t)]; /* actual state */ 40 | uint32_t block_counter1, 41 | block_counter2; /* message block counter(s) */ 42 | BitSequence buffer[SIZE512]; /* data buffer */ 43 | int buf_ptr; /* data buffer pointer */ 44 | int bits_in_last_byte; /* no. of message bits in last byte of 45 | data buffer */ 46 | } groestlHashState; 47 | 48 | /*void Init(hashState*); 49 | void Update(hashState*, const BitSequence*, DataLength); 50 | void Final(hashState*, BitSequence*); */ 51 | void groestl(const BitSequence*, DataLength, BitSequence*); 52 | /* NIST API end */ 53 | 54 | /* 55 | int crypto_hash(unsigned char *out, 56 | const unsigned char *in, 57 | unsigned long long len); 58 | */ 59 | 60 | #endif /* __hash_h */ 61 | -------------------------------------------------------------------------------- /src/crypto/cn/c_jh.h: -------------------------------------------------------------------------------- 1 | /*This program gives the 64-bit optimized bitslice implementation of JH using ANSI C 2 | 3 | -------------------------------- 4 | Performance 5 | 6 | Microprocessor: Intel CORE 2 processor (Core 2 Duo Mobile T6600 2.2GHz) 7 | Operating System: 64-bit Ubuntu 10.04 (Linux kernel 2.6.32-22-generic) 8 | Speed for long message: 9 | 1) 45.8 cycles/byte compiler: Intel C++ Compiler 11.1 compilation option: icc -O2 10 | 2) 56.8 cycles/byte compiler: gcc 4.4.3 compilation option: gcc -O3 11 | 12 | -------------------------------- 13 | Last Modified: January 16, 2011 14 | */ 15 | #pragma once 16 | 17 | #include "hash.h" 18 | 19 | HashReturn jh_hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval); 20 | -------------------------------------------------------------------------------- /src/crypto/cn/hash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef unsigned char BitSequence; 4 | typedef unsigned long long DataLength; 5 | typedef enum {SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2} HashReturn; 6 | -------------------------------------------------------------------------------- /src/crypto/common/HugePagesInfo.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2021 SChernykh 3 | * Copyright (c) 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include "crypto/common/HugePagesInfo.h" 21 | #include "crypto/common/VirtualMemory.h" 22 | 23 | 24 | xmrig::HugePagesInfo::HugePagesInfo(const VirtualMemory *memory) 25 | { 26 | if (memory->isOneGbPages()) { 27 | size = VirtualMemory::align(memory->size(), VirtualMemory::kOneGiB); 28 | total = size / VirtualMemory::kOneGiB; 29 | allocated = size / VirtualMemory::kOneGiB; 30 | } 31 | else { 32 | size = VirtualMemory::alignToHugePageSize(memory->size()); 33 | total = size / VirtualMemory::hugePageSize(); 34 | allocated = memory->isHugePages() ? total : 0; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/crypto/common/LinuxMemory.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2021 SChernykh 3 | * Copyright (c) 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_LINUXMEMORY_H 20 | #define XMRIG_LINUXMEMORY_H 21 | 22 | 23 | #include 24 | #include 25 | 26 | 27 | namespace xmrig { 28 | 29 | 30 | class LinuxMemory 31 | { 32 | public: 33 | static bool reserve(size_t size, uint32_t node, size_t hugePageSize); 34 | 35 | static bool write(const char *path, uint64_t value); 36 | static int64_t read(const char *path); 37 | }; 38 | 39 | 40 | } /* namespace xmrig */ 41 | 42 | 43 | #endif /* XMRIG_LINUXMEMORY_H */ 44 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_epilogue_linux.inc: -------------------------------------------------------------------------------- 1 | ;# restore callee-saved registers - System V AMD64 ABI 2 | pop r15 3 | pop r14 4 | pop r13 5 | pop r12 6 | pop rbp 7 | pop rbx 8 | 9 | ;# program finished 10 | ret 0 -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_epilogue_store.inc: -------------------------------------------------------------------------------- 1 | ;# save VM register values 2 | add rsp, 40 3 | pop rcx 4 | mov qword ptr [rcx+0], r8 5 | mov qword ptr [rcx+8], r9 6 | mov qword ptr [rcx+16], r10 7 | mov qword ptr [rcx+24], r11 8 | mov qword ptr [rcx+32], r12 9 | mov qword ptr [rcx+40], r13 10 | mov qword ptr [rcx+48], r14 11 | mov qword ptr [rcx+56], r15 12 | movdqa xmmword ptr [rcx+64], xmm0 13 | movdqa xmmword ptr [rcx+80], xmm1 14 | movdqa xmmword ptr [rcx+96], xmm2 15 | movdqa xmmword ptr [rcx+112], xmm3 16 | lea rcx, [rcx+64] 17 | movdqa xmmword ptr [rcx+64], xmm4 18 | movdqa xmmword ptr [rcx+80], xmm5 19 | movdqa xmmword ptr [rcx+96], xmm6 20 | movdqa xmmword ptr [rcx+112], xmm7 -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_epilogue_win64.inc: -------------------------------------------------------------------------------- 1 | ;# restore callee-saved registers - Microsoft x64 calling convention 2 | movdqu xmm15, xmmword ptr [rsp] 3 | movdqu xmm14, xmmword ptr [rsp+16] 4 | movdqu xmm13, xmmword ptr [rsp+32] 5 | movdqu xmm12, xmmword ptr [rsp+48] 6 | movdqu xmm11, xmmword ptr [rsp+64] 7 | add rsp, 80 8 | movdqu xmm10, xmmword ptr [rsp] 9 | movdqu xmm9, xmmword ptr [rsp+16] 10 | movdqu xmm8, xmmword ptr [rsp+32] 11 | movdqu xmm7, xmmword ptr [rsp+48] 12 | movdqu xmm6, xmmword ptr [rsp+64] 13 | add rsp, 80 14 | pop r15 15 | pop r14 16 | pop r13 17 | pop r12 18 | pop rsi 19 | pop rdi 20 | pop rbp 21 | pop rbx 22 | 23 | ;# program finished 24 | ret 25 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_loop_load.inc: -------------------------------------------------------------------------------- 1 | lea rcx, [rsi+rax] 2 | mov [rsp+16], rcx 3 | xor r8, qword ptr [rcx+0] 4 | xor r9, qword ptr [rcx+8] 5 | xor r10, qword ptr [rcx+16] 6 | xor r11, qword ptr [rcx+24] 7 | xor r12, qword ptr [rcx+32] 8 | xor r13, qword ptr [rcx+40] 9 | xor r14, qword ptr [rcx+48] 10 | xor r15, qword ptr [rcx+56] 11 | lea rcx, [rsi+rdx] 12 | mov [rsp+24], rcx 13 | cvtdq2pd xmm0, qword ptr [rcx+0] 14 | cvtdq2pd xmm1, qword ptr [rcx+8] 15 | cvtdq2pd xmm2, qword ptr [rcx+16] 16 | cvtdq2pd xmm3, qword ptr [rcx+24] 17 | cvtdq2pd xmm4, qword ptr [rcx+32] 18 | cvtdq2pd xmm5, qword ptr [rcx+40] 19 | cvtdq2pd xmm6, qword ptr [rcx+48] 20 | cvtdq2pd xmm7, qword ptr [rcx+56] 21 | andpd xmm4, xmm13 22 | andpd xmm5, xmm13 23 | andpd xmm6, xmm13 24 | andpd xmm7, xmm13 25 | orpd xmm4, xmm14 26 | orpd xmm5, xmm14 27 | orpd xmm6, xmm14 28 | orpd xmm7, xmm14 29 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_loop_load_xop.inc: -------------------------------------------------------------------------------- 1 | lea rcx, [rsi+rax] 2 | mov [rsp+16], rcx 3 | xor r8, qword ptr [rcx+0] 4 | xor r9, qword ptr [rcx+8] 5 | xor r10, qword ptr [rcx+16] 6 | xor r11, qword ptr [rcx+24] 7 | xor r12, qword ptr [rcx+32] 8 | xor r13, qword ptr [rcx+40] 9 | xor r14, qword ptr [rcx+48] 10 | xor r15, qword ptr [rcx+56] 11 | lea rcx, [rsi+rdx] 12 | mov [rsp+24], rcx 13 | cvtdq2pd xmm0, qword ptr [rcx+0] 14 | cvtdq2pd xmm1, qword ptr [rcx+8] 15 | cvtdq2pd xmm2, qword ptr [rcx+16] 16 | cvtdq2pd xmm3, qword ptr [rcx+24] 17 | cvtdq2pd xmm4, qword ptr [rcx+32] 18 | cvtdq2pd xmm5, qword ptr [rcx+40] 19 | cvtdq2pd xmm6, qword ptr [rcx+48] 20 | cvtdq2pd xmm7, qword ptr [rcx+56] 21 | vpcmov xmm4, xmm4, xmm14, xmm13 22 | vpcmov xmm5, xmm5, xmm14, xmm13 23 | vpcmov xmm6, xmm6, xmm14, xmm13 24 | vpcmov xmm7, xmm7, xmm14, xmm13 25 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_loop_store.inc: -------------------------------------------------------------------------------- 1 | mov rcx, [rsp+24] 2 | mov qword ptr [rcx+0], r8 3 | mov qword ptr [rcx+8], r9 4 | mov qword ptr [rcx+16], r10 5 | mov qword ptr [rcx+24], r11 6 | mov qword ptr [rcx+32], r12 7 | mov qword ptr [rcx+40], r13 8 | mov qword ptr [rcx+48], r14 9 | mov qword ptr [rcx+56], r15 10 | mov rcx, [rsp+16] 11 | xorpd xmm0, xmm4 12 | xorpd xmm1, xmm5 13 | xorpd xmm2, xmm6 14 | xorpd xmm3, xmm7 15 | movapd xmmword ptr [rcx+0], xmm0 16 | movapd xmmword ptr [rcx+16], xmm1 17 | movapd xmmword ptr [rcx+32], xmm2 18 | movapd xmmword ptr [rcx+48], xmm3 19 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_prologue_linux.inc: -------------------------------------------------------------------------------- 1 | ;# callee-saved registers - System V AMD64 ABI 2 | push rbx 3 | push rbp 4 | push r12 5 | push r13 6 | push r14 7 | push r15 8 | 9 | ;# function arguments 10 | mov rbx, rcx ;# loop counter 11 | push rdi ;# RegisterFile& registerFile 12 | mov rcx, rdi 13 | mov rbp, qword ptr [rsi] ;# "mx", "ma" 14 | mov rdi, qword ptr [rsi+8] ;# uint8_t* dataset 15 | 16 | ;# dataset prefetch for the first iteration of the main loop 17 | mov rax, rbp 18 | shr rax, 32 19 | and eax, RANDOMX_DATASET_BASE_MASK 20 | prefetchnta byte ptr [rdi+rax] 21 | 22 | mov rsi, rdx ;# uint8_t* scratchpad 23 | 24 | mov rax, rbp 25 | 26 | ;# zero integer registers 27 | xor r8, r8 28 | xor r9, r9 29 | xor r10, r10 30 | xor r11, r11 31 | xor r12, r12 32 | xor r13, r13 33 | xor r14, r14 34 | xor r15, r15 35 | 36 | ;# load constant registers 37 | lea rcx, [rcx+120] 38 | movapd xmm8, xmmword ptr [rcx+72] 39 | movapd xmm9, xmmword ptr [rcx+88] 40 | movapd xmm10, xmmword ptr [rcx+104] 41 | movapd xmm11, xmmword ptr [rcx+120] 42 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_prologue_win64.inc: -------------------------------------------------------------------------------- 1 | ;# callee-saved registers - Microsoft x64 calling convention 2 | push rbx 3 | push rbp 4 | push rdi 5 | push rsi 6 | push r12 7 | push r13 8 | push r14 9 | push r15 10 | sub rsp, 80 11 | movdqu xmmword ptr [rsp+64], xmm6 12 | movdqu xmmword ptr [rsp+48], xmm7 13 | movdqu xmmword ptr [rsp+32], xmm8 14 | movdqu xmmword ptr [rsp+16], xmm9 15 | movdqu xmmword ptr [rsp+0], xmm10 16 | sub rsp, 80 17 | movdqu xmmword ptr [rsp+64], xmm11 18 | movdqu xmmword ptr [rsp+48], xmm12 19 | movdqu xmmword ptr [rsp+32], xmm13 20 | movdqu xmmword ptr [rsp+16], xmm14 21 | movdqu xmmword ptr [rsp+0], xmm15 22 | 23 | ;# function arguments 24 | push rcx ;# RegisterFile& registerFile 25 | mov rbp, qword ptr [rdx] ;# "mx", "ma" 26 | mov rdi, qword ptr [rdx+8] ;# uint8_t* dataset 27 | 28 | ;# dataset prefetch for the first iteration of the main loop 29 | mov rax, rbp 30 | shr rax, 32 31 | and eax, RANDOMX_DATASET_BASE_MASK 32 | prefetchnta byte ptr [rdi+rax] 33 | 34 | mov rsi, r8 ;# uint8_t* scratchpad 35 | mov rbx, r9 ;# loop counter 36 | 37 | mov rax, rbp 38 | 39 | ;# zero integer registers 40 | xor r8, r8 41 | xor r9, r9 42 | xor r10, r10 43 | xor r11, r11 44 | xor r12, r12 45 | xor r13, r13 46 | xor r14, r14 47 | xor r15, r15 48 | 49 | ;# load constant registers 50 | lea rcx, [rcx+120] 51 | movapd xmm8, xmmword ptr [rcx+72] 52 | movapd xmm9, xmmword ptr [rcx+88] 53 | movapd xmm10, xmmword ptr [rcx+104] 54 | movapd xmm11, xmmword ptr [rcx+120] 55 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_read_dataset.inc: -------------------------------------------------------------------------------- 1 | xor rbp, rax ;# modify "mx" 2 | mov edx, ebp ;# edx = mx 3 | and edx, RANDOMX_DATASET_BASE_MASK 4 | prefetchnta byte ptr [rdi+rdx] 5 | ror rbp, 32 ;# swap "ma" and "mx" 6 | mov edx, ebp ;# edx = ma 7 | and edx, RANDOMX_DATASET_BASE_MASK 8 | lea rcx, [rdi+rdx] ;# dataset cache line 9 | xor r8, qword ptr [rcx+0] 10 | xor r9, qword ptr [rcx+8] 11 | xor r10, qword ptr [rcx+16] 12 | xor r11, qword ptr [rcx+24] 13 | xor r12, qword ptr [rcx+32] 14 | xor r13, qword ptr [rcx+40] 15 | xor r14, qword ptr [rcx+48] 16 | xor r15, qword ptr [rcx+56] 17 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_read_dataset_ryzen.inc: -------------------------------------------------------------------------------- 1 | mov rcx, rbp ;# ecx = ma 2 | shr rcx, 32 3 | and ecx, RANDOMX_DATASET_BASE_MASK 4 | xor r8, qword ptr [rdi+rcx] 5 | xor rbp, rax ;# modify "mx" 6 | mov edx, ebp ;# edx = mx 7 | and edx, RANDOMX_DATASET_BASE_MASK 8 | prefetchnta byte ptr [rdi+rdx] 9 | ror rbp, 32 ;# swap "ma" and "mx" 10 | xor r9, qword ptr [rdi+rcx+8] 11 | xor r10, qword ptr [rdi+rcx+16] 12 | xor r11, qword ptr [rdi+rcx+24] 13 | xor r12, qword ptr [rdi+rcx+32] 14 | xor r13, qword ptr [rdi+rcx+40] 15 | xor r14, qword ptr [rdi+rcx+48] 16 | xor r15, qword ptr [rdi+rcx+56] 17 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_read_dataset_sshash_fin.inc: -------------------------------------------------------------------------------- 1 | mov rbx, qword ptr [rsp+64] 2 | xor r8, qword ptr [rsp+56] 3 | xor r9, qword ptr [rsp+48] 4 | xor r10, qword ptr [rsp+40] 5 | xor r11, qword ptr [rsp+32] 6 | xor r12, qword ptr [rsp+24] 7 | xor r13, qword ptr [rsp+16] 8 | xor r14, qword ptr [rsp+8] 9 | xor r15, qword ptr [rsp+0] 10 | add rsp, 72 -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_read_dataset_sshash_init.inc: -------------------------------------------------------------------------------- 1 | sub rsp, 72 2 | mov qword ptr [rsp+64], rbx 3 | mov qword ptr [rsp+56], r8 4 | mov qword ptr [rsp+48], r9 5 | mov qword ptr [rsp+40], r10 6 | mov qword ptr [rsp+32], r11 7 | mov qword ptr [rsp+24], r12 8 | mov qword ptr [rsp+16], r13 9 | mov qword ptr [rsp+8], r14 10 | mov qword ptr [rsp+0], r15 11 | xor rbp, rax ;# modify "mx" 12 | ror rbp, 32 ;# swap "ma" and "mx" 13 | mov ebx, ebp ;# ecx = ma 14 | and ebx, RANDOMX_DATASET_BASE_MASK 15 | shr ebx, 6 ;# ebx = Dataset block number 16 | ;# add ebx, datasetOffset / 64 17 | ;# call 32768 -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_sshash_avx2_constants.inc: -------------------------------------------------------------------------------- 1 | r0_avx2_increments: 2 | db 2,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0 3 | mul_hi_avx2_data: 4 | db 0,0,0,0,1,0,0,0 5 | r0_avx2_mul: 6 | ;#/ 6364136223846793005 7 | db 45, 127, 149, 76, 45, 244, 81, 88 8 | r1_avx2_add: 9 | ;#/ 9298411001130361340 10 | db 252, 161, 245, 89, 138, 151, 10, 129 11 | r2_avx2_add: 12 | ;#/ 12065312585734608966 13 | db 70, 216, 194, 56, 223, 153, 112, 167 14 | r3_avx2_add: 15 | ;#/ 9306329213124626780 16 | db 92, 73, 34, 191, 28, 185, 38, 129 17 | r4_avx2_add: 18 | ;#/ 5281919268842080866 19 | db 98, 138, 159, 23, 151, 37, 77, 73 20 | r5_avx2_add: 21 | ;#/ 10536153434571861004 22 | db 12, 236, 170, 206, 185, 239, 55, 146 23 | r6_avx2_add: 24 | ;#/ 3398623926847679864 25 | db 120, 45, 230, 108, 116, 86, 42, 47 26 | r7_avx2_add: 27 | ;#/ 9549104520008361294 28 | db 78, 229, 44, 182, 247, 59, 133, 132 -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_sshash_avx2_epilogue.inc: -------------------------------------------------------------------------------- 1 | add rsp, 40 2 | pop r9 3 | 4 | movdqu xmm0, xmmword ptr [rsp] 5 | movdqu xmm1, xmmword ptr [rsp + 16] 6 | movdqu xmm2, xmmword ptr [rsp + 32] 7 | movdqu xmm3, xmmword ptr [rsp + 48] 8 | movdqu xmm4, xmmword ptr [rsp + 64] 9 | movdqu xmm5, xmmword ptr [rsp + 80] 10 | movdqu xmm6, xmmword ptr [rsp + 96] 11 | movdqu xmm7, xmmword ptr [rsp + 112] 12 | movdqu xmm8, xmmword ptr [rsp + 128] 13 | movdqu xmm9, xmmword ptr [rsp + 144] 14 | movdqu xmm10, xmmword ptr [rsp + 160] 15 | movdqu xmm11, xmmword ptr [rsp + 176] 16 | movdqu xmm12, xmmword ptr [rsp + 192] 17 | movdqu xmm13, xmmword ptr [rsp + 208] 18 | movdqu xmm14, xmmword ptr [rsp + 224] 19 | movdqu xmm15, xmmword ptr [rsp + 240] 20 | vzeroupper 21 | add rsp, 256 22 | 23 | pop r15 24 | pop r14 25 | pop r13 26 | pop r12 27 | pop rsi 28 | pop rdi 29 | pop rbp 30 | pop rbx 31 | ret 32 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_sshash_avx2_loop_begin.inc: -------------------------------------------------------------------------------- 1 | ;# prefetch RandomX dataset lines 2 | prefetchnta byte ptr [rsi] 3 | prefetchnta byte ptr [rsi+64] 4 | prefetchnta byte ptr [rsi+128] 5 | prefetchnta byte ptr [rsi+192] 6 | prefetchnta byte ptr [rsi+256] 7 | 8 | ;# prefetch RandomX cache lines 9 | mov rbx, rbp 10 | and rbx, RANDOMX_CACHE_MASK 11 | shl rbx, 6 12 | add rbx, rdi 13 | prefetchnta byte ptr [rbx] 14 | lea rax, [rbp+1] 15 | and rax, RANDOMX_CACHE_MASK 16 | shl rax, 6 17 | add rax, rdi 18 | prefetchnta byte ptr [rax] 19 | mov [rsp], rax 20 | lea rax, [rbp+2] 21 | and rax, RANDOMX_CACHE_MASK 22 | shl rax, 6 23 | add rax, rdi 24 | prefetchnta byte ptr [rax] 25 | mov [rsp+8], rax 26 | lea rax, [rbp+3] 27 | and rax, RANDOMX_CACHE_MASK 28 | shl rax, 6 29 | add rax, rdi 30 | prefetchnta byte ptr [rax] 31 | mov [rsp+16], rax 32 | lea rax, [rbp+4] 33 | and rax, RANDOMX_CACHE_MASK 34 | shl rax, 6 35 | add rax, rdi 36 | prefetchnta byte ptr [rax] 37 | mov [rsp+24], rax 38 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_sshash_avx2_loop_end.inc: -------------------------------------------------------------------------------- 1 | mov qword ptr [rsi+0], r8 2 | vpunpcklqdq ymm8, ymm0, ymm1 3 | mov qword ptr [rsi+8], r9 4 | vpunpcklqdq ymm9, ymm2, ymm3 5 | mov qword ptr [rsi+16], r10 6 | vpunpcklqdq ymm10, ymm4, ymm5 7 | mov qword ptr [rsi+24], r11 8 | vpunpcklqdq ymm11, ymm6, ymm7 9 | mov qword ptr [rsi+32], r12 10 | vpunpckhqdq ymm12, ymm0, ymm1 11 | mov qword ptr [rsi+40], r13 12 | vpunpckhqdq ymm13, ymm2, ymm3 13 | mov qword ptr [rsi+48], r14 14 | vpunpckhqdq ymm14, ymm4, ymm5 15 | mov qword ptr [rsi+56], r15 16 | vpunpckhqdq ymm15, ymm6, ymm7 17 | 18 | vperm2i128 ymm0, ymm8, ymm9, 32 19 | vperm2i128 ymm1, ymm10, ymm11, 32 20 | vmovdqu ymmword ptr [rsi+64], ymm0 21 | vmovdqu ymmword ptr [rsi+96], ymm1 22 | vperm2i128 ymm2, ymm12, ymm13, 32 23 | vperm2i128 ymm3, ymm14, ymm15, 32 24 | vmovdqu ymmword ptr [rsi+128], ymm2 25 | vmovdqu ymmword ptr [rsi+160], ymm3 26 | vperm2i128 ymm4, ymm8, ymm9, 49 27 | vperm2i128 ymm5, ymm10, ymm11, 49 28 | vmovdqu ymmword ptr [rsi+192], ymm4 29 | vmovdqu ymmword ptr [rsi+224], ymm5 30 | vperm2i128 ymm6, ymm12, ymm13, 49 31 | vperm2i128 ymm7, ymm14, ymm15, 49 32 | vmovdqu ymmword ptr [rsi+256], ymm6 33 | vmovdqu ymmword ptr [rsi+288], ymm7 34 | 35 | add rbp, 5 36 | add rsi, 320 37 | cmp rbp, qword ptr [rsp+40] 38 | db 15, 130, 0, 0, 0, 0 ;# jb rel32 39 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_sshash_avx2_save_registers.inc: -------------------------------------------------------------------------------- 1 | push rbx 2 | push rbp 3 | push rdi 4 | push rsi 5 | push r12 6 | push r13 7 | push r14 8 | push r15 9 | 10 | ;# save all XMM registers just to be safe for all calling conventions 11 | sub rsp, 256 12 | movdqu xmmword ptr [rsp], xmm0 13 | movdqu xmmword ptr [rsp + 16], xmm1 14 | movdqu xmmword ptr [rsp + 32], xmm2 15 | movdqu xmmword ptr [rsp + 48], xmm3 16 | movdqu xmmword ptr [rsp + 64], xmm4 17 | movdqu xmmword ptr [rsp + 80], xmm5 18 | movdqu xmmword ptr [rsp + 96], xmm6 19 | movdqu xmmword ptr [rsp + 112], xmm7 20 | movdqu xmmword ptr [rsp + 128], xmm8 21 | movdqu xmmword ptr [rsp + 144], xmm9 22 | movdqu xmmword ptr [rsp + 160], xmm10 23 | movdqu xmmword ptr [rsp + 176], xmm11 24 | movdqu xmmword ptr [rsp + 192], xmm12 25 | movdqu xmmword ptr [rsp + 208], xmm13 26 | movdqu xmmword ptr [rsp + 224], xmm14 27 | movdqu xmmword ptr [rsp + 240], xmm15 28 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_sshash_avx2_ssh_prefetch.inc: -------------------------------------------------------------------------------- 1 | vmovdqu ymmword ptr [rsp], ymm0 2 | 3 | mov rax, [rsp] 4 | and rax, RANDOMX_CACHE_MASK 5 | shl rax, 6 6 | add rax, rdi 7 | mov [rsp], rax 8 | prefetchnta byte ptr [rax] 9 | 10 | mov rax, [rsp+8] 11 | and rax, RANDOMX_CACHE_MASK 12 | shl rax, 6 13 | add rax, rdi 14 | mov [rsp+8], rax 15 | prefetchnta byte ptr [rax] 16 | 17 | mov rax, [rsp+16] 18 | and rax, RANDOMX_CACHE_MASK 19 | shl rax, 6 20 | add rax, rdi 21 | mov [rsp+16], rax 22 | prefetchnta byte ptr [rax] 23 | 24 | mov rax, [rsp+24] 25 | and rax, RANDOMX_CACHE_MASK 26 | shl rax, 6 27 | add rax, rdi 28 | mov [rsp+24], rax 29 | prefetchnta byte ptr [rax] 30 | -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_sshash_constants.inc: -------------------------------------------------------------------------------- 1 | r0_mul: 2 | ;#/ 6364136223846793005 3 | db 45, 127, 149, 76, 45, 244, 81, 88 4 | r1_add: 5 | ;#/ 9298411001130361340 6 | db 252, 161, 245, 89, 138, 151, 10, 129 7 | r2_add: 8 | ;#/ 12065312585734608966 9 | db 70, 216, 194, 56, 223, 153, 112, 167 10 | r3_add: 11 | ;#/ 9306329213124626780 12 | db 92, 73, 34, 191, 28, 185, 38, 129 13 | r4_add: 14 | ;#/ 5281919268842080866 15 | db 98, 138, 159, 23, 151, 37, 77, 73 16 | r5_add: 17 | ;#/ 10536153434571861004 18 | db 12, 236, 170, 206, 185, 239, 55, 146 19 | r6_add: 20 | ;#/ 3398623926847679864 21 | db 120, 45, 230, 108, 116, 86, 42, 47 22 | r7_add: 23 | ;#/ 9549104520008361294 24 | db 78, 229, 44, 182, 247, 59, 133, 132 -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_sshash_load.inc: -------------------------------------------------------------------------------- 1 | xor r8, qword ptr [rbx+0] 2 | xor r9, qword ptr [rbx+8] 3 | xor r10, qword ptr [rbx+16] 4 | xor r11, qword ptr [rbx+24] 5 | xor r12, qword ptr [rbx+32] 6 | xor r13, qword ptr [rbx+40] 7 | xor r14, qword ptr [rbx+48] 8 | xor r15, qword ptr [rbx+56] -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_sshash_prefetch.inc: -------------------------------------------------------------------------------- 1 | and rbx, RANDOMX_CACHE_MASK 2 | shl rbx, 6 3 | add rbx, rdi 4 | prefetchnta byte ptr [rbx] -------------------------------------------------------------------------------- /src/crypto/randomx/asm/program_xmm_constants.inc: -------------------------------------------------------------------------------- 1 | mantissaMask: 2 | db 0, 0, 192, 255, 255, 255, 255, 0, 0, 0, 192, 255, 255, 255, 255, 0 3 | exp240: 4 | db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 5 | scaleMask: 6 | db 0, 0, 0, 0, 0, 0, 240, 128, 0, 0, 0, 0, 0, 0, 240, 128 -------------------------------------------------------------------------------- /src/crypto/randomx/asm/randomx_reciprocal.inc: -------------------------------------------------------------------------------- 1 | mov edx, 1 2 | mov r8, rcx 3 | xor eax, eax 4 | bsr rcx, rcx 5 | shl rdx, cl 6 | div r8 7 | ret -------------------------------------------------------------------------------- /src/crypto/randomx/panthera/KeccakSponge-common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen, 3 | Michaël Peeters, Gilles Van Assche and Ronny Van Keer, 4 | hereby denoted as "the implementer". 5 | 6 | For more information, feedback or questions, please refer to our website: 7 | https://keccak.team/ 8 | 9 | To the extent possible under law, the implementer has waived all copyright 10 | and related or neighboring rights to the source code in this file. 11 | http://creativecommons.org/publicdomain/zero/1.0/ 12 | */ 13 | 14 | #ifndef _KeccakSpongeCommon_h_ 15 | #define _KeccakSpongeCommon_h_ 16 | 17 | #include 18 | #include "align.h" 19 | 20 | #define KCP_DeclareSpongeStructure(prefix, size, alignment) \ 21 | ALIGN(alignment) typedef struct prefix##_SpongeInstanceStruct { \ 22 | unsigned char state[size]; \ 23 | unsigned int rate; \ 24 | unsigned int byteIOIndex; \ 25 | int squeezing; \ 26 | } prefix##_SpongeInstance; 27 | 28 | #define KCP_DeclareSpongeFunctions(prefix) \ 29 | int prefix##_Sponge(unsigned int rate, unsigned int capacity, const unsigned char *input, size_t inputByteLen, unsigned char suffix, unsigned char *output, size_t outputByteLen); \ 30 | int prefix##_SpongeInitialize(prefix##_SpongeInstance *spongeInstance, unsigned int rate, unsigned int capacity); \ 31 | int prefix##_SpongeAbsorb(prefix##_SpongeInstance *spongeInstance, const unsigned char *data, size_t dataByteLen); \ 32 | int prefix##_SpongeAbsorbLastFewBits(prefix##_SpongeInstance *spongeInstance, unsigned char delimitedData); \ 33 | int prefix##_SpongeSqueeze(prefix##_SpongeInstance *spongeInstance, unsigned char *data, size_t dataByteLen); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/crypto/randomx/panthera/KeccakSpongeWidth1600.c: -------------------------------------------------------------------------------- 1 | /* 2 | Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen, 3 | Michaël Peeters, Gilles Van Assche and Ronny Van Keer, 4 | hereby denoted as "the implementer". 5 | 6 | For more information, feedback or questions, please refer to our website: 7 | https://keccak.team/ 8 | 9 | To the extent possible under law, the implementer has waived all copyright 10 | and related or neighboring rights to the source code in this file. 11 | http://creativecommons.org/publicdomain/zero/1.0/ 12 | */ 13 | 14 | #include "KeccakSpongeWidth1600.h" 15 | 16 | #ifdef KeccakReference 17 | #include "displayIntermediateValues.h" 18 | #endif 19 | 20 | #ifndef KeccakP1600_excluded 21 | #include "KeccakP-1600-SnP.h" 22 | 23 | #define prefix KeccakWidth1600 24 | #define SnP KeccakP1600 25 | #define SnP_width 1600 26 | #define SnP_Permute KeccakP1600_Permute_24rounds 27 | #if defined(KeccakF1600_FastLoop_supported) 28 | #define SnP_FastLoop_Absorb KeccakF1600_FastLoop_Absorb 29 | #endif 30 | #include "KeccakSponge.inc" 31 | #undef prefix 32 | #undef SnP 33 | #undef SnP_width 34 | #undef SnP_Permute 35 | #undef SnP_FastLoop_Absorb 36 | #endif 37 | 38 | #ifndef KeccakP1600_excluded 39 | #include "KeccakP-1600-SnP.h" 40 | 41 | #define prefix KeccakWidth1600_12rounds 42 | #define SnP KeccakP1600 43 | #define SnP_width 1600 44 | #define SnP_Permute KeccakP1600_Permute_12rounds 45 | #if defined(KeccakP1600_12rounds_FastLoop_supported) 46 | #define SnP_FastLoop_Absorb KeccakP1600_12rounds_FastLoop_Absorb 47 | #endif 48 | #include "KeccakSponge.inc" 49 | #undef prefix 50 | #undef SnP 51 | #undef SnP_width 52 | #undef SnP_Permute 53 | #undef SnP_FastLoop_Absorb 54 | #endif 55 | -------------------------------------------------------------------------------- /src/crypto/randomx/panthera/KeccakSpongeWidth1600.h: -------------------------------------------------------------------------------- 1 | /* 2 | Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen, 3 | Michaël Peeters, Gilles Van Assche and Ronny Van Keer, 4 | hereby denoted as "the implementer". 5 | 6 | For more information, feedback or questions, please refer to our website: 7 | https://keccak.team/ 8 | 9 | To the extent possible under law, the implementer has waived all copyright 10 | and related or neighboring rights to the source code in this file. 11 | http://creativecommons.org/publicdomain/zero/1.0/ 12 | */ 13 | 14 | #ifndef _KeccakSpongeWidth1600_h_ 15 | #define _KeccakSpongeWidth1600_h_ 16 | 17 | #include "KeccakSponge-common.h" 18 | 19 | #ifndef KeccakP1600_excluded 20 | #include "KeccakP-1600-SnP.h" 21 | KCP_DeclareSpongeStructure(KeccakWidth1600, KeccakP1600_stateSizeInBytes, KeccakP1600_stateAlignment) 22 | KCP_DeclareSpongeFunctions(KeccakWidth1600) 23 | #endif 24 | 25 | #ifndef KeccakP1600_excluded 26 | #include "KeccakP-1600-SnP.h" 27 | KCP_DeclareSpongeStructure(KeccakWidth1600_12rounds, KeccakP1600_stateSizeInBytes, KeccakP1600_stateAlignment) 28 | KCP_DeclareSpongeFunctions(KeccakWidth1600_12rounds) 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/crypto/randomx/panthera/Phases.h: -------------------------------------------------------------------------------- 1 | /* 2 | Implementation by Ronny Van Keer, hereby denoted as "the implementer". 3 | 4 | For more information, feedback or questions, please refer to our website: 5 | https://keccak.team/ 6 | 7 | To the extent possible under law, the implementer has waived all copyright 8 | and related or neighboring rights to the source code in this file. 9 | http://creativecommons.org/publicdomain/zero/1.0/ 10 | */ 11 | 12 | #ifndef _Phases_h_ 13 | #define _Phases_h_ 14 | 15 | typedef enum { 16 | NOT_INITIALIZED, 17 | ABSORBING, 18 | FINAL, 19 | SQUEEZING 20 | } KCP_Phases; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/crypto/randomx/panthera/align.h: -------------------------------------------------------------------------------- 1 | /* 2 | Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen, 3 | Michaël Peeters, Gilles Van Assche and Ronny Van Keer, 4 | hereby denoted as "the implementer". 5 | 6 | For more information, feedback or questions, please refer to our website: 7 | https://keccak.team/ 8 | 9 | To the extent possible under law, the implementer has waived all copyright 10 | and related or neighboring rights to the source code in this file. 11 | http://creativecommons.org/publicdomain/zero/1.0/ 12 | */ 13 | 14 | #ifndef _align_h_ 15 | #define _align_h_ 16 | 17 | /* on Mac OS-X and possibly others, ALIGN(x) is defined in param.h, and -Werror chokes on the redef. */ 18 | #ifdef ALIGN 19 | #undef ALIGN 20 | #endif 21 | 22 | #if defined(__GNUC__) 23 | #define ALIGN(x) __attribute__ ((aligned(x))) 24 | #elif defined(_MSC_VER) 25 | #define ALIGN(x) __declspec(align(x)) 26 | #elif defined(__ARMCC_VERSION) 27 | #define ALIGN(x) __align(x) 28 | #else 29 | #define ALIGN(x) 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/crypto/randomx/panthera/insecure_memzero.h: -------------------------------------------------------------------------------- 1 | #define insecure_memzero(buf, len) /* empty */ 2 | -------------------------------------------------------------------------------- /src/crypto/randomx/virtual_memory.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018-2019, tevador 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | void* allocExecutableMemory(std::size_t, bool); 34 | void* allocLargePagesMemory(std::size_t); 35 | void freePagedMemory(void*, std::size_t); 36 | -------------------------------------------------------------------------------- /src/crypto/rx/RxBasicStorage.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2019 tevador 3 | * Copyright (c) 2018-2020 SChernykh 4 | * Copyright (c) 2016-2020 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef XMRIG_RX_BASICSTORAGE_H 21 | #define XMRIG_RX_BASICSTORAGE_H 22 | 23 | 24 | #include "backend/common/interfaces/IRxStorage.h" 25 | 26 | 27 | namespace xmrig 28 | { 29 | 30 | 31 | class RxBasicStoragePrivate; 32 | 33 | 34 | class RxBasicStorage : public IRxStorage 35 | { 36 | public: 37 | XMRIG_DISABLE_COPY_MOVE(RxBasicStorage); 38 | 39 | RxBasicStorage(); 40 | ~RxBasicStorage() override; 41 | 42 | protected: 43 | bool isAllocated() const override; 44 | HugePagesInfo hugePages() const override; 45 | RxDataset *dataset(const Job &job, uint32_t nodeId) const override; 46 | void init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority) override; 47 | 48 | private: 49 | RxBasicStoragePrivate *d_ptr; 50 | }; 51 | 52 | 53 | } /* namespace xmrig */ 54 | 55 | 56 | #endif /* XMRIG_RX_BASICSTORAGE_H */ 57 | -------------------------------------------------------------------------------- /src/crypto/rx/RxFix.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2019 tevador 3 | * Copyright (c) 2018-2021 SChernykh 4 | * Copyright (c) 2016-2021 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef XMRIG_RXFIX_H 21 | #define XMRIG_RXFIX_H 22 | 23 | 24 | #include 25 | 26 | 27 | namespace xmrig 28 | { 29 | 30 | 31 | class RxFix 32 | { 33 | public: 34 | static void setMainLoopBounds(const std::pair &bounds); 35 | static void setupMainLoopExceptionFrame(); 36 | }; 37 | 38 | 39 | } /* namespace xmrig */ 40 | 41 | 42 | #endif /* XMRIG_RXFIX_H */ 43 | -------------------------------------------------------------------------------- /src/crypto/rx/RxMsr.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2019 tevador 3 | * Copyright (c) 2018-2021 SChernykh 4 | * Copyright (c) 2016-2021 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef XMRIG_RXMSR_H 21 | #define XMRIG_RXMSR_H 22 | 23 | 24 | #include 25 | 26 | 27 | namespace xmrig 28 | { 29 | 30 | 31 | class CpuThread; 32 | class RxConfig; 33 | 34 | 35 | class RxMsr 36 | { 37 | public: 38 | static inline bool isEnabled() { return m_enabled; } 39 | static inline bool isInitialized() { return m_initialized; } 40 | 41 | static bool init(const RxConfig &config, const std::vector &threads); 42 | static void destroy(); 43 | 44 | private: 45 | static bool m_cacheQoS; 46 | static bool m_enabled; 47 | static bool m_initialized; 48 | }; 49 | 50 | 51 | } /* namespace xmrig */ 52 | 53 | 54 | #endif /* XMRIG_RXMSR_H */ 55 | -------------------------------------------------------------------------------- /src/crypto/rx/RxVm.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2019 tevador 3 | * Copyright (c) 2018-2020 SChernykh 4 | * Copyright (c) 2016-2020 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef XMRIG_RX_VM_H 21 | #define XMRIG_RX_VM_H 22 | 23 | 24 | #include 25 | 26 | 27 | class randomx_vm; 28 | 29 | 30 | namespace xmrig 31 | { 32 | 33 | 34 | class Assembly; 35 | class RxDataset; 36 | 37 | 38 | class RxVm 39 | { 40 | public: 41 | static randomx_vm *create(RxDataset *dataset, uint8_t *scratchpad, bool softAes, const Assembly &assembly, uint32_t node); 42 | static void destroy(randomx_vm *vm); 43 | }; 44 | 45 | 46 | } /* namespace xmrig */ 47 | 48 | 49 | #endif /* XMRIG_RX_VM_H */ 50 | -------------------------------------------------------------------------------- /src/hw/api/HwApi.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2021 SChernykh 3 | * Copyright (c) 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include "hw/api/HwApi.h" 21 | #include "base/api/interfaces/IApiRequest.h" 22 | #include "base/tools/String.h" 23 | 24 | 25 | #ifdef XMRIG_FEATURE_DMI 26 | # include "hw/dmi/DmiReader.h" 27 | #endif 28 | 29 | 30 | void xmrig::HwApi::onRequest(IApiRequest &request) 31 | { 32 | if (request.method() == IApiRequest::METHOD_GET) { 33 | # ifdef XMRIG_FEATURE_DMI 34 | if (request.url() == "/2/dmi") { 35 | if (!m_dmi) { 36 | m_dmi = std::make_shared(); 37 | m_dmi->read(); 38 | } 39 | 40 | request.accept(); 41 | m_dmi->toJSON(request.reply(), request.doc()); 42 | } 43 | # endif 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/hw/api/HwApi.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2021 SChernykh 3 | * Copyright (c) 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_HWAPI_H 20 | #define XMRIG_HWAPI_H 21 | 22 | 23 | #include "base/api/interfaces/IApiListener.h" 24 | 25 | 26 | #include 27 | 28 | 29 | namespace xmrig { 30 | 31 | 32 | struct DmiReader; 33 | 34 | 35 | class HwApi : public IApiListener 36 | { 37 | public: 38 | HwApi() = default; 39 | 40 | protected: 41 | void onRequest(IApiRequest &request) override; 42 | 43 | private: 44 | # ifdef XMRIG_FEATURE_DMI 45 | std::shared_ptr m_dmi; 46 | # endif 47 | }; 48 | 49 | 50 | } /* namespace xmrig */ 51 | 52 | 53 | #endif /* XMRIG_HWAPI_H */ 54 | -------------------------------------------------------------------------------- /src/hw/api/api.cmake: -------------------------------------------------------------------------------- 1 | if (WITH_HTTP) 2 | add_definitions(/DXMRIG_FEATURE_DMI) 3 | 4 | list(APPEND HEADERS 5 | src/hw/api/HwApi.h 6 | ) 7 | 8 | list(APPEND SOURCES 9 | src/hw/api/HwApi.cpp 10 | ) 11 | endif() 12 | -------------------------------------------------------------------------------- /src/hw/dmi/DmiBoard.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2000-2002 Alan Cox 3 | * Copyright (c) 2005-2020 Jean Delvare 4 | * Copyright (c) 2018-2021 SChernykh 5 | * Copyright (c) 2016-2021 XMRig , 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | 22 | #include "hw/dmi/DmiBoard.h" 23 | #include "3rdparty/rapidjson/document.h" 24 | #include "hw/dmi/DmiTools.h" 25 | 26 | 27 | void xmrig::DmiBoard::decode(dmi_header *h) 28 | { 29 | if (h->length < 0x08) { 30 | return; 31 | } 32 | 33 | m_vendor = dmi_string(h, 0x04); 34 | m_product = dmi_string(h, 0x05); 35 | } 36 | 37 | 38 | #ifdef XMRIG_FEATURE_API 39 | rapidjson::Value xmrig::DmiBoard::toJSON(rapidjson::Document &doc) const 40 | { 41 | using namespace rapidjson; 42 | 43 | auto &allocator = doc.GetAllocator(); 44 | Value out(kObjectType); 45 | out.AddMember("vendor", m_vendor.toJSON(doc), allocator); 46 | out.AddMember("product", m_product.toJSON(doc), allocator); 47 | 48 | return out; 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /src/hw/dmi/DmiBoard.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2000-2002 Alan Cox 3 | * Copyright (c) 2005-2020 Jean Delvare 4 | * Copyright (c) 2018-2021 SChernykh 5 | * Copyright (c) 2016-2021 XMRig , 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #ifndef XMRIG_DMIBOARD_H 22 | #define XMRIG_DMIBOARD_H 23 | 24 | 25 | #include "base/tools/String.h" 26 | 27 | 28 | namespace xmrig { 29 | 30 | 31 | struct dmi_header; 32 | 33 | 34 | class DmiBoard 35 | { 36 | public: 37 | DmiBoard() = default; 38 | 39 | inline const String &product() const { return m_product; } 40 | inline const String &vendor() const { return m_vendor; } 41 | inline bool isValid() const { return !m_product.isEmpty() && !m_vendor.isEmpty(); } 42 | 43 | void decode(dmi_header *h); 44 | 45 | # ifdef XMRIG_FEATURE_API 46 | rapidjson::Value toJSON(rapidjson::Document &doc) const; 47 | # endif 48 | 49 | private: 50 | String m_product; 51 | String m_vendor; 52 | }; 53 | 54 | 55 | } /* namespace xmrig */ 56 | 57 | 58 | #endif /* XMRIG_DMIBOARD_H */ 59 | -------------------------------------------------------------------------------- /src/hw/dmi/DmiTools.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2000-2002 Alan Cox 3 | * Copyright (c) 2005-2020 Jean Delvare 4 | * Copyright (c) 2018-2021 SChernykh 5 | * Copyright (c) 2016-2021 XMRig , 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #ifndef XMRIG_DMITOOLS_H 22 | #define XMRIG_DMITOOLS_H 23 | 24 | 25 | #include 26 | #include 27 | 28 | 29 | namespace xmrig { 30 | 31 | 32 | struct dmi_header 33 | { 34 | uint8_t type; 35 | uint8_t length; 36 | uint16_t handle; 37 | uint8_t *data; 38 | }; 39 | 40 | 41 | struct u64 { 42 | uint32_t l; 43 | uint32_t h; 44 | }; 45 | 46 | 47 | template 48 | inline T dmi_get(const uint8_t *data) { return *reinterpret_cast(data); } 49 | 50 | template 51 | inline T dmi_get(const dmi_header *h, size_t offset) { return *reinterpret_cast(h->data + offset); } 52 | 53 | 54 | const char *dmi_string(dmi_header *dm, size_t offset); 55 | 56 | 57 | } /* namespace xmrig */ 58 | 59 | 60 | #endif /* XMRIG_DMITOOLS_H */ 61 | -------------------------------------------------------------------------------- /src/hw/dmi/dmi.cmake: -------------------------------------------------------------------------------- 1 | if (WITH_DMI AND (XMRIG_OS_WIN OR XMRIG_OS_LINUX OR XMRIG_OS_FREEBSD OR (XMRIG_OS_MACOS AND NOT XMRIG_ARM))) 2 | set(WITH_DMI ON) 3 | else() 4 | set(WITH_DMI OFF) 5 | endif() 6 | 7 | if (WITH_DMI) 8 | add_definitions(/DXMRIG_FEATURE_DMI) 9 | 10 | list(APPEND HEADERS 11 | src/hw/dmi/DmiBoard.h 12 | src/hw/dmi/DmiMemory.h 13 | src/hw/dmi/DmiReader.h 14 | src/hw/dmi/DmiTools.h 15 | ) 16 | 17 | list(APPEND SOURCES 18 | src/hw/dmi/DmiBoard.cpp 19 | src/hw/dmi/DmiMemory.cpp 20 | src/hw/dmi/DmiReader.cpp 21 | src/hw/dmi/DmiTools.cpp 22 | ) 23 | 24 | if (XMRIG_OS_WIN) 25 | list(APPEND SOURCES src/hw/dmi/DmiReader_win.cpp) 26 | elseif(XMRIG_OS_LINUX OR XMRIG_OS_FREEBSD) 27 | list(APPEND SOURCES src/hw/dmi/DmiReader_unix.cpp) 28 | elseif(XMRIG_OS_MACOS) 29 | list(APPEND SOURCES src/hw/dmi/DmiReader_mac.cpp) 30 | endif() 31 | else() 32 | remove_definitions(/DXMRIG_FEATURE_DMI) 33 | endif() 34 | -------------------------------------------------------------------------------- /src/net/interfaces/IJobResultListener.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2019 SChernykh 9 | * Copyright 2016-2019 XMRig , 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | #ifndef XMRIG_IJOBRESULTLISTENER_H 26 | #define XMRIG_IJOBRESULTLISTENER_H 27 | 28 | 29 | namespace xmrig { 30 | 31 | 32 | class Client; 33 | class JobResult; 34 | 35 | 36 | class IJobResultListener 37 | { 38 | public: 39 | virtual ~IJobResultListener() = default; 40 | 41 | virtual void onJobResult(const JobResult &result) = 0; 42 | }; 43 | 44 | 45 | } /* namespace xmrig */ 46 | 47 | 48 | #endif // XMRIG_IJOBRESULTLISTENER_H 49 | -------------------------------------------------------------------------------- /src/xlarig.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2019 SChernykh 9 | * Copyright 2016-2019 XMRig , 10 | * Copyright 2018-2021 The Scala Project Team , 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation, either version 3 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with this program. If not, see . 24 | */ 25 | 26 | #include "App.h" 27 | #include "base/kernel/Entry.h" 28 | #include "base/kernel/Process.h" 29 | 30 | 31 | int main(int argc, char **argv) { 32 | using namespace xmrig; 33 | 34 | Process process(argc, argv); 35 | const Entry::Id entry = Entry::get(process); 36 | if (entry) { 37 | return Entry::exec(process, entry); 38 | } 39 | 40 | App app(&process); 41 | 42 | return app.exec(); 43 | } 44 | --------------------------------------------------------------------------------