jeudi 1 février 2018

How to write data at a specific memory location? C++

Following is the code I used to write unsigned data at 0x10000000. The program has been compiled but run failed.

void load_program(unsigned base_address){
    char* IM=reinterpret_cast <char*>(base_address);
    unsigned a=0;
    *IM=a;
}
int main(int argc, char** argv) {
    unsigned address=0x10000000;    
    load_program(address);
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire