CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/external/source/exploits/CVE-2017-13861/liboffsetfinder64/patch.cpp
Views: 11784
1
//
2
// patch.cpp
3
// liboffsetfinder64
4
//
5
// Created by tihmstar on 09.03.18.
6
// Copyright © 2018 tihmstar. All rights reserved.
7
//
8
9
#include "patch.hpp"
10
11
using namespace tihmstar::patchfinder64;
12
13
patch::patch(loc_t location, const void *patch, size_t patchSize, void(*slidefunc)(class patch *patch, uint64_t slide)) : _location(location), _patchSize(patchSize), _slidefunc(slidefunc){
14
_patch = malloc(_patchSize);
15
memcpy((void*)_patch, patch, _patchSize);
16
_slideme = (_slidefunc) ? true : false;
17
}
18
19
patch::patch(const patch& cpy) : _location(cpy._location), _patchSize(cpy._patchSize){
20
_patch = malloc(_patchSize);
21
memcpy((void*)_patch, cpy._patch, _patchSize);
22
_slidefunc = cpy._slidefunc;
23
_slideme = cpy._slideme;
24
}
25
26
void patch::slide(uint64_t slide){
27
if (!_slideme)
28
return;
29
printf("sliding with %p\n",(void*)slide);
30
_slidefunc(this,slide);
31
_slideme = false; //only slide once
32
}
33
34
patch::~patch(){
35
free((void*)_patch);
36
}
37
38