Subversion Repositories Kolibri OS

Rev

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

Rev 1907 Rev 2040
Line 559... Line 559...
559
    dos = (PIMAGE_DOS_HEADER)raw;
559
    dos = (PIMAGE_DOS_HEADER)raw;
560
    nt =  MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew);
560
    nt =  MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew);
Line 561... Line 561...
561
 
561
 
-
 
562
    return  MakePtr(void*, raw, nt->OptionalHeader.AddressOfEntryPoint);
-
 
563
};
-
 
564
 
-
 
565
 
-
 
566
void *get_proc_address(module_t *module, char *proc_name)
-
 
567
{
-
 
568
 
-
 
569
    PIMAGE_DOS_HEADER        expdos;
-
 
570
    PIMAGE_NT_HEADERS32      expnt;
-
 
571
    PIMAGE_EXPORT_DIRECTORY  exp;
-
 
572
 
-
 
573
    uint32_t   *exp_functions;
-
 
574
    uint16_t   *exp_ordinals;
-
 
575
    char      **exp_names;
-
 
576
 
-
 
577
    int minn, maxn;
-
 
578
    char *export_name;
-
 
579
    uint16_t   ordinal;
-
 
580
    void *function=NULL;
-
 
581
 
-
 
582
    exp = module->img_exp;
-
 
583
 
-
 
584
    exp_functions = MakePtr(uint32_t*,exp->AddressOfFunctions,module->start);
-
 
585
    exp_ordinals = MakePtr(uint16_t*,  exp->AddressOfNameOrdinals,module->start);
-
 
586
    exp_names = MakePtr(char**, exp->AddressOfNames,module->start);
-
 
587
 
-
 
588
    minn = 0;
-
 
589
    maxn = exp->NumberOfNames - 1;
-
 
590
    while (minn <= maxn)
-
 
591
    {
-
 
592
        int mid;
-
 
593
        int res;
-
 
594
 
-
 
595
        mid = (minn + maxn) / 2;
-
 
596
 
-
 
597
        export_name = MakePtr(char*,exp_names[mid],module->start);
-
 
598
 
-
 
599
        res = strcmp(export_name, proc_name);
-
 
600
        if (res == 0)
-
 
601
        {
-
 
602
            ordinal  = exp_ordinals[mid];
-
 
603
            function = MakePtr(void*,exp_functions[ordinal], module->start);
-
 
604
 
-
 
605
            if((uint32_t)function >= (uint32_t)exp)
-
 
606
            {
-
 
607
                printf("forward %s\n", function);
-
 
608
            }
-
 
609
            else
-
 
610
            {
-
 
611
                DBG(" \t\tat %x\n", function);
-
 
612
            };
562
    return  MakePtr(void*, raw, nt->OptionalHeader.AddressOfEntryPoint);
613
            break;
-
 
614
        }
-
 
615
        else if (minn == maxn)
-
 
616
        {
-
 
617
            DBG(" unresolved %s\n",proc_name);
-
 
618
            break;
-
 
619
        }
-
 
620
        else if (res > 0)
-
 
621
        {
-
 
622
            maxn = mid - 1;
-
 
623
        }
-
 
624
        else
-
 
625
        {
-
 
626
            minn = mid + 1;
-
 
627
        }
-
 
628
    };
-
 
629
 
-
 
630
    return function;
Line 563... Line 631...
563
}
631
};
564
 
632
 
565
 
633
 
Line 640... Line 708...
640
 
708
 
Line 641... Line 709...
641
        list_add_tail(&module->list, &dll_list);
709
        list_add_tail(&module->list, &dll_list);
Line 642... Line 710...
642
 
710
 
-
 
711
        if( link_image(img_base))
-
 
712
        {
-
 
713
            int (*dll_startup)(module_t *mod, uint32_t reason);
-
 
714
 
-
 
715
            dll_startup = get_proc_address(module, "DllStartup");
-
 
716
            if( dll_startup )
-
 
717
            {
-
 
718
                if( 0 == dll_startup(module, 1))
-
 
719
                    return 0;
643
        if( link_image(img_base))
720
            }
-
 
721
            return module;
-
 
722
        };
644
            return module;
723
 
645
        return NULL;
724
        return NULL;
Line 646... Line 725...
646
    };
725
    };
647
 
726