Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Nullset a string
Results 1 to 6 of 6

Thread: Nullset a string

  1. #1

    Nullset a string

    HI AGIN.

    I decided to make a Tibia - Information program (example, you walk to Edron hero cave, and before stairs down:
    STATUS MESSAGE: Heroes - Monsters: Hero),

    it works so far, with 1 problem: The text string continues after 0x00 with the text that was there from beginning.

    Example: 13:57 Cipfried: Welcome to the temple of Rookgaard!
    Will be: Welcome to TibiaMonster 1.0 mple of Rookgaard!

    I tried to nullset the string with this:
    Code:
    	byte byte1[1000] = "Welcome to TibiaMonster 1.0";
    	for(int i = 0; i < 972; i++){
    		byte1[28+i] = 0x00;
    	}
    But problem is, I would have to do it with all byte strings, and it would be painful.
    Anyone has an idea?

    QUESTION: How to nullset all of string, with inserting 1 character, or a short function?

    Thanks.

  2. #2
    Senior Member
    Join Date
    Dec 2011
    Posts
    249
    If I understood this correctly I believe the only thing you'll have to do is to add a null character after your string. Like this:

    Code:
    byte byte1[1000] = "Welcome to TibiaMonster 1.0\0";

  3. #3
    Fantastic, works.Thanx.

  4. #4
    Member
    Join Date
    Feb 2009
    Posts
    76
    Why are you allocating 1000 bytes for a string which has +/- 30 bytes?
    char * message = "Welcome to TibiaMonster 1.0";

  5. #5
    Sry, im having virus (reinstalling computer)
    -_-

    I did 1000 bytes for making lots of zero's for string
    the backslash zero didnt work, cipfried still says stuff underneath my string.

  6. #6
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    Quote Originally Posted by Xleniz View Post
    Sry, im having virus (reinstalling computer)
    -_-

    I did 1000 bytes for making lots of zero's for string
    the backslash zero didnt work, cipfried still says stuff underneath my string.
    If you are reading it in CheatEngine or a memory viewer it will most likely ignore any null string terminator. Default ASCII BitConverters do not account for them either. For that reason, you should modify your ReadString function to work like this pseudocode:

    Code:
    char[] totalstring
    for each char in string
        if char != '\0' then
            totalstring.append(char)
        else
            return totalstring
        end
    end
    return totalstring
    Of course you'll probably want to use a stringbuilder or something for the totalstring var, or maybe a List<> or some shit, since you can't extend arrays in such a way (at least not in C#, I know it's possible in Python).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •