Пример #1
0
 def load_ami_lib(self,
                  lib_name,
                  cwd_lock=None,
                  run_sp=None,
                  progdir_lock=None):
     """try to load native lib from ami path
     return (lib_base_addr, seglist_baddr) or (0,0)"""
     search_paths = self.get_lib_search_paths(lib_name)
     # now try search paths
     prog_dir = "PROGDIR:"
     for ami_path in search_paths:
         # handle PROGDIR
         if ami_path.startswith(prog_dir):
             path = ami_path[len(prog_dir):]
             lock = progdir_lock
         else:
             path = ami_path
             lock = cwd_lock
         seglist_baddr = self.segloader.load_ami_seglist(path, lock)
         log_libmgr.debug(
             "load_ami_lib: path=%s, lock=%s -> seglist=%08x",
             path,
             lock,
             seglist_baddr,
         )
         if seglist_baddr > 0:
             return self._load_common(lib_name, seglist_baddr, run_sp)
     return 0, 0
Пример #2
0
 def open_lib(self,
              lib_name,
              cwd_lock=None,
              run_sp=None,
              progdir_lock=None):
     log_libmgr.info(
         "[native] +open_lib: lib_name='%s', cwd=%s, progdir=%s",
         lib_name,
         cwd_lock,
         progdir_lock,
     )
     # multict lib base name
     base_name = self.loader.get_lib_base_name(lib_name)
     # find library
     lib_info = self._find_info(base_name)
     log_libmgr.info("find: '%s' -> %s", base_name, lib_info)
     # not found... try to load it
     if not lib_info:
         log_libmgr.info("loading native lib: '%s'", lib_name)
         load_addr, seglist_baddr = self.loader.load_ami_lib(
             lib_name, cwd_lock, run_sp, progdir_lock)
         # even loading failed... abort
         if load_addr == 0:
             log_libmgr.info("[native] -open_lib: load failed!")
             return 0
         log_libmgr.info("loaded: @%06x  seglist: @%06x", load_addr,
                         seglist_baddr)
         info = self.segloader.get_info(seglist_baddr)
         log_libmgr.info("loaded: %s", info)
         # store original load addr and name in info
         lib_info = self._add_info(base_name, load_addr, seglist_baddr)
         loaded = True
     else:
         load_addr = lib_info.get_load_addr()
         loaded = False
     # got lib: open lib... may return new base!
     log_libmgr.debug("[native] call open lib: load_addr=%06x", load_addr)
     lib_base = self.funcs.open_library(load_addr, run_sp)
     # save base addr
     if lib_base > 0:
         lib_info.add_base_addr(lib_base)
     elif loaded:
         # remove lib info again
         self.lib_infos.remove(lib_info)
     log_libmgr.info(
         "[native] -open_lib: load_addr=@%06x, lib_base=@%06x, %s",
         load_addr,
         lib_base,
         lib_info,
     )
     # return base
     return lib_base
Пример #3
0
 def open_base_libs(self):
     log_libmgr.info("opening base libs...")
     # open exec lib
     self.exec_addr = self.lib_mgr.open_lib('exec.library', 0)
     self.exec_vlib = self.lib_mgr.get_vlib_by_addr(self.exec_addr)
     self.exec_impl = self.exec_vlib.get_impl()
     log_libmgr.info("open base lib: exec: @%06x", self.exec_addr)
     # link exec to dos
     self.dos_ctx.set_exec_lib(self.exec_impl)
     # open dos lib
     self.dos_addr = self.lib_mgr.open_lib('dos.library', 0)
     self.dos_vlib = self.lib_mgr.get_vlib_by_addr(self.dos_addr)
     self.dos_impl = self.dos_vlib.get_impl()
     self.dos_ctx.set_dos_lib(self.dos_impl)
     log_libmgr.info("open base lib: dos:  @%06x", self.dos_addr)
     # set exec base @4
     log_libmgr.debug("setting execbase @4")
     self.machine.set_zero_mem(0, self.exec_addr)
Пример #4
0
 def open_lib(self, lib_name, cwd_lock=None, run_sp=None, progdir_lock=None):
   log_libmgr.info("[native] +open_lib: lib_name='%s', cwd=%s, progdir=%s",
                   lib_name, cwd_lock, progdir_lock)
   # multict lib base name
   base_name = self.loader.get_lib_base_name(lib_name)
   # find library
   lib_info = self._find_info(base_name)
   log_libmgr.info("find: '%s' -> %s", base_name, lib_info)
   # not found... try to load it
   if not lib_info:
     log_libmgr.info("loading native lib: '%s'", lib_name)
     load_addr, seglist_baddr = self.loader.load_ami_lib(
         lib_name, cwd_lock, run_sp, progdir_lock)
     # even loading failed... abort
     if load_addr == 0:
       log_libmgr.info("[native] -open_lib: load failed!")
       return 0
     log_libmgr.info("loaded: @%06x  seglist: @%06x",
                     load_addr, seglist_baddr)
     info = self.segloader.get_info(seglist_baddr)
     log_libmgr.info("loaded: %s", info)
     # store original load addr and name in info
     lib_info = self._add_info(base_name, load_addr, seglist_baddr)
     loaded = True
   else:
     load_addr = lib_info.get_load_addr()
     loaded = False
   # got lib: open lib... may return new base!
   log_libmgr.debug("[native] call open lib: load_addr=%06x", load_addr)
   lib_base = self.funcs.open_library(load_addr, run_sp)
   # save base addr
   if lib_base > 0:
     lib_info.add_base_addr(lib_base)
   elif loaded:
     # remove lib info again
     self.lib_infos.remove(lib_info)
   log_libmgr.info("[native] -open_lib: load_addr=@%06x, lib_base=@%06x, %s",
                   load_addr, lib_base, lib_info)
   # return base
   return lib_base