Revert "winex11.drv: Optimise getting the bits of a DIB after calling SetDIBits."
[wine] / dlls / cryptdlg / main.c
1 /*
2  * Copyright 2008 Maarten Lankhorst
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wincrypt.h"
26 #include "wintrust.h"
27 #include "winuser.h"
28 #include "cryptdlg.h"
29 #include "wine/debug.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(cryptdlg);
32
33 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
34 {
35     TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
36
37     switch (fdwReason)
38     {
39         case DLL_WINE_PREATTACH:
40             return FALSE;    /* prefer native version */
41         case DLL_PROCESS_ATTACH:
42             DisableThreadLibraryCalls(hinstDLL);
43             break;
44         case DLL_PROCESS_DETACH:
45             break;
46         default:
47             break;
48     }
49     return TRUE;
50 }
51
52 /***********************************************************************
53  *              GetFriendlyNameOfCertA (CRYPTDLG.@)
54  */
55 DWORD WINAPI GetFriendlyNameOfCertA(PCCERT_CONTEXT pccert, LPSTR pchBuffer,
56                              DWORD cchBuffer)
57 {
58     return CertGetNameStringA(pccert, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL,
59      pchBuffer, cchBuffer);
60 }
61
62 /***********************************************************************
63  *              GetFriendlyNameOfCertW (CRYPTDLG.@)
64  */
65 DWORD WINAPI GetFriendlyNameOfCertW(PCCERT_CONTEXT pccert, LPWSTR pchBuffer,
66                              DWORD cchBuffer)
67 {
68     return CertGetNameStringW(pccert, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL,
69      pchBuffer, cchBuffer);
70 }
71
72 /***********************************************************************
73  *              CertTrustInit (CRYPTDLG.@)
74  */
75 HRESULT WINAPI CertTrustInit(CRYPT_PROVIDER_DATA *pProvData)
76 {
77     FIXME("(%p)\n", pProvData);
78     return E_NOTIMPL;
79 }
80
81 /***********************************************************************
82  *              CertTrustCertPolicy (CRYPTDLG.@)
83  */
84 BOOL WINAPI CertTrustCertPolicy(CRYPT_PROVIDER_DATA *pProvData, DWORD idxSigner, BOOL fCounterSignerChain, DWORD idxCounterSigner)
85 {
86     FIXME("(%p, %d, %s, %d)\n", pProvData, idxSigner, fCounterSignerChain ? "TRUE" : "FALSE", idxCounterSigner);
87     return FALSE;
88 }
89
90 /***********************************************************************
91  *              CertTrustCleanup (CRYPTDLG.@)
92  */
93 HRESULT WINAPI CertTrustCleanup(CRYPT_PROVIDER_DATA *pProvData)
94 {
95     FIXME("(%p)\n", pProvData);
96     return E_NOTIMPL;
97 }
98
99 /***********************************************************************
100  *              CertTrustFinalPolicy (CRYPTDLG.@)
101  */
102 HRESULT WINAPI CertTrustFinalPolicy(CRYPT_PROVIDER_DATA *pProvData)
103 {
104     FIXME("(%p)\n", pProvData);
105     return E_NOTIMPL;
106 }
107
108 /***********************************************************************
109  *              DllRegisterServer (CRYPTDLG.@)
110  */
111 HRESULT WINAPI DllRegisterServer(void)
112 {
113     static WCHAR cryptdlg[] = { 'c','r','y','p','t','d','l','g','.',
114      'd','l','l',0 };
115     static WCHAR wintrust[] = { 'w','i','n','t','r','u','s','t','.',
116      'd','l','l',0 };
117     static WCHAR certTrustInit[] = { 'C','e','r','t','T','r','u','s','t',
118      'I','n','i','t',0 };
119     static WCHAR wintrustCertificateTrust[] = { 'W','i','n','t','r','u','s','t',
120      'C','e','r','t','i','f','i','c','a','t','e','T','r','u','s','t',0 };
121     static WCHAR certTrustCertPolicy[] = { 'C','e','r','t','T','r','u','s','t',
122      'C','e','r','t','P','o','l','i','c','y',0 };
123     static WCHAR certTrustFinalPolicy[] = { 'C','e','r','t','T','r','u','s','t',
124      'F','i','n','a','l','P','o','l','i','c','y',0 };
125     static WCHAR certTrustCleanup[] = { 'C','e','r','t','T','r','u','s','t',
126      'C','l','e','a','n','u','p',0 };
127     CRYPT_REGISTER_ACTIONID reg;
128     GUID guid = CERT_CERTIFICATE_ACTION_VERIFY;
129     HRESULT hr = S_OK;
130
131     memset(&reg, 0, sizeof(reg));
132     reg.cbStruct = sizeof(reg);
133     reg.sInitProvider.cbStruct = sizeof(CRYPT_TRUST_REG_ENTRY);
134     reg.sInitProvider.pwszDLLName = cryptdlg;
135     reg.sInitProvider.pwszFunctionName = certTrustInit;
136     reg.sCertificateProvider.cbStruct = sizeof(CRYPT_TRUST_REG_ENTRY);
137     reg.sCertificateProvider.pwszDLLName = wintrust;
138     reg.sCertificateProvider.pwszFunctionName = wintrustCertificateTrust;
139     reg.sCertificatePolicyProvider.cbStruct = sizeof(CRYPT_TRUST_REG_ENTRY);
140     reg.sCertificatePolicyProvider.pwszDLLName = cryptdlg;
141     reg.sCertificatePolicyProvider.pwszFunctionName = certTrustCertPolicy;
142     reg.sFinalPolicyProvider.cbStruct = sizeof(CRYPT_TRUST_REG_ENTRY);
143     reg.sFinalPolicyProvider.pwszDLLName = cryptdlg;
144     reg.sFinalPolicyProvider.pwszFunctionName = certTrustFinalPolicy;
145     reg.sCleanupProvider.cbStruct = sizeof(CRYPT_TRUST_REG_ENTRY);
146     reg.sCleanupProvider.pwszDLLName = cryptdlg;
147     reg.sCleanupProvider.pwszFunctionName = certTrustCleanup;
148     if (!WintrustAddActionID(&guid, WT_ADD_ACTION_ID_RET_RESULT_FLAG, &reg))
149         hr = GetLastError();
150     return hr;
151 }
152
153 /***********************************************************************
154  *              DllUnregisterServer (CRYPTDLG.@)
155  */
156 HRESULT WINAPI DllUnregisterServer(void)
157 {
158     GUID guid = CERT_CERTIFICATE_ACTION_VERIFY;
159
160     WintrustRemoveActionID(&guid);
161     return S_OK;
162 }