Skip to content

Commit

Permalink
Update to the newest vac3 inhibitor version
Browse files Browse the repository at this point in the history
  • Loading branch information
b1scoito committed Nov 22, 2021
1 parent 34f7a8d commit 675eb7a
Show file tree
Hide file tree
Showing 5 changed files with 1,161 additions and 1,128 deletions.
2 changes: 1 addition & 1 deletion cozinha_loader/cozinha_loader.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;BLACKBONE_STATIC;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
Expand Down
54 changes: 10 additions & 44 deletions cozinha_loader/injection.cpp
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
#include "pch.hpp"
#include "injection.hpp"

const auto failure = []( std::string_view str_err, const std::pair<HANDLE, HANDLE> handles = {} ) -> bool
bool c_injector::initiaze( std::string_view str_proc_name, const std::filesystem::path dll_path )
{
const auto [hProcess, hThread] = handles;
log_debug( "Closing processes" );

if ( hProcess ) // hProcess
CloseHandle( hProcess );

if ( hThread ) // hThread
CloseHandle( hThread );

log_err( "%s", str_err );

return false;
};

const auto get_sys_dir = []() -> std::wstring
{
wchar_t buf[MAX_PATH];
GetSystemDirectory( buf, sizeof( buf ) / 4 );

return std::wstring( buf );
};

