[C# Code] Arch tool facing out of process menu

User Tag List

Results 1 to 15 of 15
  1. #1
    counted's Avatar Contributor Authenticator enabled
    Reputation
    203
    Join Date
    Mar 2008
    Posts
    183
    Thanks G/R
    11/108
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    [C# Code] Arch tool facing out of process

    Working on adding Archeology to my bot

    I read one of the other arch threads and saw the Quaternion reference which helped once i got to the unpack routine and the angle calc routine.

    I used the Tom_Rus Ida database to get to the actual code.

    I tested this on 10 or so arch dig sites and it worked on all of them.

    Code:
                    var packed = TC.Wr.Read<long>(TC.Wr.Read<uint>(TC.Wr.Read<uint>(node.Address + 0x1c8) + 0x4) + 0x20 + 0x100);
    
                    q.x = (packed >> 42) * (1.0f / 2097152.0f);
    
                    q.y = (((packed << 22) >> 32) >> 11) * (1.0f / 1048576.0f);
    
                    q.z = (packed << 43 >> 43) * (1.0f / 1048576.0f);
    
                    q.w = q.x * q.x + q.y * q.y + q.z * q.z;
    
                    if (Math.Abs(q.w - 1.0f) >= (1.0f / 1048576.0f))
                        q.w = (float)Math.Sqrt(1.0f - q.w);
                    else
                        q.w = 0.0f;
    
                    var Y = 2 * q.z * q.w + 2 * q.x * q.y;
    
                    var X = 1 - 2 * q.y * q.y - 2 * q.z * q.z;
    
                    var result = Math.Atan2(Y, X);  // answer in radians 
    
                    SystemLog("Angle = " + result * 180 / Math.PI);  // if angle is negative add 360 degrees to it

    [C# Code] Arch tool facing out of process
  2. #2
    mazer's Avatar Member Authenticator enabled
    Reputation
    11
    Join Date
    Sep 2007
    Posts
    69
    Thanks G/R
    7/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry for bumping an old thread,
    but i guess this is the only way to get the facing of the survey tool while staying out of process.

    i've tried OP's code and get a strage behavior when the angle of the survey tool is greater than 180°.
    i've debugged the whole last day and have ask a whole lot of people but nobody was able to help me.

    dump of the vars and a possible error in the calculation below.

    so, here is the code i'm using:

    Code:
    ulong packed = Memory.ReadUInt64(Memory.ReadUInt(Memory.ReadUInt(ObjectBaseAdress + 0x1c8) + 0x4) + (0x20 + 0x100));
    
    Console.WriteLine("[DEBUG] Packed: " + packed.ToString());
    
    
                var x = (packed >> 42) * (1.0f / 2097152.0f);
                var y = (((packed << 22) >> 32) >> 11) * (1.0f / 1048576.0f);
                var z = (packed << 43 >> 43) * (1.0f / 1048576.0f);
                var w = x * x + y * y + z * z;
    
    
                Console.WriteLine("[DEBUG] x: " + x.ToString() + " " + " y: " + y.ToString() + " " + " z: " + z.ToString() + " " + " w: " + w.ToString());
    
    
    
    
                if (Math.Abs(w - 1.0f) >= (1.0f / 1048576.0f))
                {
                    Console.WriteLine("[DEBUG] w if match");
                    w = (float)Math.Sqrt(1.0f - w);
                }
                else
                {
                    Console.WriteLine("[DEBUG] w if no match");
                    w = 0.0f;
                }
    
    
                Console.WriteLine("[DEBUG] w after if: " + w.ToString());
    
    
                var Y = 2 * z * w + 2 * x * y;
                var X = 1 - 2 * y * y - 2 * z * z;
    
    
                Console.WriteLine("[DEBUG] Y: " + Y.ToString() + " " + " X: " + X.ToString());
    
    
                var result = Math.Atan2(Y, X);
    
    
                var angle = result * 180 / Math.PI;
    
    
                Console.WriteLine("[DEBUG] angle pre if: " + angle.ToString());
    
    
                if (angle < 0)
                {
                    angle = angle + 360;
                }
    
    
                Console.WriteLine("[DEBUG] result: " + result.ToString());
                Console.WriteLine("[DEBUG] angle: " + angle.ToString());
    
    
                return angle;


    yes it's basicly the same as the OP's code.

    as stated, the calculation works flawless for angles smaller than 180°


    here is a dump of the vars when everthing works:
    angle smaller 180°

    Code:
    [DEBUG] Packed: 365024
    [DEBUG] x: 0  y: 0  z: 0,348114  w: 0,1211834
    [DEBUG] w if match
    [DEBUG] w after if: 0,9374522
    [DEBUG] Y: 0,6526805  X: 0,7576333
    [DEBUG] angle pre if: 40,7440068657897
    [DEBUG] result: 0,711117070263206
    [DEBUG] angle: 40,7440068657897
    [DEBUG] My Rotation: 46,533
    [DEBUG] Survey Angle: 40,744
    so, no big deal here.
    next is a dump when it doesn't work:
    angle larger 180°

    Code:
    [DEBUG] Packed: 1133353
    [DEBUG] x: 0  y: 0  z: 1,08085  w: 1,168236
    [DEBUG] w if match
    [DEBUG] w after if: n. def.
    [DEBUG] Y: n. def.  X: -1,336472
    [DEBUG] angle pre if: n. def.
    [DEBUG] result: n. def.
    [DEBUG] angle: n. def.
    [DEBUG] My Rotation: 226,264
    [DEBUG] Survey Angle: n. def.

    so this is the problem.

    things i noticed this far:
    - x and y are always 0, no problem, i don't need them
    - the if condition is always met
    - if w is larger than 1, the math.sqrt will fail! because the value (1.0f - w) is negative.
    - when the code works, z and w are below 1
    - when the code fails, z and w are above 1


    i can't find the solution to this problem. i've search the net and read stuff about the quaternion calculation.
    if someone could help me with this or point me in the right direction i would really appreciate this.

    thanks

  3. #3
    guizmows's Avatar Banned
    Reputation
    57
    Join Date
    Feb 2008
    Posts
    414
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why ain't you reading directly gameobject matrice?

  4. #4
    mazer's Avatar Member Authenticator enabled
    Reputation
    11
    Join Date
    Sep 2007
    Posts
    69
    Thanks G/R
    7/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by guizmows View Post
    why ain't you reading directly gameobject matrice?
    i don't quite understand what you mean, could you give me a link or an example?

  5. #5
    guizmows's Avatar Banned
    Reputation
    57
    Join Date
    Feb 2008
    Posts
    414
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    each object in DirectX has a matrice (offset 1D0 if I rememeber correctly). read it, and you will be able to find correct facing

  6. #6
    mazer's Avatar Member Authenticator enabled
    Reputation
    11
    Join Date
    Sep 2007
    Posts
    69
    Thanks G/R
    7/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by guizmows View Post
    each object in DirectX has a matrice (offset 1D0 if I rememeber correctly). read it, and you will be able to find correct facing
    at this point i want to stick to wow memory.
    i have never read DirectX data / memory.

    there must be another way to do so.

    but thanks for your help

  7. #7
    guizmows's Avatar Banned
    Reputation
    57
    Join Date
    Feb 2008
    Posts
    414
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    data is in wow memory : [objBase + 0x1D0] (check CGGameObject_C__GetMatrix in Wow)

  8. #8
    mazer's Avatar Member Authenticator enabled
    Reputation
    11
    Join Date
    Sep 2007
    Posts
    69
    Thanks G/R
    7/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by guizmows View Post
    data is in wow memory : [objBase + 0x1D0] (check CGGameObject_C__GetMatrix in Wow)
    will look at this, firing up ida now
    thanks!

  9. #9
    mazer's Avatar Member Authenticator enabled
    Reputation
    11
    Join Date
    Sep 2007
    Posts
    69
    Thanks G/R
    7/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, i was able to get the DX date of the object.
    part of the values look like a rotation matrix.

    a friend of mine helped me with the calculation (he forgot to give me the formula tho)
    the problem was that the resulting angle was wired.

    when i dumb the values, i place my char on the survey tool and facing roughly in the same direction,
    so i got my rotation angle and think it should nearly be the same as the rotation of the tool.
    but they never match.


    do i miss something? is the resulting angle some sort of relative angle to north or something?
    can't figure it out.

    btw, here is a dump of 5 different locations on the same digsite:
    [DEBUG] dxdata_0: -0,235289931297302 [DEBUG] dxdata_1: -0,971925258636475 [DEB - Pastebin.com

  10. #10
    guizmows's Avatar Banned
    Reputation
    57
    Join Date
    Feb 2008
    Posts
    414
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I hope this will help you : Rasterisation - Wikipedia, the free encyclopedia

    besically, you need to calculate the arc tangeant between two points.

  11. #11
    mazer's Avatar Member Authenticator enabled
    Reputation
    11
    Join Date
    Sep 2007
    Posts
    69
    Thanks G/R
    7/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by guizmows View Post
    I hope this will help you : Rasterisation - Wikipedia, the free encyclopedia

    besically, you need to calculate the arc tangeant between two points.
    thanks, i will take a look.
    i hope to get this running soon...

  12. #12
    mazer's Avatar Member Authenticator enabled
    Reputation
    11
    Join Date
    Sep 2007
    Posts
    69
    Thanks G/R
    7/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by mazer View Post
    thanks, i will take a look.
    i hope to get this running soon...
    ok, this is too heavy for me and far behind any of my knowledge.
    it was hard to even understand what a rotation matrix is and does.
    guess i have to give up at this point.
    3 days of research (of things i never heard before) were to much for my little brain
    Last edited by mazer; 01-20-2012 at 02:13 PM.

  13. #13
    !@^^@!'s Avatar Active Member
    Reputation
    23
    Join Date
    Feb 2007
    Posts
    155
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by mazer View Post
    ok, this is too heavy for me and far behind any of my knowledge.
    it was hard to even understand what a rotation matrix is and does.
    guess i have to give up at this point.
    3 days of research (of things i never heard before) were to much for my little brain
    The topic is called linear algebra and while it's difficult to research on your own, khanacadamy has some very good lessons about it that you might want to check out: Khan Academy
    It's a very interesting topic and is the basis of most modern graphics calculations
    “Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.” - Rich Cook

  14. #14
    counted's Avatar Contributor Authenticator enabled
    Reputation
    203
    Join Date
    Mar 2008
    Posts
    183
    Thanks G/R
    11/108
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Getting back into Arch.

    the location of the packed number is now.

    long packed = Mem.Read<long>(address + 0x120 + 0x2;

    address is base survey tool gameobject address.

    if you want to work in degrees, remember to add 360 if the radian answer is negative.

    -counted

  15. #15
    Holico's Avatar Contributor
    Reputation
    85
    Join Date
    Jul 2009
    Posts
    114
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That Thread was more than 5 years old >.<

Similar Threads

  1. [Code Release] C#, Out Of Process - Get Player Name
    By SwInY in forum WoW Memory Editing
    Replies: 4
    Last Post: 05-04-2011, 04:31 PM
  2. [C++]CSyringe - Out of Process Mem Manager
    By cenron in forum WoW Memory Editing
    Replies: 1
    Last Post: 01-21-2009, 08:48 PM
  3. [Out of Process] GetNumLootItems()
    By hypnodok in forum WoW Memory Editing
    Replies: 8
    Last Post: 12-16-2008, 02:51 PM
  4. [Help] Accessing a function Out of Process
    By cenron in forum WoW Memory Editing
    Replies: 18
    Last Post: 10-14-2008, 05:49 AM
  5. Can you read player names out of process?
    By sweeper18 in forum WoW Memory Editing
    Replies: 10
    Last Post: 07-06-2008, 08:54 PM
All times are GMT -5. The time now is 07:39 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