Skip to content

Commit

Permalink
Added better printf implementation as the other one could lead to cra…
Browse files Browse the repository at this point in the history
…shs on some CPUs
  • Loading branch information
BerndSchmecka committed Sep 11, 2020
1 parent d5c2414 commit 6129bbb
Show file tree
Hide file tree
Showing 6 changed files with 1,050 additions and 4 deletions.
2 changes: 2 additions & 0 deletions TS3Hook/TS3Hook.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
<ClInclude Include="include\ts3_functions.h" />
<ClInclude Include="main.h" />
<ClInclude Include="PatchTools.h" />
<ClInclude Include="printf.h" />
<ClInclude Include="util.h" />
</ItemGroup>
<ItemGroup>
Expand All @@ -165,6 +166,7 @@
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="PatchTools.cpp" />
<ClCompile Include="printf.c" />
<ClCompile Include="Ts3Plugin.cpp" />
<ClCompile Include="util.cpp" />
</ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions TS3Hook/TS3Hook.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<ClInclude Include="util.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="printf.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="PatchTools.cpp">
Expand All @@ -37,6 +40,9 @@
<ClCompile Include="util.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="printf.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<MASM Include="asmhook.asm">
Expand Down
2 changes: 1 addition & 1 deletion TS3Hook/Ts3Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define PLUGIN_API_VERSION 23

const char* ts3plugin_name() { return "TS3Hook"; }
const char* ts3plugin_version() { return "1.3.1"; }
const char* ts3plugin_version() { return "1.3.2"; }

int ts3plugin_apiVersion() {
int target = -1;
Expand Down
13 changes: 10 additions & 3 deletions TS3Hook/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <sstream>
#include <iterator>
#include <fstream>
#include "printf.h"
#include <iostream>

#ifdef ENV32
#define STD_DECL __cdecl
Expand Down Expand Up @@ -51,6 +53,11 @@ hookpt OUT_HOOKS[] = {
if (hConsole != nullptr) SetConsoleTextAttribute(hConsole, 15);\
}

void _putchar(char character)
{
std::cout << character;
}

HANDLE hConsole = nullptr;

// RUNTIME CALCED
Expand Down Expand Up @@ -290,7 +297,7 @@ void STD_DECL log_out_packet(char* packet, int length)
auto buffer = std::string(packet, length);

if (is_myts_update(buffer)) {
//CWRITE(CRED, "%ls %.*s %ls\n", outprefix, length, packet, outsuffix);
CWRITE(CRED, "%ls %.*s %ls\n", outprefix, length, packet, outsuffix);
return;
}

Expand Down Expand Up @@ -369,13 +376,13 @@ void STD_DECL log_out_packet(char* packet, int length)
for each (std::string filter in blockcmds) {
if (!buffer.compare(0, filter.size(), filter)) {
memset(packet, ' ', length);
//CWRITE(CYELLOW, "%ls Blocking %s %ls\n", outprefix, filter.c_str(), outsuffix);
CWRITE(CYELLOW, "%ls Blocking %s %ls\n", outprefix, filter.c_str(), outsuffix);
return;
}
}
}

//CWRITE(injected ? CPINK : CGREEN, "%ls %.*s %ls\n", outprefix, length, packet, outsuffix);
CWRITE(injected ? CPINK : CGREEN, "%ls %.*s %ls\n", outprefix, length, packet, outsuffix);
}

#ifdef ENV32
Expand Down

0 comments on commit 6129bbb

Please sign in to comment.