diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-09-18 21:46:00 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-09-18 21:46:00 +0200 |
| commit | 6f92db542bf146a6442f678862c413d97756e774 (patch) | |
| tree | 22c8181ccae1ba50348764279d0c04c987fd8705 /src | |
| parent | 8531750631a1d53ca6061bfbe458e8998415850a (diff) | |
| download | box64-6f92db542bf146a6442f678862c413d97756e774.tar.gz box64-6f92db542bf146a6442f678862c413d97756e774.zip | |
Updated wrapped libnns3, libnssutil3 and libsmime3 with more wrapped functions (from box86)
Diffstat (limited to 'src')
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 20 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappednss3types.h | 4 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedsmime3types.h | 12 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.c | 19 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.h | 8 | ||||
| -rwxr-xr-x | src/wrapped/wrappednss3.c | 80 | ||||
| -rwxr-xr-x | src/wrapped/wrappednss3_private.h | 167 | ||||
| -rwxr-xr-x | src/wrapped/wrappednssutil3_private.h | 4 | ||||
| -rwxr-xr-x | src/wrapped/wrappedsmime3.c | 298 | ||||
| -rwxr-xr-x | src/wrapped/wrappedsmime3_private.h | 56 |
10 files changed, 555 insertions, 113 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index 56c54d8f..87b6989d 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -141,6 +141,7 @@ #() iFuu #() iFuL #() iFup +#() iFli #() iFlp #() iFLL #() iFLp @@ -792,6 +793,7 @@ #() pFiiuu #() pFiiup #() pFiipi +#() pFiipp #() pFipii #() pFipip #() pFippi @@ -804,6 +806,7 @@ #() pFdddd #() pFDipp #() pFlfff +#() pFLiip #() pFpiii #() pFpiip #() pFpiuu @@ -1493,6 +1496,7 @@ #() pFpuuuwwu #() pFpuupwwC #() pFplppppp +#() pFpLppiip #() pFppiiipp #() pFppiiCCC #() pFppiippp @@ -1663,6 +1667,7 @@ #() iFpppiiipip #() iFpppiiuuii #() iFpppiipiiu +#() iFppppiiupp #() iFppppppppu #() iFppppppppp #() uFEipippppp @@ -1672,6 +1677,7 @@ #() pFEppuippuu #() pFEpppppiiV #() pFEpppppppi +#() pFEpppppppp #() pFpiiiiuuuu #() pFpCuWCCuuu #() pFpuuwwWWww @@ -1721,6 +1727,7 @@ #() iFpppiiipipi #() iFpppLLipppp #() iFppppiiuuii +#() iFpppppppipi #() uFpppppppppp #() pFEiippppppp #() pFEpiiiiiipp @@ -1787,6 +1794,7 @@ #() iFpppllipppppp #() iFpppppppppppp #() pFEppiiuuuipii +#() pFEppppppppppp #() pFWWiCCCCiipup #() pFpCuuWWwwCCup #() pFpuuuWWWWWWWW @@ -2876,6 +2884,8 @@ wrappedmpg123: - mpg123_replace_reader_handle_64 wrappednspr4: wrappednss3: +- vFp: + - PK11_SetPasswordFunc wrappednssutil3: wrappedopenal: - vFv: @@ -3269,6 +3279,16 @@ wrappedsdl2ttf: - TTF_OpenFontIndexRW wrappedselinux: wrappedsmime3: +- iFpp: + - SEC_PKCS12DecoderValidateBags +- iFppp: + - SEC_PKCS12Encode +- pFpppp: + - SEC_PKCS12CreateExportContext +- pFpppppppp: + - SEC_PKCS12DecoderStart +- pFppppppppppp: + - NSS_CMSEncoder_Start wrappedsmpeg: - pFppi: - SMPEG_new_rwops diff --git a/src/wrapped/generated/wrappednss3types.h b/src/wrapped/generated/wrappednss3types.h index 1015f359..b61ede44 100644 --- a/src/wrapped/generated/wrappednss3types.h +++ b/src/wrapped/generated/wrappednss3types.h @@ -11,7 +11,9 @@ #define ADDED_FUNCTIONS() #endif +typedef void (*vFp_t)(void*); -#define SUPER() ADDED_FUNCTIONS() +#define SUPER() ADDED_FUNCTIONS() \ + GO(PK11_SetPasswordFunc, vFp_t) #endif // __wrappednss3TYPES_H_ diff --git a/src/wrapped/generated/wrappedsmime3types.h b/src/wrapped/generated/wrappedsmime3types.h index 316492de..fc14d0f9 100644 --- a/src/wrapped/generated/wrappedsmime3types.h +++ b/src/wrapped/generated/wrappedsmime3types.h @@ -11,7 +11,17 @@ #define ADDED_FUNCTIONS() #endif +typedef int64_t (*iFpp_t)(void*, void*); +typedef int64_t (*iFppp_t)(void*, void*, void*); +typedef void* (*pFpppp_t)(void*, void*, void*, void*); +typedef void* (*pFpppppppp_t)(void*, void*, void*, void*, void*, void*, void*, void*); +typedef void* (*pFppppppppppp_t)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*); -#define SUPER() ADDED_FUNCTIONS() +#define SUPER() ADDED_FUNCTIONS() \ + GO(SEC_PKCS12DecoderValidateBags, iFpp_t) \ + GO(SEC_PKCS12Encode, iFppp_t) \ + GO(SEC_PKCS12CreateExportContext, pFpppp_t) \ + GO(SEC_PKCS12DecoderStart, pFpppppppp_t) \ + GO(NSS_CMSEncoder_Start, pFppppppppppp_t) #endif // __wrappedsmime3TYPES_H_ diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index 50df6300..4e732782 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -175,6 +175,7 @@ typedef int64_t (*iFui_t)(uint64_t, int64_t); typedef int64_t (*iFuu_t)(uint64_t, uint64_t); typedef int64_t (*iFuL_t)(uint64_t, uintptr_t); typedef int64_t (*iFup_t)(uint64_t, void*); +typedef int64_t (*iFli_t)(intptr_t, int64_t); typedef int64_t (*iFlp_t)(intptr_t, void*); typedef int64_t (*iFLL_t)(uintptr_t, uintptr_t); typedef int64_t (*iFLp_t)(uintptr_t, void*); @@ -826,6 +827,7 @@ typedef void* (*pFiiiu_t)(int64_t, int64_t, int64_t, uint64_t); typedef void* (*pFiiuu_t)(int64_t, int64_t, uint64_t, uint64_t); typedef void* (*pFiiup_t)(int64_t, int64_t, uint64_t, void*); typedef void* (*pFiipi_t)(int64_t, int64_t, void*, int64_t); +typedef void* (*pFiipp_t)(int64_t, int64_t, void*, void*); typedef void* (*pFipii_t)(int64_t, void*, int64_t, int64_t); typedef void* (*pFipip_t)(int64_t, void*, int64_t, void*); typedef void* (*pFippi_t)(int64_t, void*, void*, int64_t); @@ -838,6 +840,7 @@ typedef void* (*pFdipp_t)(double, int64_t, void*, void*); typedef void* (*pFdddd_t)(double, double, double, double); typedef void* (*pFDipp_t)(long double, int64_t, void*, void*); typedef void* (*pFlfff_t)(intptr_t, float, float, float); +typedef void* (*pFLiip_t)(uintptr_t, int64_t, int64_t, void*); typedef void* (*pFpiii_t)(void*, int64_t, int64_t, int64_t); typedef void* (*pFpiip_t)(void*, int64_t, int64_t, void*); typedef void* (*pFpiuu_t)(void*, int64_t, uint64_t, uint64_t); @@ -1527,6 +1530,7 @@ typedef void* (*pFpCpWWup_t)(void*, uint8_t, void*, uint16_t, uint16_t, uint64_t typedef void* (*pFpuuuwwu_t)(void*, uint64_t, uint64_t, uint64_t, int16_t, int16_t, uint64_t); typedef void* (*pFpuupwwC_t)(void*, uint64_t, uint64_t, void*, int16_t, int16_t, uint8_t); typedef void* (*pFplppppp_t)(void*, intptr_t, void*, void*, void*, void*, void*); +typedef void* (*pFpLppiip_t)(void*, uintptr_t, void*, void*, int64_t, int64_t, void*); typedef void* (*pFppiiipp_t)(void*, void*, int64_t, int64_t, int64_t, void*, void*); typedef void* (*pFppiiCCC_t)(void*, void*, int64_t, int64_t, uint8_t, uint8_t, uint8_t); typedef void* (*pFppiippp_t)(void*, void*, int64_t, int64_t, void*, void*, void*); @@ -1697,6 +1701,7 @@ typedef int64_t (*iFppLpiippp_t)(void*, void*, uintptr_t, void*, int64_t, int64_ typedef int64_t (*iFpppiiipip_t)(void*, void*, void*, int64_t, int64_t, int64_t, void*, int64_t, void*); typedef int64_t (*iFpppiiuuii_t)(void*, void*, void*, int64_t, int64_t, uint64_t, uint64_t, int64_t, int64_t); typedef int64_t (*iFpppiipiiu_t)(void*, void*, void*, int64_t, int64_t, void*, int64_t, int64_t, uint64_t); +typedef int64_t (*iFppppiiupp_t)(void*, void*, void*, void*, int64_t, int64_t, uint64_t, void*, void*); typedef int64_t (*iFppppppppu_t)(void*, void*, void*, void*, void*, void*, void*, void*, uint64_t); typedef int64_t (*iFppppppppp_t)(void*, void*, void*, void*, void*, void*, void*, void*, void*); typedef uint64_t (*uFEipippppp_t)(x64emu_t*, int64_t, void*, int64_t, void*, void*, void*, void*, void*); @@ -1706,6 +1711,7 @@ typedef void* (*pFEppiiuuLi_t)(x64emu_t*, void*, void*, int64_t, int64_t, uint64 typedef void* (*pFEppuippuu_t)(x64emu_t*, void*, void*, uint64_t, int64_t, void*, void*, uint64_t, uint64_t); typedef void* (*pFEpppppiiV_t)(x64emu_t*, void*, void*, void*, void*, void*, int64_t, int64_t, void*); typedef void* (*pFEpppppppi_t)(x64emu_t*, void*, void*, void*, void*, void*, void*, void*, int64_t); +typedef void* (*pFEpppppppp_t)(x64emu_t*, void*, void*, void*, void*, void*, void*, void*, void*); typedef void* (*pFpiiiiuuuu_t)(void*, int64_t, int64_t, int64_t, int64_t, uint64_t, uint64_t, uint64_t, uint64_t); typedef void* (*pFpCuWCCuuu_t)(void*, uint8_t, uint64_t, uint16_t, uint8_t, uint8_t, uint64_t, uint64_t, uint64_t); typedef void* (*pFpuuwwWWww_t)(void*, uint64_t, uint64_t, int16_t, int16_t, uint16_t, uint16_t, int16_t, int16_t); @@ -1755,6 +1761,7 @@ typedef int64_t (*iFppuuiiuupi_t)(void*, void*, uint64_t, uint64_t, int64_t, int typedef int64_t (*iFpppiiipipi_t)(void*, void*, void*, int64_t, int64_t, int64_t, void*, int64_t, void*, int64_t); typedef int64_t (*iFpppLLipppp_t)(void*, void*, void*, uintptr_t, uintptr_t, int64_t, void*, void*, void*, void*); typedef int64_t (*iFppppiiuuii_t)(void*, void*, void*, void*, int64_t, int64_t, uint64_t, uint64_t, int64_t, int64_t); +typedef int64_t (*iFpppppppipi_t)(void*, void*, void*, void*, void*, void*, void*, int64_t, void*, int64_t); typedef uint64_t (*uFpppppppppp_t)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*); typedef void* (*pFEiippppppp_t)(x64emu_t*, int64_t, int64_t, void*, void*, void*, void*, void*, void*, void*); typedef void* (*pFEpiiiiiipp_t)(x64emu_t*, void*, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, void*, void*); @@ -1821,6 +1828,7 @@ typedef int64_t (*iFpipppppppppp_t)(void*, int64_t, void*, void*, void*, void*, typedef int64_t (*iFpppllipppppp_t)(void*, void*, void*, intptr_t, intptr_t, int64_t, void*, void*, void*, void*, void*, void*); typedef int64_t (*iFpppppppppppp_t)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*); typedef void* (*pFEppiiuuuipii_t)(x64emu_t*, void*, void*, int64_t, int64_t, uint64_t, uint64_t, uint64_t, int64_t, void*, int64_t, int64_t); +typedef void* (*pFEppppppppppp_t)(x64emu_t*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*); typedef void* (*pFWWiCCCCiipup_t)(uint16_t, uint16_t, int64_t, uint8_t, uint8_t, uint8_t, uint8_t, int64_t, int64_t, void*, uint64_t, void*); typedef void* (*pFpCuuWWwwCCup_t)(void*, uint8_t, uint64_t, uint64_t, uint16_t, uint16_t, int16_t, int16_t, uint8_t, uint8_t, uint64_t, void*); typedef void* (*pFpuuuWWWWWWWW_t)(void*, uint64_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t); @@ -2033,6 +2041,7 @@ void iFui(x64emu_t *emu, uintptr_t fcn) { iFui_t fn = (iFui_t)fcn; R_RAX=(int64_ void iFuu(x64emu_t *emu, uintptr_t fcn) { iFuu_t fn = (iFuu_t)fcn; R_RAX=(int64_t)fn((uint64_t)R_RDI, (uint64_t)R_RSI); } void iFuL(x64emu_t *emu, uintptr_t fcn) { iFuL_t fn = (iFuL_t)fcn; R_RAX=(int64_t)fn((uint64_t)R_RDI, (uintptr_t)R_RSI); } void iFup(x64emu_t *emu, uintptr_t fcn) { iFup_t fn = (iFup_t)fcn; R_RAX=(int64_t)fn((uint64_t)R_RDI, (void*)R_RSI); } +void iFli(x64emu_t *emu, uintptr_t fcn) { iFli_t fn = (iFli_t)fcn; R_RAX=(int64_t)fn((intptr_t)R_RDI, (int64_t)R_RSI); } void iFlp(x64emu_t *emu, uintptr_t fcn) { iFlp_t fn = (iFlp_t)fcn; R_RAX=(int64_t)fn((intptr_t)R_RDI, (void*)R_RSI); } void iFLL(x64emu_t *emu, uintptr_t fcn) { iFLL_t fn = (iFLL_t)fcn; R_RAX=(int64_t)fn((uintptr_t)R_RDI, (uintptr_t)R_RSI); } void iFLp(x64emu_t *emu, uintptr_t fcn) { iFLp_t fn = (iFLp_t)fcn; R_RAX=(int64_t)fn((uintptr_t)R_RDI, (void*)R_RSI); } @@ -2684,6 +2693,7 @@ void pFiiiu(x64emu_t *emu, uintptr_t fcn) { pFiiiu_t fn = (pFiiiu_t)fcn; R_RAX=( void pFiiuu(x64emu_t *emu, uintptr_t fcn) { pFiiuu_t fn = (pFiiuu_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (int64_t)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX); } void pFiiup(x64emu_t *emu, uintptr_t fcn) { pFiiup_t fn = (pFiiup_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (int64_t)R_RSI, (uint64_t)R_RDX, (void*)R_RCX); } void pFiipi(x64emu_t *emu, uintptr_t fcn) { pFiipi_t fn = (pFiipi_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (int64_t)R_RSI, (void*)R_RDX, (int64_t)R_RCX); } +void pFiipp(x64emu_t *emu, uintptr_t fcn) { pFiipp_t fn = (pFiipp_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (int64_t)R_RSI, (void*)R_RDX, (void*)R_RCX); } void pFipii(x64emu_t *emu, uintptr_t fcn) { pFipii_t fn = (pFipii_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX); } void pFipip(x64emu_t *emu, uintptr_t fcn) { pFipip_t fn = (pFipip_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (void*)R_RCX); } void pFippi(x64emu_t *emu, uintptr_t fcn) { pFippi_t fn = (pFippi_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (int64_t)R_RCX); } @@ -2696,6 +2706,7 @@ void pFdipp(x64emu_t *emu, uintptr_t fcn) { pFdipp_t fn = (pFdipp_t)fcn; R_RAX=( void pFdddd(x64emu_t *emu, uintptr_t fcn) { pFdddd_t fn = (pFdddd_t)fcn; R_RAX=(uintptr_t)fn(emu->xmm[0].d[0], emu->xmm[1].d[0], emu->xmm[2].d[0], emu->xmm[3].d[0]); } void pFDipp(x64emu_t *emu, uintptr_t fcn) { pFDipp_t fn = (pFDipp_t)fcn; R_RAX=(uintptr_t)fn(LD2localLD((void*)(R_RSP + 8)), (int64_t)R_RDI, (void*)R_RSI, (void*)R_RDX); } void pFlfff(x64emu_t *emu, uintptr_t fcn) { pFlfff_t fn = (pFlfff_t)fcn; R_RAX=(uintptr_t)fn((intptr_t)R_RDI, emu->xmm[0].f[0], emu->xmm[1].f[0], emu->xmm[2].f[0]); } +void pFLiip(x64emu_t *emu, uintptr_t fcn) { pFLiip_t fn = (pFLiip_t)fcn; R_RAX=(uintptr_t)fn((uintptr_t)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (void*)R_RCX); } void pFpiii(x64emu_t *emu, uintptr_t fcn) { pFpiii_t fn = (pFpiii_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX); } void pFpiip(x64emu_t *emu, uintptr_t fcn) { pFpiip_t fn = (pFpiip_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (void*)R_RCX); } void pFpiuu(x64emu_t *emu, uintptr_t fcn) { pFpiuu_t fn = (pFpiuu_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (int64_t)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX); } @@ -3385,6 +3396,7 @@ void pFpCpWWup(x64emu_t *emu, uintptr_t fcn) { pFpCpWWup_t fn = (pFpCpWWup_t)fcn void pFpuuuwwu(x64emu_t *emu, uintptr_t fcn) { pFpuuuwwu_t fn = (pFpuuuwwu_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX, (int16_t)R_R8, (int16_t)R_R9, *(uint64_t*)(R_RSP + 8)); } void pFpuupwwC(x64emu_t *emu, uintptr_t fcn) { pFpuupwwC_t fn = (pFpuupwwC_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (void*)R_RCX, (int16_t)R_R8, (int16_t)R_R9, *(uint8_t*)(R_RSP + 8)); } void pFplppppp(x64emu_t *emu, uintptr_t fcn) { pFplppppp_t fn = (pFplppppp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (intptr_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); } +void pFpLppiip(x64emu_t *emu, uintptr_t fcn) { pFpLppiip_t fn = (pFpLppiip_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (uintptr_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (int64_t)R_R8, (int64_t)R_R9, *(void**)(R_RSP + 8)); } void pFppiiipp(x64emu_t *emu, uintptr_t fcn) { pFppiiipp_t fn = (pFppiiipp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (int64_t)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); } void pFppiiCCC(x64emu_t *emu, uintptr_t fcn) { pFppiiCCC_t fn = (pFppiiCCC_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (uint8_t)R_R8, (uint8_t)R_R9, *(uint8_t*)(R_RSP + 8)); } void pFppiippp(x64emu_t *emu, uintptr_t fcn) { pFppiippp_t fn = (pFppiippp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); } @@ -3555,6 +3567,7 @@ void iFppLpiippp(x64emu_t *emu, uintptr_t fcn) { iFppLpiippp_t fn = (iFppLpiippp void iFpppiiipip(x64emu_t *emu, uintptr_t fcn) { iFpppiiipip_t fn = (iFpppiiipip_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (int64_t)R_RCX, (int64_t)R_R8, (int64_t)R_R9, *(void**)(R_RSP + 8), *(int64_t*)(R_RSP + 16), *(void**)(R_RSP + 24)); } void iFpppiiuuii(x64emu_t *emu, uintptr_t fcn) { iFpppiiuuii_t fn = (iFpppiiuuii_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (int64_t)R_RCX, (int64_t)R_R8, (uint64_t)R_R9, *(uint64_t*)(R_RSP + 8), *(int64_t*)(R_RSP + 16), *(int64_t*)(R_RSP + 24)); } void iFpppiipiiu(x64emu_t *emu, uintptr_t fcn) { iFpppiipiiu_t fn = (iFpppiipiiu_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (int64_t)R_RCX, (int64_t)R_R8, (void*)R_R9, *(int64_t*)(R_RSP + 8), *(int64_t*)(R_RSP + 16), *(uint64_t*)(R_RSP + 24)); } +void iFppppiiupp(x64emu_t *emu, uintptr_t fcn) { iFppppiiupp_t fn = (iFppppiiupp_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (int64_t)R_R8, (int64_t)R_R9, *(uint64_t*)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24)); } void iFppppppppu(x64emu_t *emu, uintptr_t fcn) { iFppppppppu_t fn = (iFppppppppu_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(uint64_t*)(R_RSP + 24)); } void iFppppppppp(x64emu_t *emu, uintptr_t fcn) { iFppppppppp_t fn = (iFppppppppp_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24)); } void uFEipippppp(x64emu_t *emu, uintptr_t fcn) { uFEipippppp_t fn = (uFEipippppp_t)fcn; R_RAX=(uint64_t)fn(emu, (int64_t)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16)); } @@ -3564,6 +3577,7 @@ void pFEppiiuuLi(x64emu_t *emu, uintptr_t fcn) { pFEppiiuuLi_t fn = (pFEppiiuuLi void pFEppuippuu(x64emu_t *emu, uintptr_t fcn) { pFEppuippuu_t fn = (pFEppuippuu_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (uint64_t)R_RDX, (int64_t)R_RCX, (void*)R_R8, (void*)R_R9, *(uint64_t*)(R_RSP + 8), *(uint64_t*)(R_RSP + 16)); } void pFEpppppiiV(x64emu_t *emu, uintptr_t fcn) { pFEpppppiiV_t fn = (pFEpppppiiV_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (int64_t)R_R9, *(int64_t*)(R_RSP + 8), (void*)(R_RSP + 16)); } void pFEpppppppi(x64emu_t *emu, uintptr_t fcn) { pFEpppppppi_t fn = (pFEpppppppi_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(int64_t*)(R_RSP + 16)); } +void pFEpppppppp(x64emu_t *emu, uintptr_t fcn) { pFEpppppppp_t fn = (pFEpppppppp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16)); } void pFpiiiiuuuu(x64emu_t *emu, uintptr_t fcn) { pFpiiiiuuuu_t fn = (pFpiiiiuuuu_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (int64_t)R_R8, (uint64_t)R_R9, *(uint64_t*)(R_RSP + 8), *(uint64_t*)(R_RSP + 16), *(uint64_t*)(R_RSP + 24)); } void pFpCuWCCuuu(x64emu_t *emu, uintptr_t fcn) { pFpCuWCCuuu_t fn = (pFpCuWCCuuu_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (uint8_t)R_RSI, (uint64_t)R_RDX, (uint16_t)R_RCX, (uint8_t)R_R8, (uint8_t)R_R9, *(uint64_t*)(R_RSP + 8), *(uint64_t*)(R_RSP + 16), *(uint64_t*)(R_RSP + 24)); } void pFpuuwwWWww(x64emu_t *emu, uintptr_t fcn) { pFpuuwwWWww_t fn = (pFpuuwwWWww_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (int16_t)R_RCX, (int16_t)R_R8, (uint16_t)R_R9, *(uint16_t*)(R_RSP + 8), *(int16_t*)(R_RSP + 16), *(int16_t*)(R_RSP + 24)); } @@ -3613,6 +3627,7 @@ void iFppuuiiuupi(x64emu_t *emu, uintptr_t fcn) { iFppuuiiuupi_t fn = (iFppuuiiu void iFpppiiipipi(x64emu_t *emu, uintptr_t fcn) { iFpppiiipipi_t fn = (iFpppiiipipi_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (int64_t)R_RCX, (int64_t)R_R8, (int64_t)R_R9, *(void**)(R_RSP + 8), *(int64_t*)(R_RSP + 16), *(void**)(R_RSP + 24), *(int64_t*)(R_RSP + 32)); } void iFpppLLipppp(x64emu_t *emu, uintptr_t fcn) { iFpppLLipppp_t fn = (iFpppLLipppp_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (uintptr_t)R_RCX, (uintptr_t)R_R8, (int64_t)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24), *(void**)(R_RSP + 32)); } void iFppppiiuuii(x64emu_t *emu, uintptr_t fcn) { iFppppiiuuii_t fn = (iFppppiiuuii_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (int64_t)R_R8, (int64_t)R_R9, *(uint64_t*)(R_RSP + 8), *(uint64_t*)(R_RSP + 16), *(int64_t*)(R_RSP + 24), *(int64_t*)(R_RSP + 32)); } +void iFpppppppipi(x64emu_t *emu, uintptr_t fcn) { iFpppppppipi_t fn = (iFpppppppipi_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(int64_t*)(R_RSP + 16), *(void**)(R_RSP + 24), *(int64_t*)(R_RSP + 32)); } void uFpppppppppp(x64emu_t *emu, uintptr_t fcn) { uFpppppppppp_t fn = (uFpppppppppp_t)fcn; R_RAX=(uint64_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24), *(void**)(R_RSP + 32)); } void pFEiippppppp(x64emu_t *emu, uintptr_t fcn) { pFEiippppppp_t fn = (pFEiippppppp_t)fcn; R_RAX=(uintptr_t)fn(emu, (int64_t)R_RDI, (int64_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24)); } void pFEpiiiiiipp(x64emu_t *emu, uintptr_t fcn) { pFEpiiiiiipp_t fn = (pFEpiiiiiipp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (int64_t)R_R8, (int64_t)R_R9, *(int64_t*)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24)); } @@ -3679,6 +3694,7 @@ void iFpipppppppppp(x64emu_t *emu, uintptr_t fcn) { iFpipppppppppp_t fn = (iFpip void iFpppllipppppp(x64emu_t *emu, uintptr_t fcn) { iFpppllipppppp_t fn = (iFpppllipppppp_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (intptr_t)R_RCX, (intptr_t)R_R8, (int64_t)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24), *(void**)(R_RSP + 32), *(void**)(R_RSP + 40), *(void**)(R_RSP + 48)); } void iFpppppppppppp(x64emu_t *emu, uintptr_t fcn) { iFpppppppppppp_t fn = (iFpppppppppppp_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24), *(void**)(R_RSP + 32), *(void**)(R_RSP + 40), *(void**)(R_RSP + 48)); } void pFEppiiuuuipii(x64emu_t *emu, uintptr_t fcn) { pFEppiiuuuipii_t fn = (pFEppiiuuuipii_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (uint64_t)R_R8, (uint64_t)R_R9, *(uint64_t*)(R_RSP + 8), *(int64_t*)(R_RSP + 16), *(void**)(R_RSP + 24), *(int64_t*)(R_RSP + 32), *(int64_t*)(R_RSP + 40)); } +void pFEppppppppppp(x64emu_t *emu, uintptr_t fcn) { pFEppppppppppp_t fn = (pFEppppppppppp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24), *(void**)(R_RSP + 32), *(void**)(R_RSP + 40)); } void pFWWiCCCCiipup(x64emu_t *emu, uintptr_t fcn) { pFWWiCCCCiipup_t fn = (pFWWiCCCCiipup_t)fcn; R_RAX=(uintptr_t)fn((uint16_t)R_RDI, (uint16_t)R_RSI, (int64_t)R_RDX, (uint8_t)R_RCX, (uint8_t)R_R8, (uint8_t)R_R9, *(uint8_t*)(R_RSP + 8), *(int64_t*)(R_RSP + 16), *(int64_t*)(R_RSP + 24), *(void**)(R_RSP + 32), *(uint64_t*)(R_RSP + 40), *(void**)(R_RSP + 48)); } void pFpCuuWWwwCCup(x64emu_t *emu, uintptr_t fcn) { pFpCuuWWwwCCup_t fn = (pFpCuuWWwwCCup_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (uint8_t)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX, (uint16_t)R_R8, (uint16_t)R_R9, *(int16_t*)(R_RSP + 8), *(int16_t*)(R_RSP + 16), *(uint8_t*)(R_RSP + 24), *(uint8_t*)(R_RSP + 32), *(uint64_t*)(R_RSP + 40), *(void**)(R_RSP + 48)); } void pFpuuuWWWWWWWW(x64emu_t *emu, uintptr_t fcn) { pFpuuuWWWWWWWW_t fn = (pFpuuuWWWWWWWW_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX, (uint16_t)R_R8, (uint16_t)R_R9, *(uint16_t*)(R_RSP + 8), *(uint16_t*)(R_RSP + 16), *(uint16_t*)(R_RSP + 24), *(uint16_t*)(R_RSP + 32), *(uint16_t*)(R_RSP + 40), *(uint16_t*)(R_RSP + 48)); } @@ -3885,6 +3901,7 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &iFuu) return 1; if (fun == &iFuL) return 1; if (fun == &iFup) return 1; + if (fun == &iFli) return 1; if (fun == &iFlp) return 1; if (fun == &iFLL) return 1; if (fun == &iFLp) return 1; @@ -4427,6 +4444,7 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &pFiiuu) return 1; if (fun == &pFiiup) return 1; if (fun == &pFiipi) return 1; + if (fun == &pFiipp) return 1; if (fun == &pFipii) return 1; if (fun == &pFipip) return 1; if (fun == &pFippi) return 1; @@ -4438,6 +4456,7 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &pFdipp) return 2; if (fun == &pFdddd) return 5; if (fun == &pFlfff) return 4; + if (fun == &pFLiip) return 1; if (fun == &pFpiii) return 1; if (fun == &pFpiip) return 1; if (fun == &pFpiuu) return 1; diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index b240f57c..9e53f124 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -174,6 +174,7 @@ void iFui(x64emu_t *emu, uintptr_t fnc); void iFuu(x64emu_t *emu, uintptr_t fnc); void iFuL(x64emu_t *emu, uintptr_t fnc); void iFup(x64emu_t *emu, uintptr_t fnc); +void iFli(x64emu_t *emu, uintptr_t fnc); void iFlp(x64emu_t *emu, uintptr_t fnc); void iFLL(x64emu_t *emu, uintptr_t fnc); void iFLp(x64emu_t *emu, uintptr_t fnc); @@ -825,6 +826,7 @@ void pFiiiu(x64emu_t *emu, uintptr_t fnc); void pFiiuu(x64emu_t *emu, uintptr_t fnc); void pFiiup(x64emu_t *emu, uintptr_t fnc); void pFiipi(x64emu_t *emu, uintptr_t fnc); +void pFiipp(x64emu_t *emu, uintptr_t fnc); void pFipii(x64emu_t *emu, uintptr_t fnc); void pFipip(x64emu_t *emu, uintptr_t fnc); void pFippi(x64emu_t *emu, uintptr_t fnc); @@ -837,6 +839,7 @@ void pFdipp(x64emu_t *emu, uintptr_t fnc); void pFdddd(x64emu_t *emu, uintptr_t fnc); void pFDipp(x64emu_t *emu, uintptr_t fnc); void pFlfff(x64emu_t *emu, uintptr_t fnc); +void pFLiip(x64emu_t *emu, uintptr_t fnc); void pFpiii(x64emu_t *emu, uintptr_t fnc); void pFpiip(x64emu_t *emu, uintptr_t fnc); void pFpiuu(x64emu_t *emu, uintptr_t fnc); @@ -1526,6 +1529,7 @@ void pFpCpWWup(x64emu_t *emu, uintptr_t fnc); void pFpuuuwwu(x64emu_t *emu, uintptr_t fnc); void pFpuupwwC(x64emu_t *emu, uintptr_t fnc); void pFplppppp(x64emu_t *emu, uintptr_t fnc); +void pFpLppiip(x64emu_t *emu, uintptr_t fnc); void pFppiiipp(x64emu_t *emu, uintptr_t fnc); void pFppiiCCC(x64emu_t *emu, uintptr_t fnc); void pFppiippp(x64emu_t *emu, uintptr_t fnc); @@ -1696,6 +1700,7 @@ void iFppLpiippp(x64emu_t *emu, uintptr_t fnc); void iFpppiiipip(x64emu_t *emu, uintptr_t fnc); void iFpppiiuuii(x64emu_t *emu, uintptr_t fnc); void iFpppiipiiu(x64emu_t *emu, uintptr_t fnc); +void iFppppiiupp(x64emu_t *emu, uintptr_t fnc); void iFppppppppu(x64emu_t *emu, uintptr_t fnc); void iFppppppppp(x64emu_t *emu, uintptr_t fnc); void uFEipippppp(x64emu_t *emu, uintptr_t fnc); @@ -1705,6 +1710,7 @@ void pFEppiiuuLi(x64emu_t *emu, uintptr_t fnc); void pFEppuippuu(x64emu_t *emu, uintptr_t fnc); void pFEpppppiiV(x64emu_t *emu, uintptr_t fnc); void pFEpppppppi(x64emu_t *emu, uintptr_t fnc); +void pFEpppppppp(x64emu_t *emu, uintptr_t fnc); void pFpiiiiuuuu(x64emu_t *emu, uintptr_t fnc); void pFpCuWCCuuu(x64emu_t *emu, uintptr_t fnc); void pFpuuwwWWww(x64emu_t *emu, uintptr_t fnc); @@ -1754,6 +1760,7 @@ void iFppuuiiuupi(x64emu_t *emu, uintptr_t fnc); void iFpppiiipipi(x64emu_t *emu, uintptr_t fnc); void iFpppLLipppp(x64emu_t *emu, uintptr_t fnc); void iFppppiiuuii(x64emu_t *emu, uintptr_t fnc); +void iFpppppppipi(x64emu_t *emu, uintptr_t fnc); void uFpppppppppp(x64emu_t *emu, uintptr_t fnc); void pFEiippppppp(x64emu_t *emu, uintptr_t fnc); void pFEpiiiiiipp(x64emu_t *emu, uintptr_t fnc); @@ -1820,6 +1827,7 @@ void iFpipppppppppp(x64emu_t *emu, uintptr_t fnc); void iFpppllipppppp(x64emu_t *emu, uintptr_t fnc); void iFpppppppppppp(x64emu_t *emu, uintptr_t fnc); void pFEppiiuuuipii(x64emu_t *emu, uintptr_t fnc); +void pFEppppppppppp(x64emu_t *emu, uintptr_t fnc); void pFWWiCCCCiipup(x64emu_t *emu, uintptr_t fnc); void pFpCuuWWwwCCup(x64emu_t *emu, uintptr_t fnc); void pFpuuuWWWWWWWW(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped/wrappednss3.c b/src/wrapped/wrappednss3.c index 27084a72..83227ba9 100755 --- a/src/wrapped/wrappednss3.c +++ b/src/wrapped/wrappednss3.c @@ -6,13 +6,93 @@ #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* nss3Name = "libnss3.so"; #define LIBNAME nss3 +static library_t *my_lib = NULL; + +#include "generated/wrappednss3types.h" + +typedef struct nss3_my_s { + // functions + #define GO(A, B) B A; + SUPER() + #undef GO +} nss3_my_t; + +void* getNss3My(library_t* lib) +{ + my_lib = lib; + nss3_my_t* my = (nss3_my_t*)calloc(1, sizeof(nss3_my_t)); + #define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A); + SUPER() + #undef GO + return my; +} + +void freeNss3My(void* lib) +{ + //nss3_my_t *my = (nss3_my_t *)lib; +} + +#undef SUPER + +#define SUPER() \ +GO(0) \ +GO(1) \ +GO(2) \ +GO(3) \ +GO(4) + +// 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*)RunFunction(my_context, my_PK11PasswordFunc_fct_##A, 3, 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 nss3 PK11PasswordFunc callback\n"); + return NULL; +} + +#undef SUPER + +EXPORT void my_PK11_SetPasswordFunc(x64emu_t* emu, void* f) +{ + nss3_my_t* my = (nss3_my_t*)my_lib->priv.w.p2; + + my->PK11_SetPasswordFunc(find_PK11PasswordFunc_Fct(f)); +} + +#define CUSTOM_INIT \ + lib->priv.w.p2 = getNss3My(lib); + +#define CUSTOM_FINI \ + freeNss3My(lib->priv.w.p2); \ + free(lib->priv.w.p2); #include "wrappedlib_init.h" diff --git a/src/wrapped/wrappednss3_private.h b/src/wrapped/wrappednss3_private.h index 49e65ec9..a4793d7d 100755 --- a/src/wrapped/wrappednss3_private.h +++ b/src/wrapped/wrappednss3_private.h @@ -2,6 +2,11 @@ #error Meh.... #endif +// CK_MECHANISM_TYPE is tyoe ULong +// CK_OBJECT_HANDLE is type ULong +// CK_ATTRIBUTE_TYPE is type ULong +// SECOidTag is an enum + //GO(ATOB_AsciiToData, //GO(ATOB_ConvertAsciiToItem, //GO(BTOA_ConvertItemToAscii, @@ -202,7 +207,7 @@ //GO(CERT_KeyFromDERCrl, //GO(CERT_MakeCANickname, //GO(CERT_MergeExtensions, -DATA(CERT_NameTemplate, 32) +DATA(CERT_NameTemplate, 4*sizeof(void*)) //GO(CERT_NameToAscii, //GO(CERT_NameToAsciiInvertible, //GO(CERT_NewCertList, @@ -329,10 +334,10 @@ DATA(CERT_NameTemplate, 32) //GO(NSS_InitContext, //GO(NSS_Initialize, //GO(__nss_InitLock, -//GO(NSS_InitReadWrite, +GO(NSS_InitReadWrite, iFp) //GO(NSS_InitWithMerge, -//GO(NSS_IsInitialized, -//GO(NSS_NoDB_Init, +GO(NSS_IsInitialized, iFv) +GO(NSS_NoDB_Init, iFp) //GO(NSS_OptionGet, //GO(NSS_OptionSet, //GO(NSS_PutEnv, @@ -347,7 +352,7 @@ DATA(CERT_NameTemplate, 32) //GO(NSS_Shutdown, //GO(NSS_ShutdownContext, //GO(NSS_UnregisterShutdown, -//GO(NSS_VersionCheck, +GO(NSS_VersionCheck, iFp) //GO(__PBE_CreateContext, //GO(PBE_CreateContext, //GO(__PBE_DestroyContext, @@ -355,12 +360,12 @@ DATA(CERT_NameTemplate, 32) //GO(__PBE_GenerateBits, //GO(PBE_GenerateBits, //GO(PK11_AlgtagToMechanism, -//GO(PK11_Authenticate, +GO(PK11_Authenticate, iFpip) //GO(PK11_BlockData, //GO(PK11_ChangePW, //GO(PK11_CheckSSOPassword, -//GO(PK11_CheckUserPassword, -//GO(PK11_CipherOp, +GO(PK11_CheckUserPassword, iFpp) +GO(PK11_CipherOp, iFpppipi) //GO(PK11_CloneContext, //GO(PK11_ConfigurePKCS11, //GO(PK11_ConvertSessionPrivKeyToTokenPrivKey, @@ -368,7 +373,7 @@ DATA(CERT_NameTemplate, 32) //GO(PK11_CopySymKeyForSigning, //GO(PK11_CopyTokenPrivKeyToSessionPrivKey, //GO(__PK11_CreateContextByRawKey, -//GO(PK11_CreateContextBySymKey, +GO(PK11_CreateContextBySymKey, pFiipp) //GO(PK11_CreateDigestContext, //GO(PK11_CreateGenericObject, //GO(PK11_CreateManagedGenericObject, @@ -377,7 +382,7 @@ DATA(CERT_NameTemplate, 32) //GO(PK11_CreatePBEParams, //GO(PK11_CreatePBEV2AlgorithmID, //GO(PK11_Decrypt, -//GO(PK11_DeleteTokenCertAndKey, +GO(PK11_DeleteTokenCertAndKey, iFpp) //GO(PK11_DeleteTokenPrivateKey, //GO(PK11_DeleteTokenPublicKey, //GO(PK11_DeleteTokenSymKey, @@ -386,13 +391,13 @@ DATA(CERT_NameTemplate, 32) //GO(PK11_DeriveWithFlags, //GO(PK11_DeriveWithFlagsPerm, //GO(PK11_DeriveWithTemplate, -//GO(PK11_DestroyContext, +GO(PK11_DestroyContext, vFpi) //GO(PK11_DestroyGenericObject, //GO(PK11_DestroyGenericObjects, //GO(PK11_DestroyMergeLog, -//GO(PK11_DestroyObject, +GO(PK11_DestroyObject, iFpL) //GO(PK11_DestroyPBEParams, -//GO(PK11_DestroyTokenObject, +GO(PK11_DestroyTokenObject, iFpL) //GO(PK11_DigestBegin, //GO(PK11_DigestFinal, //GO(PK11_DigestKey, @@ -405,58 +410,58 @@ DATA(CERT_NameTemplate, 32) //GO(PK11_ExportPrivateKeyInfo, //GO(PK11_ExportPrivKeyInfo, //GO(PK11_ExtractKeyValue, -//GO(PK11_Finalize, +GO(PK11_Finalize, iFp) //GO(PK11_FindBestKEAMatch, //GO(PK11_FindCertAndKeyByRecipientList, //GO(PK11_FindCertAndKeyByRecipientListNew, //GO(PK11_FindCertByIssuerAndSN, //GO(PK11_FindCertFromDERCert, -//GO(PK11_FindCertFromDERCertItem, +GO(PK11_FindCertFromDERCertItem, pFppp) //GO(PK11_FindCertFromNickname, //GO(PK11_FindCertFromURI, //GO(PK11_FindCertInSlot, //GO(PK11_FindCertsFromEmailAddress, //GO(PK11_FindCertsFromNickname, //GO(PK11_FindCertsFromURI, -//GO(PK11_FindFixedKey, +GO(PK11_FindFixedKey, pFpipp) //GO(PK11_FindGenericObjects, -//GO(PK11_FindKeyByAnyCert, -//GO(PK11_FindKeyByDERCert, -//GO(PK11_FindKeyByKeyID, -//GO(PK11_FindPrivateKeyFromCert, +GO(PK11_FindKeyByAnyCert, pFpp) +GO(PK11_FindKeyByDERCert, pFppp) +GO(PK11_FindKeyByKeyID, pFppp) +GO(PK11_FindPrivateKeyFromCert, pFppp) //GO(PK11_FindRawCertsWithSubject, //GO(PK11_FindSlotByName, //GO(PK11_FindSlotsByNames, //GO(PK11_FortezzaHasKEA, //GO(PK11_FortezzaMapSig, -//GO(PK11_FreeSlot, -//GO(PK11_FreeSlotList, +GO(PK11_FreeSlot, vFp) +GO(PK11_FreeSlotList, vFp) //GO(PK11_FreeSlotListElement, -//GO(PK11_FreeSymKey, +GO(PK11_FreeSymKey, vFp) //GO(PK11_GenerateFortezzaIV, -//GO(PK11_GenerateKeyPair, +GO(PK11_GenerateKeyPair, pFpLppiip) //GO(PK11_GenerateKeyPairWithFlags, //GO(PK11_GenerateKeyPairWithOpFlags, //GO(PK11_GenerateNewParam, //GO(PK11_GenerateRandom, //GO(PK11_GenerateRandomOnSlot, //GO(PK11_GetAllSlotsForCert, -//GO(PK11_GetAllTokens, +GO(PK11_GetAllTokens, pFLiip) //GO(PK11_GetBestKeyLength, //GO(PK11_GetBestSlot, //GO(PK11_GetBestSlotMultiple, //GO(PK11_GetBestSlotMultipleWithAttributes, //GO(PK11_GetBestSlotWithAttributes, //GO(PK11_GetBestWrapMechanism, -//GO(PK11_GetBlockSize, +GO(PK11_GetBlockSize, iFLp) //GO(PK11_GetCertFromPrivateKey, //GO(PK11_GetCertsMatchingPrivateKey, //GO(PK11_GetCurrentWrapIndex, //GO(PK11_GetDefaultArray, //GO(PK11_GetDefaultFlags, //GO(PK11_GetDisabledReason, -//GO(PK11_GetFirstSafe, -//GO(PK11_GetInternalKeySlot, +GO(PK11_GetFirstSafe, pFp) +GO(PK11_GetInternalKeySlot, pFv) //GO(PK11_GetInternalSlot, //GO(PK11_GetIVLength, //GO(__PK11_GetKeyData, @@ -474,21 +479,21 @@ DATA(CERT_NameTemplate, 32) //GO(PK11_GetModuleID, //GO(PK11_GetModuleURI, //GO(PK11_GetNextGenericObject, -//GO(PK11_GetNextSafe, -//GO(PK11_GetNextSymKey, +GO(PK11_GetNextSafe, pFppi) +GO(PK11_GetNextSymKey, pFp) //GO(PK11_GetPadMechanism, //GO(PK11_GetPBECryptoMechanism, //GO(PK11_GetPBEIV, //GO(PK11_GetPQGParamsFromPrivateKey, //GO(PK11_GetPrevGenericObject, -//GO(PK11_GetPrivateKeyNickname, +GO(PK11_GetPrivateKeyNickname, pFp) //GO(PK11_GetPrivateModulusLen, //GO(PK11_GetPublicKeyNickname, //GO(PK11_GetSlotFromKey, //GO(PK11_GetSlotFromPrivateKey, //GO(PK11_GetSlotID, //GO(PK11_GetSlotInfo, -//GO(PK11_GetSlotName, +GO(PK11_GetSlotName, pFp) //GO(PK11_GetSlotPWValues, //GO(PK11_GetSlotSeries, //GO(PK11_GetSymKeyHandle, @@ -496,21 +501,21 @@ DATA(CERT_NameTemplate, 32) //GO(PK11_GetSymKeyType, //GO(PK11_GetSymKeyUserData, //GO(PK11_GetTokenInfo, -//GO(PK11_GetTokenName, +GO(PK11_GetTokenName, pFp) //GO(PK11_GetTokenURI, //GO(PK11_GetWindow, //GO(PK11_GetWrapKey, //GO(PK11_HasAttributeSet, //GO(PK11_HashBuf, //GO(PK11_HasRootCerts, -//GO(PK11_ImportCert, +GO(PK11_ImportCert, iFppLpi) //GO(PK11_ImportCertForKey, //GO(PK11_ImportCertForKeyToSlot, //GO(PK11_ImportCRL, //GO(PK11_ImportDERCert, //GO(PK11_ImportDERCertForKey, //GO(PK11_ImportDERPrivateKeyInfo, -//GO(PK11_ImportDERPrivateKeyInfoAndReturnKey, +GO(PK11_ImportDERPrivateKeyInfoAndReturnKey, iFppppiiupp) //GO(PK11_ImportEncryptedPrivateKeyInfo, //GO(PK11_ImportEncryptedPrivateKeyInfoAndReturnKey, //GO(PK11_ImportPrivateKeyInfo, @@ -518,43 +523,43 @@ DATA(CERT_NameTemplate, 32) //GO(PK11_ImportPublicKey, //GO(PK11_ImportSymKey, //GO(PK11_ImportSymKeyWithFlags, -//GO(PK11_InitPin, +GO(PK11_InitPin, iFppp) //GO(PK11_IsDisabled, -//GO(PK11_IsFIPS, -//GO(PK11_IsFriendly, -//GO(PK11_IsHW, -//GO(PK11_IsInternal, -//GO(PK11_IsInternalKeySlot, -//GO(PK11_IsLoggedIn, +GO(PK11_IsFIPS, iFv) +GO(PK11_IsFriendly, iFp) +GO(PK11_IsHW, iFp) +GO(PK11_IsInternal, iFp) +GO(PK11_IsInternalKeySlot, iFp) +GO(PK11_IsLoggedIn, iFpp) //GO(PK11_IsPresent, -//GO(PK11_IsReadOnly, -//GO(PK11_IsRemovable, +GO(PK11_IsReadOnly, iFp) +GO(PK11_IsRemovable, iFp) //GO(PK11_IVFromParam, -//GO(PK11_KeyForCertExists, +GO(PK11_KeyForCertExists, pFppp) //GO(PK11_KeyForDERCertExists, //GO(PK11_KeyGen, //GO(PK11_KeyGenWithTemplate, //GO(PK11_LinkGenericObject, -//GO(PK11_ListCerts, -//GO(PK11_ListCertsInSlot, -//GO(PK11_ListFixedKeysInSlot, +GO(PK11_ListCerts, pFip) +GO(PK11_ListCertsInSlot, pFp) +GO(PK11_ListFixedKeysInSlot, pFppp) //GO(PK11_ListPrivateKeysInSlot, //GO(PK11_ListPrivKeysInSlot, //GO(PK11_ListPublicKeysInSlot, //GO(PK11_LoadPrivKey, //GO(PK11_Logout, //GO(PK11_LogoutAll, -//GO(PK11_MakeIDFromPubKey, +GO(PK11_MakeIDFromPubKey, pFp) //GO(PK11_MakeKEAPubKey, //GO(PK11_MapPBEMechanismToCryptoMechanism, //GO(PK11_MapSignKeyType, //GO(PK11_MechanismToAlgtag, //GO(PK11_MergeTokens, //GO(PK11_MoveSymKey, -//GO(PK11_NeedLogin, +GO(PK11_NeedLogin, iFp) //GO(PK11_NeedPWInit, -//GO(PK11_NeedUserInit, -//GO(PK11_ParamFromAlgid, +GO(PK11_NeedUserInit, iFp) +GO(PK11_ParamFromAlgid, pFp) //GO(PK11_ParamFromIV, //GO(PK11_ParamToAlgid, //GO(PK11_PBEKeyGen, @@ -587,8 +592,8 @@ DATA(CERT_NameTemplate, 32) //GO(PK11_PubWrapSymKey, //GO(PK11_RandomUpdate, //GO(PK11_RawPBEKeyGen, -//GO(PK11_ReadRawAttribute, -//GO(PK11_ReferenceSlot, +GO(PK11_ReadRawAttribute, iFipLp) +GO(PK11_ReferenceSlot, pFp) //GO(PK11_ReferenceSymKey, //GO(PK11_ResetToken, //GO(PK11_RestoreContext, @@ -599,15 +604,15 @@ DATA(CERT_NameTemplate, 32) //GO(PK11_SeedRandom, //GO(__PK11_SetCertificateNickname, //GO(PK11_SetFortezzaHack, -//GO(PK11_SetPasswordFunc, -//GO(PK11_SetPrivateKeyNickname, -//GO(PK11_SetPublicKeyNickname, +GOM(PK11_SetPasswordFunc, vFEp) +GO(PK11_SetPrivateKeyNickname, iFpp) +GO(PK11_SetPublicKeyNickname, iFpp) //GO(PK11_SetSlotPWValues, //GO(PK11_SetSymKeyNickname, //GO(PK11_SetSymKeyUserData, //GO(PK11_SetWrapKey, -//GO(PK11_Sign, -//GO(PK11_SignatureLen, +GO(PK11_Sign, iFppp) +GO(PK11_SignatureLen, iFp) //GO(PK11_SignWithMechanism, //GO(PK11_SignWithSymKey, //GO(PK11_SymKeyFromHandle, @@ -634,7 +639,7 @@ DATA(CERT_NameTemplate, 32) //GO(PK11_WaitForTokenEvent, //GO(PK11_WrapPrivKey, //GO(PK11_WrapSymKey, -//GO(PK11_WriteRawAttribute, +GO(PK11_WriteRawAttribute, iFipLp) //GO(PORT_Alloc, //GO(PORT_ArenaAlloc, //GO(PORT_ArenaGrow, @@ -658,10 +663,10 @@ DATA(CERT_NameTemplate, 32) //GO(PORT_ZAlloc, //GO(PORT_ZFree, //GO(RSA_FormatBlock, -//DATA(SEC_AnyTemplate, //R type +DATA(SEC_AnyTemplate, 4*sizeof(void*)) //R type //GO(SEC_ASN1Decode, -//GO(SEC_ASN1DecodeInteger, -//GO(SEC_ASN1DecodeItem, +GO(SEC_ASN1DecodeInteger, iFpp) +GO(SEC_ASN1DecodeItem, iFpppp) //GO(SEC_ASN1DecoderAbort, //GO(SEC_ASN1DecoderClearFilterProc, //GO(SEC_ASN1DecoderClearNotifyProc, @@ -685,15 +690,15 @@ DATA(CERT_NameTemplate, 32) //GO(SEC_ASN1EncoderUpdate, //GO(SEC_ASN1EncodeUnsignedInteger, //GO(SEC_ASN1LengthLength, -DATA(SEC_BitStringTemplate, 32) //R type -DATA(SEC_BMPStringTemplate, 32) //R type +DATA(SEC_BitStringTemplate, 4*sizeof(void*)) //R type +DATA(SEC_BMPStringTemplate, 4*sizeof(void*)) //R type //DATA(SEC_BooleanTemplate, //R type -//GO(SEC_CertNicknameConflict, +GO(SEC_CertNicknameConflict, iFppp) //GO(SEC_CheckCrlTimes, //GO(SEC_CreateSignatureAlgorithmParameters, -//GO(SEC_DeletePermCertificate, +GO(SEC_DeletePermCertificate, iFp) //GO(SEC_DeletePermCRL, -//GO(SEC_DerSignData, +GO(SEC_DerSignData, iFpppipi) //GO(SEC_DerSignDataWithAlgorithmID, //GO(SEC_DestroyCrl, //GO(SEC_DupCrl, @@ -703,7 +708,7 @@ DATA(SEC_BMPStringTemplate, 32) //R type //GO(SEC_GetCrlTimes, //GO(SEC_GetRegisteredHttpClient, //GO(SEC_GetSignatureAlgorithmOidTag, -DATA(SEC_IA5StringTemplate, 32) //R type +DATA(SEC_IA5StringTemplate, 4*sizeof(void*)) //R type //DATA(SEC_IntegerTemplate, //R type //GO(SECITEM_AllocItem, //GO(SECITEM_ArenaDupItem, @@ -766,32 +771,32 @@ DATA(SEC_IA5StringTemplate, 32) //R type //GO(SECMOD_DeleteInternalModule, //GO(SECMOD_DeleteModule, //GO(SECMOD_DeleteModuleEx, -//GO(SECMOD_DestroyModule, +GO(SECMOD_DestroyModule, vFp) //GO(SECMOD_FindModule, //GO(SECMOD_FindSlot, //GO(SECMOD_FreeModuleSpecList, //GO(SECMOD_GetDBModuleList, //GO(SECMOD_GetDeadModuleList, //GO(SECMOD_GetDefaultModDBFlag, -//GO(SECMOD_GetDefaultModuleList, -//GO(SECMOD_GetDefaultModuleListLock, +GO(SECMOD_GetDefaultModuleList, pFv) +GO(SECMOD_GetDefaultModuleListLock, pFv) //GO(SECMOD_GetInternalModule, //GO(SECMOD_GetModuleSpecList, -//GO(SECMOD_GetReadLock, +GO(SECMOD_GetReadLock, vFp) //GO(SECMOD_GetSkipFirstFlag, //GO(SECMOD_HasRemovableSlots, //GO(SECMOD_HasRootCerts, //GO(SECMOD_InternaltoPubMechFlags, //GO(SECMOD_IsModulePresent, //GO(SECMOD_LoadModule, -//GO(SECMOD_LoadUserModule, +GO(SECMOD_LoadUserModule, pFppi) //GO(SECMOD_LookupSlot, //GO(SECMOD_OpenNewSlot, -//GO(SECMOD_OpenUserDB, +GO(SECMOD_OpenUserDB, pFp) //GO(SECMOD_PubCipherFlagstoInternal, //GO(SECMOD_PubMechFlagstoInternal, //GO(SECMOD_ReferenceModule, -//GO(SECMOD_ReleaseReadLock, +GO(SECMOD_ReleaseReadLock, vFp) //GO(SECMOD_RestartModules, //GO(SECMOD_UnloadUserModule, //GO(SECMOD_UpdateModule, @@ -800,9 +805,9 @@ DATA(SEC_IA5StringTemplate, 32) //R type //GO(SEC_NewCrl, //DATA(SEC_NullTemplate, //R type //DATA(SEC_ObjectIDTemplate, //R type -DATA(SEC_OctetStringTemplate, 32) //R type +DATA(SEC_OctetStringTemplate, 4*sizeof(void*)) //R type //GO(SECOID_AddEntry, -DATA(SECOID_AlgorithmIDTemplate, 128) //R type +DATA(SECOID_AlgorithmIDTemplate, 16*sizeof(void*)) //R type //GO(SECOID_CompareAlgorithmID, //GO(SECOID_CopyAlgorithmID, //GO(SECOID_DestroyAlgorithmID, @@ -820,14 +825,14 @@ DATA(SECOID_AlgorithmIDTemplate, 128) //R type //GO(SEC_PKCS5IsAlgorithmPBEAlgTag, //DATA(SEC_PointerToAnyTemplate, //DATA(SEC_PointerToOctetStringTemplate, -//GO(SEC_QuickDERDecodeItem, -//GO(SEC_RegisterDefaultHttpClient, +GO(SEC_QuickDERDecodeItem, iFpppp) +GO(SEC_RegisterDefaultHttpClient, iFp) //DATA(SEC_SetOfAnyTemplate, //GO(SEC_SignData, //GO(SEC_SignDataWithAlgorithmID, //DATA(SEC_SignedCertificateTemplate, //DATA(SEC_UTCTimeTemplate, //R type -DATA(SEC_UTF8StringTemplate, 32) //R type +DATA(SEC_UTF8StringTemplate, 4*sizeof(void*)) //R type //GO(SGN_Begin, //GO(SGN_CompareDigestInfo, //GO(SGN_CopyDigestInfo, diff --git a/src/wrapped/wrappednssutil3_private.h b/src/wrapped/wrappednssutil3_private.h index 6c15e845..aa819821 100755 --- a/src/wrapped/wrappednssutil3_private.h +++ b/src/wrapped/wrappednssutil3_private.h @@ -71,7 +71,7 @@ //GO(NSSRWLock_UnlockWrite_Util, //GO(NSS_SecureMemcmp, //GO(NSS_SecureMemcmpZero, -//GO(NSS_SetAlgorithmPolicy, +GO(NSS_SetAlgorithmPolicy, iFiuu) //GO(NSSUTIL_AddNSSFlagToModuleSpec, //GO(NSSUTIL_ArgDecodeNumber, //GO(NSSUTIL_ArgFetchValue, @@ -218,7 +218,7 @@ //DATA(SEC_SequenceOfObjectIDTemplate, //DATA(SEC_SetOfAnyTemplate_Util, //DATA(SEC_SkipTemplate, //R-type -//GO(SEC_StringToOID, +GO(SEC_StringToOID, iFpppu) //DATA(SEC_T61StringTemplate, //R-type //DATA(SEC_UniversalStringTemplate, //R-type //DATA(SEC_UTF8StringTemplate_Util, //R-type diff --git a/src/wrapped/wrappedsmime3.c b/src/wrapped/wrappedsmime3.c index 15d70520..78ddf017 100755 --- a/src/wrapped/wrappedsmime3.c +++ b/src/wrapped/wrappedsmime3.c @@ -6,13 +6,311 @@ #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 +static library_t *my_lib = NULL; + +#include "generated/wrappedsmime3types.h" + +typedef struct smime3_my_s { + // functions + #define GO(A, B) B A; + SUPER() + #undef GO +} smime3_my_t; + +void* getSmime3My(library_t* lib) +{ + my_lib = lib; + smime3_my_t* my = (smime3_my_t*)calloc(1, sizeof(smime3_my_t)); + #define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A); + SUPER() + #undef GO + return my; +} + +void freeSmime3My(void* lib) +{ + //smime3_my_t *my = (smime3_my_t *)lib; +} + +#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*)RunFunction(my_context, my_SECKEYGetPasswordKey_fct_##A, 2, 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 RunFunction(my_context, my_digestOpenFn_fct_##A, 2, 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 RunFunction(my_context, my_digestCloseFn_fct_##A, 2, 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 RunFunction(my_context, my_digestIOFn_fct_##A, 3, 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*)RunFunction(my_context, my_SEC_PKCS12NicknameCollisionCallback_fct_##A, 3, 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) \ +{ \ + RunFunction(my_context, my_SEC_PKCS12EncoderOutputCallback_fct_##A, 3, 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) \ +{ \ + RunFunction(my_context, my_NSSCMSContentCallback_fct_##A, 3, 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*)RunFunction(my_context, my_PK11PasswordFunc_fct_##A, 3, 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*)RunFunction(my_context, my_NSSCMSGetDecryptKeyCallback_fct_##A, 2, 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; +} + +#undef SUPER + +EXPORT void my_SEC_PKCS12CreateExportContext(x64emu_t* emu, void* f, void* pwfnarg, void* slot, void* wincx) +{ + smime3_my_t* my = (smime3_my_t*)my_lib->priv.w.p2; + + 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) +{ + smime3_my_t* my = (smime3_my_t*)my_lib->priv.w.p2; + + 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) +{ + smime3_my_t* my = (smime3_my_t*)my_lib->priv.w.p2; + + return my->SEC_PKCS12DecoderValidateBags(ctx, find_SEC_PKCS12NicknameCollisionCallback_Fct(f)); +} + +EXPORT int my_SEC_PKCS12Encode(x64emu_t* emu, void* p12exp, void* f, void* arg) +{ + smime3_my_t* my = (smime3_my_t*)my_lib->priv.w.p2; + + 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) +{ + smime3_my_t* my = (smime3_my_t*)my_lib->priv.w.p2; + + 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); +} + +#define CUSTOM_INIT \ + lib->priv.w.p2 = getSmime3My(lib); + +#define CUSTOM_FINI \ + freeSmime3My(lib->priv.w.p2); \ + free(lib->priv.w.p2); #include "wrappedlib_init.h" diff --git a/src/wrapped/wrappedsmime3_private.h b/src/wrapped/wrappedsmime3_private.h index 1f9a90fa..1bf39ae3 100755 --- a/src/wrapped/wrappedsmime3_private.h +++ b/src/wrapped/wrappedsmime3_private.h @@ -17,7 +17,7 @@ //GO(NSS_CMSContentInfo_SetContentEncAlg, //GO(NSS_CMSContentInfo_SetContent_EncryptedData, //GO(NSS_CMSContentInfo_SetContent_EnvelopedData, -//GO(NSS_CMSContentInfo_SetContent_SignedData, +GO(NSS_CMSContentInfo_SetContent_SignedData, iFppp) //GO(NSS_CMSContentInfo_SetDontStream, //GO(NSS_CMSDecoder_Cancel, //GO(NSS_CMSDecoder_Finish, @@ -34,8 +34,8 @@ //GO(NSS_CMSDigestedData_Destroy, //GO(NSS_CMSDigestedData_GetContentInfo, //GO(NSS_CMSEncoder_Cancel, -//GO(NSS_CMSEncoder_Finish, -//GO(NSS_CMSEncoder_Start, +GO(NSS_CMSEncoder_Finish, iFp) +GOM(NSS_CMSEncoder_Start, pFEppppppppppp) //GO(NSS_CMSEncoder_Update, //GO(NSS_CMSEncryptedData_Create, //GO(NSS_CMSEncryptedData_Destroy, @@ -48,11 +48,11 @@ //GO(NSS_CMSMessage_ContentLevel, //GO(NSS_CMSMessage_ContentLevelCount, //GO(NSS_CMSMessage_Copy, -//GO(NSS_CMSMessage_Create, +GO(NSS_CMSMessage_Create, pFp) //GO(NSS_CMSMessage_CreateFromDER, -//GO(NSS_CMSMessage_Destroy, +GO(NSS_CMSMessage_Destroy, vFp) //GO(NSS_CMSMessage_GetContent, -//GO(NSS_CMSMessage_GetContentInfo, +GO(NSS_CMSMessage_GetContentInfo, pFp) //GO(NSS_CMSMessage_IsEncrypted, //GO(NSS_CMSMessage_IsSigned, //GO(NSS_CMSRecipientInfo_Create, @@ -66,13 +66,13 @@ //GO(NSS_CMSRecipientInfo_UnwrapBulkKey, //GO(NSS_CMSRecipientInfo_WrapBulkKey, //GO(NSS_CMSSignedData_AddCertChain, -//GO(NSS_CMSSignedData_AddCertificate, +GO(NSS_CMSSignedData_AddCertificate, iFpp) //GO(NSS_CMSSignedData_AddCertList, //GO(NSS_CMSSignedData_AddDigest, //GO(NSS_CMSSignedData_AddSignerInfo, //GO(NSS_CMSSignedData_Create, -//GO(NSS_CMSSignedData_CreateCertsOnly, -//GO(NSS_CMSSignedData_Destroy, +GO(NSS_CMSSignedData_CreateCertsOnly, pFppi) +GO(NSS_CMSSignedData_Destroy, vFp) //GO(NSS_CMSSignedData_GetContentInfo, //GO(NSS_CMSSignedData_GetDigestAlgs, //GO(NSS_CMSSignedData_GetSignerInfo, @@ -110,29 +110,29 @@ //GO(NSS_SMIMEUtil_FindBulkAlgForRecipients, //GO(NSSSMIME_VersionCheck, //GO(SECMIME_DecryptionAllowed, -//GO(SEC_PKCS12AddCertAndKey, +GO(SEC_PKCS12AddCertAndKey, iFpppppppipi) //GO(SEC_PKCS12AddCertOrChainAndKey, -//GO(SEC_PKCS12AddPasswordIntegrity, -//GO(SEC_PKCS12CreateExportContext, -//GO(SEC_PKCS12CreatePasswordPrivSafe, -//GO(SEC_PKCS12CreateUnencryptedSafe, -//GO(SEC_PKCS12DecoderFinish, -//GO(SEC_PKCS12DecoderGetCerts, -//GO(SEC_PKCS12DecoderImportBags, -//GO(SEC_PKCS12DecoderIterateInit, -//GO(SEC_PKCS12DecoderIterateNext, +GO(SEC_PKCS12AddPasswordIntegrity, iFppi) +GOM(SEC_PKCS12CreateExportContext, pFEpppp) +GO(SEC_PKCS12CreatePasswordPrivSafe, pFppi) +GO(SEC_PKCS12CreateUnencryptedSafe, pFp) +GO(SEC_PKCS12DecoderFinish, vFp) +GO(SEC_PKCS12DecoderGetCerts, pFp) +GO(SEC_PKCS12DecoderImportBags, iFp) +GO(SEC_PKCS12DecoderIterateInit, iFp) +GO(SEC_PKCS12DecoderIterateNext, iFpp) //GO(SEC_PKCS12DecoderRenameCertNicknames, //GO(SEC_PKCS12DecoderSetTargetTokenCAs, -//GO(SEC_PKCS12DecoderStart, -//GO(SEC_PKCS12DecoderUpdate, -//GO(SEC_PKCS12DecoderValidateBags, -//GO(SEC_PKCS12DecoderVerify, +GOM(SEC_PKCS12DecoderStart, pFEpppppppp) +GO(SEC_PKCS12DecoderUpdate, iFppL) +GOM(SEC_PKCS12DecoderValidateBags, iFEpp) +GO(SEC_PKCS12DecoderVerify, iFp) //GO(SEC_PKCS12DecryptionAllowed, -//GO(SEC_PKCS12DestroyExportContext, -//GO(SEC_PKCS12EnableCipher, -//GO(SEC_PKCS12Encode, -//GO(SEC_PKCS12IsEncryptionAllowed, -//GO(SEC_PKCS12SetPreferredCipher, +GO(SEC_PKCS12DestroyExportContext, vFp) +GO(SEC_PKCS12EnableCipher, iFli) +GOM(SEC_PKCS12Encode, iFEppp) +GO(SEC_PKCS12IsEncryptionAllowed, iFv) +GO(SEC_PKCS12SetPreferredCipher, iFli) //GO(SEC_PKCS7AddCertificate, //GO(SEC_PKCS7AddRecipient, //GO(SEC_PKCS7AddSigningTime, |