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

Solved [CS:GO] Is it possible to get/set variables from the game code?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 11-04-2020 , 14:36   [CS:GO] Is it possible to get/set variables from the game code?
Reply With Quote #1

I would like to know if it is possible to get/set variables from the game code itself, if yes then how? For example this one:

https://github.com/perilouswithadoll...cs_bot.h#L1233
__________________

Last edited by manicogaming; 11-05-2020 at 15:50.
manicogaming is offline
Zeisen
Member
Join Date: Nov 2016
Location: Republic of Korea
Old 11-05-2020 , 17:02   Re: [CS:GO] Is it possible to get/set variables from the game code?
Reply With Quote #2

I apologize my english is rubbish...

You must hack dll and get offset.

For example, let's try to get m_isFollowing offset.

https://github.com/perilouswithadoll...cs_bot.h#L1001

And find some code where using m_isFollowing property in source code.

I found this one:
https://github.com/perilouswithadoll...achine.cpp#L84

and as you can see, in that code, compares m_isFollowing(https://github.com/perilouswithadoll...achine.cpp#L90).

And set m_isFollowing property values to true(https://github.com/perilouswithadoll...achine.cpp#L93).

and open server.dll and go to CCSBot::Follow function.



keep it mind, COMPARES m_isfollowing, and SET m_isfollowing to true.

let's find offset which use 2 times. because in source code, compares, and set value (totally 2 times)

I found this one: 3C10h.



but it's not the offset what we want find. because there are 2 'mov' instruction. its about set values (like, move instruction is... eax, 123123(assambler) -> a = 123123(C, java, etc))

and I found this one: 3C0Ch.

looks like this offset is right which we want find! because there are 'cmp', 'mov' instruction. comapres, and set value.

and let's convert offset to decimal. cause that offset is hexadecimal.
(and we can get 15372 value converting by 3C0C)

and make game data file like this.


and lets test some code like this...
Code:
#include <sourcemod>
#include <sdktools>

Handle g_gameConfig = INVALID_HANDLE;
int g_isFollowingOffset;

public void OnPluginStart()
{
	RegAdminCmd("sm_test_offset", Cmd_Offset, ADMFLAG_GENERIC);
	
	g_gameConfig = LoadGameConfigFile("bot_new.games");
    g_isFollowingOffset = GameConfGetOffset(g_gameConfig, "CCSBot::m_isFollowing");
}

public Action Cmd_Offset(int client, int args)
{
	for (int i=1; i<=MaxClients; i++)
	{
		if (!IsFakeClient(i))
			continue;
		
		bool isFollowing = view_as<bool>(LoadFromAddress(GetEntityAddress(i) + view_as<Address>(g_isFollowingOffset), NumberType_Int8));
		PrintToChatAll("%N bot is following? %s", i, (isFollowing ? "YES!" : "NO."));
	}
	
	return Plugin_Handled;
}
and I tested got(cliffe is my teammate, and I maked him follow me):

Cliffe bot is following? YES!
Wolf bot is following? NO.

Last edited by Zeisen; 11-06-2020 at 16:13. Reason: shitty typo test code
Zeisen is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 11-06-2020 , 04:10   Re: [CS:GO] Is it possible to get/set variables from the game code?
Reply With Quote #3

Minor note, but you should use GetEntData rather than LoadFromAddress there.
__________________
asherkin is offline
Zeisen
Member
Join Date: Nov 2016
Location: Republic of Korea
Old 11-06-2020 , 16:16   Re: [CS:GO] Is it possible to get/set variables from the game code?
Reply With Quote #4

Quote:
Originally Posted by asherkin View Post
Minor note, but you should use GetEntData rather than LoadFromAddress there.
I thought that GetEntData is legacy and no more using it. Thanks for feedback
Zeisen 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 23:01.


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