Skip to content

Commit

Permalink
add more anticheat
Browse files Browse the repository at this point in the history
  • Loading branch information
metal-crow committed Jul 16, 2019
1 parent d79d6cc commit ab0bc19
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions OverhaulDLL/DarkSoulsOverhaulMod.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
<ItemGroup>
<MASM Include="src\AnimationEditsASM.asm" />
<MASM Include="src\AntiCheat\BossGuardASM.asm" />
<MASM Include="src\AntiCheat\NameCrashPreventASM.asm" />
<MASM Include="src\AntiCheat\NpcGuardASM.asm" />
<MASM Include="src\AntiCheat\TeleBackstabProtectASM.asm" />
<MASM Include="src\BloodborneRallySystemASM.asm" />
Expand Down
3 changes: 3 additions & 0 deletions OverhaulDLL/DarkSoulsOverhaulMod.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,8 @@
<MASM Include="src\XInputUtilASM.asm">
<Filter>Source Files</Filter>
</MASM>
<MASM Include="src\AntiCheat\NameCrashPreventASM.asm">
<Filter>Source Files\AntiCheat</Filter>
</MASM>
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions OverhaulDLL/include/AntiCheat.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ static const uint64_t NpcGuard_offset = 0x25E611;
static const uint64_t BossGuard_offset = 0x3206C5;
static const uint64_t TeleBackstab_getBSAnimation_offset = 0x3AD0E3;
static const uint64_t TeleBackstab_setPlayerLocation_offset = 0x2B9A6A;
static const uint64_t NameCrash_prevention_offset = 0x75E101;

namespace TeleBackstabProtect {
extern bool active;
Expand Down
27 changes: 27 additions & 0 deletions OverhaulDLL/src/AntiCheat/AntiCheat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ extern "C" {
void TeleBackstabProtect_setPosition_check();
alignas(64) float new_player_position[4];
void TeleBackstabProtect_helper_check(float* old_position);

uint64_t NameCrash_prevent_return;
void NameCrash_prevent();
void NameCrash_prevent_helper(wchar_t* name);
}

namespace AntiCheat {
Expand Down Expand Up @@ -74,6 +78,11 @@ void start() {
}
sp::mem::patch_bytes((void*)((uint64_t)dragon_head_params + 7), dragon_params_patched_bytes, 1);
sp::mem::patch_bytes((void*)((uint64_t)dragon_body_params + 7), dragon_params_patched_bytes, 1);

// Start Namecrash prevention anti-cheat
global::cmd_out << " Enabling NameCrash prevention...\n";
write_address = Game::ds1_base + NameCrash_prevention_offset;
sp::mem::code::x64::inject_jmp_14b((void*)write_address, &NameCrash_prevent_return, 0, &NameCrash_prevent);
}

} // namespace AntiCheat
Expand All @@ -98,3 +107,21 @@ void TeleBackstabProtect_helper_check(float* old_position) {
old_position[3] = new_player_position[3];
}
}

void NameCrash_prevent_helper(wchar_t* name) {
size_t i = 0;
wchar_t cur_char = name[i];
while (cur_char != L'\0')
{
//if we locate the starting or ending tokens "<?" or "?>", then replace the </> to nullify it
if (cur_char == L'<' && name[i + 1] == L'?') {
name[i] = L'(';
}
else if (cur_char == L'?' && name[i + 1] == L'>') {
name[i + 1] = L')';
}

i++;
cur_char = name[i];
}
}
57 changes: 57 additions & 0 deletions OverhaulDLL/src/AntiCheat/NameCrashPreventASM.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
_TEXT SEGMENT

extern NameCrash_prevent_return: qword
extern NameCrash_prevent_helper: proc

PUBLIC NameCrash_prevent
NameCrash_prevent PROC

sub rsp, 10h
movdqu [rsp], xmm0
sub rsp, 10h
movdqu [rsp], xmm1
sub rsp, 10h
movdqu [rsp], xmm2
sub rsp, 10h
movdqu [rsp], xmm3
push rax
push rcx
push rdx
push r8
push r9
push r10
push r11
sub rsp, 8 ;stack align?

lea rcx, [rsi+98h] ;ptr to loaded name string
call NameCrash_prevent_helper

add rsp, 8
pop r11
pop r10
pop r9
pop r8
pop rdx
pop rcx
pop rax
movdqu xmm3, [rsp]
add rsp, 10h
movdqu xmm2, [rsp]
add rsp, 10h
movdqu xmm1, [rsp]
add rsp, 10h
movdqu xmm0, [rsp]
add rsp, 10h

;original code
mov rbx, [rsp+30h]
mov rsi, [rsp+38h]
add rsp, 20h

jmp NameCrash_prevent_return

NameCrash_prevent ENDP

_TEXT ENDS

END

0 comments on commit ab0bc19

Please sign in to comment.