Example #1
0
def Main():
    cgiEnv = lib_common.ScriptEnvironment()

    win_module = cgiEnv.GetId()

    logging.debug("win_module=%s", win_module)

    lib_win32.CheckWindowsModule(win_module)

    grph = cgiEnv.GetGraph()

    env = EnvPeFile(grph)

    rootNode = env.recursive_depends(win_module, max_level=8)

    cgiEnv.OutCgiRdf("LAYOUT_SPLINE")
Example #2
0
def Main():
    cgiEnv = lib_common.CgiEnv()

    win_module = cgiEnv.GetId()

    sys.stderr.write("win_module=%s\n" % win_module)

    lib_win32.CheckWindowsModule(win_module)

    grph = cgiEnv.GetGraph()

    env = EnvPeFile(grph)

    rootNode = env.RecursiveDepends(win_module, maxLevel=8)

    #sys.stderr.write("NbFils=%d\n" % len(env.cache_dll_to_imports))
    #for key in env.cache_dll_to_imports:
    #	sys.stderr.write("Key=%s\n"%key)

    cgiEnv.OutCgiRdf("LAYOUT_SPLINE")
Example #3
0
def Main():

    paramkeyMaximumDepth = "Maximum depth"

    cgiEnv = lib_common.CgiEnv(parameters={paramkeyMaximumDepth: 3})

    maxDepth = int(cgiEnv.get_parameters(paramkeyMaximumDepth))

    win_module = cgiEnv.GetId()

    DEBUG("win_module=%s", win_module)

    lib_win32.CheckWindowsModule(win_module)

    grph = cgiEnv.GetGraph()

    env = EnvPeFile(grph)

    rootNode = env.RecursiveDepends(win_module, maxDepth)

    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_symbol_declared])
Example #4
0
def Main():
    paramkeyGroupByDirs = "Group by directories"

    cgiEnv = lib_common.CgiEnv(parameters={paramkeyGroupByDirs: True})

    flagGroupByDirs = bool(cgiEnv.get_parameters(paramkeyGroupByDirs))

    win_module = cgiEnv.GetId()

    lib_win32.CheckWindowsModule(win_module)

    # This has to be in the path. Is it the 32 bits or 64 bits one ?
    depends_bin = "depends.exe"

    DEBUG("depends_bin=%s", depends_bin)

    tmpFilObj = lib_common.TmpFile("depends")
    tmpOutFil = tmpFilObj.Name
    args = [depends_bin, "/c", "/OC:", tmpOutFil, win_module]

    DEBUG("Depends command=%s", str(args))

    grph = cgiEnv.GetGraph()

    nodeDLL = lib_common.gUriGen.FileUri(win_module)

    # TODO: Check the return value.
    # http://www.dependencywalker.com/help/html/hidr_command_line_help.htm
    p = lib_common.SubProcPOpen(args)
    (nmap_last_output, nmap_err) = p.communicate()
    for lin in nmap_last_output:
        continue
        # Wait for the end, otherwise the file will not be ready.

    try:
        DEBUG("Depends tmpOutFil=%s", tmpOutFil)
        input_file = open(tmpOutFil, 'r')
    except Exception:
        exc = sys.exc_info()[1]
        lib_common.ErrorMessageHtml("Caught " + str(exc) +
                                    " when processing:" + tmpOutFil)

    # Status,Module,File Time Stamp,Link Time Stamp,File Size,Attr.,Link Checksum,Real Checksum,CPU,Subsystem,Symbols,Preferred Base,Actual Base,Virtual Size,Load Order,File Ver,Product Ver,Image Ver,Linker Ver,OS Ver,Subsystem Ver
    # ?,"MSVCR80D.DLL","Error opening file. The system cannot find the file specified (2).",,,,,,,,,,,,,,,,,,
    # D?,"XLCALL32.DLL","Error opening file. The system cannot find the file specified (2).",,,,,,,,,,,,,,,,,,
    # E6,"c:\windows\system32\ADVAPI32.DLL",2012-10-18 21:27:04,2012-10-18 21:27:12,876544,A,0x000D9B98,0x000D9B98,x64,Console,"CV",0x000007FF7FF10000,Unknown,0x000DB000,Not Loaded,6.1.7601.22137,6.1.7601.22137,6.1,9.0,6.1,6.1
    # E6,"c:\windows\system32\API-MS-WIN-CORE-CONSOLE-L1-1-0.DLL",2013-08-02 03:12:18,2013-08-02 03:12:52,3072,HA,0x000081B6,0x000081B6,x64,Console,"CV",0x0000000000400000,Unknown,0x00003000,Not Loaded,6.1.7601.18229,6.1.7601.18229,6.1,9.0,6.1,6.1

    # Used only if libraries are grouped by directory.
    dirsToNodes = {}

    for lin in input_file:
        # TODO: Beware of commas in file names!!!!! Maybe module shlex ?
        linargs = lin.split(',')
        module = linargs[1]
        # The library filename is enclosed in double-quotes, that we must remove.
        modulNam = module[1:-1]
        libNode = lib_common.gUriGen.SharedLibUri(modulNam)

        # If the libraries are displayed in groups belnging to a dir, this is clearer.
        if flagGroupByDirs:
            dirNam = os.path.dirname(modulNam)
            if dirNam == "":
                dirNam = "Unspecified dir"
            try:
                dirNod = dirsToNodes[dirNam]
            except KeyError:
                # TODO: Beware, in fact this is a directory.
                dirNod = lib_common.gUriGen.FileUri(dirNam)
                grph.add((nodeDLL, pc.property_library_depends, dirNod))
                dirsToNodes[dirNam] = dirNod
            grph.add((dirNod, pc.property_library_depends, libNode))
        else:
            grph.add((nodeDLL, pc.property_library_depends, libNode))

        if linargs[0] != '?':
            cpu = linargs[8]
            if cpu not in ["", "CPU"]:
                grph.add((nodeDLL, pc.property_library_cpu,
                          lib_common.NodeLiteral(cpu)))

    # Temporary file removed by constructor.
    input_file.close()

    cgiEnv.OutCgiRdf()