Please correct me if I am wrong. I am asking this question to clarify some ideas that I have.
Today at school, I learned that when a process (program) is executed, operating systems give it space in memory. So take, for example, two programs:
Program1:
static void Main(string[] args) { unsafe
Program 2
static void Main(string[] args) { unsafe { IntPtr pointer_0 = new IntPtr(95151860);
So, I understand that in program 2 I will get an error. I am accessing limited memory. So far, what I have learned makes sense.
To know that there is no point.
There is a very good program called AutoIt used to automate tasks. For example, it can send mouse clicks, move the mouse, send strokes of keys, etc.
In any case, autoit comes with a program called AutoIt Window Info, where this program allows you to get the handles (pointers) of controls on windows. For example, I could see the handle of the control window, overlaying the search tool on the control that I want to get:

int this picture I drag the search tool into the calculator input control. For example, I could drag it to button 7.
So, if you see in the picture, I now have the address of this control. Then I could access it from my program!
Another example of how you can access memory that does not belong to my program
Step 1) Get a pointer to any window with information about the autoit window
Step 2) On my computer, this pointer:

This is the google chrome window where I am typing this question.
This class will send the window back:
public static class SendWndToBack { [DllImport("user32.dll")] static extern bool SetWindowPos( IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); const UInt32 SWP_NOSIZE = 0x0001; const UInt32 SWP_NOMOVE = 0x0002; const UInt32 SWP_NOACTIVATE = 0x0010; static readonly IntPtr HWND_BOTTOM = new IntPtr(1); static readonly IntPtr k = new IntPtr(12); public static void WindowHandle(IntPtr windowHandle) { SetWindowPos(windowHandle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); } }
and then if I call the method using poniter, which I just got with autoit, and name it as:
SendWndToBack.WindowHandle(new IntPtr(0x00000000000510B2));
then I will send this window to the background
I am publishing a few examples to emphasize my point. But my question is when do you allow access to other parts of the memory? If I make my variable public, can other programs access it? Why can I access some window controls from my own program?