How to Get Interfaces (Source Engine Xbox 360)

CRACKbomber Jul 28, 2013

  1. CRACKbomber

    CRACKbomber Resident Xbox Guru XPG Developer
    105/188

    Joined:
    Sep 12, 2011
    Messages:
    276
    Likes Received:
    235
    Trophy Points:
    25
    Gender:
    Male
    Location:
    Michigan
    Console:
    Xbox
    Getting interfaces allows you to control in game elements such as getting various game info. This method works across all source engine games, CSGO to HL2.

    First off you're going to need to create a new dll (I use Jackass' trainer engine).

    Create a new header file and name it "interfaces.h".

    Add the following code to your new .h file.

    NOTE: I am going to be doing TF2 in this example
    Code:
    #ifndef INTERFACES_H
    #define INTERFACES_H
    #pragma once
    
    typedef void* (*CreateInterfaceFn)(const char *pName, int *pReturnCode);
    
    //Place holders for our CreateInterfaceFn addresses.
    #define TF2_ENGINE_CFN 0x00000000
    #define TF2_CLIENT_CFN 0x00000000
    #define TF2_VSTDLIB_CFN 0x00000000
    #define TF2_VGUIMAT_CFN 0x00000000
    
    
    CreateInterfaceFn g_EngineInterface;
    CreateInterfaceFn g_VGUIInterface;
    CreateInterfaceFn g_ClientInterface;
    CreateInterfaceFn g_VSTDInterface;
    
    
    #endif
    
    Now we need to get the addresses for our CreateInterfaceFn's.

    Open Engine_360.dll in IDA and let it load up.
    [​IMG]

    Once it's loaded navigate to the Exports tab.

    [​IMG]

    Copy the address from ordinal one and replace
    Code:
    #define TF2_ENGINE_CFN 0x00000000
    
    with
    Code:
    #define TF2_ENGINE_CFN 0x8630C3F0
    
    in our interfaces.h file.

    Now do this for all the dlls you want to get interfaces from. The 4 I defined ( vstdlib_360.dll, engine_360.dll, client_360.dll, and vguimatsurface_360.dll) are the ones I use.

    How do you know what dll has what interface?
    You have to find out through the public sdk, and common sense.

    Now that we have our CreateInterfaceFn addresses defined we can cast them into the functions.

    NOTE: You must have a sleep on your dll to wait until the engine dlls are loaded, other wise your xbox will crash.

    Add this code to your trainer dll.
    Code:
    #include "interfaces.h"
    
    // Create interface functions
    g_EngineInterface		= (CreateInterfaceFn)TF2_ENGINE_CFN;
    g_ClientInterface		= (CreateInterfaceFn)TF2_CLIENT_CFN;
    g_VSTDInterface		        = (CreateInterfaceFn)TF2_VSTD_CFN;
    g_VGUIInterface		        = (CreateInterfaceFn)TF2_VGUIMAT_CFN;
    
    Now that we have our CreateInterface functions setup we can query interfaces!

    To query interfaces you need to have the interface file for it. Most of the ones for TF2 are available in Valve's public sdk, but for the newer games you'll have to reverse engineer the changes.

    All interfaces have an interface string that tells it's name and version. ie: VClient015.

    Some times these don't change at all through the games.

    Here is an example on how to query an interface.
    Code:
    ICvar*			g_pICvar;
    IVEngineClient* g_pIEngineClient;
    ISurface*		g_pISurface;
    IBaseClientDLL* g_pIBaseClient;
    
    VOID GetInterfaces()
    {
       g_pICvar			= ( ICvar* )g_VSTDInterface("VEngineCvar004", 0);
       g_pIEngineClient	        = ( IVEngineClient* )g_EngineInterface("VEngineClient013", 0);
       g_pISurface			= (ISurface*) g_VGUIInterface("VGUI_Surface030", 0);
       g_pIBaseClient		= (IBaseClientDLL*)g_ClientInterface("VClient015",0);
    }
    
    Now we can call the cool interface functions :)
    Code:
    // Wait until we are in the game
    while (!g_pIEngineClient->IsInGame())
    	Sleep(200);
    printf("we are in a game");
    Sleep(1000);
    player_info_t pInfo;
    g_pIEngineClient->GetPlayerInfo(g_pIEngineClient->GetLocalPlayer(),&pInfo);
    printf("Player %s's info\nName: %s\nGUID %s\nUID%i",pInfo.name,pInfo.guid,pInfo.userID);
    
    And that's how you get interfaces :) Enjoy.
     
  2. Bu

    Bullet Guest

    Great tutorial CRACKBOMBER, always got the good stuff.
     
  3. Coder123

    Coder123 Finnish Modder XPG Developer TeamXPG
    105/188

    Joined:
    Jan 21, 2012
    Messages:
    1,953
    Likes Received:
    717
    Trophy Points:
    105
    Gender:
    Male
    Location:
    Finland
    Console:
    Xbox
    Nice :O
     

Share This Page

Close