Solved

OpenProcess to READ and WRITE , in windows XP

Posted on 2003-11-15
10
461 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Paint/Redraw window while dragging 16 68
MsgBox 2 47
Macro Excel - Multiple If conditions 2 63
fso.FolderExists("\\server\HiddenFolder$") 4 49
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

914 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now