Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kirc exp #3

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
742 changes: 30 additions & 712 deletions .gitignore

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Libs/SDL/SDL2-2.0.8/VisualC/SDL/SDL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
Expand Down
4 changes: 2 additions & 2 deletions Libs/SDL/SDL2_ttf-2.0.12/VisualC/SDL_ttf_VS2012.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
Expand Down
4 changes: 2 additions & 2 deletions Libs/SDL/VQA/VQA_XCC.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
Expand Down Expand Up @@ -95,7 +95,7 @@
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
Expand Down
2 changes: 0 additions & 2 deletions Libs/SDL/freetype-2.5.5/objs/README

This file was deleted.

4 changes: 2 additions & 2 deletions Libs/lpng151/projects/visualc71/libpng.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='LIB Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='LIB Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL VB|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
Expand Down
4 changes: 2 additions & 2 deletions Libs/lpng151/projects/visualc71/zlib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='LIB Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='LIB Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
Expand Down
4 changes: 2 additions & 2 deletions Libs/luasocket/socket.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
Expand Down
7 changes: 4 additions & 3 deletions SDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

LPDIRECTSOUND* noxDsound = (LPDIRECTSOUND*)0x83A1AC;

// Do not load SDL because this may cause conflict between new SDL patch and ours
bool SDL_enabled = false;

extern std::string getGameDirectory();
Expand Down Expand Up @@ -767,11 +768,11 @@ extern void InjectOffs(DWORD Addr, void *Fn);
extern void InjectData(DWORD offset, byte* buff, size_t size);
void initSDL()
{
// Get the players settings
ReadConfigFile();

if (SDL_enabled)
{
// Get the players settings
ReadConfigFile();

InjectJumpTo((DWORD)pTrueMessageLoop, &MessageLoop);
InjectJumpTo((DWORD)pTrueMouseInit, &MouseInit);
InjectJumpTo((DWORD)pTrueGetMouseData, &GetMouseData);
Expand Down
5 changes: 2 additions & 3 deletions UniMod2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -101,7 +101,6 @@
</ClCompile>
<Link>
<AdditionalDependencies>Shlwapi.lib;User32.lib;Psapi.lib;libcmt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>..\$(ProjectName).dll</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
Expand Down
1 change: 0 additions & 1 deletion admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,6 @@ namespace
}
return result;
}

}
extern "C" void adminInit(lua_State *L);
extern void authInit(lua_State *L);
Expand Down
60 changes: 60 additions & 0 deletions authManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,15 @@ namespace
unsigned char lhash[20];
sha.GetHash(lhash);
sha.Reset();

if(authData.find(sha1hash(lhash))!=authData.end() && strncmp(authData[sha1hash(lhash)].login, login, 50)==0 && authData[sha1hash(lhash)].isActive==true)
{
sha.Update((const unsigned char*)pass, strlen(pass));
sha.Final();
unsigned char phash[20];
sha.GetHash(phash);
sha.Reset();

if(strncmp((char*)authData[sha1hash(lhash)].phash, (char*)phash, 20)==0)
return true;
}
Expand Down Expand Up @@ -788,4 +790,62 @@ void authCheckDelayed(byte playerIdx, char* pass)
notLoggedIn.insert(pair<byte, char*>(playerIdx, pass));
if(specialAuthRemote)
notLoggedInRemote.push(playerIdx);
}

// Process //auth tokens both from chat and console.
// If true is returned from this function, the message is filtered out completely.
bool processSpecialAuth(byte playerIdx, char* message)
{
char authCmd[] = "//auth ";
char msgUsefulData[255];
memset(msgUsefulData, 0, 1);
// Trim //auth part
int mlen = strlen(message);
int alen = strlen(authCmd);
int start = 0;
if (strncmp(message, authCmd, alen) == 0)
{
start += alen;
mlen -= start;
}
if (mlen < 0)
mlen = 0;
strncpy(msgUsefulData, &message[start], mlen);

if (playerIdx!=0x1F && authorisedState[playerIdx]>=0 && authorisedState[playerIdx]<4)
{
switch(authorisedState[playerIdx])
{
case 0:
case 3:
return true;
break;
case 1:
// ��� ������ ����� ������
{
char* tmp = new char[255];
strcpy_s(tmp, 255, msgUsefulData);
// Copy string to heap allocated ptr; it will be freed later in updateAuthDBProcess() -> authentificate()

authorisedLogins[playerIdx] = tmp;
authorisedState[playerIdx]++;
authSendWelcomeMsg[playerIdx] = -1;

return true;
}
break;
case 2:
{
// ���� �������� ������ ������� �������������� �� http

authorisedState[playerIdx]++;
authSendWelcomeMsg[playerIdx] = -1;
authCheckDelayed(playerIdx, msgUsefulData);

return true;
}
break;
}
}
return false;
}
71 changes: 61 additions & 10 deletions bugsAndChips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,52 @@ void topicOverrideInit()
//InjectData(0x0040C29B, nop, 2);
}

