|
// Process.cpp : Implementation of CProcess
#include "stdafx.h"
#include "Processes.h"
#include "Tools\Exception.h"
#include <stdexcept>
CProcess::CProcess() :
m_name(L""),
m_pid(0),
m_threadCount(0),
m_baseAddress(0),
m_heapSize(0),
m_virtualMemory(0),
m_virtualMemoryCommitted(0),
m_virtualMemoryReserved(0),
m_dll(0)
{
}
// CProcess
HRESULT CProcess::FinalConstruct()
{
return S_OK;
}
void CProcess::FinalRelease()
{
}
STDMETHODIMP CProcess::InterfaceSupportsErrorInfo(REFIID riid)
{
static const IID* arr[] =
{
&IID_IProcess
};
for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
{
if (InlineIsEqualGUID(*arr[i],riid))
return S_OK;
}
return S_FALSE;
}
void CProcess::Init(_bstr_t name, long pid,
long threadCount,
long baseAddress,
long heapSize,
long virtualMemory,
long virtualMemoryCommitted,
long virtualMemoryReserved,
long dll)
{
m_name = name;
m_pid = pid;
m_threadCount = threadCount;
m_baseAddress = baseAddress;
m_heapSize = heapSize;
m_virtualMemory = virtualMemory;
m_virtualMemoryCommitted = virtualMemoryCommitted;
m_virtualMemoryReserved = virtualMemoryReserved;
m_dll = dll;
}
STDMETHODIMP CProcess::get_Name(/*[out, retval]*/ BSTR *value)
{
try
{
Windows::AutoCriticalSection lock(m_lock);
*value = m_name.copy ();
} catch (std::exception& err)
{
const char* msg = err.what();
Tools::Exception exception(CLSID_Process, IDS_FAILED);
return exception.GetException();
} catch (_com_error& err)
{
err = err;
Tools::Exception exception(CLSID_Process, IDS_FAILED);
return exception.GetException();
}
return S_OK;
}
STDMETHODIMP CProcess::get_Pid(/*[out, retval]*/ LONG *value)
{
*value = m_pid;
return S_OK;
}
STDMETHODIMP CProcess::get_ThreadCount(/*[out, retval]*/ LONG *value)
{
*value = m_threadCount;
return S_OK;
}
STDMETHODIMP CProcess::get_BaseAddress(/*[out, retval]*/ LONG *value)
{
*value = m_baseAddress;
return S_OK;
}
STDMETHODIMP CProcess::get_HeapSize(/*[out, retval]*/ LONG *value)
{
*value = m_heapSize;
return S_OK;
}
STDMETHODIMP CProcess::get_VirtualMemory(/*[out, retval]*/ LONG *value)
{
*value = m_virtualMemory;
return S_OK;
}
STDMETHODIMP CProcess::get_VirtualMemoryCommitted(/*[out, retval]*/ LONG *value)
{
*value = m_virtualMemoryCommitted;
return S_OK;
}
STDMETHODIMP CProcess::get_VirtualMemoryReserved(/*[out, retval]*/ LONG *value)
{
*value = m_virtualMemoryReserved;
return S_OK;
}
STDMETHODIMP CProcess::get_DllCount(/*[out, retval]*/ LONG *value)
{
*value = m_dll;
return S_OK;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.