1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "callback.h"
#include "librarian.h"
#include "box64context.h"
#include "emu/x64emu_private.h"
#include "myalign.h"
const char* smime3Name = "libsmime3.so";
#define LIBNAME smime3
#include "generated/wrappedsmime3types.h"
#include "wrappercallback.h"
#undef SUPER
#define SUPER() \
GO(0) \
GO(1) \
GO(2) \
GO(3) \
GO(4)
// SECKEYGetPasswordKey ...
#define GO(A) \
static uintptr_t my_SECKEYGetPasswordKey_fct_##A = 0; \
static void* my_SECKEYGetPasswordKey_##A(void* a, void* b) \
{ \
return (void*)RunFunctionFmt(my_SECKEYGetPasswordKey_fct_##A, "pp", a, b);\
}
SUPER()
#undef GO
static void* find_SECKEYGetPasswordKey_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_SECKEYGetPasswordKey_fct_##A == (uintptr_t)fct) return my_SECKEYGetPasswordKey_##A;
SUPER()
#undef GO
#define GO(A) if(my_SECKEYGetPasswordKey_fct_##A == 0) {my_SECKEYGetPasswordKey_fct_##A = (uintptr_t)fct; return my_SECKEYGetPasswordKey_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for smime3 SECKEYGetPasswordKey callback\n");
return NULL;
}
// digestOpenFn ...
#define GO(A) \
static uintptr_t my_digestOpenFn_fct_##A = 0; \
static int my_digestOpenFn_##A(void* a, int b) \
{ \
return RunFunctionFmt(my_digestOpenFn_fct_##A, "pi", a, b); \
}
SUPER()
#undef GO
static void* find_digestOpenFn_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_digestOpenFn_fct_##A == (uintptr_t)fct) return my_digestOpenFn_##A;
SUPER()
#undef GO
#define GO(A) if(my_digestOpenFn_fct_##A == 0) {my_digestOpenFn_fct_##A = (uintptr_t)fct; return my_digestOpenFn_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for smime3 digestOpenFn callback\n");
return NULL;
}
// digestCloseFn ...
#define GO(A) \
static uintptr_t my_digestCloseFn_fct_##A = 0; \
static int my_digestCloseFn_##A(void* a, int b) \
{ \
return RunFunctionFmt(my_digestCloseFn_fct_##A, "pi", a, b); \
}
SUPER()
#undef GO
static void* find_digestCloseFn_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_digestCloseFn_fct_##A == (uintptr_t)fct) return my_digestCloseFn_##A;
SUPER()
#undef GO
#define GO(A) if(my_digestCloseFn_fct_##A == 0) {my_digestCloseFn_fct_##A = (uintptr_t)fct; return my_digestCloseFn_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for smime3 digestCloseFn callback\n");
return NULL;
}
// digestIOFn ...
#define GO(A) \
static uintptr_t my_digestIOFn_fct_##A = 0; \
static int my_digestIOFn_##A(void* a, void* b, unsigned long c) \
{ \
return RunFunctionFmt(my_digestIOFn_fct_##A, "ppL", a, b, c); \
}
SUPER()
#undef GO
static void* find_digestIOFn_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_digestIOFn_fct_##A == (uintptr_t)fct) return my_digestIOFn_##A;
SUPER()
#undef GO
#define GO(A) if(my_digestIOFn_fct_##A == 0) {my_digestIOFn_fct_##A = (uintptr_t)fct; return my_digestIOFn_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for smime3 digestIOFn callback\n");
return NULL;
}
// SEC_PKCS12NicknameCollisionCallback ...
#define GO(A) \
static uintptr_t my_SEC_PKCS12NicknameCollisionCallback_fct_##A = 0; \
static void* my_SEC_PKCS12NicknameCollisionCallback_##A(void* a, void* b, void* c) \
{ \
return (void*)RunFunctionFmt(my_SEC_PKCS12NicknameCollisionCallback_fct_##A, "ppp", a, b, c); \
}
SUPER()
#undef GO
static void* find_SEC_PKCS12NicknameCollisionCallback_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_SEC_PKCS12NicknameCollisionCallback_fct_##A == (uintptr_t)fct) return my_SEC_PKCS12NicknameCollisionCallback_##A;
SUPER()
#undef GO
#define GO(A) if(my_SEC_PKCS12NicknameCollisionCallback_fct_##A == 0) {my_SEC_PKCS12NicknameCollisionCallback_fct_##A = (uintptr_t)fct; return my_SEC_PKCS12NicknameCollisionCallback_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for smime3 SEC_PKCS12NicknameCollisionCallback callback\n");
return NULL;
}
// SEC_PKCS12EncoderOutputCallback ...
#define GO(A) \
static uintptr_t my_SEC_PKCS12EncoderOutputCallback_fct_##A = 0; \
static void my_SEC_PKCS12EncoderOutputCallback_##A(void* a, void* b, unsigned long c) \
{ \
RunFunctionFmt(my_SEC_PKCS12EncoderOutputCallback_fct_##A, "ppL", a, b, c); \
}
SUPER()
#undef GO
static void* find_SEC_PKCS12EncoderOutputCallback_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_SEC_PKCS12EncoderOutputCallback_fct_##A == (uintptr_t)fct) return my_SEC_PKCS12EncoderOutputCallback_##A;
SUPER()
#undef GO
#define GO(A) if(my_SEC_PKCS12EncoderOutputCallback_fct_##A == 0) {my_SEC_PKCS12EncoderOutputCallback_fct_##A = (uintptr_t)fct; return my_SEC_PKCS12EncoderOutputCallback_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for smime3 SEC_PKCS12EncoderOutputCallback callback\n");
return NULL;
}
// NSSCMSContentCallback ...
#define GO(A) \
static uintptr_t my_NSSCMSContentCallback_fct_##A = 0; \
static void my_NSSCMSContentCallback_##A(void* a, void* b, unsigned long c) \
{ \
RunFunctionFmt(my_NSSCMSContentCallback_fct_##A, "ppL", a, b, c); \
}
SUPER()
#undef GO
static void* find_NSSCMSContentCallback_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_NSSCMSContentCallback_fct_##A == (uintptr_t)fct) return my_NSSCMSContentCallback_##A;
SUPER()
#undef GO
#define GO(A) if(my_NSSCMSContentCallback_fct_##A == 0) {my_NSSCMSContentCallback_fct_##A = (uintptr_t)fct; return my_NSSCMSContentCallback_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for smime3 NSSCMSContentCallback callback\n");
return NULL;
}
// PK11PasswordFunc ...
#define GO(A) \
static uintptr_t my_PK11PasswordFunc_fct_##A = 0; \
static void* my_PK11PasswordFunc_##A(void* a, int b, void* c) \
{ \
return (void*)RunFunctionFmt(my_PK11PasswordFunc_fct_##A, "pip", a, b, c); \
}
SUPER()
#undef GO
static void* find_PK11PasswordFunc_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_PK11PasswordFunc_fct_##A == (uintptr_t)fct) return my_PK11PasswordFunc_##A;
SUPER()
#undef GO
#define GO(A) if(my_PK11PasswordFunc_fct_##A == 0) {my_PK11PasswordFunc_fct_##A = (uintptr_t)fct; return my_PK11PasswordFunc_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for smime3 PK11PasswordFunc callback\n");
return NULL;
}
// NSSCMSGetDecryptKeyCallback ...
#define GO(A) \
static uintptr_t my_NSSCMSGetDecryptKeyCallback_fct_##A = 0; \
static void* my_NSSCMSGetDecryptKeyCallback_##A(void* a, void* b) \
{ \
return (void*)RunFunctionFmt(my_NSSCMSGetDecryptKeyCallback_fct_##A, "pp", a, b); \
}
SUPER()
#undef GO
static void* find_NSSCMSGetDecryptKeyCallback_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_NSSCMSGetDecryptKeyCallback_fct_##A == (uintptr_t)fct) return my_NSSCMSGetDecryptKeyCallback_##A;
SUPER()
#undef GO
#define GO(A) if(my_NSSCMSGetDecryptKeyCallback_fct_##A == 0) {my_NSSCMSGetDecryptKeyCallback_fct_##A = (uintptr_t)fct; return my_NSSCMSGetDecryptKeyCallback_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for smime3 NSSCMSGetDecryptKeyCallback callback\n");
return NULL;
}
// CERTImportCertificateFunc ...
#define GO(A) \
static uintptr_t my_CERTImportCertificateFunc_fct_##A = 0; \
static int my_CERTImportCertificateFunc_##A(void* a, void* b, int c) \
{ \
return (int)RunFunctionFmt(my_CERTImportCertificateFunc_fct_##A, "ppi", a, b, c); \
}
SUPER()
#undef GO
static void* find_CERTImportCertificateFunc_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_CERTImportCertificateFunc_fct_##A == (uintptr_t)fct) return my_CERTImportCertificateFunc_##A;
SUPER()
#undef GO
#define GO(A) if(my_CERTImportCertificateFunc_fct_##A == 0) {my_CERTImportCertificateFunc_fct_##A = (uintptr_t)fct; return my_CERTImportCertificateFunc_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for smime3 CERTImportCertificateFunc callback\n");
return NULL;
}
#undef SUPER
EXPORT void my_SEC_PKCS12CreateExportContext(x64emu_t* emu, void* f, void* pwfnarg, void* slot, void* wincx)
{
my->SEC_PKCS12CreateExportContext(find_SECKEYGetPasswordKey_Fct(f), pwfnarg, slot, wincx);
}
EXPORT void* my_SEC_PKCS12DecoderStart(x64emu_t* emu, void* item, void* slot, void* wincx, void* dOpen, void* dClose,
void* dRead, void* dWrite, void* dArg)
{
return my->SEC_PKCS12DecoderStart(item, slot, wincx, find_digestOpenFn_Fct(dOpen), find_digestCloseFn_Fct(dClose),
find_digestIOFn_Fct(dRead), find_digestIOFn_Fct(dWrite), dArg);
}
EXPORT int my_SEC_PKCS12DecoderValidateBags(x64emu_t* emu, void* ctx, void* f)
{
return my->SEC_PKCS12DecoderValidateBags(ctx, find_SEC_PKCS12NicknameCollisionCallback_Fct(f));
}
EXPORT int my_SEC_PKCS12Encode(x64emu_t* emu, void* p12exp, void* f, void* arg)
{
return my->SEC_PKCS12Encode(p12exp, find_SEC_PKCS12EncoderOutputCallback_Fct(f), arg);
}
EXPORT void* my_NSS_CMSEncoder_Start(x64emu_t* emu, void* cmsg, void* outputf, void* outputarg,
void* dest, void* destpool, void* pwfn, void* pwfnarg,
void* decryptcb, void* decryptarg, void* detached, void* items)
{
return my->NSS_CMSEncoder_Start(cmsg, find_NSSCMSContentCallback_Fct(outputf), outputarg,
dest, destpool, find_PK11PasswordFunc_Fct(pwfn), pwfnarg,
find_NSSCMSGetDecryptKeyCallback_Fct(decryptcb), decryptarg, detached, items);
}
EXPORT int my_CERT_DecodeCertPackage(x64emu_t* emu, void* cert, int len, void* f, void* data)
{
return my->CERT_DecodeCertPackage(cert, len, find_CERTImportCertificateFunc_Fct(f), data);
}
#include "wrappedlib_init.h"
|