// sxbmem.h : main header file for the SXBMEM application
//

#ifndef __AFXWIN_H__
	#error include 'stdafx.h' before including this file for PCH
#endif

#include "resource.h"       // main symbols
#include "config.h"

/////////////////////////////////////////////////////////////////////////////
// CSxbmemApp:
// See sxbmem.cpp for the implementation of this class
//

class CSxbmemView;
class CMemView;

enum eDisplayFlags
{ // types default to unsigned
	dfByte, // decimal
	dfByteHex, // hex byte
	dfChar, // ascii
	dfMaskChar, // masked with 0x7F and ascii
	dfShort, // two byte decimal
	dfShortHex, // two byte hex
	dfLong,		// four byte
	dfLongHex, //  four byte hex
	dfString,
	dfPadding,
	dfSigned = 0x80000000
};

struct CElement
{
	CString m_Name;
	DWORD m_Offset;
	DWORD m_Size;
	eDisplayFlags m_Flags;
};

struct CDef
{
	DWORD m_Size;
	CArray<CElement *, CElement *> m_Members;
};

struct CSymbol
{
	DWORD m_Address;
	DWORD m_Size;
	DWORD m_Flags;
};

class CSxbmemApp : public CWinApp
{
	CMap<CString, LPCTSTR, CSymbol *, CSymbol *> m_SymbolTable;
	CMap<CString, LPCTSTR, CDef *, CDef *> m_DefTable;

	friend class CDataSourceDlg;
	CArray<CAdapter *, CAdapter *> m_Adapters;
	CAdapter *m_CurDataSource;

	BOOL LoadConfig();
	BOOL LoadConfigNT4();
	BOOL LoadConfigNT5();
	BOOL LoadSymbolTable(const CString&);
	BOOL LoadDefs(const CString&);

public:
	CSxbmemApp();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CSxbmemApp)
	public:
	virtual BOOL InitInstance();
	virtual int ExitInstance();
	//}}AFX_VIRTUAL

	CString GetCurDataSourceName();
	BOOL GetMemory(DWORD MemAddress, LPBYTE Buffer, DWORD *Size);
	BOOL SetMemory(DWORD MemAddress, LPBYTE Buffer, DWORD *Size);

	void AddSymbols(CComboBox&);
	const CSymbol *FindSymbol(const CString&) const;

	void AddDefs(CComboBox&);
	const CDef *FindDef(const CString&) const;

// Implementation

	//{{AFX_MSG(CSxbmemApp)
	afx_msg void OnAppAbout();
	afx_msg void OnCaptureTraceport();
	afx_msg void OnUpdateCaptureTraceport(CCmdUI* pCmdUI);
	afx_msg void OnFileLoadsymboltable();
	afx_msg void OnFileLoaddefinitions();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////
