HOME FORUMS MEMBERS RECENT POSTS LOG IN  
× Авторизация
Имя пользователя:
Пароль:
Нет аккаунта? Регистрация
Баннер 1   Баннер 2
НОВЫЕ ТОРГОВАЯ НОВОСТИ ЧАТ
loading...
Скрыть
Вернуться   ANTICHAT > ПРОГРАММИРОВАНИЕ > С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby
   
Ответ
 
Опции темы Поиск в этой теме Опции просмотра

  #1  
Старый 19.02.2023, 07:33
_=Gigant=_
Участник форума
Регистрация: 19.01.2017
Сообщений: 130
С нами: 4901705

Репутация: 98
По умолчанию

inline float ByteToFloat(unsigned char value)

{

return static_cast(value) / 255.0f;

}

ImVec4 D3DColorToImVec4(DWORD color)

{

float red = ByteToFloat((color >> 16) & 0xFF);

float green = ByteToFloat((color >> 8) & 0xFF);

float blue = ByteToFloat(color & 0xFF);

float alpha = ByteToFloat(color >> 24);

return ImVec4(red, green, blue, alpha);

}

Usage

DWORD d3dcolor = 0x00FF00FF; // Example color

ImVec4 imvec4 = D3DColorToImVec4(d3dcolor);

2# D3DCOLOR TO IMVEC4

unsigned char FloatToByte(float value)

{

return static_cast(value * 255.0f);

}

DWORD ImVec4ToD3DColor(const ImVec4& color)

{

unsigned char red = FloatToByte(color.x);

unsigned char green = FloatToByte(color.y);

unsigned char blue = FloatToByte(color.z);

unsigned char alpha = FloatToByte(color.w);

return D3DCOLOR_ARGB(alpha, red, green, blue);

}

ImVec4 imvec4(1.0f, 0.0f, 1.0f, 0.5f); //usage

DWORD d3dcolor = ImVec4ToD3DColor(imvec4);
 
Ответить с цитированием

  #2  
Старый 24.04.2023, 18:58
AdCKuY_DpO4uLa
Постоянный
Регистрация: 05.08.2018
Сообщений: 372
С нами: 4091290

Репутация: 213
По умолчанию

Данный класс позволяет скрыть модуль из списка загруженных модулей путем замены указателей на "скрываемый модуль" в структуре PEB_LDR_DATA процесса.

C++:





