From 91bb5e244dac2836b5b96e39e37634396b8e8668 Mon Sep 17 00:00:00 2001 From: serg-bloim Date: Mon, 11 Nov 2019 15:52:58 -0500 Subject: [PATCH 1/2] Fix for spell duration overflow --- postbuild/server.mp | 5 ++ spell_duration_fix.cpp | 104 +++++++++++++++++++++++++++++++++++++++++ srvmgr.def | 8 +++- 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 spell_duration_fix.cpp diff --git a/postbuild/server.mp b/postbuild/server.mp index b145415..79f7ef1 100644 --- a/postbuild/server.mp +++ b/postbuild/server.mp @@ -175,5 +175,10 @@ 0 149 53126B // imp_GMNoLevelDown 0 150 52DA11 // presumably drop all 0 151 5610B6 // quest reward scaling +0 201 53973E // fix spell duration overflow +0 206 53BF9C // fix spell duration overflow +0 203 53C0E1 // fix spell duration overflow +0 204 53C21E // fix spell duration overflow +0 205 53C52A // fix spell duration overflow ////////// 0: jmp, 1: call diff --git a/spell_duration_fix.cpp b/spell_duration_fix.cpp new file mode 100644 index 0000000..801ca1c --- /dev/null +++ b/spell_duration_fix.cpp @@ -0,0 +1,104 @@ +#define FTOL 0x005BF1AC +void __declspec(naked) fix_spell_duration_overflow_0053973E() +{ // 0053973E + __asm + { + cmp eax, 0xFFFF + jle short ret_point1 + mov eax, 0xFFFF +ret_point1: + // restore overridden code begin + mov edx, [ebp-0xC] + mov [edx+10h], ax + // restore overridden code + // jump back + mov edx, 0x00539745 + jmp edx + } +} +// FUNCTIONS BELOW ARE DIFFERENT +void __declspec(naked) fix_spell_duration_overflow() +{ // 53BF9C + __asm + { + mov eax, FTOL + call eax + cmp eax, 0xFFFF + jle short ret_point + mov eax, 0xFFFF +ret_point: + ret + } +} +// FUNCTIONS BELOW ARE DIFFERENT +void __declspec(naked) fix_spell_duration_overflow_0053BFA1() +{ // 0053BFA1 + __asm + { + cmp eax, 0xFFFF + jle short ret_point2 + mov eax, 0xFFFF +ret_point2: + // restore overridden code begin + mov edx, [ebp-0x44] + mov [edx+0x42], ax + // restore overridden code + // jump back + mov edx, 0x0053BFA8 + jmp edx + } +} + +void __declspec(naked) fix_spell_duration_overflow_0053C0E1() +{ // 0053C0E1 + __asm + { + cmp eax, 0xFFFF + jle short ret_point3 + mov eax, 0xFFFF +ret_point3: + // restore overridden code begin + mov edx, [ebp-0x44] + mov [edx+0x42], ax + // restore overridden code + // jump back + mov edx, 0x0053C0E8 + jmp edx + } +} + +void __declspec(naked) fix_spell_duration_overflow_0053C21E() +{ // 0053C21E + __asm + { + cmp eax, 0xFFFF + jle short ret_point4 + mov eax, 0xFFFF +ret_point4: + // restore overridden code begin + mov edx, [ebp-0x44] + mov [edx+0x42], ax + // restore overridden code + // jump back + mov edx, 0x0053C225 + jmp edx + } +} + +void __declspec(naked) fix_spell_duration_overflow_0053C52A() +{ // 0053C52A + __asm + { + cmp eax, 0xFFFF + jle short ret_point5 + mov eax, 0xFFFF +ret_point5: + // restore overridden code begin + mov edx, [ebp-0x44] + mov [edx+0x42], ax + // restore overridden code + // jump back + mov edx, 0x0053C531 + jmp edx + } +} \ No newline at end of file diff --git a/srvmgr.def b/srvmgr.def index 957117a..fcd1fd3 100644 --- a/srvmgr.def +++ b/srvmgr.def @@ -141,4 +141,10 @@ imp_GMNoLevelUp @147 imp_ExtDiplomacy @148 imp_GMNoLevelDown @149 imp_DropAll @150 -imp_ScaleSoftcoreExperienceReward @151 \ No newline at end of file +imp_ScaleSoftcoreExperienceReward @151 +fix_spell_duration_overflow_0053973E @201 +fix_spell_duration_overflow_0053BFA1 @202 +fix_spell_duration_overflow_0053C0E1 @203 +fix_spell_duration_overflow_0053C21E @204 +fix_spell_duration_overflow_0053C52A @205 +fix_spell_duration_overflow @206 From b531f42c8f71b5e3a796a15dcbff9bfa978c255c Mon Sep 17 00:00:00 2001 From: serg-bloim Date: Mon, 11 Nov 2019 16:53:08 -0500 Subject: [PATCH 2/2] Replace 4 functions with a single function. --- postbuild/server.mp | 8 ++-- spell_duration_fix.cpp | 84 ++++-------------------------------------- srvmgr.def | 8 +--- srvmgr.vcxproj | 1 + srvmgr.vcxproj.filters | 3 ++ 5 files changed, 17 insertions(+), 87 deletions(-) diff --git a/postbuild/server.mp b/postbuild/server.mp index 79f7ef1..dd90e43 100644 --- a/postbuild/server.mp +++ b/postbuild/server.mp @@ -176,9 +176,9 @@ 0 150 52DA11 // presumably drop all 0 151 5610B6 // quest reward scaling 0 201 53973E // fix spell duration overflow -0 206 53BF9C // fix spell duration overflow -0 203 53C0E1 // fix spell duration overflow -0 204 53C21E // fix spell duration overflow -0 205 53C52A // fix spell duration overflow +1 202 53BFA1 // fix spell duration overflow +1 202 53C0E1 // fix spell duration overflow +1 202 53C21E // fix spell duration overflow +1 202 53C52A // fix spell duration overflow ////////// 0: jmp, 1: call diff --git a/spell_duration_fix.cpp b/spell_duration_fix.cpp index 801ca1c..7a40c77 100644 --- a/spell_duration_fix.cpp +++ b/spell_duration_fix.cpp @@ -1,12 +1,11 @@ -#define FTOL 0x005BF1AC void __declspec(naked) fix_spell_duration_overflow_0053973E() { // 0053973E __asm { cmp eax, 0xFFFF - jle short ret_point1 + jle short ret_point mov eax, 0xFFFF -ret_point1: +ret_point: // restore overridden code begin mov edx, [ebp-0xC] mov [edx+10h], ax @@ -18,87 +17,18 @@ void __declspec(naked) fix_spell_duration_overflow_0053973E() } // FUNCTIONS BELOW ARE DIFFERENT void __declspec(naked) fix_spell_duration_overflow() -{ // 53BF9C +{ // 0053BFA1 __asm { - mov eax, FTOL - call eax cmp eax, 0xFFFF jle short ret_point mov eax, 0xFFFF ret_point: - ret - } -} -// FUNCTIONS BELOW ARE DIFFERENT -void __declspec(naked) fix_spell_duration_overflow_0053BFA1() -{ // 0053BFA1 - __asm - { - cmp eax, 0xFFFF - jle short ret_point2 - mov eax, 0xFFFF -ret_point2: - // restore overridden code begin mov edx, [ebp-0x44] mov [edx+0x42], ax - // restore overridden code - // jump back - mov edx, 0x0053BFA8 - jmp edx - } -} - -void __declspec(naked) fix_spell_duration_overflow_0053C0E1() -{ // 0053C0E1 - __asm - { - cmp eax, 0xFFFF - jle short ret_point3 - mov eax, 0xFFFF -ret_point3: - // restore overridden code begin - mov edx, [ebp-0x44] - mov [edx+0x42], ax - // restore overridden code - // jump back - mov edx, 0x0053C0E8 - jmp edx - } -} - -void __declspec(naked) fix_spell_duration_overflow_0053C21E() -{ // 0053C21E - __asm - { - cmp eax, 0xFFFF - jle short ret_point4 - mov eax, 0xFFFF -ret_point4: - // restore overridden code begin - mov edx, [ebp-0x44] - mov [edx+0x42], ax - // restore overridden code - // jump back - mov edx, 0x0053C225 - jmp edx - } -} - -void __declspec(naked) fix_spell_duration_overflow_0053C52A() -{ // 0053C52A - __asm - { - cmp eax, 0xFFFF - jle short ret_point5 - mov eax, 0xFFFF -ret_point5: - // restore overridden code begin - mov edx, [ebp-0x44] - mov [edx+0x42], ax - // restore overridden code - // jump back - mov edx, 0x0053C531 - jmp edx + pop eax + inc eax + push eax + ret } } \ No newline at end of file diff --git a/srvmgr.def b/srvmgr.def index fcd1fd3..3b6d26a 100644 --- a/srvmgr.def +++ b/srvmgr.def @@ -142,9 +142,5 @@ imp_ExtDiplomacy @148 imp_GMNoLevelDown @149 imp_DropAll @150 imp_ScaleSoftcoreExperienceReward @151 -fix_spell_duration_overflow_0053973E @201 -fix_spell_duration_overflow_0053BFA1 @202 -fix_spell_duration_overflow_0053C0E1 @203 -fix_spell_duration_overflow_0053C21E @204 -fix_spell_duration_overflow_0053C52A @205 -fix_spell_duration_overflow @206 +fix_spell_duration_overflow_0053973E @201 +fix_spell_duration_overflow @202 diff --git a/srvmgr.vcxproj b/srvmgr.vcxproj index f3a20f3..55e6b1f 100644 --- a/srvmgr.vcxproj +++ b/srvmgr.vcxproj @@ -92,6 +92,7 @@ + diff --git a/srvmgr.vcxproj.filters b/srvmgr.vcxproj.filters index 8f378e2..a034d42 100644 --- a/srvmgr.vcxproj.filters +++ b/srvmgr.vcxproj.filters @@ -129,6 +129,9 @@ Source Files + + Source Files +