谁能帮我解决这个错误。我基本上是在读取一个 exe 文件,对其进行解密并将其复制到内存中,然后使用 createthread() 执行它,但似乎在实现此方法时我犯了一些错误。
unsigned char key[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
AES aes(128);
unsigned char* decipheredBuffer = aes.DecryptECB((unsigned char*)buffer, exeSize, key);
DWORD old_protect;
void* executable_area = VirtualAlloc(0, sizeof(decipheredBuffer), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (executable_area == 0) {
return 0;
}
memcpy(executable_area, decipheredBuffer, sizeof(decipheredBuffer));
//((void(*)())executable_area)();
bool protectTrue = VirtualProtect(executable_area, sizeof(decipheredBuffer), PAGE_EXECUTE_READWRITE, &old_protect);
if(protectTrue){
void* hThread = CreateThread(NULL, sizeof(decipheredBuffer), (LPTHREAD_START_ROUTINE)executable_area, NULL, 0, NULL);
if (hThread != 0) {
WaitForSingleObject(hThread, 0xFFFFFFFF);//acess violation
}
}
VirtualProtect(executable_area, sizeof(decipheredBuffer), old_protect, &old_protect);
VirtualFree(executable_area, 0, MEM_RELEASE);