Exemplo n.º 1
0
        public void HPSC_DiscardNodes()
        {
            Given_Image32(
                0x0010000,
                "55 8B EC  a1 32 12 1a 12 5D c3");
            Given_x86_32();
            Given_RewriterHost();
            Given_NoImportedProcedures();

            When_DisassembleProcedure();
            var hps = new BlockConflictResolver(program, CreateScanResults(proc.Cfg), proc.IsValidAddress, host.Object);

            hps.ResolveBlockConflicts(new[] { proc.BeginAddress });

            var sExp =
                #region Expected
                @"l00010000:  // pred:
    push ebp
l00010001:  // pred: l00010000
    mov ebp,esp
l00010003:  // pred: l00010001
    mov eax,[121A1232]
l00010008:  // pred: l00010003
    pop ebp
l00010009:  // pred: l00010008
    ret
";

            #endregion

            AssertBlocks(sExp, proc.Cfg);
        }
Exemplo n.º 2
0
        public void HPSC_Conflicts_1()
        {
            Given_Image32(
                0x0010000,
                "55 89 e5 c3");
            Given_x86_32();
            Given_RewriterHost();

            When_DisassembleProcedure();
            var conflicts = BlockConflictResolver.BuildConflictGraph(proc.Cfg.Nodes);
            var sExp      =
                @"(l00010001-l00010002)
(l00010002-l00010003)
";

            AssertConflicts(sExp, conflicts);
        }
Exemplo n.º 3
0
        public void HPSC_TrickyProc()
        {
            Given_Image32(0x0010000, TrickyProc);
            program.SegmentMap.AddSegment(new ImageSegment(
                                              "code",
                                              new MemoryArea(Address.Ptr32(0x11750000), new byte[100]),
                                              AccessMode.ReadExecute));
            Given_x86_32();
            Given_RewriterHost();
            Given_NoImportedProcedures();
            mr.ReplayAll();

            When_DisassembleProcedure();
            var hps = new BlockConflictResolver(program, CreateScanResults(proc.Cfg), proc.IsValidAddress, host);

            hps.BlockConflictResolution(proc.BeginAddress);

            var sExp =
                #region Expected
                @"l00010000:  // pred:
    push ebp
l00010001:  // pred: l00010000
    mov ebp,esp
l00010003:  // pred: l00010001
    call 11750008
l0001000A:  // pred:
    cmp al,00
l0001000C:  // pred: l0001000A
    jnz 00010014
l0001000E:  // pred: l0001000C
    mov al,00
l00010010:  // pred: l0001000E
    jmp 00010019
l00010014:  // pred: l0001000C
    mov eax,[01740000]
l00010019:  // pred: l00010010 l00010014
    mov esp,ebp
l0001001B:  // pred: l00010019
    pop ebp
l0001001C:  // pred: l0001001B
    ret 
";

            #endregion
            AssertBlocks(sExp, proc.Cfg);
        }
Exemplo n.º 4
0
        public void HPSC_Conflicts_2()
        {
            Given_Image32(
                0x0010000,
                "55 E8 00 00 00 38 c3");
            Given_x86_32();
            Given_RewriterHost();
            mr.ReplayAll();

            When_DisassembleProcedure();
            var conflicts = BlockConflictResolver.BuildConflictGraph(proc.Cfg.Nodes);
            var sExp      =
                @"(l00010001-l00010002)
(l00010001-l00010003)
(l00010001-l00010004)
(l00010001-l00010005)
(l00010002-l00010003)
(l00010003-l00010004)
(l00010004-l00010005)
(l00010005-l00010006)
";

            AssertConflicts(sExp, conflicts);
        }
Exemplo n.º 5
0
        private void ResolveBlockConflicts(ScanResults sr)
        {
            var hps = new BlockConflictResolver(null, sr, null, null);

            hps.ResolveBlockConflicts(new Address[0]);
        }
Exemplo n.º 6
0
        private void RemoveConflictingBlocks(params uint[] wProcStarts)
        {
            var hs = new BlockConflictResolver(null, sr, null, null);

            hs.ResolveBlockConflicts(wProcStarts.Select(w => Address.Ptr32(w)));
        }