merged from seg
This commit is contained in:
explorer
2024-11-09 15:31:28 +03:00
parent e462dff4f5
commit bdf8f51f29
22 changed files with 143 additions and 446 deletions

View File

@ -1,6 +1,38 @@
#pragma once
namespace Byte_Manager
{
#include "Byte_Manager_Functions.hpp"
void Set_Bytes(__int8 Writeable, void* Address, unsigned __int32 Size, unsigned __int8 Byte)
{
if (Writeable == 0)
{
DWORD Previous_Access_Rights;
VirtualProtect(Address, Size, PAGE_EXECUTE_READWRITE, &Previous_Access_Rights);
__builtin_memset(Address, Byte, Size);
VirtualProtect(Address, Size, Previous_Access_Rights, &Previous_Access_Rights);
}
else
{
__builtin_memset(Address, Byte, Size);
}
}
void Copy_Bytes(__int8 Writeable, void* Address, unsigned __int32 Size, void* Bytes)
{
if (Writeable == 0)
{
DWORD Previous_Access_Rights;
VirtualProtect(Address, Size, PAGE_EXECUTE_READWRITE, &Previous_Access_Rights);
__builtin_memcpy(Address, Bytes, Size);
VirtualProtect(Address, Size, Previous_Access_Rights, &Previous_Access_Rights);
}
else
{
__builtin_memcpy(Address, Bytes, Size);
}
}
};

View File

@ -1,22 +0,0 @@
#pragma once
#ifdef Bits_32
void Copy_Bytes(__int8 Modify_Access_Rights, void* Starting_Location, unsigned __int32 Bytes_Amount, void* Bytes)
#else
void Copy_Bytes(__int8 Modify_Access_Rights, void* Starting_Location, unsigned __int64 Bytes_Amount, void* Bytes)
#endif
{
unsigned long __int32 Previous_Access_Rights;
if (Modify_Access_Rights == 1)
{
VirtualProtect(Starting_Location, Bytes_Amount, PAGE_EXECUTE_READWRITE, &Previous_Access_Rights);
}
__builtin_memcpy(Starting_Location, Bytes, Bytes_Amount);
if (Modify_Access_Rights == 1)
{
VirtualProtect(Starting_Location, Bytes_Amount, Previous_Access_Rights, &Previous_Access_Rights);
}
}

View File

@ -1,24 +0,0 @@
#pragma once
#ifdef Bits_32
void* Find_Bytes(void* Starting_Location, void* Bytes, unsigned __int32 Bytes_Amount)
#else
void* Find_Bytes(void* Starting_Location, void* Bytes, unsigned __int64 Bytes_Amount)
#endif
{
Compare_Bytes_Label:
{
if (__builtin_memcmp(Starting_Location, Bytes, Bytes_Amount) == 0)
{
return Starting_Location;
}
#ifdef Bits_32
Starting_Location = (void*)((unsigned __int32)Starting_Location + 1);
#else
Starting_Location = (void*)((unsigned __int64)Starting_Location + 1);
#endif
goto Compare_Bytes_Label;
}
}

View File

@ -1,7 +0,0 @@
#pragma once
#include "Byte_Manager_Find_Bytes.hpp"
#include "Byte_Manager_Set_Bytes.hpp"
#include "Byte_Manager_Copy_Bytes.hpp"

View File

@ -1,22 +0,0 @@
#pragma once
#ifdef Bits_32
void Set_Bytes(__int8 Modify_Access_Rights, void* Starting_Location, unsigned __int32 Bytes_Amount, unsigned __int8 Byte)
#else
void Set_Bytes(__int8 Modify_Access_Rights, void* Starting_Location, unsigned __int64 Bytes_Amount, unsigned __int8 Byte)
#endif
{
unsigned long __int32 Previous_Access_Rights;
if (Modify_Access_Rights == 1)
{
VirtualProtect(Starting_Location, Bytes_Amount, PAGE_EXECUTE_READWRITE, &Previous_Access_Rights);
}
__builtin_memset(Starting_Location, Byte, Bytes_Amount);
if (Modify_Access_Rights == 1)
{
VirtualProtect(Starting_Location, Bytes_Amount, Previous_Access_Rights, &Previous_Access_Rights);
}
}