diff --git a/src/client/component/auth.cpp b/src/client/component/auth.cpp index fba96ad8..4a76dddb 100644 --- a/src/client/component/auth.cpp +++ b/src/client/component/auth.cpp @@ -155,8 +155,8 @@ namespace auth void post_unpack() override { // Skip connect handler - //utils::hook::set(game::select(0x142253EFA, 0x14053714A), 0xEB); - //network::on("connect", handle_connect_packet); + utils::hook::set(game::select(0x142253EFA, 0x14053714A), 0xEB); + network::on("connect", handle_connect_packet); // Patch steam id bit check std::vector> patches{}; @@ -203,7 +203,7 @@ namespace auth p(0x141EB5992_g, 0x141EB59D5_g); p(0x141EB74D2_g, 0x141EB7515_g); // ? - //utils::hook::call(0x14134BF7D_g, send_connect_data_stub); + utils::hook::call(0x14134BF7D_g, send_connect_data_stub); } for (const auto& patch : patches) diff --git a/src/common/utils/byte_buffer.cpp b/src/common/utils/byte_buffer.cpp index 2ef0a3b0..76e02a00 100644 --- a/src/common/utils/byte_buffer.cpp +++ b/src/common/utils/byte_buffer.cpp @@ -17,28 +17,28 @@ namespace utils void byte_buffer::write(const void* buffer, const size_t length) { - if (!writing_) + if (!this->writing_) { throw std::runtime_error("Writing to readable byte buffer"); } - buffer_.append(static_cast(buffer), length); + this->buffer_.append(static_cast(buffer), length); } void byte_buffer::read(void* data, const size_t length) { - if (writing_) + if (this->writing_) { throw std::runtime_error("Reading from writable byte buffer"); } - if (offset_ + length > buffer_.size()) + if (this->offset_ + length > this->buffer_.size()) { throw std::runtime_error("Out of bounds read from byte buffer"); } - memcpy(data, buffer_.data() + offset_, length); - offset_ += length; + memcpy(data, this->buffer_.data() + this->offset_, length); + this->offset_ += length; } std::string byte_buffer::read_string() @@ -47,7 +47,7 @@ namespace utils while (true) { - const auto b = read(); + const auto b = this->read(); if (!b) { break; @@ -66,7 +66,7 @@ namespace utils for (size_t i = 0; i < length; ++i) { - result.push_back(read()); + result.push_back(this->read()); } return result; @@ -77,7 +77,7 @@ namespace utils std::vector result{}; result.resize(length); - read(result.data(), result.size()); + this->read(result.data(), result.size()); return result; } diff --git a/src/common/utils/byte_buffer.hpp b/src/common/utils/byte_buffer.hpp index 6a801968..8989cbbd 100644 --- a/src/common/utils/byte_buffer.hpp +++ b/src/common/utils/byte_buffer.hpp @@ -23,41 +23,41 @@ namespace utils void write(const std::string& string, const bool null_terminate = false) { const size_t addend = null_terminate ? 1 : 0; - write(string.data(), string.size() + addend); + this->write(string.data(), string.size() + addend); } void write_string(const std::string& string) { - write(string, true); + this->write(string, true); } template void write(const T& object) { - write(&object, sizeof(object)); + this->write(&object, sizeof(object)); } template void write(const std::vector& vec) { - write(vec.data(), vec.size() * sizeof(T)); + this->write(vec.data(), vec.size() * sizeof(T)); } template void write_vector(const std::vector& vec) { - write(static_cast(vec.size())); - write(vec); + this->write(static_cast(vec.size())); + this->write(vec); } const std::string& get_buffer() const { - return buffer_; + return this->buffer_; } std::string move_buffer() { - return std::move(buffer_); + return std::move(this->buffer_); } void read(void* data, size_t length); @@ -66,7 +66,7 @@ namespace utils T read() { T object{}; - read(&object, sizeof(object)); + this->read(&object, sizeof(object)); return object; } @@ -75,12 +75,15 @@ namespace utils { std::vector result{}; const auto size = read(); - if (offset_ + size > buffer_.size()) + const auto totalSize = size * sizeof(T); + + if (this->offset_ + totalSize > this->buffer_.size()) { throw std::runtime_error("Out of bounds read from byte buffer"); } - read(result.data(), size); + result.resize(size); + this->read(result.data(), totalSize); return result; }