Re: problem using sdk

Tech-Archive recommends: Fix windows errors by optimizing your registry



mark wrote:
Jim Mack <jmack@xxxxxxxxxxxxxxx> wrote on Mon, 26 May 2008 18:17:46


Here's a perfect example of how translating from C can be a
minefield.

Without knowing what SECBANKDLL_API and SB_CALLMODE are,
especially the latter, you can't be sure that the DLL uses
stdcall, which is vital for correct operation with VB. Find the
definitions for those and post them, for completeness.
Here is the text from the header file:

Aside from that line-wrapped mess of prototypes, it looks OK.

From the comments, SECBANKDLL_EXPORTS will be defined on the compiler
command line, which makes the call equivalent to:

extern "C" __declspec(dllexport) UINT __stdcall SecBank_Create...

Which ought to be fine for VB.

--
Jim







//--------------------------------------------------------------------
---------
-----------------------
//
// Company: BiometriKa s.r.l. - www.biometrika.it
// E-mail: info@xxxxxxxxxxxxx
//
// Copyright(C) 2006, Biometrika s.r.l.
// All rights reserved.
//
//

//--------------------------------------------------------------------
---------
-----------------------

#ifndef __SECBANK
#define __SECBANK

// The following ifdef block is the standard way of creating macros
which make exporting
// from a DLL simpler. All files within this DLL are compiled with
the SECBANKDLL_EXPORTS
// symbol defined on the command line. this symbol should not be
defined on any project
// that uses this DLL. This way any other project whose source
files include this file see
// SECBANKDLL_API functions as being imported from a DLL, whereas
this DLL sees symbols
// defined with this macro as being exported.

#ifndef FXDLL_LINUX
// win32
#ifdef SECBANKDLL_EXPORTS
#define SECBANKDLL_API extern "C" __declspec(dllexport)
#else
#define SECBANKDLL_API
#endif

#define SB_CALLMODE __stdcall

#else
//Linux
#define SECBANKDLL_API
#define SB_CALLMODE
#endif



#ifdef __cplusplus
extern "C" {
#endif

//It's used to indicate the device where the SecBank is to be found
typedef enum
{
FlashScanner = 1,
SmartCard = 2
} Device;

#define MAX_PIN_LEN 32

#define NULL_ID_SECBANK 0
#define PIN_PROTECTION 1
#define MODEL_PROTECTION 2

//----------------------------------- Types
-----------------------------------
----------
typedef unsigned char BYTE;
typedef unsigned short int WORD;
typedef unsigned long DWORD;
typedef unsigned int UINT;
typedef int BOOL;


//--------------------------------------------------------------------
---------
---------

//--------------------------------- Functions
---------------------------------
---------
SECBANKDLL_API UINT SB_CALLMODE SecBank_GetLastError();

SECBANKDLL_API UINT SB_CALLMODE SecBank_Init (); //Library
initialization SECBANKDLL_API UINT SB_CALLMODE SecBank_End ();
//Library deallocation SECBANKDLL_API UINT SB_CALLMODE
SecBank_SetPort (DWORD port); //Sets a scanner port (the default
is 200, for standard Fx3000)

