Read data from specified adress of memory.

Started by
17 comments, last by SmkViper 9 years, 1 month ago

OK, so I need a data, because I must replace some functions, that generate this daa and save to my specyfied adress of memory. I want to read data from memory in that way, I can read this from the debugger. Then I will create function, that save this static definied data to the memory thought eg. WriteProcessMemory. I think that my data is a type of array of values. How can I do it? Should I use a ReadProcessMemory?

You're going to need to write some source code if you want help. English isn't working.

Advertisement

If i understand right, you want to modify a running executable's memory space by:

a) locking a process's memory with the correct permissions

b) reading and writing that memory with ReadProcessMemory() and WriteProcessMemory()

c) replace the machine code instructions in the code portion of the process to (i'm guessing) redirect execution into your own program.

Sounds a bit like modding a closed game to me, any chance you can shed more light on exactly which game, and what you are trying to do to it?

I think you are close to my idea, but I explain from beginning:

I have a code:

IDWriteBitmapRenderTarget *pRenderTarget;
        hResult = pGDIInterop->CreateBitmapRenderTarget(
            NULL,
            m_renderTargetWidth,
            m_renderTargetHeight,
            &pRenderTarget
        );
        if(FAILED(hResult)) {
            m_lastError = L"Failed to create bitmap render target";
        }
        else {
            hResult = pRenderTarget->SetPixelsPerDip(1.0f);
            hResult = S_OK;
            
            HDC hDC = pRenderTarget->GetMemoryDC();
            if(hDC == NULL) {
                m_lastError = L"Failed to get render target DC";
                hResult = E_FAIL;
            }
            else {
                HBRUSH hBrush = CreateSolidBrush(RGB(0, 0, 0));
                if(hBrush == NULL) {
                    m_lastError = L"Failed to create brush";
                    hResult = E_FAIL;
                }
                else {
                    HBITMAP hBitmap = static_cast<HBITMAP>(GetCurrentObject(hDC, OBJ_BITMAP));
                    if(hBitmap == NULL) {
                        m_lastError = L"GetCurrentObject failed";
                        hResult = E_FAIL;
                    }
                    else {
                        DIBSECTION dib;
                        int iResult = GetObject(hBitmap, sizeof(dib), &dib);
                        if(iResult < sizeof(dib)) {
                            m_lastError = L"GetObject failed";
                            hResult = E_FAIL;
                        }
                        else {
                            // Store render target resources and info
                            m_pRenderTarget = pRenderTarget;
                            
                            m_hDC = hDC;
                            m_hBlackBrush = hBrush;
                            
                            m_bmBits = dib.dsBm.bmBits;
                            m_bmWidthBytes = static_cast<UINT>(dib.dsBm.bmWidthBytes);
                            m_bmBytesPixel = static_cast<UINT>(dib.dsBm.bmBitsPixel) / 8;
                            
                            hResult = S_OK;
                        }
                    }
                    
                    if(FAILED(hResult))
                        DeleteObject(hBrush);
                }
            }
            
            if(FAILED(hResult))
                pRenderTarget->Release();
        }

Api of WIndows 8 doesn't support GetCurrentObject and GetObject, so I can't get m_bmBits, m_bmWidthBytes and m_bmBytesPixel. I noticed, that this values doesn't change, so I can replace that code to static declaration of this variables. With int values that was simple, but with m_bmBits there was a problem, because this is only pointer to adress of memory and I can't see properly values thought Visual Studio debugger(only I see value of this adress). So I had a idea to read from memory this values and I write it down pernamently to code and save to memory after started a program, This will be allow me to use this values in the same way, that I used it before. Can you help me now how can I get a array of this values?

That is not at all how it works... It is most certainly not static. It even changes every frame.

(This is related to another question MiXen asked some time ago about getting glyph pixels from DirectWrite, for those wondering).

I would recommend just using Direct2D like you said you already did, and draw fewer lines of text if it's too slow.

Or just use a texture with the text characters and draw quads. Either way this thread really doesn't make sense :)

Hes hacking stop it

Hes hacking stop it

No he’s not. He is epicly bad at asking questions and understanding the responses he has been given.
This is nothing but a re-post of his previous terrible question here.

Api of WIndows 8 doesn't support GetCurrentObject and GetObject

Yes it does.
If you are Windows Phone, telling us which platform and operating system might have been a good idea from the very beginning, don’t you think?


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Hes hacking stop it

No he’s not. He is epicly bad at asking questions and understanding the responses he has been given.
This is nothing but a re-post of his previous terrible question here.

Api of WIndows 8 doesn't support GetCurrentObject and GetObject

Yes it does.
If you are Windows Phone, telling us which platform and operating system might have been a good idea from the very beginning, don’t you think?


L. Spiro

Come on... I said this is for Windows and I thing that's enought. About GetCurrentObject and GetObject this is only for "desktop" apps, I adressed that I write for WIndows 8, so this is a picking on me.

That is not at all how it works... It is most certainly not static. It even changes every frame.

(This is related to another question MiXen asked some time ago about getting glyph pixels from DirectWrite, for those wondering).

I would recommend just using Direct2D like you said you already did, and draw fewer lines of text if it's too slow.

Or just use a texture with the text characters and draw quads. Either way this thread really doesn't make sense smile.png

Okej, If it isn't static, the thread is over smile.png

About GetCurrentObject and GetObject this is only for "desktop" apps

Does Windows 8 not classify as a desktop operating system? Can someone verify his claim that these functions are truly absent on Windows 8 (desktop, not mobile)? I don’t have it.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

About GetCurrentObject and GetObject this is only for "desktop" apps

Does Windows 8 not classify as a desktop operating system? Can someone verify his claim that these functions are truly absent on Windows 8 (desktop, not mobile)? I don’t have it.


L. Spiro


I think he's confusing Windows 8 with the WinRT API. For obvious reasons, WinRT is heavily sandboxed and won't allow this kind of access (just like Android or iOS), but Win32 API certainly will as you pointed out.

"Desktop" app usually refers to a program using the Win32 API, or a variant like WinForms or WPF.
"Modern" app usually refers to a program using the WinRT API, runs only on Windows 8 or newer, and cannot access the Win32 API as you'll get permission denied errors and you will be denied certification on the store.

This topic is closed to new replies.

Advertisement