ntdev-digest Friday, October 24 1997 Volume 01 : Number 342 ---------------------------------------------------------------------- Date: Thu, 23 Oct 1997 12:37:45 -0700 From: Dave Cox Subject: Re: Question on CreateFile You're granting only read sharing with the first open, but asking for write access in your second call. This would definitely be a problem opening an actual file. Interestingly, we open multiple handles to our driver, with NO sharing granted. This apparently works because we create the device object with the Exclusive parameter to IoCreateDevice set to FALSE. Also, call GetLastError() to see what the system says went wrong. deviceHandle = CreateFile( "\\\\.\\ourdriver", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ); if (deviceHandle == INVALID_HANDLE_VALUE) DWORD lasterr = GetLastError(); Dave Cox Miramar Systems Kolte, Harshad wrote: > > Hi guys, > > I am writing a parallel port driver. I need to open two handles to the > driver because two separate applications need to communicate with the > driver. But the second CreateFile always fails. > I use the following command to CreateFile: > > hNtD = CreateFile( > "\\\\.\\TRANSPORTER1", > GENERIC_READ | GENERIC_WRITE, > FILE_SHARE_READ, > NULL, > OPEN_EXISTING, > FILE_ATTRIBUTE_NORMAL, > NULL ); > > Anyone have any suggestions ?? > > Thanx in advance, > Harshad > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > [ To unsubscribe, send email to ntdev-request@atria.com with body > UNSUBSCRIBE (the subject is ignored). ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] ------------------------------ Date: Thu, 23 Oct 1997 15:45:08 -0400 From: ess013@comm.mot.com Subject: RE: finding all serial ports Thanks for all the responses! IoQueryDeviceDescription does the job (although it isn't pretty) and so does querying the registry. I have a gut feeling that using IoQueryDeviceDescription would be "safer" than counting on the information being in a particular location in the registry, but for various reasons I would rather use the registry lookup. I guess, my question is whether anyone has any thoughts on whether it really is significantly safer to use IoQueryDeviceDescription? Sherri Scharf Software Engineer Motorola, Land Mobile Products Sector Plantation, Florida >---------- >From: Vincent Goossens[SMTP:goossens@epc.be] >Sent: Tuesday, October 21, 1997 2:59 AM >To: ntdev@atria.com >Subject: Re: finding all serial ports > >From user mode, try QueryDosDevice(). >From kernel mode, try IoQueryDeviceDescription(). > >Vincent Goossens goossens@epc.be >European Peripheral Corp. > >---------- >> From: ess013@comm.mot.com >> To: ntdev@atria.com >> Subject: finding all serial ports >> Date: Monday, October 20, 1997 11:37 PM >> >> Hi, >> >> I am trying to figure out the simplest and safest method for finding the >> names of all of the serial ports in the system in order to respond to a >> client query (via IOCTL) for this information. There does not seem to be >> any automatic way of doing this. >> >> Poking around in the ddk documentation and code a few ways have occurred >> to me, my favorite of which is: >> >> If I use IoGetConfigurationInformation to get the number n of serial >> ports, then since the serial port driver uses the COM prefix on its >> symbolic links, I can count on the serial ports being COM1 through COMn? >> >> Anyone have any comments on the advisability of this method or >> suggestions of a better way? >> >> TIA for any help!! >> Sherri >> >> Sherri Scharf >> Software Engineer >> Motorola, Land Mobile Products Sector >> Plantation, Florida >> Phone: (954)723-6878 Fax: (954)723-4327 >> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >> [ To unsubscribe, send email to ntdev-request@atria.com with body >> UNSUBSCRIBE (the subject is ignored). ] > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >[ To unsubscribe, send email to ntdev-request@atria.com with body >UNSUBSCRIBE (the subject is ignored). ] > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] ------------------------------ Date: Thu, 23 Oct 1997 13:34:12 -0700 From: Arnab Bhaduri Subject: RE: dll problem > Static Library (staticlib.lib) contains function do_static_lib_init() and > a static variable initialized. > Dynamic Library (dynamiclib.dll) contains function do_dynamic_lib_init(). This > function makes a call to do_static_lib_init(). > Application (myapp) which calls do_static_lib_init() and do_dynamic_lbi_init(). > It appears that both the application (myapp) and dynamic library has its own > copy of the static library (staticlib.lib). You're right, both the exe and the dll have the static lib linked into them. I presume that you do not have a dll version of the static library available. The problem is that not only do you have two copies of the code, you also have two copies of the static lib's data. You could try to build a dll "wrapper" for the static lib, but this may not be feasible or convenient. I suggest you instead try to convert your dll into a static lib. This way only one copy of will exist in your app. You will increase memory usage if the dll is being used by more than one app, but on the other hand you will eliminate one copy of staticlib from each app - it's quite possible that the staticlib is larger than the rest of the code in your dll. Hope this helps, Arnab - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] ------------------------------ Date: Thu, 23 Oct 1997 16:54:20 -0400 From: ess013@comm.mot.com Subject: RE: Question on CreateFile I think if you only allow FILE_SHARE_READ, but then for the second handle you try to open with GENERIC_READ|GENERIC_WRITE, you are going to have a problem. Try either allowing FILE_SHARE_WRITE as well as read, or not asking for GENERIC_WRITE permission the second time. hth, Sherri Sherri Scharf Software Engineer Motorola, Land Mobile Products Sector Plantation, Florida >---------- >From: Kolte, Harshad[SMTP:kolte@wg.com] >Sent: Thursday, October 23, 1997 11:15 AM >To: 'ntdev@atria.com' >Subject: Re: Question on CreateFile > >Hi guys, > >I am writing a parallel port driver. I need to open two handles to the >driver because two separate applications need to communicate with the >driver. But the second CreateFile always fails. >I use the following command to CreateFile: > >hNtD = CreateFile( > "\\\\.\\TRANSPORTER1", > GENERIC_READ | GENERIC_WRITE, > FILE_SHARE_READ, > NULL, > OPEN_EXISTING, > FILE_ATTRIBUTE_NORMAL, > NULL ); > >Anyone have any suggestions ?? > >Thanx in advance, >Harshad > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >[ To unsubscribe, send email to ntdev-request@atria.com with body >UNSUBSCRIBE (the subject is ignored). ] > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] ------------------------------ Date: Thu, 23 Oct 1997 14:03:29 -0700 From: Jan Bottorff Subject: Re: Hi-polling rates in an NT driver At 12:58 PM 10/23/97 -0400, H.Vidal wrote: >Ongoing discussion: max poll rates under NT driver. >... >You drive this device with some sort of clock, at low frequency 10-300 >Hz. At each clock transition (each clock cycle), the detector loads a >line of data to the memory on the card. Then the card is ready to be >... >That's the rub. Single cards look like a kernel driver with hardware >interrupts would work. But not multiple cards since there is no single >event that flags when all the cards are all "and" ready. Can you put each card on it's own interupt? or a shared interrupt? (ISA devices can share interrupts if hardware is designed correctly and drivers do the right thing). An interrupt rate of 1200/sec is not horribly excessive. That's 4 devices interrupting 300 times/sec. What are the implications of being late servicing the device? A simple retry with no bad effects? a nuclear reactor melts down? It sounds like you may have lots of control over the target hardware configuration. Can you REQUIRE dual processor systems? - - Jan ___________________________________________________________________ Paradigm Matrix, San Ramon California "Development services for Win32 platforms" Internet: Jan Bottorff janb@pmatrix.com WWW http://www.pmatrix.com Phone: voice (510) 803-9318 fax (510) 803-9397 PGP: public key fingerprint 52 CB FF 60 91 25 F9 44 6F 87 23 C9 AB 5D 05 F6 ___________________________________________________________________ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] ------------------------------ Date: Thu, 23 Oct 1997 14:16:36 -0700 From: Jan Bottorff Subject: Re: Passing FILE pointers to DLLs You MUST compile all modules, EXE's, DLL's with the shared C run-time to make this work. The issue is that C run-time file handles are just indexes into a table. If you use the static linked run-time libraries, each EXE and DLL get's it's own copy of this table, so the index will not refer to the correct entry. You FILE * references the correct file structure, it's just the low-level file handles in that structure are passed to something like read, which index a private copy of the handle table, which is a different copy of the handle table than open used in a different module. If you put all file access in the same DLL, things should also be ok, as the private handle table is referenced by all functions in that DLL. - - Jan At 01:36 PM 10/23/97 -0400, Fallows, Steve wrote: >Simple question: (Win32, not strictly NT) > >Can someone explain why I can't fopen a file in my app, >pass the FILE * to a DLL function, then fread it? > >I get an access violation. ___________________________________________________________________ Paradigm Matrix, San Ramon California "Development services for Win32 platforms" Internet: Jan Bottorff janb@pmatrix.com WWW http://www.pmatrix.com Phone: voice (510) 803-9318 fax (510) 803-9397 PGP: public key fingerprint 52 CB FF 60 91 25 F9 44 6F 87 23 C9 AB 5D 05 F6 ___________________________________________________________________ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] ------------------------------ Date: Thu, 23 Oct 1997 17:40:06 -0400 From: "H.Vidal" Subject: Re: Hi-polling rates in an NT driver Jan Bottorff wrote: > > Can you put each card on it's own interupt? or a shared interrupt? (ISA > devices can share interrupts if hardware is designed correctly and drivers > do the right thing). I assume you are asking if the interrupt signals off these cards are open collector, in which case you can wire-or? I don't know. I am not sure how this would help. Yes, you have the cards being serviced by a single interrupt service routine, then the ISR has to determine which card interrupted, but I am not sure that you are still defeating the non-synchronous nature of "ready to read state" in these puppies. > An interrupt rate of 1200/sec is not horribly > excessive. That's 4 devices interrupting 300 times/sec. I spoke with someone today that suggested IRQ rates in these devices in excess of 100 hz as being excessive. Maybe someone else here can counter. Under NT, that is. > What are the implications of being late servicing the device? A simple > retry with no bad effects? a nuclear reactor melts down? No, no reactors, but these are being used to monitor/examine nuclear waste from warhead manufacturing. A missed interrupt or scan line means that a scan line will be missing from the resulting image. Not fatal (as in does not kill anyone), but then useless as the image will immediately be affected. > It sounds like you may have lots of control over the target hardware > configuration. Can you REQUIRE dual processor systems? Maybe, you mean dual Intel chips. Are you suggesting that you can tie one CPU to servicing I/O and another to just running the box? hvidal@i-2000.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] ------------------------------ Date: Fri, 24 Oct 1997 01:40:40 +0400 From: "Kirill M. Katsnelson" Subject: Off-topic C++ language question... Hi there, I understand that a question of this kind is off-topic here, but you guys on the list are all C experts anyways. Please be kind, ok? Here's my situation. A class C has a member variable of struct type S, which in turn has a member of type "pointer to member function in C". The code that is syntactically incorrect is: class C; typedef BOOL (C::*PTR_TO_FN_IN_C)(void); struct S { PTR_TO_FN_IN_C fptr; int moremembers; }; class C { ... S s; }; I tried [m]any (any or many?) combination(s) of forward declarations etc. In the above case, typedef fails as C is not decalred yet. Other combinaions give other errors (I agree with the compiler in every case except for the above, because at the time of compiling of the above typedef the compiler really needs _no_ information anout the class C - a pointer is just four bytes of memory to allocate, right?). What's the right combination, anyways? Play poker? TIA, Kirill +-------------------------------------+-----------------------------------+ + Kirill M. Katsnelson, | Welcome! My WebCounter shows + + Software and Networking Consultant | that you are Abnormal program + + Nizhni Novgorod, Russia | termination in 1997! + + E-mail: kkm@kis.ru | -- a real welcome banner + +-------------------------------------+-----------------------------------+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] ------------------------------ Date: Thu, 23 Oct 1997 18:29:40 PST From: "John McNamee" Subject: RE: finding all serial ports On 23 Oct 97 at 15:45, ess013@comm.mot.com wrote: > Thanks for all the responses! > > IoQueryDeviceDescription does the job (although it isn't pretty) and so > does querying the registry. I have a gut feeling that using > IoQueryDeviceDescription would be "safer" than counting on the > information being in a particular location in the registry, but for > various reasons I would rather use the registry lookup. I guess, my > question is whether anyone has any thoughts on whether it really is > significantly safer to use IoQueryDeviceDescription? IoQueryDeviceDescription() will only report devices that NTDETECT discovered during boot. That will exclude most non-standard serial devices. - ------------------------------------------------------------------------------ John McNamee Voice: 847-364-9200 http://www.igcinc.com FAX: 847-593-2790 - ------------------------------------------------------------------------------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] ------------------------------ Date: Thu, 23 Oct 1997 17:41:16 -0700 From: Richard Hartman Subject: Re: Passing FILE pointers to DLLs >>Can someone explain why I can't fopen a file in my app, >>pass the FILE * to a DLL function, then fread it? >>I get an access violation. > >One way I know you can get into trouble doing this sort of thing is if the >DLL and the app calling the DLL are binding to different instances (perhaps >even different _versions_ of the C runtime library DLL). So use the Win32 functions CreateFile, ReadFile, and WriteFile. They do not suffer from the single-threaded nature of the RTL, and you can safely pass their file handles between your code and a DLL. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] ------------------------------ Date: Thu, 23 Oct 1997 18:18:57 -0700 From: Arnab Bhaduri Subject: RE: Hi-polling rates in an NT driver > Jan Bottorff wrote: >> >> Can you put each card on it's own interupt? or a shared interrupt? (ISA >> devices can share interrupts if hardware is designed correctly and drivers >> do the right thing). > I assume you are asking if the interrupt signals off these cards are > open collector, in which case you can wire-or? I don't know. I guess what Jan is asking is whether you can set each card to use a different IRQ. ISA cards typically can be set to use one of a set of IRQs - suppose you set your four cards to IRQs 5, 7, 9, and 10. Since yours appears to be a dedicated system you might be able to find four free IRQs to use. If this were possible, you could then wait for each card to interrupt, collect the data, and put it in an intermediate buffer. Once you have all four pieces, assemble them together and send off your sample. You could still have a single interrupt routine. > I spoke with someone today that suggested IRQ rates in these devices in > excess of 100 hz as being excessive. Maybe someone else here can > counter. Under NT, that is. If this means that your devices will not interrupt more than 100 times a second, then you don't need to worry. > No, no reactors, but these are being used to monitor/examine nuclear > waste from warhead manufacturing. A missed interrupt or scan line means > that a scan line will be missing from the resulting image. Not fatal (as > in does not kill anyone), but then useless as the image will immediately > be affected. This is just plain curiosity on my part, but just how vital is this monitoring system to the safety of the whole setup ? What happens when this machine hangs, for example ? The thought of a PC running NT monitoring _nuclear waste_ makes me just a little apprehensive. Hope this helps, Arnab - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] ------------------------------ Date: Thu, 23 Oct 1997 18:48:44 -0700 From: Peter Craft Subject: Windbg .reboot not working I'm trying to set myself up for remote NT kernel debugging using a combination of windbg and pcAnywhere (that is, I pcAnywhere into both my windbg target and windbg host from home). This works fine until I experience a kernel panic. Obviously once that happens I can't reboot my target machine in the normal fashion, and since I'm not sitting near it, I can't hit reset either. So I'm trying to get the .reboot command of windbg to work, but when I use it I get the expected series of module unload message and then the monitor attached to my target machine gets funny looking (like its sort of stuck between the windows screen and the BIOS screen), and it hangs. Unfortunately I have not idea where it is hung since windbg has since given up control. Has anyone seen this? Any suggestions on how to solve it? Thanks - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] ------------------------------ Date: Thu, 23 Oct 1997 20:17:29 -0700 From: Naren Bhat Subject: RE: finding all serial ports Sherri, The most reliable way that I have found to find all serial ports is under 1. HLKM\HARDWARE\DEVICEMAP\SERIALCOMM where you find the COM enumerators and 2. HKLM\SYSTEM\CurrentControlSet\Services\Serial\Parameters where you find the actual resources (Port, IRQ) associated with the port. If there are no entries under this section, then we believed that it was safe to assume that the ports have standard resources associated with them. (COM1 = 3F8 IR4, COM2 = 2F8 IRQ3, COM3 = 3E8 IRQ4, COM4 = 2E8 IRQ3). If there are non-standard COM enumerators under registry key 1 (for ports >= COM5), then you will find all resource details for these ports under registry key 2. But under certain systems where it is possible to go to the BIOS and change the resources, I have seen that the Serial driver gets confused and fails to find the port at the new address. Say for example, you had 2 COM ports in the system at standard addresses and you move them to say 3E8 and 2E8 respectively for COM1 and COM2, then the serial driver fails to start. The best place to look for these ports is in the BIOS data area 400:0. 400:0 will have address for COM1, 400:2 for COM2 and so on till COM4. Hope this helps, - -Naren ---------- From: ess013@comm.mot.com[SMTP:ess013@comm.mot.com] Sent: Thursday, October 23, 1997 12:45 PM To: ntdev@atria.com Subject: RE: finding all serial ports Thanks for all the responses! IoQueryDeviceDescription does the job (although it isn't pretty) and so does querying the registry. I have a gut feeling that using IoQueryDeviceDescription would be "safer" than counting on the information being in a particular location in the registry, but for various reasons I would rather use the registry lookup. I guess, my question is whether anyone has any thoughts on whether it really is significantly safer to use IoQueryDeviceDescription? Sherri Scharf Software Engineer Motorola, Land Mobile Products Sector Plantation, Florida >---------- >From: Vincent Goossens[SMTP:goossens@epc.be] >Sent: Tuesday, October 21, 1997 2:59 AM >To: ntdev@atria.com >Subject: Re: finding all serial ports > >From user mode, try QueryDosDevice(). >From kernel mode, try IoQueryDeviceDescription(). > >Vincent Goossens goossens@epc.be >European Peripheral Corp. > >---------- >> From: ess013@comm.mot.com >> To: ntdev@atria.com >> Subject: finding all serial ports >> Date: Monday, October 20, 1997 11:37 PM >> >> Hi, >> >> I am trying to figure out the simplest and safest method for finding the >> names of all of the serial ports in the system in order to respond to a >> client query (via IOCTL) for this information. There does not seem to be >> any automatic way of doing this. >> >> Poking around in the ddk documentation and code a few ways have occurred >> to me, my favorite of which is: >> >> If I use IoGetConfigurationInformation to get the number n of serial >> ports, then since the serial port driver uses the COM prefix on its >> symbolic links, I can count on the serial ports being COM1 through COMn? >> >> Anyone have any comments on the advisability of this method or >> suggestions of a better way? >> >> TIA for any help!! >> Sherri >> >> Sherri Scharf >> Software Engineer >> Motorola, Land Mobile Products Sector >> Plantation, Florida >> Phone: (954)723-6878 Fax: (954)723-4327 >> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >> [ To unsubscribe, send email to ntdev-request@atria.com with body >> UNSUBSCRIBE (the subject is ignored). ] > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >[ To unsubscribe, send email to ntdev-request@atria.com with body >UNSUBSCRIBE (the subject is ignored). ] > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] ------------------------------ End of ntdev-digest V1 #342 *************************** - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-digest-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ]