memory-address

Changing the address value of a function pointer [closed]

落爺英雄遲暮 提交于 2019-12-13 08:30:02
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 years ago . I have the following code in C: int addInt(int n, int m) { return n + m; } int (*functionPtr)(int, int); functionPtr = &addInt; functionPtr is a function pointer and it points to the specific address of the function addInt . I want to change 1 bit of its value, but I can't figure it out how. Let's

Pointer address span on various platforms

心不动则不痛 提交于 2019-12-13 02:45:21
问题 A common situation while coding in C is to be writing functions which return pointers. In case some error occurred within the written function during runtime, NULL may be returned to indicate an error. NULL is just the special memory address 0x0, which is never used for anything but to indicate the occurrence of a special condition. My question is, are there any other special memory addresses which never will be used for userland application data? The reason I want to know this is because it

Why is it not possible to read an unaligned word in one step?

六眼飞鱼酱① 提交于 2019-12-12 14:34:22
问题 Given that the word size of a CPU allows it to address every single byte in the memory. And given that via PAE CPUs can even use more bits than its word size for addressing. What is the reason that a CPU cannot read an unaligned word in one step? For example, in a 32-bit machine you can read the 4-byte chunk starting at position 0, but you cannot read the one starting at position 1 (you can but it needs several steps). Why can CPUs not do that? 回答1: The problem is not with the ability of the

Stop perl overloading or print memory “address” of reference

早过忘川 提交于 2019-12-12 12:21:53
问题 I have a class I created that overloads the "" operator to print out a nice stringified form of the object that is user-readable. But now, I'd like to actually get the memory address such as: Some_class=HASH(0xb0aff98) which is what I would have normally done by using print "$some_object" if I had not already overridden the "" operator. Is there someway to bypass the overridden method or, failing that, just get the memory address of this object? 回答1: Use overload::StrVal($o). use overload '""

Print addresses of all local variables in C

风流意气都作罢 提交于 2019-12-12 10:25:12
问题 I want to print the addresses of all the local and global variables which are being used in a function, at different points of execution of a program and store them in a file. I am trying to use gdb for this same. The "info local" command prints the values of all local variables. I need something to print the addresses in a similar way. Is there any built in command for it? Edit 1 I am working on a gcc plugin which generates a points-to graph at compile time. I want to verify if the graph

How to show the starting address of some variables in C?

大城市里の小女人 提交于 2019-12-12 10:01:08
问题 #include <stdlib.h> #include <stdio.h> #include <math.h> #include <string.h> extern char **environ; int global_x = 10; // initialised global variable int global_y; // un-initialised global variable char global_array1[] = "Hello, world!"; // initialised global array and a string literal char global_array2[10]; // un-initialised global array char *global_pointer1 = "bye!"; // global pointer to a string literal char *global_pointer2; // un-initialised global pointer float global_float = 100.1; /

Memory RAM address of a variable in Lua

拥有回忆 提交于 2019-12-12 06:46:38
问题 How to access in C++, the memory address of a variable declared in the language Lua??? in other words (example in written Lua): X = 10 How to access the memory address of the variable X, which was declared on the Lua? address = (&X) ????????? Help me please!! 回答1: You don't, you ask the Lua API for the value of the variable, or set it. use :- lua_getfield lua_setfield refer... http://www.lua.org/manual/5.1/manual.html for a description and examples. 来源: https://stackoverflow.com/questions

how to read content of memory address 0xfeafe000 in c?

泄露秘密 提交于 2019-12-12 06:46:37
问题 i have tried to read content of a memory address 0xfeafe000 and 0xfe9b000. i have used a few techinue but unable to do so. i have tried following codes, they are- 1. unsigned int *abar = (unsigned int *) 0x0feaf000; printf("\n %x",*abar);// got segmentation fault 2. char txt[512]; memcpy(txt,(char *)0xfeafe000,sizeof(txt)); printf("%s",txt);// got segmentation fault is there anather way to resolve this or any flaws in my attempts?? 回答1: The logical address in your program is mapped by the OS

How many words can be in the address space?

心已入冬 提交于 2019-12-12 06:40:09
问题 Here is the problem I am working on The Problem: A high speed workstation has 64 bit words and 64 bit addresses with address resolution at the byte level. How many words can in be in the address space of the workstation? I defined the different terms in the problem Word Size - Processor natural unit of data. The word size determines the amount of information that can be processed in one go Byte Level Addressing - Hardware architectures that support accessing individual bytes within a word 64

How to get address of some struct member in array of structures

时光总嘲笑我的痴心妄想 提交于 2019-12-12 06:36:20
问题 I try to get the address of some struct member in array of structures but i don't want to use name of that member. It should be something like this: typedef struct{ unsigned char MrChar; unsigned short MrShort; unsigned long MrLong; unsigned char MrArray[5]; }tModule; static tModule taModulesArray[MODULES_AMOUNT] = { // MODULES_AMOUNT = 2 {0x22, 0x3298, 0x92324583, "djsoe"}, // Module 1 {0x33, 0x1843, 0x65644113, "gskwc"}, // Module 2 }; unsigned long usGetMemberAddr(unsigned long ulModule,