Memory Error!! Pls help

Posted on 2004-10-01
Last Modified: 2012-05-05
I have written a code like this in visaul c++ using a win32 API function in a WIN2000 Proffessional.

#include <windows.h>
#include <winbase.h>
void main()
     CopyMemory((LPVOID)0xffffffff,(void *)0x0000ffff,1);

i am getting an error The instruction at "0x00408410" referenced
memory at "0x0000ffff". The memory could not be "read".

I am gettinng the same error when i try to access a memory address of any hex value.
Wot could be the problem?

Thanks in advance!!,
Question by:Abin Thomas
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 12201170
you are accessing memory not in user block for that program, you can't just copy memory from somewhere in RAM, it needs to be memory you have allocated in the program you are writing or a much more complex system of IPC communication.

Author Comment

by:Abin Thomas
ID: 12235485
dear demingj1,
  i m  plannming to develop a memory tester program,
  which can read and write to a given memory location.
  so could u help me out in giving ideas or urls?  

Accepted Solution

demingj1 earned 50 total points
ID: 12238453
This seems a pretty good resource for general information regarding memory and memory management across various platforms and languages.  However, most of the information seems pretty general.

I think what you need to do however is run your app in as simple an envronment as possible.  By this I mean run it in DOS or a barebones *nix build.  OS's are a buffer between user programs and memory.  Although it is possible in C++ to map to specific addresses I believe those addresses are in terms of virtual memory and have no bearing on where the data actually lies in RAM.  

When you run your user program you recieve an allocated amount of memory for reading, writing and storing your programs instruction set.  It varies depending on the size and nature of your app, but it is all managed by the OS.  If you try to write (or read) from another programs memory space the OS catches that request, denies it, and terminates your program since it cannot continue after not being able to retrieve the data it needs to continue it's execution.  When you boot a DOS (or Windows 98 Boot Disk) for example, the autoexec.bat file begins calling all programs to set up your environment.  Some of these programs are UMB and/or XMS Memory management and other Memory Management apps, these apps perform the same function by ensuring that the OS's (DOS in this case) memory is protected and not overwritten otherwise even the standard commands like "dir" and "edit" could not guarentee thier integrity since part of their instruction set could be overwritten.

Perhaps I am rambling in error, perhaps what you meant by a memory tester program is a program to test what exact memory space is available test if you can write to certain addresses while inside the Windows OS.  In this case I still don't know how to get through the virtual memory layer, it is embedded pretty deeply into the OS, perhaps somewhere you can find an API or existing native class to access memory directly which also tells Windows Virtual Memory Management to reserve that block of RAM for your code and not write there.  If you found this software you would want to make calls to read/write to a certain block and intercept windows error flags which would be triggering the exception/failure/crash of your program and interpret those error flags appropriately (i.e. your call to CopyMemory((LPVOID)0xffffffff,(void *)0x0000ffff,1); above throws a flag "memory cannot be read") you need to intercept that flag/error before it gets to the OS and the OS terminates your program, if you can intercept the flag you can handle it appropriately inside your program and your program can continue execution.

Hope this helps a bit.


Featured Post

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
A look at what happened in the Verizon cloud breach.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question