By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,960 Members | 987 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,960 IT Pros & Developers. It's quick & easy.

Accessing Physical Memory

P: 10
Direct question , please direct answer

Want to access physical memory as 0x80 in my code
like

Expand|Select|Wrap|Line Numbers
  1. namespace ff
  2. {
  3.     class Program
  4.     {
  5.         unsafe static void Main(string[] args)
  6.         {
  7.             int* f = (int*)0x80;
  8.             Console.Write("{0}", *f);
  9.         }
  10.     }
  11. }
  12.  

Please answer with a solution , not only explanation
using winxp , visualstudio2005
thanks in advance
Dec 17 '08 #1
Share this Question
Share on Google+
18 Replies


Plater
Expert 5K+
P: 7,872
Direct Answer: I agree, you want to do that.
Dec 17 '08 #2

P: 10
@Plater
What a nonsense answer ???!!!! :S
Dec 17 '08 #3

Plater
Expert 5K+
P: 7,872
@Sharaola
Just like your question, which there wasn't one.

Did this not work:
Expand|Select|Wrap|Line Numbers
  1. unsafe static void Main(string[] args)
  2. {
  3. int* f = (int*)0x80;
  4. Console.Write("{0}", *f);
  5. }
  6.  
How do you know it didn't work?
Did you run in debug and look at the memory contents?
Dec 17 '08 #4

P: 10
@Plater
Of course man i did , and it didn't work

Briefly , Windows doesn't give you the permission to access the physical address " only virtual ones " , so how can write a code to take this privilage and pass those limits

Please answer briefly with the solution
Dec 17 '08 #5

Plater
Expert 5K+
P: 7,872
Write a c++ dll that does it for you, try using memorymappedIO if need be?
Then DLLImport the dll?
Dec 17 '08 #6

P: 10
@Plater
How ?? , please more explantion
Dec 17 '08 #7

Curtis Rutland
Expert 2.5K+
P: 3,256
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. This includes handing out fully coded solutions. Please attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

Please read the Posting Guidelines and particularly the Coursework Posting Guidelines.

@Sharaola
This isn't ExpertsExchange or RentACoder. We won't do your work for you; we help you do your own work. So asking us not to answer with an explanation goes against this site's policies.

I suggest you take that attitude elsewhere.

MODERATOR
Dec 18 '08 #8

Frinavale
Expert Mod 5K+
P: 9,731
Why do you want to access physical memory anyways?
You don't know what's in it...and worse, you don't know what's using it so if you modify it you could damage something.

Why would you want to do this?

We cannot help you if you don't explain what you are trying to do, what you have tried, and what the problem is that you are having.

We are willing to help you understand your problem so that you can find a solution, however we will never outright give you a solution...that's just not how we work here....and even if I we wanted to give you an answer, we couldn't because you are trying to...hmm there's no way to put this nicely....because you're trying to do something kind of stupid. Like I said, accessing physical memory Not a good idea because you do not know what it is, what it's used for, or what's using it.


Anyways, I have renamed your thread so that it better reflects your question.

In the future please use a more descriptive title for your thread. This will help you to receive help more quickly and without the sarcasm that you've seen here.

-Moderator Frinny
Dec 18 '08 #9

P: 10
@Frinavale
"you're trying to do something kind of stupid".
Behave yourself because i know what to do specifcally

"I have renamed your thread"
you should inform me before doing such an action , as a kind of politness

Finally thanks you for your toughness
Dec 18 '08 #10

Curtis Rutland
Expert 2.5K+
P: 3,256
@Sharaola
If you know what to do specifically, why do you need our help?


@Sharaola
As a matter of fact, we shouldn't. Many OPs abandon threads, and if we waited for OP approval, we'd have a big mess. It's part of our job as Moderators to exercise our privileges when and how we see fit.


The fact that we are all Moderators on this forum should indicate something to you...we know what we are doing; we are staff.

If you have a problem with the way we are handling this situation, feel free to contact an administrator.
Dec 18 '08 #11

P: 10
"you're trying to do something kind of stupid".
Behave yourself

Y didn't you comment about this ??
Dec 19 '08 #12

Curtis Rutland
Expert 2.5K+
P: 3,256
If you want to discuss this further, please do so via PM. This is a public forum for question/answer, not a place to discuss the rules of the forum.
Dec 19 '08 #13

P: 10
@insertAlias
You should tell this to whose called frinavale first
Dec 19 '08 #14

Banfa
Expert Mod 5K+
P: 8,916
It is not clear why you would want to access physical memory and normally a program would not require this, although device drivers may require access to the physical addresses of the devices they drive.

The windows operating system generally prevents direct access to any hardware, all accesses routed via the HAL (Hardware Abstraction Layer Architecture of Windows NT - Wikipedia, the free encyclopedia) which is one of the ways that Windows manages to run correctly on so many different types of hardware.

All programs run in their own virtual memory space which has bits of physical memory they own mapped into it but you have no control of which bits of physical memory are assigned to your program, again that is under the control of Windows.

So as has been said direct access to physical memory is not a good idea in Windows as you have no idea of the true owner of that memory or what accessing it may do (especially if you write to it), because of this Windows does rather a good job of preventing it.
Dec 19 '08 #15

Plater
Expert 5K+
P: 7,872
Since I am in a good mood, I will redirect your attention to this function:
MmMapIoSpace()

I use it to directly access the bus lines connected to the processor, feel free to look up examples on how to use it
Dec 19 '08 #16

Frinavale
Expert Mod 5K+
P: 9,731
@Banfa
Thanks for the explanation Banfa.

I honestly didn't think there was any reason for why someone would want to access physical memory. The idea seemed absurd because I have never seen .NET used to implement firmware or device drivers. It never crossed my mind.
Dec 19 '08 #17

NeoPa
Expert Mod 15k+
P: 31,343
@Sharaola
Sharaola,

Your attitude towards the staff here (This attitude towards any member of the site would also warrant an official warning, but it is more serious against staff) is entirely unacceptable. I could include (quote from) almost any of your posts to illustrate the extraordinary level of rudeness you exhibit. Your attitude implies you see yourself as someone special, and that our volunteer helpers should consider themselves at your disposal. I will leave instruction in manners to your parents, but I want to make very clear that your current understanding of what contributes acceptable behaviour is woefully short of the mark. It's interesting to note though, that the concept of politeness is something you've heard of at least. It's just a shame you seem to feel this is only relevant to how others treat you, and there's no indication you feel you should be constrained by the same standards.

This warning means that any further infractions of our rules may lead to a suspension of your account for a period (generally one or two weeks - depending on the severity). Further infractions after this point would almost certainly lead to your account being banned permanently.

Administrator.

...and even if I we wanted to give you an answer, we couldn't because you are trying to...hmm there's no way to put this nicely....because you're trying to do something kind of stupid. Like I said, accessing physical memory Not a good idea because you do not know what it is, what it's used for, or what's using it.
PS. As a matter of interest - has no real bearing on this particular issue (except in your response to it) - had you quoted Frinny accurately, it would have been clear that they were making every effort not to be rude, and to treat you with a level of respect you've certainly not earned. Personally, I'm at a loss trying to think of a less insulting way to put it in the circumstances. How do you explain to someone why something you feel is obviously stupid should not be done, without referring to the stupidity of it?
Dec 19 '08 #18

NeoPa
Expert Mod 15k+
P: 31,343
@Frinavale
I wouldn't worry too much about it. If the question had been phrased more clearly, or even less offensively, the concepts of writing Device Driver software could have come to the fore earlier.

My device driver writing days are a long way behind me now, and Windows is a whole different OS from the one I ever wrote for, but I would guess, knowing that Windows protects direct memory access as it does, that there would need to be some sort of OS call to reserve access to the memory, and this would fail unless the module were written as, and loaded up as, a device driver.

I doubt user-level software could even make the call as the priority level would be too low.

Of course if the OP had bothered to spend effort explaining the situation, instead of wasting it making exhorbitant demands, you'd have had a clearer situation to consider.
Dec 19 '08 #19

Post your reply

Sign in to post your reply or Sign up for a free account.