From 2ebf959ec02048c15323e1bbfc63faedcf5067b6 Mon Sep 17 00:00:00 2001 From: navewindre Date: Fri, 12 Jul 2024 00:55:39 +0200 Subject: ha haaa --- src/csgo/materialsystem.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/csgo/materialsystem.h (limited to 'src/csgo/materialsystem.h') diff --git a/src/csgo/materialsystem.h b/src/csgo/materialsystem.h new file mode 100644 index 0000000..263f808 --- /dev/null +++ b/src/csgo/materialsystem.h @@ -0,0 +1,61 @@ +#include "csgo.h" + +class MATERIAL { +private: + static IFACE_ENTRY* get_matsystem( CSGO* csgo ) { + static IFACE_ENTRY* ret = u_vector_search( csgo->interfaces, + []( IFACE_ENTRY i ) { + return fnv1a( "materialsystem.dll" ) == fnv1a( i.module_name ) + && !!strcmp( i.name, "VMaterialSystem" ); + } ); + + return ret; + } + + static IFACE_ENTRY* get_matsystem_cvar( CSGO* csgo ) { + static IFACE_ENTRY* ret = u_vector_search( csgo->interfaces, + []( IFACE_ENTRY i ) { + return fnv1a( "materialsystem.dll" ) == fnv1a( i.module_name ) + && !!strcmp( i.name, "VEngineCvar" ); + } ); + + return ret; + } + +public: + static U32 first_material( CSGO* csgo ) { + IFACE_ENTRY* mat_system = get_matsystem( csgo ); + + U16 mat_handle = csgo->read( mat_system->ptr + 0x250 ); + + while( mat_handle != 0xffff ) { + U32 handle_entries = csgo->read( mat_system->ptr + 0x244 ); + U16 next_handle = csgo->read( handle_entries + 16 * mat_handle ); + + if( next_handle == 0xffff ) + return mat_handle; + + mat_handle = next_handle; + } + + return 0; + } + + static U16 next_material( CSGO* csgo, U16 mat ) { + IFACE_ENTRY* mat_system = get_matsystem( csgo ); + + if( mat == 0xffff ) + return 0; + + U32 handle_array = csgo->read( mat_system->ptr + 0x244 ); + U16 next_handle = csgo->read( handle_array + 16 + mat + 2 ); + if( next_handle == 0xffff ) + return 0xffff; + + for( U16 i = next_handle; i != 0xffff; i = csgo->read( handle_array * 16 + i ) ) { + next_handle = i; + } + + return next_handle; + } +}; \ No newline at end of file -- cgit v1.2.3