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 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 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 85
Synchronizing and thread hijacking
Page 1 of 5 123 ... LastLast
Results 1 to 10 of 49

Thread: Synchronizing and thread hijacking

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

    Synchronizing and thread hijacking

    Well, I think this has passed from a coffee chat since I cant fix this f*** sh**

    @DarkstaR you told me by chat that I should do this to make it work
    1)Freeze tibia's main thread
    2)Change the thread's instruction pointer to the address of my cave code
    3)Storing orginal data
    4)Resume thread
    5)After returning from the call, inside my code cave I have to restore the original data
    6)Change the instruction pointer to the original location

    It sounds perfectly logic, but my code makes it in a different way and I'd like to know whats the difference
    I do: (for packet sending)
    1) Freeze tibia's main thread
    2) Save OutgoingDataLen and AutgoingDataBuffer
    3)Write new len and buffer values
    4)Create a new thread and ejecute my code cave in it
    5)Restore old Len and Buffer values
    6)Resume main thread
    (this makes tibia crash after many executions)


    So, my questions are:
    If I open a new thread inside tibia process the new thread and the main thread share the registers or if I modify a register in the new thread it won't modify in the main thread?
    (If the register are shared)Then it means that I have to copy and restore every register that SendOutgoinPacket touchs? If so why in't allready that in TibiaSocket's code?


    Thanks!!

  2. #2
    I'm totally noob about this, but are you sure you have to restore the last Len/Buffer values? Did you try without do that?

  3. #3
    Quote Originally Posted by Casky View Post
    I'm totally noob about this, but are you sure you have to restore the last Len/Buffer values? Did you try without do that?
    You do, 100%. If Tibia was in the middle of creating a packet, it will resume thinking that the packet is half done and finish creating it, then send a half-built packet.


    Make sure there's no other data associated with the packet. For instance, the incoming packet buffer has position and length.

  4. #4
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Quote Originally Posted by DarkstaR View Post
    You do, 100%. If Tibia was in the middle of creating a packet, it will resume thinking that the packet is half done and finish creating it, then send a half-built packet.


    Make sure there's no other data associated with the packet. For instance, the incoming packet buffer has position and length.
    Ok, now that i know about the context switch I can stay cool

    SENDOUTGOINGPACKET modifies the incoming packet buffer?

  5. #5
    Quote Originally Posted by DarkstaR View Post
    You do, 100%. If Tibia was in the middle of creating a packet, it will resume thinking that the packet is half done and finish creating it, then send a half-built packet.
    Oh, that makes totally sense, thank you.

  6. #6
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Quote Originally Posted by DarkstaR View Post
    You do, 100%. If Tibia was in the middle of creating a packet, it will resume thinking that the packet is half done and finish creating it, then send a half-built packet.


    Make sure there's no other data associated with the packet. For instance, the incoming packet buffer has position and length.
    I've been runnung some test and I found that just calling SENDOUTGOINGPACKET changes a random amount of bytes in the memory (from 20 to 17000). There must be another thread changing the memory wile main thread is freezed. I can't find what is making the clinet crash.
    If I freeze the main thread during a process that needs synchronization (with the server or something), that wouldn't make the client crash?

  7. #7
    Quote Originally Posted by Lolrapa View Post
    I've been runnung some test and I found that just calling SENDOUTGOINGPACKET changes a random amount of bytes in the memory (from 20 to 17000). There must be another thread changing the memory wile main thread is freezed. I can't find what is making the clinet crash.
    If I freeze the main thread during a process that needs synchronization (with the server or something), that wouldn't make the client crash?
    This isn't a great test because of exactly what you just said: other threads.

    A better way to find what is modified is to look at all constants touched by the assembly code of the send packet function.

  8. #8
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Quote Originally Posted by DarkstaR View Post
    This isn't a great test because of exactly what you just said: other threads.

    A better way to find what is modified is to look at all constants touched by the assembly code of the send packet function.
    Ok, there are probably like 10000 but i'll try :P

  9. #9
    Quote Originally Posted by Lolrapa View Post
    Ok, there are probably like 10000 but i'll try :P
    It's a really small function if you look closely.. Many of the values are debug related (you can tell by the strings around them and safely ignore them). The first value (in the MOV fs:[0]) is also setting up the exception handler, so it can be ignored as well.

  10. #10
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Quote Originally Posted by DarkstaR View Post
    It's a really small function if you look closely.. Many of the values are debug related (you can tell by the strings around them and safely ignore them). The first value (in the MOV fs:[0]) is also setting up the exception handler, so it can be ignored as well.
    Can you show me how memory writes looks like, I've been looking for things like this MOV ESI,DWORD PTR DS:[A68248] but they seem to be text in memory

Posting Permissions

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