[Best solution] Wait for the detour to finish menu

Shout-Out

User Tag List

Results 1 to 3 of 3
  1. #1
    Corthezz's Avatar Elite User Authenticator enabled
    Reputation
    386
    Join Date
    Nov 2011
    Posts
    325
    Thanks G/R
    191/98
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Best solution] Wait for the detour to finish

    Hello,
    in my current bot I hook EndScene to get my codecave executed by the main thread.
    My ASM is checking if a certain address is equal 1. If this case occurs the injected code get called and the adress will be set to 0 after execution.

    Finally I can use the construction like this:
    Code:
    inject(asm, address) // inject code
    write<uint>(codeCaveEnabled, 1) // let the code get executed
    while (read<uint>codecaveEnabled == 1); //wait for execution to end
    I wonder if there is any more performant way to do this? I talked with a mate a few days ago and he said using the while loop is pretty bad and referred me to Thread.WaitOne and Thread.Set however I cant figure out where the benefit is using this.

    In general I am using many while loops in combinisation with timers were I need to wait a bit but dont want to sleep the thread (other thread would work and maybe take to long etc).

    Thanks in advance
    Last edited by Corthezz; 11-11-2013 at 05:13 AM.

    [Best solution] Wait for the detour to finish
  2. #2
    Valediction's Avatar Active Member
    Reputation
    37
    Join Date
    Jul 2012
    Posts
    48
    Thanks G/R
    8/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I'm currently doing is setting up a synchronized mechanism in the function, first to check if there is anything to execute, and then to wait for the detour to finish/retrieve retvalues. Indeed, using Wait/Notify or similar synchronization mechanisms seems the most logical approach here.

    Goes like:

    - Synchronized check to see if there's anything to execute
    If so, do it, and use a WAIT primitive.
    From the function call requested, place the return value somewhere and use a NOTIFY primitive.
    - Retrieve the return value after being waked up.

    (I use a generic wrapper function to set up all the synchronization/return values appropriately)

    It's basically a simplified producer/consumer. I currently execute one function per tick, but if you need a higher call rate, you could set up a function queue and use a similar scheme, but calling N functions per detour hit.

    The benefit is performance (and elegance), busy while-loops are typically one of the worst synchronization methods.

  3. #3
    danwins's Avatar Contributor
    Reputation
    189
    Join Date
    Mar 2013
    Posts
    143
    Thanks G/R
    6/62
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what exactly are you trying to accomplish with this code?

    sounds like you would benefit from being in-process, so when your asm is called rather then just setting the variable/address and checking it you can directly call the function that needs to execute.

Similar Threads

  1. Can't wait for the new expansion of Diablo 3, Reaper of Soul!
    By AmieeLouire in forum Diablo 3 General
    Replies: 0
    Last Post: 11-06-2013, 05:04 AM
  2. I am waiting for the Diablo III
    By Christon in forum Diablo 3 General
    Replies: 0
    Last Post: 03-24-2012, 02:17 AM
  3. Waiting for the PTR to finish downloading..
    By Jorbyrules in forum The Back Room
    Replies: 1
    Last Post: 06-12-2010, 03:12 PM
  4. Looking for the bests equipment for a lvl 29 druid
    By bait in forum World of Warcraft General
    Replies: 4
    Last Post: 02-13-2007, 01:13 PM
All times are GMT -5. The time now is 02:21 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search