view _deleted.cpp @ 799:977407dfa4c5

m
author Ritor1
date Mon, 25 Mar 2013 10:40:37 +0600
parents 93287fb98441
children cc9a3a24d61d
line wrap: on
line source


/*
//----- (004AC1C9) --------------------------------------------------------
int __thiscall _4AC1C9_get_cpu_speed(unsigned int _this, Vec4_int_ *a2)
{
  unsigned int v2; // esi@1
  __int16 v3; // di@1
  signed int v4; // ebx@1
  int v5; // ecx@3
  Vec4_int_ *v6; // eax@10
  Vec4_int_ *v7; // esi@14
  int result; // eax@16
  char *v9; // esi@16
  Vec4_int_ a1; // [sp+Ch] [bp-34h]@10
  Vec4_int_ v11; // [sp+1Ch] [bp-24h]@14
  Vec4_int_ Dst; // [sp+2Ch] [bp-14h]@1
  int v13; // [sp+3Ch] [bp-4h]@1

  v2 = _this;
  v3 = _4382BC_get_cpu_speed_sub0(_this);
  v13 = _4383ED_get_cpu_speed_sub2();
  v4 = 0;
  memset(&Dst, 0, 0x10u);
  if ( v3 < 0 )
    goto LABEL_19;
  if ( (signed int)v2 > 0 )
  {
    if ( (signed int)v2 > 150 )
    {
      v5 = (int)a2;
    }
    else
    {
      v5 = 4000 * v2;
      v4 = 1;
    }
  }
  else
  {
    v5 = 4000 * dword_4F031C[(unsigned __int16)v3];
  }
  if ( v13 & 0x10 && !v4 )
  {
    if ( v2 )
      v6 = _4AC4FD_get_cpu_clocks_rdtsc(v5, &a1);
    else
      v6 = _4AC33A_get_cpu_clocks_QPC(v5, &a1);
    goto LABEL_14;
  }
  if ( (unsigned __int16)v3 < 3u )
  {
LABEL_19:
    v7 = &Dst;
    goto LABEL_16;
  }
  v6 = _4AC277_get_cpu_speed_sub3(v5, &a1);
LABEL_14:
  v11.x = v6->x;
  v11.y = v6->y;
  v11.z = v6->z;
  v11.w = v6->w;
  v7 = &v11;
LABEL_16:
  result = (int)a2;
  a2->x = v7->x;
  v9 = (char *)&v7->y;
  a2->y = *(int *)v9;
  v9 += 4;
  a2->z = *(int *)v9;
  a2->w = *((int *)v9 + 1);
  return result;
}
// 4F031C: using guessed type int dword_4F031C[];



//----- (004382BC) --------------------------------------------------------
__int16 __thiscall _4382BC_get_cpu_speed_sub0(int _this)
{
  __int16 result; // ax@4
  __int16 v14; // sp@11
  int v15; // [sp-4h] [bp-Ch]@0
  signed __int16 v16; // [sp+4h] [bp-4h]@1
  __int16 v17; // [sp+4h] [bp-4h]@8
  __int16 v18; // [sp+4h] [bp-4h]@11

  v16 = 1;
  __asm { pushf }
  if ( v15 == (v15 ^ 0x200000) )
    v16 = 0;
  if ( v16 )
  {
    result = _43847A_get_cpu_speed_sub1();
  }
  else
  {
    //UNDEF(_ZF);
    //UNDEF(_SF);
    //UNDEF(_OF);
    _CF = 0;
    if ( !_ZF )
      _CF = 1;
    __asm { pushfw }
    bProcessorIsNotIntel = (BYTE2(v15) & 1 ^ 1) & 1;
    _CF = 0;
    _OF = 0;
    _ZF = 0;
    _SF = 1;
    __asm { pushfw }
    v17 = 2;
    if ( (HIWORD(v15) | 0xF000) & 0xF000 )
      v17 = -1;
    __asm { popfw }
    result = v17;
    if ( v17 != 2 )
    {
      _CF = 0;
      _OF = 0;
      _ZF = v14 == 0;
      _SF = v14 < 0;
      __asm { pushf }
      v18 = 3;
      if ( v15 != (v15 ^ 0x40000) )
        v18 = -1;
      __asm { popf }
      result = v18;
      if ( v18 != 3 )
        result = 4;
    }
  }
  if ( bProcessorIsNotIntel )
    HIBYTE(result) |= 0x80u;
  return result;
}



//----- (0043847A) --------------------------------------------------------
__int16 __cdecl _43847A_get_cpu_speed_sub1()
{
  signed int v5; // eax@1
  char v12[12]; // [sp+Ch] [bp-28h]@1
  char v13; // [sp+18h] [bp-1Ch]@1
  char v14; // [sp+19h] [bp-1Bh]@1
  int v15[4]; // [sp+1Ch] [bp-18h]@1
  int v16; // [sp+2Eh] [bp-6h]@1
  char v17; // [sp+32h] [bp-2h]@6
  char v18; // [sp+33h] [bp-1h]@1

  *(int *)v12 = *(int *)"------------";
  *(int *)&v12[4] = *(int *)"--------";
  *(int *)&v12[8] = *(int *)"----";
  v13 = asc_4E4938[12];
  v14 = 0;
  v18 = 0;
  v15[0] = *(int *)"GenuineIntel";
  v15[1] = *(int *)"ineIntel";
  v15[2] = *(int *)"ntel";
  v16 = 65535;
  LOBYTE(v15[3]) = aGenuineintel[12];
  _EAX = 0;
  __asm { cpuid }
  *(int *)v12 = _EBX;
  *(int *)&v12[4] = _EDX;
  *(int *)&v12[8] = _ECX;
  v5 = 0;
  do
  {
    if ( v12[v5] != *((char *)v15 + v5) )
      bProcessorIsNotIntel = 1;
    ++v5;
  }
  while ( v5 < 12 );
  if ( v5 >= 1 )
  {
    _EAX = 1;
    __asm { cpuid }
    v18 = _EAX & 0xF;
    LOBYTE(_EAX) = (unsigned __int8)(_EAX & 0xF0) >> 4;
    v17 = _EAX;
    LOWORD(v16) = ((_EAX & 0xF00u) >> 8) & 0xF;
  }
  return v16;
}



//----- (004383ED) --------------------------------------------------------
int __cdecl _4383ED_get_cpu_speed_sub2()
{
  signed int v9; // eax@4
  int v16; // [sp-4h] [bp-38h]@0
  int v17[3]; // [sp+Ch] [bp-28h]@1
  char v18; // [sp+18h] [bp-1Ch]@1
  char v19; // [sp+19h] [bp-1Bh]@1
  int v20[4]; // [sp+1Ch] [bp-18h]@1
  int v21; // [sp+2Ch] [bp-8h]@1
  int v22; // [sp+30h] [bp-4h]@1

  v17[0] = *(int *)"------------";
  v17[1] = *(int *)"--------";
  v17[2] = *(int *)"----";
  v18 = asc_4E4938[12];
  v19 = 0;
  v22 = 0;
  v20[0] = *(int *)"GenuineIntel";
  v20[1] = *(int *)"ineIntel";
  v20[2] = *(int *)"ntel";
  LOBYTE(v20[3]) = aGenuineintel[12];
  _CF = 0;
  _OF = 0;
  _ZF = 0;
  _SF = 0;
  v21 = 1;
  __asm { pushf }
  if ( v16 == (v16 ^ 0x200000) )
    v21 = 0;
  if ( (short)v21 )
  {
    _EAX = 0;
    __asm { cpuid }
    v17[0] = _EBX;
    v17[1] = _EDX;
    v17[2] = _ECX;
    v9 = 0;
    do
    {
      if ( *((char *)v17 + v9) != *((char *)v20 + v9) )
        bProcessorIsNotIntel = 1;
      ++v9;
    }
    while ( v9 < 12 );
    if ( v9 >= 1 )
    {
      _EAX = 1;
      __asm { cpuid }
      v22 = _EDX;
    }
  }
  return v22;
}



//----- (004AC4FD) --------------------------------------------------------
Vec4_int_ *__thiscall _4AC4FD_get_cpu_clocks_rdtsc(int _this, Vec4_int_ *a1)
{
  int v2; // eax@1
  int v3; // eax@4
  bool v4; // eax@5
  unsigned __int64 v5; // kr00_8@8
  int v6; // edi@9
  int v7; // eax@9
  bool v8; // eax@10
  unsigned __int64 v9; // kr08_8@13
  unsigned int v10; // eax@15
  Vec4_int_ *result; // eax@17
  int Dst; // [sp+Ch] [bp-2Ch]@1
  int v13; // [sp+10h] [bp-28h]@17
  int v14; // [sp+14h] [bp-24h]@15
  int v15; // [sp+18h] [bp-20h]@17
  unsigned int v16; // [sp+1Ch] [bp-1Ch]@8
  unsigned int v17; // [sp+20h] [bp-18h]@8
  unsigned int v18; // [sp+24h] [bp-14h]@13
  int nPriority; // [sp+28h] [bp-10h]@1
  __int64 v20; // [sp+2Ch] [bp-Ch]@1
  int v21; // [sp+34h] [bp-4h]@3

  HIDWORD(v20) = GetCurrentThread();
  memset(&Dst, 0, 0x10u);
  v2 = GetThreadPriority(HIDWORD(v20));
  nPriority = v2;
  if ( v2 != 0x7FFFFFFF )
    SetThreadPriority(HIDWORD(v20), v2 + 1);
  __outbyte(0x70u, 0);
  v21 = __inbyte(0x71u);
  do
  {
    __outbyte(0x70u, 0);
    LODWORD(v20) = __inbyte(0x71u);
    v3 = v20 - v21;
    if ( (signed int)v20 >= v21 )
      v4 = v3 > 0;
    else
      v4 = v3 + 10;
  }
  while ( !v4 );
  v5 = __rdtsc();
  v16 = HIDWORD(v5);
  v17 = v5;
  do
  {
    __outbyte(0x70u, 0);
    v21 = __inbyte(0x71u);
    v6 = v21;
    v7 = v21 - v20;
    if ( v21 >= (signed int)v20 )
      v8 = v7 > 0;
    else
      v8 = v7 + 10;
  }
  while ( !v8 );
  v9 = __rdtsc();
  v18 = HIDWORD(v9);
  v21 = v9;
  if ( nPriority != 0x7FFFFFFF )
    SetThreadPriority(HIDWORD(v20), nPriority);
  nPriority = v21;
  *(__int64 *)((char *)&v20 + 4) = __PAIR__(v18, v21) - __PAIR__(v16, v17);
  Dst = HIDWORD(v20);
  v10 = HIDWORD(v20) / 0xF4240;
  v14 = HIDWORD(v20) / 0xF4240;
  if ( HIDWORD(v20) / 0x186A0 - 10 * HIDWORD(v20) / 0xF4240 >= 6 )
    ++v10;
  v15 = v10;
  result = a1;
  v13 = 1000000 * v6 - 1000000 * v20;
  a1->x = Dst;
  a1->y = v13;
  a1->z = v14;
  a1->w = v15;
  return result;
}




//----- (004AC33A) --------------------------------------------------------
Vec4_int_ *__thiscall _4AC33A_get_cpu_clocks_QPC(int _this, Vec4_int_ *a1)
{
  int v2; // esi@1
  int v3; // ebx@1
  unsigned __int64 v4; // qax@4
  unsigned __int64 v5; // qax@7
  DWORD v6; // edi@7
  DWORD v7; // eax@7
  unsigned int v8; // ecx@10
  unsigned __int64 v9; // qax@10
  unsigned int v10; // edi@10
  int v11; // eax@14
  unsigned int v12; // ecx@19
  Vec4_int_ *result; // eax@24
  int Dst; // [sp+Ch] [bp-4Ch]@1
  int v15; // [sp+10h] [bp-48h]@23
  int v16; // [sp+14h] [bp-44h]@21
  int v17; // [sp+18h] [bp-40h]@21
  LARGE_INTEGER Frequency; // [sp+1Ch] [bp-3Ch]@1
  LARGE_INTEGER PerformanceCount; // [sp+24h] [bp-34h]@2
  LARGE_INTEGER v20; // [sp+2Ch] [bp-2Ch]@2
  int v21; // [sp+34h] [bp-24h]@2
  int v22; // [sp+38h] [bp-20h]@2
  int v23; // [sp+3Ch] [bp-1Ch]@4
  int v24; // [sp+40h] [bp-18h]@7
  int nPriority; // [sp+44h] [bp-14h]@2
  unsigned int v26; // [sp+48h] [bp-10h]@1
  unsigned int v27; // [sp+4Ch] [bp-Ch]@1
  HANDLE hThread; // [sp+50h] [bp-8h]@1
  int v29; // [sp+54h] [bp-4h]@1

  v2 = 0;
  v3 = 0;
  v29 = 0;
  v27 = 0;
  v26 = 0;
  hThread = GetCurrentThread();
  memset(&Dst, 0, 0x10u);
  if ( QueryPerformanceFrequency(&Frequency) )
  {
    do
    {
      ++v29;
      v22 = v2;
      v21 = v3;
      QueryPerformanceCounter(&PerformanceCount);
      v20 = PerformanceCount;
      nPriority = GetThreadPriority(hThread);
      if ( nPriority != 2147483647 )
        SetThreadPriority(hThread, 15);
      while ( v20.s.LowPart - PerformanceCount.s.LowPart < 0x32 )
      {
        QueryPerformanceCounter(&v20);
        v4 = __rdtsc();
        v23 = v4;
      }
      PerformanceCount = v20;
      do
      {
        QueryPerformanceCounter(&v20);
        v5 = __rdtsc();
        v24 = v5;
        v6 = v20.s.LowPart;
        v7 = PerformanceCount.s.LowPart;
      }
      while ( v20.s.LowPart - PerformanceCount.s.LowPart < 0x3E8 );
      if ( nPriority != 2147483647 )
      {
        SetThreadPriority(hThread, nPriority);
        v7 = PerformanceCount.s.LowPart;
        v6 = v20.s.LowPart;
      }
      v8 = v24 - v23;
      v27 += v24 - v23;
      v9 = (100000 * v6 - 100000 * v7) / (Frequency.s.LowPart / 0xA);
      v10 = v9;
      v26 += v9;
      if ( v9 % Frequency.s.LowPart > Frequency.s.LowPart >> 1 )
        v10 = v9 + 1;
      v3 = v8 / v10;
      if ( v8 % v10 > v10 >> 1 )
        v3 = v8 / v10 + 1;
      v2 = v21;
      v11 = v3 + v22 + v21;
    }
    while ( v29 < 3
         || v29 < 20
         && ((unsigned int)(3 * v3 - v11) > 3 || (unsigned int)(3 * v21 - v11) > 3 || (unsigned int)(3 * v22 - v11) > 3) );
    v12 = 10 * v27 / v26;
    if ( 100 * v27 / v26 - 10 * v12 >= 6 )
      ++v12;
    v16 = v27 / v26;
    v17 = v27 / v26;
    if ( v12 - 10 * v27 / v26 >= 6 )
      v17 = v27 / v26 + 1;
    v15 = v26;
    Dst = v27;
  }
  result = a1;
  a1->x = Dst;
  a1->y = v15;
  a1->z = v16;
  a1->w = v17;
  return result;
}





//----- (004AC277) --------------------------------------------------------
Vec4_int_ *__thiscall _4AC277_get_cpu_speed_sub3(unsigned int _this, Vec4_int_ *a2)
{
  signed int v2; // esi@1
  signed __int16 v4; // bx@3
  int v10; // esi@8
  int v11; // eax@10
  Vec4_int_ *result; // eax@13
  Vec4_int_ Dst; // [sp+8h] [bp-30h]@1
  LARGE_INTEGER Frequency; // [sp+18h] [bp-20h]@1
  LARGE_INTEGER PerformanceCount; // [sp+20h] [bp-18h]@3
  LARGE_INTEGER v16; // [sp+28h] [bp-10h]@5
  int v17; // [sp+30h] [bp-8h]@1
  int v18; // [sp+34h] [bp-4h]@2

  v17 = _this;
  v2 = -1;
  memset(&Dst, 0, 0x10u);
  if ( QueryPerformanceFrequency(&Frequency) )
  {
    v18 = 10;
    do
    {
      QueryPerformanceCounter(&PerformanceCount);
      _EAX = -2147483648;
      v4 = 4000;
      do
      {
        __asm { bsf     ecx, eax }
        --v4;
      }
      while ( v4 );
      QueryPerformanceCounter(&v16);
      if ( (signed int)v16.s.LowPart - (signed int)PerformanceCount.s.LowPart < (unsigned int)v2 )
        v2 = v16.s.LowPart - PerformanceCount.s.LowPart;
      --v18;
    }
    while ( v18 );
    v10 = 100000 * v2 / (Frequency.s.LowPart / 0xA);
    if ( v10 % Frequency.s.LowPart > Frequency.s.LowPart >> 1 )
      ++v10;
    v11 = v17 / (unsigned int)v10;
    Dst.z = v17 / (unsigned int)v10;
    if ( v17 % (unsigned int)v10 > (unsigned int)v10 >> 1 )
      ++v11;
    Dst.x = v17;
    Dst.y = v10;
    Dst.w = v11;
  }
  result = a2;
  a2->x = Dst.x;
  a2->y = Dst.y;
  a2->z = Dst.z;
  a2->w = Dst.w;
  return result;
}*/