From eec5c473f58c9e01b64d9af3ce54a7b08a8a442f Mon Sep 17 00:00:00 2001 From: yangzhi <@4F!xZpJwly&KbWq> Date: Sun, 13 Oct 2019 13:28:38 +0800 Subject: [PATCH] First version --- cwmods/IDA/types.h | 8 + cwmods/common/ByteRGBA.cpp | 15 ++ cwmods/common/ByteRGBA.h | 16 ++ cwmods/common/FloatRGBA.cpp | 8 + cwmods/common/FloatRGBA.h | 15 ++ cwmods/common/FloatVector3.cpp | 13 ++ cwmods/common/FloatVector3.h | 15 ++ cwmods/common/IntVector2.cpp | 6 + cwmods/common/IntVector2.h | 13 ++ cwmods/common/LongVector3.cpp | 13 ++ cwmods/common/LongVector3.h | 15 ++ cwmods/cube/ChatWidget.cpp | 19 ++ cwmods/cube/ChatWidget.h | 21 ++ cwmods/cube/Client.cpp | 6 + cwmods/cube/Client.h | 19 ++ cwmods/cube/Creature.cpp | 12 ++ cwmods/cube/Creature.h | 160 +++++++++++++++ cwmods/cube/Database.cpp | 1 + cwmods/cube/Database.h | 14 ++ cwmods/cube/Field.cpp | 1 + cwmods/cube/Field.h | 18 ++ cwmods/cube/GUI.cpp | 1 + cwmods/cube/GUI.h | 178 +++++++++++++++++ cwmods/cube/Game.cpp | 21 ++ cwmods/cube/Game.h | 80 ++++++++ cwmods/cube/Host.cpp | 1 + cwmods/cube/Host.h | 17 ++ cwmods/cube/Item.cpp | 9 + cwmods/cube/Item.h | 30 +++ cwmods/cube/ItemStack.cpp | 9 + cwmods/cube/ItemStack.h | 17 ++ cwmods/cube/Speech.cpp | 1 + cwmods/cube/Speech.h | 60 ++++++ cwmods/cube/Spirit.cpp | 1 + cwmods/cube/Spirit.h | 14 ++ cwmods/cube/SpriteManager.cpp | 1 + cwmods/cube/SpriteManager.h | 30 +++ cwmods/cube/World.cpp | 1 + cwmods/cube/World.h | 41 ++++ cwmods/cube/WorldMap.cpp | 1 + cwmods/cube/WorldMap.h | 76 ++++++++ cwmods/cube/Zone.cpp | 1 + cwmods/cube/Zone.h | 23 +++ cwmods/cube/constants.h | 4 + cwmods/cwmods.cpp | 60 ++++++ cwmods/cwmods.h | 71 +++++++ cwmods/gfx/Chunk.cpp | 1 + cwmods/gfx/Chunk.h | 12 ++ cwmods/gfx/D3D11Graphics.cpp | 1 + cwmods/gfx/D3D11Graphics.h | 15 ++ cwmods/gfx/D3D11Renderer.cpp | 1 + cwmods/gfx/D3D11Renderer.h | 14 ++ cwmods/msvc/allocator.cpp | 1 + cwmods/msvc/allocator.h | 51 +++++ cwmods/msvc/list.cpp | 1 + cwmods/msvc/list.h | 130 +++++++++++++ cwmods/msvc/string.cpp | 1 + cwmods/msvc/string.h | 19 ++ cwmods/msvc/vector.cpp | 1 + cwmods/msvc/vector.h | 209 ++++++++++++++++++++ cwmods/msvc/wstring.cpp | 23 +++ cwmods/msvc/wstring.h | 22 +++ cwmods/plasma/Array.cpp | 1 + cwmods/plasma/Array.h | 29 +++ cwmods/plasma/Attribute.cpp | 1 + cwmods/plasma/Attribute.h | 24 +++ cwmods/plasma/ContinuousAttribute.cpp | 1 + cwmods/plasma/ContinuousAttribute.h | 16 ++ cwmods/plasma/D3D11Engine.cpp | 1 + cwmods/plasma/D3D11Engine.h | 14 ++ cwmods/plasma/DiscreteAttribute.cpp | 1 + cwmods/plasma/DiscreteAttribute.h | 16 ++ cwmods/plasma/Display.cpp | 13 ++ cwmods/plasma/Display.h | 27 +++ cwmods/plasma/Engine.cpp | 1 + cwmods/plasma/Engine.h | 14 ++ cwmods/plasma/Keyable.cpp | 1 + cwmods/plasma/Keyable.h | 20 ++ cwmods/plasma/NamedObject.cpp | 1 + cwmods/plasma/NamedObject.h | 17 ++ cwmods/plasma/Node.cpp | 1 + cwmods/plasma/Node.h | 32 +++ cwmods/plasma/Object.cpp | 1 + cwmods/plasma/Object.h | 16 ++ cwmods/plasma/ObjectManager.cpp | 1 + cwmods/plasma/ObjectManager.h | 16 ++ cwmods/plasma/Vector.cpp | 1 + cwmods/plasma/Vector.h | 21 ++ cwmods/plasma/Widget.cpp | 1 + cwmods/plasma/Widget.h | 30 +++ logger.cpp | 270 ++++++++++++++++++++++++++ logger.h | 106 ++++++++++ main.cpp | 16 ++ main.h | 26 +++ 94 files changed, 2394 insertions(+) create mode 100644 cwmods/IDA/types.h create mode 100644 cwmods/common/ByteRGBA.cpp create mode 100644 cwmods/common/ByteRGBA.h create mode 100644 cwmods/common/FloatRGBA.cpp create mode 100644 cwmods/common/FloatRGBA.h create mode 100644 cwmods/common/FloatVector3.cpp create mode 100644 cwmods/common/FloatVector3.h create mode 100644 cwmods/common/IntVector2.cpp create mode 100644 cwmods/common/IntVector2.h create mode 100644 cwmods/common/LongVector3.cpp create mode 100644 cwmods/common/LongVector3.h create mode 100644 cwmods/cube/ChatWidget.cpp create mode 100644 cwmods/cube/ChatWidget.h create mode 100644 cwmods/cube/Client.cpp create mode 100644 cwmods/cube/Client.h create mode 100644 cwmods/cube/Creature.cpp create mode 100644 cwmods/cube/Creature.h create mode 100644 cwmods/cube/Database.cpp create mode 100644 cwmods/cube/Database.h create mode 100644 cwmods/cube/Field.cpp create mode 100644 cwmods/cube/Field.h create mode 100644 cwmods/cube/GUI.cpp create mode 100644 cwmods/cube/GUI.h create mode 100644 cwmods/cube/Game.cpp create mode 100644 cwmods/cube/Game.h create mode 100644 cwmods/cube/Host.cpp create mode 100644 cwmods/cube/Host.h create mode 100644 cwmods/cube/Item.cpp create mode 100644 cwmods/cube/Item.h create mode 100644 cwmods/cube/ItemStack.cpp create mode 100644 cwmods/cube/ItemStack.h create mode 100644 cwmods/cube/Speech.cpp create mode 100644 cwmods/cube/Speech.h create mode 100644 cwmods/cube/Spirit.cpp create mode 100644 cwmods/cube/Spirit.h create mode 100644 cwmods/cube/SpriteManager.cpp create mode 100644 cwmods/cube/SpriteManager.h create mode 100644 cwmods/cube/World.cpp create mode 100644 cwmods/cube/World.h create mode 100644 cwmods/cube/WorldMap.cpp create mode 100644 cwmods/cube/WorldMap.h create mode 100644 cwmods/cube/Zone.cpp create mode 100644 cwmods/cube/Zone.h create mode 100644 cwmods/cube/constants.h create mode 100644 cwmods/cwmods.cpp create mode 100644 cwmods/cwmods.h create mode 100644 cwmods/gfx/Chunk.cpp create mode 100644 cwmods/gfx/Chunk.h create mode 100644 cwmods/gfx/D3D11Graphics.cpp create mode 100644 cwmods/gfx/D3D11Graphics.h create mode 100644 cwmods/gfx/D3D11Renderer.cpp create mode 100644 cwmods/gfx/D3D11Renderer.h create mode 100644 cwmods/msvc/allocator.cpp create mode 100644 cwmods/msvc/allocator.h create mode 100644 cwmods/msvc/list.cpp create mode 100644 cwmods/msvc/list.h create mode 100644 cwmods/msvc/string.cpp create mode 100644 cwmods/msvc/string.h create mode 100644 cwmods/msvc/vector.cpp create mode 100644 cwmods/msvc/vector.h create mode 100644 cwmods/msvc/wstring.cpp create mode 100644 cwmods/msvc/wstring.h create mode 100644 cwmods/plasma/Array.cpp create mode 100644 cwmods/plasma/Array.h create mode 100644 cwmods/plasma/Attribute.cpp create mode 100644 cwmods/plasma/Attribute.h create mode 100644 cwmods/plasma/ContinuousAttribute.cpp create mode 100644 cwmods/plasma/ContinuousAttribute.h create mode 100644 cwmods/plasma/D3D11Engine.cpp create mode 100644 cwmods/plasma/D3D11Engine.h create mode 100644 cwmods/plasma/DiscreteAttribute.cpp create mode 100644 cwmods/plasma/DiscreteAttribute.h create mode 100644 cwmods/plasma/Display.cpp create mode 100644 cwmods/plasma/Display.h create mode 100644 cwmods/plasma/Engine.cpp create mode 100644 cwmods/plasma/Engine.h create mode 100644 cwmods/plasma/Keyable.cpp create mode 100644 cwmods/plasma/Keyable.h create mode 100644 cwmods/plasma/NamedObject.cpp create mode 100644 cwmods/plasma/NamedObject.h create mode 100644 cwmods/plasma/Node.cpp create mode 100644 cwmods/plasma/Node.h create mode 100644 cwmods/plasma/Object.cpp create mode 100644 cwmods/plasma/Object.h create mode 100644 cwmods/plasma/ObjectManager.cpp create mode 100644 cwmods/plasma/ObjectManager.h create mode 100644 cwmods/plasma/Vector.cpp create mode 100644 cwmods/plasma/Vector.h create mode 100644 cwmods/plasma/Widget.cpp create mode 100644 cwmods/plasma/Widget.h create mode 100644 logger.cpp create mode 100644 logger.h create mode 100644 main.cpp create mode 100644 main.h diff --git a/cwmods/IDA/types.h b/cwmods/IDA/types.h new file mode 100644 index 0000000..855a784 --- /dev/null +++ b/cwmods/IDA/types.h @@ -0,0 +1,8 @@ +#ifndef IDA_CONSTANTS_H +#define IDA_CONSTANTS_H + +#define _BYTE unsigned char +#define __int64 long long int +#define __int16 short + +#endif diff --git a/cwmods/common/ByteRGBA.cpp b/cwmods/common/ByteRGBA.cpp new file mode 100644 index 0000000..82bc32d --- /dev/null +++ b/cwmods/common/ByteRGBA.cpp @@ -0,0 +1,15 @@ +#include "ByteRGBA.h" + +ByteRGBA::ByteRGBA(){ + this->red = 255; + this->green = 255; + this->blue = 255; + this->alpha = 255; +} + +ByteRGBA::ByteRGBA(char red, char green, char blue, char alpha){ + this->red = red; + this->green = green; + this->blue = blue; + this->alpha = alpha; +} diff --git a/cwmods/common/ByteRGBA.h b/cwmods/common/ByteRGBA.h new file mode 100644 index 0000000..25e729c --- /dev/null +++ b/cwmods/common/ByteRGBA.h @@ -0,0 +1,16 @@ +#ifndef BYTERGBA_H +#define BYTERGBA_H + + +class ByteRGBA { + public: + char red; + char green; + char blue; + char alpha; + ByteRGBA(); + ByteRGBA(char red, char green, char blue, char alpha); + }; + + +#endif // BYTERGBA_H diff --git a/cwmods/common/FloatRGBA.cpp b/cwmods/common/FloatRGBA.cpp new file mode 100644 index 0000000..463f1fa --- /dev/null +++ b/cwmods/common/FloatRGBA.cpp @@ -0,0 +1,8 @@ +#include "FloatRGBA.h" + +FloatRGBA::FloatRGBA(float red, float green, float blue, float alpha){ + this->red = red; + this->green = green; + this->blue = blue; + this->alpha = alpha; +} diff --git a/cwmods/common/FloatRGBA.h b/cwmods/common/FloatRGBA.h new file mode 100644 index 0000000..fe098b1 --- /dev/null +++ b/cwmods/common/FloatRGBA.h @@ -0,0 +1,15 @@ +#ifndef FLOATRGBA_H +#define FLOATRGBA_H + + +class FloatRGBA { + public: + float red; + float green; + float blue; + float alpha; + FloatRGBA(float red, float green, float blue, float alpha); + }; + + +#endif // FLOATRGBA_H diff --git a/cwmods/common/FloatVector3.cpp b/cwmods/common/FloatVector3.cpp new file mode 100644 index 0000000..9116baa --- /dev/null +++ b/cwmods/common/FloatVector3.cpp @@ -0,0 +1,13 @@ +#include "FloatVector3.h" + +FloatVector3::FloatVector3(){ + this->x = 0.0; + this->y = 0.0; + this->z = 0.0; +} + +FloatVector3::FloatVector3(float x, float y, float z){ + this->x = x; + this->y = y; + this->z = z; +} diff --git a/cwmods/common/FloatVector3.h b/cwmods/common/FloatVector3.h new file mode 100644 index 0000000..9f6079e --- /dev/null +++ b/cwmods/common/FloatVector3.h @@ -0,0 +1,15 @@ +#ifndef FLOATVECTOR3_H +#define FLOATVECTOR3_H + + +class FloatVector3 { + public: + float x; + float y; + float z; + FloatVector3(); + FloatVector3(float x, float y, float z); + }; + + +#endif // FLOATVECTOR3_H diff --git a/cwmods/common/IntVector2.cpp b/cwmods/common/IntVector2.cpp new file mode 100644 index 0000000..f1a2e56 --- /dev/null +++ b/cwmods/common/IntVector2.cpp @@ -0,0 +1,6 @@ +#include "IntVector2.h" + +IntVector2::IntVector2(int x, int y){ + this->x = x; + this->y = y; +} diff --git a/cwmods/common/IntVector2.h b/cwmods/common/IntVector2.h new file mode 100644 index 0000000..54d1efb --- /dev/null +++ b/cwmods/common/IntVector2.h @@ -0,0 +1,13 @@ +#ifndef INTVECTOR2_H +#define INTVECTOR2_H + + +class IntVector2 { + public: + int x; + int y; + IntVector2(int x, int y); + }; + + +#endif // INTVECTOR2_H diff --git a/cwmods/common/LongVector3.cpp b/cwmods/common/LongVector3.cpp new file mode 100644 index 0000000..6a7ee7c --- /dev/null +++ b/cwmods/common/LongVector3.cpp @@ -0,0 +1,13 @@ +#include "LongVector3.h" + +LongVector3::LongVector3(){ + this->x = 0; + this->y = 0; + this->z = 0; +} + +LongVector3::LongVector3(long long x, long long y, long long z){ + this->x = x; + this->y = y; + this->z = z; +} diff --git a/cwmods/common/LongVector3.h b/cwmods/common/LongVector3.h new file mode 100644 index 0000000..5e0b923 --- /dev/null +++ b/cwmods/common/LongVector3.h @@ -0,0 +1,15 @@ +#ifndef LONGVECTOR3_H +#define LONGVECTOR3_H + + +class LongVector3 { + public: + long long x; + long long y; + long long z; + LongVector3(); + LongVector3(long long x, long long y, long long z); + }; + + +#endif // LONGVECTOR3_H diff --git a/cwmods/cube/ChatWidget.cpp b/cwmods/cube/ChatWidget.cpp new file mode 100644 index 0000000..c89ec80 --- /dev/null +++ b/cwmods/cube/ChatWidget.cpp @@ -0,0 +1,19 @@ +#include "ChatWidget.h" +#include "../cwmods.h" + +void cube::ChatWidget::PrintMessage(const wchar_t* message, FloatRGBA* color){ + msvc::wstring str(message); + ((void(*)(cube::ChatWidget*, msvc::wstring*, FloatRGBA*))CWBase()+0x26BF10)(this, &str, color); +} + +void cube::ChatWidget::PrintMessage(const wchar_t* message) { + this->PrintMessage(message, 255, 255, 255); +} + +void cube::ChatWidget::PrintMessage(const wchar_t* message, char red, char green, char blue){ + float f_red = (float)red / 255.0; + float f_green = (float)green / 255.0; + float f_blue = (float)blue / 255.0; + FloatRGBA color(f_red, f_green, f_blue, 1.0); + this->PrintMessage(message, &color); +} diff --git a/cwmods/cube/ChatWidget.h b/cwmods/cube/ChatWidget.h new file mode 100644 index 0000000..d85e309 --- /dev/null +++ b/cwmods/cube/ChatWidget.h @@ -0,0 +1,21 @@ +#ifndef CHATWIDGET_H +#define CHATWIDGET_H +#include "../common/FloatRGBA.h" +#include "../msvc/wstring.h" +#include "../plasma/Widget.h" +namespace cube { +class ChatWidget : public plasma::Widget { + public: + _BYTE gap1A8[24]; + msvc::wstring typebox_text; + _BYTE gap1E0[15]; + char end; + + + void PrintMessage(const wchar_t* message, FloatRGBA* color); + void PrintMessage(const wchar_t* message); + void PrintMessage(const wchar_t* message, char red, char green, char blue); + }; +} + +#endif // CHATWIDGET_H diff --git a/cwmods/cube/Client.cpp b/cwmods/cube/Client.cpp new file mode 100644 index 0000000..4695682 --- /dev/null +++ b/cwmods/cube/Client.cpp @@ -0,0 +1,6 @@ +#include "Client.h" +#include "../cwmods.h" + +void cube::Client::JoinSteamID(long long steamID) { + ((void(*)(cube::Client*, long long))CWBase()+0x3D820)(this, steamID); +} diff --git a/cwmods/cube/Client.h b/cwmods/cube/Client.h new file mode 100644 index 0000000..2b7745d --- /dev/null +++ b/cwmods/cube/Client.h @@ -0,0 +1,19 @@ +#ifndef CLIENT_H +#define CLIENT_H + +#include "../IDA/types.h" +#include + +namespace cube { + class Client { + public: + void *vtable; + char field_8[2576]; + CRITICAL_SECTION critical_section; + char field_A40[24]; + + void JoinSteamID(long long steamID); + }; +} + +#endif // CLIENT_H diff --git a/cwmods/cube/Creature.cpp b/cwmods/cube/Creature.cpp new file mode 100644 index 0000000..3d7776d --- /dev/null +++ b/cwmods/cube/Creature.cpp @@ -0,0 +1,12 @@ +#include "Creature.h" +#include "../cwmods.h" + +cube::Creature* cube::Creature::Create(__int64 id) { + cube::Creature* newCreature = (cube::Creature*)new char[sizeof(cube::Creature)]; + newCreature->ctor(&id); + return newCreature; +} + +cube::Creature* cube::Creature::ctor(__int64* id) { + return ((cube::Creature*(*)(cube::Creature*, __int64*))CWBase()+0x4CE80)(this, id); +} diff --git a/cwmods/cube/Creature.h b/cwmods/cube/Creature.h new file mode 100644 index 0000000..f69e04c --- /dev/null +++ b/cwmods/cube/Creature.h @@ -0,0 +1,160 @@ +#ifndef CREATURE_H +#define CREATURE_H + +#include "../IDA/types.h" +#include "../common/IntVector2.h" +#include "../common/LongVector3.h" +#include "../common/FloatVector3.h" +#include "../common/ByteRGBA.h" +#include "../msvc/vector.h" +#include "ItemStack.h" + +namespace cube { + class Creature { + + // cube::Creature::EntityData + class EntityData { + + // cube::Creature::EntityData::Appearance + class Appearance { + public: + __int16 field_78; + ByteRGBA hair_color; + char padding_7E; + char padding_7F; + unsigned int flags2; + float graphics_scale; + float hitbox_scale; + float physics_scale; + __int16 head_model; + __int16 hair_model; + __int16 hands_model; + __int16 feet_model; + __int16 chest_model; + __int16 tail_model; + __int16 shoulder_model; + __int16 wings_model; + float head_scale; + float chest_scale; + float hands_scale; + float feet_scale; + float unknown_scale; + float weapon_scale; + float tail_scale; + float shoulder_scale; + float wing_scale; + float chest_rotation; + FloatVector3 hands_rotation; + float feet_rotation; + float wings_rotation; + float unknown_rotation; + FloatVector3 chest_position; + FloatVector3 head_position; + FloatVector3 hands_position; + FloatVector3 feet_position; + FloatVector3 unknown_position; + FloatVector3 wings_position; + }; + + + public: + LongVector3 position; + float pitch; + float roll; + float yaw; + FloatVector3 velocity; + FloatVector3 acceleration; + FloatVector3 retreat; + float head_rotation; + unsigned int flags; + char hostility_type; + char field_51; + char field_52; + char field_53; + int race; + BYTE current_ability; + char field_59; + char field_5A; + char field_5B; + float time_since_ability; + int hit_combo; + float time_since_hit; + cube::Creature::EntityData::Appearance appearance; + __int16 binary_toggles; + char field_11A; + char field_11B; + float roll_time; + float stun_time; + float unknown_time; + float slowed_time; + float sprint_time; + int field_130; + unsigned int level; + int XP; + unsigned __int8 classType; + char specialization; + char char_13E; + char char_13F; + IntVector2 current_region; + char charge; + _BYTE gap149[27]; + FloatVector3 attack_rotation; + float HP; + float block_power; + float MP; + float stealth; + float float_180; + float speed; + float light_radius; + _BYTE gap18C[60]; + cube::Item last_special_item; + cube::Item head; + cube::Item amulet; + cube::Item chest_armor; + cube::Item feet_armor; + cube::Item hands_armor; + cube::Item shoulder_armor; + cube::Item left_weapon; + cube::Item right_weapon; + cube::Item left_ring; + cube::Item right_ring; + cube::Item pet; + char name[16]; + __int64 field_958; + char field_960; + char field_961; + char field_962; + char field_963; + int field_964; + __int64 field_968; + }; + + + + + + public: + void *vtable; + __int64 id; + cube::Creature::EntityData entity_data; + _BYTE gap968[112]; + msvc::vector> inventory_tabs; + _BYTE gapA08[164]; + int gold; + _BYTE gapAB0[172]; + int climbing_speed; + int swimming_speed; + int diving_skill; + int riding_speed; + int hang_gliding_speed; + int sailing_speed; + int lamp_diameter; + _BYTE gapB78[2687]; + char end; + + static cube::Creature* Create(__int64 id); + cube::Creature* ctor(__int64* id); + }; +} + +#endif // CREATURE_H diff --git a/cwmods/cube/Database.cpp b/cwmods/cube/Database.cpp new file mode 100644 index 0000000..1d31ebb --- /dev/null +++ b/cwmods/cube/Database.cpp @@ -0,0 +1 @@ +#include "Database.h" diff --git a/cwmods/cube/Database.h b/cwmods/cube/Database.h new file mode 100644 index 0000000..54d1812 --- /dev/null +++ b/cwmods/cube/Database.h @@ -0,0 +1,14 @@ +#ifndef DATABASE_H +#define DATABASE_H + +#include "../IDA/types.h" + +namespace cube { + class Database { + public: + void *vtable; + __int64 field_8; + }; +} + +#endif // DATABASE_H diff --git a/cwmods/cube/Field.cpp b/cwmods/cube/Field.cpp new file mode 100644 index 0000000..63ab0c3 --- /dev/null +++ b/cwmods/cube/Field.cpp @@ -0,0 +1 @@ +#include "Field.h" diff --git a/cwmods/cube/Field.h b/cwmods/cube/Field.h new file mode 100644 index 0000000..29d7612 --- /dev/null +++ b/cwmods/cube/Field.h @@ -0,0 +1,18 @@ +#ifndef FIELD_H +#define FIELD_H + +#include "../IDA/types.h" + +namespace cube { +class Field { + public: + void *vtable; + _BYTE gap8[52]; + int base_z; + __int64 field_40; + __int64 field_48; + __int64 field_50; + }; +} + +#endif // FIELD_H diff --git a/cwmods/cube/GUI.cpp b/cwmods/cube/GUI.cpp new file mode 100644 index 0000000..0b7334a --- /dev/null +++ b/cwmods/cube/GUI.cpp @@ -0,0 +1 @@ +#include "GUI.h" diff --git a/cwmods/cube/GUI.h b/cwmods/cube/GUI.h new file mode 100644 index 0000000..0461d0b --- /dev/null +++ b/cwmods/cube/GUI.h @@ -0,0 +1,178 @@ +#ifndef CUBE_GUI_H +#define CUBE_GUI_H + +#include "../IDA/types.h" +#include "../plasma/Node.h" +#include "ChatWidget.h" + +namespace cube { + class Game; + class GUI { + public: + plasma::Node *startmenu_node; + plasma::Node *startmenu_buttons_node; + void *start_menu_widget; + plasma::Node *character_selection_node; + _BYTE gap20[24]; + plasma::Node *button2_node; + plasma::Node *smallbutton_node; + plasma::Node *button_node; + _BYTE gap50[8]; + plasma::Node *character_creation_node; + void *character_style_widget; + plasma::Node *blackwidget_node; + plasma::Node *button_node_1; + plasma::Node *charactername_node; + plasma::Node *plasma_node_10; + _BYTE gap88[56]; + plasma::Node *button_node_2; + plasma::Node *button2_node_1; + plasma::Node *smallbutton_node_1; + plasma::Node *button_node_3; + _BYTE gapE0[8]; + plasma::Node *plasma_node_15; + plasma::Node *button_node_4; + plasma::Node *worldseed_node; + plasma::Node *worldname_node; + plasma::Node *plasma_node_19; + _BYTE gap110[48]; + plasma::Node *playername_node; + plasma::Node *plasma_node_21; + plasma::Node *hpbar_node; + plasma::Node *bar_node; + plasma::Node *mpbar_node; + plasma::Node *bar_node_1; + plasma::Node *experiencebar_node; + plasma::Node *xpbar_node; + plasma::Node *chargebar_node; + plasma::Node *castbar_node; + plasma::Node *bar_node_2; + plasma::Node *staminabar_node; + plasma::Node *bar_node_3; + plasma::Node *plasma_node_33; + plasma::Node *info_node_0; + plasma::Node *info_node_1; + plasma::Node *info_node_2; + plasma::Node *location_node; + plasma::Node *levelinfo_node; + plasma::Node *crosshair_node; + plasma::Node *zoomcrosshair_node; + plasma::Node *lockedtarget_node; + plasma::Node *highlightedtarget_node; + plasma::Node *selector_node; + plasma::Node *gold_node; + plasma::Node *plasma_node_45; + plasma::Node *combopoints_node; + void *inventory_widget_0; + void *character_widget; + void *inventory_widget_1; + void *formula_details_widget; + void *inventory_widget_2; + void *stystem_widget; + void *enchant_widget; + void *voxel_widget; + void *adaption_widget; + void *question_widget; + void *map_overlay_widget; + void *multiplayer_widget; + void *help_widget; + cube::ChatWidget *chat_widget; + plasma::Node *recentlands_node; + plasma::Node *leftbutton_node; + plasma::Node *rightbutton_node; + plasma::Node *missiontag_white_node; + void *preview_widget; + _BYTE gap2B0[24]; + void *sprite_widget_0; + void *sprite_widget_1; + void *sprite_widget_2; + void *sprite_widget_3; + _BYTE gap2E8[24]; + void *speech_widget; + __int64 field_308; + plasma::Node *blackwidget_node_0; + plasma::Node *speech_node; + plasma::Node *tab_node; + plasma::Node *plasma_node_54; + plasma::Node *plasma_node_55; + plasma::Node *wait_node; + plasma::Node *button_node_5; + plasma::Node *enemy_node; + plasma::Node *monster_node; + plasma::Node *crystal_node; + plasma::Node *brazier_node; + plasma::Node *manapump_node; + plasma::Node *npc_node; + plasma::Node *static_node; + plasma::Node *object_node; + plasma::Node *star_node; + plasma::Node *cross_node; + plasma::Node *flight_point_node; + plasma::Node *unknown_flight_point_node; + plasma::Node *home_node; + plasma::Node *mapposition_node; + plasma::Node *direction_node; + plasma::Node *armor_shop_node; + plasma::Node *weapon_shop_node; + plasma::Node *item_shop_node; + plasma::Node *identifier_node; + plasma::Node *smithy_node; + plasma::Node *carpenters_shop_node; + plasma::Node *tailors_shop_node; + plasma::Node *inn_node; + plasma::Node *shrine_node; + plasma::Node *spirit_node; + plasma::Node *bell_node; + plasma::Node *harp_node; + plasma::Node *whistle_node; + plasma::Node *solved_node; + plasma::Node *gnome_node; + plasma::Node *hangglider_node; + plasma::Node *boat_node; + plasma::Node *climbingspikes_node; + plasma::Node *reins_node; + plasma::Node *destination_node; + plasma::Node *crafting1_node; + plasma::Node *crafting2_node; + plasma::Node *crafting3_node; + plasma::Node *crafting4_node; + plasma::Node *flight_master_node; + plasma::Node *guild_hall_node; + plasma::Node *flower_node; + plasma::Node *key_node; + plasma::Node *treasure_node; + plasma::Node *witch_node; + plasma::Node *demonportal_node; + char pad_04B8[32]; + plasma::Node *weaponrarity0_node; + plasma::Node *weaponrarity1_node; + plasma::Node *weaponrarity2_node; + plasma::Node *weaponrarity3_node; + plasma::Node *weaponrarity4_node; + plasma::Node *weaponrarity5_node; + plasma::Node *armorrarity0_node; + plasma::Node *armorrarity1_node; + plasma::Node *armorrarity2_node; + plasma::Node *armorrarity3_node; + plasma::Node *armorrarity4_node; + plasma::Node *armorrarity5_node; + void *options_widget; + void *controls_widget; + _BYTE gap548[16]; + plasma::Node *textFX_node; + plasma::Node *lifebars_node; + plasma::Node *enemylifebar_small_node; + plasma::Node *friendlifebar_small_node; + plasma::Node *staticlifebar_small_node; + plasma::Node *neutrallifebar_small_node; + plasma::Node *enemylifebar_node; + plasma::Node *friendlifebar_node; + plasma::Node *staticlifebar_node; + plasma::Node *neutrallifebar_node; + _BYTE gap5A8[24]; + cube::Game *game; + char pad_05C8[8]; + }; +} + +#endif // CUBE_GUI_H diff --git a/cwmods/cube/Game.cpp b/cwmods/cube/Game.cpp new file mode 100644 index 0000000..19f936b --- /dev/null +++ b/cwmods/cube/Game.cpp @@ -0,0 +1,21 @@ +#include "Game.h" +#include "../cwmods.h" + + +cube::Creature* cube::Game::GetPlayer(){ + return this->world->local_creature; +} + +cube::Game* cube::GetGame() { + return *(cube::Game**)(CWBase() + 0x551A80); +} + +void cube::Game::PrintMessage(const wchar_t* message, FloatRGBA* color) { + this->gui.chat_widget->PrintMessage(message, color); +} +void cube::Game::PrintMessage(const wchar_t* message) { + this->gui.chat_widget->PrintMessage(message); +} +void cube::Game::PrintMessage(const wchar_t* message, char red, char green, char blue) { + this->gui.chat_widget->PrintMessage(message, red, green, blue); +} diff --git a/cwmods/cube/Game.h b/cwmods/cube/Game.h new file mode 100644 index 0000000..ec41b31 --- /dev/null +++ b/cwmods/cube/Game.h @@ -0,0 +1,80 @@ +#ifndef GAME_H +#define GAME_H + +#include "../IDA/types.h" + +#include "Speech.h" +#include "World.h" +#include "Host.h" +#include "ChatWidget.h" +#include "WorldMap.h" +#include "../gfx/D3D11Renderer.h" +#include "Creature.h" +#include "Client.h" +#include "Database.h" + +#include "GUI.h" + +namespace cube { + class Game { + public: + class CCallbackInternal_onP2PSessionRequest { + public: + void *vtable; + __int64 field_8; + }; + void *vtable; + cube::World *world; + cube::WorldMap *worldmap; + gfx::D3D11Renderer *renderer; + __int64 plasma_engine; + __int64 xaudio2_engine; + _BYTE gap30[32]; + cube::Speech speech; + cube::GUI gui; + cube::Host host; + cube::Client client; + _BYTE gap1770[512]; + char gap1960[536]; + int fullscreen; + int width; + int height; + int refresh_rate; + int field_1B88; + int render_distance; + int cpu_performance; + int sound_fx_volume; + int music_volume; + int camera_speed; + int camera_smoothness; + int invert_y_axis; + int language; + int min_timestep; + int field_1BB0; + int field_1BB4; + int rarity_coding; + _BYTE gap1BCC[204]; + CRITICAL_SECTION critical_section_0; + CRITICAL_SECTION critical_section_1; + CRITICAL_SECTION critical_section_2; + CRITICAL_SECTION critical_section_3; + CRITICAL_SECTION critical_section_4; + _BYTE gap1D60[712]; + msvc::string *current_music_file; + _BYTE gap2010[60]; + int seed; + msvc::string world_name; + __int16 gap2070; + _BYTE gap2092[470]; + cube::Database database_0; + cube::Database database_1; + + cube::Creature* GetPlayer(); + void PrintMessage(const wchar_t* message, FloatRGBA* color); + void PrintMessage(const wchar_t* message); + void PrintMessage(const wchar_t* message, char red, char green, char blue); + }; + Game* GetGame(); +} + +#endif // GAME_H diff --git a/cwmods/cube/Host.cpp b/cwmods/cube/Host.cpp new file mode 100644 index 0000000..dcdc9c8 --- /dev/null +++ b/cwmods/cube/Host.cpp @@ -0,0 +1 @@ +#include "Host.h" diff --git a/cwmods/cube/Host.h b/cwmods/cube/Host.h new file mode 100644 index 0000000..34c418f --- /dev/null +++ b/cwmods/cube/Host.h @@ -0,0 +1,17 @@ +#ifndef HOST_H +#define HOST_H + +#include "../msvc/string.h" +#include "World.h" +namespace cube { +class Host { + public: + void *vtable; + cube::World world; + _BYTE gap550[144]; + CRITICAL_SECTION critical_section_0; + CRITICAL_SECTION critical_section_1; + }; +} + +#endif // HOST_H diff --git a/cwmods/cube/Item.cpp b/cwmods/cube/Item.cpp new file mode 100644 index 0000000..8d82bf6 --- /dev/null +++ b/cwmods/cube/Item.cpp @@ -0,0 +1,9 @@ +#include "Item.h" + + +cube::Item::Item(){ +} +cube::Item::Item(char category, int id) { + this->category = category; + this->id = id; +} diff --git a/cwmods/cube/Item.h b/cwmods/cube/Item.h new file mode 100644 index 0000000..5bec7e4 --- /dev/null +++ b/cwmods/cube/Item.h @@ -0,0 +1,30 @@ +#ifndef ITEM_H +#define ITEM_H + +#include "Spirit.h" + +namespace cube { +class Item { + public: + char category; + char field_1; + char field_2; + char field_3; + int id; + unsigned int modifier; + int region; + int field_10; + char rarity; + int field_18; + char material; + cube::Spirit spirits[32]; + char num_spirits; + char field_9E; + char field_9F; + + Item(); + Item(char category, int id); + }; +} + +#endif // ITEM_H diff --git a/cwmods/cube/ItemStack.cpp b/cwmods/cube/ItemStack.cpp new file mode 100644 index 0000000..dc718ae --- /dev/null +++ b/cwmods/cube/ItemStack.cpp @@ -0,0 +1,9 @@ +#include "ItemStack.h" +#include "Item.h" + +cube::ItemStack::ItemStack() { +} +cube::ItemStack::ItemStack(int quantity, cube::Item item) { + this->quantity = quantity; + this->item = item; +} diff --git a/cwmods/cube/ItemStack.h b/cwmods/cube/ItemStack.h new file mode 100644 index 0000000..b1f0066 --- /dev/null +++ b/cwmods/cube/ItemStack.h @@ -0,0 +1,17 @@ +#ifndef ITEMSTACK_H +#define ITEMSTACK_H + +#include "Item.h" + +namespace cube { +class ItemStack { + public: + int quantity; + cube::Item item; + + ItemStack(); + ItemStack(int quantity, cube::Item item); + }; +} + +#endif // ITEMSTACK_H diff --git a/cwmods/cube/Speech.cpp b/cwmods/cube/Speech.cpp new file mode 100644 index 0000000..80271f3 --- /dev/null +++ b/cwmods/cube/Speech.cpp @@ -0,0 +1 @@ +#include "Speech.h" diff --git a/cwmods/cube/Speech.h b/cwmods/cube/Speech.h new file mode 100644 index 0000000..05f1b93 --- /dev/null +++ b/cwmods/cube/Speech.h @@ -0,0 +1,60 @@ +#ifndef SPEECH_H +#define SPEECH_H +#include "../IDA/types.h" + +namespace cube { +class Speech { + public: + int field_0; + int field_4; + int field_8; + int field_C; + int field_10; + int field_14; + int field_18; + int field_1C; + int field_20; + int field_24; + int field_28; + int field_2C; + int field_30; + int field_34; + int field_38; + int field_3C; + int field_40; + int field_44; + int field_48; + int field_4C; + int field_50; + int field_54; + int field_58; + int field_5C; + int field_60; + int field_64; + int field_68; + int field_6C; + int field_70; + int field_74; + int field_78; + int field_7C; + int field_80; + int field_84; + __int64 field_88; + int field_90; + int field_94; + int field_98; + int field_9C; + int field_A0; + int field_A4; + int field_A8; + int field_AC; + int field_B0; + int field_B4; + int field_B8; + int field_BC; + int field_C0; + int field_C4; + }; +} + +#endif // SPEECH_H diff --git a/cwmods/cube/Spirit.cpp b/cwmods/cube/Spirit.cpp new file mode 100644 index 0000000..e3bea50 --- /dev/null +++ b/cwmods/cube/Spirit.cpp @@ -0,0 +1 @@ +#include "Spirit.h" diff --git a/cwmods/cube/Spirit.h b/cwmods/cube/Spirit.h new file mode 100644 index 0000000..16f5a0b --- /dev/null +++ b/cwmods/cube/Spirit.h @@ -0,0 +1,14 @@ +#ifndef SPIRIT_H +#define SPIRIT_H + +namespace cube { +class Spirit { + public: + char x; + char y; + char z; + char material; + }; +} + +#endif // SPIRIT_H diff --git a/cwmods/cube/SpriteManager.cpp b/cwmods/cube/SpriteManager.cpp new file mode 100644 index 0000000..0e2efe3 --- /dev/null +++ b/cwmods/cube/SpriteManager.cpp @@ -0,0 +1 @@ +#include "SpriteManager.h" diff --git a/cwmods/cube/SpriteManager.h b/cwmods/cube/SpriteManager.h new file mode 100644 index 0000000..342d210 --- /dev/null +++ b/cwmods/cube/SpriteManager.h @@ -0,0 +1,30 @@ +#ifndef SPRITEMANAGER_H +#define SPRITEMANAGER_H + +#include "../IDA/types.h" +#include +#include "../gfx/D3D11Graphics.h" + +namespace cube { + class SpriteManager { + public: + void *vtable; + gfx::D3D11Graphics *graphics; + void *sprite_map; + __int64 field_18; + __int64 field_20; + __int64 field_28; + __int64 field_30; + __int64 field_38; + __int64 field_40; + __int64 field_48; + __int64 field_50; + __int64 field_58; + __int64 field_60; + __int64 field_68; + __int64 field_70; + __int64 field_78; + }; +} + +#endif // SPRITEMANAGER_H diff --git a/cwmods/cube/World.cpp b/cwmods/cube/World.cpp new file mode 100644 index 0000000..a6413f1 --- /dev/null +++ b/cwmods/cube/World.cpp @@ -0,0 +1 @@ +#include "World.h" diff --git a/cwmods/cube/World.h b/cwmods/cube/World.h new file mode 100644 index 0000000..713aaed --- /dev/null +++ b/cwmods/cube/World.h @@ -0,0 +1,41 @@ +#ifndef WORLD_H +#define WORLD_H + +#include "../msvc/string.h" +#include "Creature.h" +#include "Database.h" +#include +#include "../IDA/types.h" +#include "../msvc/list.h" +#include "SpriteManager.h" + +namespace cube { +class World { + public: + void *vtable; + int day; + float time; + _BYTE gap10[48]; + msvc::list creatures; + _BYTE gap50[32]; + cube::SpriteManager *spritemanager; + _BYTE gap78[312]; + cube::World *self_ptr; + _BYTE gap1A8[72]; + msvc::string world_name; + int seed; + _BYTE gap224[404]; + cube::Database database; + CRITICAL_SECTION critical_section_0; + CRITICAL_SECTION critical_section_1; + CRITICAL_SECTION critical_section_2; + _BYTE gap440[8]; + cube::Creature *local_creature; + _BYTE gap450[16]; + BYTE zone_list[24]; + _BYTE gap478[207]; + char end; + }; +} + +#endif // WORLD_H diff --git a/cwmods/cube/WorldMap.cpp b/cwmods/cube/WorldMap.cpp new file mode 100644 index 0000000..b739e0a --- /dev/null +++ b/cwmods/cube/WorldMap.cpp @@ -0,0 +1 @@ +#include "WorldMap.h" diff --git a/cwmods/cube/WorldMap.h b/cwmods/cube/WorldMap.h new file mode 100644 index 0000000..3143ad2 --- /dev/null +++ b/cwmods/cube/WorldMap.h @@ -0,0 +1,76 @@ +#ifndef WORLDMAP_H +#define WORLDMAP_H + +#include "../IDA/types.h" +#include +#include "World.h" +#include "../common/LongVector3.h" +#include "../plasma/D3D11Engine.h" + +namespace cube { +class WorldMap { + public: + void *vtable; + cube::World *world; + plasma::D3D11Engine *d3d11engine; + __int64 field_18; + __int64 field_20; + __int64 field_28; + __int64 field_30; + __int64 field_38; + __int64 field_40; + __int64 field_48; + __int64 field_50; + FloatVector3 rotation; + int field_64; + __int64 field_68; + __int64 field_70; + __int64 field_78; + __int64 field_80; + __int64 field_88; + __int64 field_90; + __int64 field_98; + __int64 field_A0; + __int64 field_A8; + __int64 field_B0; + __int64 field_B8; + __int64 field_C0; + int field_C8; + _BYTE gapCC[52]; + LongVector3 cursor_position; + __int64 field_118; + __int64 field_120; + __int64 field_128; + __int64 field_130; + __int64 field_138; + __int64 field_140; + __int64 field_148; + int field_150; + int field_154; + int field_158; + int field_15C; + int field_160; + char field_164; + char field_165; + char field_166; + char field_167; + char field_168; + char field_169; + char field_16A; + char field_16B; + char field_16C; + char field_16D; + char field_16E; + char field_16F; + __int64 field_170; + __int64 field_178; + __int64 field_180; + __int64 field_188; + __int64 field_190; + __int64 field_198; + CRITICAL_SECTION critical_section_0; + CRITICAL_SECTION critical_section_1; + }; +} + +#endif // WORLDMAP_H diff --git a/cwmods/cube/Zone.cpp b/cwmods/cube/Zone.cpp new file mode 100644 index 0000000..f1b6a2f --- /dev/null +++ b/cwmods/cube/Zone.cpp @@ -0,0 +1 @@ +#include "Zone.h" diff --git a/cwmods/cube/Zone.h b/cwmods/cube/Zone.h new file mode 100644 index 0000000..8e3364b --- /dev/null +++ b/cwmods/cube/Zone.h @@ -0,0 +1,23 @@ +#ifndef ZONE_H +#define ZONE_H + +#include "../IDA/types.h" +#include "World.h" +#include "Field.h" +#include "../gfx/Chunk.h" + +namespace cube { +class Zone { + public: + void *vtable; + cube::World *world; + int x; + int y; + _BYTE gap18[424]; + gfx::Chunk chunk; + _BYTE gap448[208]; + cube::Field fields[4096]; + }; +} + +#endif // ZONE_H diff --git a/cwmods/cube/constants.h b/cwmods/cube/constants.h new file mode 100644 index 0000000..3fa826d --- /dev/null +++ b/cwmods/cube/constants.h @@ -0,0 +1,4 @@ +namespace cube { + const int DOTS_PER_BLOCK = 65536; + const int BLOCKS_PER_MAP_CHUNK = 20; +} diff --git a/cwmods/cwmods.cpp b/cwmods/cwmods.cpp new file mode 100644 index 0000000..b806531 --- /dev/null +++ b/cwmods/cwmods.cpp @@ -0,0 +1,60 @@ +#define MOD_MAJOR_VERSION 4 +#define MOD_MINOR_VERSION 1 + +#include "cwmods.h" +#include + +void* moduleBase; + +void* CWBase(){ + return moduleBase; +} + +EXPORT void ModPreInitialize(){ + moduleBase = GetModuleHandle(NULL); +} + +EXPORT int ModMajorVersion(){ + return MOD_MAJOR_VERSION; +} + +EXPORT int ModMinorVersion(){ + return MOD_MINOR_VERSION; +} + +void WriteByte(void* location, char val){ + DWORD dwOldProtection; + VirtualProtect(location, 1, PAGE_EXECUTE_READWRITE, &dwOldProtection); + *(char*)location = val; + VirtualProtect(location, 1, dwOldProtection, &dwOldProtection); +} + +void WriteFarJMP(void* source, void* destination) { + DWORD dwOldProtection; + VirtualProtect(source, 14, PAGE_EXECUTE_READWRITE, &dwOldProtection); + char* location = (char*)source; + + // Far jump + *((UINT16*)&location[0]) = 0x25FF; + + // mode + *((UINT32*)&location[2]) = 0x00000000; + + *((UINT64*)&location[6]) = (UINT64)destination; + + VirtualProtect(location, 14, dwOldProtection, &dwOldProtection); +} + +__declspec(noinline) void* operator new(size_t size) { + return ((void*(*)(size_t))CWBase()+0x392BAC)(size); +} +__declspec(noinline) void* operator new[](size_t size) { + return ((void*(*)(size_t))CWBase()+0x392BAC)(size); +} + +__declspec(noinline) void operator delete(void* ptr) noexcept { + ((void(*)(void*))CWBase()+0x392BE8)(ptr); +} +__declspec(noinline) void operator delete[](void* ptr) noexcept { + ((void(*)(void*))CWBase()+0x392BE8)(ptr); +} diff --git a/cwmods/cwmods.h b/cwmods/cwmods.h new file mode 100644 index 0000000..3726cf3 --- /dev/null +++ b/cwmods/cwmods.h @@ -0,0 +1,71 @@ +#ifndef CWMODS_H +#define CWMODS_H +#include + +#define EXPORT extern "C" __declspec(dllexport) __declspec(noinline) + +#include "IDA/types.h" + +#include "common/ByteRGBA.h" +#include "common/FloatRGBA.h" +#include "common/FloatVector3.h" +#include "common/IntVector2.h" +#include "common/LongVector3.h" + +#include "cube/ChatWidget.h" +#include "cube/Client.h" +#include "cube/Creature.h" +#include "cube/Database.h" +#include "cube/Field.h" +#include "cube/Game.h" +#include "cube/GUI.h" +#include "cube/Host.h" +#include "cube/Item.h" +#include "cube/ItemStack.h" +#include "cube/Speech.h" +#include "cube/SpriteManager.h" +#include "cube/World.h" +#include "cube/WorldMap.h" +#include "cube/Zone.h" +#include "cube/constants.h" + +#include "gfx/Chunk.h" +#include "gfx/D3D11Graphics.h" +#include "gfx/D3D11Renderer.h" + +#include "msvc/allocator.h" +#include "msvc/list.h" +#include "msvc/string.h" +#include "msvc/vector.h" +#include "msvc/wstring.h" + +#include "plasma/Attribute.h" +#include "plasma/ContinuousAttribute.h" +#include "plasma/D3D11Engine.h" +#include "plasma/DiscreteAttribute.h" +#include "plasma/Display.h" +#include "plasma/Engine.h" +#include "plasma/Keyable.h" +#include "plasma/NamedObject.h" +#include "plasma/Node.h" +#include "plasma/Object.h" +#include "plasma/ObjectManager.h" +#include "plasma/Vector.h" +#include "plasma/Widget.h" + + +void* CWBase(); + +EXPORT void ModPreInitialize(); +EXPORT int ModMajorVersion(); +EXPORT int ModMinorVersion(); + +void WriteByte(void* location, char val); +void WriteFarJMP(void* source, void* destination); + +__declspec(noinline) void* operator new(size_t size); +__declspec(noinline) void* operator new[](size_t size); +__declspec(noinline) void operator delete(void* ptr) noexcept; +__declspec(noinline) void operator delete[](void* ptr) noexcept; + +#endif // CWMODS_H diff --git a/cwmods/gfx/Chunk.cpp b/cwmods/gfx/Chunk.cpp new file mode 100644 index 0000000..56d5031 --- /dev/null +++ b/cwmods/gfx/Chunk.cpp @@ -0,0 +1 @@ +#include "Chunk.h" diff --git a/cwmods/gfx/Chunk.h b/cwmods/gfx/Chunk.h new file mode 100644 index 0000000..880159d --- /dev/null +++ b/cwmods/gfx/Chunk.h @@ -0,0 +1,12 @@ +#ifndef CHUNK_H +#define CHUNK_H + +namespace gfx { +class Chunk { + public: + void *vtable; + char field_8[640]; + }; +} + +#endif // CHUNK_H diff --git a/cwmods/gfx/D3D11Graphics.cpp b/cwmods/gfx/D3D11Graphics.cpp new file mode 100644 index 0000000..cc126f3 --- /dev/null +++ b/cwmods/gfx/D3D11Graphics.cpp @@ -0,0 +1 @@ +#include "D3D11Graphics.h" diff --git a/cwmods/gfx/D3D11Graphics.h b/cwmods/gfx/D3D11Graphics.h new file mode 100644 index 0000000..7bcb99a --- /dev/null +++ b/cwmods/gfx/D3D11Graphics.h @@ -0,0 +1,15 @@ +#ifndef D3D11GRAPHICS_H +#define D3D11GRAPHICS_H + +#include "../IDA/types.h" + +namespace gfx { +class D3D11Graphics { + public: + void *vtable; + __int64 field_8; + __int64 field_10; + }; +} + +#endif // D3D11GRAPHICS_H diff --git a/cwmods/gfx/D3D11Renderer.cpp b/cwmods/gfx/D3D11Renderer.cpp new file mode 100644 index 0000000..43239b2 --- /dev/null +++ b/cwmods/gfx/D3D11Renderer.cpp @@ -0,0 +1 @@ +#include "D3D11Renderer.h" diff --git a/cwmods/gfx/D3D11Renderer.h b/cwmods/gfx/D3D11Renderer.h new file mode 100644 index 0000000..12a4d63 --- /dev/null +++ b/cwmods/gfx/D3D11Renderer.h @@ -0,0 +1,14 @@ +#ifndef D3D11RENDERER_H +#define D3D11RENDERER_H + +#include "../IDA/types.h" + +namespace gfx { +class D3D11Renderer { + public: + _BYTE gap0[2631]; + char end; + }; +} + +#endif // D3D11RENDERER_H diff --git a/cwmods/msvc/allocator.cpp b/cwmods/msvc/allocator.cpp new file mode 100644 index 0000000..30c4efa --- /dev/null +++ b/cwmods/msvc/allocator.cpp @@ -0,0 +1 @@ +#include "allocator.h" diff --git a/cwmods/msvc/allocator.h b/cwmods/msvc/allocator.h new file mode 100644 index 0000000..07020b5 --- /dev/null +++ b/cwmods/msvc/allocator.h @@ -0,0 +1,51 @@ +#ifndef MSVC_ALLOCATOR_H +#define MSVC_ALLOCATOR_H +#include +#include +#include + +#include + +namespace msvc { + template + struct allocator { + public: + typedef size_t size_type; + typedef T value_type; + typedef T& reference; + typedef T* pointer; + + T* allocate( std::size_t n ) { + const static size_type alignment_size = 32; + const static size_type alignment_offset = (alignment_size-1) + sizeof(void*); + + size_type new_allocation_size = n * sizeof(T); + pointer new_backing; + + // Large arrays + if (new_allocation_size < 0x1000) { + new_backing = (pointer)new char[new_allocation_size]; + } else { + new_allocation_size += 39; + char* large_array = new char[new_allocation_size]; + new_backing = (pointer)((long long unsigned int)(large_array + alignment_offset) & ~(alignment_size-1)); + ((char**)(new_backing))[-1] = large_array; + } + return new_backing; + } + + void deallocate( T* p, std::size_t n ) { + size_type old_allocation_size = n * sizeof(T); + if (old_allocation_size < 0x1000) { + delete[] p; + } else { + char* actual_allocation = ((char**)(p))[-1]; + delete[] actual_allocation; + } + } + + + }; +} + +#endif // MSVC_ALLOCATOR_H diff --git a/cwmods/msvc/list.cpp b/cwmods/msvc/list.cpp new file mode 100644 index 0000000..471c2a1 --- /dev/null +++ b/cwmods/msvc/list.cpp @@ -0,0 +1 @@ +#include "list.h" diff --git a/cwmods/msvc/list.h b/cwmods/msvc/list.h new file mode 100644 index 0000000..6eed111 --- /dev/null +++ b/cwmods/msvc/list.h @@ -0,0 +1,130 @@ +#ifndef MSVC_LIST_H +#define MSVC_LIST_H +#include +#include +#include +#include +#include "allocator.h" + +namespace msvc { + template + struct list { + + class node { + public: + msvc::list::node *next; + msvc::list::node *prev; + T data; + + node() { + this->next = nullptr; + this->prev = nullptr; + } + node( msvc::list::node *prev, msvc::list::node *next, T data) { + this->next = next; + this->prev = prev; + this->data = data; + } + + }; + + public: + typedef size_t size_type; + typedef T value_type; + typedef T& reference; + typedef T* pointer; + + // forward iterator + class iterator { + public: + typedef iterator self_type; + typedef int difference_type; + typedef std::forward_iterator_tag iterator_category; + + iterator() {} + iterator(msvc::list::node* ptr) : list_node(ptr) { } + + self_type operator=(const self_type& other) { list_node = other.list_node; return *this; } + self_type operator++() { list_node = list_node->next; return *this; } // ++i + self_type operator++(int junk) { self_type i = *this; list_node = list_node->next; return i; } // i++ + self_type operator--() { list_node = list_node->prev; return *this; } + self_type operator--(int junk) { self_type i = *this; list_node = list_node->prev; return i; } + reference operator*() { return list_node->data; } + pointer operator->() { return &list_node->data; } + bool operator==(const self_type& rhs) const { return list_node == rhs.list_node; } + bool operator!=(const self_type& rhs) const { return list_node != rhs.list_node; } + + msvc::list::node* list_node; + }; + + private: + msvc::list::node *head; + size_type _size; + + + public: + reference front() { + return head->next->data; + } + + reference back() { + return head->prev->data; + } + + iterator begin() { + return iterator(head->next); + } + + iterator end() { + return iterator(head); + } + + size_type size() { + return _size; + } + + size_type max_size() const noexcept { + // Silly, theoretical max container size. + return UINTPTR_MAX / sizeof(T); + } + + iterator insert( iterator pos, const T& value ) { + list::node* current_node = pos.list_node; + list::node* previous_node = current_node->prev; + + + list::node* new_node = new node(previous_node, current_node, value); + + current_node->prev = new_node; + previous_node->next = new_node; + + _size++; + + return iterator(new_node); + } + + iterator erase( iterator pos ) { + if (!size()) { + return end(); + } + list::node* current_node = pos.list_node; + list::node* previous_node = current_node->prev; + list::node* next_node = current_node->next; + + + next_node->prev = previous_node; + previous_node->next = next_node; + + delete current_node; + + return iterator(next_node); + } + + void push_back( const T& value ) { + insert(end(), value); + } + + }; +} + +#endif // MSVC_LIST_H diff --git a/cwmods/msvc/string.cpp b/cwmods/msvc/string.cpp new file mode 100644 index 0000000..eab76f2 --- /dev/null +++ b/cwmods/msvc/string.cpp @@ -0,0 +1 @@ +#include "string.h" diff --git a/cwmods/msvc/string.h b/cwmods/msvc/string.h new file mode 100644 index 0000000..064c656 --- /dev/null +++ b/cwmods/msvc/string.h @@ -0,0 +1,19 @@ +#ifndef MSVC_STRING_H +#define MSVC_STRING_H +#include + +namespace msvc { + union string_data_union { + char sbo[16]; + void* ptr; + }; + + class string { + public: + string_data_union data; + int64_t size; + int64_t cap; + }; +} + +#endif // MSVC_STRING_H diff --git a/cwmods/msvc/vector.cpp b/cwmods/msvc/vector.cpp new file mode 100644 index 0000000..7da6cc5 --- /dev/null +++ b/cwmods/msvc/vector.cpp @@ -0,0 +1 @@ +#include "vector.h" diff --git a/cwmods/msvc/vector.h b/cwmods/msvc/vector.h new file mode 100644 index 0000000..dfc2a62 --- /dev/null +++ b/cwmods/msvc/vector.h @@ -0,0 +1,209 @@ +// based on https://github.com/Andoryuuta/cwsdk/blob/master/cwsdk/msvc_bincompat/vector.h + +#ifndef MSVC_VECTOR_H +#define MSVC_VECTOR_H +#include +#include +#include +#include +#include "allocator.h" + +namespace msvc { + template + struct vector { + private: + T* _start; + T* _end; + T* _cap; + + public: + typedef size_t size_type; + typedef T value_type; + typedef T& reference; + typedef T* pointer; + + // forward iterator + class iterator { + public: + typedef iterator self_type; + typedef int difference_type; + typedef std::forward_iterator_tag iterator_category; + + iterator() {} + iterator(pointer ptr) : _ptr(ptr) { } + + self_type operator=(const self_type& other) { _ptr = other._ptr; return *this; } + self_type operator++() { _ptr++; return *this; } // ++i + self_type operator++(int junk) { self_type i = *this; _ptr++; return i; } // i++ + self_type operator--() { _ptr--; return *this; } + self_type operator--(int junk) { self_type i = *this; _ptr--; return i; } + reference operator*() { return *_ptr; } + pointer operator->() { return _ptr; } + bool operator==(const self_type& rhs) const { return _ptr == rhs._ptr; } + bool operator!=(const self_type& rhs) const { return _ptr != rhs._ptr; } + + private: + pointer _ptr; + }; + + // const forward iterator + class const_iterator { + public: + typedef const_iterator self_type; + typedef int difference_type; + typedef std::forward_iterator_tag iterator_category; + + const_iterator() {} + const_iterator(pointer ptr) : _ptr(ptr) { } + + self_type operator++() { _ptr++; return *this; } + self_type operator++(int junk) { self_type i = *this; _ptr++; return i; } + self_type operator--() { _ptr--; return *this; } + self_type operator--(int junk) { self_type i = *this; _ptr--; return i; } + const value_type& operator*() { return *_ptr; } + const value_type* operator->() { return _ptr; } + bool operator==(const self_type& rhs) const { return _ptr == rhs._ptr; } + bool operator!=(const self_type& rhs) const { return _ptr != rhs._ptr; } + + private: + pointer _ptr; + }; + + /* Constructors & Destructors start*/ + vector() { + auto mem = (pointer)operator new(0); + _start = mem; + _end = mem; + _cap = mem; + + reserve(1); + } + + ~vector() { + if (_start != nullptr) { + operator delete(_start); + } + } + + /* Constructors & Destructors end*/ + + /* Element access methods start*/ + reference at(size_type pos) { + if (pos > size()) { + throw std::out_of_range("index out of bounds"); + } + return operator[](pos); + } + + reference operator [](size_type pos) { + return _start[pos]; + } + + reference front() { + return *begin(); + } + + reference back() { + auto tmp = end(); + tmp--; + return *tmp; + } + + /* Element access methods end*/ + + /* Iterators methods start*/ + iterator begin() { + return iterator(_start); + } + + iterator end() { + return iterator(_end); + } + + const_iterator begin() const { + return const_iterator(_start); + } + + const_iterator end() const { + return const_iterator(_end); + } + /* Iterators methods end*/ + + /* Capacity methods start*/ + bool empty() const { + return begin() == end(); + } + + size_type size() const { + return _end - _start; + } + + size_type max_size() const { + // Silly, theoretical max container size. + return UINTPTR_MAX / sizeof(T); + } + + void reserve(size_type new_cap) { + msvc::allocator thisAllocator; + size_type old_capacity = capacity(); + + // No need to reserve more if we need less space than we have + if (new_cap <= old_capacity) { + return; + } + + if (new_cap > max_size()) { + throw std::length_error("new_cap > max_size()"); + } + + // Create new backing array + pointer new_backing = thisAllocator.allocate(new_cap); + + // Copy old contents to new array + size_type old_size = size(); + memcpy((void*)new_backing, (void*)_start, old_size * sizeof(T)); + + // Remember old array + pointer old_backing = _start; + + // Update the vector + _start = new_backing; + _end = new_backing + old_size; + _cap = new_backing + new_cap; + + // Deallocate old array + thisAllocator.deallocate(old_backing, old_capacity); + } + + size_type capacity() const { + return _cap - _start; + } + /* Capacity methods end*/ + + /* Modifer methods start*/ + void push_back(const T& value) { + if (capacity() == 0) { + reserve(1); + } + else if (size() == capacity()) { + reserve(capacity() * 2); + } + _start[size()] = value; + _end++; + } + + void pop_back() { + if (size() > 0) { + back().~T(); + _end--; + } + } + + void clear() noexcept { + _end = _start; + } + /* Modifer methods end*/ + }; +} + +#endif // MSVC_VECTOR_H diff --git a/cwmods/msvc/wstring.cpp b/cwmods/msvc/wstring.cpp new file mode 100644 index 0000000..136fa16 --- /dev/null +++ b/cwmods/msvc/wstring.cpp @@ -0,0 +1,23 @@ +#include "wstring.h" +#include + +msvc::wstring::wstring(const wchar_t* str) { + int len = wcslen(str) + 1; + wchar_t* data; + if (len >= 8) { + data = new wchar_t[len]; + this->data.ptr = data; + } + else { + data = this->data.sbo; + } + memcpy(data, str, len * sizeof(wchar_t)); + this->size = len; + this->cap = len; + +} +msvc::wstring::~wstring() { + if (this->size >= 8) { + delete[] this->data.ptr; + } +} diff --git a/cwmods/msvc/wstring.h b/cwmods/msvc/wstring.h new file mode 100644 index 0000000..598dc35 --- /dev/null +++ b/cwmods/msvc/wstring.h @@ -0,0 +1,22 @@ +#ifndef MSVC_WSTRING_H +#define MSVC_WSTRING_H +#include + +namespace msvc { + union wstring_data_union { + wchar_t sbo[8]; + wchar_t *ptr; + }; + class wstring { + public: + wstring_data_union data; + int64_t size; + int64_t cap; + + wstring(const wchar_t* str); + ~wstring(); + }; +}; + + +#endif // MSVC_WSTRING_H diff --git a/cwmods/plasma/Array.cpp b/cwmods/plasma/Array.cpp new file mode 100644 index 0000000..172253a --- /dev/null +++ b/cwmods/plasma/Array.cpp @@ -0,0 +1 @@ +#include "Array.h" diff --git a/cwmods/plasma/Array.h b/cwmods/plasma/Array.h new file mode 100644 index 0000000..9bef5b8 --- /dev/null +++ b/cwmods/plasma/Array.h @@ -0,0 +1,29 @@ +#ifndef ARRAY_H +#define ARRAY_H + +#include "../IDA/types.h" +#include "../msvc/string.h" + +namespace plasma { + template + class Array { + public: + T *start; + T *end; + T *cap; + + int Length() { + return (this->end - this->start); + } + + T Get(int i) { + return start[i]; + } + + void Set(int i, T x) { + start[i] = x; + } + }; +} + +#endif // ARRAY_H diff --git a/cwmods/plasma/Attribute.cpp b/cwmods/plasma/Attribute.cpp new file mode 100644 index 0000000..0491e59 --- /dev/null +++ b/cwmods/plasma/Attribute.cpp @@ -0,0 +1 @@ +#include "Attribute.h" diff --git a/cwmods/plasma/Attribute.h b/cwmods/plasma/Attribute.h new file mode 100644 index 0000000..ca78c48 --- /dev/null +++ b/cwmods/plasma/Attribute.h @@ -0,0 +1,24 @@ +#ifndef ATTRIBUTE_H +#define ATTRIBUTE_H + +#include "../IDA/types.h" +#include "../msvc/string.h" + +namespace plasma { + class Attribute { + public: + void *vtable; + __int64 field_8; + __int64 field_10; + __int64 field_18; + __int64 field_20; + __int64 field_28; + __int64 field_30; + __int64 field_38; + msvc::string name; + __int64 field_60; + __int64 field_68; + }; +} + +#endif // ATTRIBUTE_H diff --git a/cwmods/plasma/ContinuousAttribute.cpp b/cwmods/plasma/ContinuousAttribute.cpp new file mode 100644 index 0000000..52e6bf2 --- /dev/null +++ b/cwmods/plasma/ContinuousAttribute.cpp @@ -0,0 +1 @@ +#include "ContinuousAttribute.h" diff --git a/cwmods/plasma/ContinuousAttribute.h b/cwmods/plasma/ContinuousAttribute.h new file mode 100644 index 0000000..7e49697 --- /dev/null +++ b/cwmods/plasma/ContinuousAttribute.h @@ -0,0 +1,16 @@ +#ifndef CONTINUOUSATTRIBUTE_H +#define CONTINUOUSATTRIBUTE_H + +#include "../IDA/types.h" +#include "Attribute.h" +#include "../msvc/vector.h" + +namespace plasma { + template + class ContinuousAttribute : public plasma::Attribute { + public: + msvc::vector data; + }; +} + +#endif // CONTINUOUSATTRIBUTE_H diff --git a/cwmods/plasma/D3D11Engine.cpp b/cwmods/plasma/D3D11Engine.cpp new file mode 100644 index 0000000..c38b668 --- /dev/null +++ b/cwmods/plasma/D3D11Engine.cpp @@ -0,0 +1 @@ +#include "D3D11Engine.h" diff --git a/cwmods/plasma/D3D11Engine.h b/cwmods/plasma/D3D11Engine.h new file mode 100644 index 0000000..cd00342 --- /dev/null +++ b/cwmods/plasma/D3D11Engine.h @@ -0,0 +1,14 @@ +#ifndef D3D11ENGINE_H +#define D3D11ENGINE_H + +#include "../IDA/types.h" +#include "Engine.h" + +namespace plasma { + class D3D11Engine : public plasma::Engine { + public: + char field_290[840]; + }; +} + +#endif // D3D11ENGINE_H diff --git a/cwmods/plasma/DiscreteAttribute.cpp b/cwmods/plasma/DiscreteAttribute.cpp new file mode 100644 index 0000000..0de7aa0 --- /dev/null +++ b/cwmods/plasma/DiscreteAttribute.cpp @@ -0,0 +1 @@ +#include "DiscreteAttribute.h" diff --git a/cwmods/plasma/DiscreteAttribute.h b/cwmods/plasma/DiscreteAttribute.h new file mode 100644 index 0000000..4b43733 --- /dev/null +++ b/cwmods/plasma/DiscreteAttribute.h @@ -0,0 +1,16 @@ +#ifndef DISCRETEATTRIBUTE_H +#define DISCRETEATTRIBUTE_H + +#include "../IDA/types.h" +#include "Attribute.h" +#include "../msvc/vector.h" + +namespace plasma { + template + class DiscreteAttribute : public plasma::Attribute { + public: + msvc::vector data; + }; +} + +#endif // DISCRETEATTRIBUTE_H diff --git a/cwmods/plasma/Display.cpp b/cwmods/plasma/Display.cpp new file mode 100644 index 0000000..713c12b --- /dev/null +++ b/cwmods/plasma/Display.cpp @@ -0,0 +1,13 @@ +#include "Display.h" + +void plasma::Display::SetVisibility(int frame, int value) { + this->visibility.data.at(frame) = value; +} + +int plasma::Display::GetVisibility(int frame) { + return this->visibility.data.at(frame); +} + +int plasma::Display::GetFrameCount() { + return this->visibility.data.size(); +} diff --git a/cwmods/plasma/Display.h b/cwmods/plasma/Display.h new file mode 100644 index 0000000..a1f160e --- /dev/null +++ b/cwmods/plasma/Display.h @@ -0,0 +1,27 @@ +#ifndef DISPLAY_H +#define DISPLAY_H + +#include "../IDA/types.h" +#include "Keyable.h" +#include "DiscreteAttribute.h" +#include "ContinuousAttribute.h" +#include "Vector.h" + +namespace plasma { + class Display : public plasma::Keyable { + public: + plasma::DiscreteAttribute visibility; + plasma::DiscreteAttribute clipping; + plasma::ContinuousAttribute> fill; + plasma::ContinuousAttribute> stroke; + plasma::ContinuousAttribute blurRadius; + _BYTE gap318[31]; + char end; + + void SetVisibility(int frame, int value); + int GetVisibility(int frame); + int GetFrameCount(); + }; +} + +#endif // DISPLAY_H diff --git a/cwmods/plasma/Engine.cpp b/cwmods/plasma/Engine.cpp new file mode 100644 index 0000000..8fdf254 --- /dev/null +++ b/cwmods/plasma/Engine.cpp @@ -0,0 +1 @@ +#include "Engine.h" diff --git a/cwmods/plasma/Engine.h b/cwmods/plasma/Engine.h new file mode 100644 index 0000000..744946d --- /dev/null +++ b/cwmods/plasma/Engine.h @@ -0,0 +1,14 @@ +#ifndef ENGINE_H +#define ENGINE_H + +#include "../IDA/types.h" +#include "ObjectManager.h" + +namespace plasma { + class Engine : public plasma::ObjectManager { + public: + char field_20[624]; + }; +} + +#endif // ENGINE_H diff --git a/cwmods/plasma/Keyable.cpp b/cwmods/plasma/Keyable.cpp new file mode 100644 index 0000000..1b4d4c4 --- /dev/null +++ b/cwmods/plasma/Keyable.cpp @@ -0,0 +1 @@ +#include "Keyable.h" diff --git a/cwmods/plasma/Keyable.h b/cwmods/plasma/Keyable.h new file mode 100644 index 0000000..31842b1 --- /dev/null +++ b/cwmods/plasma/Keyable.h @@ -0,0 +1,20 @@ +#ifndef KEYABLE_H +#define KEYABLE_H + +#include "../IDA/types.h" +#include "NamedObject.h" + +namespace plasma { + class Keyable : public plasma::NamedObject { + public: + __int64 field_38; + __int64 field_40; + __int64 field_48; + __int64 field_50; + __int64 field_58; + __int64 field_60; + __int64 field_68; + }; +} + +#endif // KEYABLE_H diff --git a/cwmods/plasma/NamedObject.cpp b/cwmods/plasma/NamedObject.cpp new file mode 100644 index 0000000..ea2abcd --- /dev/null +++ b/cwmods/plasma/NamedObject.cpp @@ -0,0 +1 @@ +#include "NamedObject.h" diff --git a/cwmods/plasma/NamedObject.h b/cwmods/plasma/NamedObject.h new file mode 100644 index 0000000..0e8c5a9 --- /dev/null +++ b/cwmods/plasma/NamedObject.h @@ -0,0 +1,17 @@ +#ifndef NAMEDOBJECT_H +#define NAMEDOBJECT_H + +#include "../IDA/types.h" +#include "Object.h" + +namespace plasma { + class NamedObject : public plasma::Object { + public: + void *field_18; + __int64 field_20; + __int64 field_28; + __int64 field_30; + }; +} + +#endif // NAMEDOBJECT_H diff --git a/cwmods/plasma/Node.cpp b/cwmods/plasma/Node.cpp new file mode 100644 index 0000000..0c2b14d --- /dev/null +++ b/cwmods/plasma/Node.cpp @@ -0,0 +1 @@ +#include "Node.h" diff --git a/cwmods/plasma/Node.h b/cwmods/plasma/Node.h new file mode 100644 index 0000000..99e4fd7 --- /dev/null +++ b/cwmods/plasma/Node.h @@ -0,0 +1,32 @@ +#ifndef NODE_H +#define NODE_H + +#include "../IDA/types.h" +#include "NamedObject.h" +#include "Display.h" + +namespace plasma { + class Node : public plasma::NamedObject { + public: + __int64 field_38; + __int64 field_40; + __int64 field_48; + __int64 field_50; + __int64 field_58; + __int64 field_60; + plasma::Display *display; + __int64 field_70; + __int64 field_78; + __int64 field_80; + __int64 field_88; + __int64 field_90; + __int64 field_98; + __int64 field_A0; + __int64 field_A8; + __int64 field_B0; + __int64 field_B8; + __int64 field_C0; + }; +} + +#endif // NODE_H diff --git a/cwmods/plasma/Object.cpp b/cwmods/plasma/Object.cpp new file mode 100644 index 0000000..1aa52d6 --- /dev/null +++ b/cwmods/plasma/Object.cpp @@ -0,0 +1 @@ +#include "Object.h" diff --git a/cwmods/plasma/Object.h b/cwmods/plasma/Object.h new file mode 100644 index 0000000..b316757 --- /dev/null +++ b/cwmods/plasma/Object.h @@ -0,0 +1,16 @@ +#ifndef OBJECT_H +#define OBJECT_H + +#include "../IDA/types.h" +#include "D3D11Engine.h" + +namespace plasma { + class Object { + public: + void *vtable; + plasma::D3D11Engine *d3d11_engine; + __int64 field_10; + }; +} + +#endif // OBJECT_H diff --git a/cwmods/plasma/ObjectManager.cpp b/cwmods/plasma/ObjectManager.cpp new file mode 100644 index 0000000..f98ef52 --- /dev/null +++ b/cwmods/plasma/ObjectManager.cpp @@ -0,0 +1 @@ +#include "ObjectManager.h" diff --git a/cwmods/plasma/ObjectManager.h b/cwmods/plasma/ObjectManager.h new file mode 100644 index 0000000..1167baa --- /dev/null +++ b/cwmods/plasma/ObjectManager.h @@ -0,0 +1,16 @@ +#ifndef OBJECTMANAGER_H +#define OBJECTMANAGER_H + +#include "../IDA/types.h" + +namespace plasma { + class ObjectManager { + public: + void *vtable; + __int64 field_8; + __int64 field_10; + __int64 field_18; + }; +} + +#endif // OBJECTMANAGER_H diff --git a/cwmods/plasma/Vector.cpp b/cwmods/plasma/Vector.cpp new file mode 100644 index 0000000..1a0d306 --- /dev/null +++ b/cwmods/plasma/Vector.cpp @@ -0,0 +1 @@ +#include "Vector.h" diff --git a/cwmods/plasma/Vector.h b/cwmods/plasma/Vector.h new file mode 100644 index 0000000..f614b13 --- /dev/null +++ b/cwmods/plasma/Vector.h @@ -0,0 +1,21 @@ +#ifndef PLASMA_VECTOR_H +#define PLASMA_VECTOR_H + + +namespace plasma { + template + class Vector { + public: + T elements[N]; + + T Get(int i) { + return elements[i]; + } + + void Set(int i, T x) { + elements[i] = x; + } + }; +} + +#endif // PLASMA_VECTOR_H diff --git a/cwmods/plasma/Widget.cpp b/cwmods/plasma/Widget.cpp new file mode 100644 index 0000000..60c7158 --- /dev/null +++ b/cwmods/plasma/Widget.cpp @@ -0,0 +1 @@ +#include "Widget.h" diff --git a/cwmods/plasma/Widget.h b/cwmods/plasma/Widget.h new file mode 100644 index 0000000..357a396 --- /dev/null +++ b/cwmods/plasma/Widget.h @@ -0,0 +1,30 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include "../IDA/types.h" +#include "NamedObject.h" + +namespace plasma { + class Widget : public plasma::NamedObject { + public: + void *vtable; + float scale; + _BYTE gap44[20]; + __int64 d3d11_render_surface_ptr; + float float_60; + float float_64; + _BYTE gap68[8]; + float float_70; + float float_74; + _BYTE gap78[8]; + float float_80; + float float_84; + _BYTE gap88[8]; + float width; + float height; + _BYTE gap98[271]; + char end; + }; +} + +#endif // WIDGET_H diff --git a/logger.cpp b/logger.cpp new file mode 100644 index 0000000..629a378 --- /dev/null +++ b/logger.cpp @@ -0,0 +1,270 @@ +//logger.cpp +#include "logger.h" +#include +#include +#include +#include + +using std::string; +using std::vector; + +namespace LOGGER +{ + CLogger::CLogger(EnumLogLevel nLogLevel, const std::string strLogPath, const std::string strLogName) + :m_nLogLevel(nLogLevel), + m_strLogPath(strLogPath), + m_strLogName(strLogName) + { + //初始化 + m_pFileStream = NULL; + if (m_strLogPath.empty()) + { + m_strLogPath = GetAppPathA(); + } + if (m_strLogPath[m_strLogPath.length()-1] != '\\') + { + m_strLogPath.append("\\"); + } + //创建文件夹 + //MakeSureDirectoryPathExists(m_strLogPath.c_str()); + //创建日志文件 + if (m_strLogName.empty()) + { + time_t curTime; + time(&curTime); + tm tm1; + localtime_s(&tm1, &curTime); + //日志的名称如:201601012130.log + m_strLogName = FormatString("%04d%02d%02d_%02d%02d%02d.log", tm1.tm_year + 1900, tm1.tm_mon + 1, tm1.tm_mday, tm1.tm_hour, tm1.tm_min, tm1.tm_sec); + } + m_strLogFilePath = m_strLogPath.append(m_strLogName); + + //以追加的方式打开文件流 + fopen_s(&m_pFileStream, m_strLogFilePath.c_str(), "a+"); + + InitializeCriticalSection(&m_cs); + } + + + //析构函数 + CLogger::~CLogger() + { + //释放临界区 + DeleteCriticalSection(&m_cs); + //关闭文件流 + if (m_pFileStream) + { + fclose(m_pFileStream); + m_pFileStream = NULL; + } + } + + //文件全路径得到文件名 + const char *CLogger::path_file(const char *path, char splitter) + { + return strrchr(path, splitter) ? strrchr(path, splitter) + 1 : path; + } + + //写严重错误信息 + void CLogger::TraceFatal(const char *lpcszFormat, ...) + { + //判断当前的写日志级别 + if (EnumLogLevel::LogLevel_Fatal > m_nLogLevel) + return; + string strResult; + if (NULL != lpcszFormat) + { + va_list marker = NULL; + va_start(marker, lpcszFormat); //初始化变量参数 + size_t nLength = _vscprintf(lpcszFormat, marker) + 1; //获取格式化字符串长度 + std::vector vBuffer(nLength, '\0'); //创建用于存储格式化字符串的字符数组 + int nWritten = _vsnprintf_s(&vBuffer[0], vBuffer.size(), nLength, lpcszFormat, marker); + if (nWritten > 0) + { + strResult = &vBuffer[0]; + } + va_end(marker); //重置变量参数 + } + if (strResult.empty()) + { + return; + } + string strLog = strFatalPrefix; + strLog.append(GetTime()).append(strResult); + + //写日志文件 + Trace(strLog); + } + + //写错误信息 + void CLogger::TraceError(const char *lpcszFormat, ...) + { + //判断当前的写日志级别 + if (EnumLogLevel::LogLevel_Error > m_nLogLevel) + return; + string strResult; + if (NULL != lpcszFormat) + { + va_list marker = NULL; + va_start(marker, lpcszFormat); //初始化变量参数 + size_t nLength = _vscprintf(lpcszFormat, marker) + 1; //获取格式化字符串长度 + std::vector vBuffer(nLength, '\0'); //创建用于存储格式化字符串的字符数组 + int nWritten = _vsnprintf_s(&vBuffer[0], vBuffer.size(), nLength, lpcszFormat, marker); + if (nWritten > 0) + { + strResult = &vBuffer[0]; + } + va_end(marker); //重置变量参数 + } + if (strResult.empty()) + { + return; + } + string strLog = strErrorPrefix; + strLog.append(GetTime()).append(strResult); + + //写日志文件 + Trace(strLog); + } + + //写警告信息 + void CLogger::TraceWarning(const char *lpcszFormat, ...) + { + //判断当前的写日志级别 + if (EnumLogLevel::LogLevel_Warning > m_nLogLevel) + return; + string strResult; + if (NULL != lpcszFormat) + { + va_list marker = NULL; + va_start(marker, lpcszFormat); //初始化变量参数 + size_t nLength = _vscprintf(lpcszFormat, marker) + 1; //获取格式化字符串长度 + std::vector vBuffer(nLength, '\0'); //创建用于存储格式化字符串的字符数组 + int nWritten = _vsnprintf_s(&vBuffer[0], vBuffer.size(), nLength, lpcszFormat, marker); + if (nWritten > 0) + { + strResult = &vBuffer[0]; + } + va_end(marker); //重置变量参数 + } + if (strResult.empty()) + { + return; + } + string strLog = strWarningPrefix; + strLog.append(GetTime()).append(strResult); + + //写日志文件 + Trace(strLog); + } + + + //写一般信息 + void CLogger::TraceInfo(const char *lpcszFormat, ...) + { + //判断当前的写日志级别 + if (EnumLogLevel::LogLevel_Info > m_nLogLevel) + return; + string strResult; + if (NULL != lpcszFormat) + { + va_list marker = NULL; + va_start(marker, lpcszFormat); //初始化变量参数 + size_t nLength = _vscprintf(lpcszFormat, marker) + 1; //获取格式化字符串长度 + std::vector vBuffer(nLength, '\0'); //创建用于存储格式化字符串的字符数组 + int nWritten = _vsnprintf_s(&vBuffer[0], vBuffer.size(), nLength, lpcszFormat, marker); + if (nWritten > 0) + { + strResult = &vBuffer[0]; + } + va_end(marker); //重置变量参数 + } + if (strResult.empty()) + { + return; + } + string strLog = strInfoPrefix; + strLog.append(GetTime()).append(strResult); + + //写日志文件 + Trace(strLog); + } + + //获取系统当前时间 + string CLogger::GetTime() + { + time_t curTime; + time(&curTime); + tm tm1; + localtime_s(&tm1, &curTime); + //2016-01-01 21:30:00 + string strTime = FormatString("%04d-%02d-%02d %02d:%02d:%02d ", tm1.tm_year + 1900, tm1.tm_mon + 1, tm1.tm_mday, tm1.tm_hour, tm1.tm_min, tm1.tm_sec); + + return strTime; + } + + //改变写日志级别 + void CLogger::ChangeLogLevel(EnumLogLevel nLevel) + { + m_nLogLevel = nLevel; + } + + //写文件操作 + void CLogger::Trace(const string &strLog) + { + try + { + //进入临界区 + EnterCriticalSection(&m_cs); + //若文件流没有打开,则重新打开 + if (NULL == m_pFileStream) + { + fopen_s(&m_pFileStream, m_strLogFilePath.c_str(), "a+"); + if (!m_pFileStream) + { + return; + } + } + //写日志信息到文件流 + fprintf(m_pFileStream, "%s\n", strLog.c_str()); + fflush(m_pFileStream); + //离开临界区 + LeaveCriticalSection(&m_cs); + } + //若发生异常,则先离开临界区,防止死锁 + catch (...) + { + LeaveCriticalSection(&m_cs); + } + } + + string CLogger::GetAppPathA() + { + char szFilePath[MAX_PATH] = { 0 }, szDrive[MAX_PATH] = { 0 }, szDir[MAX_PATH] = { 0 }, szFileName[MAX_PATH] = { 0 }, szExt[MAX_PATH] = { 0 }; + GetModuleFileNameA(NULL, szFilePath, sizeof(szFilePath)); + _splitpath_s(szFilePath, szDrive, szDir, szFileName, szExt); + + string str(szDrive); + str.append(szDir); + return str; + } + + string CLogger::FormatString(const char *lpcszFormat, ...) + { + string strResult; + if (NULL != lpcszFormat) + { + va_list marker = NULL; + va_start(marker, lpcszFormat); //初始化变量参数 + size_t nLength = _vscprintf(lpcszFormat, marker) + 1; //获取格式化字符串长度 + std::vector vBuffer(nLength, '\0'); //创建用于存储格式化字符串的字符数组 + int nWritten = _vsnprintf_s(&vBuffer[0], vBuffer.size(), nLength, lpcszFormat, marker); + if (nWritten > 0) + { + strResult = &vBuffer[0]; + } + va_end(marker); //重置变量参数 + } + return strResult; + } +} diff --git a/logger.h b/logger.h new file mode 100644 index 0000000..e1398b1 --- /dev/null +++ b/logger.h @@ -0,0 +1,106 @@ + +//logger.h +/* +//类名:CLogger +//功能介绍:Win平台日志记录功能,多线程安全,支持写日志级别的设置,日志格式包含日志等级,日志时间,文件名,行号信息 +//作者:sunflover 2016-1-15 14:31:27 +//使用方法: +1:将logger.h,logger.cpp添加到项目中 +2:设置logger.cpp的预编译头选项为“不使用预编译头” +3:使用代码示例: +#include "Logger.h" +using namespace LOGGER; +CLogger logger(LogLevel_Info,CLogger::GetAppPathA().append("log\\")); +void main() +{ +logger.TraceFatal("TraceFatal %d", 1); +logger.TraceError("TraceError %s", "sun"); +logger.TraceWarning("TraceWarning"); +logger.TraceInfo("TraceInfo"); +logger.ChangeLogLevel(LOGGER::LogLevel_Error); +logger.TraceFatal("TraceFatal %d", 2); +logger.TraceError("TraceError %s", "sun2"); +logger.TraceWarning("TraceWarning"); +logger.TraceInfo("TraceInfo"); +} +执行结果:20160126_101329.log文件内容如下 +Fatal 2016-01-26 10:13:29 TraceFatal 1 +Error 2016-01-26 10:13:29 TraceError sun +Warning 2016-01-26 10:13:29 TraceWarning +Info 2016-01-26 10:13:29 TraceInfo +Fatal 2016-01-26 10:13:29 TraceFatal 2 +Error 2016-01-26 10:13:29 TraceError sun2 +*/ + +#ifndef _LOGGER_H_ +#define _LOGGER_H_ +#include +#include +#include + +namespace LOGGER +{ + //日志级别的提示信息 + static const std::string strFatalPrefix = "Fatal\t"; + static const std::string strErrorPrefix = "Error\t"; + static const std::string strWarningPrefix = "Warning\t"; + static const std::string strInfoPrefix = "Info\t"; + + //日志级别枚举 + typedef enum EnumLogLevel + { + LogLevel_Stop = 0, //什么都不记录 + LogLevel_Fatal, //只记录严重错误 + LogLevel_Error, //记录严重错误,普通错误 + LogLevel_Warning, //记录严重错误,普通错误,警告 + LogLevel_Info //记录严重错误,普通错误,警告,提示信息(也就是全部记录) + }; + + class CLogger + { + public: + //nLogLevel:日志记录的等级,可空 + //strLogPath:日志目录,可空 + //strLogName:日志名称,可空 + CLogger(EnumLogLevel nLogLevel = EnumLogLevel::LogLevel_Info, const std::string strLogPath = "", const std::string strLogName = ""); + //析构函数 + virtual ~CLogger(); + public: + //写严重错误信息 + void TraceFatal(const char *lpcszFormat, ...); + //写错误信息 + void TraceError(const char *lpcszFormat, ...); + //写警告信息 + void TraceWarning(const char *lpcszFormat, ...); + //写提示信息 + void TraceInfo(const char *lpcszFormat, ...); + //改变写日志级别 + void ChangeLogLevel(EnumLogLevel nLevel); + //获取程序运行路径 + static std::string GetAppPathA(); + //格式化字符串 + static std::string FormatString(const char *lpcszFormat, ...); + private: + //写文件操作 + void Trace(const std::string &strLog); + //获取当前系统时间 + std::string GetTime(); + //文件全路径得到文件名 + const char *path_file(const char *path, char splitter); + private: + //写日志文件流 + FILE * m_pFileStream; + //写日志级别 + EnumLogLevel m_nLogLevel; + //日志目录 + std::string m_strLogPath; + //日志的名称 + std::string m_strLogName; + //日志文件全路径 + std::string m_strLogFilePath; + //线程同步的临界区变量 + CRITICAL_SECTION m_cs; + }; +} + +#endif diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..9f24c75 --- /dev/null +++ b/main.cpp @@ -0,0 +1,16 @@ +#include "main.h" +#include "cwmods/cwmods.h" +//#include "logger.h" +//using namespace LOGGER; +//CLogger* logger; + +EXPORT int HandleInventoryCheck(cube::Creature* player, cube::Item *item) { + //logger->TraceInfo("Player:%s, Item:%d\n", player->entity_data.name, item->id); + // 1: full, 2: not full, 0: origin logic + return 2; +} + +//EXPORT void ModInitialize() { +// logger = new CLogger(LogLevel_Info,CLogger::GetAppPathA()); +// logger->ChangeLogLevel(LOGGER::LogLevel_Error); +//} diff --git a/main.h b/main.h new file mode 100644 index 0000000..a069788 --- /dev/null +++ b/main.h @@ -0,0 +1,26 @@ +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#include + +/* To use this exported function of dll, include this header + * in your project. + */ + +#ifdef BUILD_DLL + #define DLL_EXPORT __declspec(dllexport) +#else + #define DLL_EXPORT __declspec(dllimport) +#endif + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef __cplusplus +} +#endif + +#endif // __MAIN_H__