On 2/3/2011 8:25 PM, Andre Zepezauer wrote: > On Thu, 2011-02-03 at 15:55 -0600, Douglas E. Engert wrote: >> >> On 2/3/2011 3:14 PM, Andre Zepezauer wrote: >>> On Thu, 2011-02-03 at 14:04 -0600, Douglas E. Engert wrote: >>>> I have updates #321 with a new version of the cardmod patch >>>> and would like to start to commit it in pieces. >>>> >>>> Piece 1 is the attachment I sent on 1/28 as new.martin.patch >>>> based on Martin's patch from 1/19. This was the patch that would >>>> work for Brian. The main change is adding two parameters to all >>>> the *_detect_readers routines. Martin's patch already required these >>>> to be added in a number of places. >>>> >>>> Is there any objection to adding this patch now? >>> >>> Yes, why you want to call 'sc_context_create()' altogether. There is not >>> much functionality in it. So you could easily implement the required >>> initialisation in 'CardAcquireContext()'. >> >> I disagree there is a lot of functionality in it. It main functions is to >> read the config files, and other initialization needed by OpenSC, and that >> is more then enough to justify calling it. > > I got it. The whole file ctx.c is basically one single function, that is > scattered into a lot of small functions, which are mostly called once. > The fact that most of these functions are 'static' makes it even more > interesting. So, it seem that calling 'sc_context_create()' is really > required. > > There is still the option to separate reader-pcsc and reader-cardmod. > That this would be the best solution shows the following example: > > 1. A Mini-Driver doesn't need to detect readers at all. Thus it should > define "driver->ops->detect_readers = NULL". That's the trick.
The trick the cardmod code is using is the detect_readers is setting up a reader to use the handles provided by the BaseCSP. But it is trying to pass the handles via the registry in HKLM. This will not work as multiple contexts maybe initialized at the same time by the same process using multiple threads. Or by a process run under the user who does not have rights to update the HKLM. HKCU can not be used either, as during login there is no current user. > 2. Looking at 'detect_readers' of the current driver looks like rocket > science [1]. IMO there is something fundamentally wrong. Yes as I have said over the last two week, the detect_readers should not be using the registry, and the mega patch removes this code in favor or cardmod calling sc_ctx_detect_readers(ctx, pcsc_context_handle,pcsc_card_handle) This then provides the 2 handles provided by the BaseCSP to cardmod_detect_readers. Cardmod_detect_readers then used these to create a single reader, and does what ever else is needed. sc_ctx_detect_readers can be called to reset the handles of needed. Rather then using the detect_reader, some other entry point in to the cardmod pcsc code could be used to do the same thing, maybe cardmod.c could call this directly bypassing the need to call sc_ctx_detect_readers, and ops->detect_readers == NULL could be used. > > Regards > Andre > > [1] > http://www.opensc-project.org/opensc/browser/trunk/src/libopensc/reader-pcsc.c#L1662 > > > -- Douglas E. Engert <deeng...@anl.gov> Argonne National Laboratory 9700 South Cass Avenue Argonne, Illinois 60439 (630) 252-5444 _______________________________________________ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel