Пример #1
0
int main (int argc, char **argv) {

    unsigned int i;
    WCHAR commandline[1024] = L"autochk.exe *";

    uint8_t *ptr;
    void *ep;
    RTL_USER_PROCESS_PARAMETERS *params;
    size_t autochk_size = (size_t)((void *) autochk_data_size);

    const char *executable = "autochk.exe";

    ep = setup_nloader(autochk_data, autochk_size, &params, 1);

    if (!ep)
    {
        fprintf(stderr, "setup_nloader failed\n");
        return 1;
    }

    ptr = (uint8_t *)(params+1);
    params->ImagePathName.Buffer = (WCHAR *) ptr;

    for (i = 0; i < strlen(executable); i++)
        params->ImagePathName.Buffer[i] = executable[i];

    params->ImagePathName.Length = i;
    params->ImagePathName.MaximumLength = i + 1;


    if (argc > 1)
    {
        int c = params->ImagePathName.Length;
        memcpy(commandline, params->ImagePathName.Buffer, params->ImagePathName.Length * sizeof(WCHAR));

        for (i = 1; i < (unsigned) argc; i++)
        {
            char *arg = argv[i];
            int dev = 0;
            commandline[c++] = L' ';
            if (!strncmp(arg, "/dev/", 4))
            {
                size_t len = sizeof(VOLUME_PREFIX) - sizeof(WCHAR);
                dev = 1;
                memcpy(&commandline[c], VOLUME_PREFIX, len);
                len /= sizeof(WCHAR);
                c += len;
            }

            while (*arg && (c < sizeof(commandline) - 1))
                commandline[c++] = *arg++;

            if (dev) commandline[c++] = L'}';
        }
        commandline[c++] = 0;
    }
    else
        usage();

    ptr += sizeof(WCHAR);
    memcpy(ptr, commandline, sizeof(commandline));
    params->CommandLine.Length = sizeof(commandline) - sizeof(WCHAR);
    params->CommandLine.MaximumLength = sizeof(commandline);
    params->CommandLine.Buffer = (WCHAR *) ptr;

    /******************************************************************************************************* CALL ENTRYPOINT */
    signal(SIGSEGV, sigsegv_handler);

    if (setjmp(sigsegv_env))
    {
        /* clean up console */
        fflush(stdout);
        fprintf(stderr, "Native program crashed\n");
        exit(1);
    }
    else
    {
        BPX();
        return to_ep(ep);
    }
}
Пример #2
0
void test_basic_interpolation() {
    char *s = "a_string";
    double f = 3.14159;
    bson_bool_t bb = 1;
    time_t t = time(0);
    char *x = "a symbol";
    int i = 123;
    long l = 456789L;
    bcon basic_interpolation[] = {"string", BPS(&s), "f(double)", BPF(&f), "boolean", BPB(&bb), "time", BPT(&t), "symbol", BPX(&x), "int", BPI(&i), "long", BPL(&l), BEND};
    test_bson_from_bcon( basic_interpolation, BCON_OK, BSON_VALID );
}