Click here to Skip to main content
15,887,746 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
QuestionGet process handle access rights. Pin
Green Fuze13-Sep-10 13:10
Green Fuze13-Sep-10 13:10 
AnswerRe: Get process handle access rights. Pin
Cool_Dev13-Sep-10 22:52
Cool_Dev13-Sep-10 22:52 
GeneralRe: Get process handle access rights. Pin
Green Fuze13-Sep-10 22:58
Green Fuze13-Sep-10 22:58 
GeneralRe: Get process handle access rights. Pin
«_Superman_»13-Sep-10 23:06
professional«_Superman_»13-Sep-10 23:06 
GeneralRe: Get process handle access rights. Pin
Green Fuze13-Sep-10 23:33
Green Fuze13-Sep-10 23:33 
GeneralRe: Get process handle access rights. Pin
Cool_Dev14-Sep-10 2:43
Cool_Dev14-Sep-10 2:43 
GeneralRe: Get process handle access rights. Pin
Green Fuze14-Sep-10 9:04
Green Fuze14-Sep-10 9:04 
Question::ReadProcessMemory fails with ERROR_PARTIAL_COPY Pin
Green Fuze10-Sep-10 10:50
Green Fuze10-Sep-10 10:50 
Hey everybody.

I wrote (according to articles I found on the net) the following code, in order to get the command line of another process (it is not the "full code", just until it fails.

HANDLE hproc = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
if(!hproc)
{
	printf("OpenProcess() failed: 0x%x", ::GetLastError());
	return _T("");
}

_NtQueryInformationProcess NtQueryInformationProcess = (_NtQueryInformationProcess)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtQueryInformationProcess");
PROCESS_BASIC_INFORMATION pbi;
DWORD size_written;
NTSTATUS nt = NtQueryInformationProcess(hproc, ProcessBasicInformation, (void*)&pbi, sizeof(PROCESS_BASIC_INFORMATION), &size_written); // get pbi
if(nt)
{
	printf("NtQueryInformationProcess() failed: 0x%x", nt);
	return _T("");
}

PEB* peb = pbi.PebBaseAddress;
ULONG session_id = peb->SessionId;
SIZE_T read_size;
RTL_USER_PROCESS_PARAMETERS* proc_params = NULL;
DWORD old_protection;
if(!::VirtualProtectEx(hproc, peb->ProcessParameters, sizeof(RTL_USER_PROCESS_PARAMETERS*), PAGE_EXECUTE_READWRITE, &old_protection))
{
	printf("VirtualProtectEx() failed: 0x%x", ::GetLastError());
	return _T("");
}


// ************ FAILS HERE !!!! ***************
if(!::ReadProcessMemory(hproc, peb->ProcessParameters, (RTL_USER_PROCESS_PARAMETERS*)proc_params, sizeof(RTL_USER_PROCESS_PARAMETERS*), &read_size))
{
	printf("ReadProcessMemory() failed: 0x%x", ::GetLastError());
	return _T("");
}

if(!::VirtualProtectEx(hproc, peb->ProcessParameters, sizeof(RTL_USER_PROCESS_PARAMETERS*), old_protection, NULL))
{
	printf("VirtualProtectEx() failed: 0x%x", ::GetLastError());
	return _T("");
}


The output is that ReadProcessMemory() fails with ERROR_PARTIAL_COPY.
The code works in XP for processes in the same session.
Currently I am trying to make it work in windows 7, for a process in the same session.

ANY IDEAS any one ???? Confused | :confused:

Thanks!
AnswerRe: ::ReadProcessMemory fails with ERROR_PARTIAL_COPY Pin
«_Superman_»12-Sep-10 19:25
professional«_Superman_»12-Sep-10 19:25 
GeneralRe: ::ReadProcessMemory fails with ERROR_PARTIAL_COPY Pin
Green Fuze12-Sep-10 20:26
Green Fuze12-Sep-10 20:26 
QuestionOLE runs slow on Windows 7 Pin
cdguenther8-Sep-10 7:26
cdguenther8-Sep-10 7:26 
QuestionHow to develop the tool like Visual C++ "Resource View Editer" ? Pin
wangningyu7-Sep-10 23:54
wangningyu7-Sep-10 23:54 
AnswerRe: How to develop the tool like Visual C++ "Resource View Editer" ? Pin
Richard MacCutchan8-Sep-10 3:01
mveRichard MacCutchan8-Sep-10 3:01 
JokeRe: How to develop the tool like Visual C++ "Resource View Editer" ? Pin
Cool_Dev8-Sep-10 3:12
Cool_Dev8-Sep-10 3:12 
GeneralRe: How to develop the tool like Visual C++ "Resource View Editer" ? Pin
wangningyu8-Sep-10 5:00
wangningyu8-Sep-10 5:00 
GeneralRe: How to develop the tool like Visual C++ "Resource View Editer" ? Pin
Cool_Dev8-Sep-10 5:04
Cool_Dev8-Sep-10 5:04 
GeneralRe: How to develop the tool like Visual C++ "Resource View Editer" ? Pin
wangningyu8-Sep-10 5:12
wangningyu8-Sep-10 5:12 
QuestionI cannot install sp1 package for the visual studio 2005 [modified][solved] Pin
yu-jian7-Sep-10 19:16
yu-jian7-Sep-10 19:16 
AnswerRe: I cannot install sp1 package for the visual studio 2005 Pin
wangningyu8-Sep-10 1:39
wangningyu8-Sep-10 1:39 
GeneralRe: I cannot install sp1 package for the visual studio 2005 Pin
yu-jian15-Sep-10 15:09
yu-jian15-Sep-10 15:09 
AnswerRe: I cannot install sp1 package for the visual studio 2005 Pin
VeganFanatic11-Sep-10 4:29
VeganFanatic11-Sep-10 4:29 
QuestionMemory allocation problem in C++ (memory Leak) Pin
Nab Younus7-Sep-10 15:50
Nab Younus7-Sep-10 15:50 
AnswerRe: Memory allocation problem in C++ (memory Leak) Pin
Anand Todkar9-Sep-10 3:53
Anand Todkar9-Sep-10 3:53 
QuestionWhen run,the program cannot find MFC80UD.DLL in vs2005 [modified][solved] Pin
yu-jian6-Sep-10 18:21
yu-jian6-Sep-10 18:21 
AnswerRe: When run,the program cannot find MFC80UD.DLL in vs2005 Pin
Richard MacCutchan6-Sep-10 21:29
mveRichard MacCutchan6-Sep-10 21:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.