Esempio n. 1
0
int __cdecl _pgp_init()
{
	if(!pgpErrMsg)
		pgpErrMsg = (LPSTR) LocalAlloc(LPTR,pgpErrMsgLen);

	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)) {
	case 2:
		pgpVer = 1<<24 | ((minor+1)<<16) | (PGPRevVersion(pgpVer)<<8);
		break;
	case 3:
		pgpVer = 1<<24 | ((minor+5)<<16) | (PGPRevVersion(pgpVer)<<8);
		break;
	default:
		pgpVer = 1<<24 | (minor<<16) | (PGPRevVersion(pgpVer)<<8);
		break;
	}
#else
	pgpVer = PGPGetPGPsdkVersion();
#endif

	return 1;
}
Esempio n. 2
0
int __cdecl _pgp_init()
{
	if (!pgpErrMsg)
		pgpErrMsg = (LPSTR) LocalAlloc(LPTR,pgpErrMsgLen);

	pgpVer = 0;
	#if defined(_WIN64)
		return 0;
	#else
		__try {
			if (CheckPGPError(PGPsdkInit(0)) || CheckPGPError(PGPsdkUILibInit(0))) return 0;
			PGPNewContext(kPGPsdk20APIVersion, &pgpContext);
		}
		__except ( EXCEPTION_EXECUTE_HANDLER ) {
			return 0;
		}

		pgpVer = PGPGetPGPsdkVersion();
		return 1;
	#endif
}
	BOOL APIENTRY
DllMain(
	HANDLE	hModule, 
	DWORD	ul_reason_for_call, 
	LPVOID	lpReserved)
{
	BOOL	success = TRUE;
	
	switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
		{
			gPGPsdkUILibInst = hModule;
			
			if( IsntPGPError( PGPsdkUILibInit() ) )
			{
				sInitializedLibrary = TRUE;
			}
			else
			{
				success = FALSE;
			}

			break;
		}
		
		case DLL_PROCESS_DETACH:
		{
			if( sInitializedLibrary )
			{
				(void) PGPsdkUILibCleanup();
				sInitializedLibrary = FALSE;
			}

			break;
		}
    }

    return success;
}