Raised This Month: $32 Target: $400
 8% 

Variable Offsets (How do i find them or get them)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 03-10-2014 , 20:32   Variable Offsets (How do i find them or get them)
Reply With Quote #1

Hi guys i've got a question
But first i'il tell you my touching story

I was trying to fix a quite awesome plugin HL2 NPCs In CS:S and eventualy maybe later port it to TF
But there is a problem
When i've finished all offsets a some serious shit appeared i think it's called variable offsets
example:
PHP Code:
            /* Variables Offset! */
            
"m_nTargetNodeID" // "Node is visible to player"
            
{
                
"windows"    "832"
            
}
            
"m_pNetwork" // ****** MAP CONTAINS DUPLICATE HAMMER NODE IDS! CHECK FOR PROBLEM
            
{
                
"windows"    "784"
            
}
            

            
/* CBaseEntity */
            
"m_pLink"    // 51 53 8B ? ? ? 55 8B ? ? ? 56 57 33 
            
{
                
"windows"    "212"
            
}

            
            
/* CBaseFlex */
            
"m_LocalToGlobal"    // Unable to find mapping for flexcontroller %i, settings %p on %i/
            
{
                
"windows"    "1512"
            
}

            
/* CSceneEntity */
            
"m_pRecipientFilter"    // snd_mixahead
            
{
                
"windows"    "1496"
            
}
            
"m_pScene"
            
{
                
"windows"    "952"
            
}




            
/* BaseNPC */
            
"m_Conditions"
            
{
                
"windows"    "2108"
            
}
            
"m_pSchedule"    // "Schedule cleared: %s\"
            
{
                
"windows"    "2040"
            
}
            
"m_pSquad" // "Found %s that isn't in a squad\n"
            
{
                
"windows"    "2696"
            
}
            
"m_CustomInterruptConditions"
            
{
                
"windows"    "2140"
            
}
            
"m_poseMove_Yaw" // move_yaw
            
{
                
"windows"    "2104"
            
}
            
"m_InverseIgnoreConditions"
            
{
                
"windows"    "2204"
            
}
            
"m_poseAim_Pitch"
            
{
                
"windows"    "2096"
            
}
            
"m_poseAim_Yaw"
            
{
                
"windows"    "2100"
            
}
            
"m_ConditionsPreIgnore"
            
{
                
"windows"    "2172"
            
}
            
"m_bInChoreo"
            
{
                
"windows"    "2092"
            
}



            
/* CSkyCamera */
            
"m_skyboxData"
            
{
                
"windows"    "776"
            
}



            
/* CRagdollProp */
            
"m_ragdoll"
            
{
                
"windows"    "1076"
            
}




            
/* CGib */
            
"m_lifeTime"
            
{
                
"windows"    "1084"
            
}
            
"m_bForceRemove"
            
{
                
"windows"    "1088"
            
}
            
"m_material"
            
{
                
"windows"    "1080"
            
}
            
"m_cBloodDecals"
            
{
                
"windows"    "1076"
            
}
            
"m_bloodColor"
            
{
                
"windows"    "1100"
            
}



            
/* CCollisionProperty */
            
"m_flRadius"    // fuck this!  CCollisionProperty::m_flRadius
            
{
                
"windows"    "369"
            
}
            
"m_vecSurroundingMins"
            
{
                
"windows"    "396"
            
}
            
"m_vecSurroundingMaxs"
            
{
                
"windows"    "408"
            
}



            
/* CPathTrack */
            
"m_nIterVal"
            
{
                
"windows"    "800"
            
}



            
/* Global Variables */
            
"g_EntityCollisionHash"
            
{
                
"windows"    "1050"
            
}
            
"g_WorldEntity"
            
{
                
"windows"    "20"
            
}
            
"g_vecAttackDir"
            
{
                
"windows"    "187"
            
}
            
"m_DefaultRelationship"
            
{
                
"windows"    "18"
            
}
            
"m_lastInteraction"
            
{
                
"windows"    "1"
            
}
            
"g_SoundController"
            
{
                
"windows"    "1"
            
}
            
"decalsystem"
            
{
                
"windows"    "5"
            
}
            
"m_pActivitySR"
            
{
                
"windows"    "5"
            
}
            
"m_iNumActivities"
            
{
                
"windows"    "33"
            
}
            
"m_pEventSR"
            
{
                
"windows"    "100"
            
}
            
"m_iNumEvents"
            
{
                
"windows"    "8"
            
}
            
"g_pPredictionSystems"
            
{
                
"windows"    "4"
            
}
            
"g_AI_SensedObjectsManager"
            
{
                
"windows"    "1"
            
}
            
"te"
            
{
                
"windows"    "41"
            
}
            
"my_g_MultiDamage"
            
{
                
"windows"    "266"
            
}
            
"g_Templates"
            
{
                
"windows"    "192"
            
}
            
"g_EntityListPool"
            
{
                
"windows"    "83"
            
}
            
"g_CEventQueue"
            
{
                
"windows"    "125"
            
}
            
"g_PostSimulationQueue"
            
{
                
"windows"    "9"
            
}
            
"EventQueuePrioritizedEvent_t_s_Allocator"
            
{
                
"windows"    "17"
            
}
            
"g_TouchTrace"
            
{
                
"windows"    "12"
            
}
            
"gm_AllHints"
            
{
                
"windows"    "9"
            
}
            
"s_GameSystems"
            
{
                
"windows"    "80"
            
}
            
"AI_Waypoint_t_s_Allocator"
            
{
                
"windows"    "765"
            
}
            