SECBANKDLL_API UINT SB_CALLMODE SecBank_GetFirstPublic (DWORD
IDSecBank, DWORD IDAppl, WORD *IDEntry, BYTE *Public, DWORD
*lenPublic); //Returns the first public Entry related to the given
application ID SECBANKDLL_API UINT SB_CALLMODE
SecBank_GetNextPublic (DWORD IDSecBank, DWORD IDAppl, WORD
*IDEntry, BYTE *Public, DWORD *lenPublic); //Returns the next
public Entry related to the given application ID SECBANKDLL_API
UINT SB_CALLMODE SecBank_GetPrivate (DWORD IDSecBank, WORD IDEntry,
BYTE *Private, DWORD *lenPrivate); //Returns the private data
related to the given Entry SECBANKDLL_API UINT SB_CALLMODE
SecBank_NewEntry (DWORD IDSecBank, DWORD IDAppl, WORD *IDEntry,
BYTE *Public, DWORD lenPublic, BYTE *Private, DWORD lenPrivate);
//Insert a new Entry in the SecBank currentrly on RAM and returns
the ID of the new Entry SECBANKDLL_API UINT SB_CALLMODE
SecBank_ModifyEntry (DWORD IDSecBank, WORD IDEntry, BYTE *Public,
DWORD lenPublic, BYTE *Private, DWORD lenPrivate); //Modifies
public and private data of the given Entry SECBANKDLL_API UINT
SB_CALLMODE SecBank_DeleteEntry (DWORD IDSecBank, WORD IDEntry);
//Deletes the specified Entry from the RAM SECBANKDLL_API UINT
SB_CALLMODE SecBank_DeleteAllEntry (DWORD IDSecBank, DWORD IDAppl);
//Deletes all the Entries of a given application from the RAM
SECBANKDLL_API UINT SB_CALLMODE SecBank_Save (DWORD IDSecBank);
//Saves the SecBank currentrly on the RAM of the device
SECBANKDLL_API UINT SB_CALLMODE SecBank_Open (Device Disp, char
*fileName, DWORD *IDSecBank, BYTE *Pin, DWORD lenPin); //Loads in
RAM the specified SecBank and returns the related ID SECBANKDLL_API
UINT SB_CALLMODE SecBank_Create (Device Disp, char *fileName, DWORD
*IDSecBank, BYTE *Pin, DWORD lenPin); //Creates a new SecBank
on the scanner RAM SECBANKDLL_API UINT SB_CALLMODE SecBank_Clone
(Device Disp, char *fileName, DWORD IDSecBank, BYTE *Pin, DWORD
lenPin); //Clonate the SecBank currentrly in RAM saving it on the
selected device SECBANKDLL_API UINT SB_CALLMODE SecBank_RAMDelete
(BOOL ForceDelete); //Erases the opened SecBank from the scanner RAM
SECBANKDLL_API UINT SB_CALLMODE SecBank_Delete (Device Disp, char
*fileName); //Erases the specified SecBank from the device
SECBANKDLL_API UINT SB_CALLMODE SecBank_StartEnrollModel(DWORD
IDSecBank, BYTE *Model, DWORD lenModel); //Acquires a new model for
the current SecBank SECBANKDLL_API UINT SB_CALLMODE
SecBank_EndEnrollModel(DWORD IDSecBank); //Stores the model
acquired with StartEnrollModel on the current SecBank
SECBANKDLL_API UINT SB_CALLMODE SecBank_TestModel(DWORD IDSecBank,
BYTE *Model, DWORD lenModel, float *score); //Returns a matching
score between the model on the SecBank and the given (or acquired)
model SECBANKDLL_API UINT SB_CALLMODE SecBank_SetThreshold(DWORD
IDSecBank, float threshold); //Sets the matching threshold
SECBANKDLL_API UINT SB_CALLMODE SecBank_GetThreshold(DWORD
IDSecBank, float *threshold); //Gets the current matching threshold
SECBANKDLL_API UINT SB_CALLMODE SecBank_DeleteModel (DWORD
IDSecBank); //Deletes the model from the current SecBank
SECBANKDLL_API UINT SB_CALLMODE SecBank_GetModel (DWORD IDSecBank,
BYTE *Model, DWORD *lenModel); //Returns the model stored on the
current SecBank SECBANKDLL_API UINT SB_CALLMODE SecBank_GetFileList
(Device Disp, BYTE *fileList, DWORD *lenList); //Gets a list of
Secrets Banks on the device SECBANKDLL_API UINT SB_CALLMODE
SecBank_SetPin (DWORD IDSecBank, BYTE *OldPin, DWORD lenOldPin,
BYTE *NewPin, DWORD lenNewPin); //Update the current SecBank PIN
SECBANKDLL_API UINT SB_CALLMODE SecBank_SetTimeout (DWORD
IDSecBank, DWORD Timeout); //Sets the current SecBank timeout
SECBANKDLL_API UINT SB_CALLMODE SecBank_GetTimeout (DWORD
IDSecBank, DWORD *Timeout); //Gets the current SecBank timeout
SECBANKDLL_API UINT SB_CALLMODE SecBank_Lock (DWORD IDSecBank);
//Locks the currrent SecBank: a new PIN verification would be
needed SECBANKDLL_API UINT SB_CALLMODE SecBank_Unlock (DWORD
IDSecBank, BYTE *Pin, DWORD lenPin); //Unlocks the current SecBank
if it was previously locked or the timeout expired SECBANKDLL_API
UINT SB_CALLMODE SecBank_GetIDSecBank (DWORD *IDSecBank, BYTE *Pin,
DWORD lenPin); //Return the ID of the current SecBank on RAM
SECBANKDLL_API UINT SB_CALLMODE SecBank_GetInfoCurrentSecBank
(Device *Disp, char *fileName, DWORD *lenFileName, BYTE *security);
//Returns info on the curretn SecBank: device, filename and
security attributes

