MCPcopy Create free account
hub / github.com/qilingframework/qiling / run

Method run

qiling/loader/pe.py:825–881  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

823 self.libcache = QlPeCache() if libcache else None
824
825 def run(self):
826 self.init_dlls = (
827 'ntdll.dll',
828 'kernelbase.dll', # kernel32 forwards some exports to kernelbase
829 'kernel32.dll', # for efficiency, load kernelbase first
830 'user32.dll'
831 )
832
833 self.sys_dlls = (
834 'ntdll.dll',
835 'kernelbase.dll',
836 'kernel32.dll',
837 'mscoree.dll',
838 'ucrtbase.dll'
839 )
840
841 if self.ql.code:
842 pe = None
843 self.is_driver = False
844 else:
845 pe = pefile.PE(self.path, fast_load=True)
846 self.is_driver = pe.is_driver()
847
848 ossection = f'OS{self.ql.arch.bits}'
849
850 self.stack_address = self.ql.os.profile.getint(ossection, 'stack_address')
851 self.stack_size = self.ql.os.profile.getint(ossection, 'stack_size')
852 self.image_address = self.ql.os.profile.getint(ossection, 'image_address')
853 self.dll_address = self.ql.os.profile.getint(ossection, 'dll_address')
854 self.entry_point = self.ql.os.profile.getint(ossection, 'entry_point')
855
856 self.structure_last_addr = {
857 32 : FS_SEGMENT_ADDR,
858 64 : GS_SEGMENT_ADDR
859 }[self.ql.arch.bits]
860
861 self.import_symbols = {}
862 self.export_symbols = {}
863 self.import_address_table = {}
864 self.ldr_list = []
865 self.function_tables = {}
866 self.function_table_lookup = {}
867 self.forwarded_exports = []
868 self.pe_image_address = 0
869 self.pe_image_size = 0
870 self.dll_size = 0
871 self.dll_last_address = self.dll_address
872
873 # not used, but here to remain compatible with ql.do_bin_patch
874 self.load_address = 0
875
876 cmdline = ntpath.join(self.ql.os.userprofile, 'Desktop', self.ql.targetname)
877 cmdargs = ' '.join(f'"{arg}"' if ' ' in arg else arg for arg in self.argv[1:])
878
879 self.cmdline = bytes(f'{cmdline} {cmdargs}\x00', "utf-8")
880
881 self.load(pe)
882

Callers

nothing calls this directly

Calls 1

loadMethod · 0.95

Tested by

no test coverage detected