473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Accessing physical memory using C++

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
6 6299
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: lupher cypher | last post by:
Hi, I'm trying to access memory directly at 0xb800 (text screen). I tried this: char far* screen = (char far*)0xb8000000; but apparently c++ compiler doesn't know "far" (says "syntax error...
9
by: Olumide | last post by:
Thats the question. I know about virtual memory, and the MMU. I just wonder if array members guaranteed to be contiguous in physical memory (and if so, why). Thanks, Olumide
1
by: Ronald de Feijter | last post by:
In a mechatronic system I can control some motors and servos by setting values between 0 and 255 at specific memory addresses. My problem is how to access these memory addresses within C#. I know...
4
by: Sharon | last post by:
I have an application that fails to allocate all its memory on physical memory. I have a Windows XP with 2 GByte RAM. Can anybody tell me how to configure the allowed physical memory for each...
8
by: nkrisraj | last post by:
Hi, I have a following structure: typedef struct { RateData rdr; int RateID; char RateBalance; } RateInfo;
20
by: sethukr | last post by:
hi, i need to store a value to a particular memory location without having a variable. So, how can i access a 'memory address' without using variables?? Is it possible in C??? Plz, help...
3
by: john | last post by:
I would like to view physical memory that is mapped to a pci board. I am using a tool called WinIO to try to create a virtual address to that physical memory. It works for both read and write of...
18
by: Sharaola | last post by:
Direct question , please direct answer Want to access physical memory as 0x80 in my code like namespace ff { class Program {
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.