|
This thread is locked; no one can reply to it. |
1
2
|
Getting a pointer to hard drive memory location? |
verthex
Member #11,340
September 2009
|
Just wondering how it would be possible to create a file on the hard drive and use the addresses/offsets within the file to write/read from?
|
Arthur Kalliokoski
Second in Command
February 2005
|
You can't be serious, can you? They all watch too much MSNBC... they get ideas. |
verthex
Member #11,340
September 2009
|
C is for old people, I'm still a young guy.
|
Arthur Kalliokoski
Second in Command
February 2005
|
Just which magical presto-chango "Make Game" button type language did you have in mind? They all watch too much MSNBC... they get ideas. |
verthex
Member #11,340
September 2009
|
Arthur Kalliokoski said: Just which magical presto-chango "Make Game" button type language did you have in mind? Python. I also wonder, is this possible with assembler somehow?
|
Arthur Kalliokoski
Second in Command
February 2005
|
If it's possible in a higher level language, it's possible in assembler, and then some. It may take an unreasonably long time to write, though. They all watch too much MSNBC... they get ideas. |
verthex
Member #11,340
September 2009
|
Arthur Kalliokoski said: It may take an unreasonably long time to write, though. Thats why I prefer C over assembler sometimes.
|
Paul whoknows
Member #5,081
September 2004
|
verthex said: C is for old people, I'm still a young guy. Grow up kid, C turns children into men in the blink of an eye Jokes aside, C is great when you need to work with files at low level. ____ "The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner. |
bamccaig
Member #7,536
July 2006
|
Paul whoknows said: Jokes aside, C is great when you need to work with anything[1] at low level. FTFY. References
-- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Thomas Fjellstrom
Member #476
June 2000
|
For a second I thought he was talking about getting an actual pointer. In which case he'd want mmap. -- |
verthex
Member #11,340
September 2009
|
Thomas Fjellstrom said: For a second I thought he was talking about getting an actual pointer. In which case he'd want mmap That does sound interesting except I have Xp. Damm piece of sht. XP and Borland turbo assembler are very similar btw, neither will ever catch up with time. I found this thread amusing.
|
Thomas Fjellstrom
Member #476
June 2000
|
verthex said: That does sound interesting except I have Xp. What makes you think windows doesn't have a similar feature? You did attempt to google it no? -- |
relpatseht
Member #5,034
September 2004
|
VirtualAlloc/VirtualProtect is the windows equivalent of mmap. They cannot be used to get an actual pointer to the hard drive, as they only manage pages. To directly access the hard drive on windows, one would use CreateFile, which, I suppose, is a bit like mmap.
|
van_houtte
Member #11,605
January 2010
|
Verthex, it's time you switch to an OS completely developed in assembly ----- Sometimes you may have to send 3-4 messages |
verthex
Member #11,340
September 2009
|
van_houtte said: Verthex, it's time you switch to an OS completely developed in assembly relpatseht said: To directly access the hard drive on windows, one would use CreateFile [msdn.microsoft.com], which, I suppose, is a bit like mmap. I'll look into it, thanks.
|
Thomas Fjellstrom
Member #476
June 2000
|
relpatseht said: VirtualAlloc/VirtualProtect is the windows equivalent of mmap. They cannot be used to get an actual pointer to the hard drive, as they only manage pages. You get a virtual memory range that has a backing store on disk. It's more or less a pointer to data on the HD. Though the OS is free to also assign real memory as well. Quote: To directly access the hard drive on windows, one would use CreateFile [msdn.microsoft.com], which, I suppose, is a bit like mmap. I thought CreateFile was like fopen or open. not mmap... -- |
relpatseht
Member #5,034
September 2004
|
With VirtualAlloc, you don't get the ability to specify if the memory is swapped out or not. Writing to memory returned with VirtualAlloc might be writing to the disk, but that doesn't really mean it is anything like a pointer to the disk. (Your changes will be lost, they can only show up in the paging file, etc) CreateFile can also be used for device access. To do so, you must specify the OPEN_EXISTING and FILE_SHARE_WRITE flags. Then, the device will be: If you want access to a particular partition, it would be something like: Either way, the handle returned can be used with DeviceIoControl to directly read and modify data.
|
ImLeftFooted
Member #3,935
October 2003
|
Thomas Fjellstrom said: For a second I thought he was talking about getting an actual pointer. In which case he'd want mmap That's probably too advanced for the OP. |
verthex
Member #11,340
September 2009
|
I think Arthur nailed this topic right of the bat though, his explanation is definitely superior to everyones elses. Dustin Dettmer said: That's probably too advanced for the OP. How so, what other pointer can there be besides the one Arthur mentioned?
|
relpatseht
Member #5,034
September 2004
|
The ones Thomas Fjellstrom and I have mentioned are pointers to directly modify the hard drive with no filesystem interference. The pointers Arthur mentioned are for modifying files within the hard drive's filesystem.
|
verthex
Member #11,340
September 2009
|
relpatseht said: The pointers Arthur mentioned are for modifying files within the hard drive's filesystem. Are those the ones with virtual memory addresses? Basically I want to be able to use memory on the disk that is a file called some name X for example and I want to be able to write to locations of that file, using pointers. Which approach is the better one, Arthurs or Thomas?
|
relpatseht
Member #5,034
September 2004
|
Arthur's, without a doubt. What Thomas and I were talking about would be more useful for creating filesystems, inspecting disks, and things of that nature.
|
verthex
Member #11,340
September 2009
|
relpatseht said: Arthur's, without a doubt. You derailed the thread and made me think otherwise, hisses at you and Dustin!
|
Slartibartfast
Member #8,789
June 2007
|
It rather sounds to me like MapViewOfFile is the functionality you are seeking as it allows you to map a file into memory and so you get pointers to the data (as it is in memory ) and can manipulate them as regular memory (:)). ---- |
verthex
Member #11,340
September 2009
|
Slartibartfast said: It rather sounds to me like MapViewOfFile [msdn.microsoft.com] is the functionality you are seeking as it allows you to map a file into memory and so you get pointers to the data (as it is in memory ) and can manipulate them as regular memory (:)). The farther I stay from windows.h the better, at least I'm assuming thats where the function is.
|
|
1
2
|