-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
993 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ target_sources( | |
) | ||
|
||
add_subdirectory(GUI) | ||
add_subdirectory(injector) | ||
add_subdirectory(system) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
#include "Assembly.hpp" | ||
|
||
namespace Xash | ||
{ | ||
namespace Injector | ||
{ | ||
void Assembly::ClearInstructions() | ||
{ | ||
_asmInstructions.clear(); | ||
} | ||
|
||
const std::vector<uint8_t> &Assembly::GetAssembly() const | ||
{ | ||
return _asmInstructions; | ||
} | ||
|
||
void Assembly::Ret() | ||
{ | ||
_asmInstructions.push_back(0xC3); | ||
} | ||
|
||
void Assembly::CallRax() | ||
{ | ||
_asmInstructions.push_back(0xFF); | ||
_asmInstructions.push_back(0xD0); | ||
} | ||
|
||
void Assembly::SubRsp(uint8_t value) | ||
{ | ||
_asmInstructions.push_back(0x48); | ||
_asmInstructions.push_back(0x83); | ||
_asmInstructions.push_back(0xEC); | ||
_asmInstructions.push_back(value); | ||
} | ||
|
||
void Assembly::AddRsp(uint8_t value) | ||
{ | ||
_asmInstructions.push_back(0x48); | ||
_asmInstructions.push_back(0x83); | ||
_asmInstructions.push_back(0xC4); | ||
_asmInstructions.push_back(value); | ||
} | ||
|
||
void Assembly::MoveIntoRax(void *value) | ||
{ | ||
_asmInstructions.push_back(0x48); | ||
_asmInstructions.push_back(0xB8); | ||
_asmInstructions.insert( | ||
_asmInstructions.end(), (uint8_t *)&value, (uint8_t *)&value + sizeof(void *) | ||
); | ||
} | ||
|
||
void Assembly::MoveRaxIntoValue(void *value) | ||
{ | ||
_asmInstructions.push_back(0x48); | ||
_asmInstructions.push_back(0xA3); | ||
_asmInstructions.insert( | ||
_asmInstructions.end(), (uint8_t *)&value, (uint8_t *)&value + sizeof(void *) | ||
); | ||
} | ||
|
||
void Assembly::XorRaxRax() | ||
{ | ||
_asmInstructions.push_back(0x48); | ||
_asmInstructions.push_back(0x31); | ||
_asmInstructions.push_back(0xC0); | ||
} | ||
|
||
void Assembly::XorRcxRcx() | ||
{ | ||
_asmInstructions.push_back(0x48); | ||
_asmInstructions.push_back(0x31); | ||
_asmInstructions.push_back(0xC9); | ||
} | ||
|
||
void Assembly::XorRdxRdx() | ||
{ | ||
_asmInstructions.push_back(0x48); | ||
_asmInstructions.push_back(0x31); | ||
_asmInstructions.push_back(0xD2); | ||
} | ||
|
||
void Assembly::XorR8R8() | ||
{ | ||
_asmInstructions.push_back(0x4D); | ||
_asmInstructions.push_back(0x31); | ||
_asmInstructions.push_back(0xC0); | ||
} | ||
|
||
void Assembly::XorR9R9() | ||
{ | ||
_asmInstructions.push_back(0x4D); | ||
_asmInstructions.push_back(0x31); | ||
_asmInstructions.push_back(0xC9); | ||
} | ||
|
||
void Assembly::MoveIntoRcx(void *value) | ||
{ | ||
_asmInstructions.push_back(0x48); | ||
_asmInstructions.push_back(0xB9); | ||
_asmInstructions.insert( | ||
_asmInstructions.end(), (uint8_t *)&value, (uint8_t *)&value + sizeof(void *) | ||
); | ||
} | ||
|
||
void Assembly::MoveIntoRdx(void *value) | ||
{ | ||
_asmInstructions.push_back(0x48); | ||
_asmInstructions.push_back(0xBA); | ||
_asmInstructions.insert( | ||
_asmInstructions.end(), (uint8_t *)&value, (uint8_t *)&value + sizeof(void *) | ||
); | ||
} | ||
|
||
void Assembly::MoveIntoR8(void *value) | ||
{ | ||
_asmInstructions.push_back(0x49); | ||
_asmInstructions.push_back(0xB8); | ||
_asmInstructions.insert( | ||
_asmInstructions.end(), (uint8_t *)&value, (uint8_t *)&value + sizeof(void *) | ||
); | ||
} | ||
|
||
void Assembly::MoveIntoR9(void *value) | ||
{ | ||
_asmInstructions.push_back(0x49); | ||
_asmInstructions.push_back(0xB9); | ||
_asmInstructions.insert( | ||
_asmInstructions.end(), (uint8_t *)&value, (uint8_t *)&value + sizeof(void *) | ||
); | ||
} | ||
|
||
void Assembly::MonoThreadAttach(void *monoAttachFunc, void *MonoDomain) | ||
{ | ||
MoveIntoRax(monoAttachFunc); | ||
MoveIntoRcx(MonoDomain); | ||
CallRax(); | ||
} | ||
} // namespace Injector | ||
} // namespace Xash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
|
||
namespace Xash | ||
{ | ||
namespace Injector | ||
{ | ||
class Assembly | ||
{ | ||
public: | ||
void ClearInstructions(); | ||
const std::vector<uint8_t> &GetAssembly() const; | ||
|
||
void Ret(); | ||
void CallRax(); | ||
|
||
void SubRsp(uint8_t value); | ||
void AddRsp(uint8_t value); | ||
|
||
void MoveIntoRax(void *value); | ||
void MoveIntoRcx(void *value); | ||
void MoveIntoRdx(void *value); | ||
void MoveIntoR8(void *value); | ||
void MoveIntoR9(void *value); | ||
void MoveRaxIntoValue(void *value); | ||
|
||
void XorRaxRax(); | ||
void XorRcxRcx(); | ||
void XorRdxRdx(); | ||
void XorR8R8(); | ||
void XorR9R9(); | ||
|
||
void MonoThreadAttach(void *monoAttachFunc, void *MonoDomain); | ||
|
||
private: | ||
std::vector<uint8_t> _asmInstructions; | ||
}; | ||
} // namespace Injector | ||
} // namespace Xash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
cmake_minimum_required(VERSION 3.27) | ||
|
||
target_include_directories( | ||
${PROJECT_NAME} | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
target_sources( | ||
${PROJECT_NAME} | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/MonoModule.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/Assembly.cpp | ||
) |
Oops, something went wrong.