memory-address

Get address of base object from derived object

别等时光非礼了梦想. 提交于 2019-12-04 19:38:23
I'm getting a very confusing error in my program. I think I may have two different objects of the same class where I thought I had the same object. It is confusing because I am dealing with a very large framework where it is not simple to obtain a pointer to the object I need. My question is, if I have a class Derived which in inherits from Base, and I have a pointer to a Derived object, how can I get the address of the Base object from the derived object? I am working with the source code of the Base Class and am printing out the address of "this" in Base. In another part of my code a

Can I use an std::vector as a facade for a pre-allocated (raw) array?

一曲冷凌霜 提交于 2019-12-04 18:30:34
问题 I have acquired a memory location from DirectX where my vertex information is stored. An extremely convenient way to deal with vertex information is to use a std::vector<> of a struct containing vertex info. Given that I have a pointer to a large buffer, could I use a std::vector to manage the elements in the buffer? Constructing a std::vector regularly causes it to have its own address, which isn't really what I want. Could I use operator placement new somehow? 回答1: Yes you can. Use custom

Is there is a way to get the address of a register?

冷暖自知 提交于 2019-12-04 12:26:10
问题 Is there is a way to get the address of a register? For example, the address of the eax register (not it's content). 回答1: There has been architectures where low addresses were used to designate CPU registers, like the Univac 1100 series of computers. http://en.wikipedia.org/wiki/UNIVAC_1100/2200_series Current x86 hardware doesn't work that way, so you cannot get the address of the EAX register - it just doesn't have one. 回答2: Registers are the internal processor storage. They do not have

C++ , Cheat Engine / OllyDBG finding base “static” address from multi-level pointers

萝らか妹 提交于 2019-12-04 12:07:21
问题 I'm back again, frustrated and desperately searching for help :D. I am trying to create a cheat for a simple program, it's basically going to be a .dll file which will change an integer's value from the main program when it's injected to it using its base address. The thing is, I can't find it using cheat engine mainly because there are multiple level pointers with NEGATIVE? offsets. for example: //Starting pointer address 0x0033FCF0 -> 200 //Finding second level pointer using "Find out what

What happens to address's, values, and pointers after a fork()

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 07:34:32
I'm working on a question where I am to examine values and address before and after a fork() call in C. My approach was to display the variables values and address assuming to see a difference in the address after the fork() . Much to my surprise address's for said variables remained the same. My questions is why are they the same? What happens if I change a variable in the child? Will it change in both parent and child? If not, how am I able to change the value in that address while the address is the same for both parent and child. code(for reference): #include <stdio.h> #include <stdlib.h>

Can I access random data with random memory Addresses outside of my C++ Program

假如想象 提交于 2019-12-04 04:41:44
问题 If 2 programs are running, and one program stores a number at a memory address, and if I know that memory address, and hard code it into the 2nd program and print out the value at the address, would it actually get that info? Does C++ allow programs to access any data stored in RAM no matter if it is part of the program or not? 回答1: On system with no virtual memory management and no address space protection this would work. It would be undefined behavior from the point of view of the C

The address of character type variable

感情迁移 提交于 2019-12-04 04:11:41
问题 Here is just a test prototype : #include <iostream> #include <string> using namespace std; int main() { int a=10; char b='H'; string c="Hamza"; cout<<"The value of a is : "<<a<<endl; cout<<"The value of b is : "<<b<<endl; cout<<"The value of c is : "<<c<<endl<<endl; cout<<"address of a : "<<&a<<endl; cout<<"address of b : "<<&b<<endl; cout<<"address of c : "<<&c<<endl; return 0; } Why the address of variable 'b', which is of character type, not printing? 回答1: The << operator in your code is

Is the address of a reference to a dereferenced pointer the same as the address of the pointer?

冷暖自知 提交于 2019-12-04 01:27:48
In C++, is the address of a reference to a dereferenced pointer guaranteed to be the same as the address of the pointer? Or, written in code, is the following assertion guaranteed to always hold true? SomeType *ptr = someAddress; SomeType &ref = *ptr; assert(&ref == ptr); Yes, that is correct and will always be true. Reference is nothing but an Alias of the type which it is referring to. It does not have a separate existence, it is always tied up to the one it is referring. Yes, provided of course that someAddress is not a null pointer, or otherwise not allowed to be dereferenced. In that case

Why C++ would not print the memory address of a char but will print int or bool? [duplicate]

人盡茶涼 提交于 2019-12-04 00:38:43
Possible Duplicate: Why is address of char data not displayed? Here is the code and the output: int main(int argc, char** argv) { bool a; bool b; cout<<"Address of a:"<<&a<<endl; cout<<"Address of b:"<<&b<<endl; int c; int d; cout<<"Address of c:"<<&c<<endl; cout<<"Address of d:"<<&d<<endl; char e; cout<<"Address of e:"<<&e<<endl; return 0; } The output: Address of a:0x28ac67 Address of b:0x28ac66 Address of c:0x28ac60 Address of d:0x28ac5c Address of e: My question is: Where is the memory address of the char? And why is it not printed? Thank you. I suspect that the overloaded-to- char *

Address of each character of std::string

穿精又带淫゛_ 提交于 2019-12-03 14:35:22
I tried to print the address of each character of std::string . But I amn't understanding what is happening internally with std::string that is resulting this output while for the array it is giving the address as I expected. Could someone please explain what is going on? #include <iostream> #include <string> using namespace std; int main(){ string str = "Hello"; int a[] = {1,2,3,4,5}; for( int i=0; i<str.length(); ++i ) cout << &str[i] << endl; cout << "**************" << endl; for( int i=0; i<5; ++i ) cout << &a[i] << endl; return 0; } Output: Hello ello llo lo o **************