Skip to content

Commit

Permalink
fix includes
Browse files Browse the repository at this point in the history
  • Loading branch information
NaC-L committed Oct 23, 2024
1 parent de16d7a commit bbbf77a
Show file tree
Hide file tree
Showing 14 changed files with 400 additions and 411 deletions.
7 changes: 6 additions & 1 deletion lifter/FunctionSignatures.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#ifndef FUNCSIGNATURES_H
#define FUNCSIGNATURES_H
#include "includes.h"
#include <Zydis/Register.h>
#include <map>
#include <string>
#include <unordered_map>
#include <vector>

// 8 << (arg.argtype.size - 1)
enum ArgType { NONE = 0, I8 = 1, I16 = 2, I32 = 3, I64 = 4 };

namespace funcsignatures {

struct funcArgInfo {
Expand Down
10 changes: 9 additions & 1 deletion lifter/GEPTracker.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
#include "GEPTracker.h"
#include "OperandUtils.h"
#include "includes.h"
#include "lifterClass.h"
#include "nt/nt_headers.hpp"
#include "utils.h"
#include <iostream>
#include <llvm/ADT/DenseSet.h>
#include <llvm/Analysis/AliasAnalysis.h>
#include <llvm/Analysis/AssumptionCache.h>
#include <llvm/Analysis/BasicAliasAnalysis.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
#include <llvm/Analysis/ValueTracking.h>
#include <llvm/Analysis/WithCache.h>
#include <llvm/IR/ConstantRange.h>
#include <llvm/IR/InstrTypes.h>
#include <llvm/IR/Instructions.h>
#include <llvm/Support/ErrorHandling.h>
#include <llvm/Support/KnownBits.h>
#include <llvm/TargetParser/Triple.h>
#include <llvm/Transforms/Utils/SCCPSolver.h>

namespace BinaryOperations {

Expand Down
30 changes: 18 additions & 12 deletions lifter/GEPTracker.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
#ifndef GEPTracker_H
#define GEPTracker_H

#include "includes.h"
#include <Zycore/Types.h>
#include <llvm/ADT/APInt.h>
#include <llvm/IR/Value.h>

enum Assumption { Real, Assumed }; // add None

enum isPaged { MEMORY_PAGED, MEMORY_MIGHT_BE_PAGED, MEMORY_NOT_PAGED };

struct APIntComparator {
bool operator()(const APInt& lhs, const APInt& rhs) const {
bool operator()(const llvm::APInt& lhs, const llvm::APInt& rhs) const {
return lhs.ult(rhs); // unsigned less-than comparison
}
};

class ValueByteReference {
public:
Instruction* storeInst;
Value* value;
unsigned short byteOffset;
ValueByteReference() : storeInst(nullptr), value(nullptr), byteOffset(0) {}

ValueByteReference(Instruction* inst, Value* val, short offset)
: storeInst(inst), value(val), byteOffset(offset) {}
// Instruction* storeInst;
llvm::Value* value;
uint8_t byteOffset;
// ValueByteReference() : storeInst(nullptr), value(nullptr), byteOffset(0) {}
ValueByteReference() : value(nullptr), byteOffset(0) {}

/*
ValueByteReference(Instruction* inst, Value* val, short offset)
: storeInst(inst), value(val), byteOffset(offset) {}
*/

ValueByteReference(llvm::Value* val, short offset)
: value(val), byteOffset(offset) {}
};

class ValueByteReferenceRange {
Expand All @@ -31,8 +39,6 @@ class ValueByteReferenceRange {
uint64_t memoryAddress;
};

// size info, we can make this smaller because they can only be 0-8 range
// (maybe higher for avx)
uint8_t start;
uint8_t end;

Expand All @@ -55,7 +61,7 @@ namespace BinaryOperations {

bool isImport(const uint64_t addr);

bool readMemory(const uint64_t addr, unsigned byteSize, APInt& value);
bool readMemory(const uint64_t addr, unsigned byteSize, llvm::APInt& value);

bool isWrittenTo(const uint64_t addr);

Expand Down
10 changes: 9 additions & 1 deletion lifter/OperandUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
#include "OperandUtils.h"
#include "includes.h"
#include "lifterClass.h"
#include "utils.h"
#include <Zydis/Mnemonic.h>
#include <Zydis/Register.h>
#include <Zydis/SharedTypes.h>
#include <iostream>
#include <llvm/ADT/DenseMap.h>
#include <llvm/ADT/StringRef.h>
#include <llvm/Analysis/DomConditionCache.h>
#include <llvm/Analysis/InstructionSimplify.h>
#include <llvm/Analysis/SimplifyQuery.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
#include <llvm/Analysis/ValueLattice.h>
#include <llvm/Analysis/ValueTracking.h>
#include <llvm/IR/Constants.h>
#include <llvm/IR/InstrTypes.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/PatternMatch.h>
#include <llvm/Support/KnownBits.h>
#include <llvm/TargetParser/Triple.h>
#include <optional>

#ifndef TESTFOLDER
#define TESTFOLDER
Expand Down
16 changes: 9 additions & 7 deletions lifter/OperandUtils.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#pragma once
#include "includes.h"
#include <llvm/Analysis/InstSimplifyFolder.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Value.h>

Value* simplifyValue(Value* v, const DataLayout& DL);
llvm::Value* simplifyValue(llvm::Value* v, const llvm::DataLayout& DL);

Value* getMemory();
llvm::Value* getMemory();

ReverseRegisterMap flipRegisterMap();
llvm::Value* ConvertIntToPTR(llvm::IRBuilder<llvm::InstSimplifyFolder>& builder,
llvm::Value* effectiveAddress);

Value* ConvertIntToPTR(IRBuilder<>& builder, Value* effectiveAddress);

bool comesBefore(Instruction* a, Instruction* b, DominatorTree& DT);
bool comesBefore(llvm::Instruction* a, llvm::Instruction* b,
llvm::DominatorTree& DT);
4 changes: 3 additions & 1 deletion lifter/PathSolver.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#include "CustomPasses.hpp"
#include "OperandUtils.h"
#include "includes.h"
#include "lifterClass.h"
#include "utils.h"
#include <iostream>
#include <llvm/ADT/DenseMap.h>
#include <llvm/IR/BasicBlock.h>
#include <llvm/IR/Constants.h>
#include <llvm/IR/InstrTypes.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Verifier.h>
#include <llvm/Passes/PassBuilder.h>
#include <llvm/Support/Casting.h>

// simplify Users with BFS
Expand Down
13 changes: 10 additions & 3 deletions lifter/PathSolver.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#pragma once
#include "includes.h"
#include <llvm/IR/Function.h>
#include <llvm/IR/Value.h>

void final_optpass(Function* clonedFuncx);
enum PATH_info {
PATH_unsolved = 0,
PATH_solved = 1,
};

PATH_info solvePath(Function* function, uint64_t& dest, Value* simplifyValue);
void final_optpass(llvm::Function* clonedFuncx);

PATH_info solvePath(llvm::Function* function, uint64_t& dest,
llvm::Value* simplifyValue);
6 changes: 6 additions & 0 deletions lifter/Semantics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
#include "includes.h"
#include "lifterClass.h"
#include "utils.h"
#include <Zydis/Mnemonic.h>
#include <immintrin.h>
#include <iostream>
#include <llvm/IR/Constant.h>
#include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/InlineAsm.h>
#include <llvm/IR/InstrTypes.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/PatternMatch.h>
#include <llvm/IR/Type.h>
#include <llvm/Support/Casting.h>
#include <llvm/Support/ErrorHandling.h>
Expand Down
7 changes: 1 addition & 6 deletions lifter/Semantics.h
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
#pragma once
#include "includes.h"

void liftInstruction(IRBuilder<>& builder,
ZydisDisassembledInstruction& instruction,
shared_ptr<vector<BBInfo>> blockAddresses, bool& run);
#pragma once
Loading

0 comments on commit bbbf77a

Please sign in to comment.