MinGW - An alternate to DDK ?

I DO NOT have a SDk/DDK. Since I was interested in learning to write a
simple serial port device driver for windows 2000, I used MINGW.
(mingw.sourforge.net)
I wrote a simple driver that prints some DBG messages on every interrupt.
(I wrote this with great difficulty getting required clarifications by
posting questions in this list. And further I do not have access to DDK
sample programs as I don’t have the DDK)

The problem, is however, the behaviour is unpredictable.

On slow interrupts, the system sometimes prints the DBG messages as
expected. But if the interrupts come too fast (every 1000 microsecs), the
system hangs or reboots or stops. (I get a blue screen error
“IRQ_NOT_LESS_OR_EQUAL”).

I spent quite sometime to debug this problem, but in vain.
At first, I thought the problem may be my ISR routine. MY ISR routine is
very simple which does something like this
{
// msr is a global variable.
msr = read_regs(); //pure i/o operations on UART
enable_further_interrupts(); // pure i/o operations on UAT.
if (dcd bit not set in MSR) {
print “Dummy”;
return FALSE;
}
print “real”
return FALSE;
// Actually i shud return TRUE. But if I do so, the driver hangs.
}

Also I am passing “LATCHED” as InterruptType to “IoInterruptConnect”.
If I pass “LevelSensitive”, the system always reboots.

These two problems are really troubling me. I have just started to wonder
if these problems is becoz of some bug in the MINGW devp. kit I am using.
Can anyone please throw more light on this ?

PS: If this behaviour confirms that problem is not in the code, then i can
try to post the problem in MINGW mailing list.

Do let me know if my complete source code is required.

Thanx
Kiran

At 08:37 AM 10/1/2003, Kiran wrote:

I DO NOT have a SDk/DDK. Since I was interested in learning to write a
simple serial port device driver for windows 2000, I used MINGW.
(mingw.sourforge.net)
I wrote a simple driver that prints some DBG messages on every interrupt.
(I wrote this with great difficulty getting required clarifications by
posting questions in this list. And further I do not have access to DDK
sample programs as I don’t have the DDK)

MINGW is interesting to look at once in a while, but I wouldn’t yet go
anywhere near trusting their environment to create real drivers for real
Windows.

Why don’t you have the DDK ? It’s a free download to MSDN subscribers and
for non-subscribers it can be had for the cost of shipping a CD, see:
http://www.microsoft.com/whdc/ddk/winddk.mspx

And yes, these days it comes with it’s own complete environment, including
compiler.

Mark

This question mystifies me, as I would have thought the answer is apparent:
MinGW is not an alternative.

Or let’s look at the issue differently: If you want to play with this, feel
free. But why ask here when you have problems?

Kiran wrote:

The problem, is however, the behaviour is unpredictable.


If replying by e-mail, please remove “nospam.” from the address.

James Antognini
Windows DDK MVP

I may be wrong, but I thought MinGW was a Ring 3 tool. I’m also wondering if
it’s legal to use DDK headers without owning the DDK. Do any of you know
better ?

Alberto.

-----Original Message-----
From: James Antognini [mailto:xxxxx@mindspring.nospam.com]
Sent: Wednesday, October 01, 2003 10:49 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: MinGW - An alternate to DDK ?

This question mystifies me, as I would have thought the answer is apparent:
MinGW is not an alternative.

Or let’s look at the issue differently: If you want to play with this, feel
free. But why ask here when you have problems?

Kiran wrote:

The problem, is however, the behaviour is unpredictable.


If replying by e-mail, please remove “nospam.” from the address.

James Antognini
Windows DDK MVP


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

first let me thank for the link Alberto :slight_smile:

I may be wrong, but I thought MinGW was a
Ring 3 tool.
whatever produces pe files with checksum can be used to create
drivers - there should be no doubt about it. i wrote “drivers”
(mainly functionality extension that couldn’t be done in ring3,
not real hardware drivers) in asm, under mingw, under ddk
environment and saw a little one in delphi :slight_smile:

imo the questioners problem was not in the tool but in the
design, in which having the ddk would help him very much …

I’m also wondering if
it’s legal to use DDK headers without owning
the DDK. Do any of you know
better ?
afaik mingw currently uses it’s own set of headers. anyway in the
ddk there are just values and function headers that you can find
almost everywhere on the internet - if that is a violation of
copyright law then it is really really bad …


Potrebujete vice prostoru pro vase stranky?
Ptejte se na http://sluzby.volny.cz/cs/product/ftp_paid

The DDK can be downloaded for free from MS; right?

Jamey Kirby, Windows DDK MVP
StorageCraft Inc.
xxxxx@storagecraft.com
http://www.storagecraft.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@post.cz
Sent: Wednesday, October 01, 2003 1:30 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: MinGW - An alternate to DDK ?

first let me thank for the link Alberto :slight_smile:

I may be wrong, but I thought MinGW was a
Ring 3 tool.
whatever produces pe files with checksum can be used to create
drivers - there should be no doubt about it. i wrote “drivers”
(mainly functionality extension that couldn’t be done in ring3,
not real hardware drivers) in asm, under mingw, under ddk
environment and saw a little one in delphi :slight_smile:

imo the questioners problem was not in the tool but in the
design, in which having the ddk would help him very much …

I’m also wondering if
it’s legal to use DDK headers without owning
the DDK. Do any of you know
better ?
afaik mingw currently uses it’s own set of headers. anyway in the
ddk there are just values and function headers that you can find
almost everywhere on the internet - if that is a violation of
copyright law then it is really really bad …


Potrebujete vice prostoru pro vase stranky?
Ptejte se na http://sluzby.volny.cz/cs/product/ftp_paid


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com



Jamey Kirby wrote:

> The DDK can be downloaded for free from MS; right?
>
> Jamey Kirby, Windows DDK MVP
> StorageCraft Inc.
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@post.cz
> Sent: Wednesday, October 01, 2003 1:30 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Re: MinGW - An alternate to DDK ?
>
> first let me thank for the link Alberto :slight_smile:
>
>
>>I may be wrong, but I thought MinGW was a
>>Ring 3 tool.
>
> whatever produces pe files with checksum can be used to create
> drivers - there should be no doubt about it. i wrote “drivers”
> (mainly functionality extension that couldn’t be done in ring3,
> not real hardware drivers) in asm, under mingw, under ddk
> environment and saw a little one in delphi :slight_smile:
>
> imo the questioners problem was not in the tool but in the
> design, in which having the ddk would help him very much …
>
>
>>I’m also wondering if
>>it’s legal to use DDK headers without owning
>>the DDK. Do any of you know
>>better ?
>
> afaik mingw currently uses it’s own set of headers. anyway in the
> ddk there are just values and function headers that you can find
> almost everywhere on the internet - if that is a violation of
> copyright law then it is really really bad …
>


Nick Ryan (MVP for DDK)

> The DDK can be downloaded for free from MS;

right?

afaik cannot. you can order it, or you have to have a MSDN
subscription. but i may be wrong.

either way you have to pay for it. maybe the fee for sending ($30
?) is not a big issue for an U.S. citizen, but for a student or
for a “i would like to try it” man it can be …

(i have ordered it, but couldn’t afford it without my parent’s
support - so here i see the purpose of free headers in mingw)

anyway why ms does not let people download the ddk for free ?


Best regards
Ivona Prenosilova


Vyhraj Ford Fiesta s klimatizac? a dal?? ceny!
V?ce na http://soutez.volny.cz

This is why I believe kernel development should not require any specific
compiler or development tool besides the .h files: specify the API tight
enough, and there’s no tools issue. This is why I’m also quite fond of
Linux, everything comes included and it’s crystal clear to use. I remember
in one of my Advanced OS classes I got my students to do a lab to write a
simple Linux kernel module, as you say, little snippets of kernel side
functionality. They were used to do it with the DDK and all the aggravation,
and they couldn’t believe when I showed them that all that was needed was to
build and test a Linux kernel module gcc followed by insmod.

“Prof, is that all ???”

Yes, dude, that’s all ! And that’s how it should be.

Alberto.

-----Original Message-----
From: xxxxx@post.cz [mailto:xxxxx@post.cz]
Sent: Wednesday, October 01, 2003 4:57 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: MinGW - An alternate to DDK ?

The DDK can be downloaded for free from MS;
right?

afaik cannot. you can order it, or you have to have a MSDN
subscription. but i may be wrong.

either way you have to pay for it. maybe the fee for sending ($30
?) is not a big issue for an U.S. citizen, but for a student or
for a “i would like to try it” man it can be …

