我需要转换std ::字符串到lpvoid for create pimage_dos_header。
我已经测试了一些铸造,但我的PE标头不对。
std::ifstream file;
file.open("C:/testDLL.enc");
std::string data;
file >> data;
file.close();;
std::string decrypted = decrypt(data);
LPVOID lpData = static_cast<LPVOID>(&decrypted[0]);
//LPVOID lpData = reinterpret_cast<LPVOID>((char*)decrypted.c_str());
//LPVOID lpData = (char*)decrypted.c_str();
PIMAGE_DOS_HEADER pDH = (PIMAGE_DOS_HEADER)lpData;
感谢您的帮助。
string decryptempty(string data)
{
// I dont know your decrypt & encrypt functions..
return string(data);
}
int main() {
std::ifstream file;
file.open("C://testDLL.dll",ios::binary);
std::string data;
file >> data;
file.close();
string decryptedstr = decryptempty(data);
LPVOID ptr = &decryptedstr[0];
PIMAGE_DOS_HEADER pDos = reinterpret_cast<PIMAGE_DOS_HEADER>(ptr);
printf("e_magic : %02xn", pDos->e_magic);
printf("string buffer : %pn", ptr);
getchar();
return 0;
}
输出:E_MAGIC:5A4D字符串缓冲区:00B53A50
e_magic正确。