Storm/Byte_Manager/Byte_Manager.hpp

38 lines
884 B
C++
Raw Permalink Normal View History

namespace Byte_Manager
{
2024-11-09 20:31:28 +08:00
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);
}
}
};