Код:
#include 
#include 
class
ModuleHider
{
private
:
//only x86 structs
typedef
struct
_PEB_LDR_DATA
{
ULONG Length
;
BOOLEAN Initialized
;
HANDLE SsHandle
;
LIST_ENTRY InLoadOrderModuleList
;
LIST_ENTRY InMemoryOrderModuleList
;
LIST_ENTRY InInitializationOrderModuleList
;
PVOID      EntryInProgress
;
}
PEB_LDR_DATA
,
*
PPEB_LDR_DATA
;
typedef
struct
_LDR_DATA_ENTRY
{
//PVOID Reserved1[0];
LIST_ENTRY InLoadOrderModuleList
;
LIST_ENTRY InInitializationOrderModuleList
;
LIST_ENTRY InMemoryOrderModuleList
;
//PVOID Reserved2[2];
PVOID DllBase
;
PVOID Reserved3
[
2
]
;
UNICODE_STRING FullDllName
;
BYTE Reserved4
[
8
]
;
PVOID Reserved5
[
3
]
;
#pragma warning(push)
#pragma warning(disable: 4201)
// we'll always use the Microsoft compiler
union
{
ULONG CheckSum
;
PVOID Reserved6
;
}
DUMMYUNIONNAME
;
#pragma warning(pop)
ULONG TimeDateStamp
;
}
LDR_DATA_ENTRY
,
*
PLDR_DATA_ENTRY
;
PPEB_LDR_DATA _m_pPEB_LDR
;
PLDR_DATA_ENTRY _m_pEntry
;
HINSTANCE _m_DllHandle
;
PLDR_DATA_ENTRY _m_pDoEntry
,
_m_pAfterEntry
;
LIST_ENTRY _m_origAddrs
;
bool
_m_bIsHided
;
public
:
ModuleHider
(
const
HINSTANCE hModule
)
:
_m_DllHandle
(
hModule
)
,
_m_bIsHided
(
false
)
{
_m_pPEB_LDR
=
(
PPEB_LDR_DATA
)
NtCurrentTeb
(
)
->
ProcessEnvironmentBlock
->
Ldr
;
_m_pEntry
=
(
PLDR_DATA_ENTRY
)
_m_pPEB_LDR
->
InLoadOrderModuleList
.
Flink
;
}
;
~
ModuleHider
(
)
{
Show
(
)
;
}
;
auto
Hide
(
void
)
->
bool
{
if
(
_m_bIsHided
==
true
)
return
false
;
while
(
_m_pEntry
->
DllBase
)
{
if
(
_m_pEntry
->
DllBase
==
_m_DllHandle
)
{
_m_pDoEntry
=
(
PLDR_DATA_ENTRY
)
_m_pEntry
->
InLoadOrderModuleList
.
Blink
;
_m_pAfterEntry
=
(
PLDR_DATA_ENTRY
)
_m_pEntry
->
InLoadOrderModuleList
.
Flink
;
_m_origAddrs
.
Flink
=
_m_pAfterEntry
->
InLoadOrderModuleList
.
Blink
;
_m_origAddrs
.
Blink
=
_m_pDoEntry
->
InLoadOrderModuleList
.
Flink
;
_m_pDoEntry
->
InLoadOrderModuleList
.
Flink
=
_m_pEntry
->
InLoadOrderModuleList
.
Flink
;
_m_pAfterEntry
->
InLoadOrderModuleList
.
Blink
=
_m_pEntry
->
InLoadOrderModuleList
.
Blink
;
_m_bIsHided
=
true
;
return
true
;
}
_m_pEntry
=
(
PLDR_DATA_ENTRY
)
_m_pEntry
->
InLoadOrderModuleList
.
Flink
;
}
return
false
;
}
;
auto
Show
(
void
)
->
bool
{
if
(
_m_bIsHided
==
true
)
{
_m_pDoEntry
->
InLoadOrderModuleList
.
Flink
=
_m_origAddrs
.
Flink
;
_m_pAfterEntry
->
InLoadOrderModuleList
.
Blink
=
_m_origAddrs
.
Blink
;
_m_bIsHided
=
false
;
return
true
;
}
return
false
;
}
;
auto
IsModuleHided
(
void
)
->
bool
{
return
_m_bIsHided
;
}
;
}
;


Пример использования:

C++:





Код:
HINSTANCE hModule
{
}
;
//предположим, что это валидный хендл нашего модуля
//создадим экзепляр класса, передавая в конструктор хендл модуля
std
::
unique_ptr

pModuleHider
=
std
::
make_unique

(
hModule
)
;
//метод для скрытия модуля
if
(
pModuleHider
->
Hide
(
)
)
std
::
cout

Show
(
)
)
std
::
cout

IsModuleHided
(
)
;
 
Ответить с цитированием

  #3  
Старый 18.07.2023, 14:53
Z3roKwq
Участник форума
Регистрация: 20.12.2021
Сообщений: 290
С нами: 2315345

Репутация: 48
По умолчанию

Функцию позволяющая установить позицию камеры на 3д координаты

Цитата:
Сообщение от Спойлер  


C++:





