Solved CSGO Material Chams crashing

  • CSGO recently moved logic from 'client_panorama.dll' to 'client.dll', you must update all code that uses 'client_panorama.dll' and replace it with 'client.dll' or the code will not work.
Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat
Status
Not open for further replies.

LOLKFC

Newbie
Full Member
Oct 23, 2014
17
318
0
Wazzap gh

Im trying to paste and understand some Marterial chams from uc. The whole hook and the interfaces are working and up 2 date. Im using an SDK.

Hook:
C++:
void __stdcall hkDrawModelExecute( IMatRenderContext * ctx, const DrawModelState_t &state, const ModelRenderInfo_t &pInfo, matrix3x4_t *pCustomBoneToWorld )
{
	oDrawModelExecute( ctx, state, pInfo, pCustomBoneToWorld );

	if( pInfo.pModel )
	{
		string pszModelName = modelinfo->GetModelName( pInfo.pModel );
		
		if( pszModelName.find( "models/player" ) != string::npos )
		{
			IMaterial *mats[ MAXSTUDIOSKINS ];

			studiohdr_t* hdr = modelinfo->GetStudioModel( pInfo.pModel );

			Color col, col2;

			C_BaseEntity* pModelEntity = ( C_BaseEntity* ) entitylist->GetClientEntity( pInfo.entity_index );
			if( pModelEntity )
			{
				C_BaseEntity* pLocal = ( C_BaseEntity* ) entitylist->GetClientEntity( engine->GetLocalPlayer( ) );

				if( pLocal )
				{
					if( pModelEntity->m_iHealth >= 1 && pModelEntity->team( ) != pLocal->team( ) )
					{

						modelinfo->GetModelMaterials( pInfo.pModel, hdr->numtextures, mats );

						for( int i = 0; i < hdr->numtextures; i++ )
						{
							IMaterial* mat = mats[ i ];

							if( !mat )
								continue;

							mat->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, true );
							mat->SetMaterialVarFlag( MATERIAL_VAR_FLAT, true );
							mat->SetMaterialVarFlag( MATERIAL_VAR_ALPHATEST, true );
							mat->AlphaModulate( 1.0f );

							col = Color( 0, 255, 0 );

							render->SetColorModulation( col.Base( ) );

							modelrender->DrawModelExecute( ctx, state, pInfo, pCustomBoneToWorld );

							mat->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, false );
							mat->SetMaterialVarFlag( MATERIAL_VAR_FLAT, false );
							mat->SetMaterialVarFlag( MATERIAL_VAR_ALPHATEST, false );
							mat->AlphaModulate( 1.0f );

							col2 = Color( 0, 255, 0 );
							render->SetColorModulation( col2.Base( ) );
						}
					}
					else
					{
						modelinfo->GetModelMaterials( pInfo.pModel, hdr->numtextures, mats );
						for( int i = 0; i < hdr->numtextures; i++ )
						{
							IMaterial* mat = mats[ i ];
							if( !mat )
								continue;

							mat->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, false );
							mat->SetMaterialVarFlag( MATERIAL_VAR_ALPHATEST, false );
							mat->SetMaterialVarFlag( MATERIAL_VAR_FLAT, false );

						}
					}

					modelrender->DrawModelExecute( ctx, state, pInfo, pCustomBoneToWorld );
					modelrender->ForcedMaterialOverride( NULL );

				} 
			} 
		} 
	}
}
I get a crash on
C++:
string pszModelName = modelinfo->GetModelName( pInfo.pModel );
I dont get it why its crashing here. Im using the modelinfo in funcs like gethitboxposition. But here its crashing on getmodelname. Any idea? Thanks for help
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,118
78,998
2,392
Best Answer Necro:

Im trying to paste
Thread closed, pasting gets you no where. Just learn everything from the ground up 1 thing at a time over the course of months and you will be successful.
 

LOLKFC

Newbie
Full Member
Oct 23, 2014
17
318
0
Thanks for you anser.

Checked now but still crashing. Do i need the full model_t struct ?
 

