Skip to content

Commit bbdce38

Browse files
Merge pull request #1 from plusvic/master
Pull latest changes from yara master
2 parents 4fafd37 + 751cf43 commit bbdce38

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

docs/modules/pe.rst

+24
Original file line numberDiff line numberDiff line change
@@ -529,3 +529,27 @@ Reference
529529
*addr*. *addr* can be an offset into the file or a memory address.
530530

531531
*Example: pe.section_index(pe.entry_point)*
532+
533+
.. c:function:: is_dll()
534+
535+
.. versionadded:: 3.5.0
536+
537+
Function returning true if the PE is a DLL.
538+
539+
*Example: pe.is_dll()*
540+
541+
.. c:function:: is_32bit()
542+
543+
.. versionadded:: 3.5.0
544+
545+
Function returning true if the PE is 32bits.
546+
547+
*Example: pe.is_32bit()*
548+
549+
.. c:function:: is_64bit()
550+
551+
.. versionadded:: 3.5.0
552+
553+
Function returning true if the PE is 64bits.
554+
555+
*Example: pe.is_64bit()*

libyara/modules/pe.c

+40
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,43 @@ define_function(language)
18601860
}
18611861

18621862

1863+
define_function(is_dll)
1864+
{
1865+
int64_t characteristics;
1866+
YR_OBJECT* module = module();
1867+
1868+
if (is_undefined(module, "characteristics"))
1869+
return_integer(UNDEFINED);
1870+
1871+
characteristics = get_integer(module, "characteristics");
1872+
return_integer(characteristics & IMAGE_FILE_DLL);
1873+
}
1874+
1875+
1876+
define_function(is_32bit)
1877+
{
1878+
YR_OBJECT* module = module();
1879+
PE* pe = module->data;
1880+
1881+
if (pe == NULL)
1882+
return_integer(UNDEFINED);
1883+
1884+
return_integer(IS_64BITS_PE(pe) ? 0 : 1);
1885+
}
1886+
1887+
1888+
define_function(is_64bit)
1889+
{
1890+
YR_OBJECT* module = module();
1891+
PE* pe = module->data;
1892+
1893+
if (pe == NULL)
1894+
return_integer(UNDEFINED);
1895+
1896+
return_integer(IS_64BITS_PE(pe) ? 1 : 0);
1897+
}
1898+
1899+
18631900
static uint64_t rich_internal(
18641901
YR_OBJECT* module,
18651902
uint64_t version,
@@ -2102,6 +2139,9 @@ begin_declarations;
21022139
declare_function("imports", "s", "i", imports_dll);
21032140
declare_function("locale", "i", "i", locale);
21042141
declare_function("language", "i", "i", language);
2142+
declare_function("is_dll", "", "i", is_dll);
2143+
declare_function("is_32bit", "", "i", is_32bit);
2144+
declare_function("is_64bit", "", "i", is_64bit);
21052145

21062146
declare_integer("resource_timestamp");
21072147

0 commit comments

Comments
 (0)