gb_emulator / gb_debugger_msvs / memory_context.h

/*  Copyright Š 2011 Chris Spencer <spencercw@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

#pragma once

#include <stdint.h>

#include <atlbase.h>
#include <atlcom.h>

#include "gb_debugger_msvs_i.h"

#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif

using namespace ATL;

// {162D35F8-8808-4255-9519-CA2B3A2ABA67}
extern const __declspec(selectany) GUID IID_GbDebuggerMsvsMemoryContext =
	{ 0x162d35f8, 0x8808, 0x4255, { 0x95, 0x19, 0xca, 0x2b, 0x3a, 0x2a, 0xba, 0x67 } };

class ATL_NO_VTABLE CMemoryContext :
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CMemoryContext, &CLSID_MemoryContext>,
	public IDebugMemoryContext2
{
public:
	CMemoryContext()
	{
	}

DECLARE_REGISTRY_RESOURCEID(IDR_MEMORYCONTEXT)

BEGIN_COM_MAP(CMemoryContext)
	COM_INTERFACE_ENTRY(IDebugMemoryContext2)
	COM_INTERFACE_ENTRY_IID(IID_GbDebuggerMsvsMemoryContext, CMemoryContext)
END_COM_MAP()

	// IDebugMemoryContext2 methods
	STDMETHOD(GetName)(BSTR *pbstrName);
	STDMETHOD(GetInfo)(CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO *pInfo);
	STDMETHOD(Add)(UINT64 dwCount, IDebugMemoryContext2 **ppMemCxt);
	STDMETHOD(Subtract)(UINT64 dwCount, IDebugMemoryContext2 **ppMemCxt);
	STDMETHOD(Compare)(
		CONTEXT_COMPARE compare,
		IDebugMemoryContext2 **rgpMemoryContextSet,
		DWORD dwMemoryContextSetLen,
		DWORD *pdwMemoryContext);

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

public:
	void Init(uint16_t address);
	uint16_t GetAddress() const;

protected:
	uint16_t address_;
};

OBJECT_ENTRY_AUTO(__uuidof(MemoryContext), CMemoryContext)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.