masteraimer1

Newbie
Full Member
Nobleman
Aug 27, 2014
95
1,768
6
Thanks for you anser.

Checked now but still crashing. Do i need the full model_t struct ?
u dont even need any from the model_t you just can do "class model_t;" in ur sdk .
check if getmodelname is index 3 and check ur model render info struct
C++:
struct ModelRenderInfo_t
{
	Vector origin;
	QAngle angles;
	CBaseEntity *pRenderable;
	const model_t *pModel;
	const matrix3x4 *pModelToWorld;
	const matrix3x4 *pLightingOffset;
	const Vector *pLightingOrigin;
	int flags;
	int entity_index;
	int skin;
	int body;
	int hitboxset;
	unsigned short instance;
	ModelRenderInfo_t()
	{
		pModelToWorld = NULL;
		pLightingOffset = NULL;
		pLightingOrigin = NULL;
	}
};
 

LOLKFC

Newbie
Full Member
Oct 23, 2014
17
318
0
thx 4 answer

it seems like:
C++:
class IVModelInfo
{
public:
	virtual							~IVModelInfo(void) { }
	virtual const model_t			*GetModel(int modelindex) const = 0;
	virtual int						GetModelIndex(const char *name) const = 0;
	virtual const char				*GetModelName(const model_t *model) const = 0;
...
and i used this struct before:
C++:
struct ModelRenderInfo_t
{
    Vector origin;
    QAngle angles; 
    IClientRenderable *pRenderable;
    const model_t *pModel;
    const matrix3x4_t *pModelToWorld;
    const matrix3x4_t *pLightingOffset;
    const Vector *pLightingOrigin;
    int flags;
    int entity_index;
    int skin;
    int body;
    int hitboxset;
    ModelInstanceHandle_t instance;
    ModelRenderInfo_t()
    {
        pModelToWorld = NULL;
        pLightingOffset = NULL;
        pLightingOrigin = NULL;
    }
};
i gonna try it out now
 

LOLKFC

Newbie
Full Member
Oct 23, 2014
17
318
0
sry, this point isnt crashing anymore.

Now it crashs on
C++:
modelrender->DrawModelExecute( ctx, state, pInfo, pCustomBoneToWorld );
any idea?

my class:
C++:
abstract_class IVModelRender
{
public:
	virtual int	DrawModel(int flags, IClientRenderable *pRenderable, ModelInstanceHandle_t instance, int entity_index, const model_t *model, Vector const& origin, QAngle const& angles, int skin, int body, int hitboxset, const matrix3x4_t *modelToWorld = NULL, const matrix3x4_t *pLightingOffset = NULL) = 0;
	virtual void	ForcedMaterialOverride(IMaterial *newMaterial, OverrideType_t nOverrideType = OVERRIDE_NORMAL) = 0;
	virtual bool	IsForcedMaterialOverride(void) = 0;
	virtual void	SetViewTarget(const CStudioHdr *pStudioHdr, int nBodyIndex, const Vector& target) = 0;
	virtual ModelInstanceHandle_t CreateInstance(IClientRenderable *pRenderable, LightCacheHandle_t *pCache = NULL) = 0;
	virtual void DestroyInstance(ModelInstanceHandle_t handle) = 0;
	virtual void SetStaticLighting(ModelInstanceHandle_t handle, LightCacheHandle_t* pHandle) = 0;
	virtual LightCacheHandle_t GetStaticLighting(ModelInstanceHandle_t handle) = 0;
	virtual bool ChangeInstance(ModelInstanceHandle_t handle, IClientRenderable *pRenderable) = 0;
	virtual void AddDecal(ModelInstanceHandle_t handle, Ray_t const& ray, Vector const& decalUp, int decalIndex, int body, bool noPokeThru = false, int maxLODToDecal = ADDDECAL_TO_ALL_LODS) = 0;
	virtual void RemoveAllDecals(ModelInstanceHandle_t handle) = 0;
	virtual bool ModelHasDecals(ModelInstanceHandle_t handle) = 0;
	virtual void RemoveAllDecalsFromAllModels() = 0;
	virtual matrix3x4a_t* DrawModelShadowSetup(IClientRenderable *pRenderable, int body, int skin, DrawModelInfo_t *pInfo, matrix3x4a_t *pCustomBoneToWorld = NULL) = 0;
	virtual void DrawModelShadow(IClientRenderable *pRenderable, const DrawModelInfo_t &info, matrix3x4a_t *pCustomBoneToWorld = NULL) = 0;
	virtual bool RecomputeStaticLighting(ModelInstanceHandle_t handle) = 0;
	virtual void ReleaseAllStaticPropColorData(void) = 0;
	virtual void RestoreAllStaticPropColorData(void) = 0;
	virtual int	DrawModelEx(ModelRenderInfo_t &pInfo) = 0;
	virtual int	DrawModelExStaticProp(ModelRenderInfo_t &pInfo) = 0;
	virtual bool DrawModelSetup(ModelRenderInfo_t &pInfo, DrawModelState_t *pState, matrix3x4_t **ppBoneToWorldOut) = 0;
	virtual void DrawModelExecute(IMatRenderContext * ctx, const DrawModelState_t &state, const ModelRenderInfo_t &pInfo, matrix3x4_t *pCustomBoneToWorld = NULL) = 0;
...
Interface Version VEngineModel016
 

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
I can imagine that if pInfo or pCustomBoneToWorld or both are 0 it could crash, so you should check there aswell
 

LOLKFC

Newbie
Full Member
Oct 23, 2014
17
318
0
thx 4 answer i added some checks but it still crashing -.-

looks like this now:
C++:
void __stdcall hkDrawModelExecute( IMatRenderContext * ctx, const DrawModelState_t &state, const ModelRenderInfo_t &pInfo, matrix3x4_t *pCustomBoneToWorld )
{
	oDrawModelExecute( ctx, state, pInfo, pCustomBoneToWorld );

	if( pInfo.pModel )
	{
		if( pCustomBoneToWorld == nullptr )
			return;

		string pszModelName = modelinfo->GetModelName( pInfo.pModel );

		if( pszModelName.find( "models/player" ) != string::npos )
		{
			IMaterial *mats[ MAXSTUDIOSKINS ];

			studiohdr_t* hdr = modelinfo->GetStudioModel( pInfo.pModel );

			Color col, col2;
			if( pInfo.entity_index )
			{
				C_BaseEntity* pModelEntity = ( C_BaseEntity* ) entitylist->GetClientEntity( pInfo.entity_index );
				if( pModelEntity )
				{
					C_BaseEntity* pLocal = ( C_BaseEntity* ) entitylist->GetClientEntity( engine->GetLocalPlayer( ) );

					if( pLocal )
					{
						if( pModelEntity->m_iHealth >= 1 && pModelEntity->team( ) != pLocal->team( ) )
						{

							modelinfo->GetModelMaterials( pInfo.pModel, hdr->numtextures, mats );

							for( int i = 0; i < hdr->numtextures; i++ )
							{
								IMaterial* mat = mats[ i ];

								if( !mat )
									continue;

								mat->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, true );
								mat->SetMaterialVarFlag( MATERIAL_VAR_FLAT, true );
								mat->SetMaterialVarFlag( MATERIAL_VAR_ALPHATEST, true );
								mat->AlphaModulate( 1.0f );

								col = Color( 0, 255, 0 );

								render->SetColorModulation( col.Base( ) );

								modelrender->DrawModelExecute( ctx, state, pInfo, pCustomBoneToWorld );

								mat->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, false );
								mat->SetMaterialVarFlag( MATERIAL_VAR_FLAT, false );
								mat->SetMaterialVarFlag( MATERIAL_VAR_ALPHATEST, false );
								mat->AlphaModulate( 1.0f );

								col2 = Color( 0, 255, 0 );
								render->SetColorModulation( col2.Base( ) );
							}
						}
						else
						{
							modelinfo->GetModelMaterials( pInfo.pModel, hdr->numtextures, mats );
							for( int i = 0; i < hdr->numtextures; i++ )
							{
								IMaterial* mat = mats[ i ];
								if( !mat )
									continue;

								mat->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, false );
								mat->SetMaterialVarFlag( MATERIAL_VAR_ALPHATEST, false );
								mat->SetMaterialVarFlag( MATERIAL_VAR_FLAT, false );

							}
						}

						modelrender->DrawModelExecute( ctx, state, pInfo, pCustomBoneToWorld );
						modelrender->ForcedMaterialOverride( NULL );

					}
				}
			}
		}
	}
}
 

