c++winapielectronresourcesexecutable

Trying to read resources of an external executable file C++


I'm trying to read resources of an external executable. I'm using Resource Tuner application and it gives me such a result:

image

std::filesystem::path exeSignalPath{ LR"__(c:\Users\user\AppData\Local\Programs\signal-desktop\Signal.exe)__" };

const HMODULE hExe = ::LoadLibrary(exeSignalPath.c_str());

if (NULL == hExe)
{
    return 0;
}

const HRSRC handleIntegrity = ::FindResourceW(hExe, L"ElectronAsar", L"Integrity");

if (handleIntegrity == NULL)
{
    return 0;
}

LPVOID lpResLock = ::LockResource(handleIntegrity);

if (NULL == lpResLock)
{
    ::FreeResource(handleIntegrity);

    return 0;
}

DWORD resorcesSize = ::SizeofResource(hExe, handleIntegrity);

if (0 == resorcesSize)
{
    UnlockResource(handleIntegrity);
    ::FreeResource(handleIntegrity);

    return 0;
}

std::string res(std::bit_cast<uint8_t*>(lpResLock), std::bit_cast<uint8_t*>(lpResLock) + resorcesSize);

But the result string contains such a binary data:

image

Is there any way to make this data readable like on the first image?


Solution

  • I missed call of LoadResource. Now it's works just fine.