If a program mallocs, can another program read those values?

Home » Programming & Design » If a program mallocs, can another program read those values?
Programming & Design No Comments

Say a program mallocs a bunch of integers

Can another program access those integers?

Or is it that the main program that malloc'd can only access those integers? (access only in its stack?)
in C and Linux.

Other answer:

?:
In C it's possible to read any memory on the system if the OS supports it, for example you can make applications that scan the entire memory for specific values (this is how some game cheat software works, you write how much gold you have and the memory is scanned for this value, and then the cheat software can overwrie that value to give you more gold for example).

However in Windows for example memory is not accessible by other programs by default, but if you launch the program from another program in a specific way it could be possible.

In Linux it is possible to read another process' memory using ptrace.

If you are creating both programs you typically want to write data to a file or use networking, a COM interface, pipes, sockets, or some other interprocess communication method supported by the targeted OS.

BlueTyphoid:
The Operating System probably reserves an amount of memory for each program/process, that only that process can access. So I don't think one process can access another process's malloc by default. But I'm no expert, maybe there's an easy way to do it.
Undisclosed:
It won't access them as Integers. Usually this causes an exception in the application, but apps with poor exception handling which have pointers that are manually assigned can still point to the address of the value. This can lead to unexpected behavior, as you can' tbe certain what you're loading if that happens.
david:
Well, if you want a program to be able to access some numbers generated by another program, the ordinary thing to do would be to output those numbers to a file, database, registry, etc., and then have the program read from that output.
Parker:
well, if you want a program to be able to access some numbers generated by another program, the ordinary thing to do would be to output those numbers to a file, database, registry, etc…, and then have the program read from that output…
Alessandra:
it will not access them as integers… usually this causes an exception in the application, but apps with poor exception handling which have pointers that are manually assigned can still point to the address of the value… this can lead to unexpected behavior, as you can' tbe certain what you're loading if that happens…
Joyanta:
Nope
Andy T:
No it is assigned to this app, unless the snooping app is written by a genius in Assembly there s no way to snoopy that.
no1home2day:
No. The RAM that is allocated is private to the software that created that block of RAM. The whole concept of .NET was to get rid of all the holes that other software can access.
Kim:
may be do not clear idea

LEAVE A COMMENT