Subversion Repositories Kolibri OS

Rev

Rev 908 | Rev 996 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 908 Rev 914
Line 275... Line 275...
275
        ( ( raw[1] == 0x31305445) ||
275
        ( ( raw[1] == 0x31305445) ||
276
          ( raw[1] == 0x30305445) ) )
276
          ( raw[1] == 0x30305445) ) )
277
 
277
 
Line 278... Line 278...
278
    {
278
    {
279
        DBG("leagacy Kolibri application\n");
279
        DBG("leagacy Kolibri application");
280
        int tmp =  mnt_exec(raw, raw_size, path, cmdline, flags);
280
        int tmp =  mnt_exec(raw, raw_size, path, cmdline, flags);
-
 
281
        DBG("  pid %x\n",tmp);
281
        return tmp;
282
        return tmp;
282
    }
283
    }
Line 283... Line 284...
283
 
284
 
284
    if( ! validate_pe(raw, raw_size) )
285
    if( ! validate_pe(raw, raw_size, true) )
285
    {
286
    {
286
        DBG("invalid executable file %s\n", path);
287
        DBG("invalid executable file %s\n", path);
287
        mem_free(raw);
288
        mem_free(raw);
288
        return -31;
289
        return -31;
Line -... Line 290...
-
 
290
    }
-
 
291
 
-
 
292
    dos = (PIMAGE_DOS_HEADER)raw;
289
    }
293
    nt =  MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew);
Line 290... Line 294...
290
 
294
 
291
    pathsize = strlen(path)+1;
295
    pathsize = strlen(path)+1;
Line 357... Line 361...
357
 
361
 
Line 358... Line 362...
358
    DBG("create stack at %x\n\tpath %x\n\tcmdline %x\n",
362
    DBG("create stack at %x\n\tpath %x\n\tcmdline %x\n",
359
         ex_stack, ex_stack->path, ex_stack->cmdline);
363
         ex_stack, ex_stack->path, ex_stack->cmdline);
Line 360... Line 364...
360
 
364
 
361
    pe_app_param(path, raw, ex_pg_dir, ex_stack);
-
 
362
    return 0;
365
    return pe_app_param(path, raw, ex_pg_dir, ex_stack);
Line 363... Line 366...
363
};
366
};
Line 364... Line 367...
364
 
367
 
Line 392... Line 395...
392
    PIMAGE_NT_HEADERS32   nt;
395
    PIMAGE_NT_HEADERS32   nt;
393
 
396
 
Line 394... Line 397...
394
    size_t   img_size;
397
    size_t   img_size;
395
    count_t  img_pages;
398
    count_t  img_pages;
-
 
399
    size_t   stack_size;
-
 
400
    addr_t   img_stack;
-
 
401
    addr_t  *pte;
-
 
402
 
396
    count_t  i;
403
    count_t  i;
397
    u32_t    tmp;
404
    u32_t    tmp;
Line 398... Line 405...
398
 
405
 
Line 406... Line 413...
406
    current_slot->mem_size  = img_size;
413
    current_slot->mem_size  = img_size;
Line 407... Line 414...
407
 
414
 
Line -... Line 415...
-
 
415
    list_initialize(¤t_slot->dll_list);
408
    list_initialize(¤t_slot->dll_list);
416
 
Line -... Line 417...
-
 
417
    pte = (addr_t*)page_tabs;
409
 
418
    img_pages = img_size >> 12;
-
 
419
 
410
    img_pages = img_size >> 12;
420
    stack_size = (nt->OptionalHeader.SizeOfStackReserve + 4095) & ~4095;
-
 
421
    img_stack = 0x7FFFF000 - stack_size;
411
 
422
    stack_size>>= 12;
-
 
423
 
412
    for(i = 0; i < img_pages; i++)
424
    while (img_pages--)
413
    {
425
        *pte++ = 2;
-
 
426
 
-
 
427
    pte = &((addr_t*)page_tabs)[img_stack>>12];
Line 414... Line 428...
414
        addr_t page = core_alloc(0);
428
 
415
        ((u32_t*)page_tabs)[i] = page | 7;                          /*   FIXME     */
-
 
Line -... Line 429...
-
 
429
    while(stack_size--)
-
 
430
        *pte++ = 0x02;
416
    }
431
 
Line 417... Line 432...
417
 
432
    addr_t stack_page = ((addr_t)ex_stack-OS_BASE) & ~4095;
Line 418... Line 433...
418
    addr_t stack_page = ((addr_t)ex_stack-OS_BASE) & ~4095;
