Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
144
GameTools/NeoRylClient/StringFilter.cpp
Normal file
144
GameTools/NeoRylClient/StringFilter.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
// StringFilter.cpp: implementation of the CStringFilter class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <algorithm>
|
||||
#include <Utility/Compress/MiniLZO/MiniLZOWrapper.h>
|
||||
#include <Network/XORCrypt/XORCrypt.h>
|
||||
#include <Utility/Resource/EnsureCleanup.h>
|
||||
//#include "MemUtils.h"
|
||||
//#include "..\\NeoRylClient\\Network\\Compress\\Compress.h"
|
||||
//#include "..\\NeoRylClient\\Network\\Crypto\\DemonCryptoFunctions.h"
|
||||
|
||||
#include "StringFilter.h"
|
||||
#include "windows.h"
|
||||
#include "ScriptEngine.h"
|
||||
#include <string.h>
|
||||
|
||||
CStringFilter g_StringFilter;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CStringFilter::CStringFilter()
|
||||
{
|
||||
m_dwStringCount = 0;
|
||||
m_dwPhraseCount = 0;
|
||||
m_lpSearched = NULL;
|
||||
}
|
||||
|
||||
CStringFilter::~CStringFilter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CStringFilter::Filter(char *strTarget)
|
||||
{
|
||||
WCHAR strWideTarget[300], strWideString[300], strWidePhrase[300];
|
||||
int nBufferSize = 300;
|
||||
int nWideTargetLen, nWideStringLen, nWidePhraseLen;
|
||||
long i, j, k;
|
||||
BOOL bNext;
|
||||
|
||||
MultiByteToWideChar(CP_ACP, 0, strTarget, strlen(strTarget) + 1, strWideTarget, nBufferSize);
|
||||
nWideTargetLen = wcslen(strWideTarget);
|
||||
|
||||
for(i = 0; i < m_dwStringCount; i++)
|
||||
{
|
||||
MultiByteToWideChar(CP_ACP, 0, m_strString[i], strlen(m_strString[i]) + 1, strWideString, nBufferSize);
|
||||
nWideStringLen = wcslen(strWideString);
|
||||
|
||||
j = 0;
|
||||
|
||||
if(nWideTargetLen >= nWideStringLen)
|
||||
{
|
||||
do
|
||||
{
|
||||
bNext = TRUE;
|
||||
for(k = 0; k < m_dwPhraseCount; k++)
|
||||
{
|
||||
MultiByteToWideChar(CP_ACP, 0, m_strPhrase[k], strlen(m_strPhrase[k]) + 1, strWidePhrase, nBufferSize);
|
||||
nWidePhraseLen = wcslen(strWidePhrase);
|
||||
|
||||
if(!wcsncmp(&strWideTarget[j], strWidePhrase, nWidePhraseLen))
|
||||
{
|
||||
j += nWidePhraseLen;
|
||||
bNext = FALSE;
|
||||
break;
|
||||
}
|
||||
}/**/
|
||||
|
||||
if(bNext)
|
||||
{
|
||||
if(!wcsncmp(&strWideTarget[j], strWideString, nWideTargetLen))
|
||||
{
|
||||
m_lpSearched = m_strString[i];
|
||||
return false;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
} while(j <= (nWideTargetLen - nWideStringLen));
|
||||
}
|
||||
}
|
||||
|
||||
m_lpSearched = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStringFilter::Load(const char *strScriptFile)
|
||||
{
|
||||
m_dwPhraseCount = 2;
|
||||
strcpy(m_strPhrase[0], "¾Æºü");
|
||||
strcpy(m_strPhrase[1], "¿Àºü");
|
||||
|
||||
HANDLE hFile = CreateFile(strScriptFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CEnsureCloseHandle readFile(hFile);
|
||||
|
||||
DWORD dwRead = 0;
|
||||
DWORD dwFileHighSize = 0;
|
||||
DWORD dwFileSize = GetFileSize(hFile, &dwFileHighSize);
|
||||
|
||||
char* lpAllocated = new char[dwFileSize];
|
||||
|
||||
CEnsureDeleteArray<char> allocated(lpAllocated);
|
||||
|
||||
if(FALSE == ReadFile(hFile, lpAllocated, dwFileSize, &dwRead, NULL))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
char *lpProtoType = NULL;
|
||||
|
||||
DWORD dwHeaderSize = sizeof(DWORD) + *reinterpret_cast<DWORD*>(lpAllocated) + sizeof(DWORD);
|
||||
char* lpBuffer = new char[*reinterpret_cast<DWORD*>(lpAllocated + dwHeaderSize - sizeof(DWORD))];
|
||||
if (NULL == lpBuffer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CEnsureDeleteArray<char> buffer(lpBuffer);
|
||||
|
||||
char* lpBufferStartPointer = lpBuffer;
|
||||
DWORD dwBufferSize = 1000000;
|
||||
|
||||
CMiniLZOCompress::Decompress(lpAllocated + dwHeaderSize, dwFileSize - dwHeaderSize, lpBuffer, &dwBufferSize);
|
||||
CXORCrypt::GetInstance().DecodeHeader(lpBuffer, dwBufferSize, 0, 1);
|
||||
|
||||
while (dwBufferSize > 0)
|
||||
{
|
||||
lpProtoType = reinterpret_cast<char *>(lpBuffer);
|
||||
strncpy(m_strString[m_dwStringCount], lpProtoType, sizeof(char[15]));
|
||||
m_dwStringCount++;
|
||||
|
||||
dwBufferSize -= sizeof(char[15]);
|
||||
lpBuffer += sizeof(char[15]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user