Solved

Memory Error!! Pls help

Posted on 2004-10-01
3
445 Views
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!!,
 Abin.
0
Comment
Question by:Abin Thomas
  • 2
3 Comments
 
LVL 2

Expert Comment

by:demingj1
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.
0
 

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?  
 
0
 
LVL 2

Accepted Solution

by:
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.

http://www.memorymanagement.org/

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.

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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 Short Story about the Best File Recovery Software – Acronis True Image 2017
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now