File tree Expand file tree Collapse file tree 7 files changed +66
-3
lines changed
Expand file tree Collapse file tree 7 files changed +66
-3
lines changed Original file line number Diff line number Diff line change @@ -75,11 +75,14 @@ void create<ImportEntry>(nb::module_& m) {
7575 &ImportEntry::hint,
7676 " Index into the :attr:`lief.PE.Export.entries` that is used to speed-up the symbol resolution" _doc)
7777
78- .def_prop_ro (" iat_value" ,
79- &ImportEntry::iat_value,
78+ .def_prop_rw (" iat_value" ,
79+ nb::overload_cast<>(&ImportEntry::iat_value, nb::const_),
80+ nb::overload_cast<uint64_t >(&ImportEntry::iat_value),
8081 " Value of the current entry in the Import Address Table. It should match the lookup table value." _doc)
8182
82- .def_prop_ro (" ilt_value" , &ImportEntry::ilt_value,
83+ .def_prop_rw (" ilt_value" ,
84+ nb::overload_cast<>(&ImportEntry::ilt_value, nb::const_),
85+ nb::overload_cast<uint64_t >(&ImportEntry::ilt_value),
8386 R"doc(
8487 Original value in the import lookup table.
8588
Original file line number Diff line number Diff line change @@ -160,6 +160,18 @@ impl ImportEntry<'_> {
160160 self . ptr . ilt_value ( )
161161 }
162162
163+ /// Set the value of the current entry in the Import Address Table.
164+ pub fn set_iat_value ( & mut self , value : u64 ) -> & mut Self {
165+ self . ptr . pin_mut ( ) . set_iat_value ( value) ;
166+ self
167+ }
168+
169+ /// Set the original value in the Import Lookup Table.
170+ pub fn set_ilt_value ( & mut self , value : u64 ) -> & mut Self {
171+ self . ptr . pin_mut ( ) . set_ilt_value ( value) ;
172+ self
173+ }
174+
163175 /// Raw value
164176 pub fn data ( & self ) -> u64 {
165177 self . ptr . data ( )
Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ class PE_ImportEntry : public AbstractSymbol {
3333
3434 auto demangled_name () const { return impl ().demangled_name (); }
3535
36+ void set_iat_value (uint64_t value) { impl ().iat_value (value); }
37+ void set_ilt_value (uint64_t value) { impl ().ilt_value (value); }
38+
3639 private:
3740 const lief_t & impl () const { return as<lief_t >(this ); }
41+ lief_t & impl () { return as<lief_t >(this ); }
3842};
Original file line number Diff line number Diff line change 528528 :py: class:`lief.PE.ImportEntry`
529529 :cpp: class:`LIEF::PE::ImportEntry`
530530
531+ .. |lief-pe-importentry-iat-value | lief-api :: lief.PE.ImportEntry.iat_value
532+
533+ :rust: method:`lief::pe::import::ImportEntry::iat_value [struct]`
534+ :py: attr:`lief.PE.ImportEntry.iat_value`
535+ :cpp: func:`LIEF::PE::ImportEntry::iat_value`
536+
537+ .. |lief-pe-importentry-ilt-value | lief-api :: lief.PE.ImportEntry.ilt_value
538+
539+ :rust: method:`lief::pe::import::ImportEntry::ilt_value [struct]`
540+ :py: attr:`lief.PE.ImportEntry.ilt_value`
541+ :cpp: func:`LIEF::PE::ImportEntry::ilt_value`
542+
531543.. |lief-pe-importentry-iat-address | lief-api :: lief.PE.ImportEntry.iat_address()
532544
533545 :rust: method:`lief::pe::import::ImportEntry::iat_address [struct]`
Original file line number Diff line number Diff line change 5757
5858:PE:
5959
60+ * Add setters for |lief-pe-importentry-iat-value | and |lief-pe-importentry-ilt-value |
6061 * Add |lief-pe-binary-offset_to_rva | to convert a raw offset into a RVA
6162 * Update |lief-binary-offset_to_virtual_address | for PE binaries to
6263 return an **absolute ** virtual address instead of a RVA (:issue: `1318 `)
Original file line number Diff line number Diff line change @@ -82,12 +82,20 @@ class LIEF_API ImportEntry : public LIEF::Symbol {
8282 return iat_value_;
8383 }
8484
85+ void iat_value (uint64_t value) {
86+ iat_value_ = value;
87+ }
88+
8589 // / Original value in the import lookup table.
8690 // / This value should match the iat_value().
8791 uint64_t ilt_value () const {
8892 return ilt_value_;
8993 }
9094
95+ void ilt_value (uint64_t value) {
96+ ilt_value_ = value;
97+ }
98+
9199 // / Raw value
92100 uint64_t data () const {
93101 return data_;
Original file line number Diff line number Diff line change @@ -340,6 +340,29 @@ def test_issue_multiple(tmp_path: Path):
340340 assert len (imp .entries ) == 1
341341
342342
343+ def test_set_iat_ilt_value ():
344+ pe = lief .PE .parse (get_sample ("PE/PE64_x86-64_binary_winhello64-mingw.exe" ))
345+
346+ kernel32 = pe .get_import ("KERNEL32.dll" )
347+ assert kernel32 is not None
348+
349+ entry = kernel32 .entries [0 ]
350+ original_iat = entry .iat_value
351+ original_ilt = entry .ilt_value
352+
353+ entry .iat_value = 0xDEADBEEF
354+ entry .ilt_value = 0xCAFEBABE
355+
356+ assert entry .iat_value == 0xDEADBEEF
357+ assert entry .ilt_value == 0xCAFEBABE
358+
359+ entry .iat_value = original_iat
360+ entry .ilt_value = original_ilt
361+
362+ assert entry .iat_value == original_iat
363+ assert entry .ilt_value == original_ilt
364+
365+
343366def test_import_front (tmp_path : Path ):
344367 pe = lief .PE .parse (get_sample ("PE/pe_reader.exe" ))
345368 assert pe .imports [0 ].name == "KERNEL32.dll"
You can’t perform that action at this time.
0 commit comments