(i have ordered it, but couldn’t afford it without my parent’s
support - so here i see the purpose of free headers in mingw)

anyway why ms does not let people download the ddk for free ?


Best regards
Ivona Prenosilova


Vyhraj Ford Fiesta s klimatizac? a dal?? ceny!
V?ce na http://soutez.volny.cz


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

On Wed, 2003-10-01 at 16:50, Moreira, Alberto wrote:

This is why I believe kernel development should not require any specific
compiler or development tool besides the .h files: specify the API tight
enough, and there’s no tools issue.

The api doesn’t capture all of the issues. To build windows drivers,
you need things like SEH and fastcall. SEH is patented and cannot be
directly implemented by mingw. Try writing any non-trivial driver
without that…

Compilers and operating systems aren’t entirely divorced from each
other, as good as that sounds in theory.

That said, I agree with your sentiment here.

-sd

The SEH is needed for calling a few API functions. It should be possible to
write
a preamble to those functions that checks, for instance, security
approval, before calling the API function raising an exception
on a security violation.

George

At 02:55 PM 10/1/2003, you wrote:

On Wed, 2003-10-01 at 16:50, Moreira, Alberto wrote:
> This is why I believe kernel development should not require any specific
> compiler or development tool besides the .h files: specify the API tight
> enough, and there’s no tools issue.

The api doesn’t capture all of the issues. To build windows drivers,
you need things like SEH and fastcall. SEH is patented and cannot be
directly implemented by mingw. Try writing any non-trivial driver
without that…

Compilers and operating systems aren’t entirely divorced from each
other, as good as that sounds in theory.

That said, I agree with your sentiment here.

-sd


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@ntrealtime.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

On Wed, 2003-10-01 at 17:09, George Blat wrote:

The SEH is needed for calling a few API functions. It should be possible to
write
a preamble to those functions that checks, for instance, security
approval, before calling the API function raising an exception
on a security violation.

ProbeForRead()? I guess you could check pte’s or something, but the ddk
says you should wrap it in an eh frame, and anything else sounds like a
hack to me…

-sd

I saw some code around mingw, that converts seh type exceptions
into standard C++ try-catch exceptions.

George

At 03:09 PM 10/1/2003, you wrote:

The SEH is needed for calling a few API functions. It should be possible
to write
a preamble to those functions that checks, for instance, security
approval, before calling the API function raising an exception
on a security violation.

George

At 02:55 PM 10/1/2003, you wrote:
>On Wed, 2003-10-01 at 16:50, Moreira, Alberto wrote:
> > This is why I believe kernel development should not require any specific
> > compiler or development tool besides the .h files: specify the API tight
> > enough, and there’s no tools issue.
>
>The api doesn’t capture all of the issues. To build windows drivers,
>you need things like SEH and fastcall. SEH is patented and cannot be
>directly implemented by mingw. Try writing any non-trivial driver
>without that…
>
>Compilers and operating systems aren’t entirely divorced from each
>other, as good as that sounds in theory.
>
>That said, I agree with your sentiment here.
>
> -sd
>
>
>
>—
>Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@ntrealtime.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@ntrealtime.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

On Wed, 2003-10-01 at 17:18, George Blat wrote:

I saw some code around mingw, that converts seh type exceptions
into standard C++ try-catch exceptions.

I was not aware of that; can you post a pointer? I’d be curious to see
what they have done.

The patented things appear to be the use of the stack to hold an
exception record (which itself holds a pointer to an exception handler
function), and the interaction of that eh record with operating-system
supplied facilities. The patent is not too difficult to understand and
can be found online at the uspto if anyone is interested. The patent is
owned by Borland, and Microsoft has paid Borland in order to license
this technology from them, as has IBM (so i have heard). It wouldn’t be
legal for mingw to duplicate this without a license from Borland.

Also, don’t forget that you must chain an exception handler to fs:0 or
you will get KMODE_EXCEPTION_NOT_HANDLED, regardless of a c++ catch
block.

Also, who would use c++ for a driver? JUST KIDDING :smiley:

-sd

A quick search gave me:

http://reactos.wox.org/download.php?id=5

I don’t have time now to look much deeper. But I would not be
surprised if the fs:0 part has been addressed.

George

At 04:11 PM 10/1/2003, you wrote:

On Wed, 2003-10-01 at 17:18, George Blat wrote:
> I saw some code around mingw, that converts seh type exceptions
> into standard C++ try-catch exceptions.

I was not aware of that; can you post a pointer? I’d be curious to see
what they have done.

The patented things appear to be the use of the stack to hold an
exception record (which itself holds a pointer to an exception handler
function), and the interaction of that eh record with operating-system
supplied facilities. The patent is not too difficult to understand and
can be found online at the uspto if anyone is interested. The patent is
owned by Borland, and Microsoft has paid Borland in order to license
this technology from them, as has IBM (so i have heard). It wouldn’t be
legal for mingw to duplicate this without a license from Borland.

Also, don’t forget that you must chain an exception handler to fs:0 or
you will get KMODE_EXCEPTION_NOT_HANDLED, regardless of a c++ catch
block.

Also, who would use c++ for a driver? JUST KIDDING :smiley:

-sd


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@ntrealtime.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> On slow interrupts, the system sometimes prints the DBG messages as

expected. But if the interrupts come too fast (every 1000 microsecs), the
system hangs or reboots or stops. (I get a blue screen error

So what? The debug print engine is not this fast to print 1000 strings per
second.

BTW - MinGW is a wrong way to go. If you will have any problem using MinGW for
Windows kernel mode development - then nearly nobody would help. It is by far
better to have Windows DDK (costs around USD 30, also included to MSDN
subscription) and use the build suite from it.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

> This is why I believe kernel development should not require any specific

compiler or development tool besides the .h files: specify the API tight
enough, and there’s no tools issue. This is why I’m also quite fond of
Linux, everything comes included and it’s crystal clear to use.

Linux is closely tied to GCC and code for Linux kernel is IIRC impossible to
develop using other compilers.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

> The api doesn’t capture all of the issues. To build windows drivers,

you need things like SEH and fastcall. SEH is patented and cannot be

MS have documented the RtlUnwind routine to help compiler writers to develop
SEH.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

> can be found online at the uspto if anyone is interested. The patent is

owned by Borland, and Microsoft has paid Borland in order to license

Really?

A kind of SEH is a part of C++ standard, which is free, and is based on some
British uni scientific work.

Also I never remember any Borland tool having C SEH. Only the C++ one. Even the
renowned BC++3.1 (for 16bit Windows 3.1) had no even C++ SEH.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

On Thu, 2003-10-02 at 16:26, Maxim S. Shatskih wrote:

> can be found online at the uspto if anyone is interested. The patent is
> owned by Borland, and Microsoft has paid Borland in order to license

Really?

This could be just an urban legend, but I did find this on searching the
uspto (watch word wrap):

http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO2&Sect2=HITOFF&p=1&u=/netahtml/search-bool.html&r=1&f=G&l=50&co1=AND&d=ptxt&s1=‘structured+exception+handling’&s2=borland&OS=

Title: Systems and methods and implementing exception handling using
exception registration records stored in stack memory
Inventors:
Kukol; Peter (Aptos, CA)
Assignee:
Borland International, Inc. (Scotts
Valley, CA)
Appl. No.:
262072
Filed:
June 15, 1994

Even if it *is* a legend, the MinGW, Wine, and ReactOS people all seem
to be concerned about it, according to some google searching. Search
google for conversations on the mingw list where the patent status of
SEH has seemingly been debated at length.

A kind of SEH is a part of C++ standard, which is free, and is based on some
British uni scientific work.

I may be quite wrong here, but i was under the impression that the C++
exception handling standard had nothing to do with the operating system
the code would run on. Microsoft happens to hook SEH exceptions up to
the C++ exception handler, but that is a vendor-ism of the microsoft
compiler.

The patent discusses C++ EH at length, and specifically calls out the
distinction between the C++ EH system and the OS-specific SEH system it
claims. It would seem, according to the patent, that the covered work
is not an OS-based EH, nor is it EH in general (as implemented by C++,
for example), but rather is the combination of a compiler/language
stack-based EH system with OS-specific EH support. Or have I
misunderstood your point?

Also I never remember any Borland tool having C SEH. Only the C++ one. Even the
renowned BC++3.1 (for 16bit Windows 3.1) had no even C++ SEH.

You’ve got me here. I was never a Borland person. I would submit the
above patent as evidence that they at least thought about it, though.
I’m not sure that matters, either.

-sd