Другое С/С++ Вопрос - Ответ

jenekbueno

Известный
157
69
Код:
int comp(const int *i, const int *j)
{
    return *i - *j;
}

void foo()
{
    int var[10]{ 0, 15, 23, 21, 32, 2, 3, 4, 5, 3};
    qsort(var, _countof(var), sizeof(int), (int(*) (const void *, const void *)) comp);

    for (byte i = NULL; i < _countof(var); i++)
    {
        printf("orig %d / result %d", var[i], var[i] * 2);
        var[i] *= 2;
    }
}

немогу добавить имгуи в соб, в сф всё норм
@FYP помоги...
 
  • Нравится
Реакции: Black_Bird

checkdasound

Известный
Проверенный
963
406
Почему при инжекте dll в уже запущенную игру, все работает, а при переименовании в asi, после запуска игры сразу краш.

Код:
#include <windows.h>
#include <process.h>
#include "main.h"

bool pStatus = false;

unsigned int CurrentCharPointer = *(unsigned int*)0xB6F5F0;

void __cdecl func(void *pArg)
{
   *reinterpret_cast<DWORD*>(0x004B35A0) = 0x560CEC83;
   *reinterpret_cast<WORD*>(0x004B35A4) = 0xF18B;
   while (true)
   {
       Sleep(50);
       if (GetAsyncKeyState(0x47))
       {
           pStatus = !pStatus;
           if (pStatus == true)
           {
               AddMessageJumpQ("~g~[ON]", 500, NULL, false); // 500 - ms
           }
           else
           {
               AddMessageJumpQ("~r~[OFF]", 500, NULL, false); // 500 - ms
           }
       }
       if (pStatus == true)
       {
           *reinterpret_cast<BYTE*>(0x96916D) = 1; // bullet
           *reinterpret_cast<BYTE*>(0xB7CEE6) = 1; // fire
           *(unsigned char*)(CurrentCharPointer + 66) = 0xCC; // all
       } else
           {
               *reinterpret_cast<BYTE*>(0x96916D) = 0; // bullet
               *reinterpret_cast<BYTE*>(0xB7CEE6) = 0; // fire
               *(unsigned char*)(CurrentCharPointer + 66) = 0; // all
           }
   }
}

BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ PVOID lpvReserved)
{
   if (fdwReason == DLL_PROCESS_ATTACH)
   {
       _beginthread(func, NULL, nullptr);
   }
   return TRUE;
}

Код:
#define FUNC_CMessages__AddMessageJumpQ 0x69F1E0

void AddMessageJumpQ(PCHAR text, UINT time, USHORT flag, bool bPreviousBrief) // Функция показа сообщения на экране.
{
   ((void(__cdecl *)(PCHAR, UINT, USHORT, bool))FUNC_CMessages__AddMessageJumpQ)(text, time, flag, bPreviousBrief);
}
Вроде поставил VirtualProtect, но все равно при переименовании в .asi при входе в игру крашит.
Код:
#include <windows.h>
#include <process.h>
#include "main.h"

bool pStatus = false;

unsigned int CurrentCharPointer = *(unsigned int*)0xB6F5F0;

void __cdecl func(void *pArg)
{

   DWORD oldProtect;

   VirtualProtect((void*)(0x004B35A0), 4, PAGE_EXECUTE_READWRITE, &oldProtect);
   *reinterpret_cast<DWORD*>(0x004B35A0) = 0x560CEC83;
   VirtualProtect((void*)(0x004B35A0), 4, oldProtect, &oldProtect);

   VirtualProtect((void*)(0x004B35A4), 2, PAGE_EXECUTE_READWRITE, &oldProtect);
   *reinterpret_cast<WORD*>(0x004B35A4) = 0xF18B;
   VirtualProtect((void*)(0x004B35A4), 2, oldProtect, &oldProtect);

   while (true)
   {
       Sleep(50);
       if (GetAsyncKeyState(0x47))
       {
           pStatus = !pStatus;
           if (pStatus == true)
           {
               AddMessageJumpQ("~g~[ON]", 500, NULL, false); // 500 - ms
           }
           else
           {
               AddMessageJumpQ("~r~[OFF]", 500, NULL, false); // 500 - ms
           }
       }
       if (pStatus == true)
       {
           VirtualProtect((void*)(0x96916D), 1, PAGE_EXECUTE_READWRITE, &oldProtect);
           *reinterpret_cast<BYTE*>(0x96916D) = 1; // bullet
           VirtualProtect((void*)(0x96916D), 1, oldProtect, &oldProtect);

           VirtualProtect((void*)(0xB7CEE6), 1, PAGE_EXECUTE_READWRITE, &oldProtect);
           *reinterpret_cast<BYTE*>(0xB7CEE6) = 1; // fire
           VirtualProtect((void*)(0xB7CEE6), 1, oldProtect, &oldProtect);

           VirtualProtect((void*)(CurrentCharPointer + 66), 1, PAGE_EXECUTE_READWRITE, &oldProtect);
           *(unsigned char*)(CurrentCharPointer + 66) = 0xCC; // all
           VirtualProtect((void*)(CurrentCharPointer + 66), 1, oldProtect, &oldProtect);
       } else
           {
           VirtualProtect((void*)(0x96916D), 1, PAGE_EXECUTE_READWRITE, &oldProtect);
               *reinterpret_cast<BYTE*>(0x96916D) = 0; // bullet
               VirtualProtect((void*)(0x96916D), 1, oldProtect, &oldProtect);

               VirtualProtect((void*)(0xB7CEE6), 1, PAGE_EXECUTE_READWRITE, &oldProtect);
               *reinterpret_cast<BYTE*>(0xB7CEE6) = 0; // fire
               VirtualProtect((void*)(0xB7CEE6), 1, oldProtect, &oldProtect);

               VirtualProtect((void*)(CurrentCharPointer + 66), 1, PAGE_EXECUTE_READWRITE, &oldProtect);
               *(unsigned char*)(CurrentCharPointer + 66) = 0; // all
               VirtualProtect((void*)(CurrentCharPointer + 66), 1, oldProtect, &oldProtect);
           }
   }
}

BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ PVOID lpvReserved)
{
   if (fdwReason == DLL_PROCESS_ATTACH)
   {
       _beginthread(func, NULL, nullptr);
   }
   return TRUE;
}
 

CleanLegend

Известный
Всефорумный модератор
476
928
Вроде поставил VirtualProtect, но все равно при переименовании в .asi при входе в игру крашит.
Код:
#include <windows.h>
#include <process.h>
#include "main.h"

bool pStatus = false;

unsigned int CurrentCharPointer = *(unsigned int*)0xB6F5F0;

void __cdecl func(void *pArg)
{

   DWORD oldProtect;

   VirtualProtect((void*)(0x004B35A0), 4, PAGE_EXECUTE_READWRITE, &oldProtect);
   *reinterpret_cast<DWORD*>(0x004B35A0) = 0x560CEC83;
   VirtualProtect((void*)(0x004B35A0), 4, oldProtect, &oldProtect);

   VirtualProtect((void*)(0x004B35A4), 2, PAGE_EXECUTE_READWRITE, &oldProtect);
   *reinterpret_cast<WORD*>(0x004B35A4) = 0xF18B;
   VirtualProtect((void*)(0x004B35A4), 2, oldProtect, &oldProtect);

   while (true)
   {
       Sleep(50);
       if (GetAsyncKeyState(0x47))
       {
           pStatus = !pStatus;
           if (pStatus == true)
           {
               AddMessageJumpQ("~g~[ON]", 500, NULL, false); // 500 - ms
           }
           else
           {
               AddMessageJumpQ("~r~[OFF]", 500, NULL, false); // 500 - ms
           }
       }
       if (pStatus == true)
       {
           VirtualProtect((void*)(0x96916D), 1, PAGE_EXECUTE_READWRITE, &oldProtect);
           *reinterpret_cast<BYTE*>(0x96916D) = 1; // bullet
           VirtualProtect((void*)(0x96916D), 1, oldProtect, &oldProtect);

           VirtualProtect((void*)(0xB7CEE6), 1, PAGE_EXECUTE_READWRITE, &oldProtect);
           *reinterpret_cast<BYTE*>(0xB7CEE6) = 1; // fire
           VirtualProtect((void*)(0xB7CEE6), 1, oldProtect, &oldProtect);

           VirtualProtect((void*)(CurrentCharPointer + 66), 1, PAGE_EXECUTE_READWRITE, &oldProtect);
           *(unsigned char*)(CurrentCharPointer + 66) = 0xCC; // all
           VirtualProtect((void*)(CurrentCharPointer + 66), 1, oldProtect, &oldProtect);
       } else
           {
           VirtualProtect((void*)(0x96916D), 1, PAGE_EXECUTE_READWRITE, &oldProtect);
               *reinterpret_cast<BYTE*>(0x96916D) = 0; // bullet
               VirtualProtect((void*)(0x96916D), 1, oldProtect, &oldProtect);

               VirtualProtect((void*)(0xB7CEE6), 1, PAGE_EXECUTE_READWRITE, &oldProtect);
               *reinterpret_cast<BYTE*>(0xB7CEE6) = 0; // fire
               VirtualProtect((void*)(0xB7CEE6), 1, oldProtect, &oldProtect);

               VirtualProtect((void*)(CurrentCharPointer + 66), 1, PAGE_EXECUTE_READWRITE, &oldProtect);
               *(unsigned char*)(CurrentCharPointer + 66) = 0; // all
               VirtualProtect((void*)(CurrentCharPointer + 66), 1, oldProtect, &oldProtect);
           }
   }
}

BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ PVOID lpvReserved)
{
   if (fdwReason == DLL_PROCESS_ATTACH)
   {
       _beginthread(func, NULL, nullptr);
   }
   return TRUE;
}
Я тебе ответил уже, в начале потока дождись пока игра загрузится.
И протект тут не играет роли, у тебя бы тогда не работало при инжекте в запущенную игру

немогу добавить имгуи в соб, в сф всё норм
В собейте используются предкомпилированные заголовки, изучи их и сможешь правильно подключить imgui.
на скрине ошибка связана с этим
 
Последнее редактирование:
  • Нравится
Реакции: jenekbueno и checkdasound

NarutoUA

NarutoUA
BH Team
692
1,537
Я тебе ответил уже, в начале потока дождись пока игра загрузится.
И протект тут не играет роли, у тебя бы тогда не работало при инжекте в запущенную игру
Клео снимает защиту со всей гта
 
  • Нравится
Реакции: CleanLegend

jenekbueno

Известный
157
69
В собейте используются предкомпилированные заголовки, изучи их и сможешь правильно подключить imgui.
на скрине ошибка связана с этим

заголовки я знаю как подключаются
а ты сам пробовал подключить имгуи к собейту?
я не совсем понимаю в чем дело
 

jenekbueno

Известный
157
69
как в собейте показать диалог
Код:
void showSampDialog(int send, int dialogID, int typedialog, char *caption, char *text, char *button1, char *button2)
{
    uint32_t func = g_dwSAMP_Addr + SAMP_FUNC_DIALOG_SHOW;
    uint32_t data = g_dwSAMP_Addr + SAMP_DIALOG_INFO_OFFSET;

    __asm mov eax, dword ptr[data]
        __asm mov ecx, dword ptr[eax]
        __asm push send
    __asm push button2
    __asm push button1
    __asm push text
    __asm push caption
    __asm push typedialog
    __asm push dialogID
    __asm call func
    return;
}

тогда вообще всё по пизде идёт, какая то проблема большая.
upd:
собейт это один большой пиздец, неужели на этапе создания нельзя было сделать всё по человечески
 
Последнее редактирование:

checkdasound

Известный
Проверенный
963
406
Какие флаги есть для неуязвимости персонажа через CPed + 0x42?
Знаю только сумму всех: 204
 

Rjx13

Известный
Проверенный
224
160
Какие флаги есть для неуязвимости персонажа через CPed + 0x42?
Знаю только сумму всех: 204
#define PedSoft 0x01
#define FreezePed 0x02
#define BulletProtect 0x04
#define FireProtect 0x08
#define CollisionProtect 0x10
#define MeleeProtect 0x20
#define Unc_7bit 0x40
#define ExplosionProtect 0x80
 
  • Нравится
Реакции: checkdasound

checkdasound

Известный
Проверенный
963
406
Почему меня телепортирует на "спавн сампа" (центр карты вроде как), вместо тп на метку?
Код нахождения координат метки и функцию нахождения координаты z брал из собейта.
Честно говоря, я не разбираюсь в ассемблере, поэтому даже не знаю с чем это связано.
C++:
#define FUNC_CMessages__AddMessageJumpQ 0x69F1E0
#define FUNC_FindGroundZForCoord 0x569660

void AddMessageJumpQ(PCHAR text, UINT time, USHORT flag, bool bPreviousBrief) // Функция показа сообщения на экране.
{
   ((void(__cdecl *)(PCHAR, UINT, USHORT, bool))FUNC_CMessages__AddMessageJumpQ)(text, time, flag, bPreviousBrief);
}

float FindGroundZForPosition(float fX, float fY)
{
   //DEBUG_TRACE("FLOAT CWorldSA::FindGroundZForPosition(FLOAT fX, FLOAT fY)");
   DWORD dwFunc = FUNC_FindGroundZForCoord;
   FLOAT fReturn = 0;
   _asm
   {
       push   fY
       push   fX
       call   dwFunc
       fstp   fReturn
       add       esp, 8
   }
   return fReturn;
}

void teleport(float posX, float posY, float posZ)
{
   float *position = (*(DWORD *)0xB6F5F0) ? (float *)(*(DWORD *)(*(DWORD *)0xB6F5F0 + 0x14) + 0x30) : nullptr;
   position[0] = posX;
   position[1] = posY;
   position[2] = posZ;
}

void teleport_target_blip()
{
   if ((*(int *)0xBA6774 != 0))
   {
       float mapPos[3];
       for (int i = 0; i < (0xAF * 0x28); i += 0x28)
       {
           if (*(short *)(0xBA873D + i) == 4611)
           {
               float *pos = (float *)(0xBA86F8 + 0x28 + i);
               mapPos[0] = *pos;
               mapPos[1] = *(pos + 1);
               mapPos[2] = FindGroundZForPosition(mapPos[0], mapPos[1]) + 2.0f;

               teleport(mapPos[0], mapPos[1], mapPos[2]);
           }
       }
   }
   else AddMessageJumpQ("~r~HA KAPTE HET METKU", 2000, NULL, false);
}
 

SR_team

like pancake
BH Team
4,720
6,367
Почему меня телепортирует на "спавн сампа" (центр карты вроде как), вместо тп на метку?
Код нахождения координат метки и функцию нахождения координаты z брал из собейта.
Честно говоря, я не разбираюсь в ассемблере, поэтому даже не знаю с чем это связано.
C++:
#define FUNC_CMessages__AddMessageJumpQ 0x69F1E0
#define FUNC_FindGroundZForCoord 0x569660

void AddMessageJumpQ(PCHAR text, UINT time, USHORT flag, bool bPreviousBrief) // Функция показа сообщения на экране.
{
   ((void(__cdecl *)(PCHAR, UINT, USHORT, bool))FUNC_CMessages__AddMessageJumpQ)(text, time, flag, bPreviousBrief);
}

float FindGroundZForPosition(float fX, float fY)
{
   //DEBUG_TRACE("FLOAT CWorldSA::FindGroundZForPosition(FLOAT fX, FLOAT fY)");
   DWORD dwFunc = FUNC_FindGroundZForCoord;
   FLOAT fReturn = 0;
   _asm
   {
       push   fY
       push   fX
       call   dwFunc
       fstp   fReturn
       add       esp, 8
   }
   return fReturn;
}

void teleport(float posX, float posY, float posZ)
{
   float *position = (*(DWORD *)0xB6F5F0) ? (float *)(*(DWORD *)(*(DWORD *)0xB6F5F0 + 0x14) + 0x30) : nullptr;
   position[0] = posX;
   position[1] = posY;
   position[2] = posZ;
}

void teleport_target_blip()
{
   if ((*(int *)0xBA6774 != 0))
   {
       float mapPos[3];
       for (int i = 0; i < (0xAF * 0x28); i += 0x28)
       {
           if (*(short *)(0xBA873D + i) == 4611)
           {
               float *pos = (float *)(0xBA86F8 + 0x28 + i);
               mapPos[0] = *pos;
               mapPos[1] = *(pos + 1);
               mapPos[2] = FindGroundZForPosition(mapPos[0], mapPos[1]) + 2.0f;

               teleport(mapPos[0], mapPos[1], mapPos[2]);
           }
       }
   }
   else AddMessageJumpQ("~r~HA KAPTE HET METKU", 2000, NULL, false);
}
Да там и не нужен ассемблер, просто разраб соба выебывался. Всю функцию можно заменить вот таким вот вызовом в одну строку:
C++:
float fZ = ((float(__cdecl*)(float,float))FUNC_FindGroundZForCoord)(fX, fY);
 
Последнее редактирование:
  • Нравится
Реакции: bottom_text и checkdasound