• Advertisement
Sign in to follow this  

Read data from specified adress of memory.

This topic is 1058 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I need to get data from specified adress of memory. I have adress in LPCVOID variable. Next I need to save this data to new adress of memory. How can I do it? I add, that I done it in Windows. Thank you for any help.

Share this post


Link to post
Share on other sites
Advertisement

No, I don't mean about copying data from one adress to another. I want to get a variable with data, next I want to save it to another adress, not the other way.

Share this post


Link to post
Share on other sites

He doesn't want to read and write, he wants to read and write.


He doesn't want to "he doesn't want to read and write, he wants to read and write", he wants to "he doesn't want to read and write, he wants to read and write" with variables.

Share this post


Link to post
Share on other sites

 

He doesn't want to read and write, he wants to read and write.


He doesn't want to "he doesn't want to read and write, he wants to read and write", he wants to "he doesn't want to read and write, he wants to read and write" with variables.

 

 

Dynamically.

 

(I think he's asking why he can't deref a void pointer.)

Edited by Khatharr

Share this post


Link to post
Share on other sites

If it's a single value rather than an array of values then you can just cast it. In any case, he needs to put more effort into explaining what he's talking about before we should start trying to answer him.

Edited by Khatharr

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

 

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

Edited by MiXen

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement