diff options
author | George Hazan <george.hazan@gmail.com> | 2013-06-11 17:48:18 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-06-11 17:48:18 +0000 |
commit | 2fbe1d2262383b272ef887d712f308f787cf33f1 (patch) | |
tree | 772a78df1caf0be843d8778344e02ac750ba7a03 /plugins/CryptoPP/src | |
parent | 48fc03aa394f4506c6053323386c040fede13a29 (diff) |
64-bit compatible version of CryptoPP
git-svn-id: http://svn.miranda-ng.org/main/trunk@4917 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CryptoPP/src')
-rw-r--r-- | plugins/CryptoPP/src/GPGw/Release/GnuPGw.dll | bin | 13824 -> 0 bytes | |||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/commonheaders.c | 42 | ||||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/gpg.cpp (renamed from plugins/CryptoPP/src/GPGw/gpg.c) | 5 | ||||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/gpg.rc (renamed from plugins/CryptoPP/src/GPGw/resource.rc) | 15 | ||||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/gpg_main.cpp (renamed from plugins/CryptoPP/src/GPGw/main.c) | 56 | ||||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/gpg_res.h (renamed from plugins/CryptoPP/src/GPGw/resource.h) | 0 | ||||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/gpgw.h (renamed from plugins/CryptoPP/src/GPGw/commonheaders.h) | 30 | ||||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/keys.cpp (renamed from plugins/CryptoPP/src/GPGw/keys.c) | 5 | ||||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/language.cpp (renamed from plugins/CryptoPP/src/GPGw/language.c) | 3 | ||||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/passdialog.cpp (renamed from plugins/CryptoPP/src/GPGw/passdialog.c) | 4 | ||||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/passphrases.cpp (renamed from plugins/CryptoPP/src/GPGw/passphrases.c) | 7 | ||||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/pipeexec.cpp (renamed from plugins/CryptoPP/src/GPGw/pipeexec.c) | 4 | ||||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/tools.cpp (renamed from plugins/CryptoPP/src/GPGw/tools.c) | 3 | ||||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/userdialog.cpp (renamed from plugins/CryptoPP/src/GPGw/userdialog.c) | 5 | ||||
-rw-r--r-- | plugins/CryptoPP/src/PGPw/Release6/PGPsdkW6.dll | bin | 8192 -> 0 bytes | |||
-rw-r--r-- | plugins/CryptoPP/src/PGPw/Release8/PGPsdkW8.dll | bin | 8192 -> 0 bytes | |||
-rw-r--r-- | plugins/CryptoPP/src/PGPw/commonheaders.cpp | 5 | ||||
-rw-r--r-- | plugins/CryptoPP/src/PGPw/commonheaders.h | 64 | ||||
-rw-r--r-- | plugins/CryptoPP/src/PGPw/pgpw.h | 33 | ||||
-rw-r--r-- | plugins/CryptoPP/src/PGPw/sdk6.cpp (renamed from plugins/CryptoPP/src/PGPw/main.cpp) | 239 | ||||
-rw-r--r-- | plugins/CryptoPP/src/commonheaders.h | 5 | ||||
-rw-r--r-- | plugins/CryptoPP/src/cpp_gpgw.cpp | 159 | ||||
-rw-r--r-- | plugins/CryptoPP/src/cpp_pgpw.cpp | 52 | ||||
-rw-r--r-- | plugins/CryptoPP/src/main.cpp | 9 |
24 files changed, 140 insertions, 605 deletions
diff --git a/plugins/CryptoPP/src/GPGw/Release/GnuPGw.dll b/plugins/CryptoPP/src/GPGw/Release/GnuPGw.dll Binary files differdeleted file mode 100644 index 7dba65ea45..0000000000 --- a/plugins/CryptoPP/src/GPGw/Release/GnuPGw.dll +++ /dev/null diff --git a/plugins/CryptoPP/src/GPGw/commonheaders.c b/plugins/CryptoPP/src/GPGw/commonheaders.c deleted file mode 100644 index 5404e4ed80..0000000000 --- a/plugins/CryptoPP/src/GPGw/commonheaders.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "commonheaders.h"
-
-LPCSTR szModuleName = MODULENAME;
-LPCSTR szVersionStr = MODULENAME" DLL ("__VERSION_STRING")";
-HINSTANCE g_hInst;
-
-char temporarydirectory[fullfilenamesize];
-char logfile[fullfilenamesize];
-/*
-char *txtbeginpgppublickeyblock="-----BEGIN PGP PUBLIC KEY BLOCK-----";
-char *txtendpgppublickeyblock="-----END PGP PUBLIC KEY BLOCK-----";
-*/
-char *txtbeginpgpmessage="-----BEGIN PGP MESSAGE-----";
-char *txtendpgpmessage="-----END PGP MESSAGE-----";
-
-
-void __cdecl ErrorMessage(const char *alevel, const char *atext, const char *ahint)
-{
- char buffer[errormessagesize];
-
- strcpy(buffer, atext);
- strcat(buffer, " ");
- strcat(buffer, ahint);
- MessageBox(NULL, buffer, alevel, MB_OK);
-}
-
-
-void __cdecl LogMessage(const char *astart, const char *atext, const char *aend)
-{
- FILE *log;
-
- if(logfile[0]=='\0') return;
-
- log=fopen(logfile, "a");
- if(log!=NULL)
- {
- fputs(astart, log);
- fputs(atext, log);
- fputs(aend, log);
- fclose(log);
- }
-}
diff --git a/plugins/CryptoPP/src/GPGw/gpg.c b/plugins/CryptoPP/src/GPGw/gpg.cpp index 8ec3a57b11..47d5d178dc 100644 --- a/plugins/CryptoPP/src/GPGw/gpg.c +++ b/plugins/CryptoPP/src/GPGw/gpg.cpp @@ -1,5 +1,5 @@ -#include "commonheaders.h"
-#include <stdio.h>
+#include "../commonheaders.h"
+#include "gpgw.h"
char *txtgpgargslistpublickeys=
"--homedir \"%home%\""
@@ -363,4 +363,3 @@ gpgResult gpgDecrypt(char *aresult, const char *aciphertext, const char *apassph remove(plainfile);
return gpgSuccess;
}
-
diff --git a/plugins/CryptoPP/src/GPGw/resource.rc b/plugins/CryptoPP/src/GPGw/gpg.rc index 53968a5d2e..313dad2701 100644 --- a/plugins/CryptoPP/src/GPGw/resource.rc +++ b/plugins/CryptoPP/src/GPGw/gpg.rc @@ -1,6 +1,6 @@ // Microsoft Visual C++ generated resource script.
//
-#include "resource.h"
+#include "gpg_res.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
@@ -43,7 +43,7 @@ STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTI CAPTION "GnuPG Plugin - Select public key"
FONT 8, "MS Shell Dlg"
BEGIN
- CONTROL "",IDC_KEYLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING |
+ CONTROL "",IDC_KEYLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING |
LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,7,258,174
PUSHBUTTON "Refresh",IDC_REFRESH,7,187,50,14
DEFPUSHBUTTON "Ok",IDOK,154,187,50,14
@@ -57,7 +57,7 @@ END //
#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO
+GUIDELINES DESIGNINFO
BEGIN
IDD_SELECTKEY, DIALOG
BEGIN
@@ -76,18 +76,18 @@ END // TEXTINCLUDE
//
-1 TEXTINCLUDE
+1 TEXTINCLUDE
BEGIN
- "resource.h\0"
+ "gpg_res.h\0"
END
-2 TEXTINCLUDE
+2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
-3 TEXTINCLUDE
+3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
@@ -109,4 +109,3 @@ END /////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
-
diff --git a/plugins/CryptoPP/src/GPGw/main.c b/plugins/CryptoPP/src/GPGw/gpg_main.cpp index fc23b24262..700e27b691 100644 --- a/plugins/CryptoPP/src/GPGw/main.c +++ b/plugins/CryptoPP/src/GPGw/gpg_main.cpp @@ -1,9 +1,44 @@ -#include "commonheaders.h"
-
+#include "../commonheaders.h"
+#include "gpgw.h"
BOOL ShowSelectExecDlg(LPSTR);
BOOL ShowSelectHomeDlg(LPSTR);
+char temporarydirectory[fullfilenamesize];
+char logfile[fullfilenamesize];
+/*
+char *txtbeginpgppublickeyblock="-----BEGIN PGP PUBLIC KEY BLOCK-----";
+char *txtendpgppublickeyblock="-----END PGP PUBLIC KEY BLOCK-----";
+*/
+char *txtbeginpgpmessage="-----BEGIN PGP MESSAGE-----";
+char *txtendpgpmessage="-----END PGP MESSAGE-----";
+
+void __cdecl ErrorMessage(const char *alevel, const char *atext, const char *ahint)
+{
+ char buffer[errormessagesize];
+
+ strcpy(buffer, atext);
+ strcat(buffer, " ");
+ strcat(buffer, ahint);
+ MessageBox(NULL, buffer, alevel, MB_OK);
+}
+
+
+void __cdecl LogMessage(const char *astart, const char *atext, const char *aend)
+{
+ FILE *log;
+
+ if(logfile[0]=='\0') return;
+
+ log=fopen(logfile, "a");
+ if(log!=NULL)
+ {
+ fputs(astart, log);
+ fputs(atext, log);
+ fputs(aend, log);
+ fclose(log);
+ }
+}
int __cdecl _gpg_init()
{
@@ -74,7 +109,7 @@ void __cdecl _gpg_set_tmp(LPCSTR TmpPath) LPSTR __cdecl _gpg_get_passphrases()
{
size_t i; char *b, x;
-
+
b = (char *) LocalAlloc(LPTR,(keyuseridsize+passphrasesize)*passphrasecount+1); *b = '\0';
for(i=0; i<(size_t)passphrasecount; i++) {
@@ -155,7 +190,6 @@ LPSTR __cdecl _gpg_decrypt(LPCSTR message) char buffer[ciphertextsize];
char plaintext[plaintextsize];
char keyuserid[keyuseridsize];
- char *begin, *end;
int dlgresult;
BOOL useridvalid;
char *storedpassphrase;
@@ -164,8 +198,8 @@ LPSTR __cdecl _gpg_decrypt(LPCSTR message) int decmessagelen;
gpgResult gpgresult;
- begin=strstr(message, txtbeginpgpmessage);
- end=strstr(message, txtendpgpmessage);
+ const char *begin = strstr(message, txtbeginpgpmessage);
+ const char *end = strstr(message, txtendpgpmessage);
if ((begin!=NULL)&&(end!=NULL))
{
@@ -353,17 +387,9 @@ BOOL ShowSelectHomeDlg(LPSTR path) ofn.lpstrFilter = "Public key rings (pubring.gpg)\0pubring.gpg\0All files (*.*)\0*.*\0";
ofn.lpstrTitle = "Open Public Keyring";
if (!GetOpenFileName(&ofn)) return FALSE;
-
+
for(i=strlen(path);i && path[i]!='\\';i--);
path[i] = 0;
return TRUE;
}
-
-
-// dllmain
-BOOL WINAPI dllmain(HINSTANCE hInst, DWORD dwReason, LPVOID lpVoid) {
- g_hInst = hInst;
- return TRUE;
-}
-
diff --git a/plugins/CryptoPP/src/GPGw/resource.h b/plugins/CryptoPP/src/GPGw/gpg_res.h index af5efe29d7..af5efe29d7 100644 --- a/plugins/CryptoPP/src/GPGw/resource.h +++ b/plugins/CryptoPP/src/GPGw/gpg_res.h diff --git a/plugins/CryptoPP/src/GPGw/commonheaders.h b/plugins/CryptoPP/src/GPGw/gpgw.h index 4ae6e155a7..abaf52430e 100644 --- a/plugins/CryptoPP/src/GPGw/commonheaders.h +++ b/plugins/CryptoPP/src/GPGw/gpgw.h @@ -1,19 +1,11 @@ // Windows API
#pragma once
-#define _WIN32_IE 0x0500
-//#define WIN32_LEAN_AND_MEAN
-//#pragma warning(disable: 4078)
-#include <windows.h>
-//#include <afxwin.h>
-#include <commdlg.h>
-#include <commctrl.h>
-#include <stdio.h>
#include "..\version.h"
// gnupg plugin
-#include "resource.h"
+#include "gpg_res.h"
#include "size.h"
#include "language.h"
#include "pipeexec.h"
@@ -24,17 +16,14 @@ #include "userdialog.h"
#include "keys.h"
-// debug makro
-#define debugout(mtext) MessageBox(NULL, (mtext), "GnuPG Plugin - Debug", MB_OK)
-
// passphrase typ
-struct passphrase
+struct passphrase_t
{
- char keyuserid[keyuseridsize];
- char passphrase[passphrasesize];
+ char keyuserid[keyuseridsize];
+ char passphrase[passphrasesize];
};
-extern struct passphrase *passphrases;
+extern struct passphrase_t *passphrases;
extern int passphrasecount;
extern char temporarydirectory[fullfilenamesize];
@@ -45,14 +34,7 @@ extern char *txtendpgppublickeyblock; extern char *txtbeginpgpmessage;
extern char *txtendpgpmessage;
-#ifdef _MSC_VER
-//#pragma comment(linker,"/merge:.rdata=.text")
-#pragma comment(linker,"/entry:dllmain")
-#pragma comment(linker,"/nodefaultlib")
-#pragma comment(linker,"/subsystem:windows")
-#pragma optimize("gsy", on)
-#endif
-
+#undef MODULENAME
#define MODULENAME "GnuPG"
extern LPCSTR szModuleName;
diff --git a/plugins/CryptoPP/src/GPGw/keys.c b/plugins/CryptoPP/src/GPGw/keys.cpp index 4cfbe4f71d..19606d446a 100644 --- a/plugins/CryptoPP/src/GPGw/keys.c +++ b/plugins/CryptoPP/src/GPGw/keys.cpp @@ -1,4 +1,5 @@ -#include "commonheaders.h"
+#include "../commonheaders.h"
+#include "gpgw.h"
typedef char tkeyuserid[keyuseridsize];
@@ -41,7 +42,7 @@ void updateKeyUserIDs(const int atype) if(pos!=NULL)
{
keyuseridcount[atype]++;
- keyuserids[atype]=realloc(keyuserids[atype], sizeof(tkeyuserid)*keyuseridcount[atype]);
+ keyuserids[atype] = (tkeyuserid*)realloc(keyuserids[atype], sizeof(tkeyuserid)*keyuseridcount[atype]);
strcpy(keyuserids[atype][keyuseridcount[atype]-1], keyuserid);
}
}
diff --git a/plugins/CryptoPP/src/GPGw/language.c b/plugins/CryptoPP/src/GPGw/language.cpp index 4997711629..a815f7cff3 100644 --- a/plugins/CryptoPP/src/GPGw/language.c +++ b/plugins/CryptoPP/src/GPGw/language.cpp @@ -1,4 +1,5 @@ -#include "commonheaders.h"
+#include "../commonheaders.h"
+#include "gpgw.h"
//char *txtverifyoptions="Please verify your settings in M->Options->Plugins->GnuPG and GnuPG Advanced."; /*lang*/
//char *txtinvalidexecutable="The GnuPG Plugin requires the GnuPG executable \"gpg.exe\"."; /*lang*/
diff --git a/plugins/CryptoPP/src/GPGw/passdialog.c b/plugins/CryptoPP/src/GPGw/passdialog.cpp index cbba1139ab..d00753af9e 100644 --- a/plugins/CryptoPP/src/GPGw/passdialog.c +++ b/plugins/CryptoPP/src/GPGw/passdialog.cpp @@ -1,8 +1,8 @@ -#include "commonheaders.h"
+#include "../commonheaders.h"
+#include "gpgw.h"
char dlgpassphrase[passphrasesize];
-
BOOL CALLBACK PassphraseDialogProcedure(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch(msg)
diff --git a/plugins/CryptoPP/src/GPGw/passphrases.c b/plugins/CryptoPP/src/GPGw/passphrases.cpp index 5e93936ffc..847472f5ac 100644 --- a/plugins/CryptoPP/src/GPGw/passphrases.c +++ b/plugins/CryptoPP/src/GPGw/passphrases.cpp @@ -1,7 +1,8 @@ -#include "commonheaders.h"
+#include "../commonheaders.h"
+#include "gpgw.h"
// globale variablen
-struct passphrase *passphrases;
+struct passphrase_t *passphrases;
int passphrasecount;
@@ -26,7 +27,7 @@ void releasePassphrases(void) void addPassphrase(const char *akeyuserid, const char *apassphrase)
{
passphrasecount++;
- passphrases=realloc(passphrases, sizeof(struct passphrase)*passphrasecount);
+ passphrases = (passphrase_t*)realloc(passphrases, sizeof(struct passphrase_t)*passphrasecount);
strcpy(passphrases[passphrasecount-1].keyuserid, akeyuserid);
strcpy(passphrases[passphrasecount-1].passphrase, apassphrase);
diff --git a/plugins/CryptoPP/src/GPGw/pipeexec.c b/plugins/CryptoPP/src/GPGw/pipeexec.cpp index ea54f85d1a..fdefb147d6 100644 --- a/plugins/CryptoPP/src/GPGw/pipeexec.c +++ b/plugins/CryptoPP/src/GPGw/pipeexec.cpp @@ -1,5 +1,5 @@ -#include "commonheaders.h"
-
+#include "../commonheaders.h"
+#include "gpgw.h"
BOOL isWindowsNT(void)
{
diff --git a/plugins/CryptoPP/src/GPGw/tools.c b/plugins/CryptoPP/src/GPGw/tools.cpp index 002f18824d..6886088e4e 100644 --- a/plugins/CryptoPP/src/GPGw/tools.c +++ b/plugins/CryptoPP/src/GPGw/tools.cpp @@ -1,4 +1,5 @@ -#include "commonheaders.h"
+#include "../commonheaders.h"
+#include "gpgw.h"
// escape sequence type
struct escapesequence
diff --git a/plugins/CryptoPP/src/GPGw/userdialog.c b/plugins/CryptoPP/src/GPGw/userdialog.cpp index bb82917c55..65edcfe278 100644 --- a/plugins/CryptoPP/src/GPGw/userdialog.c +++ b/plugins/CryptoPP/src/GPGw/userdialog.cpp @@ -1,9 +1,8 @@ -#include "commonheaders.h"
-
+#include "../commonheaders.h"
+#include "gpgw.h"
void RefreshListView(HWND hLV);
-
BOOL CALLBACK UserIdDialogProcedure(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
static char *keyid;
diff --git a/plugins/CryptoPP/src/PGPw/Release6/PGPsdkW6.dll b/plugins/CryptoPP/src/PGPw/Release6/PGPsdkW6.dll Binary files differdeleted file mode 100644 index 90a7a2abfc..0000000000 --- a/plugins/CryptoPP/src/PGPw/Release6/PGPsdkW6.dll +++ /dev/null diff --git a/plugins/CryptoPP/src/PGPw/Release8/PGPsdkW8.dll b/plugins/CryptoPP/src/PGPw/Release8/PGPsdkW8.dll Binary files differdeleted file mode 100644 index f026dde7fd..0000000000 --- a/plugins/CryptoPP/src/PGPw/Release8/PGPsdkW8.dll +++ /dev/null diff --git a/plugins/CryptoPP/src/PGPw/commonheaders.cpp b/plugins/CryptoPP/src/PGPw/commonheaders.cpp deleted file mode 100644 index 763395fcd6..0000000000 --- a/plugins/CryptoPP/src/PGPw/commonheaders.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "commonheaders.h"
-
-LPCSTR szModuleName = MODULENAME;
-LPCSTR szVersionStr = MODULENAME" DLL ("__VERSION_STRING")";
-HINSTANCE g_hInst;
diff --git a/plugins/CryptoPP/src/PGPw/commonheaders.h b/plugins/CryptoPP/src/PGPw/commonheaders.h deleted file mode 100644 index 8c79d2ec5c..0000000000 --- a/plugins/CryptoPP/src/PGPw/commonheaders.h +++ /dev/null @@ -1,64 +0,0 @@ -// Windows API
-
-#pragma once
-//#define WIN32_LEAN_AND_MEAN
-//#pragma warning(disable: 4078)
-
-#include <windows.h>
-//#include <afxwin.h>
-#include <commdlg.h>
-#include "..\version.h"
-
-#pragma comment(linker,"/merge:.rdata=.text")
-#pragma comment(linker,"/entry:dllmain")
-#pragma comment(linker,"/nodefaultlib")
-#pragma comment(linker,"/subsystem:windows")
-#pragma optimize("gsy", on)
-
-// PGP API
-#ifndef PGP_WIN32
-#error Define PGP_WIN32 to SDK version (e.g. 0x658)
-#endif
-
-#include <pgpEncode.h>
-#include <pgpErrors.h>
-#include <pgpKeys.h>
-#include <pgpOptionList.h>
-#include <pgpUserInterface.h>
-#include <pgpUtilities.h>
-#include <pgpFeatures.h>
-
-
-#define MODULENAME "PGPsdk"
-BOOL ShowSelectKeyringsDlg(HWND,LPSTR,LPSTR);
-
-extern LPCSTR szModuleName;
-extern LPCSTR szVersionStr;
-extern HINSTANCE g_hInst;
-
-
-#define DLLEXPORT __declspec(dllexport)
-
-extern "C" DLLEXPORT int __cdecl _pgp_init(void);
-extern "C" DLLEXPORT int __cdecl _pgp_done(void);
-extern "C" DLLEXPORT int __cdecl _pgp_open_keyrings(LPSTR,LPSTR);
-extern "C" DLLEXPORT int __cdecl _pgp_close_keyrings(void);
-extern "C" DLLEXPORT int __cdecl _pgp_get_version(void);
-extern "C" DLLEXPORT LPSTR __cdecl _pgp_get_error(void);
-extern "C" DLLEXPORT int __cdecl _pgp_size_keyid(void);
-extern "C" DLLEXPORT PVOID __cdecl _pgp_select_keyid(HWND,LPSTR);
-extern "C" DLLEXPORT LPSTR __cdecl _pgp_encrypt_keydb(LPCSTR,PVOID);
-extern "C" DLLEXPORT LPSTR __cdecl _pgp_decrypt_keydb(LPCSTR);
-//extern "C" DLLEXPORT int __cdecl _pgp_check_key(LPCSTR);
-extern "C" DLLEXPORT LPSTR __cdecl _pgp_encrypt_key(LPCSTR,LPCSTR);
-extern "C" DLLEXPORT LPSTR __cdecl _pgp_decrypt_key(LPCSTR,LPCSTR);
-
-/*
-#undef RtlMoveMemory
-#undef RtlFillMemory
-#undef RtlZeroMemory
-
-NTSYSAPI VOID NTAPI RtlMoveMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, SIZE_T Length);
-NTSYSAPI VOID NTAPI RtlFillMemory(VOID UNALIGNED *Destination, SIZE_T Length, BYTE Fill);
-NTSYSAPI VOID NTAPI RtlZeroMemory(VOID UNALIGNED *Destination, SIZE_T Length);
-*/
diff --git a/plugins/CryptoPP/src/PGPw/pgpw.h b/plugins/CryptoPP/src/PGPw/pgpw.h new file mode 100644 index 0000000000..9e26090e58 --- /dev/null +++ b/plugins/CryptoPP/src/PGPw/pgpw.h @@ -0,0 +1,33 @@ +// Windows API
+
+#pragma once
+
+#include "..\version.h"
+
+// PGP API
+#ifndef PGP_WIN32
+#error Define PGP_WIN32 to SDK version (e.g. 0x658)
+#endif
+
+#undef MODULENAME
+#define MODULENAME "PGPsdk"
+
+BOOL ShowSelectKeyringsDlg(HWND,LPSTR,LPSTR);
+
+extern LPCSTR szModuleName;
+extern LPCSTR szVersionStr;
+extern HINSTANCE g_hInst;
+
+extern "C" int __cdecl _pgp_init(void);
+extern "C" int __cdecl _pgp_done(void);
+extern "C" int __cdecl _pgp_open_keyrings(LPSTR,LPSTR);
+extern "C" int __cdecl _pgp_close_keyrings(void);
+extern "C" int __cdecl _pgp_get_version(void);
+extern "C" LPSTR __cdecl _pgp_get_error(void);
+extern "C" int __cdecl _pgp_size_keyid(void);
+extern "C" PVOID __cdecl _pgp_select_keyid(HWND,LPSTR);
+extern "C" LPSTR __cdecl _pgp_encrypt_keydb(LPCSTR,PVOID);
+extern "C" LPSTR __cdecl _pgp_decrypt_keydb(LPCSTR);
+extern "C" int __cdecl _pgp_check_key(LPCSTR);
+extern "C" LPSTR __cdecl _pgp_encrypt_key(LPCSTR,LPCSTR);
+extern "C" LPSTR __cdecl _pgp_decrypt_key(LPCSTR,LPCSTR);
diff --git a/plugins/CryptoPP/src/PGPw/main.cpp b/plugins/CryptoPP/src/PGPw/sdk6.cpp index 8427046a16..3d9bf47f17 100644 --- a/plugins/CryptoPP/src/PGPw/main.cpp +++ b/plugins/CryptoPP/src/PGPw/sdk6.cpp @@ -1,14 +1,22 @@ -#include "commonheaders.h"
+#include "../commonheaders.h"
+
+#define PGP_WIN32 0x600
+
+#include "sdk6/include/pgpEncode.h"
+#include "sdk6/include/pgpErrors.h"
+#include "sdk6/include/pgpKeys.h"
+#include "sdk6/include/pgpOptionList.h"
+#include "sdk6/include/pgpUserInterface.h"
+#include "sdk6/include/pgpUtilities.h"
+#include "sdk6/include/pgpFeatures.h"
+
+#include "pgpw.h"
// pgpsdk.lib pgpsdknl.lib pgpsdkui.lib libcmt.lib
// /delayload:pgpsdk.dll,pgpsdknl.dll,pgpsdkui.dll
PGPContextRef pgpContext;
-#if (PGP_WIN32 < 0x700)
PGPKeySetRef pgpKeyDB = 0;
-#else
-PGPKeyDBRef pgpKeyDB = 0;
-#endif
LPSTR pszPassphrase = 0;
LPSTR pgpErrMsg = 0;
#define pgpErrMsgLen 512
@@ -51,19 +59,13 @@ int __cdecl _pgp_init() pgpVer = 0;
__try {
-#if (PGP_WIN32 < 0x700)
if (CheckPGPError(PGPsdkInit()) || CheckPGPError(PGPsdkUILibInit())) return 0;
PGPNewContext(kPGPsdkAPIVersion, &pgpContext);
-#else
- if (CheckPGPError(PGPsdkInit(0)) || CheckPGPError(PGPsdkUILibInit(0))) return 0;
- PGPNewContext(kPGPsdk20APIVersion, &pgpContext);
-#endif
}
__except ( EXCEPTION_EXECUTE_HANDLER ) {
return 0;
}
-#if (PGP_WIN32 < 0x700)
PGPGetSDKVersion(&pgpVer);
int minor = (pgpVer & 0x000FF000 ) >> 12;
switch(PGPMajorVersion(pgpVer)) {
@@ -77,9 +79,6 @@ int __cdecl _pgp_init() pgpVer = 1<<24 | (minor<<16) | (PGPRevVersion(pgpVer)<<8);
break;
}
-#else
- pgpVer = PGPGetPGPsdkVersion();
-#endif
return 1;
}
@@ -91,11 +90,7 @@ int __cdecl _pgp_done() __try {
if(pgpErrMsg) LocalFree(pgpErrMsg);
if (pszPassphrase) PGPFreeData(pszPassphrase);
-#if (PGP_WIN32 < 0x700)
if (pgpKeyDB) PGPFreeKeySet(pgpKeyDB);
-#else
- if (pgpKeyDB) PGPFreeKeyDB(pgpKeyDB);
-#endif
PGPFreeContext(pgpContext);
PGPsdkUILibCleanup();
PGPsdkCleanup();
@@ -114,21 +109,7 @@ int __cdecl _pgp_open_keyrings(LPSTR PubRingPath, LPSTR SecRingPath) {
_pgp_close_keyrings();
-#if (PGP_WIN32 < 0x700)
PGPError err = PGPOpenDefaultKeyRings(pgpContext, kPGPKeyRingOpenFlags_None, &pgpKeyDB);
-#else
- if ((!PubRingPath || !*PubRingPath) && !ShowSelectKeyringsDlg(0,PubRingPath,SecRingPath)) {
- return 0;
- }
-
- PGPFileSpecRef PubKeyRing, SecKeyRing;
- PGPNewFileSpecFromFullPath(pgpContext, PubRingPath, &PubKeyRing);
- PGPNewFileSpecFromFullPath(pgpContext, SecRingPath, &SecKeyRing);
-
- PGPError err = PGPOpenKeyDBFile(pgpContext, kPGPOpenKeyDBFileOptions_None, PubKeyRing, SecKeyRing, &pgpKeyDB);
- PGPFreeFileSpec(SecKeyRing);
- PGPFreeFileSpec(PubKeyRing);
-#endif
if (CheckPGPError(err)) {
return 0;
}
@@ -138,17 +119,10 @@ int __cdecl _pgp_open_keyrings(LPSTR PubRingPath, LPSTR SecRingPath) int __cdecl _pgp_close_keyrings()
{
-#if (PGP_WIN32 < 0x700)
if (pgpKeyDB) {
PGPFreeKeySet(pgpKeyDB);
pgpKeyDB = 0;
}
-#else
- if (pgpKeyDB) {
- PGPFreeKeyDB(pgpKeyDB);
- pgpKeyDB = 0;
- }
-#endif
return 1;
}
@@ -175,33 +149,22 @@ LPSTR __cdecl _pgp_encrypt_keydb(LPCSTR szPlainMsg, PVOID pgpKeyID) if (!pgpKeyDB)
return 0;
-#if (PGP_WIN32 < 0x700)
PGPFilterRef IDFilter;
PGPNewKeyIDFilter(pgpContext, RemoteKeyID, &IDFilter);
PGPKeySetRef PublicKey;
PGPFilterKeySet(pgpKeyDB, IDFilter, &PublicKey);
-#else
- PGPKeyDBObjRef PublicKey;
- PGPFindKeyByKeyID(pgpKeyDB, RemoteKeyID, &PublicKey);
-#endif
PGPError err = PGPEncode(pgpContext,
PGPOInputBuffer(pgpContext, szPlainMsg, lstrlen(szPlainMsg)),
PGPOArmorOutput(pgpContext, TRUE),
PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szEncMsg, 16384, (PGPUInt32 *)&dwEncMsgLen),
-#if (PGP_WIN32 < 0x700)
PGPOEncryptToKeySet(pgpContext, PublicKey),
-#else
- PGPOEncryptToKeyDBObj(pgpContext, PublicKey),
-#endif
PGPOVersionString(pgpContext, szVersionStr),
PGPOLastOption(pgpContext));
-#if (PGP_WIN32 < 0x700)
PGPFreeKeySet(PublicKey);
PGPFreeFilter(IDFilter);
-#endif
if (CheckPGPError(err))
return 0;
@@ -227,7 +190,7 @@ LPSTR __cdecl _pgp_decrypt_keydb(LPCSTR szEncMsg) int iTry = 0;
do {
- if (!pszPassphrase &&
+ if (!pszPassphrase &&
PGPPassphraseDialog(pgpContext,
PGPOUIOutputPassphrase(pgpContext, &pszPassphrase),
PGPOLastOption(pgpContext)) == kPGPError_UserAbort) {
@@ -238,11 +201,7 @@ LPSTR __cdecl _pgp_decrypt_keydb(LPCSTR szEncMsg) PGPError err = PGPDecode(pgpContext,
PGPOInputBuffer(pgpContext, szEncMsg, lstrlen(szEncMsg)),
PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szPlainMsg, 16384, (PGPUInt32 *)&dwPlainMsgLen),
-#if (PGP_WIN32 < 0x700)
PGPOKeySetRef(pgpContext, pgpKeyDB),
-#else
- PGPOKeyDBRef(pgpContext, pgpKeyDB),
-#endif
PGPOPassphrase(pgpContext, pszPassphrase),
PGPOLastOption(pgpContext));
@@ -268,7 +227,6 @@ LPSTR __cdecl _pgp_decrypt_keydb(LPCSTR szEncMsg) }
-#if (PGP_WIN32 < 0x700)
PGPError _pgp_import_key(PGPKeySetRef *keySet, LPCSTR pgpKey)
{
return PGPImportKeySet( pgpContext,
@@ -278,35 +236,6 @@ PGPError _pgp_import_key(PGPKeySetRef *keySet, LPCSTR pgpKey) lstrlen(pgpKey) ),
PGPOLastOption( pgpContext ) );
}
-#else
-PGPError _pgp_import_key(PGPKeyDBRef *keyDB, LPCSTR pgpKey)
-{
- return PGPImport( pgpContext,
- keyDB,
- PGPOInputBuffer( pgpContext,
- pgpKey,
- lstrlen(pgpKey) ),
- PGPOLastOption( pgpContext ) );
-}
-#endif
-
-/*
-int __cdecl _pgp_check_key(LPCSTR pgpKey)
-{
-#if (PGP_WIN32 < 0x700)
- PGPKeySetRef PrivateKey;
- if (CheckPGPError(_pgp_import_key(&PrivateKey,pgpKey)))
- return 0;
- PGPFreeKeySet(PrivateKey);
-#else
- PGPKeyDBRef PrivateKey;
- if (CheckPGPError(_pgp_import_key(&PrivateKey,pgpKey)))
- return 0;
- PGPFreeKeyDB(PrivateKey);
-#endif
- return 1;
-}
-*/
LPSTR __cdecl _pgp_encrypt_key(LPCSTR szPlainMsg, LPCSTR pgpKey)
{
@@ -314,31 +243,12 @@ LPSTR __cdecl _pgp_encrypt_key(LPCSTR szPlainMsg, LPCSTR pgpKey) DWORD dwEncMsgLen;
PGPUInt32 dwKeys;
-#if (PGP_WIN32 < 0x700)
PGPKeySetRef PublicKey;
if (CheckPGPError(_pgp_import_key(&PublicKey,pgpKey)))
return 0;
PGPCountKeys(PublicKey, &dwKeys);
-#else
- PGPKeyDBRef PublicKeyDB;
- if (CheckPGPError(_pgp_import_key(&PublicKeyDB,pgpKey)))
- return 0;
-
- PGPKeyIterRef KeyIterRef;
- PGPNewKeyIterFromKeyDB(PublicKeyDB, &KeyIterRef);
-
- PGPKeyDBObjRef PublicKey;
- PGPKeyIterNextKeyDBObj(KeyIterRef, kPGPKeyDBObjType_Key, &PublicKey);
-
- PGPCountKeysInKeyDB(PublicKeyDB, &dwKeys);
-#endif
if(dwKeys==0) {
-#if (PGP_WIN32 < 0x700)
PGPFreeKeySet(PublicKey);
-#else
- PGPFreeKeyIter(KeyIterRef);
- PGPFreeKeyDB(PublicKeyDB);
-#endif
return 0;
}
@@ -346,21 +256,11 @@ LPSTR __cdecl _pgp_encrypt_key(LPCSTR szPlainMsg, LPCSTR pgpKey) PGPOInputBuffer(pgpContext, szPlainMsg, lstrlen(szPlainMsg)),
PGPOArmorOutput(pgpContext, TRUE),
PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szEncMsg, 16384, (PGPUInt32 *)&dwEncMsgLen),
-#if (PGP_WIN32 < 0x700)
PGPOEncryptToKeySet(pgpContext, PublicKey),
-#else
- PGPOEncryptToKeyDBObj(pgpContext, PublicKey),
-#endif
PGPOVersionString(pgpContext, szVersionStr),
PGPOLastOption(pgpContext));
-#if (PGP_WIN32 < 0x700)
PGPFreeKeySet(PublicKey);
-#else
- PGPFreeKeyIter(KeyIterRef);
- PGPFreeKeyDB(PublicKeyDB);
-#endif
-
if (CheckPGPError(err))
return 0;
@@ -379,23 +279,12 @@ LPSTR __cdecl _pgp_decrypt_key(LPCSTR szEncMsg, LPCSTR pgpKey) DWORD dwPlainMsgLen;
PGPUInt32 dwKeys;
-#if (PGP_WIN32 < 0x700)
PGPKeySetRef PrivateKeyDB;
if (CheckPGPError(_pgp_import_key(&PrivateKeyDB,pgpKey)))
return 0;
PGPCountKeys(PrivateKeyDB, &dwKeys);
-#else
- PGPKeyDBRef PrivateKeyDB;
- if (CheckPGPError(_pgp_import_key(&PrivateKeyDB,pgpKey)))
- return 0;
- PGPCountKeysInKeyDB(PrivateKeyDB, &dwKeys);
-#endif
if(dwKeys==0) {
-#if (PGP_WIN32 < 0x700)
PGPFreeKeySet(PrivateKeyDB);
-#else
- PGPFreeKeyDB(PrivateKeyDB);
-#endif
return 0;
}
@@ -410,47 +299,10 @@ LPSTR __cdecl _pgp_decrypt_key(LPCSTR szEncMsg, LPCSTR pgpKey) break;
}
-/*
-#if (PGP_WIN32 < 0x700)
- PGPKeyListRef PrivateKeyList;
- PGPOrderKeySet(PrivateKeyDB, kPGPKeyIDOrdering, &PrivateKeyList);
-
- PGPKeyIterRef KeyIterRef;
- PGPNewKeyIter(PrivateKeyList, &KeyIterRef);
-
- PGPKeyRef PrivateKey;
- for(int i=0;i<dwKeys;i++) {
- PGPKeyIterNext(KeyIterRef, &PrivateKey);
- PGPOPassphraseIsValid(PrivateKey,
- PGPOPassphrase(pgpContext, pszPassphrase),
- PGPOLastOption(pgpContext));
- }
-
- PGPFreeKeyList(PrivateKeyList);
- PGPFreeKeyIter(KeyIterRef);
-#else
- PGPKeyIterRef KeyIterRef;
- PGPNewKeyIterFromKeyDB(PrivateKeyDB, &KeyIterRef);
-
- PGPKeyDBObjRef KeyDBObjRef;
- for(int i=0;i<dwKeys;i++) {
- PGPKeyIterNextKeyDBObj(KeyIterRef, kPGPKeyDBObjType_Key, &KeyDBObjRef);
- PGPOPassphraseIsValid(PrivateKey,
- PGPOPassphrase(pgpContext, pszPassphrase),
- PGPOLastOption(pgpContext));
- }
-
- PGPFreeKeyIter(KeyIterRef);
-#endif
-*/
PGPError err = PGPDecode(pgpContext,
PGPOInputBuffer(pgpContext, szEncMsg, lstrlen(szEncMsg)),
PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szPlainMsg, 16384, (PGPUInt32 *)&dwPlainMsgLen),
-#if (PGP_WIN32 < 0x700)
PGPOKeySetRef(pgpContext, PrivateKeyDB),
-#else
- PGPOKeyDBRef(pgpContext, PrivateKeyDB),
-#endif
PGPOPassphrase(pgpContext, pszPassphrase),
PGPOLastOption(pgpContext));
@@ -464,12 +316,8 @@ LPSTR __cdecl _pgp_decrypt_key(LPCSTR szEncMsg, LPCSTR pgpKey) }
} while(!dwPlainMsgLen && iTry<3);
-
-#if (PGP_WIN32 < 0x700)
+
PGPFreeKeySet(PrivateKeyDB);
-#else
- PGPFreeKeyDB(PrivateKeyDB);
-#endif
if(iTry == 3) return 0;
@@ -490,11 +338,7 @@ int __cdecl _pgp_size_keyid() PVOID __cdecl _pgp_select_keyid(HWND hDlg,LPSTR szKeyID)
{
-#if (PGP_WIN32 < 0x700)
PGPKeySetRef ContactKeyDB;
-#else
- PGPKeyDBRef ContactKeyDB;
-#endif
PGPError err;
err = PGPRecipientDialog(pgpContext, pgpKeyDB, TRUE, &ContactKeyDB,
PGPOUIParentWindowHandle(pgpContext, hDlg),
@@ -504,11 +348,7 @@ PVOID __cdecl _pgp_select_keyid(HWND hDlg,LPSTR szKeyID) return 0;
PGPUInt32 dwKeys;
-#if (PGP_WIN32 < 0x700)
PGPCountKeys(ContactKeyDB, &dwKeys);
-#else
- PGPCountKeysInKeyDB(ContactKeyDB, &dwKeys);
-#endif
if (!dwKeys) {
return 0;
} else if (dwKeys > 1)
@@ -516,7 +356,6 @@ PVOID __cdecl _pgp_select_keyid(HWND hDlg,LPSTR szKeyID) static PGPKeyID KeyID;
-#if (PGP_WIN32 < 0x700)
PGPKeyListRef ContactKeyList;
PGPOrderKeySet(ContactKeyDB, kPGPKeyIDOrdering, &ContactKeyList);
@@ -532,53 +371,5 @@ PVOID __cdecl _pgp_select_keyid(HWND hDlg,LPSTR szKeyID) PGPFreeKeyList(ContactKeyList);
PGPFreeKeyIter(KeyIterRef);
PGPFreeKeySet(ContactKeyDB);
-#else
- PGPKeyIterRef KeyIterRef;
- PGPNewKeyIterFromKeyDB(ContactKeyDB, &KeyIterRef);
-
- PGPKeyDBObjRef KeyDBObjRef;
- PGPKeyIterNextKeyDBObj(KeyIterRef, kPGPKeyDBObjType_Key, &KeyDBObjRef);
-
- PGPSize dwFilled;
- PGPGetKeyDBObjDataProperty(KeyDBObjRef, kPGPKeyProperty_KeyID, &KeyID, sizeof(PGPKeyID), &dwFilled);
- PGPGetKeyIDString(&KeyID, kPGPKeyIDString_Abbreviated, szKeyID);
-
- PGPFreeKeyIter(KeyIterRef);
- PGPFreeKeyDB(ContactKeyDB);
-#endif
-
return (PVOID)&KeyID;
}
-
-
-#if (PGP_WIN32 >= 0x700)
-BOOL ShowSelectKeyringsDlg(HWND hParent, LPSTR PubRingPath, LPSTR SecRingPath)
-{
- // set keyring paths
- OPENFILENAME ofn={0};
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = hParent;
- ofn.nMaxFile = MAX_PATH;
- ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON;
-
- ofn.lpstrFile = PubRingPath;
- ofn.lpstrFilter = "Public key rings (pubring.pkr)\0pubring.pkr\0All files (*.*)\0*.*\0";
- ofn.lpstrTitle = "Open Public Keyring";
- if (!GetOpenFileName(&ofn)) return FALSE;
-
- ofn.lpstrFile = SecRingPath;
- ofn.lpstrFilter = "Secret key rings (secring.skr)\0secring.skr\0All files (*.*)\0*.*\0";
- ofn.lpstrTitle = "Open Secret Keyring";
- if (!GetOpenFileName(&ofn)) return FALSE;
-
- return TRUE;
-}
-#endif
-
-
-// dllmain
-BOOL WINAPI dllmain(HINSTANCE hInst, DWORD dwReason, LPVOID) {
- g_hInst = hInst;
- return TRUE;
-}
-
diff --git a/plugins/CryptoPP/src/commonheaders.h b/plugins/CryptoPP/src/commonheaders.h index aa2b79c773..0d1c068d9e 100644 --- a/plugins/CryptoPP/src/commonheaders.h +++ b/plugins/CryptoPP/src/commonheaders.h @@ -29,6 +29,8 @@ #include <windows.h>
#include <wincrypt.h>
#include <winsock2.h>
+#include <CommCtrl.h>
+#include <CommDlg.h>
#include <malloc.h>
#include <process.h>
@@ -70,9 +72,6 @@ extern LPCSTR szModuleName;
extern LPCSTR szVersionStr;
-extern TCHAR TEMP[MAX_PATH];
-extern int TEMP_SIZE;
-extern BOOL isVista;
// shared vars
extern HINSTANCE g_hInst;
diff --git a/plugins/CryptoPP/src/cpp_gpgw.cpp b/plugins/CryptoPP/src/cpp_gpgw.cpp index e6a5899fc2..ff62e0104d 100644 --- a/plugins/CryptoPP/src/cpp_gpgw.cpp +++ b/plugins/CryptoPP/src/cpp_gpgw.cpp @@ -5,20 +5,6 @@ HMODULE hgpg; HRSRC hRS_gpg;
PBYTE pRS_gpg;
-extern DLLEXPORT int __cdecl _gpg_init(void);
-extern DLLEXPORT int __cdecl _gpg_done(void);
-extern DLLEXPORT int __cdecl _gpg_open_keyrings(LPSTR,LPSTR);
-extern DLLEXPORT int __cdecl _gpg_close_keyrings(void);
-extern DLLEXPORT void __cdecl _gpg_set_log(LPCSTR);
-extern DLLEXPORT void __cdecl _gpg_set_tmp(LPCSTR);
-extern DLLEXPORT LPSTR __cdecl _gpg_get_error(void);
-extern DLLEXPORT int __cdecl _gpg_size_keyid(void);
-extern DLLEXPORT int __cdecl _gpg_select_keyid(HWND,LPSTR);
-extern DLLEXPORT LPSTR __cdecl _gpg_encrypt(LPCSTR,LPCSTR);
-extern DLLEXPORT LPSTR __cdecl _gpg_decrypt(LPCSTR);
-extern DLLEXPORT LPSTR __cdecl _gpg_get_passphrases();
-extern DLLEXPORT void __cdecl _gpg_set_passphrases(LPCSTR);
-
int __cdecl _gpg_init(void);
int __cdecl _gpg_done(void);
int __cdecl _gpg_open_keyrings(LPSTR,LPSTR);
@@ -33,130 +19,17 @@ LPSTR __cdecl _gpg_decrypt(LPCSTR); LPSTR __cdecl _gpg_get_passphrases();
void __cdecl _gpg_set_passphrases(LPCSTR);
-int (__cdecl *p_gpg_init)(void);
-int (__cdecl *p_gpg_done)(void);
-int (__cdecl *p_gpg_open_keyrings)(LPSTR,LPSTR);
-int (__cdecl *p_gpg_close_keyrings)(void);
-void (__cdecl *p_gpg_set_log)(LPCSTR);
-void (__cdecl *p_gpg_set_tmp)(LPCSTR);
-LPSTR (__cdecl *p_gpg_get_error)(void);
-int (__cdecl *p_gpg_size_keyid)(void);
-int (__cdecl *p_gpg_select_keyid)(HWND,LPSTR);
-LPSTR (__cdecl *p_gpg_encrypt)(LPCSTR,LPCSTR);
-LPSTR (__cdecl *p_gpg_decrypt)(LPCSTR);
-LPSTR (__cdecl *p_gpg_get_passphrases)();
-void (__cdecl *p_gpg_set_passphrases)(LPCSTR);
-
-
-#define GPA(x) \
- { \
- *((PVOID*)&p##x) = (PVOID)GetProcAddress(mod, TEXT(#x)); \
- if (!p##x) { \
- return 0; \
- } \
- }
-
-int load_gpg_dll(HMODULE mod) {
-
- GPA(_gpg_init);
- GPA(_gpg_done);
- GPA(_gpg_open_keyrings);
- GPA(_gpg_close_keyrings);
- GPA(_gpg_set_log);
- GPA(_gpg_set_tmp);
- GPA(_gpg_get_error);
- GPA(_gpg_size_keyid);
- GPA(_gpg_select_keyid);
- GPA(_gpg_encrypt);
- GPA(_gpg_decrypt);
- GPA(_gpg_get_passphrases);
- GPA(_gpg_set_passphrases);
-
- return 1;
-}
-
-#undef GPA
-
-
-#define GPA(x) \
- { \
- *((PVOID*)&p##x) = (PVOID)MemGetProcAddress(mod, TEXT(#x)); \
- if (!p##x) { \
- return 0; \
- } \
- }
-
-int load_gpg_mem(HMODULE mod) {
-
- GPA(_gpg_init);
- GPA(_gpg_done);
- GPA(_gpg_open_keyrings);
- GPA(_gpg_close_keyrings);
- GPA(_gpg_set_log);
- GPA(_gpg_set_tmp);
- GPA(_gpg_get_error);
- GPA(_gpg_size_keyid);
- GPA(_gpg_select_keyid);
- GPA(_gpg_encrypt);
- GPA(_gpg_decrypt);
- GPA(_gpg_get_passphrases);
- GPA(_gpg_set_passphrases);
-
- return 1;
-}
-
-#undef GPA
-
-
int __cdecl gpg_init()
{
- int r; char t[MAX_PATH];
- if ( isVista ) {
- sprintf(t,"%s\\gnupgw.dll",TEMP);
- ExtractFile(t,666,1);
- hgpg = LoadLibraryA(t);
- }
- else {
- hRS_gpg = FindResource( g_hInst, MAKEINTRESOURCE(1), MAKEINTRESOURCE(666) );
- pRS_gpg = (PBYTE) LoadResource( g_hInst, hRS_gpg ); LockResource( pRS_gpg );
- hgpg = MemLoadLibrary( pRS_gpg );
- }
- if (hgpg) {
- if ( isVista ) load_gpg_dll(hgpg);
- else load_gpg_mem(hgpg);
- r = p_gpg_init();
- if (r) {
- return r;
- }
- if ( isVista ) {
- FreeLibrary(hgpg);
- }
- else {
- MemFreeLibrary(hgpg);
- UnlockResource( pRS_gpg );
- FreeResource( pRS_gpg );
- }
- }
-
- hgpg = 0;
-
- return 0;
+ hgpg = g_hInst;
+ return _gpg_init();
}
-
int __cdecl gpg_done()
{
int r = 0;
if (hgpg) {
- r = p_gpg_done();
- if ( isVista ) {
- FreeLibrary(hgpg);
- }
- else {
- MemFreeLibrary(hgpg);
- UnlockResource( pRS_gpg );
- FreeResource( pRS_gpg );
- }
+ r = _gpg_done();
hgpg = 0;
}
return r;
@@ -165,31 +38,31 @@ int __cdecl gpg_done() int __cdecl gpg_open_keyrings(LPSTR ExecPath, LPSTR HomePath)
{
- return p_gpg_open_keyrings(ExecPath, HomePath);
+ return _gpg_open_keyrings(ExecPath, HomePath);
}
int __cdecl gpg_close_keyrings()
{
- return p_gpg_close_keyrings();
+ return _gpg_close_keyrings();
}
void __cdecl gpg_set_log(LPCSTR LogPath)
{
- p_gpg_set_log(LogPath);
+ _gpg_set_log(LogPath);
}
void __cdecl gpg_set_tmp(LPCSTR TmpPath)
{
- p_gpg_set_tmp(TmpPath);
+ _gpg_set_tmp(TmpPath);
}
LPSTR __cdecl gpg_get_error()
{
- return p_gpg_get_error();
+ return _gpg_get_error();
}
@@ -200,7 +73,7 @@ LPSTR __cdecl gpg_encrypt(pCNTX ptr, LPCSTR szPlainMsg) SAFE_FREE(ptr->tmp);
LPSTR szEncMsg;
- szEncMsg = p_gpg_encrypt(szPlainMsg,(LPCSTR)p->gpgKeyID);
+ szEncMsg = _gpg_encrypt(szPlainMsg,(LPCSTR)p->gpgKeyID);
if (!szEncMsg) return 0;
ptr->tmp = (LPSTR)_strdup(szEncMsg);
@@ -215,11 +88,11 @@ LPSTR __cdecl gpg_decrypt(pCNTX ptr, LPCSTR szEncMsg) ptr->error = ERROR_NONE;
SAFE_FREE(ptr->tmp);
- LPSTR szPlainMsg = p_gpg_decrypt(szEncMsg);
+ LPSTR szPlainMsg = _gpg_decrypt(szEncMsg);
/* if (!szPlainMsg) {
ptr = get_context_on_id(hPGPPRIV); // find private pgp keys
if (ptr && ptr->pgpKey)
- szPlainMsg = p_gpg_decrypt_key(szEncMsg,(LPCSTR)ptr->pgpKey);
+ szPlainMsg = _gpg_decrypt_key(szEncMsg,(LPCSTR)ptr->pgpKey);
if (!szPlainMsg) return NULL;
}*/
@@ -282,7 +155,7 @@ int __cdecl gpg_set_key(HANDLE context, LPCSTR RemoteKey) if (!ptr) return 0;
ptr->error = ERROR_NONE;
-// if (!p_gpg_check_key(RemoteKey)) return 0;
+// if (!_gpg_check_key(RemoteKey)) return 0;
SAFE_FREE(ptr->pgpKey);
ptr->pgpKey = (BYTE *) malloc(strlen(RemoteKey)+1);
@@ -309,25 +182,25 @@ int __cdecl gpg_set_keyid(HANDLE context, LPCSTR RemoteKeyID) int __cdecl gpg_size_keyid()
{
- return p_gpg_size_keyid();
+ return _gpg_size_keyid();
}
int __cdecl gpg_select_keyid(HWND hDlg,LPSTR szKeyID)
{
- return p_gpg_select_keyid(hDlg,szKeyID);
+ return _gpg_select_keyid(hDlg,szKeyID);
}
LPSTR __cdecl gpg_get_passphrases()
{
- return p_gpg_get_passphrases();
+ return _gpg_get_passphrases();
}
void __cdecl gpg_set_passphrases(LPCSTR buffer)
{
- p_gpg_set_passphrases(buffer);
+ _gpg_set_passphrases(buffer);
}
diff --git a/plugins/CryptoPP/src/cpp_pgpw.cpp b/plugins/CryptoPP/src/cpp_pgpw.cpp index 7a70a99607..84349583c7 100644 --- a/plugins/CryptoPP/src/cpp_pgpw.cpp +++ b/plugins/CryptoPP/src/cpp_pgpw.cpp @@ -92,46 +92,8 @@ int load_pgpsdk_mem(HMODULE mod) { #undef GPA
-BOOL load_pgp_sdk(int type, int id)
-{
- int r; char t[MAX_PATH];
- pgpVer = 0;
-
- if ( isVista ) {
- sprintf(t,"%s\\pgpsdkw.dll",TEMP);
- ExtractFile(t,type,id);
- hpgpsdk = LoadLibraryA(t);
- }
- else {
- hRS_pgp = FindResource( g_hInst, MAKEINTRESOURCE(id), MAKEINTRESOURCE(type) );
- pRS_pgp = (PBYTE) LoadResource( g_hInst, hRS_pgp ); LockResource( pRS_pgp );
- hpgpsdk = MemLoadLibrary( pRS_pgp );
- }
- if (hpgpsdk) {
- if ( isVista ) load_pgpsdk_dll(hpgpsdk);
- else load_pgpsdk_mem(hpgpsdk);
- r = p_pgp_init();
- if (r) {
- pgpVer = p_pgp_get_version();
- return r;
- }
- if ( isVista ) {
- FreeLibrary(hpgpsdk);
- }
- else {
- MemFreeLibrary(hpgpsdk);
- UnlockResource( pRS_pgp );
- FreeResource( pRS_pgp );
- }
- }
- return 0;
-}
-
-
int __cdecl pgp_init()
{
- int r;
-
if ( !hPGPPRIV ) {
// create context for private pgp keys
hPGPPRIV = (HANDLE) cpp_create_context(MODE_PGP|MODE_PRIV_KEY);
@@ -140,11 +102,7 @@ int __cdecl pgp_init() memset(tmp->pdata,0,sizeof(PGPDATA));
}
- if ( r = load_pgp_sdk(666,6) ) return r;
- if ( r = load_pgp_sdk(666,8) ) return r;
-
- hpgpsdk = 0;
-
+ hpgpsdk = g_hInst;
return 0;
}
@@ -155,14 +113,6 @@ int __cdecl pgp_done() pgpVer = 0;
if (hpgpsdk) {
r = p_pgp_done();
- if ( isVista ) {
- FreeLibrary(hpgpsdk);
- }
- else {
- MemFreeLibrary(hpgpsdk);
- UnlockResource( pRS_pgp );
- FreeResource( pRS_pgp );
- }
hpgpsdk = 0;
}
return r;
diff --git a/plugins/CryptoPP/src/main.cpp b/plugins/CryptoPP/src/main.cpp index dacdfda235..ae447897f6 100644 --- a/plugins/CryptoPP/src/main.cpp +++ b/plugins/CryptoPP/src/main.cpp @@ -11,10 +11,6 @@ HANDLE hRSA4096 = NULL; CRITICAL_SECTION localQueueMutex;
CRITICAL_SECTION localContextMutex;
-char TEMP[MAX_PATH];
-int TEMP_SIZE = 0;
-BOOL isVista = 0;
-
PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -33,11 +29,6 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID) {
if (dwReason == DLL_PROCESS_ATTACH) {
g_hInst = hInst;
- #ifdef _DEBUG
- isVista = 1;
- #else
- isVista = ( (DWORD)(LOBYTE(LOWORD(GetVersion()))) == 6 );
- #endif
InitializeCriticalSection(&localQueueMutex);
InitializeCriticalSection(&localContextMutex);
}
|