Exemplo n.º 1
0
Arquivo: oid.c Projeto: Jactry/wine
static void test_installOIDFunctionAddress(void)
{
    BOOL ret;
    CRYPT_OID_FUNC_ENTRY entry = { CRYPT_DEFAULT_OID, funky };
    HCRYPTOIDFUNCSET set;

    /* This crashes
    ret = CryptInstallOIDFunctionAddress(NULL, 0, NULL, 0, NULL, 0);
     */

    /* Installing zero functions should work */
    SetLastError(0xdeadbeef);
    ret = CryptInstallOIDFunctionAddress(NULL, 0, "CryptDllEncodeObject", 0,
     NULL, 0);
    ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n",
     GetLastError());

    /* The function name doesn't much matter */
    SetLastError(0xdeadbeef);
    ret = CryptInstallOIDFunctionAddress(NULL, 0, "OhSoFunky", 0, NULL, 0);
    ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n",
     GetLastError());
    SetLastError(0xdeadbeef);
    entry.pszOID = X509_CERT;
    ret = CryptInstallOIDFunctionAddress(NULL, 0, "OhSoFunky", 1, &entry, 0);
    ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n",
     GetLastError());
    set = CryptInitOIDFunctionSet("OhSoFunky", 0);
    ok(set != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
    if (set)
    {
        funcY funcAddr = NULL;
        HCRYPTOIDFUNCADDR hFuncAddr = NULL;

        /* This crashes
        ret = CryptGetOIDFunctionAddress(set, X509_ASN_ENCODING, 0, 0, NULL,
         NULL);
         */
        ret = CryptGetOIDFunctionAddress(set, X509_ASN_ENCODING, 0, 0,
         (void **)&funcAddr, &hFuncAddr);
        ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND ||
         GetLastError() == E_INVALIDARG /* some Win98 */),
         "Expected ERROR_FILE_NOT_FOUND or E_INVALIDARG, got %d\n",
         GetLastError());
        ret = CryptGetOIDFunctionAddress(set, X509_ASN_ENCODING, X509_CERT, 0,
         (void **)&funcAddr, &hFuncAddr);
        ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
         "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
        ret = CryptGetOIDFunctionAddress(set, 0, X509_CERT, 0,
         (void **)&funcAddr, &hFuncAddr);
        ok(ret, "CryptGetOIDFunctionAddress failed: %d\n", GetLastError());
        if (funcAddr)
        {
            int y = funcAddr(0xabadc0da);

            ok(y == 0xabadc0da, "Unexpected return (%d) from function\n", y);
            CryptFreeOIDFunctionAddress(hFuncAddr, 0);
        }
    }
}
Exemplo n.º 2
0
#include "tagBuf.hpp"
#include "runtime.hpp"
#include "CHString.hpp"
#include "TaggedPointer.h"
#include <stdarg.h>
#include <algorithm>
#include "CHString.hpp"

struct runtimeclass(CHArray)
{
    static struct method_list_t *methods()
    {
        static method_list_t method[24] = {
            {.method = {0, overloadFunc(Class(*)(std::nullptr_t),CHArray::getClass), selector(getClass), __Static} },
            {.method = {0, overloadFunc(Class(CHArray::*)()const, &CHArray::getClass), selector(getClass), __Member} },
            {.method = {0, funcAddr(&CHArray::allocateInstance), selector(allocateInstance), __Static} },

            {.method = {0, funcAddr(&CHArray::count), selector(count), __Member} },
            {.method = {0, funcAddr(&CHArray::objectAtIndex), selector(objectAtIndex), __Member} },

            {.method = {0, funcAddr(&CHArray::arrayWithObject), selector(arrayWithObject), __Static} },
            {.method = {0, overloadFunc(CHArray *(*)(const id[], uint32_t), &CHArray::arrayWithObjects), selector(arrayWithObjects), __Static|__Overload} },
            {.method = {0, overloadFunc(CHArray *(*)(id, ...), &CHArray::arrayWithObjects), selector(arrayWithObjects), __Static|__Overload} },
            {.method = {0, funcAddr(&CHArray::arrayWithArray), selector(arrayWithArray), __Static} },

            {.method = {0, funcAddr(&CHArray::arrayByAddiObject), selector(arrayByAddiObject), __Member} },
            {.method = {0, funcAddr(&CHArray::arrayByAddingObjectsFromArray), selector(arrayByAddingObjectsFromArray), __Member} },
            {.method = {0, funcAddr(&CHArray::componentsJoinedByString), selector(componentsJoinedByString), __Member} },

            {.method = {0, funcAddr(&CHArray::containsObject), selector(containsObject), __Member} },
            {.method = {0, funcAddr(&CHArray::indexOfObject), selector(indexOfObject), __Member} },