Skip to content

Commit

Permalink
v0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
kekekekkek committed May 8, 2024
1 parent 34a0bde commit 4a7ad9b
Show file tree
Hide file tree
Showing 21 changed files with 213 additions and 22 deletions.
Binary file modified Images/Screenshot_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Screenshot_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Screenshot_20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Screenshot_21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions SvenDPP/SvenDPP/DiscordAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ struct structDiscord
char chMsg[256];
ULONG64 uChanId = -1;
cluster* clBot = nullptr;
bool bShowCountry = false;
};

class CDiscordAPI
Expand Down
57 changes: 51 additions & 6 deletions SvenDPP/SvenDPP/DllMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CUtils g_Utils;
CConsole g_Console;
CServerAPI g_ServerAPI;
CDiscordAPI g_DiscordAPI;
CSteamWebAPI g_SteamWebAPI;

UnknownFuncFn OrigUnknownFunc = NULL;
UnknownFuncFn2 OrigUnknownFunc2 = NULL;
Expand All @@ -13,15 +14,57 @@ UnknownFuncFn3 OrigUnknownFunc3 = NULL;
DWORD WINAPI AsyncMessage(LPVOID lpParam)
{
structDiscord* pStructDiscord = (structDiscord*)lpParam;
g_DiscordAPI.SendBotMessage(pStructDiscord->clBot, pStructDiscord->uChanId, pStructDiscord->chMsg);
string strMsg = pStructDiscord->chMsg;

if (strMsg.find(":warning:") == string::npos)
{
if (pStructDiscord->bShowCountry
&& !g_SteamWebAPI.GetAPIKey().empty())
{
string strName = "";
string strCountry = "";

int iFind = strMsg.find_first_of("`");

if (iFind != string::npos)
{
for (int i = (iFind + 1); i < strMsg.length(); i++)
{
if (strMsg[i] == '`')
break;

strName += strMsg[i];
}
}

strCountry = g_SteamWebAPI.GetSteamProfileCountry(g_ServerAPI.GetSteamIdByPlayerName(strName));

if (!strCountry.empty())
{
int iErase = 0;

if (strMsg.find(":speech_balloon:") != string::npos)
iErase = 16;
else if (strMsg.find(":thumbsup:") != string::npos)
iErase = 10;
else if (strMsg.find(":thumbsdown:") != string::npos)
iErase = 12;

strMsg.erase(0, iErase);
strMsg.insert(0, (":flag_" + g_Utils.ToLowerCase(strCountry) + ":"));
}
}
}

g_DiscordAPI.SendBotMessage(pStructDiscord->clBot, pStructDiscord->uChanId, strMsg);
return NULL;
}

void CreateAsyncMessage(const char* chMsg)
{
structDiscord stDiscord = { };

stDiscord.bShowCountry = true;
stDiscord.clBot = g_DiscordAPI.clBot;
stDiscord.uChanId = g_Vars.uChannelId;

Expand All @@ -34,7 +77,7 @@ void CreateAsyncMessage(const char* chMsg)
CloseHandle(hThread);
}

