small dw changes
This commit is contained in:
parent
309867f7b2
commit
ccf71ca67f
@ -119,7 +119,7 @@ namespace demonware
|
||||
int getaddrinfo_stub(const char* name, const char* service,
|
||||
const addrinfo* hints, addrinfo** res)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[ network ]: [getaddrinfo]: \"%s\" \"%s\"\n", name, service);
|
||||
#endif
|
||||
|
||||
@ -202,7 +202,7 @@ namespace demonware
|
||||
|
||||
hostent* gethostbyname_stub(const char* name)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[ network ]: [gethostbyname]: \"%s\"\n", name);
|
||||
#endif
|
||||
|
||||
@ -430,7 +430,7 @@ namespace demonware
|
||||
//printf("logged\n");
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
void a(unsigned int n)
|
||||
{
|
||||
printf("bdAuth: Auth task failed with HTTP code [%u]\n", n);
|
||||
|
@ -3,18 +3,24 @@
|
||||
|
||||
namespace demonware
|
||||
{
|
||||
bool byte_buffer::read_byte(unsigned char* output)
|
||||
{
|
||||
if (!this->read_data_type(3)) return false;
|
||||
return this->read(1, output);
|
||||
}
|
||||
|
||||
bool byte_buffer::read_bool(bool* output)
|
||||
{
|
||||
if (!this->read_data_type(1)) return false;
|
||||
return this->read(1, output);
|
||||
}
|
||||
|
||||
bool byte_buffer::read_byte(char* output)
|
||||
{
|
||||
if (!this->read_data_type(2)) return false;
|
||||
return this->read(1, output);
|
||||
}
|
||||
|
||||
bool byte_buffer::read_ubyte(unsigned char* output)
|
||||
{
|
||||
if (!this->read_data_type(3)) return false;
|
||||
return this->read(1, output);
|
||||
}
|
||||
|
||||
bool byte_buffer::read_int16(short* output)
|
||||
{
|
||||
if (!this->read_data_type(5)) return false;
|
||||
@ -152,18 +158,24 @@ namespace demonware
|
||||
return true;
|
||||
}
|
||||
|
||||
bool byte_buffer::write_byte(char data)
|
||||
{
|
||||
this->write_data_type(3);
|
||||
return this->write(1, &data);
|
||||
}
|
||||
|
||||
bool byte_buffer::write_bool(bool data)
|
||||
{
|
||||
this->write_data_type(1);
|
||||
return this->write(1, &data);
|
||||
}
|
||||
|
||||
bool byte_buffer::write_byte(char data)
|
||||
{
|
||||
this->write_data_type(2);
|
||||
return this->write(1, &data);
|
||||
}
|
||||
|
||||
bool byte_buffer::write_ubyte(unsigned char data)
|
||||
{
|
||||
this->write_data_type(3);
|
||||
return this->write(1, &data);
|
||||
}
|
||||
|
||||
bool byte_buffer::write_int16(short data)
|
||||
{
|
||||
this->write_data_type(5);
|
||||
@ -242,7 +254,7 @@ namespace demonware
|
||||
const auto using_types = this->is_using_data_types();
|
||||
this->set_use_data_types(false);
|
||||
|
||||
auto result = this->write_byte(type + 100);
|
||||
auto result = this->write_ubyte(type + 100);
|
||||
|
||||
this->set_use_data_types(true);
|
||||
result &= this->write_uint32(element_count * element_size);
|
||||
|
@ -11,8 +11,9 @@ namespace demonware
|
||||
{
|
||||
}
|
||||
|
||||
bool read_byte(unsigned char* output);
|
||||
bool read_bool(bool* output);
|
||||
bool read_byte(char* output);
|
||||
bool read_ubyte(unsigned char* output);
|
||||
bool read_int16(short* output);
|
||||
bool read_uint16(unsigned short* output);
|
||||
bool read_int32(int* output);
|
||||
@ -30,8 +31,9 @@ namespace demonware
|
||||
bool read_array_header(unsigned char expected, unsigned int* element_count,
|
||||
unsigned int* element_size = nullptr);
|
||||
|
||||
bool write_byte(char data);
|
||||
bool write_bool(bool data);
|
||||
bool write_byte(char data);
|
||||
bool write_ubyte(unsigned char data);
|
||||
bool write_int16(short data);
|
||||
bool write_uint16(unsigned short data);
|
||||
bool write_int32(int data);
|
||||
|
@ -89,7 +89,7 @@ namespace demonware
|
||||
std::memcpy(data.m_dec_key, &out_3[40], 16);
|
||||
std::memcpy(data.m_enc_key, &out_3[56], 16);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW] Response id: %s\n", utils::string::dump_hex(std::string(&out_2[8], 8)).data());
|
||||
printf("[DW] Hash verify: %s\n", utils::string::dump_hex(std::string(&out_3[20], 20)).data());
|
||||
printf("[DW] AES dec key: %s\n", utils::string::dump_hex(std::string(&out_3[40], 16)).data());
|
||||
|
@ -14,7 +14,7 @@ namespace demonware
|
||||
|
||||
result.write_int32(static_cast<int>(this->buffer_.size()) + 2);
|
||||
result.write_bool(false);
|
||||
result.write_byte(this->type());
|
||||
result.write_ubyte(this->type());
|
||||
result.write(this->buffer_);
|
||||
|
||||
return result.get_buffer();
|
||||
@ -29,7 +29,7 @@ namespace demonware
|
||||
enc_buffer.set_use_data_types(false);
|
||||
|
||||
enc_buffer.write_uint32(static_cast<unsigned int>(this->buffer_.size())); // service data size CHECKTHIS!!
|
||||
enc_buffer.write_byte(this->type()); // TASK_REPLY type
|
||||
enc_buffer.write_ubyte(this->type()); // TASK_REPLY type
|
||||
enc_buffer.write(this->buffer_); // service data
|
||||
|
||||
auto aligned_data = enc_buffer.get_buffer();
|
||||
@ -51,8 +51,8 @@ namespace demonware
|
||||
response.set_use_data_types(false);
|
||||
|
||||
response.write_int32(30 + static_cast<int>(enc_data.size()));
|
||||
response.write_byte(static_cast<char>(0xAB));
|
||||
response.write_byte(static_cast<char>(0x85));
|
||||
response.write_ubyte(static_cast<unsigned char>(0xAB));
|
||||
response.write_ubyte(static_cast<unsigned char>(0x85));
|
||||
response.write_int32(msg_count);
|
||||
response.write(16, seed.data());
|
||||
response.write(enc_data);
|
||||
|
@ -119,7 +119,7 @@ namespace demonware
|
||||
byte_buffer buffer;
|
||||
buffer.write_uint64(transaction_id);
|
||||
buffer.write_uint32(this->error_);
|
||||
buffer.write_byte(this->type_);
|
||||
buffer.write_ubyte(this->type_);
|
||||
|
||||
if (!this->error_)
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ namespace demonware
|
||||
{
|
||||
if (packet.starts_with("POST /auth/"))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [auth]: user requested authentication.\n");
|
||||
#endif
|
||||
return;
|
||||
@ -81,7 +81,7 @@ namespace demonware
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [auth]: authenticating user %s\n", token.data() + 64);
|
||||
#endif
|
||||
|
||||
@ -161,7 +161,7 @@ namespace demonware
|
||||
|
||||
this->send_reply(&reply);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [auth]: user successfully authenticated.\n");
|
||||
#endif
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace demonware
|
||||
}
|
||||
else if (size == 0xC8)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [lobby]: received client_header_ack.\n");
|
||||
#endif
|
||||
|
||||
@ -74,7 +74,7 @@ namespace demonware
|
||||
|
||||
raw_reply reply(packet_2);
|
||||
this->send_reply(&reply);
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [lobby]: sending server_header_ack.\n");
|
||||
#endif
|
||||
return;
|
||||
@ -83,15 +83,15 @@ namespace demonware
|
||||
if (buffer.size() < size_t(size)) return;
|
||||
|
||||
uint8_t check_ab;
|
||||
buffer.read_byte(&check_ab);
|
||||
buffer.read_ubyte(&check_ab);
|
||||
if (check_ab == 0xAB)
|
||||
{
|
||||
uint8_t type;
|
||||
buffer.read_byte(&type);
|
||||
buffer.read_ubyte(&type);
|
||||
|
||||
if (type == 0x82)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [lobby]: received client_auth.\n");
|
||||
#endif
|
||||
std::string packet_3(packet.data(), packet.size() - 8); // this 8 are client hash check?
|
||||
@ -106,7 +106,7 @@ namespace demonware
|
||||
raw_reply reply(response);
|
||||
this->send_reply(&reply);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [lobby]: sending server_auth_done.\n");
|
||||
#endif
|
||||
return;
|
||||
@ -135,10 +135,10 @@ namespace demonware
|
||||
serv.read_uint32(&serv_size);
|
||||
|
||||
uint8_t magic; // 0x86
|
||||
serv.read_byte(&magic);
|
||||
serv.read_ubyte(&magic);
|
||||
|
||||
uint8_t service_id;
|
||||
serv.read_byte(&service_id);
|
||||
serv.read_ubyte(&service_id);
|
||||
|
||||
this->call_service(service_id, serv.get_remaining());
|
||||
|
||||
@ -170,7 +170,7 @@ namespace demonware
|
||||
// return no error
|
||||
byte_buffer buffer(data);
|
||||
uint8_t task_id;
|
||||
buffer.read_byte(&task_id);
|
||||
buffer.read_ubyte(&task_id);
|
||||
|
||||
this->create_reply(task_id)->send();
|
||||
}
|
||||
|
@ -11,9 +11,9 @@ namespace demonware
|
||||
|
||||
byte_buffer buffer(packet);
|
||||
buffer.set_use_data_types(false);
|
||||
buffer.read_byte(&type);
|
||||
buffer.read_byte(&version);
|
||||
buffer.read_byte(&padding);
|
||||
buffer.read_ubyte(&type);
|
||||
buffer.read_ubyte(&version);
|
||||
buffer.read_ubyte(&padding);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@ -34,9 +34,9 @@ namespace demonware
|
||||
|
||||
byte_buffer buffer;
|
||||
buffer.set_use_data_types(false);
|
||||
buffer.write_byte(31); // type
|
||||
buffer.write_byte(2); // version
|
||||
buffer.write_byte(0); // version
|
||||
buffer.write_ubyte(31); // type
|
||||
buffer.write_ubyte(2); // version
|
||||
buffer.write_ubyte(0); // version
|
||||
buffer.write_uint32(ip); // external ip
|
||||
buffer.write_uint16(3074); // port
|
||||
|
||||
@ -49,9 +49,9 @@ namespace demonware
|
||||
|
||||
byte_buffer buffer;
|
||||
buffer.set_use_data_types(false);
|
||||
buffer.write_byte(21); // type
|
||||
buffer.write_byte(2); // version
|
||||
buffer.write_byte(0); // version
|
||||
buffer.write_ubyte(21); // type
|
||||
buffer.write_ubyte(2); // version
|
||||
buffer.write_ubyte(0); // version
|
||||
buffer.write_uint32(ip); // external ip
|
||||
buffer.write_uint16(3074); // port
|
||||
buffer.write_uint32(this->get_address()); // server ip
|
||||
|
@ -45,13 +45,13 @@ namespace demonware
|
||||
|
||||
byte_buffer buffer(data);
|
||||
|
||||
buffer.read_byte(&this->task_id_);
|
||||
buffer.read_ubyte(&this->task_id_);
|
||||
|
||||
const auto& it = this->tasks_.find(this->task_id_);
|
||||
|
||||
if (it != this->tasks_.end())
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW] %s: executing task '%d'\n", name_.data(), this->task_id_);
|
||||
#endif
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace demonware
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [bdStorage]: missing publisher file: %s\n", name.data());
|
||||
#endif
|
||||
|
||||
@ -66,10 +66,6 @@ namespace demonware
|
||||
|
||||
void bdStorage::list_publisher_files(service_server* server, byte_buffer* buffer)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
utils::io::write_file("demonware/bdStorage/list_publisher_files", buffer->get_buffer());
|
||||
#endif
|
||||
|
||||
uint32_t date;
|
||||
uint16_t num_results, offset;
|
||||
std::string unk, filename, data;
|
||||
@ -80,7 +76,7 @@ namespace demonware
|
||||
buffer->read_uint16(&offset);
|
||||
buffer->read_string(&filename);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [bdStorage]: list publisher files: %s\n", filename.data());
|
||||
#endif
|
||||
|
||||
@ -106,15 +102,11 @@ namespace demonware
|
||||
|
||||
void bdStorage::get_publisher_file(service_server* server, byte_buffer* buffer)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
utils::io::write_file("demonware/bdStorage/get_publisher_file", buffer->get_buffer());
|
||||
#endif
|
||||
|
||||
std::string unk, filename;
|
||||
buffer->read_string(&unk);
|
||||
buffer->read_string(&filename);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [bdStorage]: loading publisher file: %s\n", filename.data());
|
||||
#endif
|
||||
|
||||
@ -122,7 +114,7 @@ namespace demonware
|
||||
|
||||
if (this->load_publisher_resource(filename, data))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [bdStorage]: sending publisher file: %s, size: %lld\n", filename.data(), data.size());
|
||||
#endif
|
||||
|
||||
@ -143,10 +135,6 @@ namespace demonware
|
||||
|
||||
void bdStorage::set_user_file(service_server* server, byte_buffer* buffer) const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
utils::io::write_file("demonware/bdStorage/set_user_file", buffer->get_buffer());
|
||||
#endif
|
||||
|
||||
uint64_t owner;
|
||||
uint32_t numfiles;
|
||||
std::string game, platform;
|
||||
@ -183,7 +171,7 @@ namespace demonware
|
||||
info->filename = filename;
|
||||
info->data = data;
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [bdStorage]: set user file: %s\n", filename.data());
|
||||
#endif
|
||||
|
||||
@ -195,10 +183,6 @@ namespace demonware
|
||||
|
||||
void bdStorage::get_user_file(service_server* server, byte_buffer* buffer) const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
utils::io::write_file("demonware/bdStorage/get_user_file", buffer->get_buffer());
|
||||
#endif
|
||||
|
||||
uint32_t unk32_0;
|
||||
uint32_t numfiles, count = 0;
|
||||
uint64_t owner;
|
||||
@ -222,7 +206,7 @@ namespace demonware
|
||||
const auto path = get_user_file_path(filename);
|
||||
if (!utils::io::read_file(path, &data))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [bdStorage]: get user file: missing file: %s, %s, %s\n", game.data(), filename.data(), platform.data());
|
||||
#endif
|
||||
continue;
|
||||
@ -238,7 +222,7 @@ namespace demonware
|
||||
reply->add(response);
|
||||
++count;
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [bdStorage]: get user file: %s, %s, %s\n", game.data(), filename.data(), platform.data());
|
||||
#endif
|
||||
}
|
||||
@ -255,10 +239,6 @@ namespace demonware
|
||||
|
||||
void bdStorage::unk12(service_server* server, byte_buffer* buffer) const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
utils::io::write_file("demonware/bdStorage/unk12", buffer->get_buffer());
|
||||
#endif
|
||||
|
||||
// TODO:
|
||||
auto reply = server->create_reply(this->task_id());
|
||||
reply->send();
|
||||
|
@ -58,6 +58,10 @@
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
//#define DW_DEBUG
|
||||
#endif
|
||||
|
||||
#define MSG_BOX_INFO(message) MessageBoxA(nullptr, message, "H1-Mod: INFORMATION", MB_ICONINFORMATION);
|
||||
#define MSG_BOX_WARN(message) MessageBoxA(nullptr, message, "H1-Mod: WARNING", MB_ICONWARNING);
|
||||
#define MSG_BOX_ERROR(message) MessageBoxA(nullptr, message, "H1-Mod: ERROR", MB_ICONERROR);
|
||||
|
Loading…
Reference in New Issue
Block a user