From 4c8b52fc94c04c4b3d338c2501971ae348f5b3e5 Mon Sep 17 00:00:00 2001 From: navewindre Date: Tue, 16 Jul 2024 07:19:43 +0200 Subject: =?UTF-8?q?=E3=82=84=E3=83=BC=E3=83=BC=E3=83=BC=E3=83=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + dwm/dwm.vcxproj | 159 +++++++++++++++++++++++++++++++++++++++ dwm/dwm.vcxproj.filters | 30 ++++++++ dwm/dwm.vcxproj.user | 4 + dwm/source.cpp | 12 +++ dwm/typedef.h | 2 + dwm/util.h | 2 + heavens-gate.sln | 20 +++++ src/cs2/cs2.h | 1 - src/cs2/entity.cpp | 4 + src/cs2/entity.h | 114 ++++++++++++++++++++++++++++ src/cs2/hack.cpp | 26 ++++++- src/cs2/hack.h | 2 + src/cs2/iface.h | 14 ++++ src/cs2/schema.h | 71 ++++++++++++++++- src/heavens-gate.vcxproj | 4 + src/heavens-gate.vcxproj.filters | 12 +++ src/perf.cpp | 23 ++++++ src/perf.h | 23 ++++++ src/source.cpp | 12 +-- src/typedef.h | 5 +- src/util.cpp | 16 +++- src/util.h | 6 ++ 23 files changed, 546 insertions(+), 17 deletions(-) create mode 100644 dwm/dwm.vcxproj create mode 100644 dwm/dwm.vcxproj.filters create mode 100644 dwm/dwm.vcxproj.user create mode 100644 dwm/source.cpp create mode 100644 dwm/typedef.h create mode 100644 dwm/util.h create mode 100644 src/cs2/entity.cpp create mode 100644 src/cs2/entity.h create mode 100644 src/perf.cpp create mode 100644 src/perf.h diff --git a/.gitignore b/.gitignore index 47e8b43..83b421c 100644 --- a/.gitignore +++ b/.gitignore @@ -42,5 +42,6 @@ src/Release/* src/X64/* .idea/* .vs/* +.vscode/* bin/* \ No newline at end of file diff --git a/dwm/dwm.vcxproj b/dwm/dwm.vcxproj new file mode 100644 index 0000000..bab2871 --- /dev/null +++ b/dwm/dwm.vcxproj @@ -0,0 +1,159 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {33618e8d-258b-4ce2-968c-ae0ea1f2162e} + dwm + 10.0 + + + + Application + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + DynamicLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + $(SolutionDir)\bin\ + ..\intermediate\X64\$(Configuration)\ + dwmhook + + + false + $(SolutionDir)\bin\ + ..\intermediate\X64\$(Configuration)\ + dwmhook + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions);X64 + true + stdcpp17 + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions);X64 + true + stdcpp17 + + + Console + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/dwm/dwm.vcxproj.filters b/dwm/dwm.vcxproj.filters new file mode 100644 index 0000000..37e74bf --- /dev/null +++ b/dwm/dwm.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/dwm/dwm.vcxproj.user b/dwm/dwm.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/dwm/dwm.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/dwm/source.cpp b/dwm/source.cpp new file mode 100644 index 0000000..c8d4951 --- /dev/null +++ b/dwm/source.cpp @@ -0,0 +1,12 @@ +#include +#include "typedef.h" + + +int __stdcall DllMain( void* hinst, U32 reason, void* reserved ) { + // coca cola yayo bought me this + if( reason == DLL_PROCESS_ATTACH ) { + // do a fucking EPIC here + + return 1; + } +} \ No newline at end of file diff --git a/dwm/typedef.h b/dwm/typedef.h new file mode 100644 index 0000000..8d532d4 --- /dev/null +++ b/dwm/typedef.h @@ -0,0 +1,2 @@ +#pragma once +#include "../src/typedef.h" \ No newline at end of file diff --git a/dwm/util.h b/dwm/util.h new file mode 100644 index 0000000..b723112 --- /dev/null +++ b/dwm/util.h @@ -0,0 +1,2 @@ +#pragma once +#include "../src/util.h" \ No newline at end of file diff --git a/heavens-gate.sln b/heavens-gate.sln index aa3a577..754b908 100644 --- a/heavens-gate.sln +++ b/heavens-gate.sln @@ -5,19 +5,39 @@ VisualStudioVersion = 16.0.32002.261 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "heavens-gate", "src\heavens-gate.vcxproj", "{D2960E74-5A8F-4D86-9788-7BBAF0248F68}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dwm", "dwm\dwm.vcxproj", "{33618E8D-258B-4CE2-968C-AE0EA1F2162E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + debug|x64 = debug|x64 debug|x86 = debug|x86 + release|x64 = release|x64 release|x86 = release|x86 + stripped|x64 = stripped|x64 stripped|x86 = stripped|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D2960E74-5A8F-4D86-9788-7BBAF0248F68}.debug|x64.ActiveCfg = Debug|Win32 {D2960E74-5A8F-4D86-9788-7BBAF0248F68}.debug|x86.ActiveCfg = Debug|Win32 {D2960E74-5A8F-4D86-9788-7BBAF0248F68}.debug|x86.Build.0 = Debug|Win32 + {D2960E74-5A8F-4D86-9788-7BBAF0248F68}.release|x64.ActiveCfg = Release|Win32 {D2960E74-5A8F-4D86-9788-7BBAF0248F68}.release|x86.ActiveCfg = Release|Win32 {D2960E74-5A8F-4D86-9788-7BBAF0248F68}.release|x86.Build.0 = Release|Win32 + {D2960E74-5A8F-4D86-9788-7BBAF0248F68}.stripped|x64.ActiveCfg = stripped|Win32 {D2960E74-5A8F-4D86-9788-7BBAF0248F68}.stripped|x86.ActiveCfg = stripped|Win32 {D2960E74-5A8F-4D86-9788-7BBAF0248F68}.stripped|x86.Build.0 = stripped|Win32 + {33618E8D-258B-4CE2-968C-AE0EA1F2162E}.debug|x64.ActiveCfg = Debug|x64 + {33618E8D-258B-4CE2-968C-AE0EA1F2162E}.debug|x64.Build.0 = Debug|x64 + {33618E8D-258B-4CE2-968C-AE0EA1F2162E}.debug|x86.ActiveCfg = Debug|Win32 + {33618E8D-258B-4CE2-968C-AE0EA1F2162E}.debug|x86.Build.0 = Debug|Win32 + {33618E8D-258B-4CE2-968C-AE0EA1F2162E}.release|x64.ActiveCfg = Release|x64 + {33618E8D-258B-4CE2-968C-AE0EA1F2162E}.release|x64.Build.0 = Release|x64 + {33618E8D-258B-4CE2-968C-AE0EA1F2162E}.release|x86.ActiveCfg = Release|x64 + {33618E8D-258B-4CE2-968C-AE0EA1F2162E}.release|x86.Build.0 = Release|x64 + {33618E8D-258B-4CE2-968C-AE0EA1F2162E}.stripped|x64.ActiveCfg = Debug|x64 + {33618E8D-258B-4CE2-968C-AE0EA1F2162E}.stripped|x64.Build.0 = Debug|x64 + {33618E8D-258B-4CE2-968C-AE0EA1F2162E}.stripped|x86.ActiveCfg = Debug|Win32 + {33618E8D-258B-4CE2-968C-AE0EA1F2162E}.stripped|x86.Build.0 = Debug|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/cs2/cs2.h b/src/cs2/cs2.h index db136b9..f8a3f9b 100644 --- a/src/cs2/cs2.h +++ b/src/cs2/cs2.h @@ -14,7 +14,6 @@ public: VECTOR entries = iface_get_all( this ); for( auto it : entries ) { if( strncmp( it.name, name, strlen( name ) ) == 0 ) { - clog( "iface %s: [%llx]\n", it.name.data, it.ptr ); return it; } } diff --git a/src/cs2/entity.cpp b/src/cs2/entity.cpp new file mode 100644 index 0000000..36265e0 --- /dev/null +++ b/src/cs2/entity.cpp @@ -0,0 +1,4 @@ +#include "entity.h" + +CS2* CS2_PAWN::cs; +CS2* CS2_PLAYERCONTROLLER::cs; \ No newline at end of file diff --git a/src/cs2/entity.h b/src/cs2/entity.h new file mode 100644 index 0000000..999f776 --- /dev/null +++ b/src/cs2/entity.h @@ -0,0 +1,114 @@ +#pragma once +#include "cs2.h" +#include "schema.h" + +static U64 cs2_ent_get_list( CS2* p ); +inline U64 cs2_ent_from_idx( CS2* p, U32 idx ); +inline U64 cs2_ent_from_handle( CS2* p, U32 handle ); +class CS2_PLAYERCONTROLLER; + +class CS2_PAWN { +public: + CS2_PAWN( U64 _ptr ) : ptr( _ptr ) {} + CS2_PAWN() : ptr( 0 ) {} + operator U64() { return ptr; } + + NETVAR_MOD( I32, m_iHealth, "C_BaseEntity", "client.dll" ); + + U64 ptr; + static CS2* cs; +}; + +class CS2_PLAYERCONTROLLER { +public: + CS2_PLAYERCONTROLLER( U64 _ptr ) : ptr( _ptr ) {} + CS2_PLAYERCONTROLLER() : ptr( 0 ) {} + operator U64() { return ptr; } + + NETVAR_MOD( U32, m_hPawn, "CBasePlayerController", "client.dll" ); + + STR<128> m_sSanitizedPlayerName() { + static I32 off = schema_get_offset( cs, "CCSPlayerController", "m_sSanitizedPlayerName", "client.dll" ); + + STR<128> ret; + U64 str = cs->read( ptr + off ); + cs->read( str, ret, sizeof( ret ) ); + + return ret; + } + + CS2_PAWN get_pawn() { + return cs2_ent_from_handle( cs, m_hPawn() ); + } + + U64 ptr; + static CS2* cs; +}; + +// ------------------------------------------------------------------------------------------------ + +static U64 cs2_ent_get_list( CS2* p ) { + static U64 entitylist = 0; + + if( !entitylist ) { + if( !CS2_PLAYERCONTROLLER::cs ) + CS2_PLAYERCONTROLLER::cs = CS2_PAWN::cs = p; + U64 client = p->mod.client.base; + + // GetEntityByIndex + // xref str: '%s' : '%s' (entindex %d) \n, + // ent_find_index cvar + U64 call = p->code_match( p->mod.client.base, "E8 ? ? ? ? 48 8B D0 48 8B CE FF D7" ); + assert( !!call ); + + U32 off = p->read( call + 1 ) + 5; + U64 fn = call + off; + + U8 bytes[32]; + p->read( fn, bytes, sizeof( bytes ) ); + + if( bytes[0] != 0x8b || bytes[1] != 0xd1 || // mov edx, ecx + bytes[2] != 0x48 || bytes[3] != 0x8b || bytes[4] != 0x0d // mov rcx, entlist + ) { + assert( false ); + return 0; + } + + off = *(U32*)&bytes[5]; + entitylist = p->read( fn + off + 9 ); + } + + return entitylist; +} + +// ? ? ? ? ? +// i really wanna know what the actual c++ looks like. +inline U64 cs2_ent_from_idx( CS2* p, U32 idx ) { + U64 entlist = cs2_ent_get_list( p ); + if( !entlist ) + return 0; + + if( idx >= 0x7fff ) + return 0; + + if( (idx >> 9) > 0x3f ) + return 0; + + U64 v2 = entlist + 8 * (idx >> 9) + 0x10; + v2 = p->read( v2 ); + if( !v2 ) + return 0; + + U64 v3 = 0x78 * (idx & 0x1ff) + v2; + if( !v3 ) + return 0; + + return p->read( v3 ); +} + +inline U64 cs2_ent_from_handle( CS2* p, U32 handle ) { + if( handle == 0xffffffff ) + return 0; + + return cs2_ent_from_idx( p, handle & 0x7fff ); +} diff --git a/src/cs2/hack.cpp b/src/cs2/hack.cpp index ef4008d..c98337a 100644 --- a/src/cs2/hack.cpp +++ b/src/cs2/hack.cpp @@ -1,9 +1,10 @@ #include "hack.h" +#include "entity.h" +#include "entity.h" #include "iface.h" SETTING_HOLDER gcfg; -#include "cs2.h" PROCESS64* hack_init() { CS2* p = new CS2(); @@ -12,9 +13,32 @@ PROCESS64* hack_init() { return nullptr; } + schema_dump_to_file( p ); + iface_dump_to_file( p ); + return p; } bool hack_run( PROCESS64* p ) { + perf_run_metric( perf_loop_start ); + CS2* cs = (CS2*)p; + + for( I32 i = 0; i < 64; ++i ) { + CS2_PLAYERCONTROLLER pc = cs2_ent_from_idx( cs, i ); + if( !pc ) + continue; + + CS2_PAWN pawn = pc.get_pawn(); + if( !pawn ) + continue; + + STR<128> name = pc.m_sSanitizedPlayerName(); + I32 health = pawn.m_iHealth(); + + clog( "player %d [%llx]: %s, health %d\n", i, pc.ptr, name.data, health ); + } + + + perf_run_metric( perf_loop_end ); return true; } \ No newline at end of file diff --git a/src/cs2/hack.h b/src/cs2/hack.h index 18bd4e3..3ba769a 100644 --- a/src/cs2/hack.h +++ b/src/cs2/hack.h @@ -2,8 +2,10 @@ #include "../process64.h" #include "../setting.h" +#include "../perf.h" extern SETTING_HOLDER gcfg; + extern PROCESS64* hack_init(); extern bool hack_run( PROCESS64* p ); \ No newline at end of file diff --git a/src/cs2/iface.h b/src/cs2/iface.h index be2137d..61cd91c 100644 --- a/src/cs2/iface.h +++ b/src/cs2/iface.h @@ -109,3 +109,17 @@ inline VECTOR iface_get_all( PROCESS64* p ) { return entries; } +inline void iface_dump_to_file( PROCESS64* p ) { + VECTOR entries = iface_get_all( p ); + + static STR<9999999> output; + memset( output, 0, sizeof( output.data ) ); + + for( auto& it : entries ) { + U64 off = it.ptr - it.module; + + sprintf( output, "%siface: %s @%s+0x%llx [0x%llx]\n", output.data, it.name.data, it.module_name.data, off, it.ptr ); + } + + u_write_to_file( output.data, "interfaces.txt" ); +} \ No newline at end of file diff --git a/src/cs2/schema.h b/src/cs2/schema.h index f99683d..1c55906 100644 --- a/src/cs2/schema.h +++ b/src/cs2/schema.h @@ -3,6 +3,54 @@ #include "../util.h" #include "sdk.h" +#define NETVAR(type, name, classn) \ +type name() { \ + static I32 off = schema_get_offset( cs, classn, #name ); \ + assert( !!off ); \ + return cs->read( ptr + off ); \ +} \ +void name( type val ) { \ + static I32 off = schema_get_offset( cs, classn, #name ); \ + assert( !!off ); \ + cs->write( ptr + off, val ); \ +} \ + +#define NETVARO(type, name, classn, off1) \ +type name() { \ + static I32 off = schema_get_offset( cs, classn, #name ); \ + assert( !!off ); \ + return cs->read( ptr + off + off1 ); \ +} \ +void name( type val ) { \ + static I32 off = schema_get_offset( cs, classn, #name ); \ + cs->write( ptr + off + off1, val ); \ +} \ + +#define NETVAR_MOD(type, name, classn, mod) \ +type name() { \ + static I32 off = schema_get_offset( cs, classn, #name, mod ); \ + assert( !!off ); \ + return cs->read( ptr + off ); \ +} \ +void name( type val ) { \ + static I32 off = schema_get_offset( cs, classn, #name, mod ); \ + assert( !!off ); \ + cs->write( ptr + off, val ); \ +} \ + +#define NETVARO_MOD(type, name, classn, off1, mod) \ +type name() { \ + static I32 off = schema_get_offset( cs, classn, #name, mod ); \ + assert( !!off ); \ + return cs->read( ptr + off + off1 ) mod; \ +} \ +void name( type val ) { \ + static I32 off = schema_get_offset( cs, classn, #name, mod ); \ + assert( !!off ); \ + cs->write( ptr + off + off1, val mod ); \ +} \ + + inline CS2_SCHEMA_FIELD* schema_class_get_fields( CS2* p, CS2_SCHEMA_CLASS* schclass ) { if( !schclass->fields || !schclass->num_fields ) @@ -75,8 +123,8 @@ static VECTOR schema_get_all( CS2* p ) { for( U32 j = 0; j < scope->num_classes; ++j ) { CS2_SCHEMA_CLASS* schclass = &classes[j]; - STR<128> classname{}; - p->read( schclass->name, classname.data, 128 ); + STR<256> classname{}; + p->read( schclass->name, classname.data, 256 ); if( classname.data[0] == 0 || !strlen( classname ) ) continue; @@ -93,8 +141,9 @@ static VECTOR schema_get_all( CS2* p ) { STR<256> buf; p->read( field->name, buf.data, 256 ); entry.prop = buf; - entry.clientclass = buf; - entry.scope = scope->name; + entry.clientclass = classname; + entry.scope = scope->name; + entry.offset = (I32)field->offset; entries.push_back( entry ); } @@ -108,6 +157,20 @@ static VECTOR schema_get_all( CS2* p ) { return entries; } +static I32 schema_get_offset( CS2* p, const char* classname, const char* prop, const char* scope = nullptr ) { + if( p->netvars.empty() ) + p->netvars = schema_get_all( p ); + + for( auto& it : p->netvars ) { + if( !strcmp( it.clientclass, classname ) && !strcmp( it.prop, prop ) ) { + if( !scope || !strcmp( it.scope, scope ) ) + return it.offset; + } + } + + return -1; +} + static void schema_dump_to_file( CS2* p ) { CS2_SCHEMA schema = schema_read_iface( p, p->iface.schema.ptr ); diff --git a/src/heavens-gate.vcxproj b/src/heavens-gate.vcxproj index 0a41f0b..a7a20bc 100644 --- a/src/heavens-gate.vcxproj +++ b/src/heavens-gate.vcxproj @@ -198,9 +198,11 @@ + + @@ -208,6 +210,7 @@ + @@ -216,6 +219,7 @@ + diff --git a/src/heavens-gate.vcxproj.filters b/src/heavens-gate.vcxproj.filters index 643ec4f..2140028 100644 --- a/src/heavens-gate.vcxproj.filters +++ b/src/heavens-gate.vcxproj.filters @@ -20,6 +20,12 @@ Game + + Game + + + Util + @@ -81,6 +87,12 @@ Game + + Game + + + Util + diff --git a/src/perf.cpp b/src/perf.cpp new file mode 100644 index 0000000..b8f29a6 --- /dev/null +++ b/src/perf.cpp @@ -0,0 +1,23 @@ +#if defined DEBUG || defined PERF_DEBUG +#include "perf.h" + +PERF_DATA perf; + +U64 last_loop = 0; + +void perf_loop_begin() { + perf.readctr = perf.writectr = 0; + + if( !last_loop ) { + last_loop = u_tick(); + } +} + +void perf_loop_end() { + U64 tick = u_tick(); + U64 delta = last_loop - tick; + perf.ticks = delta; + + last_loop = tick; +} +#endif \ No newline at end of file diff --git a/src/perf.h b/src/perf.h new file mode 100644 index 0000000..25190a8 --- /dev/null +++ b/src/perf.h @@ -0,0 +1,23 @@ +#pragma once +#if defined DEBUG || defined PERF_DEBUG +#include "typedef.h" + +struct PERF_DATA { + U64 ticks; + U64 lastwrites; + U64 lastreads; + U64 avgwrites; + U64 avgreads; + + U64 writectr; + U64 readctr; +}; + +extern void perf_loop_begin(); +extern void perf_loop_end(); + +extern PERF_DATA perf; +#define perf_run_metric( x ) x() +#else +#define perf_run_metric( x ) +#endif diff --git a/src/source.cpp b/src/source.cpp index 1ce0754..b27149f 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -1,6 +1,8 @@ //|_ _ _. _ ._ |_ _. _ | //| | (/_ (_| \/ (/_ | | | | (_| (_ |< +//#define PERF_DEBUG 1 + #include "cs2/hack.h" #include "conin.h" #include "menu.h" @@ -9,18 +11,10 @@ bool run() { con_init(); PROCESS64* p = hack_init(); - Sleep( 1000 ); gcfg.load(); - menu_show_ui( p ); - for( ;; ) { - if( !hack_run( p ) ) { - nt_close64( p->get_base() ); - u_sleep( 5 * T_SEC ); - break; - } - } + for( ; hack_run( p ); ); return false; } diff --git a/src/typedef.h b/src/typedef.h index 97b17da..5cbc038 100644 --- a/src/typedef.h +++ b/src/typedef.h @@ -21,8 +21,11 @@ typedef unsigned long long U64; typedef float F32; typedef double F64; +#ifdef X64 +typedef unsigned long long PTR; +#else typedef unsigned long PTR; - +#endif #define assert( x ) if( !x ) con_set_assert( "ASSERTION FAILED: %s() (line: %d)", __func__, __LINE__ ) #define pause() system( "pause" ) \ No newline at end of file diff --git a/src/util.cpp b/src/util.cpp index 81b1192..7f47677 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -8,11 +8,25 @@ ULONG u_thread_create( LPTHREAD_START_ROUTINE routine, void* param ) { REG64 thread; ULONG ret_id; +#ifndef X64 nt_create_thread64( &thread, 0x1fffff, 0, GetCurrentProcess(), routine, param, 0 ); ret_id = GetThreadId( (HANDLE)thread.u32[0] ); nt_close64( thread ); - +#else + static auto nt_create_thread = (NTSTATUS(__stdcall*)( + PHANDLE, + ACCESS_MASK, + POBJECT_ATTRIBUTES, + HANDLE, + PCLIENT_ID, + PCONTEXT, + PINITIAL_TEB, + BOOLEAN) + )GetProcAddress( GetModuleHandleA( "ntdll.dll" ), "NtCreateThread" ); + + //aaa +#endif return ret_id; } diff --git a/src/util.h b/src/util.h index 705a778..1277047 100644 --- a/src/util.h +++ b/src/util.h @@ -181,4 +181,10 @@ inline U64 u_tick() { inline F64 u_time() { constexpr F64 NSEC_TO_SEC = 1.f / T_SEC; return u_tick() * NSEC_TO_SEC; +} + +inline void u_write_to_file( const char* str, const char* file ) { + FILE* f = fopen( file, "w" ); + fwrite( str, 1, strlen( str ), f ); + fclose( f ); } \ No newline at end of file -- cgit v1.2.3