const char* UnknownFuncHook(const char* chStr1, const char* chStr2, int iSize)
const char* __cdecl UnknownFuncHook(const char* chStr1, const char* chStr2, int iSize)
{
if (chStr1[0] == 2)
{
Expand Down Expand Up @@ -64,7 +107,7 @@ const char* UnknownFuncHook(const char* chStr1, const char* chStr2, int iSize)
return OrigUnknownFunc(chStr1, chStr2, iSize);
}

int UnknownFuncHook2(int a1, const char* a2, const char* chPlayerName)
int __cdecl UnknownFuncHook2(int a1, const char* a2, const char* chPlayerName)
{
if (strstr(a2, "has joined the game")
|| strstr(a2, "has left the game"))
Expand All @@ -88,7 +131,7 @@ int UnknownFuncHook2(int a1, const char* a2, const char* chPlayerName)
return OrigUnknownFunc2(a1, a2, chPlayerName);
}

int UnknownFuncHook3(const char* chText, const char* chCvar, const char* chValue)
int __cdecl UnknownFuncHook3(const char* chText, const char* chCvar, const char* chValue)
{
if (strstr(chText, "changed to"))
{
Expand Down Expand Up @@ -162,16 +205,17 @@ void ListenCommands()
clBot.start(st_wait);
}

bool Initialization(HMODULE hModule)
void Initialization(HMODULE hModule)
{
if (!hModule)
return false;
return;

HMODULE hEngine = GetModuleHandleA("hw.dll");
HMODULE hServer = GetModuleHandleA("server.dll");

g_Vars.strToken = g_Utils.GetRegValueString(HKEY_CURRENT_USER, "SOFTWARE\\SvenJector", "Token");
g_Vars.strChannelId = g_Utils.GetRegValueString(HKEY_CURRENT_USER, "SOFTWARE\\SvenJector", "ChannelID");
g_Vars.strSteamAPIKey = g_Utils.GetRegValueString(HKEY_CURRENT_USER, "SOFTWARE\\SvenJector", "SteamAPI");

if (!g_Vars.strChannelId.empty())
g_Vars.uChannelId = _atoi64(g_Vars.strChannelId.c_str());
Expand All @@ -181,6 +225,7 @@ bool Initialization(HMODULE hModule)
&& g_Vars.uChannelId != NULL)
{
g_ServerAPI.Initialization(hServer);
g_SteamWebAPI.SetAPIKey(g_Vars.strSteamAPIKey);

OrigUnknownFunc = (UnknownFuncFn)DetourFunction((PBYTE)((DWORD)hServer + 0x0D6EB0), (PBYTE)UnknownFuncHook);
OrigUnknownFunc2 = (UnknownFuncFn2)DetourFunction((PBYTE)((DWORD)hServer + 0x13DA80), (PBYTE)UnknownFuncHook2);
Expand Down
5 changes: 4 additions & 1 deletion SvenDPP/SvenDPP/Include.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <iostream>
#include <dpp/dpp.h>
#include <Windows.h>
#include <wininet.h>
#include <algorithm>

using namespace std;
Expand All @@ -31,9 +32,11 @@ typedef int(__cdecl* UnknownFuncFn3)(const char* chText, const char* chCvar, con
#include "Console.h"
#include "ServerAPI.h"
#include "DiscordAPI.h"
#include "SteamWebAPI.h"

extern CVars g_Vars;
extern CUtils g_Utils;
extern CConsole g_Console;
extern CServerAPI g_ServerAPI;
extern CDiscordAPI g_DiscordAPI;
extern CDiscordAPI g_DiscordAPI;
extern CSteamWebAPI g_SteamWebAPI;
10 changes: 10 additions & 0 deletions SvenDPP/SvenDPP/ServerAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ void CServerAPI::ClientPrintAll(string strMsg)
pServerFuncs->pfnMessageEnd();
}

string CServerAPI::GetSteamIdByPlayerName(string strName)
{
edict_t* pEdict = g_ServerAPI.pServerFuncs->pfnFindEntityByString(NULL, "netname", strName.c_str());

if (pEdict != NULL)
return g_ServerAPI.pServerFuncs->pfnGetPlayerAuthId(pEdict);

return "";
}

enginefuncs_s* CServerAPI::Initialization(HMODULE hServer)
{
pServerFuncs = (enginefuncs_t*)((DWORD)hServer + 0x563C80);
Expand Down
1 change: 1 addition & 0 deletions SvenDPP/SvenDPP/ServerAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class CServerAPI
public:
void Execute(string strCommand);
void ClientPrintAll(string strMsg);
string GetSteamIdByPlayerName(string strName);
enginefuncs_s* Initialization(HMODULE hServer);
void SetVariable(string strCVar, string strValue);
void RegisterVariable(string strName, string strDefValue);
Expand Down
29 changes: 29 additions & 0 deletions SvenDPP/SvenDPP/SteamWebAPI.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "Include.h"

string CSteamWebAPI::GetAPIKey()
{
return strAPIKey;
}

void CSteamWebAPI::SetAPIKey(string strValue)
{
strAPIKey = strValue;
}

string CSteamWebAPI::GetSteamProfileCountry(string strSteamId)
{
if (!strSteamId.empty())
{
UINT64 uSteamId64 = g_Utils.ToSteamID64(strSteamId);

if (uSteamId64 > 0)
{
string strCountryCode = g_Utils.Parse("loccountrycode", g_Utils.SendGETRequest("api.steampowered.com", ("/ISteamUser/GetPlayerSummaries/v0002/?key=" + strAPIKey + "&steamids=" + to_string(uSteamId64))));

if (!strCountryCode.empty())
return strCountryCode;
}
}

return "";
}
12 changes: 12 additions & 0 deletions SvenDPP/SvenDPP/SteamWebAPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

class CSteamWebAPI
{
public:
string GetAPIKey();
void SetAPIKey(string strValue);
string GetSteamProfileCountry(string strSteamId);

private:
string strAPIKey = "";
};
8 changes: 5 additions & 3 deletions SvenDPP/SvenDPP/SvenDPP.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<ClCompile Include="DiscordAPI.cpp" />
<ClCompile Include="DllMain.cpp" />
<ClCompile Include="ServerAPI.cpp" />
<ClCompile Include="SteamWebAPI.cpp" />
<ClCompile Include="Utils.cpp" />
</ItemGroup>
<ItemGroup>
Expand All @@ -31,6 +32,7 @@
<ClInclude Include="Include.h" />
<ClInclude Include="SDK\Structs.h" />
<ClInclude Include="ServerAPI.h" />
<ClInclude Include="SteamWebAPI.h" />
<ClInclude Include="Utils.h" />
<ClInclude Include="Vars.h" />
</ItemGroup>
Expand Down Expand Up @@ -88,8 +90,8 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(IncludePath)</IncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
<IncludePath>C:\Users\User\Desktop\Random\SvenJect + SvenDPP\v0.4\SvenDPP\SvenDPP\DPP\include\dpp-10.0;$(IncludePath)</IncludePath>
<LibraryPath>C:\Users\User\Desktop\Random\SvenJect + SvenDPP\v0.4\SvenDPP\SvenDPP\DPP\lib\dpp-10.0;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down Expand Up @@ -124,7 +126,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>dpp.lib;WinInet.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
Expand Down
6 changes: 6 additions & 0 deletions SvenDPP/SvenDPP/SvenDPP.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<ClCompile Include="ServerAPI.cpp">
<Filter>CPP</Filter>
</ClCompile>
<ClCompile Include="SteamWebAPI.cpp">
<Filter>CPP</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Console.h">
Expand All @@ -39,6 +42,9 @@
<ClInclude Include="ServerAPI.h">
<Filter>H</Filter>
</ClInclude>
<ClInclude Include="SteamWebAPI.h">
<Filter>H</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="CPP">
Expand Down
72 changes: 72 additions & 0 deletions SvenDPP/SvenDPP/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,39 @@ string CUtils::ToLowerCase(string strText)
return strText;
}

UINT64 CUtils::ToSteamID64(string strSteamId)
{
if (strSteamId.find_last_of(":") != string::npos)
return (((stoull(strSteamId.erase(0, (strSteamId.find_last_of(":") + 1))) << 1) | 0x0110000100000000ULL) + 1);

return NULL;
}

string CUtils::Parse(string strValue, string strText)
{
int iReadFrom = 0;
string strOutput = "";

if (strValue.empty()
|| strText.empty())
return strOutput;

iReadFrom = strText.find(strValue);

if (iReadFrom == string::npos)
return strOutput;

for (int i = (iReadFrom + strValue.length() + 3); i < strText.length(); i++)
{
if (strText[i] == 34)
break;

strOutput += strText[i];
}

return strOutput;
}

vector<string> CUtils::GetArguments(string strCommand)
{
int iArg = 0;
Expand Down Expand Up @@ -97,6 +130,45 @@ int CUtils::IsWhiteSpace(string strText, int iStart, int iEnd)
return 1;
}

string CUtils::SendGETRequest(string strServerName, string strGETRequest)
{
string strResult = "";

HINTERNET hOpen = NULL;
HINTERNET hConnect = NULL;
HINTERNET hRequest = NULL;

hOpen = InternetOpenA(NULL, NULL, NULL, NULL, NULL);

if (hOpen)
{
hConnect = InternetConnectA(hOpen, strServerName.c_str(), INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, NULL, NULL);

if (hConnect)
{
hRequest = HttpOpenRequestA(hConnect, "GET", strGETRequest.c_str(), NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, NULL);

if (hRequest)
{
if (HttpSendRequestA(hRequest, NULL, NULL, NULL, NULL))
{
char chResult[4096];
DWORD dwBytes = NULL;

if (InternetReadFile(hRequest, chResult, sizeof(chResult), &dwBytes))
strResult = chResult;
}
}
}
}

InternetCloseHandle(hOpen);
InternetCloseHandle(hConnect);
InternetCloseHandle(hRequest);

return strResult;
}

string CUtils::GetRegValueString(HKEY hKey, string strSubKey, string strValue)
{
char chValue[500];
Expand Down
3 changes: 3 additions & 0 deletions SvenDPP/SvenDPP/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ class CUtils
int ArgCount(string strCommand);
int ArgCount(vector<string> strArgs);
string ToLowerCase(string strText);
UINT64 ToSteamID64(string strSteamId);
string Parse(string strValue, string strText);
vector<string> GetArguments(string strCommand);
int IsWhiteSpace(string strText, int iStart, int iEnd);
string SendGETRequest(string strServerName, string strGETRequest);
string GetRegValueString(HKEY hKey, string strSubKey, string strValue);
bool SetRegValue(HKEY hKey, string strSubKey, string strKeyName, string strValue);
};
3 changes: 2 additions & 1 deletion SvenDPP/SvenDPP/Vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class CVars
public:
string strToken = "";
string strChannelId = "";

ULONG64 uChannelId = NULL;

string strSteamAPIKey = "";
};
Loading

0 comments on commit 4a7ad9b

Please sign in to comment.