Direct Access to RAM

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
Hi,

Is it possible on a modern personal computer to directly access the RAM? I want to place binary code directly into the RAM the way they used to do it in the old days.

I know if I write a program in a language and compile / assemble it, the compiled file will contain machine code. If I run the file, the binary information will then be loaded into RAM.

But, I don't want to do it this way. I want to "burrow" through the operating system and go directly into the RAM.

Is this possible nowadays?

Thanks.
 

VirtualLarry

No Lifer
Aug 25, 2001
56,453
10,120
126
Hi,

Is it possible on a modern personal computer to directly access the RAM? I want to place binary code directly into the RAM the way they used to do it in the old days.

I know if I write a program in a language and compile / assemble it, the compiled file will contain machine code. If I run the file, the binary information will then be loaded into RAM.

But, I don't want to do it this way. I want to "burrow" through the operating system and go directly into the RAM.

Is this possible nowadays?

Thanks.

If you write your own bootloader, then yes, it can access the RAM fairly directly in real mode. (That is, if you can get to real mode from UEFI these days, I don't know.)

If you are talking about direct memory access under Windows NT-based OSes, then you need to write a kernel-mode device-driver, that runs in Ring0. (Or possibly, only the OS kernel itself runs in ring0 these days.)

If you are talking toggle switches and LEDs directly to the RAM contents, then no, you wouldn't be able to flip toggle switches in 10ns, or whatever the timing window is to send data to RAM. Not to mention, encoding the RAS / CAS, etc., bits, along with the data bits.

Can I ask why you want to do this?

Edit: If your PC includes a Firewire port, apparently, it is possible to arbitrarily read and write RAM, using an external hardware device.
 

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
If you write your own bootloader, then yes, it can access the RAM fairly directly in real mode. (That is, if you can get to real mode from UEFI these days, I don't know.)

If you are talking about direct memory access under Windows NT-based OSes, then you need to write a kernel-mode device-driver, that runs in Ring0. (Or possibly, only the OS kernel itself runs in ring0 these days.)

If you are talking toggle switches and LEDs directly to the RAM contents, then no, you wouldn't be able to flip toggle switches in 10ns, or whatever the timing window is to send data to RAM. Not to mention, encoding the RAS / CAS, etc., bits, along with the data bits.

Can I ask why you want to do this?

Edit: If your PC includes a Firewire port, apparently, it is possible to arbitrarily read and write RAM, using an external hardware device.

Thanks for the info.

I'm learning everything I can about computers. I know Java and C# and have programmed in those languages using the Visual Studio and JEdit IDEs.

However, I'm fascinated with the software / hardware interface. I dream about being able to code in opcodes.

I'm currently reading about architecture and learning a great deal. I finally understand the basics of how a computer works.

I was just wondering if you could directly access the RAM and put in your own opcodes / data.

If you are talking toggle switches and LEDs directly to the RAM contents,

This is exactly how the author of "Code" built his RAM assembly, toggle switches, light bulbs, and old telegraph relays for the switches.

On a personal note, you seem REALLY knowledgeable. Did you start out in the "golden days" of comp sci? Were you just as clueless as I am now when you started out?

Thanks.
 
Last edited:

Mark R

Diamond Member
Oct 9, 1999
8,513
14
81
Thanks for the info.

I was just wondering if you could directly access the RAM and put in your own opcodes / data.

Modern OSs stop you doing this for a long list of good reasons.

You can program a PC at the "bare metal" level, with direct access to the hardware. On a machine as complex as a modern PC, this can be very difficult as you need to be aware of all the minor bugs in the CPU, motherboard, BIOS, etc. and there can be lots of them. You will also need detailed technical information about the various components, and many manufacturers keep these as trade secrets (for example, GPUs may not have public hardware manuals, which means if you want to program your own drivers, you can't, or you just have to use trial and error - this is one reason why GPU support on OSs like linux sucks, because the volunteers that do the programming don't have any manuals to work from).

If you want to try programming at "bare metal" level, then I'd strongly suggest learning with a simple microcontroller, like a PIC micro. Example tutorial. These are very simple computers on a single chip. You can buy the chips for $1-2 each, and connect up some LEDs and buttons and stuff, write some code, save it to the chip's internal flash, and you're off. Alternatively, buy a ready-made board - e.g. Link
 
Last edited:

Dufus

Senior member
Sep 20, 2010
675
119
101
Plenty of software out there that will read/write RAM such as RWEverything.

If you want to have your own physical memory in Windows though better to go through the memory manager.

Not sure exactly what you want to do that can not be done normally.
 

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
Modern OSs stop you doing this for a long list of good reasons.

You can program a PC at the "bare metal" level, with direct access to the hardware. On a machine as complex as a modern PC, this can be very difficult as you need to be aware of all the minor bugs in the CPU, motherboard, BIOS, etc. and there can be lots of them. You will also need detailed technical information about the various components, and many manufacturers keep these as trade secrets (for example, GPUs may not have public hardware manuals, which means if you want to program your own drivers, you can't, or you just have to use trial and error - this is one reason why GPU support on OSs like linux sucks, because the volunteers that do the programming don't have any manuals to work from).

If you want to try programming at "bare metal" level, then I'd strongly suggest learning with a simple microcontroller, like a PIC micro. Example tutorial. These are very simple computers on a single chip. You can buy the chips for $1-2 each, and connect up some LEDs and buttons and stuff, write some code, save it to the chip's internal flash, and you're off. Alternatively, buy a ready-made board - e.g. Link

Thanks for the links.

So, this memory protection is done through software then?

That is, somewhere in the millions of lines of code for the operating system, there's code that says "memory blocks xxxx --> yyyy are off limits to the user"?

How would you code that exactly?

Is it a simple command or would it require many lines of code?

Thanks.
 

easp

Member
Mar 4, 2006
45
0
0
Dude, first off, why are you obsessed with "direct access to RAM?"

Second, if you want to know exactly how memory protection is implemented in a modern OS, you can see for yourself. The kernel sources for Linux, *BSD, Darwin/Xnu, Plan 9 and more are all open source. There are also open source operating systems designed for teaching. I don't have a recommendation off the top of my head, but there is a fork of Minix 2.X with protected and virtual memory support.

If you want to work close to the bare metal, I agree with the suggestion of looking into MCUs. In addition to PIC, AVR from Atmel, and MSP430 from TI are also accessible options.

If you want to be spoon-fed this stuff, well, I'm guessing it will cost you upwards of $200/hour.
 

hal2kilo

Lifer
Feb 24, 2009
23,654
10,517
136
Going back to what I remember from programming of old. Now that we have long since left DOS, is it possible to even peek or poke memory locations from a Visual Basic program?
 

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
Dude, first off, why are you obsessed with "direct access to RAM?"

Dude, first off, I don't think asking one question constitutes obsession.

Second, if you want to know exactly how memory protection is implemented in a modern OS, you can see for yourself. The kernel sources for Linux, *BSD, Darwin/Xnu, Plan 9 and more are all open source. There are also open source operating systems designed for teaching. I don't have a recommendation off the top of my head, but there is a fork of Minix 2.X with protected and virtual memory support.

Thanks. I'll look into it.

If you want to be spoon-fed this stuff, well, I'm guessing it will cost you upwards of $200/hour.

LOL.....haha.... Do you know how internet forums work?

I've been "spoon-fed" this stuff for several weeks now and have paid $0/hour.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |