Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7420767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:17:41+00:00 2026-05-29T08:17:41+00:00

Please correct me if I am wrong. I am asking this question to clarify

  • 0

Please correct me if I am wrong. I am asking this question to clarify some ideas that I have.

Today in school I learned that when a process (program) executes, then the operating systems gives it a space in memory. So take for instance this two programs:

Program1:

    static void Main(string[] args)
    {

        unsafe // in debug options on the properties enable unsafe code
        {

            int a = 2;

            int* pointer_1 = &a; // create pointer1 to point to the address of variable a

            // breakpoint in here !!!!!!!!!!!!!!!!!

            // in the debug I should be able to see the address of pointer1. Copy it and 
            // type it in the console

            string hexValue = Console.ReadLine();

            // convert the hex value to base 10
            int decValue = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber);

            // create a new pointer that point to the address that I typed in the console
            IntPtr pointer_2 = new IntPtr(decValue);

            Console.WriteLine("The address of a: {0} Value {1}", ((int)&a), a);

            try
            {
                Console.WriteLine("The address of {0} points to value {1}", (int)&pointer_1, (int)pointer_2);

                // different approach of acomplishing the same
                Console.WriteLine(Marshal.ReadInt32(pointer_2));
            }
            catch
            {
                Console.WriteLine(@"you are supposed to be debuging this program.");                    
            }

        }

Program 2

    static void Main(string[] args)
    {            
        unsafe
        {
            IntPtr pointer_0 = new IntPtr(95151860); // see address of variable from program1
            int* pointer_1 = (int*)pointer_0;
            // try to access program's 1 object
            Console.WriteLine("addrees of {0} points to value {1} ", (int)&pointer_1, *pointer_1); 
        }
    }

So I understand that in program 2 I will get an error. I will be accessing restricted memory. So far what I have learned makes sense.

Ok know here is where things do not make sense.

There is a very nice program called AutoIt used to automate tasks. For example it can send mouse clicks, move the mouse, send key strokes etc.

Anyways autoit comes with a program called AutoIt Window Info where that program enables you to get the handles (pointers) of controls on windows. For example I could see the handle of the window’s control by draging the finder tool to the control that I wish on getting information:

enter image description here

int this picture I am dragging the finder tool to the calculator’s input control. I could also drag it to button 7 for instance.

So if you see in the picture I now have the address of that control. I could then be able to access it from my program!!


Yet another example of how you can access memory that does not belong to my program

Step 1) Get the pointer of any window with autoit window info

Step 2) In my computer that pointer is:

enter image description here

That is the window of google chrome the place where I am typing this question.

This class will send a window to the 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 with the poniter that I just got with the help of autoit and call it as:

            SendWndToBack.WindowHandle(new IntPtr(0x00000000000510B2));

then I will send that window to the back


I post some examples in order to ilustrate my point. But my question is when are you allowed to access other parts of the memory? If I make my variable public other programs will be able to access it? Why can I access some controls of windows from my own program?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:17:41+00:00Added an answer on May 29, 2026 at 8:17 am

    You are confusing “Handles” and “Pointers”.
    Just because it looks like an address, it may not be.
    Windows uses a lot of handles and the OS may let you do things to handles even though you didn’t create them.
    You can represent a Handle as an IntPtr, but it you were to actually treat it directly as a pointer, you would (probably) crash.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please correct me if I am wrong but I understand that John McCarthy was
If I am wrong then please correct me as I am new in this.
First post so hi! (please correct me if I use some term wrong) I've
Whats wrong wrong with this query please correct me on this syntactcally it's going
Forgive my probably incorrect application of terminology in this question (btw, please correct me
(Please correct me if i am wrong) I understand that when you run a
Someone please correct me if I'm wrong, but parsing a yyyy/MM/dd (or other specific
I'm by no means a sysadmin so please correct me if I'm wrong. I
Please feel free to correct me if I am wrong at any point... I
Could you please explain why this code is not syntactically correct? private void addEditor(final

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.