The file from resources is passed to function Change which should XOR each byte value, but then I get write access violation error.
INT CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR lpCmdLine, INT nCmdShow)
{
HRSRC hRes = FindResource(NULL, L"FILE", RT_RCDATA);
if (hRes == NULL)
{
// print error
}
DWORD resSize = SizeofResource(NULL, hRes);
HGLOBAL resData = LoadResource(NULL, hRes);
byte *file = reinterpret_cast<byte*>(LockResource(resData));
Change(file, resSize);
return 0;
}
void Change(byte *data, int size)
{
for (int i = 0; i < size; ++i)
{
data[i] ^= 2;
}
}
LockResourceto ensure that it wasn't null?