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 8628225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:28:59+00:00 2026-06-12T08:28:59+00:00

im working on a little solitär trainer. I don’t know why the function ReadProcessMemory

  • 0

im working on a little solitär trainer. I don’t know why the function ReadProcessMemory doesn’t work. Normally it returns a False or True but in that case nothing. The GetlastError() gives me the Errorcode 6.

#-*- coding: cp1252 -*-

import ctypes, win32ui, win32process ,win32api

PROCESS_ALL_ACCESS = 0x1F0FFF
HWND = win32ui.FindWindow(None,"Solitär").GetSafeHwnd()
print(HWND)
PID = win32process.GetWindowThreadProcessId(HWND)[1]
print(PID)
PROCESS = win32api.OpenProcess(PROCESS_ALL_ACCESS,0,PID).handle

rPM = ctypes.windll.kernel32.ReadProcessMemory
wPM = ctypes.windll.kernel32.WriteProcessMemory

ADDRESS1 = 0x00E97074
ADDRESS2 = ctypes.create_string_buffer(64)
pi = ctypes.pointer(ADDRESS2)
rPM(PROCESS,ADDRESS1,ADDRESS2,64,0)
print(ADDRESS2)
x=ctypes.windll.kernel32.GetLastError()
print(x)
  • 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-06-12T08:29:01+00:00Added an answer on June 12, 2026 at 8:29 am

    Check the community comment to the MSDN ReadProcessMemory page, quote(sic):

    W7 wont run read process memory

    You may need to check your access permissions for "SE_DEBUG_NAME" for the current processes token. If not enabled. Enabled it. This must be done as administrator of course.

    Also fully declare the return types and use the use_last_error parameter, where ctypes will cache the GetLastError() value internally directly after the call. Otherwise, it may be incorrect. If you are on a 64-bit system, SIZE_T and pointers are 64-bit values so ctypes needs to know the types to set up the stack correctly for the call.

    ...
    from ctypes import wintypes
    ...
    rPM = ctypes.WinDLL('kernel32',use_last_error=True).ReadProcessMemory
    rPM.argtypes = [wintypes.HANDLE,wintypes.LPCVOID,wintypes.LPVOID,ctypes.c_size_t,ctypes.POINTER(ctypes.c_size_t)]
    rPM.restype = wintypes.BOOL
    wPM = ctypes.WinDLL('kernel32',use_last_error=True).WriteProcessMemory
    wPM.argtypes = [wintypes.HANDLE,wintypes.LPVOID,wintypes.LPCVOID,ctypes.c_size_t,ctypes.POINTER(ctypes.c_size_t)]
    wPM.restype = wintypes.BOOL
    
    ADDRESS1 = 0x00E97074
    ADDRESS2 = ctypes.create_string_buffer(64)
    bytes_read = ctypes.c_size_t()
    print(rPM(PROCESS,ADDRESS1,ADDRESS2,64,ctypes.byref(bytes_read)))
    print(ctypes.get_last_error())
    

    Also, FYI, even with all the fixes I get the same error value, but I didn’t go through the trouble of enabling SE_DEBUG_NAME.

    SOLVED

    The following line is the issue:

    PROCESS = win32api.OpenProcess(PROCESS_ALL_ACCESS,0,PID).handle
    

    win32api.OpenProcess returns a temporary PyHANDLE that gets destroyed and closes the handle after the handle is retrieved.

    The solution is to use:

    PROCESS = win32api.OpenProcess(PROCESS_ALL_ACCESS,0,PID)
    ...
    rPM(PROCESS.handle,ADDRESS1,ADDRESS2,64,0)
    

    PROCESS then holds the PyHANDLE object and the handle remains valid.

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

Sidebar

Related Questions

I'm working on a little project, but I'm stuck and don't know what I'm
I thought people would be working on little code projects together, but I don't
I've started working a little bit with lift+scala+mongorecord but I found a small annoyance
I've been working a little bit on a Facebook application, but when I registered
I'm pretty new to curses but I wrote a working little curses application. But
I have little working knowledge of python. I know that there is something called
So working on an little project but thinking about making maps efficient. I have
I'm working on a little Android app to stream some camera footage (as a
I'm working on a little program to make my life easier when using Microsoft
I'm working on a little project right now in ActionScript 3. The project is

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.