about ReadProcessMemory
DWORD dwProcessId;
HANDLE hProcess;
SCOPEINFO psi_buffer;
BOOL fRet = FALSE;
GetWindowThreadProcessId(hwnd, &dwProcessId);
if (dwProcessId != GetCurrentProcessId())
{
// If the memory is owned by a process other than the current process we
// need to remote read memory from that process.
hProcess = OpenProcess(0, FALSE, dwProcessId);
if(!hProcess)
{
fRet = FALSE;
goto Leave;
}
else
{
if(!ReadProcessMemory(hProcess,
(VOID *) psi,(VOID *) &psi_buffer, sizeof(SCOPEINFO), NULL))
{
fRet = FALSE;
goto Leave;
}
}
}
else
{
psi_buffer = *psi;
}
if (psi_buffer.dwSize != sizeof(SCOPEINFO))
{
return FALSE;
}
UserTakenHereFlag;
EnterUserMaybe();
ScopeControl *psc = (ScopeControl *)GetWindowLong(hwnd, 0);
if (!psc)
{
fRet = FALSE;
goto Leave;
}
if (dwProcessId != GetCurrentProcessId())
{
if(!WriteProcessMemory(hProcess, (VOID *) psi,
(VOID *) &psc->m_si, sizeof(SCOPEINFO), NULL))
{
fRet = FALSE;
goto Leave;
}
}
else
{
memcpy(psi, &psc->m_si, sizeof(SCOPEINFO));
}
fRet = TRUE;
Leave:
LeaveUserMaybe();
if (hProcess)
{
CloseHandle(hProcess);
}