Accessing physical memory using C++

G

Grant

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
 
V

Victor Bazarov

Grant said:
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
 
F

Frederick Gotham

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;
}
 
V

Victor Bazarov

Frederick said:
Grant posted:


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
 
N

Nick Keighley

Victor said:
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?
 
V

Victor Bazarov

Nick said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top