masteraimer1

Newbie
Full Member
Nobleman
Aug 27, 2014
95
1,768
6
thx 4 answer i added some checks but it still crashing -.-

looks like this now:
C++:
void __stdcall hkDrawModelExecute( IMatRenderContext * ctx, const DrawModelState_t &state, const ModelRenderInfo_t &pInfo, matrix3x4_t *pCustomBoneToWorld )
{
	oDrawModelExecute( ctx, state, pInfo, pCustomBoneToWorld );

	if( pInfo.pModel )
	{
		if( pCustomBoneToWorld == nullptr )
			return;

		string pszModelName = modelinfo->GetModelName( pInfo.pModel );

		if( pszModelName.find( "models/player" ) != string::npos )
		{
			IMaterial *mats[ MAXSTUDIOSKINS ];

			studiohdr_t* hdr = modelinfo->GetStudioModel( pInfo.pModel );

			Color col, col2;
			if( pInfo.entity_index )
			{
				C_BaseEntity* pModelEntity = ( C_BaseEntity* ) entitylist->GetClientEntity( pInfo.entity_index );
				if( pModelEntity )
				{
					C_BaseEntity* pLocal = ( C_BaseEntity* ) entitylist->GetClientEntity( engine->GetLocalPlayer( ) );

					if( pLocal )
					{
						if( pModelEntity->m_iHealth >= 1 && pModelEntity->team( ) != pLocal->team( ) )
						{

							modelinfo->GetModelMaterials( pInfo.pModel, hdr->numtextures, mats );

							for( int i = 0; i < hdr->numtextures; i++ )
							{
								IMaterial* mat = mats[ i ];

								if( !mat )
									continue;

								mat->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, true );
								mat->SetMaterialVarFlag( MATERIAL_VAR_FLAT, true );
								mat->SetMaterialVarFlag( MATERIAL_VAR_ALPHATEST, true );
								mat->AlphaModulate( 1.0f );

								col = Color( 0, 255, 0 );

								render->SetColorModulation( col.Base( ) );

								modelrender->DrawModelExecute( ctx, state, pInfo, pCustomBoneToWorld );

								mat->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, false );
								mat->SetMaterialVarFlag( MATERIAL_VAR_FLAT, false );
								mat->SetMaterialVarFlag( MATERIAL_VAR_ALPHATEST, false );
								mat->AlphaModulate( 1.0f );

								col2 = Color( 0, 255, 0 );
								render->SetColorModulation( col2.Base( ) );
							}
						}
						else
						{
							modelinfo->GetModelMaterials( pInfo.pModel, hdr->numtextures, mats );
							for( int i = 0; i < hdr->numtextures; i++ )
							{
								IMaterial* mat = mats[ i ];
								if( !mat )
									continue;

								mat->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, false );
								mat->SetMaterialVarFlag( MATERIAL_VAR_ALPHATEST, false );
								mat->SetMaterialVarFlag( MATERIAL_VAR_FLAT, false );

							}
						}

						modelrender->DrawModelExecute( ctx, state, pInfo, pCustomBoneToWorld );
						modelrender->ForcedMaterialOverride( NULL );

					}
				}
			}
		}
	}
}
where does it crash?
 

LOLKFC

Newbie
Full Member
Oct 23, 2014
17
318
0
C++:
modelrender->DrawModelExecute( ctx, state, pInfo, pCustomBoneToWorld );
 
Status
Not open for further replies.
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods