memory-address

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

冷暖自知 提交于 2019-12-02 22:32:51
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-mode and kernel-mode call. For example, a call to NtWriteFile will need an address for the kernel

Can we check a pointer to make sure it is a valid address?

℡╲_俬逩灬. 提交于 2019-12-02 21:41:35
问题 My idea is to print the object it points to. I think a valid pointer should have a valid object. If we try to print out the object we verify if the pointer is valid. Am I right? 回答1: I think a valid pointer should have a valid object. Yes, that's the definition of a valid pointer. If we try to print out the object we verify if the pointer is valid. Unfortunately, you can't. You can check whether the pointer is null; but if it wasn't initialised properly, or if it pointed to an object that's

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

两盒软妹~` 提交于 2019-12-02 21:03:45
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 I use add-symbol-file command in gdb (gdb) add-symbol-file a.out.debug [Enter] The address where a.out

In C++, I'm getting a message “error: 'void*' is not a pointer-to-object type”

余生长醉 提交于 2019-12-02 20:17:19
问题 Here's my code: #include <iostream> using namespace std; int main() { void *x; int arr[10]; x = arr; *x = 23; //This is where I get the error } As you can see, the code is very simple. It just creates a void pointer x which points to the memory address of the array 'arr' and puts the integer 23 into that memory address. But when I compile it, I get the error message "'void*' is not a pointer-to-object type". When I use an 'int' pointer instead of a void pointer and then compile it, I don't

How can a non-assigned string in Python have an address in memory?

廉价感情. 提交于 2019-12-02 17:52:06
Can someone explain this to me? So I've been playing with the id() command in python and came across this: >>> id('cat') 5181152 >>> a = 'cat' >>> b = 'cat' >>> id(a) 5181152 >>> id(b) 5181152 This makes some sense to me except for one part: The string 'cat' has an address in memory before I assign it to a variable. I probably just don't understand how memory addressing works but can someone explain this to me or at least tell me that I should read up on memory addressing? So that is all well and good but this confused me further: >>> a = a[0:2]+'t' >>> a 'cat' >>> id(a) 39964224 >>> id('cat')

Understanding virtual address and virtual address space

倖福魔咒の 提交于 2019-12-02 16:52:27
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 ? Programs and data are stored as numbers in memory cells. Each memory cell has a unique number, called its address . The range of numbers representing valid

C++ pointer address issue

大城市里の小女人 提交于 2019-12-02 15:13:56
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? &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 pointed to, which at the moment is uninitialized, but this is where your actual data will go. 来源: https:/

Print the address or pointer for value in C

我与影子孤独终老i 提交于 2019-12-02 15:01:16
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 void* item1 */ const Emp* emp1 = (const Emp*) item1; printf("\n comp1-> emp1 = %p; item1 = %p \n",

Can we check a pointer to make sure it is a valid address?

浪子不回头ぞ 提交于 2019-12-02 10:23:20
My idea is to print the object it points to. I think a valid pointer should have a valid object. If we try to print out the object we verify if the pointer is valid. Am I right? I think a valid pointer should have a valid object. Yes, that's the definition of a valid pointer. If we try to print out the object we verify if the pointer is valid. Unfortunately, you can't. You can check whether the pointer is null; but if it wasn't initialised properly, or if it pointed to an object that's been destroyed, it will be neither valid nor null. If you want a pointer that's smart enough to know whether

In C++, I'm getting a message “error: 'void*' is not a pointer-to-object type”

天涯浪子 提交于 2019-12-02 08:13:42
Here's my code: #include <iostream> using namespace std; int main() { void *x; int arr[10]; x = arr; *x = 23; //This is where I get the error } As you can see, the code is very simple. It just creates a void pointer x which points to the memory address of the array 'arr' and puts the integer 23 into that memory address. But when I compile it, I get the error message "'void*' is not a pointer-to-object type". When I use an 'int' pointer instead of a void pointer and then compile it, I don't get any errors or warnings. I wanna know why I get this error. Thank you. As the compiler message says,