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

Accessing physical memory using C++

P: n/a
I need to write data to a physical address between 0xD0000 and 0xDFFFF
I have download the windows DDK but have no experience with this and
would like to get up and running very quickly can any one point me in
the direction of an example that I could modify. I found a reference
to an example program called GENPORT but can't seem to find any similar
example in the latest DDK. I have also found an already written and
complied driver called portTalk but this only allows you to talk to an
addresses between 0x0000 and 0xFFFF. Any help most appreicated.

Thanks,

Grant

Oct 24 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Grant wrote:
I need to write data to a physical address between 0xD0000 and 0xDFFFF
I have download the windows DDK but have no experience with this and
would like to get up and running very quickly can any one point me in
the direction of an example that I could modify. I found a reference
to an example program called GENPORT but can't seem to find any
similar example in the latest DDK. I have also found an already
written and complied driver called portTalk but this only allows you
to talk to an addresses between 0x0000 and 0xFFFF. Any help most
appreicated.
C++ _language_ does not define "DDK" or "windows". Try looking in
the 'microsoft.public.*' newsgroup hierarchy.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 24 '06 #2

P: n/a
Grant posted:
I need to write data to a physical address between 0xD0000 and 0xDFFFF
int main()
{
char unsigned *const min = (char unsigned*)0xD0000;
char unsigned const *const max = (char unsigned*)0xDFFFF;

char unsigned *p = min;

do *p++ = 5;
while (max != p);

*p = 5;
}

--

Frederick Gotham
Oct 24 '06 #3

P: n/a
Frederick Gotham wrote:
Grant posted:
>I need to write data to a physical address between 0xD0000 and
0xDFFFF

int main()
{
char unsigned *const min = (char unsigned*)0xD0000;
char unsigned const *const max = (char unsigned*)0xDFFFF;

char unsigned *p = min;

do *p++ = 5;
while (max != p);

*p = 5;
}
The code above does not guarantee to access *physical addresses*,
only *virtual* ones. Besides, there is no guarantee such virtual
addresses exist.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 24 '06 #4

P: n/a
Victor Bazarov wrote:
Frederick Gotham wrote:
Grant posted:
I need to write data to a physical address between 0xD0000 and
0xDFFFF
int main()
{
char unsigned *const min = (char unsigned*)0xD0000;
char unsigned const *const max = (char unsigned*)0xDFFFF;

char unsigned *p = min;

do *p++ = 5;
while (max != p);

*p = 5;
}

The code above does not guarantee to access *physical addresses*,
only *virtual* ones. Besides, there is no guarantee such virtual
addresses exist.
isn't casting an int to a pointer implemetation defined behaviour? And
isn't dereferencing the resulting pointer undefined behaviour?
--
Nick Keighley

Oct 25 '06 #5

P: n/a
Thanks I'll do that

Victor Bazarov wrote:
Grant wrote:
I need to write data to a physical address between 0xD0000 and 0xDFFFF
I have download the windows DDK but have no experience with this and
would like to get up and running very quickly can any one point me in
the direction of an example that I could modify. I found a reference
to an example program called GENPORT but can't seem to find any
similar example in the latest DDK. I have also found an already
written and complied driver called portTalk but this only allows you
to talk to an addresses between 0x0000 and 0xFFFF. Any help most
appreicated.

C++ _language_ does not define "DDK" or "windows". Try looking in
the 'microsoft.public.*' newsgroup hierarchy.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 25 '06 #6

P: n/a
Nick Keighley wrote:
Victor Bazarov wrote:
>Frederick Gotham wrote:
>>Grant posted:
>>>I need to write data to a physical address between 0xD0000 and
0xDFFFF

int main()
{
char unsigned *const min = (char unsigned*)0xD0000;
char unsigned const *const max = (char unsigned*)0xDFFFF;

char unsigned *p = min;

do *p++ = 5;
while (max != p);

*p = 5;
}

The code above does not guarantee to access *physical addresses*,
only *virtual* ones. Besides, there is no guarantee such virtual
addresses exist.

isn't casting an int to a pointer implemetation defined behaviour? And
isn't dereferencing the resulting pointer undefined behaviour?
Any undefined behaviour can still be defined by the implementation,
the Standard does not prohibit that. FWIW in MS-DOS ("real mode" of
x86 processors), for instance, the mechanism Frederick showed *is*
the way to access a particular location in physical memory. There
are, I am sure, other platforms that implement it that way. The only
reason it's so is that the mapping between virtual space and physical
space is 1-to-1 there.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 25 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.