Код:
void
SFrotateCameraAt3D
(
CVector coords
)
{
CVector camera_orig
=
*
GAME
->
GetCamera
(
)
->
GetCam
(
GAME
->
GetCamera
(
)
->
GetActiveCam
(
)
)
->
GetSource
(
)
;
;
int
camera_mode
=
GAME
->
GetCamera
(
)
->
GetCam
(
GAME
->
GetCamera
(
)
->
GetActiveCam
(
)
)
->
GetMode
(
)
;
CVector2D crosshair_offset
;
float
aspect_ratio
;
CVector vector
;
vector
=
{
(
camera_orig
.
fX
-
coords
.
fX
)
,
(
camera_orig
.
fY
-
coords
.
fY
)
,
(
camera_orig
.
fZ
-
coords
.
fZ
)
}
;
crosshair_offset
=
{
*
reinterpret_cast

(
0xB6EC10
)
,
*
reinterpret_cast

(
0xB6EC14
)
}
;
aspect_ratio
=
*
reinterpret_cast

(
0xC3EFA4
)
;
float
mult
;
float
idk_fX
,
idk_fZ
;
float
idk_afX
,
idk_afZ
;
mult
=
tan
(
GAME
->
GetCamera
(
)
->
GetCam
(
GAME
->
GetCamera
(
)
->
GetActiveCam
(
)
)
->
GetFOV
(
)
*
0.5
*
0.01745
)
;
idk_fZ
=
(
3.14
-
atan2
(
1.0
,
mult
*
(
(
0.5
-
crosshair_offset
.
fX
)
*
(
2
/
aspect_ratio
)
)
)
)
;
idk_fX
=
(
3.14
-
atan2
(
1.0
,
mult
*
2
*
(
crosshair_offset
.
fY
-
0.5
)
)
)
;
if
(
!
(
camera_mode
==
53
||
camera_mode
==
55
)
)
{
idk_fX
=
3.14
/
2
;
idk_fZ
=
3.14
/
2
;
}
idk_afX
=
atan2
(
vector
.
fY
,
-
vector
.
fX
)
-
3.14
/
2
;
idk_afZ
=
atan2
(
sqrt
(
vector
.
fX
*
vector
.
fX
+
vector
.
fY
*
vector
.
fY
)
,
vector
.
fZ
)
;
GAME
->
GetCamera
(
)
->
GetCam
(
GAME
->
GetCamera
(
)
->
GetActiveCam
(
)
)
->
SetDirection
(
(
idk_afZ
-
idk_fZ
)
,
(
idk_fX
-
idk_afX
)
)
;
//SF->getCLEO()->callOpcode("0A25: %f %f", (idk_afZ - idk_fZ), (idk_fX - idk_afX));
}


Цитата:
Сообщение от Спойлер  


C++:





Код:
void
rotateCameraAt3D
(
CVector coords
)
{
CVector camera_orig
=
TheCamera
.
GetPosition
(
)
;
int
camera_mode
=
TheCamera
.
m_aCams
[
0
]
.
m_nMode
;
CVector2D crosshair_offset
;
float
aspect_ratio
;
CVector vector
;
vector
=
{
(
camera_orig
.
x
-
coords
.
x
)
,
(
camera_orig
.
y
-
coords
.
y
)
,
(
camera_orig
.
z
-
coords
.
z
)
}
;
crosshair_offset
=
{
*
reinterpret_cast

(
0xB6EC10
)
,
*
reinterpret_cast

(
0xB6EC14
)
}
;
aspect_ratio
=
*
reinterpret_cast

(
0xC3EFA4
)
;
float
mult
;
float
idk_fX
,
idk_fZ
;
float
idk_afX
,
idk_afZ
;
mult
=
tan
(
TheCamera
.
FindCamFOV
(
)
*
0.5
*
0.01745
)
;
idk_fZ
=
(
3.14
-
atan2
(
1.0
,
mult
*
(
(
0.5
-
crosshair_offset
.
x
)
*
(
2
/
aspect_ratio
)
)
)
)
;
idk_fX
=
(
3.14
-
atan2
(
1.0
,
mult
*
2
*
(
crosshair_offset
.
y
-
0.5
)
)
)
;
if
(
!
(
camera_mode
==
53
||
camera_mode
==
55
)
)
{
idk_fX
=
3.14
/
2
;
idk_fZ
=
3.14
/
2
;
}
idk_afX
=
atan2
(
vector
.
y
,
-
vector
.
x
)
-
3.14
/
2
;
idk_afZ
=
atan2
(
sqrt
(
vector
.
x
*
vector
.
x
+
vector
.
y
*
vector
.
y
)
,
vector
.
z
)
;
TheCamera
.
m_aCams
[
0
]
.
m_fHorizontalAngle
=
(
idk_fX
-
idk_afX
)
;
TheCamera
.
m_aCams
[
0
]
.
m_fVerticalAngle
=
(
idk_afZ
-
idk_fZ
)
;
}


 
Ответить с цитированием

  #4  
