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 85

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 85

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 85

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 85

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 85

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 85
Getting Actions Functions
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Getting Actions Functions

  1. #1
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125

    Getting Actions Functions

    Hello everybody!! I'm back trying to learn some more and now I'm trying to make my program do some actions in the game.

    I'm working with VC++, injected into the client and I'm trying to learn how to identify and use some tibia functions, right now I'm trying to make my char eat or moove.

    I allready did it by using tibia functions to send packets and by sending messages to the game window and now I want to know if its posible to use tibia functions for this.

    Ex: when I click on an item I guess tibia will rise a click event and then call a "Item Use" function with the information of the item, position, etc. and taht function will send the packets.

    • There is any way to find those functions and use them?
    • It is worth to do it? I guess there will be many adresses to update then.
    • There is any other way you think it might be safer or easier?



    Thank you all!!

  2. #2
    Senior Member
    Join Date
    Dec 2011
    Posts
    249
    The simplest way for me to find these functions I described here: http://tpforums.org/forum/threads/63...5642#post55642

    However I found out after making the screenshots that ASLR was enabled so the addresses shown will not be correct.

    I'd argue that calling internal functions is the safest way to go since you'll most likely never miss if Cipsoft decides to change a packet structure which is easily done otherwise.

  3. #3
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Thank You!! I was able to understund how to find these adresses and found one my self! Great tutotrial, I learned about intermodular calls and how to read the call stack (that was way shorter than I expected).

    I found the adress of the Use Item in container function and I figured out that it takes at least 4 parameters (two times the position in the container, the item id to use and the container id)

    I made this function then:
    Code:
    typedef void(__fastcall *_useItem)(DWORD poscon1, DWORD itemId, DWORD poscon2, DWORD container);
    And called it in sync with the main thread but it crashes tibia
    Here is an example of a call to the use item function

    Add.jpg

    There is something wrong with my function definition?
    How can I tell if there is any other param or the return type?

    Note:
    I have ASLR on too and wen i get the real adress of this fucntion is [0x1DF80 + BaseAdress], maybe is nothing but most adresses have 6 digits, maybe i'm in the wrong module?

  4. #4
    Senior Member
    Join Date
    Dec 2011
    Posts
    249
    I dont think that is the correct parameters. Show the registers and stack when you just call it normally.

    I think the location parameters are pointers to location structures.
    Last edited by ottizy; 03-31-2016 at 05:40 PM.

  5. #5
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Hey! I'm pretty sure those are the values, not cpmpletely sure about the order but that shouldn't make tibia crash.
    How can I know if there is another param involved? Maybe via registers


    To the left is the call stack when I use your method.

    To the right is the registers and the stack when function 12CDF80 is called.

    If you see some discordance between the two sides of the image is because the ASLR changed the addresses between screenshots

    Function 12CDF80 = Function 1BDF80


    Thanks!

  6. #6
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    I've been reading about the fast call convention and I realized that ECX and EDX are also parameters in my function

    ECX is always 0xFFFF
    EDX is 0x40 + IdContainer

    Convention says that allways ECX and EDX come first and then the opther parameters int he stack from left to right;
    So I changed my function to:

    Code:
    typedef void(__fastcall *_useItem)(DWORD ECX, DWORD EDX, DWORD poscon1, DWORD itemId, DWORD poscon2, DWORD container);
    Now the function works, it eats the brea but it makes tibia crash anyways. What am I missing?
    I'm calling _useItem function in sync with peekMessage Function

  7. #7
    Junior Member
    Join Date
    Mar 2016
    Posts
    9
    The first three (ECX, EDX and poscon1 in your case) parameters are the tile coordinates (TileXCoord, TileYCoord, TileZCoord) which the item stands.
    If the item is inside a container, TileXCoord will always be 0xFFFF, TileYCoord will be the container ID (0x41 is the first opened container) and TileZCoord will be the item position within the container.

    The fourth parameter is the item ID and the fifth parameter is again, its position within the container, you deduced them right. (remember that when the item stands on a tile instead of a container, that redundancy does not happens).

    The sixth parameter is not the container ID as you said.
    If UseItem function parameters are similar to UseItemWith function (I suppose they are), the last parameter is TargetIsNotBank (I named it TargetIsNotGround in my code to avoid confusion). TargetIsNotBank is a boolean that will always be 1 for items inside containers. It will only be 0 if the item you are using has the flag isBank (tibia.dat) set to 1.
    Last edited by Brunocg; 04-01-2016 at 05:23 PM.

  8. #8
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Thank for the help!
    But I think you may be mistaken, here is a picture of the stack in the use item function call.

    d2.jpg

    The number 3 is the 6th parameter and its the Id of the container where the item was, i opened 4 container to do this test, the target container last so it must have id 3.

    By the way, do you know about .dat file? I've been trying to read it today but this ecuation...

    Code:
    spritecount = width * height * blendframes * xrepeat * yrepeat * zrepeat * animations
    ...to get the sprites does not match the current structure when animations is bigger than 1.
    I can't fine any pattern

    Thanks again!

  9. #9
    Junior Member
    Join Date
    Mar 2016
    Posts
    9
    Quote Originally Posted by Lolrapa View Post
    Thank for the help!
    But I think you may be mistaken, here is a picture of the stack in the use item function call.

    d2.jpg

    The number 3 is the 6th parameter and its the Id of the container where the item was, i opened 4 container to do this test, the target container last so it must have id 3.

    By the way, do you know about .dat file? I've been trying to read it today but this ecuation...

    Code:
    spritecount = width * height * blendframes * xrepeat * yrepeat * zrepeat * animations
    ...to get the sprites does not match the current structure when animations is bigger than 1.
    I can't fine any pattern

    Thanks again!
    Yea, I may be wrong indeed. As I said, I was supposing that UseItem parameters were similar to UseItemWith. It seems they are not. In spite of that, did you managed to call the function?

    In order to count the sprites, try the following:
    SpritesCount := Width * Height * Layers * PatternWidth * PatternHeight * PatternDepth * Phases;

    There is a really good topic created by Jo3 here that may help you
    Last edited by Brunocg; 04-01-2016 at 10:59 PM.

  10. #10
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Thanks! I found this code http://pastebin.com/YgL99fwg that works fine, it was a trick with the animations.

    My "Use Item" function works, it uses the item but then it crashes tibia, maybe I'm missing something before maind the call

Posting Permissions

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