Skip to content

Commit

Permalink
Reliable detection of CLR dlls is added.
Browse files Browse the repository at this point in the history
  • Loading branch information
himeshsameera committed Sep 8, 2023
1 parent f52229c commit 99fa1c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ClrPhlib/include/ClrPhlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ namespace Dependencies {

// Check if the PE is 32-bit
bool IsArm32Dll();

// Check if the PE is a dot net
bool IsClrDll();

// return the processorArchiture of PE
String^ GetProcessor();
Expand Down
10 changes: 10 additions & 0 deletions ClrPhlib/src/managed/PE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ bool PE::IsArm32Dll()
return ((Properties->Machine & 0xffff) == IMAGE_FILE_MACHINE_ARMNT);
}

bool PE::IsClrDll()
{
PIMAGE_DATA_DIRECTORY dataDirectory;
if (NT_SUCCESS(PhGetMappedImageDataEntry( &m_Impl->m_PvMappedImage, IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR, &dataDirectory)))
{
return dataDirectory->VirtualAddress != 0;
}
return false;
}

String^ PE::GetProcessor()
{
if ((Properties->Machine & 0xffff) == IMAGE_FILE_MACHINE_I386)
Expand Down

0 comments on commit 99fa1c9

Please sign in to comment.