This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[L4D2] "m_iClip1" net_prop's value for "rifle_m60" has a max value of 255


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fraggor
Member
Join Date: Jun 2020
Old 10-21-2023 , 05:39   [L4D2] "m_iClip1" net_prop's value for "rifle_m60" has a max value of 255
Reply With Quote #1

Hi, in the net_props and data_maps dumps, the type of the member "m_iClip1" is 4Bytes 1-Byte, yet when using a value above 255 (the max value that a boolean variable can represent) it seems to overflow off course it will overflow

Here's a small snippet to demonstrate the issue:

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sdkhooks>

public void OnEntityCreated(int entity, const char[] classname) {
    if ( 
strcmp(classname"weapon_rifle_m60") == )
        
SDKHook(entitySDKHook_SpawnPostOnSpawnPost);
}

void OnSpawnPost(int entity) {
    if( !
IsValidEntity(entity) )
        return;

    
RequestFrame(OnNextFrameEntIndexToEntRef(entity));
}

void OnNextFrame(int entity) {
    if( (
entity EntRefToEntIndex(entity)) != INVALID_ENT_REFERENCE ) {
        
SetEntProp(entityProp_Send"m_iClip1"300); // this will overflow

        
static char classname[32];
        
GetEdictClassname(entityclassnamesizeof(classname));
        
int clipsize GetEntProp(entityProp_Send"m_iClip1");

        
PrintToChatAll("Spawned: %s | index: %d"classnameentity);
        
PrintToChatAll("with clip size %d"clipsize);
    }

Using Mission and Weapons - Info Editor to increase the "clip_size" value of "weapon_rifle_m60" has the same effect

A possible solution is to do something similar to this

Edit: on Windows the "m_iClip1" net_prop is 1-Byte long, whereas on Linux it's 4-Bytes (32-Bits), Rooky mistake

Still unsolved though

Last edited by Fraggor; 10-22-2023 at 21:23. Reason: correct wrong information
Fraggor is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 10-22-2023 , 19:39   Re: [L4D2] "m_iClip1" net_prop's value for "rifle_m60" has a max value of 255
Reply With Quote #2

besides being 4 bytes in datamaps, in netprops is 8 bits, which max value is 255.

datamaps:
m_iClip1 (Offset 5140) (Save)(4 Bytes)

netprops:
Member: m_iClip1 (offset 5140) (type integer) (bits 8) (Unsigned)
__________________

Last edited by Marttt; 10-22-2023 at 19:40.
Marttt is offline
Fraggor
Member
Join Date: Jun 2020
Old 10-22-2023 , 21:10   Re: [L4D2] "m_iClip1" net_prop's value for "rifle_m60" has a max value of 255
Reply With Quote #3

Many thanks for the correction, you're absolutely correct.

I've Just dumped the net_props of a Windows binary, and just like you wrote it's the size of a byte
I was looking at the dumps of a Linux binary
Fraggor 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 22:08.


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