Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Is anyone able to translate this pseudo code (C++) ?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
H4x0rBattie
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 58

PostPosted: Sat Jan 14, 2017 11:47 am    Post subject: Is anyone able to translate this pseudo code (C++) ? Reply with quote

I did a bit of reversing. The below function is a drag calculation function for one game I work with.

I already worked for several days with a real life drag calculation function that was quite close to game one but it's not accurate enough at longer distances.

I figured out that I have to solve out the way the game does it and ended up reversing it.

Is anyone able to translate it to something more readable? You can use fictional float values in formulas. Thanks.

Code:

__int64 __fastcall sub_145ABFD00(__int64 a1, __int64 a2, __m128i *a3, float a4)
{
  __m128 v4; // xmm4@1
  __int64 v5; // rax@1
  float v6; // xmm5_4@1
  float v7; // xmm0_4@1
  __m128i v8; // xmm3@1
  float v9; // xmm6_4@1
  unsigned int v11; // [sp+20h] [bp+8h]@2

  v4 = *(__m128 *)a3;
  v5 = *(_QWORD *)(a1 + 16);
  _mm_store_si128((__m128i *)a2, *a3);
  v6 = a4;
  v7 = a4 * *(float *)(v5 + 320);
  v8 = (__m128i)_mm_mul_ps(v4, v4);
  *(float *)(a2 + 4) = v7 + *(float *)(a2 + 4);
  v9 = fsqrt(COERCE_FLOAT(_mm_add_ps(_mm_add_ps((__m128)_mm_shuffle_epi32(v8, 85), (__m128)_mm_shuffle_epi32(v8, 0)), (__m128)_mm_shuffle_epi32(v8, -86))));
  if ( v9 != 0.0 )
  {
    v11 = (unsigned __int128)_mm_add_ps(
                               _mm_add_ps((__m128)_mm_shuffle_epi32(v8, 85), (__m128)_mm_shuffle_epi32(v8, 0)),
                               (__m128)_mm_shuffle_epi32(v8, -86));
    *(__m128 *)a2 = _mm_sub_ps(
                      *(__m128 *)a2,
                      _mm_mul_ps(
                        _mm_mul_ps(
                          _mm_mul_ps(
                            _mm_div_ps(v4, _mm_shuffle_ps((__m128)LODWORD(v9), (__m128)LODWORD(v9), 0)),
                            _mm_shuffle_ps((__m128)v11, (__m128)v11, 0)),
                          _mm_shuffle_ps((__m128)*(_DWORD *)(v5 + 324), (__m128)*(_DWORD *)(v5 + 324), 0)),
                        _mm_shuffle_ps((__m128)LODWORD(v6), (__m128)LODWORD(v6), 0)));
  }
  return a2;
}

_________________
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Sat Jan 14, 2017 2:41 pm    Post subject: Reply with quote

Keep in mind HexRays output is not guaranteed to be 100% correct and can often times leave out parts of the code. While it is a good starting point to understand some code flow, I wouldn't recommend trying to translate its output for a 1:1 result.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites