Second set of eyes - xmm calculations from IDA disassembly menu

User Tag List

Results 1 to 4 of 4
  1. #1
    Tanaris4's Avatar Contributor Authenticator enabled
    Reputation
    148
    Join Date
    Oct 2008
    Posts
    646
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Second set of eyes - xmm calculations from IDA disassembly

    All-

    I basically was wondering if someone else could take a look at this so I know I'm doing this properly, here is the pseudocode from IDA:

    Code:
                        v4 = (__m128)*(_DWORD *)a2;
                        v4.m128_f32[0] = v4.m128_f32[0] - 17066.666;
                        v5 = (signed int)ffloor(COERCE_FLOAT(_mm_xor_ps(v4, (__m128)xmmword_8F6F60)) * 0.001875);
                        v6 = (__m128)*(_DWORD *)(a2 + 4);
                        v6.m128_f32[0] = v6.m128_f32[0] - 17066.666;
    I believe (thanks for Apoc's help so far!) it may be as simple as: Math.Floor( (1/(val - 17066.666)) * 0.001875);

    val basically just being a double of what is in location a2

    Does this seem right? Am I completely off/incorrect?

    Thanks in advance!
    ~ Tanaris
    https://tanaris4.com

    Second set of eyes - xmm calculations from IDA disassembly
  2. #2
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just pointing out that "xmmword_8F6F60" is -1 (128bit -1)

  3. #3
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    0.001875f == 3.0f/1600.0f == 1.0f/AdtWidth. And are you sure about having -1 rather than -0, which would be just the sign bit, at 0x8f6f60?
    In either case your calculation is wrong. That snippet ought to calculate the adt tile coordinate from world coordinates. That is
    Code:
    const float AdtWidth = 1600.0f/3.0f;
    const float MapOrigin = 32*AdtWidth; // == 17066.66666666f
    var tileX = Math.Floor((MapOrigin - v.X) / AdtWidth);
    The
    _mm_xor_ps does an xor on the result of (v.X - MapOrigin) with the sign bit, yielding the inverse, namely (MapOrigin - v.X). You get v by dereferencing a2.


  4. #4
    Tanaris4's Avatar Contributor Authenticator enabled
    Reputation
    148
    Join Date
    Oct 2008
    Posts
    646
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    +rep ty bananenbrot!

    Do you know where .029999999 comes from? A similar functino w/in the snippets I'm reversing basically has the exact same as the above, but changes .001875 to .029999

    Snippet:
    Code:
                    v2 = (__m128)*(_DWORD *)(PositionPtr + 4);  // yPosition
                    v2.m128_f32[0] = v2.m128_f32[0] - 17066.666;
                    v3 = (signed int)ffloor(COERCE_FLOAT(_mm_xor_ps(v2, (__m128)xmmword_8F6F60)) * 0.029999999);
                    v4 = (__m128)*(_DWORD *)PositionPtr;        // xPosition
                    v4.m128_f32[0] = v4.m128_f32[0] - 17066.666;
                    v5 = (signed int)ffloor(COERCE_FLOAT(_mm_xor_ps(v4, (__m128)xmmword_8F6F60)) * 0.029999999);
    Edit: I'm basically trying to reverse CMap::QueryAreaIdTerrain and all it's sub functions

    Edit 2: And based on what you just taught me, I believe the above in this post would translate to:

    Code:
                    const float AdtWidth = 1600.0f / 3.0f;
                    const float MapOrigin = 32 * AdtWidth; // == 17066.66666666f
    
                    float yPosition = Memory.ReadFloat((uint)PositionPtr + 4);  // yPosition
                    v3 = (int)Math.Floor((MapOrigin - yPosition) * 0.029999999);
                    //v3 = (signed int)ffloor(COERCE_FLOAT(_mm_xor_ps(v2, (__m128)xmmword_8F6F60)) * 0.029999999);
    
                    float xPosition = Memory.ReadFloat((uint)PositionPtr);        // xPosition
                    v5 = (int)Math.Floor((MapOrigin - xPosition) * 0.029999999);
                    //v5 = (signed int)ffloor(COERCE_FLOAT(_mm_xor_ps(v4, (__m128)xmmword_8F6F60)) * 0.029999999);
    Last edited by Tanaris4; 11-06-2012 at 10:25 AM.
    https://tanaris4.com

Similar Threads

  1. [question] Calculate from 3d to 2d
    By Kwapuzzi in forum WoW Memory Editing
    Replies: 3
    Last Post: 09-20-2009, 03:16 PM
  2. [EPIC] Setting up a private server from Start to Finish!
    By Found in forum WoW EMU Guides & Tutorials
    Replies: 1
    Last Post: 03-21-2009, 03:44 PM
  3. [Guide] Setting up a Arcemu server from the scratch
    By Dr. Emu in forum WoW EMU Guides & Tutorials
    Replies: 68
    Last Post: 11-22-2008, 03:31 PM
  4. Blizzard set to make $6 million from bot maker
    By K1boRG in forum World of Warcraft General
    Replies: 3
    Last Post: 10-11-2008, 07:15 PM
  5. Setting up an ascent server from scratch.
    By faxmunky in forum WoW EMU Guides & Tutorials
    Replies: 2
    Last Post: 03-21-2008, 04:01 PM
All times are GMT -5. The time now is 10:39 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