-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMallocContract.cs
30 lines (24 loc) · 932 Bytes
/
MallocContract.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// This file is part of bugreport.
// Copyright (c) 2006-2009 The bugreport Developers.
// See AUTHORS.txt for details.
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
using System;
namespace bugreport
{
internal sealed class MallocContract : Contract
{
public override Boolean IsSatisfiedBy(MachineState state, Byte[] code)
{
var effectiveAddress = Opcode.GetEffectiveAddress(code, state.InstructionPointer);
const UInt32 MALLOC_IMPORT_FUNCTION_ADDR = 0x80482a8;
return effectiveAddress == MALLOC_IMPORT_FUNCTION_ADDR;
}
public override MachineState Execute(MachineState state)
{
var buffer = AbstractValue.GetNewBuffer(state.TopOfStack.Value);
state.ReturnValue = new AbstractValue(buffer);
return state;
}
}
}