Subversion Repositories Kolibri OS

Rev

Rev 6536 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6536 Rev 9874
Line 5... Line 5...
5
#include 
5
#include 
6
#include 
6
#include 
7
#include 
7
#include 
8
 
8
 
Line 9... Line 9...
9
#include 
9
#include 
Line 10... Line 10...
10
 
10
 
11
#include "list.h"
11
#include "list.h"
Line 12... Line 12...
12
#include "pe.h"
12
#include "pe.h"
Line 20... Line 20...
20
 
20
 
21
void    init_loader(void *libc_image);
21
void    init_loader(void *libc_image);
22
void*   create_image(void *raw);
22
void*   create_image(void *raw);
-
 
23
int     link_image(void *img_base, PIMAGE_IMPORT_DESCRIPTOR imp);
Line 23... Line 24...
23
int     link_image(void *img_base, PIMAGE_IMPORT_DESCRIPTOR imp);
24
void*   load_library(const char *name);
24
 
25
 
Line 25... Line 26...
25
extern char* __appenv;
26
extern char* __appenv;
Line 264... Line 265...
264
 
265
 
Line 265... Line 266...
265
    dos = (PIMAGE_DOS_HEADER)raw;
266
    dos = (PIMAGE_DOS_HEADER)raw;
266
    nt =  MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew);
267
    nt =  MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew);
Line 267... Line 268...
267
 
268
 
Line 268... Line 269...
268
    img_base = user_alloc(nt->OptionalHeader.SizeOfImage);
269
    img_base = _ksys_alloc(nt->OptionalHeader.SizeOfImage);
269
 
270
 
Line 270... Line 271...
270
    if(unlikely(img_base == NULL))
271
    if(unlikely(img_base == NULL))
Line 649... Line 650...
649
    PIMAGE_DOS_HEADER        dos;
650
    PIMAGE_DOS_HEADER        dos;
650
    PIMAGE_NT_HEADERS32      nt;
651
    PIMAGE_NT_HEADERS32      nt;
651
    PIMAGE_EXPORT_DIRECTORY  exp;
652
    PIMAGE_EXPORT_DIRECTORY  exp;
652
 
653
 
Line 653... Line 654...
653
    ufile_t   uf;
654
    ksys_ufile_t   uf;
654
    void     *raw_img;
655
    void     *raw_img;
655
    size_t    raw_size;
656
    size_t    raw_size;
656
    void     *img_base = NULL;
657
    void     *img_base = NULL;
Line 657... Line 658...
657
 
658
 
658
    uf = load_file(path);
659
    uf = _ksys_load_file(path);
659
    raw_img  = uf.data;
660
    raw_img  = uf.data;
Line 660... Line 661...
660
    raw_size = uf.size;
661
    raw_size = uf.size;
661
 
662
 
Line 662... Line 663...
662
    if(raw_img == NULL)
663
    if(raw_img == NULL)
663
        return NULL;
664
        return NULL;
664
 
665
 
665
    if( validate_pe(raw_img, raw_size, 0) == 0)
666
    if( validate_pe(raw_img, raw_size, 0) == 0)
666
    {
667
    {
667
        printf("invalide module %s\n", path);
668
        printf("invalide module %s\n", path);
Line 668... Line 669...
668
        user_free(raw_img);
669
        _ksys_free(raw_img);
669
        return NULL;
670
        return NULL;
Line 670... Line 671...
670
    };
671
    };
671
 
672
 
Line 672... Line 673...
672
    img_base = create_image(raw_img);
673
    img_base = create_image(raw_img);
Line 795... Line 796...
795
    free(module->img_name);
796
    free(module->img_name);
796
    free(module->img_path);
797
    free(module->img_path);
797
    free(module);
798
    free(module);
798
err1:
799
err1:
799
    user_free(img_base);
800
    _ksys_free(img_base);
800
    return NULL;
801
    return NULL;
801
};
802
};
802
 
803
 
Line 803... Line 804...
803
void enumerate_libraries(int (*callback)(void *handle, const char* name,
804
void enumerate_libraries(int (*callback)(void *handle, const char* name,
804
                                         uint32_t base, uint32_t size, void *user_data),
805
                                         uint32_t base, uint32_t size, void *user_data),