Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 511
  • Last Modified:

OpenProcess to READ and WRITE , in windows XP

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
fadixp
Asked:
fadixp
  • 5
  • 4
1 Solution
 
NBrownohCommented:
why not set the inherit value to true?
0
 
fadixpAuthor Commented:
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
 
NBrownohCommented:
'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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
NBrownohCommented:
oh yeah, change 3932 to your PID, 3932 was VB6.exe's PID on my comp right now, and it worked just fine.
0
 
fadixpAuthor Commented:
some how its about to work but i still dont know how to read and write .
0
 
fadixpAuthor Commented:
i mean like ( ReadProcessMemory ) and ( WriteProcessMemory )
i couldnt understand it .
0
 
NBrownohCommented:
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
 
fadixpAuthor Commented:
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
 
NBrownohCommented:
k, i sent you an email.
0

Featured Post

Industry Leaders: 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!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now