LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-17-2006, 11:39 AM   #1
imsandy_007
LQ Newbie
 
Registered: Nov 2006
Distribution: SuSe 10.1 , Knoppix
Posts: 15

Rep: Reputation: 0
copy RAM to disk


i want to copy the RAM as is on the hard disk..
i want to write a simple C program..
i don't know which pointer do i have to use.
please give me some sort of help.
 
Old 11-17-2006, 11:54 AM   #2
Vincent_Vega
Member
 
Registered: Nov 2003
Location: South Jersey
Distribution: Slackware, Raspbian, Manjaro
Posts: 826

Rep: Reputation: 31
your RAM can be found at /dev/mem. Using cat /dev/mem > filename works I think. Is that what you want?
 
Old 11-17-2006, 12:01 PM   #3
imsandy_007
LQ Newbie
 
Registered: Nov 2006
Distribution: SuSe 10.1 , Knoppix
Posts: 15

Original Poster
Rep: Reputation: 0
how to copy RAM in a particular memory range

Quote:
Originally Posted by Vincent_Vega
your RAM can be found at /dev/mem. Using cat /dev/mem > filename works I think. Is that what you want?
by issuing command cat /dev/mem > RAM.DAT will copy whole RAM to disk...
i would also like to know what to do if i want to copy from an address to another address... i mean copying memory range
 
Old 11-17-2006, 12:16 PM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
You can probably use dd to specify an offset and number of bytes, e.g.
Code:
dd if=/dev/mem of=mem.dump bs=1 skip=10000 count=5000
...to dump 5000 bytes starting at offset 10000. I'm not 100% sure what the effect of reading the /dev/mem like this will be. One thing to watch is that dumping the memory will no doubt affect the memory... so you won't get an instantaneous snapshot. You might do better to dump from a virtual machine, or use a hardware debugger.
 
Old 11-17-2006, 05:34 PM   #5
slantoflight
Member
 
Registered: Aug 2005
Distribution: Smoothwall
Posts: 283
Blog Entries: 3

Rep: Reputation: 35
Quote:
Originally Posted by Vincent_Vega
your RAM can be found at /dev/mem. Using cat /dev/mem > filename works I think. Is that what you want?
I was under the impression you could'nt arbitrarly access memory from other programs, without use of a debugger.
 
Old 11-18-2006, 08:52 AM   #6
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Yes, the ability to copy the entirety of your memory to a file a normal user could read sounds very .. unsafe .. isn't that basically the same as reading from any random memory address, which could be beyond your process' space? I get SIGSEGVs when I try to do that in C.
 
Old 11-18-2006, 09:20 AM   #7
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Quote:
Originally Posted by taylor_venable
Yes, the ability to copy the entirety of your memory to a file a normal user could read sounds very .. unsafe .. isn't that basically the same as reading from any random memory address, which could be beyond your process' space? I get SIGSEGVs when I try to do that in C.
It's not possible as a normal user - you have to be root. On Ubuntu (and I'm sure some other distros) there is a group, kmem which is also able to read this, but normal users are not added to this group.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Booting without RAM disk Tinku Linux - General 3 10-03-2005 02:57 PM
ram disk quiron Linux From Scratch 3 07-20-2005 02:43 AM
Create a ram disk consty Linux - Newbie 9 05-19-2005 08:06 AM
Ram disk consty Red Hat 1 05-11-2005 07:06 AM
copy linux installation from old disk to new disk rmanocha Linux - Software 4 07-20-2004 06:21 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration