Fixed some compiler warnings
This commit is contained in:
parent
3b3574d54d
commit
5fff4369ef
@ -1,4 +1,4 @@
|
||||
1
|
||||
success
|
||||
cb73d9df3258eaf59e4799c9e54d5f865e891734
|
||||
22 Sep 2019 13:38:56
|
||||
870933c892c6b84a7127daac8f92f5c205b09611
|
||||
22 Sep 2019 16:25:55
|
||||
|
@ -39,15 +39,17 @@ namespace str_obf {
|
||||
return !str[h] ? 5381 : (string_hash(str, h + 1) * 33) ^ str[h];
|
||||
}
|
||||
|
||||
#pragma warning(disable: 4146) // unary minus operator applied to unsigned type, result still unsigned
|
||||
constexpr std::uint32_t rng32_next(std::uint64_t& state, const std::uint32_t& inc) noexcept {
|
||||
std::uint64_t oldstate = state;
|
||||
// Advance internal state
|
||||
state = oldstate * 6364136223846793005ULL + (inc | 1UL);
|
||||
// Calculate output function (XSH RR), uses old state for max ILP
|
||||
std::uint32_t xorshifted = ((oldstate >> 18u) ^ oldstate) >> 27u;
|
||||
std::uint32_t xorshifted = (uint32_t) (((oldstate >> 18u) ^ oldstate) >> 27u);
|
||||
std::uint32_t rot = oldstate >> 59u;
|
||||
return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
|
||||
}
|
||||
#pragma warning(default: 4146) // unary minus operator applied to unsigned type, result still unsigned
|
||||
|
||||
/* we use a buffer dividable by 8 so the compiler could do crazy shit, when loading (moving) the characters */
|
||||
constexpr size_t recommand_message_buffer(size_t message_size) noexcept {
|
||||
@ -105,7 +107,7 @@ namespace str_obf {
|
||||
std::uint64_t rng_seed = internal::time_seed() ^ internal::string_hash(message, 0);
|
||||
std::uint64_t rng_base = rng_seed;
|
||||
while(padding-- > 0)
|
||||
*bit++ = internal::rng32_next(rng_base, rng_seed) & 0xFFUL;
|
||||
*bit++ = internal::rng32_next(rng_base, (uint32_t) rng_seed) & 0xFFUL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +136,7 @@ namespace str_obf {
|
||||
std::uint64_t rng_base = seed;
|
||||
size_t length = 0;
|
||||
do {
|
||||
length = (internal::rng32_next(rng_base, seed) >> 12UL) & 0xFFUL;
|
||||
length = (size_t) ((internal::rng32_next(rng_base, (uint32_t) seed) >> 12UL) & 0xFFUL);
|
||||
} while(length < 8 || length >= max_size);
|
||||
|
||||
/* it does not really matter if we have a 8 byte aligned number here, because we iterate so or so byte for byte */
|
||||
@ -149,7 +151,7 @@ namespace str_obf {
|
||||
constexpr size_t key_length = generate_key_length(internal::time_seed() ^ (line_number << 37UL), max_size);
|
||||
std::array<uint8_t, key_length> result{};
|
||||
for(auto& it : result)
|
||||
it = (internal::rng32_next(rng_base, rng_seed) >> 16UL) & 0xFFUL;
|
||||
it = (internal::rng32_next(rng_base, (uint32_t) rng_seed) >> 16UL) & 0xFFUL;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -166,7 +168,7 @@ namespace str_obf {
|
||||
#endif
|
||||
const char* c_str() noexcept {
|
||||
if(!this->decoded) {
|
||||
memcpy(this->buffer.data(), this->encoded.buffer.begin(), message::_size);
|
||||
memcpy(this->buffer.data(), this->encoded.buffer.data(), message::_size);
|
||||
crypt<
|
||||
typename message::_char_t,
|
||||
typename message::_key_t
|
||||
|
@ -7,6 +7,11 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
// Windows defines the macro max(a, b)
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
namespace ts {
|
||||
namespace protocol {
|
||||
template <typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user