bool c_injector::init( std::string_view str_proc_name, const std::filesystem::path dll_path )
{
// Closing processes
this->close_processes( { str_proc_name, "steam.exe" } );

Expand All @@ -34,7 +13,7 @@ bool c_injector::init( std::string_view str_proc_name, const std::filesystem::pa
if ( steam_path.empty() )
return failure( "Failed to retrieve steam path" );

std::string launch_append {};
std::string launch_append = {};

// I don't think it's a good idea to automatically open games from the list, but the code is here just in case.
//for ( const auto& it : this->vec_app_ids )
Expand All @@ -52,33 +31,20 @@ bool c_injector::init( std::string_view str_proc_name, const std::filesystem::pa
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );

log_debug( "Writing vac bypass to buffer..." );

const auto vac_buf_start = std::chrono::high_resolution_clock::now();

// This won't take long
std::vector<std::uint8_t> vac_buffer( std::begin( vac3_data ), std::end( vac3_data ) );

const auto vac_buf_end = std::chrono::high_resolution_clock::now();

std::chrono::duration<double, std::milli> vac_buf_elapsed( vac_buf_end - vac_buf_start );
log_debug( "Done in %.3fms.", vac_buf_elapsed );

// Inject vac bypass to steam
if ( !this->map( "steam.exe", L"tier0_s.dll", vac_buffer ) )
return false;

log_debug( "Writing dll to buffer..." );

const auto dll_buf_start = std::chrono::high_resolution_clock::now();

std::vector<std::uint8_t> dll_buffer;
std::vector<std::uint8_t> dll_buffer = {};
if ( !util::read_file_to_memory( std::filesystem::absolute( dll_path ), &dll_buffer ) )
return failure( "Failed to write DLL to memory!" );

const auto dll_buf_end = std::chrono::high_resolution_clock::now();

std::chrono::duration<double, std::milli> dll_buf_elapsed( dll_buf_end - dll_buf_start );
log_debug( "Done in %.3fms.", dll_buf_elapsed );
log_debug( "Done" );

// Inject dll to process
if ( !this->map( str_proc_name, L"serverbrowser.dll", dll_buffer ) )
Expand All @@ -101,7 +67,7 @@ bool c_injector::map( std::string_view str_proc, std::wstring_view wstr_mod_name
while ( !memory::is_process_open( proc_list, str_proc ) );

blackbone::Process bb_proc;
bb_proc.Attach( memory::get_process_id_by_name( proc_list, str_proc ), PROCESS_ALL_ACCESS ); // PROCESS_ALL_ACCESS not needed perhaps? placed it back in
bb_proc.Attach( memory::get_process_id_by_name( proc_list, str_proc ), PROCESS_ALL_ACCESS ); // PROCESS_ALL_ACCESS not needed perhaps?

// Wait for a process module so we can continue with injection
log_debug( "Waiting for - [ %ls ] in %s", wstr_mod_name.data(), str_proc );
Expand Down Expand Up @@ -129,7 +95,7 @@ bool c_injector::map( std::string_view str_proc, std::wstring_view wstr_mod_name
{
const auto patch_nt_open_file = [&]()
{
const auto ntdll_path = string::format( "%ls\\ntdll.dll", get_sys_dir().data() );
const auto ntdll_path = string::format( "%ls\\ntdll.dll", get_system_directory().data() );
const auto ntdll = LoadLibrary( string::to_unicode( ntdll_path ).data() );

if ( !ntdll )
Expand All @@ -140,10 +106,10 @@ bool c_injector::map( std::string_view str_proc, std::wstring_view wstr_mod_name
if ( !ntopenfile_ptr )
return failure( "Failed to get NtOpenFile proc address?" );

uint8_t restore[5];
std::uint8_t restore[5];
std::memcpy( restore, ntopenfile_ptr, sizeof( restore ) );

const auto result = bb_proc.memory().Write( (uintptr_t) ntopenfile_ptr, restore );
const auto result = bb_proc.memory().Write( (std::uintptr_t) ntopenfile_ptr, restore );

if ( !NT_SUCCESS( result ) )
return failure( "Failed to write patch memory" );
Expand Down
27 changes: 26 additions & 1 deletion cozinha_loader/injection.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
#pragma once

#include <functional>

#include <BlackBone/Process/Process.h>

const auto failure = []( std::string_view str_err, const std::pair<HANDLE, HANDLE> handles = {} ) -> bool
{
const auto [hProcess, hThread] = handles;

if ( hProcess ) // hProcess
CloseHandle( hProcess );

if ( hThread ) // hThread
CloseHandle( hThread );

log_err( "%s", str_err );

return false;
};

const auto get_system_directory = []() -> std::wstring
{
wchar_t buf[MAX_PATH];
GetSystemDirectory( buf, sizeof( buf ) / 4 );

return std::wstring( buf );
};

class c_injector
{
private:
Expand All @@ -21,7 +46,7 @@ class c_injector
~c_injector() = default;

// Initialize routine
bool init( std::string_view str_proc_name, const std::filesystem::path dll_path );
bool initiaze( std::string_view str_proc_name, const std::filesystem::path dll_path );
};

inline auto g_injector = std::make_unique<c_injector>();
9 changes: 4 additions & 5 deletions cozinha_loader/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ INT WINAPI WinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
{
std::atexit( [] { std::this_thread::sleep_for( 10s ); } );

int argc; auto* const argv = CommandLineToArgvW( GetCommandLineW(), &argc );
std::int32_t argc; auto* const argv = CommandLineToArgvW( GetCommandLineW(), &argc );

#ifndef _DEBUG
const std::filesystem::path dll_path = argv[1] ? argv[1] : L"cheat.dll";
#else
const std::filesystem::path dll_path = "D:\\cheat.dll";
const std::filesystem::path dll_path = "debug.dll";
#endif

if ( !std::filesystem::exists( dll_path ) )
Expand All @@ -21,13 +21,12 @@ INT WINAPI WinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
log_debug( "DLL path - [ %s ]", std::filesystem::absolute( dll_path ).string().c_str() );

std::string str_proc_name;
log_prompt( "Target process name -> " );
log_prompt( "Target process name: " );

std::cin >> str_proc_name;
std::cin.clear();

// this function will inject vac3 bypass on steam and the dll on the target process
if ( !g_injector->init( str_proc_name, dll_path ) )
if ( !g_injector->initiaze( str_proc_name, dll_path ) )
return EXIT_FAILURE;

log_ok( "Done." );
Expand Down
Loading

0 comments on commit 675eb7a

Please sign in to comment.