Hi...can any1 help me in this code?? i am trying to read the content present at address 0x2c of memory of floppy...but i am having problem in this...please tell me how can i do this???
#include "stdafx.h"
#include "fat_32.h"
#include <conio.h>
#include <memory.h>
#include <string.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print an error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL,
::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
HANDLE hFloppy = ::CreateFile(_T("\\\\.\\A:"),
// Open the A: drive for PHYSICAL ACCESS
GENERIC_READ | GENERIC_WRITE, // Want R/W Access
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL
);
if(hFloppy != NULL)
{
WORD *temp=new WORD();
WORD *p;
p = reinterpret_cast< WORD* > (0x2C);
memcpy( temp, p, 2);
cout<<"contents at 2C are "<<*temp;
getch();
}
CloseHandle(hFloppy);
// Close the handle
}
return nRetCode;
}
it gives the following error..
Unhandled exception at 0x10232058 (msvcr80d.dll) in fat_32.exe: 0xC0000005: Access violation reading location 0x0000002c.