Vaka znaci.
Vo memorija postoi adresa na primer 0x00123456 i na taa adresa ima funkcija printf. E sega jas sakam od moj program vo C++ da ja povikam ovaa funkcija no ne kako printf tuku preku nejzinata memoriska adresa.
Doznav deka za ova se koristi komandata
reinterpret_cast
deklaracijata na printf funkcijata e
int printf(const char *, ...);
Znaci moeto prasanje e kako ovaa deklaracija na printf da ja povrzam preku reinterpret_cast so memoriskata adresa 0x00123456 taka sto ponatamu vo programot kje si ja koristam kako normalna funkcija printf.
Aj ve molam za pomos zosto nikako ne moze da mi vleze ova vo glava.
Fala
Pomos okolu C++
Moderators: pedja089, stojke369, [eDo], trax, LAF
Ok sorry I'll translte.
I am trying to define and call a function based on its location in memory. For example, if I have a function printf and I have the location of this function in memory, say its address is 0x00123456, what is the most proper way to define and call this function (along with the arguments)?
How can I call the function by using only is memory address, without it being defined in my code.
A real world example: If an external program had a function that I want called, and I have its address, I need to know how to cast a function like this.
I heard I should use reinterpret_cast but I dont know how to connect the printf with 0x00123456 adress.
With one word I want to replace printf memory adress 0x00123456 with int printf(const char *, ...); so I can use this printf in my code. I don't want to use stdio. h because this function is already compiled and it is at 0x00123456
I am trying to define and call a function based on its location in memory. For example, if I have a function printf and I have the location of this function in memory, say its address is 0x00123456, what is the most proper way to define and call this function (along with the arguments)?
How can I call the function by using only is memory address, without it being defined in my code.
A real world example: If an external program had a function that I want called, and I have its address, I need to know how to cast a function like this.
I heard I should use reinterpret_cast but I dont know how to connect the printf with 0x00123456 adress.
With one word I want to replace printf memory adress 0x00123456 with int printf(const char *, ...); so I can use this printf in my code. I don't want to use stdio. h because this function is already compiled and it is at 0x00123456
program kada se prevodi iz viseg jezika kompajler ga prevede se u asemblerski oblik...kada se izvodi nema isti oblik kao u visem jeziku...funkcija npr printf(); nije definirana samo tako i daje ispis na ekran nego sadrzi niz instrukcija potrebnih za to...s toga kad se ta funkcija prevede nalazi se na vise lokacija u memoriji ne samo u jednoj...ne razumim sta zelis tocno izvesti
Cirkus Kolorado :D
- VasilyZaitsev
- Pravo uznapredovao :)
- Posts: 219
- Joined: 03-04-2007, 10:37
- Location: Sarajevo, BIH
Here is everything you'll need: http://www.newty.de/fpt/index.html
Making a function pointer is quite simple, although you must be very careful or your application will crash from time to time.
Making a function pointer is quite simple, although you must be very careful or your application will crash from time to time.