SECBANKDLL_API UINT SB_CALLMODE SecBank_DetectCard (); //Check the
presence of a Smart Card in the reader
SECBANKDLL_API UINT SB_CALLMODE SecBank_FormatCard (BYTE mode, BYTE
auth_mode, BYTE enc_mode, BYTE extraAuth[32]); //Formats the
SmartCard in the reader SECBANKDLL_API UINT SB_CALLMODE
SecBank_FormatCardDlg(BYTE cardID[10]); //Formats the SmartCard.
Displays an user interface SECBANKDLL_API UINT SB_CALLMODE
SecBank_GetCardInfo (BYTE extraAuth[32], int *status, BYTE
*cardType, BYTE cardID[10], BYTE *idLen, WORD *freeSize, BYTE *app,
BYTE *auth_mode, BYTE *enc_mode, WORD *FSVersion, BYTE *numEntry,
BYTE *templateAval);

//--------------------------------------------------------------------
---------
---------

//-------------------------------- Application ID
-----------------------------
---------
#define IDAppSecBank 1
#define IDAppLogon 2
#define IDAppReserved3 3
#define IDAppReserved4 4
#define IDAppReserved5 5
#define IDAppReservedLast 100
//Applications ID > 100 are available for user applications

//----------------------------------- Errors
----------------------------------
---------

#define errSBSuccess
0 #define errSBNoCard
1 #define errSBNoSecBank
2 #define errSBNoFile
3 #define errSBNoDevice
4 #define errSBNoCheckUser
5 #define errSBNoModel
6 #define errSBModifiedSB
7 #define errSBAccessDenied
8 #define errSBSecBankOnSC
9 #define errSBNoFormattedCard 10
#define errSBInputParameter
11 #define errSBOutputParameter
12 #define errSBNoMemoryLeft
13 #define errSBDeviceConnection
14 #define errSBFingerprintAcquisition 15
#define errSBTimeOut
16 #define errSBNoPin
17 #define errSBNoEntry
18 #define errSBCrypto
19 #define errSBSecBankAlreadyExist 20
#define errSBModelNotEnrolled 21
#define errSBModelWrong
22 #define errSBOperationCancelled 23
#define errSBCardFull
24 #define errSBWrongCard
25

#define errSBUnknown
40

// Blocking errors
#define errSBInternalError
101 #define errSBUnableToSave
102 #define errSBUnableToLoad
103

#define errSBMatchErrorBase
150 #define errSBAGIStep
300 #define errSBEGIStep
301

//Base error for the fingerprint acquisition routine
#define errSBFingerPrintAcquisitionPlus 1000

#ifdef __cplusplus
}
#endif

#endif

.



Relevant Pages

  • Re: problem using sdk
    ... SECBANKDLL_API UINT SB_CALLMODE SecBank_GetFirstPublic (DWORD IDSecBank, ... //Insert a new Entry in the SecBank currentrly on RAM and returns ...
    (microsoft.public.vb.winapi)
  • Mangaged to Unmanaged code I2C device access violation issue
    ... in unmanged code in passing PBYTE pBufIn in the function below's signature. ... It is defined as a 4 byte array and the driver code casts this to a DWORD. ... BOOL bRet = FALSE; ... public static uint CTL_CODE(uint DeviceType, uint Function, uint ...
    (microsoft.public.dotnet.framework.interop)
  • Re: NotifyIconData versions
    ... Hwnd As Long ... UINT uFlags; ... CHAR szTip; ... DWORD dwState; ...
    (microsoft.public.vb.winapi)
  • Multimedia Timer
    ... void CMyAppDlg::SomeFunctio ... DWORD resolution = min, ... void CALLBACK CMyAppDlgDlg::StartTimer(UINT wTimerID, UINT msg, DWORD ...
    (microsoft.public.vc.mfc)
  • the cbSize problem
    ... Some are UINT, some are DWORD, some are INT, some are ULONG, some are int. ...
    (microsoft.public.vc.mfc)