void bugsInit()
int (__cdecl *netOnPacketRecvServ)(int playerId, char *packet, int length);
// Validates incoming player data in order to prevent rogue players crashing the server
// (this packet always comes singular, in contrast to regular MSG_* packets)
int __cdecl netOnPacketRecvServ_Hook(int playerId, char *packet, int length)
{
if (*packet == 0x20 )
{
if (length < 0x9A)
{
char test[60];
sprintf(test,"[UniMod] Wrong player data len detected: 0x%X", length);
conPrintI(test);
// Go away, little bugger
return 0;
}

packet++;
// Check if nickname starts with invalid character
if (packet[0] <= 0x1F)
{
wcscpy((wchar_t*)packet, L"Jack\0");
conPrintI("[UniMod] Bugged player name was detected!");
}

// Check if player class is invalid
if (packet[0x42] >= 3)
{
packet[0x42] = 0;
conPrintI("[UniMod] Bugged player class was detected!");
}

// Check if player object requested by client is invalid
if (packet[0x43] > 0)
{
packet[0x43] = 0;
conPrintI("[UniMod] Bugged player object was detected!");
}
packet--;
}

// Carry on
return netOnPacketRecvServ(playerId, packet, length);
}

void bugsInit()
{
ASSIGN(wndSummonUsed,0x00716E88);

ASSIGN(creatureSummonCommandAll,0x005B4080);
Expand All @@ -369,18 +412,26 @@ void bugsInit()
ASSIGN(wndSummonCreateList,0x004C2560);
ASSIGN(cliSummondWndLoad,0x004C2E50);


InjectJumpTo(0x004E1C8A,&asmDeathBallBugGs);
InjectJumpTo(0x004E1BD6,&asmDeathBallBugSh);

InjectJumpTo(0x004C2BC7,&asmConjSummonEnotherCmp); // ������ ����������� ���
InjectJumpTo(0x004C2BB6,&asmConjSummonDo); // ������ ������ ������ ���� 2 ���������� �����
InjectJumpTo(0x0049179A,&asmConjSummonCreate);
InjectJumpTo(0x004C2ACC,&asmConjSummonDoAll);
InjectJumpTo(0x004C3147,&asmConjSummonDieOrBanish);
InjectJumpTo(0x004C1FA1,&asmConjSummonLoadWnd);
bool conjurerSummonCmdImprovements=false;
if (conjurerSummonCmdImprovements)
{
InjectJumpTo(0x004C2BC7,&asmConjSummonEnotherCmp); // ������ ����������� ���
InjectJumpTo(0x004C2BB6,&asmConjSummonDo); // ������ ������ ������ ���� 2 ���������� �����
InjectJumpTo(0x0049179A,&asmConjSummonCreate);
InjectJumpTo(0x004C2ACC,&asmConjSummonDoAll);
InjectJumpTo(0x004C3147,&asmConjSummonDieOrBanish);
InjectJumpTo(0x004C1FA1,&asmConjSummonLoadWnd);
}

// InjectJumpTo(0x0052C7CD,&asmFixCastFireball);
//InjectJumpTo(0x0052C7CD,&asmFixCastFireball);

topicOverrideInit();
bool filterPlayerJoinData=true; // TODO: convert all similar hardcoded-switches into #defines in a separate file
if (filterPlayerJoinData)
{
InjectOffs(0x4DEC40 + 1, &netOnPacketRecvServ_Hook);
}
ASSIGN(netOnPacketRecvServ, 0x51BAD0);
}
2 changes: 0 additions & 2 deletions console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ namespace
lua_settop(L,Top);
}



int __declspec(naked) onPrintConsoleTrap()
{
__asm
Expand Down
12 changes: 6 additions & 6 deletions libVer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <stdio.h>
#include <objbase.h>

extern void injectCon();
extern "C" void __cdecl onNetPacket(BYTE *&BufStart,BYTE *E);
extern "C" void __cdecl onNetPacket2(BYTE *&BufStart,BYTE *E, BYTE *MyPlayer, BYTE *MyUc);
extern void initStepTwo();
extern "C" void __cdecl onNetPacketClient(BYTE *&BufStart,BYTE *E);
extern "C" void __cdecl onNetPacketServer(BYTE *&BufStart,BYTE *E, BYTE *MyPlayer, BYTE *MyUc);
extern "C" int __cdecl playerOnTrySpell(bigUnitStruct *Unit,byte *Uc,spellPacket *Pckt);
extern "C" void conSendToServer(const char *Cmd);

Expand Down Expand Up @@ -38,7 +38,7 @@ namespace
push ebx
lea eax, [esp+8-4]
push eax
call onNetPacket
call onNetPacketClient
add esp, 8
pop ebp
cmp ebp, ebx
Expand All @@ -64,7 +64,7 @@ namespace
lea eax, [esp+0Ch-4]
push ecx
push eax
call onNetPacket2
call onNetPacketServer
add esp, 10h
pop esi
cmp esi, [esp+2Ch]
Expand Down Expand Up @@ -147,7 +147,7 @@ namespace

lua_pushcclosure(L, delayedConL, 0);
lua_setfield(L, LUA_REGISTRYINDEX, "delayedCon");
injectCon();
initStepTwo();

__asm
{
Expand Down
Loading