Extreme laggage on my threadage menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Extreme laggage on my threadage

    I have 2 threads running along with a keyboard hook running in my app. One of the threads updates X, Y, Z. The other thread parses the location of enemies around me through TLS. I can't think of any way to speed up this thread, it is EXTREMELY slow on my laptop at least... Here's the code I'm using...

    Code:
     
    public void getObjects()
    {
    curObj = ReadFourBytes(hWow, (long)(s_curMgr + 0xAC));
    labelCurObj.Text = curObj.ToString();
    nextObj = curObj;
    
    while(curObj != 0 && curObj != 0x1C)
    {
    UInt64 cGUID = 0;
    cGUID = ReadEightBytes(hWow, (long)(curObj + 0x30));
    
    float cX = Memory.ReadFloat(hWow, (long)(curObj + 0xBF4), false);
    float cY = Memory.ReadFloat(hWow, (long)(curObj + 0xBF0), false);
    float cZ = Memory.ReadFloat(hWow, (long)(curObj + 0xBF8), false);
    
    if(cGUID == localGUID)
    {
    localObj = curObj;
    objFieldPtr = Memory.ReadUInt(hWow, (long)(curObj + 0x8));
    targetGUID = Memory.ReadUInt64(hWow, (long)(objFieldPtr + 0x40));
    labelTGUID.Text = targetGUID.ToString();
    labelLGUID.Text = localGUID.ToString();
    }
    
    if(targetGUID == cGUID && targetGUID != 0)
    {
    targetLocX = cX;
    targetLocY = cY;
    targetLocZ = cZ;
    }
    
    nextObj = ReadFourBytes(hWow, (long)(curObj + 0x3C));
    if(nextObj == curObj)
    break;
    curObj = nextObj;
    Thread.Sleep(100);
    }
    }

    Extreme laggage on my threadage
  2. #2
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're using a Sleep(100) which will pause the thread for 1/10th of a second in each pass. Apart from that I can't see anything obvious that would slow it down.

  3. #3
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The thread isn't too terrible slow the first time, but it seems to get slower and not update my targetGUID very well. My other thread is working quite well. I wouldn't imagine the sleep(100); slowing it down much at all, i only put it there since my other threads need some time to execute.

  4. #4
    Shynd's Avatar Contributor
    Reputation
    97
    Join Date
    May 2008
    Posts
    393
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do either a Sleep(1) or Sleep(10) and you'll see it speed up considerably, without chewing up too much CPU. Other than that, it shouldn't run too slowly. I have nearly the same loop in one of my threads (except it updates a list of objects instead of form components) with a Thread.Sleep(1) and it doesn't chew up CPU at all and seems to update information in near-real-time.

  5. #5
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Heh, thanks Shynd. You're my idol :P



    OK, I tried what you said and my program is running great now. The only thing that isnt working is my targetGUID, it only updates as soon as I click refresh values.
    Last edited by lanman92; 07-30-2008 at 03:25 PM.

  6. #6
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by lanman92 View Post
    The thread isn't too terrible slow the first time, but it seems to get slower and not update my targetGUID very well. My other thread is working quite well. I wouldn't imagine the sleep(100); slowing it down much at all, i only put it there since my other threads need some time to execute.

    Threading times/priorities/etc are handled automatically by your OS. You don't need to put a massive sleep so your 'other threads have time to execute'.


    Originally Posted by Shynd View Post
    Do either a Sleep(1) or Sleep(10) and you'll see it speed up considerably, without chewing up too much CPU. Other than that, it shouldn't run too slowly. I have nearly the same loop in one of my threads (except it updates a list of objects instead of form components) with a Thread.Sleep(1) and it doesn't chew up CPU at all and seems to update information in near-real-time.

    I don't know if it's different in C# but when I'm enumerating objects in C++ I don't need to call Sleep at all.

  7. #7
    Shynd's Avatar Contributor
    Reputation
    97
    Join Date
    May 2008
    Posts
    393
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I'm only calling it occasionally, no, I don't need the sleep. I have it looping constantly, though. Infinite loop + no sleep = 100% CPU usage (or 100% of whatever core it's running on), pretty much no matter what the language.

  8. #8
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    While you're on, could you tell me why it doesn't update my target GUID properly when i switch targets? It only does it whenever i first hit my refresh values button, which starts both threads.

  9. #9
    Apoc's Avatar Angry Penguin
    Reputation
    1387
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/12
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Shynd View Post
    If I'm only calling it occasionally, no, I don't need the sleep. I have it looping constantly, though. Infinite loop + no sleep = 100% CPU usage (or 100% of whatever core it's running on), pretty much no matter what the language.
    Not quite.

    A thread with an infinite loop (or semi-infinite as most threads are) will take up an entire thread in the local thread pool. (And not allow other threads to execute. We had a problem with this in OB.NET not too long ago, where one thread was locking everything up because it had 0 delay on running another loop. It wouldn't allow other threads to execute)

    I suggest using at LEAST a 500ms sleep on memory reading threads. (Or you run the risk of burning memory and CPU just trying to read it so often.)

    Keep in mind, reflection/marshaling is incredibly slow in comparison to what C++ provides, and it takes more "oompf" to get it working.

  10. #10
    Shynd's Avatar Contributor
    Reputation
    97
    Join Date
    May 2008
    Posts
    393
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Apoc View Post
    Not quite.

    A thread with an infinite loop (or semi-infinite as most threads are) will take up an entire thread in the local thread pool. (And not allow other threads to execute. We had a problem with this in OB.NET not too long ago, where one thread was locking everything up because it had 0 delay on running another loop. It wouldn't allow other threads to execute)

    I suggest using at LEAST a 500ms sleep on memory reading threads. (Or you run the risk of burning memory and CPU just trying to read it so often.)

    Keep in mind, reflection/marshaling is incredibly slow in comparison to what C++ provides, and it takes more "oompf" to get it working.
    I dunno, I have the same basic bot outline written in C#, VB.NET, C++ (unmanaged, with both external and in-process variations), python, and FASM, and if I remove the Sleep(1) from any of them, it chews the unholy shit out of whatever CPU core it's executing on. The only one that doesn't is AutoIt, but that's a really shitty implementation of a 'language' anyway. Edit: And, yeah, not allowing any other threads to execute was a bit of a problem for me for a little while, as well. Two concurrent threads executing cpu-intensive code == fail.



    And, lanman, I have no idea why. I don't see where localGUID is being defined, so I do not know how you are setting the value of that variable, so I do not know if it is ever equal to cGUID. That is the only thing I can think of: maybe localGUID is being changed in some way (nulled?) and that causes your if-statement to never evaluate true.
    Last edited by Shynd; 07-30-2008 at 05:09 PM.

  11. #11
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My localGUID gets defined in the same function where i retrieve s_curMgr and g_localConnection. I wrote a basic command line version almost the same as yours that displays all objects linked through s_curmgr. here's the output, it gets the targetGUID and teleports to it.

    Code:
     
    GUID: 0x400000000D83519D  X: 1  Y: 0  Z: 0
    GUID: 0x400000000D83519E  X: 1  Y: 0  Z: 0
    GUID: 0x400000000D83519F  X: 1  Y: 0  Z: 0
    GUID: 0x400000000D8351A1  X: 1  Y: 0  Z: 0
    GUID: 0x400000000D8351A0  X: 1  Y: 0  Z: 0
    GUID: 0x400000000D8351A2  X: 0  Y: 0  Z: 0
    GUID: 0x400000000D8351A3  X: 0  Y: 0  Z: 0
    GUID: 0x00000000001A3975  X: 667.748  Y: 10411.28  Z: 1324.082
    GUID: 0xF1300007EF001284  X: 650.01  Y: 10353.4  Z: 1329.37
    GUID: 0xF1300007EF001283  X: 635.9808  Y: 10392.73  Z: 1327.341
    GUID: 0xF1300007C0001286  X: 662.5806  Y: 10383.25  Z: 1326.006
    Teleported.
    GUID: 0xF1300007C00017E0  X: 589.686  Y: 10409.7  Z: 1325.435
    GUID: 0xF1300007C000101C  X: 689.5941  Y: 10349.64  Z: 1327.186
    GUID: 0xF11000080D0004E2  X: 0  Y: 0  Z: 0
    GUID: 0xF11000806F0004E3  X: 1  Y: 1327.87  Z: 0
    GUID: 0xF130002187000861  X: 713.794  Y: 10407.2  Z: 1321.617
    GUID: 0xF11002521E0008C9  X: 1  Y: 1321.53  Z: 0
    GUID: 0xF11002521E0003C4  X: 1  Y: 1329.06  Z: 0
    GUID: 0xF130002F80000E3D  X: 743.603  Y: 10395  Z: 1319.88
    GUID: 0x00000000001A38E0  X: 714.6417  Y: 10403.68  Z: 1321.714
    GUID: 0xF1300007EF0017DF  X: 600.124  Y: 10430.8  Z: 1322.791
    GUID: 0x00000000001A3560  X: 719.0043  Y: 10391.19  Z: 1323.926
    GUID: 0x00000000001A3904  X: 728.2156  Y: 10381.32  Z: 1323.981
    GUID: 0xD79151ECC134797E  X: 6.310887E-30  Y: 0  Z: 0
    GUID: 0x0000000000000000  X: 3.402823E+38  Y: 3.402823E+38  Z: 3.402823E+38
    s_curMgr: 0x022D0F08
    g_clientConnection: 0x09D68008
    localGUID: 0x00000000001A3975
    Speed: 7
    ObjType: 25
    HP: 69
    MP: 0
    TargetGUID: 0xF1300007C00017E0
    TargetHP: 367831920
    TargetX: 589.686
    TargetY: 10409.7
    Done with functions.

  12. #12
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Teleports to it? Private server I assume.

  13. #13
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep, I'm writing this for a friend. not to mention myself :P

  14. #14
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, I got my program to start working. Instead of parsing through all of the objects through TLS in a thread, i only have it parse them upto my localGUID and my target. The only problem is i have no way to filter out if the target isnt a target, if i missclick, i get sent out into the middle of...nowhere. It sucks. Any ideas on how i could verify that its a valid GUID?

    EDIT:
    Here's my code for my function that gets executed when you hit 7........
    Code:
    void keyPressed(object sender, System.Windows.Forms.KeyPressEventArgs e)
    {
    string buffer = tbKbdHook.Text;
    char keyChar = buffer.ToCharArray()[0];
    if(e.KeyChar == '7')
    {
    getObjects();
    }
    }
    
    void getObjects()
    {
    curObj = ReadFourBytes(hWow, (long)(s_curMgr + 0xAC));
    nextObj = curObj;
    
    while(curObj != 0)
    {
    UInt64 cGUID = ReadEightBytes(hWow, (long)(curObj + 0x30));
    
    if(cGUID == localGUID)
    {
    localObj = curObj;
    objFieldPtr = ReadFourBytes(hWow, (long)(localObj + 0x8));
    labelObjectFPtr.Text = objFieldPtr.ToString();
    targetGUID = ReadEightBytes(hWow, (long)(objFieldPtr + 0x40));
    labelTGUID.Text = targetGUID.ToString();
    
    }
    
    if(cGUID == targetGUID && localGUID != 0)
    {
    target.X = Memory.ReadFloat(hWow, (curObj + 0xBF0), false);
    target.Y = Memory.ReadFloat(hWow, (curObj + 0xBF4), false);
    target.Z = Memory.ReadFloat(hWow, (curObj + 0xBF8), false);
    Memory.WriteMemory(hWow, (long)(localObj + 0xBF0), (float)(target.X));
    Memory.WriteMemory(hWow, (long)(localObj + 0xBF4), (float)(target.Y));
    Memory.WriteMemory(hWow, (long)(localObj + 0xBF8), (float)(target.Z + 5.0F));
    return;
    }
    
    nextObj = ReadFourBytes(hWow, (long)(curObj + 0x3C));
    if (nextObj == curObj)
    break;
    else
    curObj = nextObj;
    }
    }


  15. #15
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ugh, okay. I'm trying to do this on my own, and it's going very bad. I tried writing a function to read the objectType at offset 0x14. I ran my target on that, but it still seems to teleport me out to nowhere whenever i'm not targeting anything.

    Code:
     
    uint objectType;
    objectType = getTargetType(curObj);
    if(objectType != 1 && objectType != 2 && objectType != 5 && objectType != 6)
    {
    Memory.WriteMemory(hWow, (long)(localObj + 0xBF0), (float)(target.X));
    Memory.WriteMemory(hWow, (long)(localObj + 0xBF4), (float)(target.Y));
    Memory.WriteMemory(hWow, (long)(localObj + 0xBF8), (float)(target.Z + 5.0F));
    return;
    }
    Code:
     
    public uint getTargetType(uint targetObject)
    {
    uint objBuffer = Memory.ReadUInt(hWow, (long)(targetObject));
    uint type = Memory.ReadUInt(hWow, (long)(objBuffer + 0x14));
    return type;
    }
    EDIT:
    Ha, i got it to work. turns out that targetGUID == 0 whenever your player isnt targeting anything :P simple if statement fixed her up
    Last edited by lanman92; 08-01-2008 at 07:35 PM.

Page 1 of 2 12 LastLast

Similar Threads

  1. Netherwing Egg >>> Giant Outlands Root (Extremely easy to see)
    By kkosik in forum World of Warcraft Model Editing
    Replies: 17
    Last Post: 08-03-2012, 01:22 PM
  2. Extremely good model editor NEEDED FOR THIS
    By barnyonfire1 in forum WoW ME Questions and Requests
    Replies: 7
    Last Post: 05-09-2010, 04:23 AM
  3. Extreme Mac-over: Model Editing Edition (WoW TBC Model Editing Fix for Mac)
    By Athrin Onu in forum World of Warcraft Model Editing
    Replies: 53
    Last Post: 11-26-2007, 08:20 PM
  4. [Reskin] Extreme Model Make-Over : Gnome Edition
    By The Ronin in forum World of Warcraft Model Editing
    Replies: 4
    Last Post: 10-14-2007, 12:55 AM
  5. Hyjal Extremely easy
    By Cheezeit117 in forum World of Warcraft Exploration
    Replies: 19
    Last Post: 04-10-2007, 03:54 PM
All times are GMT -5. The time now is 07:09 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search