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

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
NEW Packet Structures - Page 2
Page 2 of 13 FirstFirst 123412 ... LastLast
Results 11 to 20 of 129

Thread: NEW Packet Structures

  1. #11
    Senior Member
    Join Date
    Apr 2007
    Posts
    314

    NEW Packet Structures

    Sure Juapillo, just don't forget that a 0 represents the first byte in both my examples (LongToByte( 31320, 0 )
    Code:
    BYTE LongToByte( DWORD dwValue, int nCount ) {
        BYTE ret;
        ret = (dwValue >> (nCount*8)) & 0xFF;
        return ret;
    }
    I guess you could just add a -1 if you want to use LongToByte( 31320, 1 ); where 1 is the first byte:
    Code:
    BYTE LongToByte( DWORD dwValue, int nCount ) {
        BYTE ret;
        ret = (dwValue >> ((nCount-1)*8)) & 0xFF;
        return ret;
    }
    About ASM I'm not sure since I can't try it atm. You could probably just add a sub command:
    Code:
    LongToByte proc szValue:DWORD,nCount:DWORD
        lea eax,szValue ; Set eax to the address of szValue
        sub nCount,1 ; Since people are lazy, subtract 1 from nCount which makes 1 the least possible action
        add eax,nCount ; We add nCount to eax (if nCount is 1 we will return the first byte of the dword)
        movzx eax,byte ptr [eax] ; We move a byte into the 32-bit register using movzx. eax will now hold the correct byte
        ret ; Return eax which holds the correct byte to the application calling this function
    LongToByte endp
    It all just seems so unecessary to force the computer to do another command just because people rather write 1 instead of 0.

  2. #12

    NEW Packet Structures

    Convert the string length to a 16b Integer and then insert the high and low order parts. Should look something like this?
    short strLen = str.length();
    byte lowByte = strLen & 0xFF; //Bitwise AND with 0000000011111111
    byte highByte = strLen >> 8; //Bitwise left shift with 8 bits

    Edit: I'm way to slow replying.

  3. #13
    Senior Member
    Join Date
    Apr 2007
    Posts
    314

    NEW Packet Structures

    Juapillo: If you want to continue with the standard of having LongToByte( x, 1 ) as first byte you should use the ASM code that has sub nCount,1 in it.

  4. #14
    Senior Member
    Join Date
    Mar 2007
    Posts
    218

    NEW Packet Structures

    thanks grob

    coops, i don't understand your code :S

  5. #15

    NEW Packet Structures

    Then I supposed you don't understand how Grob's code work either. The only difference is that he packed it in a function that you can just copy in and use. If you look closely you will realize that.

    The lowByte would contains what had been returned by LongToByte(strLen,1) and highByte = LongToByte(strLen,2).

  6. #16
    Senior Member
    Join Date
    Mar 2007
    Posts
    218

    NEW Packet Structures

    oh, that's right, i didn't notice bout that
    always.. i prefert the LongToByte function because i won't have to put much comments

  7. #17

    NEW Packet Structures

    okay, it can be good to know what the functions you use actually do and why

  8. #18
    Senior Member
    Join Date
    Mar 2007
    Posts
    1,323

    NEW Packet Structures

    I can notice, that the level of programming skills is rising in TProgramming! That's really nice!

    @Juapillo: For beginneers those packet structures can be a bit misleading.. At least they were for me at start. Maybe if you could post whole function (I suppose that you're using functions right) with declarations so it makes clearier image..

  9. #19

    NEW Packet Structures

    Quote Originally Posted by OsQu
    @Juapillo: For beginneers those packet structures can be a bit misleading.. At least they were for me at start. Maybe if you could post whole function (I suppose that you're using functions right) with declarations so it makes clearier image..
    YES YES YES Agree in 100%
    To every packet structure there shloud be a sample.

  10. #20
    Senior Member
    Join Date
    Apr 2007
    Posts
    314

    NEW Packet Structures

    The only things I find hard to understand are things like
    Code:
        packetBuffer(10) = LongToByte(Standing, 1) 'Stack Position
        packetBuffer(11) = LongToByte(BackPacks, 1) 'Slot where you wanna open your backpack
    What Standing and BackPack holds is a mystery, brief explanations on variables like these would be great for people who's just starting out.

    For example, if there's an item beneith the rotwom, should Standing be 0 or 1?

    Oh and Juapillo, it never hurts to hear it too many times; you're doing a great job.

Posting Permissions

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