- more win32 fixes from Stef

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@779 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
okir 2002-12-17 16:00:40 +00:00
parent 96c953c5a3
commit 29dd06ba9f
6 changed files with 62 additions and 7 deletions

View File

@ -1,5 +1,5 @@
SUBDIRS = include common scconf libopensc tests scrandom pkcs15init tools pkcs11
SUBDIRS = include common scconf libopensc tests scrandom pkcs15init pkcs11 tools
all::

View File

@ -1,15 +1,25 @@
TOPDIR = ..\..
HEADERS = pkcs11.h
HEADERSDIRFROM2 = rsaref
HEADERSDIR = $(TOPDIR)/src\include\opensc
HEADERSDIR2 = $(TOPDIR)/src\include\opensc\rsaref
TARGET = opensc-pkcs11.dll
TARGET2 = libpkcs11.lib
OBJECTS = pkcs11-global.obj pkcs11-session.obj pkcs11-object.obj misc.obj slot.obj \
secretkey.obj framework-pkcs15.obj framework-pkcs15init.obj
secretkey.obj framework-pkcs15.obj framework-pkcs15init.obj mechanism.obj
OBJECTS2 = libpkcs11.obj
all: $(TARGET)
all: install-headers install-headers-dir $(TARGET)
!INCLUDE $(TOPDIR)\win32\Make.rules.mak
$(TARGET): $(OBJECTS)
link $(LINKFLAGS) /dll /out:$(TARGET) $(OBJECTS) ..\libopensc\opensc.lib ..\scconf\scconf.lib ..\pkcs15init\pkcs15init.lib winscard.lib
$(TARGET2): $(OBJECTS2)
lib /nologo /machine:ix86 /out:$(TARGET2) $(OBJECTS2)

View File

@ -14,7 +14,7 @@
struct sc_pkcs11_module {
unsigned int _magic;
#if defined(linux)
#if defined(linux) || defined(_WIN32)
void * _dl_handle;
#endif
};
@ -133,3 +133,44 @@ sys_dlsym(sc_pkcs11_module_t *mod, const char *name)
}
#endif
#ifdef _WIN32
#include <windows.h>
/*
* Module loader for the Windows platform.
*/
int
sys_dlopen(struct sc_pkcs11_module *mod, const char *name)
{
mod->_dl_handle = LoadLibrary(name);
return (mod->_dl_handle? 0 : GetLastError());
}
int
sys_dlclose(struct sc_pkcs11_module *mod)
{
if (mod->_dl_handle) {
if (FreeLibrary(mod->_dl_handle)) {
mod->_dl_handle = NULL;
return 0;
}
else
return -1;
}
return 0;
}
void *
sys_dlsym(sc_pkcs11_module_t *mod, const char *name)
{
if (!mod->_dl_handle)
return NULL;
return GetProcAddress(mod->_dl_handle, name);
}
#endif // _WIN32

View File

@ -2,7 +2,7 @@
TOPDIR = ..\..
TARGETS = opensc-explorer.exe opensc-tool.exe \
pkcs15-tool.exe pkcs15-crypt.exe #pkcs15-init.exe
pkcs15-tool.exe pkcs15-crypt.exe pkcs11-tool.exe #pkcs15-init.exe
all: util.obj $(TARGETS)
@ -15,4 +15,4 @@ all: util.obj $(TARGETS)
cl $(COPTS) /c $<
link $(LINKFLAGS) /pdb:$*.pdb /out:$@ $*.obj util.obj \
..\common\common.lib ..\scconf\scconf.lib ..\libopensc\opensc.lib \
..\pkcs15init\pkcs15init.lib
..\pkcs15init\pkcs15init.lib ..\pkcs11\libpkcs11.lib

View File

@ -566,7 +566,7 @@ get##ATTR(CK_SESSION_HANDLE sess, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount) \
rv = p11->C_GetAttributeValue(sess, obj, &attr, 1); \
if (rv == CKR_OK) { \
if (!(attr.pValue = malloc(attr.ulValueLen))) \
fatal("out of memory in %s: %m", __FUNCTION__); \
fatal("out of memory in get" #ATTR ": %m"); \
rv = p11->C_GetAttributeValue(sess, obj, &attr, 1); \
} \
if (rv != CKR_OK) \

View File

@ -6,6 +6,10 @@ install-headers:
@for %i in ( $(HEADERS) ) do \
@xcopy /d /q /y %i $(HEADERSDIR) > nul
install-headers-dir:
@for %i in ( $(HEADERSDIRFROM2) ) do \
@xcopy /d /q /y %i\*.h $(HEADERSDIR2)\*.h > nul
.c.obj::
cl $(COPTS) /c $<