Solved

OpenProcess to READ and WRITE , in windows XP

Posted on 2003-11-15
10
478 Views
Last Modified: 2013-12-25
i am trying to open a process by PID in windows XP to change some values like we normally do in HEXEDITOR , but the program is having an error when i get to
hProcess = OpenProcess ( PROCESS_ALL_ACCESS,FALSE,PID)
it means not being able to handle a process , am sure about the PID .
can any one help me to solve this problem , please.
thank you
0
Comment
Question by:fadixp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9757909
why not set the inherit value to true?
0
 
LVL 2

Author Comment

by:fadixp
ID: 9757918
i tried still not able to handle the process please send me the full code of changing any process
to accept the answer , and to earn the 500 =)
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9757922
'Declare this in a variable
Public Declare Function OpenProcess Lib "Kernel32.dll" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long
Public Const STANDARD_RIGHTS_REQUIRED As Long = &HF0000
Public Const SYNCHRONIZE As Long = &H100000
Public Const PROCESS_ALL_ACCESS As Long = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)

'Do this in a button or something
'Private Sub Command1_Click()
    Ret = OpenProcess(PROCESS_ALL_ACCESS, 0, 3932)
    MsgBox Ret
'End Sub

'--

Basically if the number in the msgbox isnt zero then it worked and that is the handle to your process that you wanna edit, if it is zero then you could use getlasterror, another API call to see what happened.  i just tested this on my machine and it works.  i also have administrative rights on my account.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:NBrownoh
ID: 9757923
oh yeah, change 3932 to your PID, 3932 was VB6.exe's PID on my comp right now, and it worked just fine.
0
 
LVL 2

Author Comment

by:fadixp
ID: 9757979
some how its about to work but i still dont know how to read and write .
0
 
LVL 2

Author Comment

by:fadixp
ID: 9757982
i mean like ( ReadProcessMemory ) and ( WriteProcessMemory )
i couldnt understand it .
0
 
LVL 3

Accepted Solution

by:
NBrownoh earned 500 total points
ID: 9757995
i dont see any API calls to write process memory, there is a function:

Declare Function GetProcessMemoryInfo Lib "PSAPI.DLL" (ByVal hProcess As Long, ppsmemCounters As PROCESS_MEMORY_COUNTERS, ByVal cb As Long) As Long

that will get information on the process memory usage. it will return data in this structure:

Type PROCESS_MEMORY_COUNTERS
    cb As Long
    PageFaultCount As Long
    PeakWorkingSetSize As Long
    WorkingSetSize As Long
    QuotaPeakPagedPoolUsage As Long
    QuotaPagedPoolUsage As Long
    QuotaPeakNonPagedPoolUsage As Long
    QuotaNonPagedPoolUsage As Long
    PagefileUsage As Long
    PeakPagefileUsage As Long
End Type

but the only thing you can do to a process is set its priority or close the process itself.  What exactly are you trying to do?
0
 
LVL 2

Author Comment

by:fadixp
ID: 9758001
actually you deserve the 500 for the time you wasted to solve this probelm
if you have an email i will send you the VB project that i found over the net and i am trying to make it working .

mine is : <removed by PashaMod for users privacy>
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9758003
k, i sent you an email.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question