433
 
419
    ((u32_t*)page_tabs)[0x7FFFF000>>12] = stack_page | 7;
434
    *pte = stack_page | 7;
420
 
435
 
421
    create_image(0, raw);
436
    create_image(0, raw, false);
422
 
437
 
423
    init_user_heap();
438
    init_user_heap();
Line -... Line 439...
-
 
439
 
424
 
440
    if (! link_pe(0))
425
    if (! link_pe(0))
441
    {
Line 426... Line 442...
426
    {
442
        DBG("\nunresolved imports\nexit\n");
427
        DBG("\nunresolved imports\nexit\n");
443
        __asm__ __volatile__ (
Line 479... Line 495...
479
        DBG("file not found: %s\n", path);
495
        DBG("file not found: %s\n", path);
480
        return NULL;
496
        return NULL;
481
    };
497
    };
482
 
498
 
Line 483... Line 499...
483
    if( ! validate_pe(raw, raw_size) )
499
    if( ! validate_pe(raw, raw_size, false) )
484
    {
500
    {
485
        DBG("invalid pe file %s\n", path);
501
        DBG("invalid pe file %s\n", path);
486
        mem_free(raw);
502
        mem_free(raw);
487
        return NULL;
503
        return NULL;
488
    }
504
    }
Line 506... Line 522...
506
        user_free((void*)img_base);
522
        user_free((void*)img_base);
507
        return NULL;
523
        return NULL;
508
    };
524
    };
509
 
525
 
Line 510... Line 526...
510
    create_image(img_base, (addr_t)raw);
526
    create_image(img_base, (addr_t)raw, false);
Line 511... Line 527...
511
 
527
 
Line 512... Line 528...
512
    mem_free(raw);
528
    mem_free(raw);
513
 
529
 
Line 607... Line 623...
607
            while ( 1 ) // Loop forever (or until we break out)
623
            while ( 1 ) // Loop forever (or until we break out)
608
            {
624
            {
609
                PIMAGE_IMPORT_BY_NAME ord;
625
                PIMAGE_IMPORT_BY_NAME ord;
610
                addr_t addr;
626
                addr_t addr;
-
 
627
                *iat=0;
Line 611... Line 628...
611
 
628
 
612
                if ( thunk->u1.AddressOfData == 0 )
629
                if ( thunk->u1.AddressOfData == 0 )
Line 613... Line 630...
613
                    break;
630
                    break;
614
 
631
 
-
 
632
                if ( thunk->u1.Ordinal & IMAGE_ORDINAL_FLAG )
615
                if ( thunk->u1.Ordinal & IMAGE_ORDINAL_FLAG )
633
                {
-
 
634
                   u16_t ordinal;
616
                {
635
                   ordinal = thunk->u1.Ordinal & 0xFFFF;
617
        //  printf("  %4u\n", thunk->u1.Ordinal & 0xFFFF);
636
                   *iat = functions[ordinal-exp->Base] + exp_dll->img_base;
618
                    break;
637
                    break;
619
                }
638
                }
620
                else
639
                else
621
                {
640
                {
622
                    ord = MakePtr(PIMAGE_IMPORT_BY_NAME,
-
 
Line 623... Line 641...
623
                                  thunk->u1.AddressOfData, img_base);
641
                    ord = MakePtr(PIMAGE_IMPORT_BY_NAME,
Line 624... Line 642...
624
                    *iat=0;
642
                                  thunk->u1.AddressOfData, img_base);
625
 
643
 
Line 637... Line 655...
637
                            if(!strncmp(ord->Name,MakePtr(char*,*names,exp_dll->img_base),32))
655
                            if(!strncmp(ord->Name,MakePtr(char*,*names,exp_dll->img_base),32))
638
                            {
656
                            {
639
                                u16_t ordinal;
657
                                u16_t ordinal;
640
                                ordinal = ordinals[ind];
658
                                ordinal = ordinals[ind];
641
                                DBG(" \t\tat %x\n", functions[ordinal] + exp_dll->img_base);
659
                                DBG("ordinal %d\t\tat %x\n", ordinal, functions[ordinal] + exp_dll->img_base);
642
                                *iat = functions[ordinal] + exp_dll->img_base;
660
                                *iat = functions[ordinal] + exp_dll->img_base;
643
                                break;
661
                                break;
644
                            };
662
                            };
645
                        };
663
                        };
646
                        if(ind == exp->NumberOfNames)
664
                        if(ind == exp->NumberOfNames)
647
                        {
665
                        {