Google Analytics

Search This Blog

Sunday, April 09, 2017

64-Bit MyKad Reader Application Source Code

First of all, proceed to download the MyKad Reader Application Source Code (VB.NET) for 32-bit from:

http://www.yasin.my/blog/son_mykad_reader

http://mykad.codeplex.com/

The code is meant for 32-bit platform - it is compatible with Visual Studio 2008 onwards.

To support 64-bit platform, a few modifications are required.


The idea is to change all Handle type parameters to IntPtr instead of Int32

Refer to the following image for illustration:


Is that simple, save it and recompile.

I have tested this code and it supports HID Omnikey 3121 smart card reader on Windows 10 Pro 64-bit.

Why IntPtr ?

Refer to the following knowledgebase from Microsoft, it was quoted that:

https://msdn.microsoft.com/en-us/library/ms973190.aspx

Making all data types 64 bits in length would waste space, because most applications do not need the increased size. However, applications do need pointers to 64-bit data, and they need the ability to have 64-bit data types in selected cases. These considerations led the Windows team to select an abstract data model called LLP64 (or P64). In the LLP64 data model, only pointers expand to 64 bits; all other basic data types (integer and long) remain 32 bits in length.

The .NET CLR for 64-bit platforms uses the same LLP64 abstract data model. In .NET there is an integral data type, not widely known, that is specifically designated to hold 'pointer' information: IntPtr whose size is dependent on the platform (e.g., 32-bit or 64-bit) it is running on.

Other relevant discussion threads found in the Internet:

1.) Using the code targeting 32-bit on 64-bit platform, the scardconnect will returns 6 instead of zero.

https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/3efbabeb-ccc7-44c1-b7ed-f4c8e56844ec/help-with-scardconnect-for-vista-64-bit?forum=windowssecurity

2.) http://stackoverflow.com/questions/10635738/error-invalid-handle-in-net-app-with-winscard-dll

3.) Using OpenSC library.

https://github.com/OpenSC/OpenSC/wiki/Malaysian-MyKAD

Dedicated to the spirit of open source and open society - happy coding !!!

No comments: