memory-address

What if accessing a non-existing physical address in X86 system?

拜拜、爱过 提交于 2019-12-24 07:48:36
问题 I am working on a Linux kernel module, which maps a physical address range to a process virtual address space, by playing with process's page tables. Then, I have a question in my head, what will happen if a PTE points to a non-existing physical address? For example, my X86 laptop has 8GB DRAM, and if a PTE has the value of 0x8000000400001227, will the CPU generate some exception for this invalid address accessing? I did a quick a test with that, but there is NOthing unusual happened, and I

malloc pointer address in main and in other function difference [duplicate]

对着背影说爱祢 提交于 2019-12-24 06:27:06
问题 This question already has answers here : Printing pointer addresses in C [two questions] (5 answers) Closed 2 years ago . I have the following question. Why is there a difference in the addresses of the two pointers in following example? This is the full code: #include <stdio.h> #include <stdlib.h> void *mymalloc(size_t bytes){ void * ptr = malloc(bytes); printf("Address1 = %zx\n",(size_t)&ptr); return ptr; } void main (void) { unsigned char *bitv = mymalloc(5); printf("Address2 = %zx\n",

Get specific byte from M68k ram address with C language

馋奶兔 提交于 2019-12-23 20:35:01
问题 Through the IDA disassembler I've reached this address: 0010FD74 00 00 00 00 00 00 03 00 00 00 00 00 82 03 80 02 Now I need, given the address to get particular bytes; for example the 7th position where there is "03". I've tried using C language to do this: char *dummycharacter; *dummycharacter = *(char*)0x10FD74; Now if I try to access 7th value with this: dummycharacter[6] I don't get 0x03…where am I going wrong? 回答1: You're trying to assign the value dummycharacter points to (which is

C++ - Allocating memory on heap using “new”

假如想象 提交于 2019-12-23 08:18:06
问题 If I have the following statement: int *x = new int; In this case, I have allocated memory on the heap dynamically. In other words, I now have a reserved memory address for an int object. Say after that that I made the following: delete x; Which means that I freed up the memory address on the heap. Say after that I did the following again: int *x = new int; Will x point to the same old memory address it pointed to at the heap before it was deleted? What if I did this before delete : x = NULL;

Open Watcom Inline assembly SEG and OFFSET operators

爱⌒轻易说出口 提交于 2019-12-23 02:49:20
问题 Today, I have learned that the SEG operator in MASM by default returns the address of the GROUP and not the address of the SEGMENT of the expression in question, and that there are options and methods to override that. Since I am currently doing a complex project in Open Watcom 1.9 / 16 bit DOS where C and assembly (inline and standalone) are mixed (actually, DOS is only needed for startup, then my own MINI-OS takes control), and since I know that WASM is somewhat MASM compatible, I have the

For buffer overflows, what is the stack address when using pthreads?

断了今生、忘了曾经 提交于 2019-12-21 17:39:11
问题 I'm taking a class in computer security and there is an extra credit assignment to insert executable code into a buffer overflow. I have the c source code for the target program I'm trying to manipulate, and I've gotten to the point where I can successfully overwrite the eip for the current function stack frame. However, I always get a Segmentation fault, because the address I supply is always wrong. The problem is that the current function is inside a pthread, and therefore, the address of

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

不打扰是莪最后的温柔 提交于 2019-12-21 02:48:15
问题 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

Setting limit to total physical memory available in Linux

情到浓时终转凉″ 提交于 2019-12-20 18:06:50
问题 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. 回答1: 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

How do game trainers change an address in memory that's dynamic?

我的梦境 提交于 2019-12-20 10:37:19
问题 Lets assume I am a game and I have a global int* that contains my health. A game trainer's job is to modify this value to whatever in order to achieve god mode. I've looked up tutorials on game trainers to understand how they work, and the general idea is to use a memory scanner to try and find the address of a certain value. Then modify this address by injecting a dll or whatever. But I made a simple program with a global int* and its address changes every time I run the app, so I don't get

How can I use a page table to convert a virtual address into a physical one?

喜你入骨 提交于 2019-12-20 09:19:54
问题 Lets say I have a normal page table: Page Table (Page size = 4k) Page #: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Page Frame #: 3 x 1 x 0 x 2 x 5 x 7 4 6 x x x How can I convert an arbitrary logical address like 51996 into a physical memory address? If I take log base 2 (4096), I get 12. I think this is how many bits I'm suppose to use for the offset of my address. I'm just not sure. 51996 / 4096 = 12.69. So does this mean it lay on page#12 with a certain offset? How do I then turn that into the