Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
64-bit fixes (#263)
Browse files Browse the repository at this point in the history
* Game: Initial structure fixes

* CI: Update configure step to use x64

* Game: Fix critical objects being null at time of scan

* Update TTFfontSize and Item Stack Magnet CD Removal (#266)

* Game: Initial structure fixes

* Update ttffontsize and item magnet cd

Fix pattern for item magnet CD removal. Update pattern for TTFfontsize. Removed ugly workaround to prevent client hang on speaking with NPCs as it is no longer needed.

---------

Co-authored-by: cursey <[email protected]>

* CEntityList: Fix structures so that iterating entities is more reliable

* Update move to same channel and pet mount CD removal (#267)

* Game: Initial structure fixes

* Update ttffontsize and item magnet cd

Fix pattern for item magnet CD removal. Update pattern for TTFfontsize. Removed ugly workaround to prevent client hang on speaking with NPCs as it is no longer needed.

* Update move to same channel

Fix pattern and byte swap for move to same channel patch

* Update mount/dismount cd removal

Update mount/dismount cd removal

---------

Co-authored-by: cursey <[email protected]>

* EquipmentOverride: Fix for 64-bit

* FieldOfView: re-enable it since it was already fixed

* Fix Range Attack Swap and re-enable curr target (#268)

* Fix Range Attack Swap

Also clean up log entry to match the rest of the mods

* Re-enable Curr Target

all this mod needed to work was updated entity lists

* EquipmentOverride: Fix crash in release mode

* Loader: Load Kanan.dll by default

* FreezeTimeOfDay: Fix for 64-bit

* EnableMultiClient: Fix for 64-bit

* UseDataFolder: Fix for 64-bit

* Update disable waitprocess skill locks (#269)

* Game: Initial structure fixes

* Update ttffontsize and item magnet cd

Fix pattern for item magnet CD removal. Update pattern for TTFfontsize. Removed ugly workaround to prevent client hang on speaking with NPCs as it is no longer needed.

* Update move to same channel

Fix pattern and byte swap for move to same channel patch

* Update mount/dismount cd removal

Update mount/dismount cd removal

* Update disable waitprocess skill locks

Update pattern and desc for disable waitprocess skill locks

---------

Co-authored-by: cursey <[email protected]>

* Update CP Viewer and CC/Logout while talking with NPC.  (#270)

* Game: Initial structure fixes

* Update ttffontsize and item magnet cd

Fix pattern for item magnet CD removal. Update pattern for TTFfontsize. Removed ugly workaround to prevent client hang on speaking with NPCs as it is no longer needed.

* Update move to same channel

Fix pattern and byte swap for move to same channel patch

* Update mount/dismount cd removal

Update mount/dismount cd removal

* Update disable waitprocess skill locks

Update pattern and desc for disable waitprocess skill locks

* Fix CP Viewer

Update pattern for CP Viewer

* Update allow CC and Logout while speaking with NPC fix

Update allow CC and Logout while speaking with NPC fix. Remove channel move denial speedup patch (redundant). Fix issue with being unable to speak with NPC following a CC while speaking with NPC until client restart.

---------

Co-authored-by: cursey <[email protected]>

* Update remove sunglare and remove drop anination (#271)

* Add mounted prop attack and hidden enemy target (#272)

* Game: Initial structure fixes

* Update ttffontsize and item magnet cd

Fix pattern for item magnet CD removal. Update pattern for TTFfontsize. Removed ugly workaround to prevent client hang on speaking with NPCs as it is no longer needed.

* Update move to same channel

Fix pattern and byte swap for move to same channel patch

* Update mount/dismount cd removal

Update mount/dismount cd removal

* Update disable waitprocess skill locks

Update pattern and desc for disable waitprocess skill locks

* Fix CP Viewer

Update pattern for CP Viewer

* Update allow CC and Logout while speaking with NPC fix

Update allow CC and Logout while speaking with NPC fix. Remove channel move denial speedup patch (redundant). Fix issue with being unable to speak with NPC following a CC while speaking with NPC until client restart.

* Add mounted prop attack and hidden enemy target

Added mounted prop attack and hidden enemy target

---------

Co-authored-by: cursey <[email protected]>

* Update don't close title window and enable prop target with skill loaded (#273)

* Game: Initial structure fixes

* Update ttffontsize and item magnet cd

Fix pattern for item magnet CD removal. Update pattern for TTFfontsize. Removed ugly workaround to prevent client hang on speaking with NPCs as it is no longer needed.

* Update move to same channel

Fix pattern and byte swap for move to same channel patch

* Update mount/dismount cd removal

Update mount/dismount cd removal

* Update disable waitprocess skill locks

Update pattern and desc for disable waitprocess skill locks

* Fix CP Viewer

Update pattern for CP Viewer

* Update allow CC and Logout while speaking with NPC fix

Update allow CC and Logout while speaking with NPC fix. Remove channel move denial speedup patch (redundant). Fix issue with being unable to speak with NPC following a CC while speaking with NPC until client restart.

* Add mounted prop attack and hidden enemy target

Added mounted prop attack and hidden enemy target

* Update don't close title window and enable prop target with skill loaded

Update don't close title window and enable prop target with skill loaded patterns.

---------

Co-authored-by: cursey <[email protected]>

* Update client side devcat (#274)

* Game: Initial structure fixes

* Update ttffontsize and item magnet cd

Fix pattern for item magnet CD removal. Update pattern for TTFfontsize. Removed ugly workaround to prevent client hang on speaking with NPCs as it is no longer needed.

* Update move to same channel

Fix pattern and byte swap for move to same channel patch

* Update mount/dismount cd removal

Update mount/dismount cd removal

* Update disable waitprocess skill locks

Update pattern and desc for disable waitprocess skill locks

* Fix CP Viewer

Update pattern for CP Viewer

* Update allow CC and Logout while speaking with NPC fix

Update allow CC and Logout while speaking with NPC fix. Remove channel move denial speedup patch (redundant). Fix issue with being unable to speak with NPC following a CC while speaking with NPC until client restart.

* Add mounted prop attack and hidden enemy target

Added mounted prop attack and hidden enemy target

* Update don't close title window and enable prop target with skill loaded

Update don't close title window and enable prop target with skill loaded patterns.

* Update client side devcat

Update client side devcat pattern

---------

Co-authored-by: cursey <[email protected]>

* Build: Copy Patches.json and Loader.txt to out dir automatically

---------

Co-authored-by: Kohu <[email protected]>
Co-authored-by: Byteretention <[email protected]>
  • Loading branch information
3 people authored Mar 12, 2023
1 parent 8179181 commit b57dccc
Show file tree
Hide file tree
Showing 34 changed files with 616 additions and 810 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
uses: actions/checkout@v2

- name: Configure
run: cmake -B build -A Win32
run: cmake -B build -A x64

- name: Build
run: cmake --build build --config Release --parallel
Expand Down
24 changes: 17 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ endif()

project(Kanan)

set(VCPKG_TARGET_TRIPLET x86-windows-static)
set(VCPKG_TARGET_TRIPLET x64-windows-static)

if(CMKR_ROOT_PROJECT AND NOT CMKR_DISABLE_VCPKG)
include(FetchContent)
Expand Down Expand Up @@ -197,16 +197,12 @@ list(APPEND Kanan_SOURCES
"Kanan/LoginScreen.hpp"
"Kanan/Mabinogi.hpp"
"Kanan/Mabinogi/CAccount.hpp"
"Kanan/Mabinogi/CAccountPtr.hpp"
"Kanan/Mabinogi/CCharacter.hpp"
"Kanan/Mabinogi/CEntityList.hpp"
"Kanan/Mabinogi/CEntityListPtr.hpp"
"Kanan/Mabinogi/CItem.hpp"
"Kanan/Mabinogi/CRenderer.hpp"
"Kanan/Mabinogi/CRendererPtr.hpp"
"Kanan/Mabinogi/CString.hpp"
"Kanan/Mabinogi/CWorld.hpp"
"Kanan/Mabinogi/CWorldPtr.hpp"
"Kanan/Mabinogi/Matrix4x4.hpp"
"Kanan/Mabinogi/Vector3.hpp"
"Kanan/Mabinogi/Vector4.hpp"
Expand Down Expand Up @@ -257,6 +253,13 @@ set_target_properties(Kanan PROPERTIES
MultiThreaded$<$<CONFIG:Debug>:Debug>
)

# Copy Kanan/Patches.json to the output directory.
add_custom_command(TARGET Kanan POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/Kanan/Patches.json
$<TARGET_FILE_DIR:Kanan>
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)

Expand Down Expand Up @@ -291,14 +294,21 @@ target_link_libraries(Loader PRIVATE
)

target_link_options(Loader PRIVATE
"/MANIFESTUAC:level=requireAdministrator"
"/MANIFESTUAC:level='requireAdministrator'"
)

set_target_properties(Loader PROPERTIES
MSVC_RUNTIME_LIBRARY
MultiThreaded$<$<CONFIG:Debug>:Debug>
)

# Copy Loader/Loader.txt to the output directory
add_custom_command(TARGET Loader POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/Loader/Loader.txt
$<TARGET_FILE_DIR:Loader>
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)

Expand Down Expand Up @@ -367,7 +377,7 @@ target_link_libraries(Launcher PRIVATE
)

target_link_options(Launcher PRIVATE
"/MANIFESTUAC:level=requireAdministrator"
"/MANIFESTUAC:level='requireAdministrator'"
)

set_target_properties(Launcher PROPERTIES
Expand Down
6 changes: 3 additions & 3 deletions Kanan/AutoChangeChannels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ void AutoChangeChannels::onFrame() {
}

auto& characters = ents->characters;
auto node = characters.root;
auto node = *characters.root;

for (uint32_t i = 0; i <= characters.count && node != nullptr; ++i, node = node->next) {
auto character = (KCharacter*)node->entry->character;
for (uint32_t i = 0; i < characters.count && node != nullptr; ++i, node = node->next) {
auto character = (KCharacter*)node->character;

if (character == nullptr) {
continue;
Expand Down
6 changes: 5 additions & 1 deletion Kanan/CookingMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace kanan {


//the asm we want to inject
#if 0
void __declspec(naked) HookForCooking()
{
__asm
Expand All @@ -45,8 +46,11 @@ namespace kanan {
ret

}

}
#else
void HookForCooking() {
}
#endif


//the code i use for injecting stuff
Expand Down
9 changes: 5 additions & 4 deletions Kanan/EnableMultiClient.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <imgui.h>

#include <Scan.hpp>
#include <Utility.hpp>

#include "Log.hpp"
#include "EnableMultiClient.hpp"
Expand All @@ -14,12 +15,12 @@ namespace kanan {
{
log("Entering EnableMultiClient.");

auto address = scan("client.exe", "B9 ? ? ? ? E8 ? ? ? ? 84 C0 74 ? 8B 0D ? ? ? ? 8D 45 C0");
auto address = scan("client.exe", "48 8D 0D ? ? ? ? E8 ? ? ? ? 84 C0 74 ? 48 8B 0D ? ? ? ? E8 ? ? ? ?");

if (address) {
log("Got EnableMultiClient %p", *address);

m_handlePtr = (HANDLE**)(*address + 1);
m_handlePtr = (HANDLE*)rel_to_abs(*address + 3);
}
else {
log("Failed to find EnableMultiClient address.");
Expand Down Expand Up @@ -72,12 +73,12 @@ namespace kanan {

log("Toggling EnableMultiClient...");

if (SetHandleInformation(**m_handlePtr, HANDLE_FLAG_PROTECT_FROM_CLOSE, 0) == FALSE) {
if (SetHandleInformation(*m_handlePtr, HANDLE_FLAG_PROTECT_FROM_CLOSE, 0) == FALSE) {
log("Failed to SetHandleInformation on the handle %p", *m_handlePtr);
return;
}

if (CloseHandle(**m_handlePtr) == FALSE) {
if (CloseHandle(*m_handlePtr) == FALSE) {
log("Failed to CloseHandle on the handle %p", *m_handlePtr);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Kanan/EnableMultiClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace kanan {

private:
bool m_isEnabled;
HANDLE** m_handlePtr;
HANDLE* m_handlePtr;

void apply();
};
Expand Down
12 changes: 6 additions & 6 deletions Kanan/EntityViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ namespace kanan {

auto& characters = entityList->characters;
auto highestIndex = characters.count;
auto node = characters.root;
auto node = *characters.root;

for (uint32_t i = 0; i <= highestIndex && node != nullptr; ++i, node = node->next) {
auto character = (KCharacter*)node->entry->character;
for (uint32_t i = 0; i < highestIndex && node != nullptr; ++i, node = node->next) {
auto character = (KCharacter*)node->character;

if (character == nullptr || !character->getID()) {
continue;
Expand Down Expand Up @@ -114,10 +114,10 @@ namespace kanan {

auto& items = entityList->items;
auto highestIndex = items.count;
auto node = items.root;
auto node = *items.root;

for (uint32_t i = 0; i <= highestIndex && node != nullptr; ++i, node = node->next) {
auto item = (KItem*)node->entry->item;
for (uint32_t i = 0; i < highestIndex && node != nullptr; ++i, node = node->next) {
auto item = (KItem*)node->item;

if (item == nullptr || !item->getID()) {
continue;
Expand Down
10 changes: 5 additions & 5 deletions Kanan/EquipmentOverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ namespace kanan {
m_equipmentOverrides[17].name = "Accessory 2";
m_equipmentOverrides[18].name = "Tail";

if (auto call_address = scan("client.exe", "E8 ? ? ? ? C7 45 FC ? ? ? ? 8D 4D C0 E8 ? ? ? ? 8B 45 B8")) {
if (auto call_address = scan("client.exe", "E8 ? ? ? ? 90 E9 ? ? ? ? 44 39 B6 A4 1B 00 00")) {
log("[EquipmentOverride] Found address of call setEquipmentInfo %p", *call_address);

auto set_equip_info = rel_to_abs(*call_address + 1);
Expand Down Expand Up @@ -247,7 +247,7 @@ namespace kanan {
}
}

void EquipmentOverride::hookedSetEquipmentInfo(CCharacter::CEquipment* equipment, uint32_t EDX, int inventoryID, int itemID, int a4, int a5, uint32_t* color, int a7, int * a8, int a9, int a10, int * a11) {
void EquipmentOverride::hookedSetEquipmentInfo(CCharacter::CEquipment* equipment,int inventoryID, int itemID, int a4, int a5, uint32_t* color, uint64_t a7, int * a8, int a9, int a10, int * a11) {
auto orig = (decltype(hookedSetEquipmentInfo)*)g_equipmentOverride->m_setEquipmentInfoHook->getOriginal();
auto equipmentSlot = convertInventoryIDToEquipmentSlot(inventoryID);

Expand All @@ -264,12 +264,12 @@ namespace kanan {
auto localCharacter = game->getLocalCharacter();

if (localCharacter == nullptr || equipment != localCharacter->equipment) {
return orig(equipment, EDX, inventoryID, itemID, a4, a5, color, a7, a8, a9, a10, a11);
return orig(equipment, inventoryID, itemID, a4, a5, color, a7, a8, a9, a10, a11);
}

// Filter out inventoryIDs.
if (equipmentSlot < 0 || equipmentSlot >= (int)g_equipmentOverride->m_equipmentOverrides.size()) {
return orig(equipment, EDX, inventoryID, itemID, a4, a5, color, a7, a8, a9, a10, a11);
return orig(equipment, inventoryID, itemID, a4, a5, color, a7, a8, a9, a10, a11);
}

auto& overrideInfo = g_equipmentOverride->m_equipmentOverrides[equipmentSlot];
Expand All @@ -292,6 +292,6 @@ namespace kanan {
log("[EquipmentOverride] Item overwritten!");
}

return orig(equipment, EDX, inventoryID, itemID, a4, a5, color, a7, a8, a9, a10, a11);
return orig(equipment, inventoryID, itemID, a4, a5, color, a7, a8, a9, a10, a11);
}
}
2 changes: 1 addition & 1 deletion Kanan/EquipmentOverride.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ namespace kanan {
std::unique_ptr<FunctionHook> m_setEquipmentInfoHook;
bool m_isNoFlashyEquipmentEnabled;

static void __fastcall hookedSetEquipmentInfo(CCharacter::CEquipment* equipment, uint32_t EDX, int inventoryID, int itemID, int a4, int a5, uint32_t* color, int a7, int* a8, int a9, int a10, int* a11);
static void hookedSetEquipmentInfo(CCharacter::CEquipment* equipment, int inventoryID, int itemID, int a4, int a5, uint32_t* color, uint64_t a7, int* a8, int a9, int a10, int* a11);
};
}
2 changes: 1 addition & 1 deletion Kanan/FreezeTimeOfDay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace kanan {

g_freezeTimeOfDay = this;

auto address = scan("client.exe", "55 8B EC 8B 01 F3 0F 10 45 08 F3 0F 11 40 0C");
auto address = scan("client.exe", "48 8B 01 F3 0F 11 48 18");

if (address) {
log("[FreezeTimeOfDay] Found address for setTimeOfDay %p", *address);
Expand Down
89 changes: 33 additions & 56 deletions Kanan/Game.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <Scan.hpp>
#include <String.hpp>
#include <Utility.hpp>

#include "Log.hpp"
#include "Game.hpp"
Expand All @@ -8,59 +9,67 @@ using namespace std;

namespace kanan {
Game::Game()
: m_rendererPtr{ nullptr },
m_entityListPtr{ nullptr },
m_worldPtr{nullptr},
m_accountPtr{nullptr}
: m_renderer{ nullptr },
m_entityList{ nullptr },
m_world{nullptr},
m_account{nullptr}
{
log("Entering Game constructor.");

// Find the games global renderer pointer.
auto rendererAddress = scan("client.exe", "8B 0D ? ? ? ? 8D 45 DC 6A ? 6A ? 50");
auto rendererAddress = scan("client.exe", "48 8B 0D ? ? ? ? E8 ? ? ? ? 84 C0 74 ? C7 07 ? ? ? ? 32 C0");

if (rendererAddress) {
m_rendererPtr = *(CRendererPtr**)(*rendererAddress + 2);
do {
m_renderer = (CRenderer**)rel_to_abs(*rendererAddress + 3);
} while (*m_renderer == nullptr);

log("Got CRendererPtr %p", m_rendererPtr);
log("Got CRenderer %p", *m_renderer);
}
else {
error("Failed to find address of CRendererPtr.");
error("Failed to find address of CRenderer.");
}

// Find the games global entity list pointer.
auto entityListAddress = scan("client.exe", "8B 0D ? ? ? ? 56 FF 75 08 E8 ? ? ? ? 85 C0 0F 84 ? ? ? ?");
auto entityListAddress = scan("client.exe", "48 8B 0D ? ? ? ? E8 ? ? ? ? 48 85 C0 0F 84 ? ? ? ? 48 8B 0D ? ? ? ? 48 8B 91 60 01 00 00 E8 ? ? ? ?");

if (entityListAddress) {
m_entityListPtr = *(CEntityListPtr**)(*entityListAddress + 2);
do {
m_entityList = (CEntityList**)rel_to_abs(*entityListAddress + 3);
} while (*m_entityList == nullptr);

log("Got CEntityListPtr %p", m_entityListPtr);
log("Got CEntityList %p", *m_entityList);
}
else {
error("Failed to find CEntityListPtr.");
error("Failed to find CEntityList.");
}

// Find the games global world pointer.
auto worldAddress = scan("client.exe", "A1 ? ? ? ? 8B 48 1C E8 ? ? ? ? 0F B6 C0");
auto worldAddress = scan("client.exe", "48 8B 0D ? ? ? ? E8 ? ? ? ? 84 C0 0F 85 ? ? ? ? 48 8B 86 A0 01 00 00");

if (worldAddress) {
m_worldPtr = *(CWorldPtr**)(*worldAddress + 1);
do {
m_world = (CWorld**)rel_to_abs(*worldAddress + 3);
} while (*m_world == nullptr);

log("Got CWorldPtr %p", m_worldPtr);
log("Got CWorld %p", *m_world);
}
else {
error("Failed to find CWorldPtr.");
error("Failed to find CWorld.");
}

// Find the games global account pointer.
auto accountAddress = scan("client.exe", "8B 0D ? ? ? ? 6A ? 6A ? 53 E8 ? ? ? ? 8B 06");
auto accountAddress = scan("client.exe", "48 8B 0D ? ? ? ? E8 ? ? ? ? 84 C0 74 ? 49 8B CE E8 ? ? ? ? 84 C0 75 ? 49 8B 06");

if (accountAddress) {
m_accountPtr = *(CAccountPtr**)(*accountAddress + 2);
do {
m_account = (CAccount**)rel_to_abs(*accountAddress + 3);
} while (*m_account == nullptr);

log("Got CAccountPtr %p", m_accountPtr);
log("Got CAccount %p", *m_account);
}
else {
error("Failed to find CAccountPtr.");
error("Failed to find CAccount.");
}

log("Leaving Game constructor.");
Expand All @@ -77,10 +86,10 @@ namespace kanan {
// ID.
auto& characters = entityList->characters;
auto highestIndex = characters.count;
auto node = characters.root;
auto node = *characters.root;

for (uint32_t i = 0; i <= highestIndex && node != nullptr; ++i, node = node->next) {
auto character = (KCharacter*)node->entry->character;
for (uint32_t i = 0; i < highestIndex && node != nullptr; ++i, node = node->next) {
auto character = (KCharacter*)node->character;

if (character == nullptr) {
continue;
Expand Down Expand Up @@ -149,36 +158,4 @@ namespace kanan {

cc(account, &val2, 0, 0);
}

CRenderer* Game::getRenderer() const {
if (m_rendererPtr == nullptr || m_rendererPtr->renderer == nullptr) {
return nullptr;
}

return m_rendererPtr->renderer;
}

CEntityList* Game::getEntityList() const {
if (m_entityListPtr == nullptr || m_entityListPtr->entityList == nullptr) {
return nullptr;
}

return m_entityListPtr->entityList;
}

CWorld* Game::getWorld() const {
if (m_worldPtr == nullptr || m_worldPtr->world == nullptr) {
return nullptr;
}

return m_worldPtr->world;
}

CAccount* Game::getAccount() const {
if (m_accountPtr == nullptr || m_accountPtr->account == nullptr) {
return nullptr;
}

return m_accountPtr->account;
}
}
}
Loading

0 comments on commit b57dccc

Please sign in to comment.