You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I built POEX and added a test app pretty much as shown in POEX wiki:
#include
#include "..\POEX\POEX.h" // include POEX header
#ifdef x64_DEBUG
#pragma comment(lib, "../Build/Debug/X64/POEX.lib") // Link with POEX.lib
#else
#pragma comment(lib, "../Build/Debug/X86/POEX.lib") // Link with POEX.lib
#endif
int main()
{
const wchar_t* pathToFile = L"C:\_W\_Wdevelop\BandBroadening\empowermonorepo\Source\UnitTests\ASTRALibraryd.dll"; // Path to the file
POEX::PE pe = POEX::PE(pathToFile);
std::unique_ptr resources = pe.GetImageResourceDirectory();
return 0;
}
I get an exception immediately in a call to GetImageResourceDirectory, which calls GetImageNtHeader, which, in turn, calls GetImageDosHeader. Since the offset for DOS header is 0, this last call throws in WRONG_LONG, which expands to (x <= 0), but macro's argument x is in fact 0, "[ERROR] offset value is wrong." is thrown:
ImageDosHeader::ImageDosHeader(const std::shared_ptr& bFile,
const long& offset) : bFile(bFile), offset(offset)
{
if (WRONG_LONG(this->offset))
THROW_EXCEPTION("[ERROR] offset value is wrong.");
}
I built POEX and added a test app pretty much as shown in POEX wiki:
#include
#include "..\POEX\POEX.h" // include POEX header
#ifdef x64_DEBUG
#pragma comment(lib, "../Build/Debug/X64/POEX.lib") // Link with POEX.lib
#else
#pragma comment(lib, "../Build/Debug/X86/POEX.lib") // Link with POEX.lib
#endif
int main()
{
const wchar_t* pathToFile = L"C:\_W\_Wdevelop\BandBroadening\empowermonorepo\Source\UnitTests\ASTRALibraryd.dll"; // Path to the file
POEX::PE pe = POEX::PE(pathToFile);
std::unique_ptr resources = pe.GetImageResourceDirectory();
return 0;
}
I get an exception immediately in a call to GetImageResourceDirectory, which calls GetImageNtHeader, which, in turn, calls GetImageDosHeader. Since the offset for DOS header is 0, this last call throws in WRONG_LONG, which expands to (x <= 0), but macro's argument x is in fact 0, "[ERROR] offset value is wrong." is thrown:
ImageDosHeader::ImageDosHeader(const std::shared_ptr& bFile,
const long& offset) : bFile(bFile), offset(offset)
{
if (WRONG_LONG(this->offset))
THROW_EXCEPTION("[ERROR] offset value is wrong.");
}
Same happens in x86 build.
After changing (in Defines.h)
//#define WRONG_LONG(x) (x <= 0)
#define WRONG_LONG(x) (x < 0)
the code builds and runs.
Please comment and/or fix.
The text was updated successfully, but these errors were encountered: