Source

gb_emulator / gb_debugger_msvs / memory_bytes.cpp

Full commit
/*  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/>.  */

#include "stdafx.h"

#include "memory_bytes.h"

#include <iomanip>

#include "disassembly_stream.h"
#include "memory_context.h"

// IDebugMemoryBytes2 methods

HRESULT CMemoryBytes::ReadAt(
	IDebugMemoryContext2 *pStartContext,
	DWORD dwCount,
	BYTE *rgbMemory,
	DWORD *pdwRead,
	DWORD *pdwUnreadable)
{
	if (!pStartContext || !rgbMemory || !pdwRead)
	{
		return E_POINTER;
	}

	if (dwCount > 0xffff)
	{
		return E_INVALIDARG;
	}

	CMemoryContext *memoryContext = NULL;
	HRESULT hr = pStartContext->QueryInterface(IID_GbDebuggerMsvsMemoryContext,
		reinterpret_cast<void **>(&memoryContext));
	if (!SUCCEEDED(hr))
	{
		return E_INVALIDARG;
	}

	gbd->memRead(memoryContext->GetAddress(), static_cast<uint16_t>(dwCount), rgbMemory);
	*pdwRead = dwCount;
	*pdwUnreadable = 0;	

	return S_OK;
}

HRESULT CMemoryBytes::WriteAt(
	IDebugMemoryContext2 *pStartContext,
	DWORD dwCount,
	BYTE *rgbMemory)
{
	(void) pStartContext;
	(void) dwCount;
	(void) rgbMemory;

	return E_NOTIMPL;
}

HRESULT CMemoryBytes::GetSize(UINT64 *pqwSize)
{
	(void) pqwSize;

	return E_NOTIMPL;
}