/////////////////////////////////////////////////////////////// // PROTOTYPES /////////////////////////////////////////////////////////////// int ( __stdcall *pfnFFGCR121StartComm )( int ); void ( __stdcall *pfnFFGCR121StopComm )( void ); int ( __stdcall *pfnFFGCR121Reset )( void ); char* ( __stdcall *pfnFFGCR121FirmVers )( void ); int ( __stdcall *pfnFFGCR121DisRosComp )( void ); int ( __stdcall *pfnFFGPC410Led )( int ); /////////////////////////////////////////////////////////////// // SECTION 1: LOAD THE DLL AND ITS FUNCTIONS /////////////////////////////////////////////////////////////// // jan 26th, 2004: thanks to Paolo, from Chile, a bug was fixed (the name of // the DLL was wrong... now it is has been corrected // load FFGCR121.DLL FFGCR121DllHandle = 0; FFGCR121DllHandle = LoadLibrary ( "FFGCR121.DLL" ); if ( FFGCR121DllHandle == 0 ) { MessageBox ( NULL, "LoadLibrary:\nFFGCR121.DLL not found.", "Error FS 001", MB_SYSTEMMODAL ); return; } // load address of FFGCR121StartComm pfnFFGCR121StartComm = ( int ( __stdcall *)( int ) ) GetProcAddress ( FFGCR121DllHandle, "FFGCR121StartComm" ); if ( pfnFFGCR121StartComm == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFGCR121StartComm not found.", "Error FS 003", MB_SYSTEMMODAL ); return; } // load address of FFGCR121StopComm pfnFFGCR121StopComm = ( void ( __stdcall *)( void ) ) GetProcAddress ( FFGCR121DllHandle, "FFGCR121StopComm" ); if ( pfnFFGCR121StopComm == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFGCR121StopComm not found.", "Error FS 003", MB_SYSTEMMODAL ); return; } // load address of FFGCR121Reset pfnFFGCR121Reset = ( int ( __stdcall *)( void ) ) GetProcAddress ( FFGCR121DllHandle, "FFGCR121Reset" ); if ( pfnFFGCR121Reset == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFGCR121Reset not found.", "Error FS 003", MB_SYSTEMMODAL ); return; } // load address of FFGCR121FirmVers pfnFFGCR121FirmVers = ( char* ( __stdcall *)( void ) ) GetProcAddress ( FFGCR121DllHandle, "FFGCR121FirmVers" ); if ( pfnFFGCR121FirmVers == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFGCR121FirmVers not found.", "Error FS 003", MB_SYSTEMMODAL ); return; } // load address of FFGCR121DisRosComp pfnFFGCR121DisRosComp = ( int ( __stdcall *)( void ) ) GetProcAddress ( FFGCR121DllHandle, "FFGCR121DisRosComp" ); if ( pfnFFGCR121DisRosComp == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFGCR121DisRosComp not found.", "Error FS 003", MB_SYSTEMMODAL ); return; } // load address of FFGPC410Led pfnFFGPC410Led = ( int ( __stdcall *)( int ) ) GetProcAddress ( FFGCR121DllHandle, "FFGPC410Led" ); if ( pfnFFGPC410Led == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFGPC410Led not found.", "Error FS 003", MB_SYSTEMMODAL ); return; } // load address of FFGPM2KSetCardType pfnFFGPM2KSetCardType = ( int ( __stdcall *)( void ) ) GetProcAddress ( FFGCR121DllHandle, "FFGPM2KSetCardType" ); if ( pfnFFGPM2KSetCardType == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFGPM2KSetCardType not found.", "Error FS 003", MB_SYSTEMMODAL ); return; } // load address of FFGPM2KCardPowerUp pfnFFGPM2KCardPowerUp = ( int ( __stdcall *)( void ) ) GetProcAddress ( FFGCR121DllHandle, "FFGPM2KCardPowerUp" ); if ( pfnFFGPM2KCardPowerUp == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFGPM2KCardPowerUp not found.", "Error FS 003", MB_SYSTEMMODAL ); return; } // load address of FFGPM2KCardPowerDn pfnFFGPM2KCardPowerDn = ( int ( __stdcall *)( void ) ) GetProcAddress ( FFGCR121DllHandle, "FFGPM2KCardPowerDn" ); if ( pfnFFGPM2KCardPowerDn == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFGPM2KCardPowerDn not found.", "Error FS 003", MB_SYSTEMMODAL ); return; } // load address of FFGPM2KChkSecrCode pfnFFGPM2KChkSecrCode = ( int ( __stdcall *)( char* ) ) GetProcAddress ( FFGCR121DllHandle, "FFGPM2KChkSecrCode" ); if ( pfnFFGPM2KChkSecrCode == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFGPM2KChkSecrCode not found.", "Error FS 003", MB_SYSTEMMODAL ); return; } // load address of FFGPM2KSetSecrCode pfnFFGPM2KSetSecrCode = ( int ( __stdcall *)( char* ) ) GetProcAddress ( FFGCR121DllHandle, "FFGPM2KSetSecrCode" ); if ( pfnFFGPM2KSetSecrCode == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFGPM2KSetSecrCode not found.", "Error FS 003", MB_SYSTEMMODAL ); return; } // load address of FFGPM2KRead pfnFFGPM2KRead = ( char* ( __stdcall *)( int, int ) ) GetProcAddress ( FFGCR121DllHandle, "FFGPM2KRead" ); if ( pfnFFGPM2KRead == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFGPM2KRead not found.", "Error FS 003", MB_SYSTEMMODAL ); return; } // load address of FFGPM2KWrite pfnFFGPM2KWrite = ( int ( __stdcall *)( int, int, char* ) ) GetProcAddress ( FFGCR121DllHandle, "FFGPM2KWrite" ); if ( pfnFFGPM2KWrite == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFGPM2KWrite not found.", "Error FS 003", MB_SYSTEMMODAL ); return; } /////////////////////////////////////////////////////////////// // SECTION 2: CALL THE FUNCTIONS /////////////////////////////////////////////////////////////// // initialize the serial port int rc; rc = pfnFFGCR121StartComm ( 1 ); // 1 = COM1 // restart the reader rc = pfnFFGCR121Reset ( ); // check the firmware version of the reader char* firmVers; firmVers = pfnFFGCR121FirmVers ( ); // play with the LED of the reader rc = pfnFFGPC410Led ( 0 ); // turn off rc = pfnFFGPC410Led ( 2 ); // blink rc = pfnFFGPC410Led ( 1 ); // turn on // disable ROS compatibility (unuseful) rc = pfnFFGCR121DisRosComp ( ); // set cart type = GPM2K rc = pfnFFGPM2KSetCardType ( ); // check card presence and power up it rc = pfnFFGPM2KCardPowerUp ( ); // 251 = no smart card into reader // present the Card Secret Code char secretCode [ 3 ]; secretCode [ 0 ] = 0xAA; secretCode [ 1 ] = 0xAA; secretCode [ 2 ] = 0xAA; rc = pfnFFGPM2KChkSecrCode ( secretCode ); // set a new CSC secretCode [ 0 ] = 0xBB; secretCode [ 1 ] = 0xBB; secretCode [ 2 ] = 0xBB; rc = pfnFFGPM2KSetSecrCode ( secretCode ); // write "foo bar" at address 32 char writeData [ 34 ]; strcpy ( writeData, "foo bar" ); rc = pfnFFGPM2KWrite ( 32, 7, writeData ); // read 7 bytes at address 32 char* readData; readData = pfnFFGPM2KRead ( 32, 7 ); // power off the card rc = pfnFFGPM2KCardPowerDn ( ); // free the serial port pfnFFGCR121StopComm ( ); /////////////////////////////////////////////////////////////// // SECTION 3: UNLOAD THE DLL /////////////////////////////////////////////////////////////// // free the DLL if ( FFGCR121DllHandle != 0 ) FreeLibrary ( FFGCR121DllHandle );}