Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

C# How to modify a string from process memory

Featured Replies

Posted

I want to find a string from a process memory and change it through C#.

My current code to modify the string via its address:

[DllImport("kernel32.dll")] public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId); [DllImport("kernel32.dll", SetLastError = true)] static extern bool WriteProcessMemory(int hProcess, int lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesWritten); private void button1_Click(object sender, EventArgs e) { var process = Process.GetProcessesByName("ProcessName").FirstOrDefault(); IntPtr processHandle = OpenProcess(0x1F0FFF, false, process.Id); int bytesWritten = 0; byte[] buffer = Encoding.Unicode.GetBytes("It works!\0"); WriteProcessMemory((int)processHandle, 0x02C45B54 /* string address in memory */, buffer, buffer.Length, ref bytesWritten); }

My code is working perfectly but I want to modify the string from memory without knowing its memory address so this code is not useful for me.

I attached an assembly so you can do your tries on it.

image.png.e8eb7b3dff58fbc53235f7b6d5311e39.png

image.png.d13cbd1a500e95e531c9a4cf7a738697.png

EditMyMemory.exe

 

I would be grateful if someone could guide me on how to do this (I am a bit of an amateur please explain in full).

Edited by Fr4x
uploaded attachment

If it's not protected or packed then strings will be located in the .text section wherever this section is mapped in memory.

all you need is to find the scan the process memory for any occurrences of that string and then patch it correctly giving attention to the length of that string.

https://reverseengineering.stackexchange.com/questions/22130/how-to-find-the-starting-address-of-text-section-of-a-dll-inside-a-process-64

Edited by Kurapica

  • Author
1 hour ago, Kurapica said:

If it's not protected or packed then strings will be located in the .text section wherever this section is mapped in memory.

all you need is to find the scan the process memory for any occurrences of that string and then patch it correctly giving attention to the length of that string.

https://reverseengineering.stackexchange.com/questions/22130/how-to-find-the-starting-address-of-text-section-of-a-dll-inside-a-process-64

Hi, thank you very much for your answer, but as I said, I'm a bit of an amateur and I need a sample code to edit it..

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.