[QuickPatch] Fix invalid name check

This commit is contained in:
momo5502 2018-11-19 21:08:23 +01:00
parent 3a9d8da1f1
commit b2cb5f7394
2 changed files with 7 additions and 7 deletions

View File

@ -119,13 +119,15 @@ namespace Components
} }
} }
int QuickPatch::InvalidNameCheck(char *dest, char *source, int size) bool QuickPatch::InvalidNameCheck(char *dest, char *source, int size)
{ {
strncpy(dest, source, size - 1); strncpy(dest, source, size - 1);
dest[size - 1] = 0; dest[size - 1] = 0;
for (int i = 0; i < size - 1; i++) for (int i = 0; i < size - 1; i++)
{ {
if (!dest[i]) break;
if (dest[i] > 125 || dest[i] < 32) if (dest[i] > 125 || dest[i] < 32)
{ {
return false; return false;
@ -133,7 +135,6 @@ namespace Components
} }
return true; return true;
} }
__declspec(naked) void QuickPatch::InvalidNameStub() __declspec(naked) void QuickPatch::InvalidNameStub()
@ -143,11 +144,10 @@ namespace Components
__asm __asm
{ {
call InvalidNameCheck; call InvalidNameCheck;
cmp eax, 1; test al, al
jne invalidName; jnz returnSafe;
invalidName:
pushad; pushad;
push 1; push 1;
push kick_reason; push kick_reason;
@ -157,7 +157,7 @@ namespace Components
add esp, 12; add esp, 12;
popad; popad;
// return returnSafe:
push 0x00401988; push 0x00401988;
retn; retn;
} }

View File

@ -27,7 +27,7 @@ namespace Components
static void JavelinResetHookStub(); static void JavelinResetHookStub();
static int QuickPatch::InvalidNameCheck(char *dest, char *source, int size); static bool QuickPatch::InvalidNameCheck(char *dest, char *source, int size);
static void QuickPatch::InvalidNameStub(); static void QuickPatch::InvalidNameStub();
}; };
} }