Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions AllocaFixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <hexrays.hpp>
#include "HexRaysUtil.hpp"
#include <frame.hpp>
#include "Config.hpp"

// Finds calls to alloca in a function's decompilation microcode, and
// records the integer parameter from each call site.
Expand Down Expand Up @@ -46,7 +45,7 @@ struct AllocaFixer : minsn_visitor_t
#elif IDA_SDK_VERSION >= 720
mcallinfo_t *func = curins->d.f;
#endif
if (func == NULL)
if (func == nullptr)
{
msg("[E] %a: curins->d.f was NULL?", curins->ea);
return 0;
Expand Down Expand Up @@ -102,7 +101,7 @@ void FixCallsToAllocaProbe()
continue;

func_t *f = get_func(xr.from);
if (f == NULL)
if (f == nullptr)
{
msg("[E] Call to alloca from %a is not within a function; will not be processed\n", xr.from);
continue;
Expand All @@ -120,7 +119,7 @@ void FixCallsToAllocaProbe()
mba_ranges_t mbr(f);
hexrays_failure_t hf;
mbl_array_t *mba = gen_microcode(mbr, &hf);
if (mba == NULL)
if (mba == nullptr)
{
msg("[E] FixCallsToAllocaProbe(%a): decompilation failed (%s)\n", f->start_ea, hf.desc().c_str());
continue;
Expand Down
12 changes: 6 additions & 6 deletions CFFlattenInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bool JZInfo::ShouldBlacklist()
// thing being compared, we use a JZInfo structure to collect the number of
// times it's been used in a comparison, and a list of the values it was
// compared against.
struct JZCollector : public minsn_visitor_t
struct JZCollector : minsn_visitor_t
{
std::vector<JZInfo> m_SeenComparisons;
int m_nMaxJz;
Expand Down Expand Up @@ -155,7 +155,7 @@ mblock_t *GetFirstBlock(mbl_array_t *mba, int &iFirst, int &iDispatch)
#if UNFLATTENVERBOSE
debugmsg("[E] Block %d had %d (!= 1) successors\n", iCurr, mb->nsucc());
#endif
return NULL;
return nullptr;
}

// Get the successor block
Expand All @@ -178,7 +178,7 @@ mblock_t *GetFirstBlock(mbl_array_t *mba, int &iFirst, int &iDispatch)
// This class is used to find all variables that have 32-bit numeric values
// assigned to them in the first block (as well as the values that are
// assigned to them).
struct BlockInsnAssignNumberExtractor : public minsn_visitor_t
struct BlockInsnAssignNumberExtractor : minsn_visitor_t
{
std::vector<std::pair<mop_t *, uint64> > m_SeenAssignments;
int visit_minsn()
Expand All @@ -199,7 +199,7 @@ struct BlockInsnAssignNumberExtractor : public minsn_visitor_t
// block. This class is used to locate the "update" variable, by simply looking
// for a variable whose contents are copied into the "comparison" variable,
// which must have had a number assigned to it in the first block.
struct HandoffVarFinder : public minsn_visitor_t
struct HandoffVarFinder : minsn_visitor_t
{
// We're looking for assignments to this variable
mop_t *m_ComparisonVar;
Expand Down Expand Up @@ -253,7 +253,7 @@ struct HandoffVarFinder : public minsn_visitor_t
// Once we know which variable is the one used for comparisons, look for all
// jz instructions that compare a number against this variable. This then tells
// us which number corresponds to which basic block.
struct JZMapper : public minsn_visitor_t
struct JZMapper : minsn_visitor_t
{
std::map<uint64, int> &m_KeyToBlock;
std::map<int, uint64> &m_BlockToKey;
Expand Down Expand Up @@ -438,7 +438,7 @@ bool CFFlattenInfo::GetAssignedAndComparisonVariables(mblock_t *blk)
// Find the "first" block in the function, the one immediately before the
// control flow switch.
mblock_t *first = GetFirstBlock(mba, this->iFirst, this->iDispatch);
if (first == NULL)
if (first == nullptr)
{
#if UNFLATTENVERBOSE
debugmsg("[E] Can't find top-level block in function\n");
Expand Down
18 changes: 9 additions & 9 deletions CFFlattenInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

struct JZInfo
{
JZInfo() : op(NULL) {};
JZInfo() : op(nullptr) {};

mop_t *op;
int nSeen;
Expand All @@ -26,25 +26,25 @@ struct CFFlattenInfo
int FindBlockByKey(uint64 key);
void Clear(bool bFree)
{
if (bFree && opAssigned != NULL)
if (bFree && opAssigned != nullptr)
delete opAssigned;
opAssigned = NULL;
opAssigned = nullptr;

if (bFree && opCompared != NULL)
if (bFree && opCompared != nullptr)
delete opCompared;
opCompared = NULL;
opCompared = nullptr;

iFirst = -1;
iDispatch = -1;
uFirst = 0LL;
m_WhichFunc = BADADDR;
if (bFree && m_DomInfo != NULL)
if (bFree && m_DomInfo != nullptr)
delete m_DomInfo;
m_DomInfo = NULL;
m_DomInfo = nullptr;

if (bFree && m_DominatedClusters != NULL)
if (bFree && m_DominatedClusters != nullptr)
delete m_DominatedClusters;
m_DominatedClusters = NULL;
m_DominatedClusters = nullptr;

m_KeyToBlock.clear();
m_BlockToKey.clear();
Expand Down
32 changes: 16 additions & 16 deletions DefUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,27 @@ bool InsertOp(mblock_t *mb, mlist_t &ml, mop_t *op)
minsn_t *my_find_def_backwards(mblock_t *mb, mlist_t &ml, minsn_t *start)
{
minsn_t *mend = mb->head;
for (minsn_t *p = start != NULL ? start : mb->tail; p != NULL; p = p->prev)
for (minsn_t *p = start != nullptr ? start : mb->tail; p != nullptr; p = p->prev)
{
mlist_t def = mb->build_def_list(*p, MAY_ACCESS | FULL_XDSU);
if (def.includes(ml))
return p;
}
return NULL;
return nullptr;
}

// This is a nearly identical version of the function above, except it works
// in the forward direction rather than backwards.
minsn_t *my_find_def_forwards(mblock_t *mb, mlist_t &ml, minsn_t *start)
{
minsn_t *mend = mb->head;
for (minsn_t *p = start != NULL ? start : mb->head; p != NULL; p = p->next)
for (minsn_t *p = start != nullptr ? start : mb->head; p != nullptr; p = p->next)
{
mlist_t def = mb->build_def_list(*p, MAY_ACCESS | FULL_XDSU);
if (def.includes(ml))
return p;
}
return NULL;
return nullptr;

}

Expand Down Expand Up @@ -93,15 +93,15 @@ bool FindNumericDefBackwards(mblock_t *blk, mop_t *op, mop_t *&opNum, MovChain &

// Start from the end of the block. This variable gets updated when a copy
// is encountered, so that subsequent searches start from the right place.
minsn_t *mStart = NULL;
minsn_t *mStart = nullptr;
do
{
// Told you this function was just a wrapper around
// my_find_def_backwards.
minsn_t *mDef = my_find_def_backwards(blk, ml, mStart);

// If we did find a definition...
if (mDef != NULL)
if (mDef != nullptr)
{
// Ensure that it's a mov instruction. We don't want, for example,
// an "stx" instruction, which is assumed to redefine everything
Expand Down Expand Up @@ -174,7 +174,7 @@ bool FindNumericDefBackwards(mblock_t *blk, mop_t *op, mop_t *&opNum, MovChain &
return false;

// Resume the search at the end of the new block.
mStart = NULL;
mStart = nullptr;
}
} while (true);
return false;
Expand All @@ -186,11 +186,11 @@ mop_t *FindForwardNumericDef(mblock_t *blk, mop_t *mop, minsn_t *&assign_insn)
{
mlist_t ml;
if (!InsertOp(blk, ml, mop))
return NULL;
return nullptr;

// Find a forward definition
assign_insn = my_find_def_forwards(blk, ml, NULL);
if (assign_insn != NULL)
assign_insn = my_find_def_forwards(blk, ml, nullptr);
if (assign_insn != nullptr)
{

#if UNFLATTENVERBOSE
Expand All @@ -202,28 +202,28 @@ mop_t *FindForwardNumericDef(mblock_t *blk, mop_t *mop, minsn_t *&assign_insn)

// We only want MOV instructions with numeric left-hand sides
if (assign_insn->opcode != m_mov || assign_insn->l.t != mop_n)
return NULL;
return nullptr;

// Return the numeric operand if we found it
return &assign_insn->l;
}
return NULL;
return nullptr;
}

// This function is just a thin wrapper around FindForwardNumericDef, which
// also inserts the mov into the "chain" argument.
mop_t *FindForwardStackVarDef(mblock_t *mbClusterHead, mop_t *opCopy, MovChain &chain)
{
// Must be a non-NULL stack variable
if (opCopy == NULL || opCopy->t != mop_S)
return NULL;
if (opCopy == nullptr || opCopy->t != mop_S)
return nullptr;

minsn_t *ins;

// Find the definition
mop_t *num = FindForwardNumericDef(mbClusterHead, opCopy, ins);
if (num == NULL)
return NULL;
if (num == nullptr)
return nullptr;

#if UNFLATTENVERBOSE
qstring qs;
Expand Down
Loading