Exemplo n.º 1
0
        public void Ose_FindReplace()
        {
            Given_Engine();
            Given_Image(0x001000, new byte[] { 0x2a, 0x2a, 0x2a, 0x21, 0x23, 0x21, 0x23 });
            host.Setup(h => h.WriteMemory(
                           It.IsAny <Address>(),
                           3,
                           It.IsNotNull <byte[]>()))
            .Returns((Address a, int l, byte[] b) =>
            {
                var offset = a - mem.BaseAddress;
                MemoryArea.WriteBytes(b, offset, l, mem.Bytes);
                return(true);
            });

            Given_Script(
                "find 001000, #21??21#\r\n" +
                "test $RESULT,$RESULT\r\n" +
                "jz done\r\n" +
                "fill $RESULT,3,2d\r\n" +
                "done:\r\n"
                );

            engine.Run();

            Assert.AreEqual("***---#", Encoding.ASCII.GetString(mem.Bytes));
        }
Exemplo n.º 2
0
        public void Ose_FindReplace()
        {
            Given_Engine();
            Given_Image(0x001000, new byte[] { 0x2a, 0x2a, 0x2a, 0x21, 0x23, 0x21, 0x23 });
            host.Expect(h => h.WriteMemory(
                            Arg <ulong> .Is.Anything,
                            Arg <int> .Is.Equal(3),
                            Arg <byte[]> .Is.NotNull)).Do(new Func <ulong, int, byte[], bool>((a, l, b) =>
            {
                MemoryArea.WriteBytes(b, (long)a - (long)mem.BaseAddress.ToLinear(), l, mem.Bytes);
                return(true);
            }));

            Given_Script(
                "find 001000, #21??21#\r\n" +
                "test $RESULT,$RESULT\r\n" +
                "jz done\r\n" +
                "fill $RESULT,3,2d\r\n" +
                "done:\r\n"
                );
            mr.ReplayAll();

            engine.Run();

            Assert.AreEqual("***---#", Encoding.ASCII.GetString(mem.Bytes));
        }