memory-address

What does “DS:[40207A]” mean in assembly?

故事扮演 提交于 2019-11-26 08:23:18
问题 0040103A CALL DWORD PTR DS:[40207A] USER32.MessageBoxA What does DS: mean? 回答1: It means the instruction is referencing memory in the Data Segment - and can pretty much be ignored on modern OSes, since they run with a flat address space model (code, data and stack segments all refer to the same memory range, and memory protection is handled with paging). EDIT: A little elaboration - note that, to keep things simple, this is in the context of 32bit protected mode running Windows. A segment

Why can't I treat an array like a pointer in C?

ぐ巨炮叔叔 提交于 2019-11-26 07:42:43
问题 I see this question a lot on SO. Maybe not in so many words... but time and again there is confusion on how arrays are different from pointers. So I thought I would take a moment to Q&A a few points about this. For purposes of this Q&A we\'re going to assume a 32-bit system and the following have been declared: char * ptr = \"hello\"; char arr[10] = \"hello\"; int iarr[10] = {0}; Here\'s a list of questions that surmise the confusion I see on SO. As I see new ones I\'ll add to my list of Q&A

How can I reliably get an object's address when operator& is overloaded?

蹲街弑〆低调 提交于 2019-11-26 06:55:58
问题 Consider the following program: struct ghost { // ghosts like to pretend that they don\'t exist ghost* operator&() const volatile { return 0; } }; int main() { ghost clyde; ghost* clydes_address = &clyde; // darn; that\'s not clyde\'s address :\'( } How do I get clyde \'s address? I\'m looking for a solution that will work equally well for all types of objects. A C++03 solution would be nice, but I\'m interested in C++11 solutions too. If possible, let\'s avoid any implementation-specific

Access memory address in python

别说谁变了你拦得住时间么 提交于 2019-11-26 06:38:00
问题 My question is: How can I read the content of a memory address in python? example: ptr = id(7) I want to read the content of memory pointed by ptr. Thanks. 回答1: Have a look at ctypes.string_at. Here's an example. It dumps the raw data structure of a Python 3 integer. Hopefully you're only doing this as an exercise. No reason to do this with pure Python. from ctypes import string_at from sys import getsizeof from binascii import hexlify a = 0x7fff print(hexlify(string_at(id(a), getsizeof(a))))

Accessing Object Memory Address

蓝咒 提交于 2019-11-26 05:55:27
问题 When you call the object.__repr__() method in Python you get something like this back: <__main__.Test object at 0x2aba1c0cf890> Is there any way to get a hold of the memory address if you overload __repr__() , other then calling super(Class, obj).__repr__() and regexing it out? 回答1: The Python manual has this to say about id() : Return the "identity'' of an object. This is an integer (or long integer) which is guaranteed to be unique and constant for this object during its lifetime. Two

Using LEA on values that aren&#39;t addresses / pointers?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 05:48:47
问题 I was trying to understand how Address Computation Instruction works, especially with leaq command. Then I get confused when I see examples using leaq to do arithmetic computation. For example, the following C code, long m12(long x) { return x*12; } In assembly, leaq (%rdi, %rdi, 2), %rax salq $2, $rax If my understanding is right, leaq should move whatever address (%rdi, %rdi, 2) , which should be 2*%rdi+%rdi , evaluate to into %rax . What I get confused is since value x is stored in %rdi ,

How to access physical addresses from user space in Linux?

馋奶兔 提交于 2019-11-26 03:56:19
问题 On a ARM based system running Linux, I have a device that\'s memory mapped to a physical address. From a user space program where all addresses are virtual, how can I read content from this address? 回答1: You can map a device file to a user process memory using mmap(2) system call. Usually, device files are mappings of physical memory to the file system. Otherwise, you have to write a kernel module which creates such a file or provides a way to map the needed memory to a user process. Another

Address of an array

∥☆過路亽.° 提交于 2019-11-26 02:37:54
问题 int t[10]; int * u = t; cout << t << \" \" << &t << endl; cout << u << \" \" << &u << endl; Output: 0045FB88 0045FB88 0045FB88 0045FB7C The output for u makes sense. I understand that t and &t[0] should have the same value, but how come &t is also the same? What does &t actually mean? 回答1: When t is used on its own in the expression, an array-to-pointer conversion takes place, this produces a pointer to the first element of the array. When t is used as the argument of the & operator, no such

Why in 64bit the virtual address are 4 bits short (48bit long) compared with the physical address (52 bit long)?

那年仲夏 提交于 2019-11-26 02:00:38
问题 In the book \"Low-Level Programming: C, Assembly, and Program Execution on Intel® 64 Architecture\" I read: Each virtual 64-bit address (e.g., ones we are using in our programs) consists of several fields. The address itself is in fact only 48 bits wide; it is sign-extended to a 64-bit canonical address. Its characteristic is that its 17 left bits are equal. If the condition is not satisfied, the address gets rejected immediately when used. Then 48 bits of virtual address are transformed into

Memory address of variables in Java

北城余情 提交于 2019-11-26 01:06:53
问题 Please take a look at the picture below. When we create an object in java with the new keyword, we are getting a memory address from the OS. When we write out.println(objName) we can see a \"special\" string as output. My questions are: What is this output? If it is memory address which given by OS to us: a) How can I convert this string to binary? b) How can I get one integer variables address? 回答1: That is the class name and System.identityHashCode() separated by the '@' character. What the