memory-address

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

早过忘川 提交于 2019-12-03 11:58:15
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? Yousf Yes you can. Use custom allocator . In this allocator return address of your DirectX memory. Here is a complete examlpe based

Are the elements of an array guaranteed to be stored from lower to higher addresses?

六眼飞鱼酱① 提交于 2019-12-03 09:49:48
Suppose I have the following array: int list[3]={2,8,9}; printf("%p,%p,%p",(void*)&list[0],(void*)&list[1],(void*)&list[2]); Is it always guaranteed that &list[0]<&list[1]<&list[2] ? I had assumed it to be a hard and fast rule while using C, but now have to very sure about it as an OP just asked me about it when I answered his question about endianness Little endian or Big endian What gave me second thoughts is the stacks can grow up or down issue.I am not very sure about that so your rigorous answers are appreciated.Thanks. Yes, it's guaranteed that &list[0]<&list[1] and &list[1]<&list[2] .

Why does Windows reserve 1Gb (or 2 Gb) for its system address space?

↘锁芯ラ 提交于 2019-12-03 08:40:36
问题 It's a known fact that Windows applications usually have 2Gb of private address space on a 32bit system. This space can be extended to 3Gb with the /3Gb switch. The operating system reserves itself the remaining of the 4Gb. My question is WHY? Code running in kernel mode (i.e. device driver code) has its own address space. Why, on top of a exclusive 4Gb address space, the operating system still want to reserve 2Gb of each user-mode process? I thought the reason is the transition between user

The address where filename has been loaded is missing [GDB]

怎甘沉沦 提交于 2019-12-03 08:26:33
问题 I have following sample code #include<stdio.h> int main() { int num1, num2; printf("Enter two numbers\n"); scanf("%d",&num1); scanf("%d",&num2); int i; for(i = 0; i < num2; i++) num1 = num1 + num1; printf("Result is %d \n",num1); return 0; } I compiled this code with -g option to gcc. gcc -g file.c Generate separate symbol file objcopy --only-keep-debug a.out a.out.sym Strip the symbols from a.out strip -s a.out Load this a.out in gdb gdb a.out gdb says "no debug information found" fine. Then

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

和自甴很熟 提交于 2019-12-03 08:16:28
Is there is a way to get the address of a register? For example, the address of the eax register (not it's content). 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. Registers are the internal processor storage. They do not have memory addresses, because they do not reside in memory . You identify them by their names: EAX, for example. That

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

拟墨画扇 提交于 2019-12-03 07:47:54
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's accessing this address" in Cheat Engine **(mov eax,[ebp+08])** // **EAX=0x00000007** , **EPB

Setting limit to total physical memory available in Linux

天涯浪子 提交于 2019-12-03 06:21:53
I know that I am supposed to set mem=MEMORY_LIMIT . But I do not know where to go, during runtime, or during boot time, in order to set a limit to the total physical memory that the OS has control of. I am running I/O benchmarks, and I would like to limit the amount of overall physical memory that is available. I found the answer I was looking for. Basically, the parameter that sets the total available physical memory is "mem=MEMORY_LIMIT". And this is a kernel boot parameter. You need to add, say "mem=1G" for maximum of 1GB available physical memory to the kernel boot parameter. For more info

Understanding virtual address and virtual address space

最后都变了- 提交于 2019-12-03 03:23:31
问题 I read that , "When a program executes an instruction like : MOV REG,1000 , it does so to copy the contents of the memory address 1000 to REG. Address can be generated using indexing,base registers,segment registers and other ways. These program generated address are called virtual address and form the virtual address space." Can anyone please explain me,what does it (These program generated address are called virtual address) mean ? 回答1: Programs and data are stored as numbers in memory

Print the address or pointer for value in C

自作多情 提交于 2019-12-03 03:00:55
问题 I want to do something that seems fairly simple. I get results but the problem is, I have no way to know if the results are correct. I'm working in C and I have two pointers; I want to print the contents of the pointer. I don't want to dereference the pointer to get the value pointed at, I just want the address that the pointer has stored. I wrote the following code and what I need to know is if it is right and if not, how can I correct it. /* item one is a parameter and it comes in as: const

C++ pointer address issue

雨燕双飞 提交于 2019-12-02 23:52:55
问题 int *i = new int; cout << &i << endl << i; delete i; i = 0; i get this output: 0031FB2B 0057C200 Why 2 different addresses? Isn't & referencing the address of the dynamic pointer and i itself the address of the pointer, which should be the same address? 回答1: &i is the address of the pointer. This is the place where the value returned by new will be stored. i is the value of the pointer itself, this is the value returned by new . And just for completeness, *i is the value of the integer