"g_AIFriendliesTalkSemaphore"
            
{
                
"windows"    "72"
            
}
            
"g_AIFoesTalkSemaphore"
            
{
                
"windows"    "79"
            
}
            
"g_pNotify"
            
{
                
"windows"    "533"
            
}
            
"gm_TypedHints"
            
{
                
"windows"    "86"
            
}
            
"s_pSymbolTable"
            
{
                
"windows"    "16"
            
}
            
"g_interactionHitByPlayerThrownPhysObj"
            
{
                
"windows"    "678"
            
}
            
"g_AI_SquadManager"
            
{
                
"windows"    "89"
            
}
            
"g_PhysWorldObject"
            
{
                
"windows"    "625"
            
}
            
"g_Collisions"
            
{
                
"windows"    "72"
            
}
            
"sm_pSingleton"
            
{
                
"windows"    "4"
            
}
            
"g_interactionScriptedTarget"
            
{
                
"windows"    "2"
            

I have no idea how to find them
I'd really appreciate that if somebody could help me with that
No tutorial just some hints or tips or something that will enlighten me in this situation

- Thanks

Edit:

Those things are datamaps as far as i know
But sm_dump_datamaps does not prints their offsets so i'm unsure wat
GetDataDescMap() function might print them out but that'd be quite painful
I'd need for each variable find offset of GetDataDescMap() and get ze variable offsets
Oh well this is really confusing
__________________
...

Last edited by Oshizu; 03-10-2014 at 20:36.
Oshizu is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 03-10-2014 , 23:22   Re: Variable Offsets (How do i find them or get them)
Reply With Quote #2

I've tried to update that stuff too some time ago. It's not only the gamedata that needs updates but the css sdk too.

That part are actual class member variables of different classes nothing to do with datamaps. To find the correct offsets you need to find a method of that class which uses/sets them and grab the this+OFFSET from there.

like *(_DWORD *)(v9 + 1544) = v14; for m_pRecipientFilter, where 1544 would be your offset. I don't really know if that is the correct one by the way;)
I checked the sdk for CSceneEntity::m_pRecipientFilter and found a method which sets the filter and is easy to find due to a string. Even though "instanced_scripted_scene" isn't unique, the right function stands out when comparing to the code in the sdk. When checking where the last argument "filter" (a8 in hexrays) is used, we see
PHP Code:
if ( a8 )
  {
    
v13 sub_10172480(32);
    if ( 
v13 )
      
v14 sub_101E7B00(v13);
    else
      
v14 0;
    *(
_DWORD *)(v9 1544) = v14;
    
sub_101E7B80(v14a8);
  } 
So SetRecipientFilter was inlined, but that won't bother us much. We're only interested in that 1544 offset!

For linux it's even easier, because SetRecipientFilter wasn't inlined ;)
PHP Code:
void __cdecl CSceneEntity::SetRecipientFilter(int a1int a2)
{
  
int v2// esi@2

  
if ( a2 )
  {
    
v2 operator new(32);
    
CRecipientFilter::CRecipientFilter(v2);
    *(
_DWORD *)(a1 1564) = v2;
    
CRecipientFilter::CopyFrom(v2a2);
  }

But i don't think that extension supports linux?
__________________

Last edited by Peace-Maker; 03-10-2014 at 23:26.
Peace-Maker is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 03-11-2014 , 02:15   Re: Variable Offsets (How do i find them or get them)
Reply With Quote #3

If you need, I can provide everything needed to run CSS NPC and play. Including server and source code necessary to compile the plugin (for server v72). So you can see all the signatures in the old server.dll and find them in the new server.dll using IDA pseudocode (F5). Or you can use it to understand how to find signatures and offsets. Also you can use it to debug each function of the extension to understand what it does.

My knowledge of the language is not enough to understand how it works, but I can help to find signatures.
Maybe it's better to start to deal with the first version of the plugin, because there is very little code. if you remove all the NPC, except headcrabs, then it will need fewer signatures.
I tried to compile the extension for Linux, but unfortunately it uses a lot of windows dependencies. The project must be initially developed in Qt to be compatible with mingw (windows, linux, mac...)

Last edited by kadet.89; 03-11-2014 at 02:46.
kadet.89 is offline
Send a message via Skype™ to kadet.89
donrevan
AlliedModders Donor
Join Date: Jul 2010
Old 03-11-2014 , 11:46   Re: Variable Offsets (How do i find them or get them)
Reply With Quote #4

Quote:
Originally Posted by kadet.89 View Post
I tried to compile the extension for Linux, but unfortunately it uses a lot of windows dependencies. The project must be initially developed in Qt to be compatible with mingw (windows, linux, mac...)
What.
Qt is a application/UI framework. A application doesn't need to be developed in Qt to be compatible with mingw.
donrevan is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 03-11-2014 , 12:21   Re: Variable Offsets (How do i find them or get them)
Reply With Quote #5

Yes, of course you can use other frameworks, but this way is much easier, than use vs + vs compiler and then rewrite the entire code for mingw. Though maybe I'm wrong and it is possible to use vs+mingw, or there is a vs compiler for Linux?

Last edited by kadet.89; 03-11-2014 at 12:27.
kadet.89 is offline
Send a message via Skype™ to kadet.89
psychonic

BAFFLED
Join Date: May 2008
Old 03-11-2014 , 13:20   Re: Variable Offsets (How do i find them or get them)
Reply With Quote #6

The binaries produced with the mingw gcc compiler are not ABI compatible with binaries produced with the msvc compiler (such as the game binaries).
psychonic is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode