Solved

Memory Error!! Pls help

Posted on 2004-10-01
3
454 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
[X]
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
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

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…
This article outlines some of the reasons why an email message gets flagged as spam on a recipient's end.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 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