Results 1 to 3 of 3
  1. #1
    CyanRed3's Avatar
    Join Date
    Feb 2016
    Gender
    male
    Location
    cfitsio.dll
    Posts
    79
    Reputation
    10
    Thanks
    425
    My Mood
    Cheerful

    studiohdr_t crash

    I've been hit with a crash and I can't seem to find out why its doing it. I've tried debugging it and setting breakpoints around. But it keeps crashing everytime it runs..
    Code:
    studiohdr_t * studio = Interfaces::ModelInfo->GetStudiomodel(pEntity->GetModel());
    the studiohdr_t struct:
    Code:
    struct studiohdr_t
    {
    	int id;
    	int version;
    
    	long checksum; // this has to be the same in the phy and vtx files to load!
    
    	inline const char* pszName(void) const
    	{
    		return name;
    	}
    
    	char name[64];
    
    	int length;
    
    	Vector eyeposition; // ideal eye position
    
    	Vector illumposition; // illumination center
    
    	Vector hull_min; // ideal movement hull size
    	Vector hull_max;
    
    	Vector view_bbmin; // clipping bounding box
    	Vector view_bbmax;
    
    	int flags;
    
    	int numbones; // bones
    	int boneindex;
    
    	inline mstudiobone_t* pBone(int i) const
    	{
    		Assert(i >= 0 && i < numbones);
    		return (mstudiobone_t *)(((byte *)this) + boneindex) + i;
    	};
    	int RemapSeqBone(int iSequence, int iLocalBone) const; // maps local sequence bone to global bone
    	int RemapAnimBone(int iAnim, int iLocalBone) const; // maps local animations bone to global bone
    
    	int numbonecontrollers; // bone controllers
    	int bonecontrollerindex;
    
    	inline mstudiobonecontroller_t* pBonecontroller(int i) const
    	{
    		Assert(i >= 0 && i < numbonecontrollers);
    		return (mstudiobonecontroller_t *)(((byte *)this) + bonecontrollerindex) + i;
    	};
    
    	int numhitboxsets;
    	int hitboxsetindex;
    
    	// Look up hitbox set by index
    	mstudiohitboxset_t* pHitboxSet(int i) const
    	{
    		Assert(i >= 0 && i < numhitboxsets);
    		return (mstudiohitboxset_t *)(((byte *)this) + hitboxsetindex) + i;
    	};
    
    	// Calls through to hitbox to determine size of specified set
    	inline mstudiobbox_t* pHitbox(int i, int set) const
    	{
    		mstudiohitboxset_t const* s = pHitboxSet(set);
    		if (!s)
    			return NULL;
    
    		return s->pHitbox(i);
    	};
    
    	// Calls through to set to get hitbox count for set
    	inline int iHitboxCount(int set) const
    	{
    		mstudiohitboxset_t const* s = pHitboxSet(set);
    		if (!s)
    			return 0;
    
    		return s->numhitboxes;
    	};
    
    	// file local animations? and sequences
    	//private:
    	int numlocalanim; // animations/poses
    	int localanimindex; // animation descriptions
    	inline mstudioanimdesc_t* pLocalAnimdesc(int i) const
    	{
    		return NULL;
    	};
    
    	int numlocalseq; // sequences
    	int localseqindex;
    
    	inline mstudioseqdesc_t* pLocalSeqdesc(int i) const
    	{
    		return NULL;
    	};
    
    	//public:
    	bool SequencesAvailable() const
    	{
    		return true;
    	}
    
    	int GetNumSeq() const;
    	mstudioanimdesc_t& pAnimdesc(int i) const;
    	mstudioseqdesc_t& pSeqdesc(int i) const;
    	int iRelativeAnim(int baseseq, int relanim) const; // maps seq local anim reference to global anim index
    	int iRelativeSeq(int baseseq, int relseq) const; // maps seq local seq reference to global seq index
    
    	//private:
    	mutable int activitylistversion; // initialization flag - have the sequences been indexed?
    	mutable int eventsindexed;
    	//public:
    	int GetSequenceActivity(int iSequence);
    	void SetSequenceActivity(int iSequence, int iActivity);
    	int GetActivityListVersion(void);
    	void SetActivityListVersion(int version) const;
    	int GetEventListVersion(void);
    	void SetEventListVersion(int version);
    
    	// raw textures
    	int numtextures;
    	int textureindex;
    
    	inline mstudiotexture_t* pTexture(int i) const
    	{
    		return NULL;
    	};
    
    	// raw textures search paths
    	int numcdtextures;
    	int cdtextureindex;
    
    	inline char* pCdtexture(int i) const
    	{
    		return (((char *)this) + *((int *)(((byte *)this) + cdtextureindex) + i));
    	};
    
    	// replaceable textures tables
    	int numskinref;
    	int numskinfamilies;
    	int skinindex;
    
    	inline short* pSkinref(int i) const
    	{
    		return (short *)(((byte *)this) + skinindex) + i;
    	};
    
    	int numbodyparts;
    	int bodypartindex;
    
    	inline mstudiobodyparts_t* pBodypart(int i) const
    	{
    		return NULL;
    	};
    };
    the CModelInfo Class:
    Code:
    class CModelInfo
    {
    public:
    	int	GetModelIndex(const char *name)
    	{
    		typedef int(__thiscall* oGetModelName)(PVOID, const char *);
    		return call_vfunc< oGetModelName >(this, 2)(this, name);
    	}
    	const char *GetModelName(const model_t *mod)
    	{
    		typedef const char *(__thiscall* oGetModelName)(PVOID, const model_t*);
    		return call_vfunc< oGetModelName >(this, 3)(this, mod);
    	}
    
    	studiohdr_t	*GetStudiomodel(const model_t *mod)
    	{
    		typedef studiohdr_t *(__stdcall* oGetStudiomodel)(const model_t*);
    		return call_vfunc< oGetStudiomodel >(this, 30)(mod);
    	}
    };
    the IClientRenderable class which is where pLocal->GetModel() is:
    Code:
    class IClientRenderable
    {
    public:
    	virtual ~IClientRenderable() {};
    
    	model_t* GetModel()
    	{
    		void* pRenderable = (void*)(this + 4);
    		typedef model_t* (__thiscall* fnGetModel)(void*);
    		return call_vfunc<fnGetModel>(pRenderable, 8)(pRenderable);
    	}
    
    	bool SetupBones(vMatrix* pBoneMatrix, int nMaxBones, int nBoneMask, float flCurTime = 0)
    	{
    		typedef bool(__thiscall* oSetupBones)(PVOID, vMatrix*, int, int, float);
    		return call_vfunc< oSetupBones>(this, 13)(this, pBoneMatrix, nMaxBones, nBoneMask, flCurTime);
    	}
    
    	void GetRenderBounds(Vector& mins, Vector& maxs)
    	{
    		typedef void(__thiscall* oGetRenderBounds)(PVOID, Vector&, Vector&);
    		return call_vfunc<oGetRenderBounds>(this, 17)(this, mins, maxs);
    	}
    };
    and where im getting the ModelInfo Interface:
    Code:
    EngineFactory = (CreateInterface_t)GetProcAddress((HMODULE)Offsets::Modules::Engine, "CreateInterface");
    char* EngineModelInfoInterface = (char*)ToolKit::FindTextPattern("engine.dll", "VModelInfoClient0");
    ModelInfo = (CModelInfo*)EngineFactory(EngineModelInfoInterface, NULL);
    CModelInfo* ModelInfo;
    i dont usually ask for help so dont kill me too hard

  2. #2
    certmemer's Avatar
    Join Date
    Feb 2016
    Gender
    female
    Location
    Southampton
    Posts
    2,511
    Reputation
    104
    Thanks
    25,994
    check for a null pointer, eh
    my steam acc: click
    donate me a few cents: click

  3. #3
    CyanRed3's Avatar
    Join Date
    Feb 2016
    Gender
    male
    Location
    cfitsio.dll
    Posts
    79
    Reputation
    10
    Thanks
    425
    My Mood
    Cheerful
    //Solved..
    turned out i had the wrong GetModel() function.. ty

    old:
    Code:
    class IClientRenderable
    {
    public:
    	virtual ~IClientRenderable() {};
    
    	model_t* GetModel()
    	{
    		void* pRenderable = (void*)(this + 4);
    		typedef model_t* (__thiscall* fnGetModel)(void*);
    		return call_vfunc<fnGetModel>(pRenderable, 8)(pRenderable);
    	}
    
    	bool SetupBones(vMatrix* pBoneMatrix, int nMaxBones, int nBoneMask, float flCurTime = 0)
    	{
    		typedef bool(__thiscall* oSetupBones)(PVOID, vMatrix*, int, int, float);
    		return call_vfunc< oSetupBones>(this, 13)(this, pBoneMatrix, nMaxBones, nBoneMask, flCurTime);
    	}
    
    	void GetRenderBounds(Vector& mins, Vector& maxs)
    	{
    		typedef void(__thiscall* oGetRenderBounds)(PVOID, Vector&, Vector&);
    		return call_vfunc<oGetRenderBounds>(this, 17)(this, mins, maxs);
    	}
    };
    new:
    Code:
    class IClientRenderable
    {
    public:
    	virtual ~IClientRenderable() {};
    
    	model_t* GetModel()
    	{
    		typedef model_t* (__thiscall* fnGetModel)(PVOID);
    		return call_vfunc<fnGetModel>(this, 8)(this);
    	}
    
    	bool SetupBones(vMatrix* pBoneMatrix, int nMaxBones, int nBoneMask, float flCurTime = 0)
    	{
    		typedef bool(__thiscall* oSetupBones)(PVOID, vMatrix*, int, int, float);
    		return call_vfunc< oSetupBones>(this, 13)(this, pBoneMatrix, nMaxBones, nBoneMask, flCurTime);
    	}
    
    	void GetRenderBounds(Vector& mins, Vector& maxs)
    	{
    		typedef void(__thiscall* oGetRenderBounds)(PVOID, Vector&, Vector&);
    		return call_vfunc<oGetRenderBounds>(this, 17)(this, mins, maxs);
    	}
    };
    Last edited by CyanRed3; 06-11-2017 at 02:09 PM.

Similar Threads

  1. Anti-Crash
    By EleMentX in forum Hardware & Software Support
    Replies: 9
    Last Post: 04-12-2007, 04:17 AM
  2. Kid crashes into Mall
    By arunforce in forum General
    Replies: 1
    Last Post: 12-15-2006, 04:55 PM
  3. Apple - A new kind of crash.
    By Dave84311 in forum General
    Replies: 2
    Last Post: 07-26-2006, 08:58 PM