Exemplo n.º 1
0
        public void Set_Breakpoint_Correctly()
        {
            var builder = new BreakpointFacadeBuilder();

            builder.WithSetBreakpointByMask();
            var bp = BreakpointMask.Parse("kernel32!*");

            bp.SetBreakpoint(builder.Mock.Object);
            builder.Mock.Verify(facade => facade.SetBreakpointByMask("kernel32", "*"), Times.Once);
        }
Exemplo n.º 2
0
        public void Parse_Correctly()
        {
            Action a = () => BreakpointMask.Parse(null);

            a.Should().Throw <ArgumentException>();

            a = () => BreakpointMask.Parse("gibberish");
            a.Should().Throw <FormatException>();

            var bp = BreakpointMask.Parse("kernel32!*");

            bp.ModuleMask.Should().Be("kernel32");
            bp.FunctionMask.Should().Be("*");
        }
Exemplo n.º 3
0
        public void Exhibit_Value_Equality()
        {
            var b1 = new BreakpointMask("mod", "fun");
            var b2 = new BreakpointMask("mod", "fun");

            b1.Equals(null).Should().BeFalse();
            b1.Equals((object)null).Should().BeFalse();
            b1.Equals(b1).Should().BeTrue();
            b1.Equals(b2).Should().BeTrue();
            b1.Equals((object)b1).Should().BeTrue();
            b1.Equals((object)b2).Should().BeTrue();
            b1.Equals(new object()).Should().BeFalse();
            b1.Should().Be(b1);
            b1.Should().Be(b2);
            b1.GetHashCode().Should().Be(b2.GetHashCode());
        }
Exemplo n.º 4
0
        public void Set_Breakpoints_If_They_Are_Provided_In_The_Options()
        {
            // arrange
            var indexMethod  = new IndexMethod();
            var indexOptions = new IndexOptions
            {
                AccessBreakpoints = new[]
                {
                    AccessBreakpoint.Parse("r8:100"),
                    AccessBreakpoint.Parse("w8:200"),
                    AccessBreakpoint.Parse("rw4:300")
                },
                BreakpointMasks = new[]
                {
                    BreakpointMask.Parse("kernel32!createprocess*"),
                    BreakpointMask.Parse("user32!*"),
                    BreakpointMask.Parse("mycustommod!myfancyfunction")
                }
            };
            var builder = new BreakpointFacadeBuilder();

            indexMethod.BreakpointFacade = builder.Build();

            // act
            indexMethod.SetBreakpoints(indexOptions);

            // assert
            builder.Mock.Verify(proxy => proxy.SetBreakpointByMask("kernel32", "createprocess*"), Times.Once);
            builder.Mock.Verify(proxy => proxy.SetBreakpointByMask("user32", "*"), Times.Once);
            builder.Mock.Verify(proxy => proxy.SetBreakpointByMask("mycustommod", "myfancyfunction"), Times.Once);

            builder.Mock.Verify(proxy => proxy.SetReadAccessBreakpoint(0x8, 0x100), Times.Once);
            builder.Mock.Verify(proxy => proxy.SetReadAccessBreakpoint(0x4, 0x300), Times.Once);
            builder.Mock.Verify(proxy => proxy.SetWriteAccessBreakpoint(0x8, 0x200), Times.Once);
            builder.Mock.Verify(proxy => proxy.SetWriteAccessBreakpoint(0x4, 0x300), Times.Once);
        }