keybode

csgo sdk

Feb 19th, 2014
1,406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 12.97 KB | None | 0 0
  1. #ifndef SDK_H
  2. #define SDK_H
  3.  
  4. #include "Vector.h"
  5. #include "VMethod.h"
  6.  
  7. #include "dt_recv.h"
  8. #include "crc32_checksum.h"
  9. #include "md5_checksum.h"
  10.  
  11. typedef void* ( *CreateInterfaceFn )( const char*, int* );
  12.  
  13. #undef  CreateFont
  14.  
  15. #define IN_ATTACK               ( 1 << 0 )
  16. #define IN_JUMP                 ( 1 << 1 )
  17. #define IN_DUCK                 ( 1 << 2 )
  18.  
  19. #define FL_ONGROUND             ( 1 << 0 )
  20. #define FL_DUCKING              ( 1 << 1 )
  21.  
  22. #define MULTIPLAYER_BACKUP      ( 150 )
  23.  
  24. #define COLORCODE( r, g, b, a ) ((DWORD_PTR)((((r)&0xFF)<<24)|(((g)&0xFF)<<16)|(((b)&0xFF)<<8)|(((a)&0xFF))))
  25. #define RED( COLORCODE )        ((int)(COLORCODE>>24))
  26. #define BLUE( COLORCODE )       ((int)(COLORCODE>>8)&0xFF)
  27. #define GREEN( COLORCODE )      ((int)(COLORCODE>>16)&0xFF)
  28. #define ALPHA( COLORCODE )      ((int)(COLORCODE&0xFF))
  29. #define RGBA( COLORCODE )       RED(COLORCODE),GREEN(COLORCODE),BLUE(COLORCODE),ALPHA(COLORCODE)
  30.  
  31. class IPanel;
  32. class ISurface;
  33. class IBaseClientDLL;
  34. class IVEngineClient;
  35. class IClientEntityList;
  36. class CInput;
  37. class CUserCmd;
  38. class CVerifiedUserCmd;
  39. class IEngineTrace;
  40. class ClientClass;
  41. class CSPlayer;
  42. class CSWeapon;
  43. class model_t;
  44.  
  45. typedef struct player_info_s
  46. {
  47.     unsigned long long  unknown;
  48.     unsigned long long  xuid;
  49.     char                name[128];
  50.     int                 userID;
  51.     char                guid[32 + 1];
  52.     unsigned int        friendsID;
  53.     char                friendsName[128];
  54.     bool                fakeplayer;
  55.     bool                ishltv;
  56.     unsigned long       customFiles[4];
  57.     unsigned char       filesDownloaded;
  58. } player_info_t;
  59.  
  60. class ClientClass
  61. {
  62. public:
  63.     const char* GetName( )
  64.     {
  65.         return *( char** )( this + 0x8 );
  66.     }
  67.  
  68.     RecvTable* GetTable( )
  69.     {
  70.         return *( RecvTable** )( this + 0xC );
  71.     }
  72.  
  73.     ClientClass* NextClass( )
  74.     {
  75.         return *( ClientClass** )( this + 0x10 );
  76.     }
  77.  
  78.     int GetClassId( )
  79.     {
  80.         return *( int* )( this + 0x14 );
  81.     }
  82. };
  83.  
  84. class IBaseClientDLL
  85. {
  86. public:
  87.     ClientClass* GetAllClasses( )
  88.     {
  89.         typedef ClientClass* ( __thiscall* GetAllClassesFn )( PVOID );
  90.         return GetMethod< GetAllClassesFn >( this, 8 )( this );
  91.     }
  92. };
  93.  
  94. class IClientEntityList
  95. {
  96. public:
  97.     CSPlayer* GetClientEntity( int nIndex )
  98.     {
  99.         typedef CSPlayer* ( __thiscall* GetClientEntityFn )( PVOID, int );
  100.         return GetMethod< GetClientEntityFn >( this, 3 )( this, nIndex );
  101.     }
  102.  
  103.     CSWeapon* GetClientEntityFromHandle( int nHandle )
  104.     {
  105.         typedef CSWeapon* ( __thiscall* GetClientEntityFromHandleFn )( PVOID, int );
  106.         return GetMethod< GetClientEntityFromHandleFn >( this, 4 )( this, nHandle );
  107.     }
  108.  
  109.     int GetHighestEntityIndex( )
  110.     {
  111.         typedef int ( __thiscall* GetHighestEntityIndexFn )( PVOID );
  112.         return GetMethod< GetHighestEntityIndexFn >( this, 6 )( this );
  113.     }
  114. };
  115.  
  116. class IVEngineClient
  117. {
  118. public:
  119.     void GetScreenSize( int& width, int& height )
  120.     {
  121.         typedef void ( __thiscall* GetScreenSizeFn )( PVOID, int& , int& );
  122.         return GetMethod< GetScreenSizeFn >( this, 5 )( this, width, height );
  123.     }
  124.  
  125.     bool GetPlayerInfo( int ent_num, player_info_t* pinfo )
  126.     {
  127.         typedef bool ( __thiscall* GetPlayerInfoFn )( PVOID, int, player_info_t* );
  128.         return GetMethod< GetPlayerInfoFn >( this, 8 )( this, ent_num, pinfo );
  129.     }
  130.  
  131.     int GetLocalPlayer( )
  132.     {
  133.         typedef int ( __thiscall* GetLocalPlayerFn )( PVOID );
  134.         return GetMethod< GetLocalPlayerFn >( this, 12 )( this );
  135.     }
  136.  
  137.     void GetViewAngles( Vector& va )
  138.     {
  139.         typedef void ( __thiscall* GetViewAnglesFn )( PVOID, Vector& );
  140.         GetMethod< GetViewAnglesFn >( this, 18 )( this, va );
  141.     }
  142.  
  143.     void SetViewAngles( Vector& va )
  144.     {
  145.         typedef void ( __thiscall* SetViewAnglesFn )( PVOID, Vector& );
  146.         GetMethod< SetViewAnglesFn >( this, 19 )( this, va );
  147.     }
  148.  
  149.     int GetMaxClients( )
  150.     {
  151.         typedef int ( __thiscall* GetMaxClientsFn )( PVOID );
  152.         return GetMethod< GetMaxClientsFn >( this, 20 )( this );
  153.     }
  154.  
  155.     const VMatrix& WorldToScreenMatrix( )
  156.     {
  157.         typedef const VMatrix& ( __thiscall* WorldToScreenMatrixFn )( PVOID );
  158.         return GetMethod< WorldToScreenMatrixFn >( this, 37 )( this );
  159.     }
  160. };
  161.  
  162. class CUserCmd
  163. {
  164. public:
  165.     virtual ~CUserCmd( ) { };
  166.  
  167.     int     command_number;
  168.     int     tick_count;
  169.     Vector  viewangles;
  170.     Vector  aimdirection;
  171.     float   forwardmove;
  172.     float   sidemove;
  173.     float   upmove;
  174.     int     buttons;
  175.     BYTE    impulse;
  176.     int     weaponselect;
  177.     int     weaponsubtype;
  178.     int     random_seed;
  179.     short   mousedx;
  180.     short   mousedy;
  181.     bool    hasbeenpredicted;
  182.     Vector  headangles;
  183.     Vector  headoffset;
  184. };
  185.  
  186. class CVerifiedUserCmd
  187. {
  188. public:
  189.     CUserCmd    m_cmd;
  190.     ULONG       m_crc;
  191. };
  192.  
  193. class CInput
  194. {
  195. public:
  196.     CUserCmd* GetUserCmd( int nSlot, int sequence_number )
  197.     {
  198.         typedef CUserCmd* ( __thiscall* GetUserCmdFn )( PVOID, int, int );
  199.         return GetMethod< GetUserCmdFn >( this, 8 )( this, nSlot, sequence_number );
  200.     }
  201.    
  202.     char                __pad0[ 0xE4 ];
  203.     CUserCmd*           m_pCmd;
  204.     CVerifiedUserCmd*   m_pVerifiedCmd;
  205. };
  206.  
  207. class CGlobalVarsBase
  208. {
  209. public:
  210.     float           realtime;
  211.     int             framecount;
  212.     float           absoluteframetime;
  213.     float           curtime;
  214.     float           frametime;
  215.     int             maxClients;
  216.     int             tickcount;
  217.     float           interval_per_tick;
  218.     float           interpolation_amount;
  219.     int             simTicksThisFrame;
  220.     int             network_protocol;
  221. };
  222.  
  223. struct mstudiobbox_t
  224. {
  225.     int                 bone;
  226.     int                 group;
  227.     Vector              bbmin;
  228.     Vector              bbmax; 
  229.     int                 szhitboxnameindex;
  230.     int                 unused[8];
  231.  
  232.     const char* pszHitboxName( ) const
  233.     {
  234.         if( szhitboxnameindex == 0 )
  235.             return "";
  236.  
  237.         return ( ( const char* )this ) + szhitboxnameindex;
  238.     }
  239. };
  240.  
  241. struct mstudiohitboxset_t
  242. {
  243.     int                     sznameindex;
  244.     inline char* const      pszName( void ) const { return ( ( char* )this ) + sznameindex; }
  245.     int                     numhitboxes;
  246.     int                     hitboxindex;
  247.     inline mstudiobbox_t*   pHitbox( int i ) const { return ( mstudiobbox_t* )( ( ( BYTE* )this ) + hitboxindex ) + i; };
  248. };
  249.  
  250. struct studiohdr_t
  251. {
  252.     unsigned char       pad[0xAC];
  253.     int                 numhitboxsets;
  254.     int                 hitboxsetindex;
  255.  
  256.     mstudiohitboxset_t* pHitboxSet( int i ) const
  257.     {
  258.         return ( mstudiohitboxset_t* )( ( ( BYTE* )this ) + hitboxsetindex ) + i;
  259.     };
  260.  
  261.     inline mstudiobbox_t* pHitbox( int i, int set ) const
  262.     {
  263.         mstudiohitboxset_t const* s = pHitboxSet( set );
  264.  
  265.         if( !s )
  266.             return NULL;
  267.  
  268.         return s->pHitbox( i );
  269.     };
  270.  
  271.     inline int iHitboxCount( int set ) const
  272.     {
  273.         mstudiohitboxset_t const* s = pHitboxSet( set );
  274.  
  275.         if( !s )
  276.             return 0;
  277.  
  278.         return s->numhitboxes;
  279.     };
  280. };
  281.  
  282. struct Ray_t
  283. {
  284.     VectorAligned   m_Start;
  285.     VectorAligned   m_Delta;
  286.     VectorAligned   m_StartOffset;
  287.     VectorAligned   m_Extents;
  288.  
  289.     const   matrix3x4_t* m_pWorldAxisTransform;
  290.  
  291.     bool    m_IsRay;
  292.     bool    m_IsSwept;
  293.  
  294.     Ray_t( ) : m_pWorldAxisTransform( NULL ) { }
  295.  
  296.     void Init( Vector& vecStart, Vector& vecEnd )
  297.     {
  298.         m_Delta = vecEnd - vecStart;
  299.  
  300.         m_IsSwept = ( m_Delta.LengthSqr( ) != 0 );
  301.  
  302.         m_Extents.x = m_Extents.y = m_Extents.z = 0.0f;
  303.  
  304.         m_pWorldAxisTransform = NULL;
  305.  
  306.         m_IsRay = true;
  307.  
  308.         m_StartOffset.x = m_StartOffset.y = m_StartOffset.z = 0.0f;
  309.  
  310.         m_Start = vecStart;
  311.     }
  312. };
  313.  
  314. struct cplane_t
  315. {
  316.     Vector  normal;
  317.     float   dist;
  318.     BYTE    type;
  319.     BYTE    signbits;
  320.     BYTE    pad[2];
  321. };
  322.  
  323. class CBaseTrace
  324. {
  325. public:
  326.     Vector          startpos;
  327.     Vector          endpos;
  328.     cplane_t        plane;
  329.     float           fraction;
  330.     int             contents;
  331.     unsigned short  dispFlags;
  332.     bool            allsolid;
  333.     bool            startsolid;
  334. };
  335.  
  336. struct csurface_t
  337. {
  338.     const char*     name;
  339.     short           surfaceProps;
  340.     unsigned short  flags;
  341. };
  342.  
  343. class CGameTrace : public CBaseTrace
  344. {
  345. public:
  346.     bool            DidHitWorld( ) const;
  347.     bool            DidHitNonWorldEntity( ) const;
  348.     int             GetEntityIndex( ) const;
  349.     bool            DidHit( ) const;
  350. public:
  351.     float           fractionleftsolid;
  352.     csurface_t      surface;
  353.     int             hitgroup;
  354.     short           physicsbone;
  355.     unsigned short  worldSurfaceIndex;
  356.     CSPlayer*       m_pEnt;
  357.     int             hitbox;
  358. };
  359.  
  360. inline bool CGameTrace::DidHit( ) const
  361. {
  362.     return fraction < 1.0f || allsolid || startsolid;
  363. }
  364.  
  365. typedef CGameTrace trace_t;
  366.  
  367. enum TraceType_t
  368. {
  369.     TRACE_EVERYTHING = 0,
  370.     TRACE_WORLD_ONLY,
  371.     TRACE_ENTITIES_ONLY,
  372.     TRACE_EVERYTHING_FILTER_PROPS,
  373. };
  374.  
  375. class ITraceFilter
  376. {
  377. public:
  378.     virtual bool        ShouldHitEntity( PVOID pEntity, int contentsMask ) = 0;
  379.     virtual TraceType_t GetTraceType( ) const = 0;
  380. };
  381.  
  382. class IEngineTrace
  383. {
  384. public:
  385.     void TraceRay( const Ray_t& ray, unsigned int flMask, ITraceFilter* pTraceFilter, trace_t* pTrace )
  386.     {
  387.         typedef void ( __thiscall* TraceRayFn )( PVOID, const Ray_t&, unsigned int, ITraceFilter*, trace_t* );
  388.         GetMethod< TraceRayFn >( this, 5 )( this, ray, flMask, pTraceFilter, pTrace );
  389.     }
  390. };
  391.  
  392. class IVModelInfoClient
  393. {
  394. public:
  395.     const char* GetModelName( const model_t* model )
  396.     {
  397.         typedef const char* ( __thiscall* GetModelNameFn )( PVOID, const model_t* );
  398.         return GetMethod< GetModelNameFn >( this, 3 )( this, model );
  399.     }
  400.     studiohdr_t* GetStudiomodel( const model_t* mod )
  401.     {
  402.         typedef studiohdr_t* ( __thiscall* GetStudiomodelFn )( PVOID, const model_t* );
  403.         return GetMethod< GetStudiomodelFn >( this, 30 )( this, mod );
  404.     }
  405. };
  406.  
  407. class IPanel
  408. {
  409. public:
  410.     const char* GetPanelName( unsigned int vguiPanel )
  411.     {
  412.         typedef const char* ( __thiscall* GetPanelNameFn )( void*, unsigned int );
  413.         return GetMethod< GetPanelNameFn >( this, 36 )( this, vguiPanel );
  414.     }
  415. };
  416.  
  417. class ISurface
  418. {
  419. public:
  420.     void DrawSetColor( int r, int g, int b, int a )
  421.     {
  422.         typedef void ( __thiscall* DrawSetColorFn )( PVOID, int, int, int, int );
  423.         GetMethod< DrawSetColorFn >( this, 14 )( this, r, g, b, a );
  424.     }
  425.  
  426.     void DrawFilledRect( int x0, int y0, int x1, int y1 )
  427.     {
  428.         typedef void ( __thiscall* DrawFilledRectFn )( PVOID, int, int, int, int );
  429.         GetMethod< DrawFilledRectFn >( this, 15 )( this, x0, y0, x1, y1 );
  430.     }
  431.  
  432.     void DrawOutlinedRect( int x0, int y0, int x1, int y1 )
  433.     {
  434.         typedef void ( __thiscall* DrawOutlinedFn )( PVOID, int, int, int, int );
  435.         GetMethod< DrawOutlinedFn >( this, 17 )( this, x0, y0, x1, y1 );
  436.     }
  437.  
  438.     void DrawLine( int x0, int y0, int x1, int y1 )
  439.     {
  440.         typedef void ( __thiscall* DrawLineFn )( PVOID, int, int, int, int );
  441.         GetMethod< DrawLineFn >( this, 18 )( this, x0, y0, x1, y1 );
  442.     }
  443.  
  444.     void DrawSetTextFont( unsigned long font )
  445.     {
  446.         typedef void ( __thiscall* DrawSetTextFontFn )( PVOID, unsigned long );
  447.         GetMethod< DrawSetTextFontFn >( this, 22 )( this, font );
  448.     }
  449.  
  450.     void DrawSetTextColor( int r, int g, int b, int a )
  451.     {
  452.         typedef void ( __thiscall* DrawSetTextColorFn )( PVOID, int, int, int, int );
  453.         GetMethod< DrawSetTextColorFn >( this, 24 )( this, r, g, b, a );
  454.     }
  455.  
  456.     void DrawSetTextPos( int x, int y )
  457.     {
  458.         typedef void ( __thiscall* DrawSetTextPosFn )( PVOID, int, int );
  459.         GetMethod< DrawSetTextPosFn >( this, 25 )( this, x, y );
  460.     }
  461.  
  462.     void DrawPrintText( const wchar_t* text, int textLen )
  463.     {
  464.         typedef void ( __thiscall* DrawPrintTextFn )( PVOID, const wchar_t*, int, int );
  465.         return GetMethod< DrawPrintTextFn >( this, 27 )( this, text, textLen, 0 );
  466.     }
  467.  
  468.     unsigned long CreateFont( )
  469.     {
  470.         typedef unsigned int ( __thiscall* CreateFontFn )( PVOID );
  471.         return GetMethod< CreateFontFn >( this, 70 )( this );
  472.     }
  473.  
  474.     void SetFontGlyphSet( unsigned long font, const char* windowsFontName, int tall, int weight, int blur, int scanlines, int flags )
  475.     {
  476.         typedef void ( __thiscall* SetFontGlyphSetFn )( PVOID, unsigned long, const char*, int, int, int, int, int, int, int );
  477.         GetMethod< SetFontGlyphSetFn >( this, 71 )( this, font, windowsFontName, tall, weight, blur, scanlines, flags, 0, 0 );
  478.     }
  479.  
  480.     void GetTextSize( unsigned long font, const wchar_t* text, int& wide, int& tall )
  481.     {
  482.         typedef void ( __thiscall* GetTextSizeFn )( PVOID, unsigned long, const wchar_t*, int&, int& );
  483.         GetMethod< GetTextSizeFn >( this, 78 )( this, font, text, wide, tall );
  484.     }
  485. };
  486.  
  487. enum ButtonCode_t
  488. {
  489.     BUTTON_CODE_INVALID = -1,
  490.     BUTTON_CODE_NONE = 0,
  491.     KEY_FIRST = 0,
  492.     KEY_NONE = KEY_FIRST,
  493.     KEY_0,
  494.     KEY_1,
  495.     KEY_2,
  496.     KEY_3,
  497.     KEY_4,
  498.     KEY_5,
  499.     KEY_6,
  500.     KEY_7,
  501.     KEY_8,
  502.     KEY_9,
  503.     KEY_A,
  504.     KEY_B,
  505.     KEY_C,
  506.     KEY_D,
  507.     KEY_E,
  508.     KEY_F,
  509.     KEY_G,
  510.     KEY_H,
  511.     KEY_I,
  512.     KEY_J,
  513.     KEY_K,
  514.     KEY_L,
  515.     KEY_M,
  516.     KEY_N,
  517.     KEY_O,
  518.     KEY_P,
  519.     KEY_Q,
  520.     KEY_R,
  521.     KEY_S,
  522.     KEY_T,
  523.     KEY_U,
  524.     KEY_V,
  525.     KEY_W,
  526.     KEY_X,
  527.     KEY_Y,
  528.     KEY_Z,
  529.     KEY_PAD_0,
  530.     KEY_PAD_1,
  531.     KEY_PAD_2,
  532.     KEY_PAD_3,
  533.     KEY_PAD_4,
  534.     KEY_PAD_5,
  535.     KEY_PAD_6,
  536.     KEY_PAD_7,
  537.     KEY_PAD_8,
  538.     KEY_PAD_9,
  539.     KEY_PAD_DIVIDE,
  540.     KEY_PAD_MULTIPLY,
  541.     KEY_PAD_MINUS,
  542.     KEY_PAD_PLUS,
  543.     KEY_PAD_ENTER,
  544.     KEY_PAD_DECIMAL,
  545.     KEY_LBRACKET,
  546.     KEY_RBRACKET,
  547.     KEY_SEMICOLON,
  548.     KEY_APOSTROPHE,
  549.     KEY_BACKQUOTE,
  550.     KEY_COMMA,
  551.     KEY_PERIOD,
  552.     KEY_SLASH,
  553.     KEY_BACKSLASH,
  554.     KEY_MINUS,
  555.     KEY_EQUAL,
  556.     KEY_ENTER,
  557.     KEY_SPACE,
  558.     KEY_BACKSPACE,
  559.     KEY_TAB,
  560.     KEY_CAPSLOCK,
  561.     KEY_NUMLOCK,
  562.     KEY_ESCAPE,
  563.     KEY_SCROLLLOCK,
  564.     KEY_INSERT,
  565.     KEY_DELETE,
  566.     KEY_HOME,
  567.     KEY_END,
  568.     KEY_PAGEUP,
  569.     KEY_PAGEDOWN,
  570.     KEY_BREAK,
  571.     KEY_LSHIFT,
  572.     KEY_RSHIFT,
  573.     KEY_LALT,
  574.     KEY_RALT,
  575.     KEY_LCONTROL,
  576.     KEY_RCONTROL,
  577.     KEY_LWIN,
  578.     KEY_RWIN,
  579.     KEY_APP,
  580.     KEY_UP,
  581.     KEY_LEFT,
  582.     KEY_DOWN,
  583.     KEY_RIGHT,
  584.     KEY_F1,
  585.     KEY_F2,
  586.     KEY_F3,
  587.     KEY_F4,
  588.     KEY_F5,
  589.     KEY_F6,
  590.     KEY_F7,
  591.     KEY_F8,
  592.     KEY_F9,
  593.     KEY_F10,
  594.     KEY_F11,
  595.     KEY_F12,
  596.     KEY_CAPSLOCKTOGGLE,
  597.     KEY_NUMLOCKTOGGLE,
  598.     KEY_SCROLLLOCKTOGGLE,
  599.     KEY_LAST = KEY_SCROLLLOCKTOGGLE,
  600.     KEY_COUNT = KEY_LAST - KEY_FIRST + 1,
  601.     MOUSE_FIRST = KEY_LAST + 1,
  602.     MOUSE_LEFT = MOUSE_FIRST,
  603.     MOUSE_RIGHT,
  604.     MOUSE_MIDDLE,
  605.     MOUSE_4,
  606.     MOUSE_5,
  607.     MOUSE_WHEEL_UP,
  608.     MOUSE_WHEEL_DOWN,
  609.     MOUSE_LAST = MOUSE_WHEEL_DOWN,
  610.     MOUSE_COUNT = MOUSE_LAST - MOUSE_FIRST + 1,
  611. };
  612.  
  613. #endif // SDK_H
Advertisement
Add Comment
Please, Sign In to add comment