| KyleMiles (83) | |
|
Hello, I'm trying to get the process ID of a process... I know how to get the ID of a window, but is it not possible to get it of a process? This is for the function ReadProcessMemory() and WriteProcessMemory()... Thank you for any help that you can give! - Kyle | |
|
|
|
| fdxuwei (6) | |
|
First, you call EnumPrecesses() to get all pids of running process. Second , for each pid use OpenProcess to get the handle to the process. Last, call GetModuleFileNameEx() to get the name of the process by the handle, if it matchs the name of your process, return the related pid。 | |
|
|
|
| Clearner1 (21) | |||||
declare like this:
use it in the function like this:
try this | |||||
|
Last edited on
|
|||||
| Clearner1 (21) | |||
complete example:
this is better | |||
|
Last edited on
|
|||
| KyleMiles (83) | |||
|
Thank you for your time, however, I've gotten around that: tasklist in the CMD is good enough for what I'm doing... I'll remember this though. I'm now having a different problem I need help with. It's in the access rights to read/write the data... I have read up on access tokens, and they make sense to me. However, how do you get permission to edit the tokens? I know I can launch the program as administrator and do anything I want, but I need to be able to get around this... I get system error 5 (access denied) when I OpenProcessToken() with TOKEN_ADJUST_ACCESS, but I get system error 1300 when I OpenProcessToken() with TOKEN_ALL_ACCESS... Which doesn't make sense to me! Does TOKEN_ALL_ACCESS not have COMPLETE permission to do whatever it wants to a token? Or is 1300 a more serious error message? Whatever the case, it causes system error 299 (Only part of ReadProcessMemory() or WriteProcessMemory() request was complete). So my final question is can I incrementally give myself more and more permission until I have all process? Here is my code:
- Kyle | |||
|
Last edited on
|
|||
| modoran (1100) | |
|
The only way is to run your application elevated or disable UAC. There are tricks like using a windows service to do the job for you, but that requires administrator privileges to install it for the first time. You then communicate with the service using some sort of IPC, like named pipes or shared memory. | |
|
|
|
| KyleMiles (83) | |
|
And what would those tricks at installation be? - Kyle | |
|
|
|
| modoran (1100) | |
|
To install a windows service ? There is no trick - just do it from your application unstaller - it requires administrator privileges anyway and the user must accept it. It is just after that you will not nned any UAC prompts to do administrative tasks like ReadProcessMemory. Btw, it is this a malware application ? It looks that way ......... | |
|
|
|