Skip to main content

A library for manipulating memory in a Windows process

Project description

This library provides a set of functions for manipulating memory in a Windows process. It allows you to read and write memory, inject DLLs, and search for byte patterns in memory.

Twine Version Python Versions Docs Badge Build Status

installation

pip install PyMemoryR-W

Functions

process_handle(app_name)

Returns a process handle for the given App name.

Usage:

from PyMemoryRW import process_handle

# Get a handle for the Notepad process
handle = process_handle("notepad.exe")
print(handle)  # Output might look like: <Handle pid='1234'>

inject_dll(process_handle, dll_path)

Injects a DLL into a running process.

Usage:

from PyMemoryRW import process_handle, inject_dll

# Get a handle for the target process
handle = process_handle("myapp.exe")

# Path to the DLL to inject
dll_path = "C:\\Path\\To\\MyDLL.dll"

# Inject the DLL into the target process
inject_dll(handle, dll_path)

write_memory(process_handle, base_address, data)

Writes data to a chunk of memory in the process.

Usage:

from PyMemoryRW import process_handle, write_memory

# Get a handle for the target process
handle = process_handle("myapp.exe")

# Memory address to write to
base_address = 0x1000000

# Data to write (must be bytes)
data = b'Hello, World!'

# Write the data to the process memory
write_memory(handle, base_address, data)

read_memory(process_handle, base_address, size)

Reads a valu of memory from the process.

Usage:

from PyMemoryRW import process_handle, read_memory


# Open the process (replace with your process ID)
process_handle = process_handle("notepad.exe")

# Memory address to read from
base_address = 0x10000000

# Number of bytes to read
size = 1024

# Read the memory contents
data = read_memory(process_handle, base_address, size)

# Print the contents of the memory region
print(data)

search_byte_pattern(process_handle, pattern)

Searches for a byte pattern in the process memory and returns a list of dictionaries containing the addresses where the pattern was found, along with the original data at those addresses.

Usage:

from PyMemoryRW import process_handle, search_byte_pattern

# Get a handle for the target process
handle = process_handle("xyz.exe")

# Byte arrry pattern to search for
byte_pattern = bytes.fromhex('A0 42 00 00 C0 3F 33 33 13 40 00 00 F0 3F 00')
# Byte pattern to search for
value=12413414
pattern = value.to_bytes(4, byteorder='little')

# Search for the byte pattern in the process memory
matches = search_byte_pattern(handle, pattern)

# Print the results
print(matches)  # Example output: [{'address': '0x1000000', 'data': '12345678'}, {'address': '0x2000000', 'data': '12345678'}]

Scan_pattern(process_handle, pattern)

The Scan_pattern function searches for a given byte pattern in the memory of a specified process. The pattern can include specific bytes and wildcards (??) that match any byte.

Usage:

from PyMemoryRW import Scan_pattern

# Get a handle for the target process (example handle value)
handle = process_handle("xyz.exe")

# Byte pattern to search for, with '??' as wildcards
patterns = "12 34 ?? 56 ?? 11"

# Search for the byte pattern in the process memory
matches = Scan_pattern(process_handle, patterns)

# Print the results
print(matches)  # Example output: [{'base_address': '0x1000', 'data': '12 34 78 56 88 11'}, {'base_address': '0x2000', 'data': '12 34 90 56 33 11'}]

Requirements

Requirements

To use this library, you need the following Python libraries:

  • pymem
  • pyinjector
  • ctypes (included in the standard library)

You can install the required libraries using pip:

pip install pymem pyinjector mahdix

Author

Mahdi Hasan Shuvo

Contact

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymemrw-0.0.0.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyMemRW-0.0.0.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pymemrw-0.0.0.1.tar.gz.

File metadata

  • Download URL: pymemrw-0.0.0.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for pymemrw-0.0.0.1.tar.gz
Algorithm Hash digest
SHA256 edde64f0cd8afef3880144de91a14167ab98baca2b09285b727230a39087edf9
MD5 0f748371545168a583a1edf5703234be
BLAKE2b-256 585674a499001a5333a3ae7031233c3921175f191a1f9428154db977b95c77f6

See more details on using hashes here.

File details

Details for the file PyMemRW-0.0.0.1-py3-none-any.whl.

File metadata

  • Download URL: PyMemRW-0.0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for PyMemRW-0.0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 56b41158de7946d76d3adfe4e5d3454fa125bf7b8fe4457b8b3a9875eb859dd2
MD5 c29daa71c6dae0da2569f0367ccaed60
BLAKE2b-256 3af514031e80eda818d5c018f3f936b5bf147d78b2cbee10e79706db1a00edec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page