Beispiel #1
0
        public void Set_Breakpoints_Correctly()
        {
            var options = new IndexOptions()
            {
                BreakpointMasks = new []
                {
                    new BreakpointMask("kernel32", "*create*"),
                    new BreakpointMask("kernel32", "*process*"),
                },
                AccessBreakpoints = new []
                {
                    new AccessBreakpoint(0x100, 8, true, false),
                }
            };
            var indexMethod = new IndexMethod();
            BreakpointFacadeBuilder breakpointFacadeBuilder = new BreakpointFacadeBuilder();

            indexMethod.BreakpointFacade = breakpointFacadeBuilder
                                           .WithSetBreakpointByMask()
                                           .WithSetReadAccessBreakpoint()
                                           .Build();
            indexMethod.SetBreakpoints(options);
            breakpointFacadeBuilder.Mock.Verify(facade => facade.SetBreakpointByMask(It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(2));
            breakpointFacadeBuilder.Mock.Verify(facade => facade.SetReadAccessBreakpoint(It.IsAny <int>(), It.IsAny <ulong>()), Times.Once);
        }
        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);
        }