c++ - 如何将模块化代码更改为 OOP 设计?
问题描述
我正在尝试将这个 c 的自突变示例移植到 c++,但是我遇到了指针问题,以使其适用于 c++ OOP 的这个示例。我已经更改了显示数据的部分,但是如何更改其余的指针?
啊啊啊
void aa::display(std::string data){
const char* str;
str = data.data();
std::cout << str << std::endl;
}
void aa::printfFunctionStub() {}
void aa::enc(DWORD dwAddress, DWORD dwSize) {
__asm {
mov ecx, dwAddress
add ecx, dwSize
mov eax, dwAddress
C_loop :
xor byte ptr ds : [eax], 0x5A
inc eax
cmp eax, ecx
jl C_loop;
}
}
aa.cpp
class aa{
public:
void debugger();
bool IsVmRunning();
void sandbox();
void foo(void);
void display(std::string data);
void printfFunctionStub();
void enc(DWORD dwAddress, DWORD dwSize);
};
主文件
int main(){
DWORD dwPrintFunctionSize = 0, dwOldProtect; 双字 *fA = NULL,*fB = NULL;
// Obtain the addresses for the functions so we can calculate size. fA = (DWORD *)&printfFunction; fB = (DWORD *)&printfFunctionStub;
// Get total function size
dwPrintFunctionSize = (fB - fA);
// Test the function
aa.display("Hello A!\n");
// We need to give ourselves access to modifify data at the given address
VirtualProtect(fA, dwPrintFunctionSize, PAGE_READWRITE, &dwOldProtect);
enc((DWORD)fA, dwPrintFunctionSize); // XOR encrypt the function
enc((DWORD)fA, dwPrintFunctionSize); // XOR decrypt the function
// Restore the old protection
VirtualProtect(fA, dwPrintFunctionSize, dwOldProtect, NULL);
// Test the function
aa.display("Hello B!\n");
_getch();
return 0;
}
解决方案
推荐阅读
- python - glClearColor 返回负值?(溢出?)
- javascript - 如何在不使用 npm 或 nodejs 的情况下捆绑 javascript 文件?[ 独立的 javascript 捆绑器 ]
- java - ForEach 循环和 PropertyNotFoundExceptions 中的 JSP 错误
- python - 是否有输入 Google 结果的每个链接并提取文本的程序?
- javascript - 在输入字段中输入 youtube 视频 url,它应该显示该视频的 iframe 以进行确认
- python - 如何通过从python中的用户获取函数名来调用另一个文件中的函数?
- android - 如果仅安装了面部作为生物特征,则使用 AndroidX.Biometric 的 KeyGeneration 会失败
- python - FFT 中的幅度单位
- docker - 是否可以使用 Table API 选项在 docker-compose 中运行 Comos DB
- r - 从 radioButton 中选择的选项中获取 ggplot 的标题