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
[Error] Using the Tibia functions
Results 1 to 5 of 5

Thread: [Error] Using the Tibia functions

  1. #1
    Senior Member
    Join Date
    Jul 2011
    Posts
    120

    [Error] Using the Tibia functions

    Hello guys, does anyone know what you're wrong?
    I'm trying to inject a dll, but when I run the procedure does not work right, I use Delphi 2010, the same code works in Delphi 7.

    Code:
    PHP Code:
    const
      
    FSpeechAdress = $004073F0// 8.6

    var
      
    FSpeechprocedure(const speechTypeInteger; const textString); stdcall;

    begin
      
    @FSpeech := Ptr(FSpeechAdress);
      
    // Execute
      
    FSpeech($1'Testing'); 
    Result:
    00:56 Test [1]: T
    Last edited by Kush; 03-01-2013 at 05:06 AM.

  2. #2
    Senior Member
    Join Date
    Sep 2007
    Posts
    230
    First stdcall is the wrong calling convention to use as the callee cleans the stack for this function, use cdecl instead as using stdcall will result in a corrupted stack pointer. If your program indeed ran fine with stdcall before you simply got lucky.

    Now based on your result of only a single character I surmise that Delphi 2010 is using a 2-byte Unicode encoding (eg: "T\0" for 'T') for its string type which would be causing Tibia to stop processing it at the second byte due to a NULL byte immediately after the 'T' byte. A quick Google search does reveal that the string type will either be UnicodeString or AnsiString depending whether your project has been Unicode enabled. You should use the AnsiString type for any strings that will interface with Tibia's code, however you may need to pass them to Tibia's code through a PAnsiChar pointer (unsure how Delphi marshals an AnsiString to external functions).

    And one more thing, if you aren't doing so already make sure this code is synchronised with Tibia.

  3. #3
    Senior Member
    Join Date
    Jul 2011
    Posts
    120
    Oh, Thanks.

    Working:
    PHP Code:
    var
      
    FSpeechprocedure(const speechTypeInteger; const textAnsiString); 
    But I'm wondering if it is really safe to use in Tibia Global.
    Last edited by Kush; 03-01-2013 at 03:27 PM.

  4. #4
    Senior Member
    Join Date
    Nov 2009
    Posts
    320
    Sketchy, when using internals, I never had problems, even not synchronizing with Tibia...
    Can you explain about it ? Why I need to sync with Tibia, and... how ?
    oi amiguinhos

  5. #5
    Senior Member
    Join Date
    Sep 2007
    Posts
    230
    Well taking this particular case for example the function being called is one of Tibia's outgoing packet constructors all of which write their packet to a single buffer which is ultimately encrypted and passed along to the socket send function. These aren't designed for concurrency and concurrently running two of them will likely cause both packets to be corrupted and potentially a client crash (not too sure about this case, but other internal functions it definitely could). So if your call isn't synchronised with Tibia you run the risk of its main thread calling one of these functions at the same time, and this risk increases greatly if the player is manually playing at the time too.

    Ideally any call to Tibia's internals should be synchronised no matter how small the risk of concurrency issues is. Thankfully synchronisation is easy and you may be doing it already without realising, just hook one of Tibia's functions (eg: FPS print) to call your code which will then run from its main thread.

Posting Permissions

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