计算机天才
RetDec框架之bin2llvmir工具的使用
python .\retdec-decompiler.py <binary_path>
测试代码
#include<iostream>
#include<windows.h>
#include<intrin.h>
using namespace std;
int dummy_1 = 1;
int dummy_2 = 2;
int res = 0;
int cpuid[4];
int main()
{
res = IsDebuggerPresent();
printf("%d\n", res);
res = dummy_1 + dummy_2;
printf("%d\n", res);
res = dummy_1 - dummy_2;
printf("%d\n", res);
res = dummy_1 * dummy_2;
printf("%d\n", res);
res = dummy_1 / dummy_2;
printf("%d\n", res);
res = dummy_1 << 1…
steve lee
Ruby - DIY accessor methods
1. Ruby accessor methods
Ruby does not allow instance variables to be accessed outside of methods for that object.
class Person
def initialize(name)
@name = name
@age = 10
end
end
p = Person.new('steve')
p.name # => undefined method `name=' for #<Person ..>
This design ensures OOP encapsulation - an object’s data is protected from the outside world.
In some languages like Java, to access private instance variables, we must define getter/setter methods for each attribute. But in Ruby, we can generate getter/setter methods by using one of the methods in the Module…
计算机天才
retdec项目源代码阅读部分记录
只涉及到x86架构的部分,像arm mips powerpc架构我目前用不上。
// 获得对应长度的整数类型
llvm::IntegerType* getIntegerTypeFromByteSize(llvm::Module* module, unsigned sz)
{
sz = sz ? 8*sz : module->getDataLayout().getPointerSizeInBits();
return llvm::Type::getIntNTy(module->getContext(), sz);
}
// llvm中的CreateNot可不是x86的not指令,not指令要xor -1来模拟
llvm::Value* generateValueNegate(llvm::IRBuilder<>& irb, llvm::Value* val)
{
return irb.CreateXor(val, llvm::ConstantInt::getSigned(val->getType(), -1));
}
llvm::Value* Capstone2LlvmIrTranslatorX86_impl::loadOp(...){
case X86_OP_REG:
{
//把llvm ir中的@op…