Re: [Tutor] I want to learn how memory works!
On 29/09/17 19:47, Michael C wrote: > Could you point me to a source of information about all the things someone > should know before he starts writing a memory scanner? Not a single source but wikipedia is a good start for anything technical. In particular you need to understand the difference between virtual(VM) and physical memory(PM). Virtual memory is the memory that your program(process in OS speak) sees and physical memory is the RAM installed in your computer. The OS maps virtual memory to physical memory and depending on the OS that mapping can be done in many ways. In some OS (especially mainframes) you can specify in a config file how much VM each process is given at startup, in others you specify how much VM it needs so the OS won't allow it to start up unless there is that much available (this is often used on small machines and embedded systems). In others the VM is always a theoretical space determined by the address size (or built into the kernel). The PM is a combination of the theoretical address space, the installed RAM and the virtual memory page file(s). The OS swaps memory between RAM and page file as necessary. It is quite a complex topic and heavily OS dependent. It looks like you are using Windows and it's too long since I looked at that level of detail (around NT4!) to be confident of a reply, but ~ I'd start with wikipedia for the basic concepts then move to MSDN for the detail for your OS. The key point is that from inside a process you are seeing a virtualized version of memory, rarely, if ever, the actual physical RAM addresses. Only the OS sees that. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] I want to learn how memory works!
Hi all, after 1 week of on and off hacking, I realized I simply don't know enough about how memory works fundamentally! Could you point me to a source of information about all the things someone should know before he starts writing a memory scanner? Attached is my current code, which doesn't work and can't figure out why. That's where I am at. > code starts. import ctypes User32 = ctypes.WinDLL('User32', use_last_error=True) Kernel32 = ctypes.WinDLL('kernel32', use_last_error=True) PID = 5924 PROCESS_QUERY_INFORMATION = 0x0400 PROCESS_VM_READ = 0x0010 Process = Kernel32.OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, False, PID) ReadProcessMemory = Kernel32.ReadProcessMemory buffer = ctypes.create_string_buffer(4) bufferSize = (ctypes.sizeof(buffer)) # I think instead of using 10, I should use the size of the total # memory used. but I don't know how to find this value. for n in range(10): if ReadProcessMemory(Process, n, buffer, bufferSize, None): print('buffer: ',buffer) else: print('something is wrong!') print('Done.') ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor