-
Notifications
You must be signed in to change notification settings - Fork 12
/
IDAMemCopyPaste.cpp
95 lines (79 loc) · 2.43 KB
/
IDAMemCopyPaste.cpp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// IDAMemCopyPaste.cpp: implementation of the IDAMemCopyPaste class.
//
//////////////////////////////////////////////////////////////////////
//Standard Defs
typedef int BOOL;
#define FALSE 0
#define TRUE 1
#define NULL 0
#include <pro.h>
#include <kernwin.hpp>
#include <bytes.hpp>
//#include <funcs.hpp>
//#include <lines.hpp>
//#include <name.hpp>
//#include <ida.hpp>
//#include <idp.hpp>
//#include <loader.hpp>
#include "IDAMemCopyPaste.h"//
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//,Construction/Destruction
//////////////////////////////////////////////////////////////////////
IDAMemCopyPaste::IDAMemCopyPaste()
{
}
IDAMemCopyPaste::~IDAMemCopyPaste()
{
}
//////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////
#define MAX_COPYPASTE 1024
// This will hold our copied buffer for pasting
char data[MAX_COPYPASTE];
void IDAMemCopyPaste::copy_buffer(ea_t eaStartAddr, ea_t eaEndAddr)
{
ssize_t size;
// Work out the size, make sure it doesn't exceed the buffer
// we have allocated.
size = eaEndAddr - eaStartAddr;
if (size > MAX_COPYPASTE)
{
warning("You can only copy a max of %d bytes\n", MAX_COPYPASTE);
return;
}
// Get the bytes from the file, store it in our buffer
if (get_many_bytes(eaStartAddr, data, size))
{
msg("Successfully copied %d bytes from %a into memory.\n", size, eaStartAddr);
}
else
{
msg("FAILED to copy %d bytes from %a into memory.\n", size, eaStartAddr);
}
}
void IDAMemCopyPaste::paste_buffer(ea_t eaStartAddr, ea_t eaEndAddr)
{
ssize_t size;
// Work out the size, make sure it doesn't exceed the buffer
// we have allocated.
size = eaEndAddr - eaStartAddr;
if (size > MAX_COPYPASTE)
{
warning("You can only copy a max of %d bytes\n", MAX_COPYPASTE);
return;
}
// Patch the binary (paste)
patch_many_bytes(eaStartAddr, data, size);
msg("Patched %d bytes at %a.\n", size, eaStartAddr);
}
//////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////
//Looks for specific binary patterns and then makes a subroutine and comments it
void IDAMemCopyPaste::FindFuncSigsAndComment(void)
{
}