Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CreateFile: Specifying an address to open a file stream ...

103 views
Skip to first unread message

Jamie Risk

unread,
Aug 5, 2005, 2:15:00 PM8/5/05
to
I downloaded some code from the Altera web site to program there parts
via a special cable connected to the serial port. In a portion of the
downloaded code there is a call to "CreateFile" as follows:

nt_device_handle = CreateFile(
"\\\\.\\ALTLPT1",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL );

Which, incidentally doesn't seem to work when I compile it as part of a
Win32 Console Application under Visual C++ 6.0 (although it did under a
competitor product ... hmmm).


Anyway, this leads me to two questions:
1. The LPCTSTR lpFileName argument appears to map names to addresses of
named ports - is there a list of such ports available?

2. I'd like to open a file (stream?) handle to write to an address at
0x300, and 0x301 (on the ISA bus). In a PC not running the x86 in
protected mode I'd simply use 'in/outbytep and inp/outp' macros. Is
there a way I can construct an LPCTSTR file name to accomplish opening
an memory address?

I've googled things like "CreateFile Win32 inbyteb" and "CreateFile
Win32 port addresses" to no avail.

Help appreciated!

- Jamie


rou...@yahoo.com

unread,
Aug 7, 2005, 7:55:00 PM8/7/05
to
You want to talk to the LPT port? Why not
CreateFile("LPT1:",.... ?
Why the hang up over string type?
You want to write directly to the BIOS I/O address instead of using
createfile, read/write?
I hope this helps: http://www.vcomsoft.com/infopage/LPTPORT.html

Don Burn

unread,
Aug 7, 2005, 8:00:59 PM8/7/05
to
Well the good news on things like this is they don't work on 64-bit, and
they probably will not work on Windows Vista.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

<rou...@yahoo.com> wrote in message
news:1123458900.3...@o13g2000cwo.googlegroups.com...

Jamie Risk

unread,
Aug 8, 2005, 9:26:27 AM8/8/05
to

Thanks for the link, but after a quick skim of the URL, it appears the
library is not entirely useful for my project.

The "hang up over string type" is that I haven't seen documentation for
a name space that the first argument of CreateFile will willingly
accept. If "LPT1:" works, that's terrific, my problem is that I'm
trying to convert the code that uses the printer port ("LPT1") to an I/O
port on an ISA bus (0x300:0x301).

Another "hang up" is that I'm relegated to using "free" tools - despite
the fact that it cost 10 times as much for me (an embedded C programmer)
to learn enough of the Windows API to accomplish this.

** EMPHASIS **
Can CreateFile() be called to open a file stream to an arbitrary I/O
port address? If yes, how?
**

- Jamie

Gary Chanson

unread,
Aug 8, 2005, 1:45:49 PM8/8/05
to

"Jamie Risk" <ri...@intectus.com> wrote in message
news:%23eZDPyB...@TK2MSFTNGP15.phx.gbl...

The standard driver for LPT1 will only support output. Given your
constraints, I'd suggest using a third-party device drive such as WinIO which
will let your program have direct access to the IO ports that LPT1 is
connected to.

--
-GJC [MS Windows SDK MVP]
-Software Consultant (Embedded systems and Real Time Controls)
- http://www.mvps.org/ArcaneIncantations/consulting.htm
-gcha...@mvps.org

David J. Craig

unread,
Jun 18, 2006, 12:46:30 AM6/18/06
to
No!!!

"Jamie Risk" <ri...@intectus.com> wrote in message
news:%23eZDPyB...@TK2MSFTNGP15.phx.gbl...

NeilShore

unread,
Jul 17, 2006, 7:03:01 AM7/17/06
to
Jamie,

I believe you will need a device driver to what you want. There is a simple
device driver example for addressing the ISA bus. It is called genport and
can be found in the DDK sample directory. I don't write device drivers, but
found the example simple enough for me modify, build, and to use in
conjunction with an application that I wrote years ago.

- Neil Shore

Ben Voigt

unread,
Sep 4, 2006, 12:09:18 PM9/4/06
to
"NeilShore" <Neil...@discussions.microsoft.com> wrote in message
news:D1851882-4B31-4F8C...@microsoft.com...

> Jamie,
>
> I believe you will need a device driver to what you want. There is a
> simple
> device driver example for addressing the ISA bus. It is called genport
> and
> can be found in the DDK sample directory. I don't write device drivers,
> but
> found the example simple enough for me modify, build, and to use in
> conjunction with an application that I wrote years ago.

You do need a device driver, but no need to write your own. There's a
widespread one called giveio, see for example
http://www.cs.ucr.edu/~eblock/pages/pictools/giveio.html
http://www.intel.com/design/pca/applicationsprocessors/swsup/RelNote_JFlashmm_V5_01_007.pdf

>
> - Neil Shore
>
> "Jamie Risk" wrote:
>
>> I downloaded some code from the Altera web site to program there parts
>> via a special cable connected to the serial port. In a portion of the
>> downloaded code there is a call to "CreateFile" as follows:
>>
>> nt_device_handle = CreateFile(
>> "\\\\.\\ALTLPT1",
>> GENERIC_READ | GENERIC_WRITE,
>> 0,
>> NULL,
>> OPEN_EXISTING,
>> FILE_ATTRIBUTE_NORMAL,
>> NULL );
>>
>> Which, incidentally doesn't seem to work when I compile it as part of a
>> Win32 Console Application under Visual C++ 6.0 (although it did under a
>> competitor product ... hmmm).
>>
>>
>> Anyway, this leads me to two questions:
>> 1. The LPCTSTR lpFileName argument appears to map names to addresses of
>> named ports - is there a list of such ports available?

The available port names depend on the installed drivers.


>>
>> 2. I'd like to open a file (stream?) handle to write to an address at
>> 0x300, and 0x301 (on the ISA bus). In a PC not running the x86 in
>> protected mode I'd simply use 'in/outbytep and inp/outp' macros. Is
>> there a way I can construct an LPCTSTR file name to accomplish opening
>> an memory address?

The giveio driver I think disables memory protected for whatever list of
ports you give it, so inp/outp work.

>>
>>
>>
>> I've googled things like "CreateFile Win32 inbyteb" and "CreateFile
>> Win32 port addresses" to no avail.

Because CreateFile is pretty much useless for this purpose, unless you have
a special driver like the Altera to talk to. "WinNT user mode port i/o"
would be a better query.

>>
>> Help appreciated!
>>
>> - Jamie
>>
>>
>>


0 new messages