diff options
author | Werner Koch <[email protected]> | 2010-03-05 17:55:57 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2010-03-05 17:55:57 +0000 |
commit | 5c0a0af4344df1175104dc95ad63b81dceea2306 (patch) | |
tree | 92e56b7ada418b730180f3abd23a92946b9df5ce | |
parent | Fix DLL creation. (diff) | |
download | libassuan-5c0a0af4344df1175104dc95ad63b81dceea2306.tar.gz libassuan-5c0a0af4344df1175104dc95ad63b81dceea2306.zip |
Add options and documentation for gpgcedev.
-rw-r--r-- | README | 20 | ||||
-rw-r--r-- | src/ChangeLog | 4 | ||||
-rw-r--r-- | src/gpgcemgr.c | 74 |
3 files changed, 95 insertions, 3 deletions
@@ -13,3 +13,23 @@ category "libassuan". The primary FTP site is ftp://ftp.gnupg.org/gcrypt/libassuan. + + +Notes for Windows CE: +---------------------- + +Libassuan supports WindowsCE (tested with WindowsMobile 6.5). To +install it, copy libassuan-0.dll into a location where DLL are found +and install the included gpgcedev driver: First copy "gpgcedev.dll" +into the root directory, second run the included program gpgcemgr on +the device: "gpgcemgr --register". This creates the necessary +registry keys. In case the copy step fails, the driver may still be +in use: Close all applications using that driver, run "gpgcemgr +--deactivate" to deactivate the running driver and try again. + +Registry keys created by "gpgcemgr --register" are: + + Drivers\\GnuPG_Device\dll -> "gpgcedev.dll" + Drivers\\GnuPG_Device\prefix -> "GPG" + Drivers\\GnuPG_Device\Index -> 1 (dword) + diff --git a/src/ChangeLog b/src/ChangeLog index 0fc7019..d3af990 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2010-03-05 Werner Koch <[email protected]> + + * gpgcemgr.c: Add options to register a device and activate it. + 2010-02-24 Werner Koch <[email protected]> * gpgcemgr.c: New. diff --git a/src/gpgcemgr.c b/src/gpgcemgr.c index da51602..d5d354e 100644 --- a/src/gpgcemgr.c +++ b/src/gpgcemgr.c @@ -24,10 +24,44 @@ #define PGM "gpgcemgr" -#warning Fixme: Add support to create the device. +#define GPGCEDEV_KEY_NAME L"Drivers\\GnuPG_Device" +#define GPGCEDEV_DLL_NAME L"gpgcedev.dll" +#define GPGCEDEV_PREFIX L"GPG" -int -main (int argc, char **argv) + +static int +install (void) +{ + HKEY handle; + DWORD disp, dw; + + if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, GPGCEDEV_KEY_NAME, 0, NULL, 0, + KEY_WRITE, NULL, &handle, &disp)) + { + fprintf (stderr, PGM": error creating registry key: rc=%d\n", + (int)GetLastError ()); + return 1; + } + + RegSetValueEx (handle, L"dll", 0, REG_SZ, + (void*)GPGCEDEV_DLL_NAME, sizeof (GPGCEDEV_DLL_NAME)); + RegSetValueEx (handle, L"prefix", 0, REG_SZ, + (void*)GPGCEDEV_PREFIX, sizeof (GPGCEDEV_PREFIX)); + + dw = 1; + RegSetValueEx (handle, L"Index", 0, REG_DWORD, (void*)&dw, sizeof dw); + + RegCloseKey (handle); + + fprintf (stderr, PGM": registry key created\n"); + + + return 0; +} + + +static int +deinstall (void) { int result = 0; HANDLE shd; @@ -63,6 +97,40 @@ main (int argc, char **argv) } FindClose (shd); } + + return result; +} + + + +int +main (int argc, char **argv) +{ + int result = 0; + + if (argc > 1 && !strcmp (argv[1], "--register")) + result = install (); + else if (argc > 1 && !strcmp (argv[1], "--deactivate")) + result = deinstall (); + else if (argc > 1 && !strcmp (argv[1], "--activate")) + { + /* This is mainly for testing. The activation is usually done + right before the device is opened. */ + if (ActivateDevice (GPGCEDEV_DLL_NAME, 0) == INVALID_HANDLE_VALUE) + { + fprintf (stderr, PGM": ActivateDevice failed: rc=%d\n", + (int)GetLastError ()); + result = 1; + } + else + fprintf (stderr, PGM": device activated\n"); + } + else + { + fprintf (stderr, "usage: " PGM " --register|--deactivate|--activate\n"); + result = 1; + } + fflush (stdout); fflush (stderr); Sleep (1000); |