Старый 06.11.2023, 05:03
p1cador
Участник форума
Регистрация: 19.03.2014
Сообщений: 222
С нами: 6395080

Репутация: 128
По умолчанию

Converts 2d screen coordinates (.z is depth) to world 3d coordinates. Actually, this is implementation of the SF opcode:

CLEO:





Код:
0B8F:
convert_screen_coords
1@
2@
depth
3@
to_world_3d
4@
5@
6@


C:





Код:
#if defined(_MSC_VER)
#define CC_STDCALL   __stdcall
#elif defined(__GNUC__) || defined(__clang__)
#define CC_STDCALL   __attribute__((stdcall))
#endif
typedef
struct
D3DMATRIX
{
union
{
struct
{
float
_11
;
float
_12
;
float
_13
;
float
_14
;
float
_21
;
float
_22
;
float
_23
;
float
_24
;
float
_31
;
float
_32
;
float
_33
;
float
_34
;
float
_41
;
float
_42
;
float
_43
;
float
_44
;
}
;
float
m
[
4
]
[
4
]
;
}
;
}
D3DMATRIX
;
typedef
struct
CVector
{
float
x
;
float
y
;
float
z
;
}
CVector
;
typedef
char
(
CC_STDCALL
*
D3DXMatrixInverse_t
)
(
void
*
a1
,
float
*
a2
,
const
void
*
a3
)
;
D3DXMatrixInverse_t D3DXMatrixInverse
=
(
D3DXMatrixInverse_t
)
0x76795B
;
void
convert_screen_coords_to_world_3d
(
const
CVector
*
screen_coors
,
CVector
*
world_coors
)
{
D3DMATRIX worldMatrix
;
/* Get the combined view-projection matrix and invert it */
memcpy
(
&
worldMatrix
,
(
const
void
*
)
0xB6FA2C
,
sizeof
(
worldMatrix
)
)
;
worldMatrix
.
m
[
3
]
[
3
]
=
1.0f
;
D3DMATRIX inverseMatrix
;
// TODO: Check is it possible to reuse the same matrix
D3DXMatrixInverse
(
&
inverseMatrix
,
NULL
,
&
worldMatrix
)
;
/* Apply the inverse view-projection matrix to the screen coordinates */
float
invZ
=
1.0f
/
screen_coors
->
z
;
float
screenX
=
screen_coors
->
x
/
(
*
(
int
*
)
0xC17044
*
invZ
)
;
float
screenY
=
screen_coors
->
y
/
(
*
(
int
*
)
0xC17048
*
invZ
)
;
/* Transform the screen coordinates into world coordinates */
world_coors
->
x
=
screenX
*
inverseMatrix
.
_11
+
screenY
*
inverseMatrix
.
_21
+
screen_coors
->
z
*
inverseMatrix
.
_31
+
inverseMatrix
.
_41
;
world_coors
->
y
=
screenX
*
inverseMatrix
.
_12
+
screenY
*
inverseMatrix
.
_22
+
screen_coors
->
z
*
inverseMatrix
.
_32
+
inverseMatrix
.
_42
;
world_coors
->
z
=
screenX
*
inverseMatrix
.
_13
+
screenY
*
inverseMatrix
.
_23
+
screen_coors
->
z
*
inverseMatrix
.
_33
+
inverseMatrix
.
_43
;
}


Tested on 1.0 US
 
Ответить с цитированием

  #5  
Старый 19.05.2024, 13:35
#Northn
Флудер
Регистрация: 10.08.2017
Сообщений: 2,659
С нами: 4609424

Репутация: 183


По умолчанию

Добавляет пробелы между целыми тысячами, десятью тысячами, и так далее...

C++:





Код:
std
::
string
separate_number
(
auto
number
,
char
separator
=
' '
)
{
static_assert
(
std
::
is_integral_v

,
"only integral values are supported"
)
;
std
::
string ret_number
;
auto
number_str
=
std
::
to_string
(
number
)
;
auto
i
=
0
;
for
(
auto
str_iter
=
number_str
.
rbegin
(
)
;
str_iter
!=
number_str
.
rend
(
)
;
++
str_iter
)
{
auto
next_str_iter
=
str_iter
+
1
;
ret_number
+=
*
str_iter
;
if
(
next_str_iter
!=
number_str
.
rend
(
)
&&
*
next_str_iter
!=
'-'
&&
++
i
==
3
)
{
ret_number
+=
separator
;
i
=
0
;
}
}
std
::
reverse
(
ret_number
.
begin
(
)
,
ret_number
.
end
(
)
)
;
return
ret_number
;
}


Использование:

C++:





[CODE]
std
::
cout

 
Ответить с цитированием

  #6  
Старый 20.07.2024, 17:03
_=Gigant=_
Участник форума
Регистрация: 19.01.2017
Сообщений: 130
С нами: 4901705

Репутация: 98
По умолчанию

Functions to add names to the file, could be useful for friends list etc... not just names other text in general:





Код:
void
WriteNamesToFile
(
const
std
::
string
&
filename
,
const
std
::
set

&
names
)
{
std
::
ofstream
outfile
(
filename
)
;
for
(
const
auto
&
name
:
names
)
{
if
(
!
name
.
empty
(
)
)
{
outfile

names
=
ReadNamesFromFile
(
filename
)
;
if
(
new_name
.
empty
(
)
||
names
.
find
(
new_name
)
!=
names
.
end
(
)
)
return
;
names
.
insert
(
new_name
)
;
WriteNamesToFile
(
filename
,
names
)
;
}
//name_to_remove or in general any text
void
RemoveNameFromFile
(
const
std
::
string
&
filename
,
const
std
::
string
&
name_to_remove
)
{
std
::
set

names
=
ReadNamesFromFile
(
filename
)
;
if
(
names
.
erase
(
name_to_remove
)
>
0
)
WriteNamesToFile
(
filename
,
names
)
;
}
bool
NameExistsInFile
(
const
std
::
string
&
filename
,
const
std
::
string
&
name_to_check
)
{
std
::
set

names
=
ReadNamesFromFile
(
filename
)
;
return
names
.
find
(
name_to_check
)
!=
names
.
end
(
)
;
}
std
::
set

ReadNamesFromFile
(
const
std
::
string
&
filename
)
{
std
::
set

names
;
std
::
ifstream
infile
(
filename
)
;
std
::
string name
;
while
(
std
::
getline
(
infile
,
name
)
)
{
if
(
!
name
.
empty
(
)
)
names
.
insert
(
name
)
;
}
return
names
;
}
 
Ответить с цитированием

  #7  
Старый 21.08.2024, 16:19
walkerdev
Новичок
Регистрация: 31.07.2022
Сообщений: 7
С нами: 1994625

Репутация: 1
По умолчанию

SAMPFuncs - управление выносливостью игрока

Функции get/set:





Код:
float
getFloatFromMemory
(
unsigned
char
*
memoryAddress
)
{
float
*
floatPtr
=
reinterpret_cast

(
memoryAddress
)
;
return
*
floatPtr
;
}
void
setFloatToMemory
(
unsigned
char
*
memoryAddress
,
float
value
)
{
float
*
floatPtr
=
reinterpret_cast

(
memoryAddress
)
;
*
floatPtr
=
value
*
31.47000244
;
}


Пример использования:





[CODE]
unsigned
char
*
memoryAddress
=
reinterpret_cast

(
0xB7CDB4
)
;
float
value
=
0.0f
;
if
(
type
>=
20
)
value
=
100.0f
;
else
if
(
type
>=
10
&&
type
=
4
&&
type



type - в моем случае переменная, которая передается из pawn-кода, отвечающая за выносливость игрока.
 
Ответить с цитированием
Ответ





Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT ™ © 2001- Antichat Kft.