Tags » Disassemble

How To Be Compled Class #3 Virtual & Not Virtual

How to be compiled class at the point of virtual?

Example Code

class funny {
public:          virtual int hello(void);
public:          int world(void);
public:          funny(void);
public:          virtual ~funny(void);
};

int main(void)
{
    funny f;
    f.hello();
    f.world();
    return 0;
}

funny::funny(void)
{
}

funny::~funny(void)
{

}

int funny::hello(void)
{
    printf("hello\n");
    return 0;
}

int funny::world(void)
{
    printf("hello\n");
    return 0;
}
…
623 more words

Disassemble

How To Be Compiled Class #2 Virtual Method

I will check how to be compiled class at the point of virtual method.

Example Code

class base
{
public:     virtual void print(void);
public:     base(void);
public:     virtual ~base(void);
};

class funny : public base
{
public:     virtual void print(void);
public:     funny(void);
public:     virtual ~funny(void);
};

int main(void)
{
    base * b = new base();
    b->print();
    delete b;
    funny * f = new funny();
    f->print();
    f->base::print();
    delete f;
    return 0;
}

base::base(void){}
base::~base(void){}

void base::print(void)
{
    std::cout<<"base"<<std::endl;
}

funny::funny(void){}
funny::~funny(void){}

void funny::print(void)
{
    std::cout<<"funny"<<std::endl;
}
…
732 more words

Disassemble

Basic Program Execution Register

Basic Program Execution Register

The eight general purpose registers, the six segment registers, the EFLAGS register, and the EIP (instruction pointer) register comprise a basic execution environment in which to execute a set of general purpose instructions. 34 more words

Disassemble

How To Be Compiled Class? #1

Assumption

  • g++ -std=c++0x -o example.20161117 example.20161117.cc
  • gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)

Example Code

#include 
#include 

class funny
{
private:    long __value;
private:    std::string __str;
public:     inline long value(void) const { return __value; }
public:     inline std::string & str(void){ return __str; }
public:     void str(const std::string & s);
public:     void value(long v);
public:     funny(void);
public:     funny(long v,const std::string & s);
public:     virtual ~funny(void);
};


int main(void)
{
    funny f(10,"hello world!");
    for(long i = 0;i<f.value();i++)
    {
        std::cout<<f.str()<<std::endl;
    }
    return 0;
}

funny::funny(void)
{

}

funny::funny(long v,const std::string & s)
{
    __value = v;
    __str = s;
}

funny::~funny(void)
{

}

void funny::str(const std::string & s){ __str = s; }

void funny::value(long v){ __value = v; }
…
878 more words

Disassemble

How To Be Compiled Lambda?

How to be compiled Lambda, just my funny!

Example Code To Lambda

int main(void)
{
     auto f = [](int x)->int{ return x * 10; };
     std::cout<<"lambda f return: "<<f(10)<<std::endl;
     return 0;
}
…
587 more words

Disassemble

Is custom strlen function is good?

Is to implement custom string length function is good?

Example Code

Example Code Using ::Strlen

int main(int argc,char ** argv)
{
     std::string content;
     std::string line;
     std::ifstream f("rfc793.txt");
     while(std::getline(f,line)){ content+=line; }
     f.close();
     for(int i=0;i<atoi(argv[1]);i++){ content+=content; }
     struct timespec start;
     struct timespec end;
     clock_gettime(CLOCK_REALTIME,&start);
     printf("string length is: %ld\n",::strlen(content.c_str()));
     clock_gettime(CLOCK_REALTIME,&end);
     long sec = end.tv_sec - start.tv_sec;
     long nano = end.tv_nsec - start.tv_nsec;
     if(nano<0)
     {
         sec--;
         nano+=1000000000;
     }
     printf("%ld.%09ld\n",sec,nano);
     return 0;
}
…
476 more words

Disassemble

Disassemble #2

Took out the Hard Drive, the facial, the DVD player, and some data cables.

Technology